summaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-11-14 09:51:12 -0500
committerFreya Murphy <freya@freyacat.org>2025-11-14 09:51:12 -0500
commit7b78c39cb604961564b1d4e0a491eafacc85e8cb (patch)
tree8618f2a4fc76a389bcabdeb94ff46ab6d74b1d77 /graphics
parentdungeon: refactor manual drop (diff)
downloadDungeonCrawl-7b78c39cb604961564b1d4e0a491eafacc85e8cb.tar.gz
DungeonCrawl-7b78c39cb604961564b1d4e0a491eafacc85e8cb.tar.bz2
DungeonCrawl-7b78c39cb604961564b1d4e0a491eafacc85e8cb.zip
Enable more clippy lints
Diffstat (limited to 'graphics')
-rw-r--r--graphics/src/lib.rs32
-rw-r--r--graphics/src/render.rs20
-rw-r--r--graphics/src/timer.rs2
3 files changed, 27 insertions, 27 deletions
diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs
index 2633e8d..b42845c 100644
--- a/graphics/src/lib.rs
+++ b/graphics/src/lib.rs
@@ -89,36 +89,42 @@ pub struct WindowBuilder<'a> {
}
impl<'a> WindowBuilder<'a> {
/// Default window builder
- pub fn new() -> Self {
- Self::default()
+ pub const fn new() -> Self {
+ Self {
+ title: "Dungeon Crawl",
+ width: render::RENDER_WIDTH,
+ height: render::RENDER_HEIGHT,
+ vsync: false,
+ verbose: false,
+ }
}
/// Set the window title
- pub fn title(&mut self, title: &'a str) -> &mut Self {
+ pub const fn title(&mut self, title: &'a str) -> &mut Self {
self.title = title;
self
}
/// Set the default window width
- pub fn width(&mut self, width: u16) -> &mut Self {
+ pub const fn width(&mut self, width: u16) -> &mut Self {
self.width = width;
self
}
/// Set the default window height
- pub fn height(&mut self, height: u16) -> &mut Self {
+ pub const fn height(&mut self, height: u16) -> &mut Self {
self.height = height;
self
}
/// Toggle vsync support
- pub fn vsync(&mut self, vsync: bool) -> &mut Self {
+ pub const fn vsync(&mut self, vsync: bool) -> &mut Self {
self.vsync = vsync;
self
}
/// Toggle verbose logging
- pub fn verbose(&mut self, verbose: bool) -> &mut Self {
+ pub const fn verbose(&mut self, verbose: bool) -> &mut Self {
self.verbose = verbose;
self
}
@@ -164,13 +170,7 @@ impl<'a> WindowBuilder<'a> {
}
impl Default for WindowBuilder<'_> {
fn default() -> Self {
- Self {
- title: "Dungeon Crawl",
- width: render::RENDER_WIDTH,
- height: render::RENDER_HEIGHT,
- vsync: false,
- verbose: false,
- }
+ Self::new()
}
}
@@ -198,7 +198,7 @@ impl Window {
}
/// Toggles the debug UI
- pub fn toggle_debug(&mut self) {
+ pub const fn toggle_debug(&mut self) {
self.renderer.toggle_debug();
}
@@ -228,7 +228,7 @@ impl Window {
}
/// Get audio data for the window
- pub fn audio(&self) -> &Audio {
+ pub const fn audio(&self) -> &Audio {
&self.audio
}
}
diff --git a/graphics/src/render.rs b/graphics/src/render.rs
index d450f16..bfd9e37 100644
--- a/graphics/src/render.rs
+++ b/graphics/src/render.rs
@@ -148,7 +148,7 @@ impl Textures {
})
}
- fn item_texture(&self, _item: &Item) -> &Texture2D {
+ const fn item_texture(&self, _item: Item) -> &Texture2D {
// TODO: make item textures
&self.error
}
@@ -201,7 +201,7 @@ impl Renderer {
})
}
- pub fn toggle_debug(&mut self) {
+ pub const fn toggle_debug(&mut self) {
self.debug = !self.debug;
}
@@ -254,11 +254,11 @@ impl Renderer {
// Restore the fb
self.framebuffer = Some(fb);
- };
+ }
}
/// Draws the game dungeon
- fn draw_dungeon<R>(&mut self, r: &mut R, dungeon: &Dungeon)
+ fn draw_dungeon<R>(&self, r: &mut R, dungeon: &Dungeon)
where
R: RaylibDraw + RaylibMode2DExt,
{
@@ -280,7 +280,7 @@ impl Renderer {
{
// Textures are up to date
return;
- };
+ }
self.tiles_hash = Some(current_hash);
self.update_fg_tilemap(r, t, floor);
@@ -302,7 +302,7 @@ impl Renderer {
// fg layer only draws a top walls
if floor.get(pos) != Tile::Wall {
continue;
- };
+ }
// draw base wall top texture
rt.draw_atlas(
@@ -476,7 +476,7 @@ impl Renderer {
}
/// Draws player HP, inventory, and floor number
- fn draw_ui<R>(&mut self, r: &mut R, dungeon: &Dungeon)
+ fn draw_ui<R>(&self, r: &mut R, dungeon: &Dungeon)
where
R: RaylibDraw,
{
@@ -586,7 +586,7 @@ impl Renderer {
);
if let Some(item) = player.inventory.get(idx as usize) {
- let tex = self.textures.item_texture(item);
+ let tex = self.textures.item_texture(*item);
const ITEM_PADDDING: u16 = UI_PADDING * 3;
let dest_rec = rect! {
slot_x + ITEM_PADDDING/2,
@@ -607,7 +607,7 @@ impl Renderer {
}
/// Draw player health & equpped weapon damage
- fn draw_stats<R>(&mut self, r: &mut R, player: &Player)
+ fn draw_stats<R>(&self, r: &mut R, player: &Player)
where
R: RaylibDraw,
{
@@ -645,7 +645,7 @@ impl Renderer {
}
/// Draws debug information ontop of other UI elements
- fn draw_debug_ui<R>(&mut self, r: &mut R, dungeon: &Dungeon)
+ fn draw_debug_ui<R>(&self, r: &mut R, dungeon: &Dungeon)
where
R: RaylibDraw,
{
diff --git a/graphics/src/timer.rs b/graphics/src/timer.rs
index 8310776..a8317c7 100644
--- a/graphics/src/timer.rs
+++ b/graphics/src/timer.rs
@@ -52,7 +52,7 @@ impl Timer {
self.count += 1;
}
- pub fn get_frame(&self) -> u32 {
+ pub const fn get_frame(&self) -> u32 {
self.count
}