# Dungeon Generator GUI
# Overview
The Dungeon Generator GUI is a tool for creating new dungeons in the game. It allows users to customize various aspects of the dungeon, such as its size, tileset, enemy types, and map generation algorithm. The GUI provides a visual interface for designing and generating dungeons, which can then be added to the game world.
# Files Involved
ui/dungeon_generator_gui.py: The main GUI file that handles user input and calls the dungeon generation functions.core/new_dungeon_generator.py: Generates the dungeon data (tile map, width, height, etc.) based on user-defined parameters.ui/dungeon_gui_scene_generator.py: Generates the dungeon scene file (.py) based on the generated dungeon data.
# GUI Components
- Width and Height: Input fields for specifying the dimensions of the dungeon.
- Tileset: Dropdown menu for selecting the tileset to use for the dungeon.
- Enemy Types: Checkboxes for selecting the enemy types to include in the dungeon.
- Dungeon Name: Input field for specifying the name of the dungeon.
- Portal Graphic: Button for browsing and selecting the portal graphic.
- Map Algorithm: Dropdown menu for selecting the map generation algorithm (Perlin noise or room-based).
- Portal Placement: Dropdown menu for selecting the portal placement method (random or specific).
- Portal X and Y: Input fields for specifying the exact coordinates of the portal (only enabled when “specific” portal placement is selected).
- Decorations: Checkboxes for selecting decorations to add to the dungeon.
- Perlin Noise Threshold: Input field for specifying the Perlin noise threshold (only used when “Perlin noise” map algorithm is selected).
- Generate Dungeon: Button that triggers the dungeon generation process.
- Dungeon Frame: Displays the generated dungeon.
- Toolbar Frame: Contains buttons for placing objects, zooming, panning, and removing the dungeon.
# Dungeon Generation Process
- The user provides input through the GUI components.
- The user clicks the “Generate Dungeon” button.
- The
generate_dungeonfunction inui/dungeon_generator_gui.pyis called. - The
generate_dungeonfunction retrieves the values from the GUI components and passes them to thegenerate_new_dungeonfunction incore/new_dungeon_generator.py. - The
generate_new_dungeonfunction generates the dungeon data (tile map, width, height, etc.) based on the provided parameters. - The
generate_dungeonfunction calls thedisplay_dungeonfunction to display the generated dungeon in the GUI. - The
generate_dungeonfunction prompts the user to enter a filename for the dungeon. - The
generate_dungeonfunction calls thesave_dungeon_datafunction to save the dungeon data to a JSON file and perform other actions.
# Saving the Dungeon Data
- The
save_dungeon_datafunction inui/dungeon_generator_gui.pyis called. - The
save_dungeon_datafunction saves the dungeon data to a JSON file in thedata/dungeonsdirectory. - The
save_dungeon_datafunction calls thegenerate_scene_filefunction inui/dungeon_gui_scene_generator.pyto generate the dungeon scene file. - The
save_dungeon_datafunction calls theadd_scene_to_game_enginefunction inui/dungeon_gui_scene_generator.pyto add the new scene to thedata/scenes.jsonfile. - The
save_dungeon_datafunction calls theadd_portal_to_spawntownfunction inui/dungeon_gui_scene_generator.pyto add a portal to the new dungeon inspawntownin thedata/zone_data.jsonfile.
# Key Functions
generate_new_dungeon(core/new_dungeon_generator.py): Generates the dungeon data based on the provided parameters.generate_scene_file(ui/dungeon_gui_scene_generator.py): Generates the dungeon scene file (.py) based on the generated dungeon data.add_scene_to_game_engine(ui/dungeon_gui_scene_generator.py): Adds the new scene to thedata/scenes.jsonfile.add_portal_to_spawntown(ui/dungeon_gui_scene_generator.py): Adds a portal to the new dungeon inspawntownin thedata/zone_data.jsonfile.find_portal_location(ui/dungeon_gui_scene_generator.py): Finds a suitable location for the portal inspawntownnear existing portals.
# Customization
The dungeon generation process can be customized by modifying the different parameters in the GUI. For example, you can change the size of the dungeon, select a different tileset, choose different enemy types, and use a different map generation algorithm.