File size: 2,331 Bytes
e2a4174
 
 
 
 
 
 
 
 
 
6cab2b0
e2a4174
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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!")