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