diff --git a/src/editor.rs b/src/editor.rs index 77acf7d..27cb053 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -512,6 +512,7 @@ impl Editor { Rectangle::new(input_x as f32, 5., (width - input_x - 5) as f32, 30.), &mut input_text, &mut self.input_text_selected, + 256, self.level.is_sandbox(), ) { self.machine.set_input(input_text.into_bytes()); diff --git a/src/main.rs b/src/main.rs index d4c3708..bc86108 100644 --- a/src/main.rs +++ b/src/main.rs @@ -93,7 +93,7 @@ impl Game { fn draw(&mut self, d: &mut RaylibDrawHandle) { d.clear_background(Color::new(64, 64, 64, 255)); - let level_list_width = d.get_screen_width() / 4; // woah! Reactive UI! so fancy + let level_list_width = d.get_screen_width() / 3; let screen_height = d.get_screen_height(); d.draw_rectangle(0, 0, level_list_width, screen_height, Color::GRAY); @@ -208,6 +208,7 @@ impl Game { bounds, &mut solution.name, &mut self.editing_solution_name, + 24, true, ); d.draw_text(solution.id(), column_x, y + 35, 10, Color::GRAY); diff --git a/src/util.rs b/src/util.rs index 349360f..4d7e498 100644 --- a/src/util.rs +++ b/src/util.rs @@ -90,6 +90,7 @@ pub fn text_input( bounds: Rectangle, text: &mut String, is_selected: &mut bool, + max_len: usize, editable: bool, ) -> bool { let mut changed = false; @@ -136,15 +137,17 @@ pub fn text_input( changed = true; text.pop(); } - let char_code = unsafe { ffi::GetCharPressed() }; - let c = if char_code > 0 { - char::from_u32(char_code as u32) - } else { - None - }; - if let Some(c) = c { - changed = true; - text.push(c); + if text.len() < max_len { + let char_code = unsafe { ffi::GetCharPressed() }; + let c = if char_code > 0 { + char::from_u32(char_code as u32) + } else { + None + }; + if let Some(c) = c { + changed = true; + text.push(c); + } } } changed