added comments to clearify what is in each rust file
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Contains the core DungeonApp struct and its eframe::App implementation.
|
||||||
|
* This file manages the application lifecycle, main state, undo/redo stacks,
|
||||||
|
* and high-level level management (generation, deletion, and refreshing).
|
||||||
|
*/
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::mpsc;
|
use std::sync::mpsc;
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Image and vector export module.
|
||||||
|
* Handles building SVG representations of dungeon levels and
|
||||||
|
* exporting them to various formats (PNG, JPEG, WebP, SVG)
|
||||||
|
* via a background thread to maintain UI responsiveness.
|
||||||
|
*/
|
||||||
|
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::fmt::Write as _;
|
use std::fmt::Write as _;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|||||||
@@ -1,3 +1,12 @@
|
|||||||
|
/*
|
||||||
|
* Manages user interaction and grid-based logic for the dungeon canvas.
|
||||||
|
* Includes logic for:
|
||||||
|
* - Dragging and moving rooms, corridors, markers, and text.
|
||||||
|
* - Resizing rooms, text, and staircases.
|
||||||
|
* - Handling "Add" tool operations (placing new rooms, doors, etc.).
|
||||||
|
* - Hit testing and hover detection for all dungeon elements.
|
||||||
|
*/
|
||||||
|
|
||||||
use crate::app::{DungeonApp, ManualDoorKind};
|
use crate::app::{DungeonApp, ManualDoorKind};
|
||||||
use crate::layout::{
|
use crate::layout::{
|
||||||
self, blocked_room_cells, corridor_cells, rects_overlap, room_index_at_cell, rooms_overlap,
|
self, blocked_room_cells, corridor_cells, rects_overlap, room_index_at_cell, rooms_overlap,
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* High-level procedural generation algorithms.
|
||||||
|
* Contains the logic for building room connection graphs,
|
||||||
|
* placing packed rooms, and populating random markers, traps,
|
||||||
|
* monsters, and staircase transitions between levels.
|
||||||
|
*/
|
||||||
|
|
||||||
use super::types::{
|
use super::types::{
|
||||||
AreaMarker, Corridor, Door, DoorSettings, DungeonLayout, Room, Staircase, Window,
|
AreaMarker, Corridor, Door, DoorSettings, DungeonLayout, Room, Staircase, Window,
|
||||||
WindowSettings, WindowSide,
|
WindowSettings, WindowSide,
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
pub mod generation;
|
pub mod generation;
|
||||||
|
/*
|
||||||
|
* Public entry point for the layout module.
|
||||||
|
* Exports types, utilities, and generation algorithms used to build
|
||||||
|
* the dungeon structure.
|
||||||
|
*/
|
||||||
|
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Core data structures for the dungeon layout.
|
||||||
|
* Defines structs for Rooms, Corridors, Doors, Windows, Stairs,
|
||||||
|
* TextLabels, and the master DungeonLayout container.
|
||||||
|
*/
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Geometric utilities and low-level layout helpers.
|
||||||
|
* Provides logic for Manhattan distance, room overlap testing,
|
||||||
|
* BFS-based shortest pathfinding, and custom deterministic RNG.
|
||||||
|
*/
|
||||||
|
|
||||||
use super::types::{DungeonLayout, Room};
|
use super::types::{DungeonLayout, Room};
|
||||||
use std::collections::{HashSet, VecDeque};
|
use std::collections::{HashSet, VecDeque};
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Entry point for the Desktop Dungeon Generator.
|
||||||
|
* Handles application initialization, module declarations,
|
||||||
|
* and starts the eframe/egui event loop.
|
||||||
|
*/
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
mod exporter;
|
mod exporter;
|
||||||
mod interact;
|
mod interact;
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Canvas drawing logic for the dungeon layout.
|
||||||
|
* Provides functions to render rooms, corridors, walls, doors, windows,
|
||||||
|
* and various markers using egui's Painter API.
|
||||||
|
*/
|
||||||
|
|
||||||
use crate::interact::{
|
use crate::interact::{
|
||||||
GridGeometry, HoverMarker, MarkerKind, cell_center, cell_rect, door_edges_for,
|
GridGeometry, HoverMarker, MarkerKind, cell_center, cell_rect, door_edges_for,
|
||||||
door_render_width, marker_rect, normalized_edge, window_render_width,
|
door_render_width, marker_rect, normalized_edge, window_render_width,
|
||||||
|
|||||||
@@ -3,6 +3,12 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Persistence logic for dungeon state.
|
||||||
|
* Handles saving and loading the complete dungeon state
|
||||||
|
* (settings and layout data) to and from disk using JSON.
|
||||||
|
*/
|
||||||
|
|
||||||
use crate::layout::DungeonLayout;
|
use crate::layout::DungeonLayout;
|
||||||
use crate::ui::UiSettings;
|
use crate::ui::UiSettings;
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Deterministic seed management.
|
||||||
|
* Provides functions to generate random master seeds and
|
||||||
|
* derive sub-seeds for specific procedural generation steps.
|
||||||
|
*/
|
||||||
|
|
||||||
use std::time::{SystemTime, UNIX_EPOCH};
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
// Generate a random master seed from time and process id.
|
// Generate a random master seed from time and process id.
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Application-level persistent configuration.
|
||||||
|
* Manages the loading and saving of UiSettings to the system's
|
||||||
|
* local data directory.
|
||||||
|
*/
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* The primary UI module. Defines the UiSettings structure and
|
||||||
|
* manages the side panel layout, legend panel, and level selection tabs.
|
||||||
|
* Serves as the entry point for all UI-related rendering.
|
||||||
|
*/
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
use super::{AddTool, ExportFormat, MaskFormat, SidePanelResult, UiSettings};
|
use super::{AddTool, ExportFormat, MaskFormat, SidePanelResult, UiSettings};
|
||||||
|
/*
|
||||||
|
* Individual tab rendering logic for the side panel.
|
||||||
|
* Contains functions for drawing the "Generate", "Layout", "Add",
|
||||||
|
* "Start & End", and "Monsters & Traps" control panels.
|
||||||
|
*/
|
||||||
|
|
||||||
use crate::seed;
|
use crate::seed;
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::RichText;
|
use egui::RichText;
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Reusable UI components and drawing helpers.
|
||||||
|
* Includes logic for legend entries (standard and colorblind-friendly)
|
||||||
|
* and custom line styling (dashed, dotted, dash-dot patterns).
|
||||||
|
*/
|
||||||
|
|
||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
use egui::{Color32, Stroke};
|
use egui::{Color32, Stroke};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user