revert: remove camera zoom, keep day/night + tooltip + crosshair

Zoom caused buffer reallocation issues and cursor misalignment.
Removed: char_size field, adjust_zoom(), MIN/MAX_CHAR, zoom input.
Kept: day/night cycle, tooltip, crosshair, cell_pixel_size() (returns constant 8).
This commit is contained in:
Emil
2026-06-22 19:45:09 +03:00
parent 69e3a6578e
commit 4a89612081
5 changed files with 6 additions and 67 deletions
-1
View File
@@ -88,7 +88,6 @@ GPU (`--mode ascii` / `--mode graphics`):
- `r` — drop first inventory item
- `1``0` / `x` — paint material brush
- `y` / `u` / `i` / `o` — move camera offset
- `+` / `-` — zoom in / out
- `m` — toggle audio
- `q` / `esc` — quit
-14
View File
@@ -72,7 +72,6 @@ trait GpuRenderer {
);
fn grid_w(&self) -> usize;
fn grid_h(&self) -> usize;
fn adjust_zoom(&mut self, delta: i32);
fn cell_pixel_size(&self) -> u32;
}
@@ -100,9 +99,6 @@ impl GpuRenderer for verbatim::render::vulkan::VulkanRenderer {
fn grid_h(&self) -> usize {
verbatim::render::vulkan::VulkanRenderer::grid_h(self)
}
fn adjust_zoom(&mut self, delta: i32) {
verbatim::render::vulkan::VulkanRenderer::adjust_zoom(self, delta)
}
fn cell_pixel_size(&self) -> u32 {
verbatim::render::vulkan::VulkanRenderer::cell_pixel_size(self)
}
@@ -132,9 +128,6 @@ impl GpuRenderer for verbatim::render::graphics::GraphicsRenderer {
fn grid_h(&self) -> usize {
verbatim::render::graphics::GraphicsRenderer::grid_h(self)
}
fn adjust_zoom(&mut self, delta: i32) {
verbatim::render::graphics::GraphicsRenderer::adjust_zoom(self, delta)
}
fn cell_pixel_size(&self) -> u32 {
verbatim::render::graphics::GraphicsRenderer::cell_pixel_size(self)
}
@@ -327,13 +320,6 @@ fn run_gpu_mode<R: GpuRenderer>(title: &str) {
game.audio.toggle();
}
if input.zoom_in {
renderer.adjust_zoom(-2);
}
if input.zoom_out {
renderer.adjust_zoom(2);
}
if input.jump {
let on_ground = game.check_on_ground();
if on_ground {
+3 -17
View File
@@ -12,8 +12,6 @@ const CHAR_W: u32 = 8;
const CHAR_H: u32 = 8;
const UI_CELL_SIZE: u32 = 2;
const MAX_FRAMES: usize = 2;
const MIN_CHAR: u32 = 4;
const MAX_CHAR: u32 = 24;
fn entity_priority(kind: crate::entity::EntityKind) -> u32 {
use crate::entity::EntityKind;
@@ -75,7 +73,6 @@ struct PushConstants {
pub struct GraphicsRenderer {
grid_w: usize,
grid_h: usize,
char_size: u32,
entry: ash::Entry,
instance: ash::Instance,
@@ -712,7 +709,6 @@ impl GraphicsRenderer {
Ok(Self {
grid_w,
grid_h,
char_size: CHAR_W,
entry,
instance,
surface,
@@ -1115,18 +1111,8 @@ impl GraphicsRenderer {
self.grid_h
}
pub fn adjust_zoom(&mut self, delta: i32) {
let new_size =
(self.char_size as i32 + delta).clamp(MIN_CHAR as i32, MAX_CHAR as i32) as u32;
if new_size == self.char_size {
return;
}
self.char_size = new_size;
self.check_resize();
}
pub fn cell_pixel_size(&self) -> u32 {
self.char_size
CHAR_W
}
fn check_resize(&mut self) {
@@ -1253,8 +1239,8 @@ impl GraphicsRenderer {
};
// Reallocate instance buffer if grid size changed
let new_grid_w = (new_extent.width / self.char_size) as usize;
let new_grid_h = (new_extent.height / self.char_size) as usize;
let new_grid_w = (new_extent.width / CHAR_W) as usize;
let new_grid_h = (new_extent.height / CHAR_H) as usize;
let new_count = new_grid_w * new_grid_h;
if new_count != self.instance_count {
+3 -17
View File
@@ -12,8 +12,6 @@ use crate::world::grid::{MAX_WORLD_H, MAX_WORLD_W};
const CHAR_W: u32 = 8;
const CHAR_H: u32 = 8;
const UI_CELL_SIZE: u32 = 2;
const MIN_CHAR: u32 = 4;
const MAX_CHAR: u32 = 24;
const ATLAS_COLS: usize = 16;
const ATLAS_ROWS: usize = 8;
const ATLAS_W: u32 = (ATLAS_COLS as u32) * CHAR_W;
@@ -84,7 +82,6 @@ struct PushConstants {
pub struct VulkanRenderer {
grid_w: usize,
grid_h: usize,
char_size: u32,
entry: ash::Entry,
instance: ash::Instance,
@@ -279,7 +276,6 @@ impl VulkanRenderer {
Ok(Self {
grid_w,
grid_h,
char_size: CHAR_W,
entry,
instance,
surface,
@@ -712,18 +708,8 @@ impl VulkanRenderer {
self.grid_h
}
pub fn adjust_zoom(&mut self, delta: i32) {
let new_size =
(self.char_size as i32 + delta).clamp(MIN_CHAR as i32, MAX_CHAR as i32) as u32;
if new_size == self.char_size {
return;
}
self.char_size = new_size;
self.check_resize();
}
pub fn cell_pixel_size(&self) -> u32 {
self.char_size
CHAR_W
}
fn check_resize(&mut self) {
@@ -846,8 +832,8 @@ impl VulkanRenderer {
.expect("cmd_bufs")
};
let new_grid_w = (new_extent.width / self.char_size) as usize;
let new_grid_h = (new_extent.height / self.char_size) as usize;
let new_grid_w = (new_extent.width / CHAR_W) as usize;
let new_grid_h = (new_extent.height / CHAR_H) as usize;
let new_count = new_grid_w * new_grid_h;
if new_count != self.instance_count {
-18
View File
@@ -19,8 +19,6 @@ pub struct WindowInput {
pub cam_down: bool,
pub quit: bool,
pub toggle_audio: bool,
pub zoom_in: bool,
pub zoom_out: bool,
pub paint: Option<u8>,
pub mouse_x: f64,
pub mouse_y: f64,
@@ -43,8 +41,6 @@ pub struct WindowInput {
use_item_was_down: bool,
drop_item_was_down: bool,
audio_was_down: bool,
zoom_in_was_down: bool,
zoom_out_was_down: bool,
down_keys: HashSet<KeyCode>,
}
@@ -68,8 +64,6 @@ impl WindowInput {
cam_down: false,
quit: false,
toggle_audio: false,
zoom_in: false,
zoom_out: false,
paint: None,
mouse_x: 0.0,
mouse_y: 0.0,
@@ -92,8 +86,6 @@ impl WindowInput {
use_item_was_down: false,
drop_item_was_down: false,
audio_was_down: false,
zoom_in_was_down: false,
zoom_out_was_down: false,
down_keys: HashSet::new(),
}
}
@@ -214,20 +206,10 @@ impl WindowInput {
self.cam_up = keys.contains(&KeyCode::KeyI);
self.cam_down = keys.contains(&KeyCode::KeyO);
self.quit = keys.contains(&KeyCode::KeyQ) || keys.contains(&KeyCode::Escape);
let now_audio = keys.contains(&KeyCode::KeyM);
self.toggle_audio = now_audio && !self.audio_was_down;
self.audio_was_down = now_audio;
let now_zoom_in = keys.contains(&KeyCode::Equal) || keys.contains(&KeyCode::NumpadAdd);
self.zoom_in = now_zoom_in && !self.zoom_in_was_down;
self.zoom_in_was_down = now_zoom_in;
let now_zoom_out =
keys.contains(&KeyCode::Minus) || keys.contains(&KeyCode::NumpadSubtract);
self.zoom_out = now_zoom_out && !self.zoom_out_was_down;
self.zoom_out_was_down = now_zoom_out;
self.paint = None;
if keys.contains(&KeyCode::Digit1) {
self.paint = Some(1);