Change mouse_pos() to fix HiDPI errors
@@ -117,17 +117,16 @@ impl Rltk {
/// Applies the current physical mouse position to the active console, and translates
/// the coordinates into that console's coordinate space.
pub fn mouse_pos(&mut self) -> (i32, i32) {
- let font_size = self.fonts[self.consoles[self.active_console].font_index].tile_size;
let max_sizes = self.consoles[self.active_console].console.get_char_size();
(
iclamp(
- (self.mouse_pos.0 as f32 / font_size.0 as f32) as i32,
+ self.mouse_pos.0 * max_sizes.0 as i32 / self.width_pixels as i32,
0,
max_sizes.0 as i32 - 1,
),
iclamp(
- (self.mouse_pos.1 as f32 / font_size.1 as f32) as i32,
+ self.mouse_pos.1 * max_sizes.1 as i32 / self.height_pixels as i32,
0,
max_sizes.1 as i32 - 1,
),
