pass to remove issues in cargo check
This commit is contained in:
+2
-4
@@ -263,11 +263,9 @@ impl eframe::App for DungeonApp {
|
||||
(i.key_pressed(egui::Key::Delete) || i.key_pressed(egui::Key::Backspace))
|
||||
&& self.hover_level_idx.is_some()
|
||||
});
|
||||
if level_delete_requested {
|
||||
if let Some(level_idx) = self.hover_level_idx {
|
||||
if level_delete_requested && let Some(level_idx) = self.hover_level_idx {
|
||||
self.delete_level(level_idx);
|
||||
}
|
||||
}
|
||||
|
||||
let resizing = crate::interact::handle_resize(self, ctx, &response, &geometry);
|
||||
if !resizing {
|
||||
@@ -305,7 +303,7 @@ pub fn generate_all_levels(settings: &UiSettings) -> Vec<DungeonLayout> {
|
||||
let level_count = if settings.min_levels == settings.max_levels {
|
||||
settings.min_levels
|
||||
} else {
|
||||
let range_seed = crate::seed::derive_seed(settings.seed, 0x1E_7E_1_u64);
|
||||
let range_seed = crate::seed::derive_seed(settings.seed, 0x0001_E7E1_u64);
|
||||
(range_seed as usize % (settings.max_levels - settings.min_levels + 1))
|
||||
+ settings.min_levels
|
||||
};
|
||||
|
||||
+12
-7
@@ -5,8 +5,9 @@
|
||||
*/
|
||||
|
||||
use super::types::{
|
||||
BG, BLACK, CORRIDOR, DoorStyle, END_MARKER, ExportGeometry, GRID, MONSTER_MARKER, ROOM, STAIRS,
|
||||
START_MARKER, TRAP_MARKER, WHITE, WINDOW_COLOR, door_render_width, norm_edge,
|
||||
BG, BLACK, CORRIDOR, Cell, CellEdge, DoorStyle, END_MARKER, ExportGeometry, GRID,
|
||||
MONSTER_MARKER, ROOM, STAIRS, START_MARKER, TRAP_MARKER, WHITE, WINDOW_COLOR,
|
||||
door_render_width, norm_edge,
|
||||
};
|
||||
use super::utils::{collect_scene_data, door_line_points, window_line_points};
|
||||
use crate::layout::{AreaMarker, DungeonLayout, Room, Staircase, Window};
|
||||
@@ -531,9 +532,9 @@ pub fn draw_room_crosshatch(
|
||||
pub fn draw_cell_walls(
|
||||
pixmap: &mut Pixmap,
|
||||
g: &ExportGeometry,
|
||||
cells: &HashSet<(usize, usize)>,
|
||||
connected_edges: Option<&HashSet<((usize, usize), (usize, usize))>>,
|
||||
door_edges: &HashSet<((usize, usize), (usize, usize))>,
|
||||
cells: &HashSet<Cell>,
|
||||
connected_edges: Option<&HashSet<CellEdge>>,
|
||||
door_edges: &HashSet<CellEdge>,
|
||||
width: f32,
|
||||
color: (u8, u8, u8, u8),
|
||||
) {
|
||||
@@ -683,6 +684,7 @@ pub fn draw_window(
|
||||
draw_line(pixmap, x1, y1, x2, y2, width, color, style);
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn draw_line(
|
||||
pixmap: &mut Pixmap,
|
||||
x1: f32,
|
||||
@@ -705,6 +707,7 @@ pub fn draw_line(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn stroke_path(
|
||||
pixmap: &mut Pixmap,
|
||||
x1: f32,
|
||||
@@ -725,8 +728,10 @@ pub fn stroke_path(
|
||||
let mut paint = Paint::default();
|
||||
paint.set_color_rgba8(color.0, color.1, color.2, color.3);
|
||||
|
||||
let mut stroke = Stroke::default();
|
||||
stroke.width = width;
|
||||
let mut stroke = Stroke {
|
||||
width,
|
||||
..Default::default()
|
||||
};
|
||||
if let Some((dash_len, gap_len)) = dash {
|
||||
stroke.dash = StrokeDash::new(vec![dash_len, gap_len], 0.0);
|
||||
}
|
||||
|
||||
+5
-5
@@ -5,8 +5,8 @@
|
||||
*/
|
||||
|
||||
use super::types::{
|
||||
BG, CORRIDOR, END_MARKER, ExportGeometry, GRID, MONSTER_MARKER, ROOM, START_MARKER,
|
||||
TRAP_MARKER, WINDOW_COLOR, door_render_width, norm_edge,
|
||||
BG, CORRIDOR, Cell, CellEdge, END_MARKER, ExportGeometry, GRID, MONSTER_MARKER, ROOM,
|
||||
START_MARKER, TRAP_MARKER, WINDOW_COLOR, door_render_width, norm_edge,
|
||||
};
|
||||
use super::utils::{collect_scene_data, door_line_points, window_line_points};
|
||||
use crate::layout::DungeonLayout;
|
||||
@@ -256,9 +256,9 @@ pub fn build_svg(layout: &DungeonLayout, settings: &UiSettings) -> String {
|
||||
pub fn append_svg_walls(
|
||||
out: &mut String,
|
||||
g: &ExportGeometry,
|
||||
cells: &HashSet<(usize, usize)>,
|
||||
connected_edges: Option<&HashSet<((usize, usize), (usize, usize))>>,
|
||||
door_edges: &HashSet<((usize, usize), (usize, usize))>,
|
||||
cells: &HashSet<Cell>,
|
||||
connected_edges: Option<&HashSet<CellEdge>>,
|
||||
door_edges: &HashSet<CellEdge>,
|
||||
width: f32,
|
||||
) {
|
||||
for &(col, row) in cells {
|
||||
|
||||
+10
-11
@@ -9,6 +9,9 @@ use std::collections::HashSet;
|
||||
use std::path::PathBuf;
|
||||
use tiny_skia::Rect;
|
||||
|
||||
pub type Cell = (usize, usize);
|
||||
pub type CellEdge = (Cell, Cell);
|
||||
|
||||
pub const BG: (u8, u8, u8, u8) = (24, 24, 26, 255);
|
||||
pub const GRID: (u8, u8, u8, u8) = (130, 130, 130, 255);
|
||||
pub const ROOM: (u8, u8, u8, u8) = (70, 120, 160, 255);
|
||||
@@ -105,11 +108,11 @@ impl ExportGeometry {
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct SceneData {
|
||||
pub corridor_cells: HashSet<(usize, usize)>,
|
||||
pub corridor_edges: HashSet<((usize, usize), (usize, usize))>,
|
||||
pub room_cells: HashSet<(usize, usize)>,
|
||||
pub room_edges: HashSet<((usize, usize), (usize, usize))>,
|
||||
pub door_edges: HashSet<((usize, usize), (usize, usize))>,
|
||||
pub corridor_cells: HashSet<Cell>,
|
||||
pub corridor_edges: HashSet<CellEdge>,
|
||||
pub room_cells: HashSet<Cell>,
|
||||
pub room_edges: HashSet<CellEdge>,
|
||||
pub door_edges: HashSet<CellEdge>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
@@ -144,15 +147,11 @@ pub struct CompositeExportContext<'a> {
|
||||
pub door_width: f32,
|
||||
}
|
||||
|
||||
pub fn norm_edge(a: (usize, usize), b: (usize, usize)) -> ((usize, usize), (usize, usize)) {
|
||||
pub fn norm_edge(a: Cell, b: Cell) -> CellEdge {
|
||||
if a <= b { (a, b) } else { (b, a) }
|
||||
}
|
||||
|
||||
pub fn door_edges_for(
|
||||
door: &Door,
|
||||
cols: usize,
|
||||
rows: usize,
|
||||
) -> Vec<((usize, usize), (usize, usize))> {
|
||||
pub fn door_edges_for(door: &Door, cols: usize, rows: usize) -> Vec<CellEdge> {
|
||||
let mut edges = Vec::new();
|
||||
if door.from.0.abs_diff(door.to.0) + door.from.1.abs_diff(door.to.1) != 1 {
|
||||
return edges;
|
||||
|
||||
@@ -55,12 +55,12 @@ pub fn handle_add_tool(app: &mut DungeonApp, response: &egui::Response, geometry
|
||||
drag.current_cell = (grid_x.floor() as usize, grid_y.floor() as usize);
|
||||
}
|
||||
|
||||
if response.drag_stopped() {
|
||||
if let Some(drag) = app.add_corridor_drag.take() {
|
||||
if response.drag_stopped()
|
||||
&& let Some(drag) = app.add_corridor_drag.take()
|
||||
{
|
||||
add_corridor_between(app, drag.start_cell, drag.current_cell);
|
||||
}
|
||||
}
|
||||
}
|
||||
AddTool::Staircase => {
|
||||
app.add_corridor_drag = None;
|
||||
if response.clicked()
|
||||
|
||||
+3
-3
@@ -962,12 +962,12 @@ pub fn draw_resize_overlay(app: &DungeonApp, painter: &egui::Painter, geometry:
|
||||
if let Some(room) = layout.rooms.get(room_idx) {
|
||||
draw_room_resize_visuals(painter, geometry, room, false);
|
||||
}
|
||||
} else if let Some(stair_idx) = app.hover_stair_idx {
|
||||
if let Some(stair) = layout.stairs.get(stair_idx) {
|
||||
} else if let Some(stair_idx) = app.hover_stair_idx
|
||||
&& let Some(stair) = layout.stairs.get(stair_idx)
|
||||
{
|
||||
draw_staircase_resize_visuals(painter, geometry, stair, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_room_resize_visuals(
|
||||
painter: &egui::Painter,
|
||||
|
||||
@@ -23,8 +23,10 @@ pub fn handle_resize(
|
||||
return false;
|
||||
}
|
||||
|
||||
if ctx.input(|i| i.pointer.secondary_pressed()) && app.resize_state.is_none() {
|
||||
if let Some(pointer_pos) = response.interact_pointer_pos() {
|
||||
if ctx.input(|i| i.pointer.secondary_pressed())
|
||||
&& app.resize_state.is_none()
|
||||
&& let Some(pointer_pos) = response.interact_pointer_pos()
|
||||
{
|
||||
if let Some(text_idx) = text_at_pointer(app, pointer_pos, geometry) {
|
||||
if let Some(state) = start_text_resize(app, text_idx) {
|
||||
app.push_undo_snapshot();
|
||||
@@ -37,22 +39,21 @@ pub fn handle_resize(
|
||||
app.resize_state = Some(ResizeState::Staircase(state));
|
||||
return true;
|
||||
}
|
||||
} else if let Some(room_idx) = resize_room_at_pointer(app, pointer_pos, geometry) {
|
||||
if let Some(state) = start_resize(app, room_idx, pointer_pos, geometry) {
|
||||
} else if let Some(room_idx) = resize_room_at_pointer(app, pointer_pos, geometry)
|
||||
&& let Some(state) = start_resize(app, room_idx, pointer_pos, geometry)
|
||||
{
|
||||
app.push_undo_snapshot();
|
||||
app.resize_state = Some(ResizeState::Room(state));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(state) = app.resize_state.clone() {
|
||||
if response.dragged_by(egui::PointerButton::Secondary)
|
||||
&& ctx.input(|i| i.pointer.secondary_down())
|
||||
&& let Some(pointer_pos) = response.interact_pointer_pos()
|
||||
&& let Some((grid_x, grid_y)) = pointer_to_grid(pointer_pos, geometry)
|
||||
{
|
||||
if let Some((grid_x, grid_y)) = pointer_to_grid(pointer_pos, geometry) {
|
||||
let cell = (grid_x.floor() as usize, grid_y.floor() as usize);
|
||||
match state {
|
||||
ResizeState::Room(state) => resize_room(app, &state, cell),
|
||||
@@ -60,7 +61,6 @@ pub fn handle_resize(
|
||||
ResizeState::Staircase(state) => resize_staircase(app, &state, cell),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ctx.input(|i| i.pointer.button_released(egui::PointerButton::Secondary)) {
|
||||
app.resize_state = None;
|
||||
|
||||
@@ -10,6 +10,10 @@ use super::super::utils::{
|
||||
};
|
||||
use std::collections::HashSet;
|
||||
|
||||
pub type Cell = (usize, usize);
|
||||
pub type CellEdge = (Cell, Cell);
|
||||
pub type RoomBoundary = (usize, usize, Vec<CellEdge>);
|
||||
|
||||
pub fn build_room_connection_edges(
|
||||
centers: &[(usize, usize)],
|
||||
randomness: f32,
|
||||
@@ -176,9 +180,7 @@ pub fn room_collision_edges(
|
||||
edges
|
||||
}
|
||||
|
||||
pub fn shared_room_boundaries(
|
||||
rooms: &[Room],
|
||||
) -> Vec<(usize, usize, Vec<((usize, usize), (usize, usize))>)> {
|
||||
pub fn shared_room_boundaries(rooms: &[Room]) -> Vec<RoomBoundary> {
|
||||
let mut boundaries = Vec::new();
|
||||
for a_idx in 0..rooms.len() {
|
||||
for b_idx in (a_idx + 1)..rooms.len() {
|
||||
|
||||
@@ -120,6 +120,7 @@ pub fn marker_in_room(
|
||||
AreaMarker { cell: (x, y), size }
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn assign_extra_markers(
|
||||
markers: &mut Vec<AreaMarker>,
|
||||
rooms: &[Room],
|
||||
@@ -399,7 +400,7 @@ pub fn get_stair_count(settings: &UiSettings, gap_idx: usize) -> usize {
|
||||
if settings.min_stairs_per_level == settings.max_stairs_per_level {
|
||||
settings.min_stairs_per_level
|
||||
} else {
|
||||
let range_seed = seed::derive_seed(settings.seed, 0x2A_3B_4_u64 + gap_idx as u64);
|
||||
let range_seed = seed::derive_seed(settings.seed, 0x0002_A3B4_u64 + gap_idx as u64);
|
||||
(range_seed as usize % (settings.max_stairs_per_level - settings.min_stairs_per_level + 1))
|
||||
+ settings.min_stairs_per_level
|
||||
}
|
||||
@@ -460,18 +461,14 @@ pub fn ensure_stair_in_room(layout: &mut DungeonLayout, stair: &Staircase) -> bo
|
||||
pub fn room_to_stair_min_dist(room: &Room, stair: &Staircase) -> usize {
|
||||
let dx = if stair.cell.0 + stair.width <= room.x {
|
||||
room.x - (stair.cell.0 + stair.width)
|
||||
} else if stair.cell.0 >= room.x + room.width {
|
||||
stair.cell.0 - (room.x + room.width)
|
||||
} else {
|
||||
0
|
||||
stair.cell.0.saturating_sub(room.x + room.width)
|
||||
};
|
||||
|
||||
let dy = if stair.cell.1 + stair.height <= room.y {
|
||||
room.y - (stair.cell.1 + stair.height)
|
||||
} else if stair.cell.1 >= room.y + room.height {
|
||||
stair.cell.1 - (room.y + room.height)
|
||||
} else {
|
||||
0
|
||||
stair.cell.1.saturating_sub(room.y + room.height)
|
||||
};
|
||||
|
||||
dx + dy
|
||||
|
||||
@@ -18,6 +18,7 @@ pub use markers::*;
|
||||
pub use passages::*;
|
||||
pub use room_placement::*;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn generate_layout(
|
||||
cols: usize,
|
||||
rows: usize,
|
||||
|
||||
@@ -44,8 +44,9 @@ pub fn apply_doors(
|
||||
let start_room = &layout.rooms[corridor.start_room_id];
|
||||
let end_room = &layout.rooms[corridor.end_room_id];
|
||||
|
||||
if let Some(edge) = room_exit_edge(&corridor.path, start_room, true) {
|
||||
if seen_edges.insert(edge) {
|
||||
if let Some(edge) = room_exit_edge(&corridor.path, start_room, true)
|
||||
&& seen_edges.insert(edge)
|
||||
{
|
||||
let place_door = door_chance > 0.0 && rng.next_f32() <= door_chance;
|
||||
layout.doors.push(Door {
|
||||
from: edge.0,
|
||||
@@ -58,10 +59,10 @@ pub fn apply_doors(
|
||||
manual: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(edge) = room_exit_edge(&corridor.path, end_room, false) {
|
||||
if seen_edges.insert(edge) {
|
||||
if let Some(edge) = room_exit_edge(&corridor.path, end_room, false)
|
||||
&& seen_edges.insert(edge)
|
||||
{
|
||||
let place_door = door_chance > 0.0 && rng.next_f32() <= door_chance;
|
||||
layout.doors.push(Door {
|
||||
from: edge.0,
|
||||
@@ -74,7 +75,6 @@ pub fn apply_doors(
|
||||
manual: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (room_idx, room) in layout.rooms.iter().enumerate() {
|
||||
if room_idx == corridor.start_room_id || room_idx == corridor.end_room_id {
|
||||
@@ -404,6 +404,7 @@ pub fn collect_window_segments(
|
||||
segments
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn collect_room_side_segments(
|
||||
room_idx: usize,
|
||||
room: &Room,
|
||||
|
||||
@@ -143,8 +143,8 @@ pub fn placement_order(room_count: usize, room_edges: &[(usize, usize)]) -> Vec<
|
||||
}
|
||||
}
|
||||
|
||||
for idx in 0..room_count {
|
||||
if !visited[idx] {
|
||||
for (idx, was_visited) in visited.iter().enumerate().take(room_count) {
|
||||
if !was_visited {
|
||||
order.push(idx);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-19
@@ -98,7 +98,7 @@ pub struct WindowSettings {
|
||||
pub allow_internal_windows: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
pub struct DungeonLayout {
|
||||
pub rooms: Vec<Room>,
|
||||
pub corridors: Vec<Corridor>,
|
||||
@@ -113,24 +113,6 @@ pub struct DungeonLayout {
|
||||
pub stairs: Vec<Staircase>,
|
||||
}
|
||||
|
||||
impl Default for DungeonLayout {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
rooms: Vec::new(),
|
||||
corridors: Vec::new(),
|
||||
doors: Vec::new(),
|
||||
windows: Vec::new(),
|
||||
text_labels: Vec::new(),
|
||||
start_markers: Vec::new(),
|
||||
end_markers: Vec::new(),
|
||||
trap_markers: Vec::new(),
|
||||
monster_markers: Vec::new(),
|
||||
packed_rooms: false,
|
||||
stairs: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DungeonLayout {
|
||||
// Build an empty layout for the current packing mode.
|
||||
pub(crate) fn empty(packed_rooms: bool) -> Self {
|
||||
|
||||
@@ -218,6 +218,7 @@ pub fn overlaps_with_padding(a: &Room, b: &Room, padding: usize) -> bool {
|
||||
a_left < b_right && a_right > b_left && a_top < b_bottom && a_bottom > b_top
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn rects_overlap(
|
||||
ax: usize,
|
||||
ay: usize,
|
||||
|
||||
@@ -430,6 +430,7 @@ pub fn draw_area_marker(
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn draw_area_marker_group(
|
||||
painter: &egui::Painter,
|
||||
geometry: &GridGeometry,
|
||||
|
||||
Reference in New Issue
Block a user