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:
@@ -88,7 +88,6 @@ GPU (`--mode ascii` / `--mode graphics`):
|
|||||||
- `r` — drop first inventory item
|
- `r` — drop first inventory item
|
||||||
- `1`–`0` / `x` — paint material brush
|
- `1`–`0` / `x` — paint material brush
|
||||||
- `y` / `u` / `i` / `o` — move camera offset
|
- `y` / `u` / `i` / `o` — move camera offset
|
||||||
- `+` / `-` — zoom in / out
|
|
||||||
- `m` — toggle audio
|
- `m` — toggle audio
|
||||||
- `q` / `esc` — quit
|
- `q` / `esc` — quit
|
||||||
|
|
||||||
|
|||||||
-14
@@ -72,7 +72,6 @@ trait GpuRenderer {
|
|||||||
);
|
);
|
||||||
fn grid_w(&self) -> usize;
|
fn grid_w(&self) -> usize;
|
||||||
fn grid_h(&self) -> usize;
|
fn grid_h(&self) -> usize;
|
||||||
fn adjust_zoom(&mut self, delta: i32);
|
|
||||||
fn cell_pixel_size(&self) -> u32;
|
fn cell_pixel_size(&self) -> u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,9 +99,6 @@ impl GpuRenderer for verbatim::render::vulkan::VulkanRenderer {
|
|||||||
fn grid_h(&self) -> usize {
|
fn grid_h(&self) -> usize {
|
||||||
verbatim::render::vulkan::VulkanRenderer::grid_h(self)
|
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 {
|
fn cell_pixel_size(&self) -> u32 {
|
||||||
verbatim::render::vulkan::VulkanRenderer::cell_pixel_size(self)
|
verbatim::render::vulkan::VulkanRenderer::cell_pixel_size(self)
|
||||||
}
|
}
|
||||||
@@ -132,9 +128,6 @@ impl GpuRenderer for verbatim::render::graphics::GraphicsRenderer {
|
|||||||
fn grid_h(&self) -> usize {
|
fn grid_h(&self) -> usize {
|
||||||
verbatim::render::graphics::GraphicsRenderer::grid_h(self)
|
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 {
|
fn cell_pixel_size(&self) -> u32 {
|
||||||
verbatim::render::graphics::GraphicsRenderer::cell_pixel_size(self)
|
verbatim::render::graphics::GraphicsRenderer::cell_pixel_size(self)
|
||||||
}
|
}
|
||||||
@@ -327,13 +320,6 @@ fn run_gpu_mode<R: GpuRenderer>(title: &str) {
|
|||||||
game.audio.toggle();
|
game.audio.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if input.zoom_in {
|
|
||||||
renderer.adjust_zoom(-2);
|
|
||||||
}
|
|
||||||
if input.zoom_out {
|
|
||||||
renderer.adjust_zoom(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if input.jump {
|
if input.jump {
|
||||||
let on_ground = game.check_on_ground();
|
let on_ground = game.check_on_ground();
|
||||||
if on_ground {
|
if on_ground {
|
||||||
|
|||||||
+3
-17
@@ -12,8 +12,6 @@ const CHAR_W: u32 = 8;
|
|||||||
const CHAR_H: u32 = 8;
|
const CHAR_H: u32 = 8;
|
||||||
const UI_CELL_SIZE: u32 = 2;
|
const UI_CELL_SIZE: u32 = 2;
|
||||||
const MAX_FRAMES: usize = 2;
|
const MAX_FRAMES: usize = 2;
|
||||||
const MIN_CHAR: u32 = 4;
|
|
||||||
const MAX_CHAR: u32 = 24;
|
|
||||||
|
|
||||||
fn entity_priority(kind: crate::entity::EntityKind) -> u32 {
|
fn entity_priority(kind: crate::entity::EntityKind) -> u32 {
|
||||||
use crate::entity::EntityKind;
|
use crate::entity::EntityKind;
|
||||||
@@ -75,7 +73,6 @@ struct PushConstants {
|
|||||||
pub struct GraphicsRenderer {
|
pub struct GraphicsRenderer {
|
||||||
grid_w: usize,
|
grid_w: usize,
|
||||||
grid_h: usize,
|
grid_h: usize,
|
||||||
char_size: u32,
|
|
||||||
|
|
||||||
entry: ash::Entry,
|
entry: ash::Entry,
|
||||||
instance: ash::Instance,
|
instance: ash::Instance,
|
||||||
@@ -712,7 +709,6 @@ impl GraphicsRenderer {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
grid_w,
|
grid_w,
|
||||||
grid_h,
|
grid_h,
|
||||||
char_size: CHAR_W,
|
|
||||||
entry,
|
entry,
|
||||||
instance,
|
instance,
|
||||||
surface,
|
surface,
|
||||||
@@ -1115,18 +1111,8 @@ impl GraphicsRenderer {
|
|||||||
self.grid_h
|
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 {
|
pub fn cell_pixel_size(&self) -> u32 {
|
||||||
self.char_size
|
CHAR_W
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_resize(&mut self) {
|
fn check_resize(&mut self) {
|
||||||
@@ -1253,8 +1239,8 @@ impl GraphicsRenderer {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Reallocate instance buffer if grid size changed
|
// Reallocate instance buffer if grid size changed
|
||||||
let new_grid_w = (new_extent.width / self.char_size) as usize;
|
let new_grid_w = (new_extent.width / CHAR_W) as usize;
|
||||||
let new_grid_h = (new_extent.height / self.char_size) as usize;
|
let new_grid_h = (new_extent.height / CHAR_H) as usize;
|
||||||
let new_count = new_grid_w * new_grid_h;
|
let new_count = new_grid_w * new_grid_h;
|
||||||
|
|
||||||
if new_count != self.instance_count {
|
if new_count != self.instance_count {
|
||||||
|
|||||||
+3
-17
@@ -12,8 +12,6 @@ use crate::world::grid::{MAX_WORLD_H, MAX_WORLD_W};
|
|||||||
const CHAR_W: u32 = 8;
|
const CHAR_W: u32 = 8;
|
||||||
const CHAR_H: u32 = 8;
|
const CHAR_H: u32 = 8;
|
||||||
const UI_CELL_SIZE: u32 = 2;
|
const UI_CELL_SIZE: u32 = 2;
|
||||||
const MIN_CHAR: u32 = 4;
|
|
||||||
const MAX_CHAR: u32 = 24;
|
|
||||||
const ATLAS_COLS: usize = 16;
|
const ATLAS_COLS: usize = 16;
|
||||||
const ATLAS_ROWS: usize = 8;
|
const ATLAS_ROWS: usize = 8;
|
||||||
const ATLAS_W: u32 = (ATLAS_COLS as u32) * CHAR_W;
|
const ATLAS_W: u32 = (ATLAS_COLS as u32) * CHAR_W;
|
||||||
@@ -84,7 +82,6 @@ struct PushConstants {
|
|||||||
pub struct VulkanRenderer {
|
pub struct VulkanRenderer {
|
||||||
grid_w: usize,
|
grid_w: usize,
|
||||||
grid_h: usize,
|
grid_h: usize,
|
||||||
char_size: u32,
|
|
||||||
|
|
||||||
entry: ash::Entry,
|
entry: ash::Entry,
|
||||||
instance: ash::Instance,
|
instance: ash::Instance,
|
||||||
@@ -279,7 +276,6 @@ impl VulkanRenderer {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
grid_w,
|
grid_w,
|
||||||
grid_h,
|
grid_h,
|
||||||
char_size: CHAR_W,
|
|
||||||
entry,
|
entry,
|
||||||
instance,
|
instance,
|
||||||
surface,
|
surface,
|
||||||
@@ -712,18 +708,8 @@ impl VulkanRenderer {
|
|||||||
self.grid_h
|
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 {
|
pub fn cell_pixel_size(&self) -> u32 {
|
||||||
self.char_size
|
CHAR_W
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_resize(&mut self) {
|
fn check_resize(&mut self) {
|
||||||
@@ -846,8 +832,8 @@ impl VulkanRenderer {
|
|||||||
.expect("cmd_bufs")
|
.expect("cmd_bufs")
|
||||||
};
|
};
|
||||||
|
|
||||||
let new_grid_w = (new_extent.width / self.char_size) as usize;
|
let new_grid_w = (new_extent.width / CHAR_W) as usize;
|
||||||
let new_grid_h = (new_extent.height / self.char_size) as usize;
|
let new_grid_h = (new_extent.height / CHAR_H) as usize;
|
||||||
let new_count = new_grid_w * new_grid_h;
|
let new_count = new_grid_w * new_grid_h;
|
||||||
|
|
||||||
if new_count != self.instance_count {
|
if new_count != self.instance_count {
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ pub struct WindowInput {
|
|||||||
pub cam_down: bool,
|
pub cam_down: bool,
|
||||||
pub quit: bool,
|
pub quit: bool,
|
||||||
pub toggle_audio: bool,
|
pub toggle_audio: bool,
|
||||||
pub zoom_in: bool,
|
|
||||||
pub zoom_out: bool,
|
|
||||||
pub paint: Option<u8>,
|
pub paint: Option<u8>,
|
||||||
pub mouse_x: f64,
|
pub mouse_x: f64,
|
||||||
pub mouse_y: f64,
|
pub mouse_y: f64,
|
||||||
@@ -43,8 +41,6 @@ pub struct WindowInput {
|
|||||||
use_item_was_down: bool,
|
use_item_was_down: bool,
|
||||||
drop_item_was_down: bool,
|
drop_item_was_down: bool,
|
||||||
audio_was_down: bool,
|
audio_was_down: bool,
|
||||||
zoom_in_was_down: bool,
|
|
||||||
zoom_out_was_down: bool,
|
|
||||||
down_keys: HashSet<KeyCode>,
|
down_keys: HashSet<KeyCode>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +64,6 @@ impl WindowInput {
|
|||||||
cam_down: false,
|
cam_down: false,
|
||||||
quit: false,
|
quit: false,
|
||||||
toggle_audio: false,
|
toggle_audio: false,
|
||||||
zoom_in: false,
|
|
||||||
zoom_out: false,
|
|
||||||
paint: None,
|
paint: None,
|
||||||
mouse_x: 0.0,
|
mouse_x: 0.0,
|
||||||
mouse_y: 0.0,
|
mouse_y: 0.0,
|
||||||
@@ -92,8 +86,6 @@ impl WindowInput {
|
|||||||
use_item_was_down: false,
|
use_item_was_down: false,
|
||||||
drop_item_was_down: false,
|
drop_item_was_down: false,
|
||||||
audio_was_down: false,
|
audio_was_down: false,
|
||||||
zoom_in_was_down: false,
|
|
||||||
zoom_out_was_down: false,
|
|
||||||
down_keys: HashSet::new(),
|
down_keys: HashSet::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -214,20 +206,10 @@ impl WindowInput {
|
|||||||
self.cam_up = keys.contains(&KeyCode::KeyI);
|
self.cam_up = keys.contains(&KeyCode::KeyI);
|
||||||
self.cam_down = keys.contains(&KeyCode::KeyO);
|
self.cam_down = keys.contains(&KeyCode::KeyO);
|
||||||
self.quit = keys.contains(&KeyCode::KeyQ) || keys.contains(&KeyCode::Escape);
|
self.quit = keys.contains(&KeyCode::KeyQ) || keys.contains(&KeyCode::Escape);
|
||||||
|
|
||||||
let now_audio = keys.contains(&KeyCode::KeyM);
|
let now_audio = keys.contains(&KeyCode::KeyM);
|
||||||
self.toggle_audio = now_audio && !self.audio_was_down;
|
self.toggle_audio = now_audio && !self.audio_was_down;
|
||||||
self.audio_was_down = now_audio;
|
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;
|
self.paint = None;
|
||||||
if keys.contains(&KeyCode::Digit1) {
|
if keys.contains(&KeyCode::Digit1) {
|
||||||
self.paint = Some(1);
|
self.paint = Some(1);
|
||||||
|
|||||||
Reference in New Issue
Block a user