limit length of solution names
This commit is contained in:
parent
9f21c2b258
commit
4c4563c326
3 changed files with 15 additions and 10 deletions
|
@ -512,6 +512,7 @@ impl Editor {
|
||||||
Rectangle::new(input_x as f32, 5., (width - input_x - 5) as f32, 30.),
|
Rectangle::new(input_x as f32, 5., (width - input_x - 5) as f32, 30.),
|
||||||
&mut input_text,
|
&mut input_text,
|
||||||
&mut self.input_text_selected,
|
&mut self.input_text_selected,
|
||||||
|
256,
|
||||||
self.level.is_sandbox(),
|
self.level.is_sandbox(),
|
||||||
) {
|
) {
|
||||||
self.machine.set_input(input_text.into_bytes());
|
self.machine.set_input(input_text.into_bytes());
|
||||||
|
|
|
@ -93,7 +93,7 @@ impl Game {
|
||||||
fn draw(&mut self, d: &mut RaylibDrawHandle) {
|
fn draw(&mut self, d: &mut RaylibDrawHandle) {
|
||||||
d.clear_background(Color::new(64, 64, 64, 255));
|
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();
|
let screen_height = d.get_screen_height();
|
||||||
d.draw_rectangle(0, 0, level_list_width, screen_height, Color::GRAY);
|
d.draw_rectangle(0, 0, level_list_width, screen_height, Color::GRAY);
|
||||||
|
|
||||||
|
@ -208,6 +208,7 @@ impl Game {
|
||||||
bounds,
|
bounds,
|
||||||
&mut solution.name,
|
&mut solution.name,
|
||||||
&mut self.editing_solution_name,
|
&mut self.editing_solution_name,
|
||||||
|
24,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
d.draw_text(solution.id(), column_x, y + 35, 10, Color::GRAY);
|
d.draw_text(solution.id(), column_x, y + 35, 10, Color::GRAY);
|
||||||
|
|
|
@ -90,6 +90,7 @@ pub fn text_input(
|
||||||
bounds: Rectangle,
|
bounds: Rectangle,
|
||||||
text: &mut String,
|
text: &mut String,
|
||||||
is_selected: &mut bool,
|
is_selected: &mut bool,
|
||||||
|
max_len: usize,
|
||||||
editable: bool,
|
editable: bool,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut changed = false;
|
let mut changed = false;
|
||||||
|
@ -136,6 +137,7 @@ pub fn text_input(
|
||||||
changed = true;
|
changed = true;
|
||||||
text.pop();
|
text.pop();
|
||||||
}
|
}
|
||||||
|
if text.len() < max_len {
|
||||||
let char_code = unsafe { ffi::GetCharPressed() };
|
let char_code = unsafe { ffi::GetCharPressed() };
|
||||||
let c = if char_code > 0 {
|
let c = if char_code > 0 {
|
||||||
char::from_u32(char_code as u32)
|
char::from_u32(char_code as u32)
|
||||||
|
@ -147,6 +149,7 @@ pub fn text_input(
|
||||||
text.push(c);
|
text.push(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
changed
|
changed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue