added a composition mode, to turn off auto generation
This commit is contained in:
+37
-2
@@ -89,8 +89,12 @@ impl Default for DungeonApp {
|
||||
hover_level_idx: None,
|
||||
hover_stair_idx: None,
|
||||
};
|
||||
if app.settings.composition_mode {
|
||||
app.enter_composition_layout();
|
||||
} else {
|
||||
app.levels = generate_all_levels(&app.settings);
|
||||
app.refresh_stairs();
|
||||
}
|
||||
app
|
||||
}
|
||||
}
|
||||
@@ -136,7 +140,14 @@ impl eframe::App for DungeonApp {
|
||||
if panel_result.clear_clicked {
|
||||
self.push_undo_snapshot();
|
||||
self.clear_layout();
|
||||
} else if panel_result.reset_clicked || panel_result.settings_changed {
|
||||
} else if panel_result.reset_clicked {
|
||||
self.push_undo_snapshot();
|
||||
if self.settings.composition_mode {
|
||||
self.enter_composition_layout();
|
||||
} else {
|
||||
self.regenerate_layout();
|
||||
}
|
||||
} else if panel_result.settings_changed && !self.settings.composition_mode {
|
||||
self.push_undo_snapshot();
|
||||
self.regenerate_layout();
|
||||
} else if panel_result.save_clicked {
|
||||
@@ -164,9 +175,15 @@ impl eframe::App for DungeonApp {
|
||||
}
|
||||
} else if panel_result.new_level_clicked {
|
||||
self.push_undo_snapshot();
|
||||
if self.settings.composition_mode {
|
||||
self.levels.push(DungeonLayout::empty(
|
||||
self.settings.pack_rooms_without_corridors,
|
||||
));
|
||||
} else {
|
||||
self.levels
|
||||
.push(generate_level(&self.settings, self.levels.len()));
|
||||
self.refresh_stairs();
|
||||
}
|
||||
self.settings.active_level_index = self.levels.len() - 1;
|
||||
}
|
||||
if ctx.input(|i| i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace)) {
|
||||
@@ -237,7 +254,14 @@ impl eframe::App for DungeonApp {
|
||||
self.export_progress = None;
|
||||
}
|
||||
|
||||
draw_legend_panel(ctx, &mut self.settings.colorblind_mode);
|
||||
if draw_legend_panel(ctx, &mut self.settings) {
|
||||
self.push_undo_snapshot();
|
||||
if self.settings.composition_mode {
|
||||
self.enter_composition_layout();
|
||||
} else {
|
||||
self.regenerate_layout();
|
||||
}
|
||||
}
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
// Clear level hover state so it only reflects current frame.
|
||||
@@ -444,6 +468,17 @@ impl DungeonApp {
|
||||
self.reset_transient_state();
|
||||
}
|
||||
|
||||
// Start composition mode with one empty level.
|
||||
fn enter_composition_layout(&mut self) {
|
||||
self.levels = vec![DungeonLayout::empty(
|
||||
self.settings.pack_rooms_without_corridors,
|
||||
)];
|
||||
self.settings.active_level_index = 0;
|
||||
self.settings.export_level_index = 0;
|
||||
self.suppressed_auto_door_edges.clear();
|
||||
self.reset_transient_state();
|
||||
}
|
||||
|
||||
// Regenerate the dungeon layout from current settings and reset drag state.
|
||||
fn regenerate_layout(&mut self) {
|
||||
self.drag_state = None;
|
||||
|
||||
@@ -125,6 +125,7 @@ pub struct UiSettings {
|
||||
pub room_hallway_window_percent: usize,
|
||||
pub allow_internal_windows: bool,
|
||||
pub colorblind_mode: bool,
|
||||
pub composition_mode: bool,
|
||||
pub export_format: ExportFormat,
|
||||
pub mask_format: MaskFormat,
|
||||
pub export_width: u32,
|
||||
@@ -190,6 +191,7 @@ impl Default for UiSettings {
|
||||
room_hallway_window_percent: 10,
|
||||
allow_internal_windows: false,
|
||||
colorblind_mode: false,
|
||||
composition_mode: false,
|
||||
export_format: ExportFormat::Png,
|
||||
mask_format: MaskFormat::Png,
|
||||
export_width: 0,
|
||||
@@ -323,23 +325,28 @@ pub fn draw_side_panel(
|
||||
result
|
||||
}
|
||||
|
||||
// Draw the accessibility and legend panel.
|
||||
pub fn draw_legend_panel(ctx: &egui::Context, colorblind_mode: &mut bool) {
|
||||
// Draw mode controls and the legend panel.
|
||||
pub fn draw_legend_panel(ctx: &egui::Context, settings: &mut UiSettings) -> bool {
|
||||
let mut composition_mode_changed = false;
|
||||
|
||||
egui::SidePanel::right("legend_panel")
|
||||
.resizable(false)
|
||||
.min_width(180.0)
|
||||
.default_width(200.0)
|
||||
.show_separator_line(true)
|
||||
.show(ctx, |ui| {
|
||||
ui.heading("Accessibility");
|
||||
ui.heading("Modes");
|
||||
ui.add_space(6.0);
|
||||
ui.checkbox(colorblind_mode, "Colorblind Mode");
|
||||
ui.checkbox(&mut settings.colorblind_mode, "Colorblind Mode");
|
||||
composition_mode_changed = ui
|
||||
.checkbox(&mut settings.composition_mode, "Composition Mode")
|
||||
.changed();
|
||||
ui.add_space(10.0);
|
||||
ui.separator();
|
||||
ui.add_space(8.0);
|
||||
ui.heading("Legend");
|
||||
ui.add_space(8.0);
|
||||
if *colorblind_mode {
|
||||
if settings.colorblind_mode {
|
||||
draw_legend_entry_colorblind(ui, "Rooms", LegendStyle::Crosshatch);
|
||||
draw_legend_entry_colorblind(ui, "Corridors", LegendStyle::Dots);
|
||||
draw_legend_entry_colorblind(ui, "Walls", LegendStyle::SolidLine);
|
||||
@@ -380,6 +387,8 @@ pub fn draw_legend_panel(ctx: &egui::Context, colorblind_mode: &mut bool) {
|
||||
ui.label("• Right click: Cancel add tool");
|
||||
ui.label("• Right click + drag: Resize hovered room");
|
||||
});
|
||||
|
||||
composition_mode_changed
|
||||
}
|
||||
|
||||
// Draw level tabs and return the hovered tab index.
|
||||
|
||||
Reference in New Issue
Block a user