Compare commits

..

No commits in common. "eebeb478d2f73135653b49caa937bce4764e4009" and "c3677a3ff441e4270e131ac2a8c3046108ddae58" have entirely different histories.

3 changed files with 12 additions and 24 deletions

View File

@ -85,20 +85,19 @@ pub(crate) fn render_to_window(
src: &mut [u8], src: &mut [u8],
palette: &[Rgb; 256], palette: &[Rgb; 256],
window_size: IVec2, window_size: IVec2,
screen_size: IVec2,
scale: usize, scale: usize,
off_x: usize, off_x: usize,
off_y: usize, off_y: usize,
) { ) {
let start = window_size.x as usize * off_y; let start = window_size.x as usize * off_y;
let end = start + window_size.x as usize * screen_size.y as usize * scale; let end = start + window_size.x as usize * window_size.y as usize * scale;
for (y, row) in target[start..end] for (y, row) in target[start..end]
.chunks_exact_mut(window_size.x as usize * scale) .chunks_exact_mut(window_size.x as usize * scale)
.enumerate() .enumerate()
{ {
let y = y as i32; let y = y as i32;
for x in 0..screen_size.x as usize { for x in 0..window_size.x as usize {
let p = src[x + y as usize * screen_size.x as usize]; let p = src[x + y as usize * window_size.x as usize];
for scaley in 0..scale { for scaley in 0..scale {
for scalex in 0..scale { for scalex in 0..scale {

View File

@ -104,10 +104,7 @@ pub(crate) fn run_mapedit() {
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
WindowEvent::KeyboardInput { input, .. } => { WindowEvent::KeyboardInput { input, .. } => {
match ( match (input.state, input.virtual_keycode.unwrap()) {
input.state,
input.virtual_keycode.unwrap_or(VirtualKeyCode::F24),
) {
(winit::event::ElementState::Pressed, VirtualKeyCode::Escape) => { (winit::event::ElementState::Pressed, VirtualKeyCode::Escape) => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit;
} }
@ -155,8 +152,8 @@ pub(crate) fn run_mapedit() {
}, },
WindowEvent::CursorMoved { position, .. } => { WindowEvent::CursorMoved { position, .. } => {
let new_pos = IVec2 { let new_pos = IVec2 {
x: position.x as i32 / 2, x: position.x as i32,
y: position.y as i32 / 2, y: position.y as i32,
}; };
let delta = new_pos - *mouse_pos; let delta = new_pos - *mouse_pos;
if *middle_down { if *middle_down {
@ -236,15 +233,15 @@ pub(crate) fn run_mapedit() {
) )
.unwrap(); .unwrap();
let mut screen_buffer = let mut screen_buffer =
vec![TRANSPARENT; size.width as usize * size.height as usize / 4]; vec![TRANSPARENT; size.width as usize * size.height as usize];
let mut window_buffer = surface.buffer_mut().unwrap(); let mut window_buffer = surface.buffer_mut().unwrap();
render_to_screen( render_to_screen(
&mut screen_buffer, &mut screen_buffer,
&gsa, &gsa,
&tileset, &tileset,
IVec2 { IVec2 {
x: size.width as i32 / 2, x: size.width as i32,
y: size.height as i32 / 2, y: size.height as i32,
}, },
); );
render_to_screen( render_to_screen(
@ -252,8 +249,8 @@ pub(crate) fn run_mapedit() {
&gsa2, &gsa2,
&tileset, &tileset,
IVec2 { IVec2 {
x: size.width as i32 / 2, x: size.width as i32,
y: size.height as i32 / 2, y: size.height as i32,
}, },
); );
render_to_window( render_to_window(
@ -264,11 +261,7 @@ pub(crate) fn run_mapedit() {
x: size.width as i32, x: size.width as i32,
y: size.height as i32, y: size.height as i32,
}, },
IVec2 { 1,
x: size.width as i32 / 2,
y: size.height as i32 / 2,
},
2,
0, 0,
0, 0,
); );

View File

@ -212,10 +212,6 @@ pub fn run<TGame: 'static>(
x: size.width as i32, x: size.width as i32,
y: size.height as i32, y: size.height as i32,
}, },
IVec2 {
x: SCREEN_WIDTH as i32,
y: SCREEN_HEIGHT as i32,
},
*scale, *scale,
*off_x, *off_x,
*off_y, *off_y,