import streamlit as st import os import random from PIL import Image # Set up the title and description st.title("Dungeon Map Generator") st.write("This app generates random dungeon maps using pre-designed templates or dynamically creates new layouts.") # Directory for map images map_dir = "" # Replace with your actual directory containing .png files # Create layout for map generation and details with st.container(): st.header("Dungeon Map") col1, col2 = st.columns(2) # Display the dungeon map with col1: if os.path.exists(map_dir): # Randomly select a map image map_files = [f for f in os.listdir(map_dir) if f.endswith(".png")] if map_files: selected_map = random.choice(map_files) map_path = os.path.join(map_dir, selected_map) st.image(Image.open(map_path), caption="Generated Dungeon Map") else: st.write("No map images found in the directory.") else: st.write("Map directory does not exist.") # Generate Key and Outline with col2: st.subheader("Map Key") st.write(""" - **V20**: Dining Hall - **V21**: Storage Room - **V22**: Hallway - **V23**: Guard Room - **V24**: Training Room - **V25**: Treasury - **V26**: Throne Room - **V27**: Passageway - **V28**: Crypt - **V29**: Prison - **V30**: Exit Hall - **V31**: Barracks - **V32**: Workshop - **V33**: Common Room - **V34**: Secret Chamber - **V35**: Armory - **V36**: Ritual Room """) # Add an option to dynamically generate maps st.subheader("Generate a New Dungeon") if st.button("Create New Map"): st.write("**Feature coming soon!** Dynamically generating new maps using procedural algorithms.") # Sidebar for user options st.sidebar.title("Options") st.sidebar.write("Select map options or upload your own dungeon map template:") uploaded_file = st.sidebar.file_uploader("Upload a .png map file", type="png") if uploaded_file: with open(os.path.join(map_dir, uploaded_file.name), "wb") as f: f.write(uploaded_file.getbuffer()) st.sidebar.success("File uploaded successfully!")