mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-03-20 08:59:22 +00:00
improve command line appearance and autofocus
This commit is contained in:
parent
3dbe56690a
commit
e77241cd56
|
@ -27,6 +27,7 @@ pub struct LiveDebugger {
|
||||||
npc_inspector_visible: bool,
|
npc_inspector_visible: bool,
|
||||||
hotkey_list_visible: bool,
|
hotkey_list_visible: bool,
|
||||||
command_line_parser: CommandLineParser,
|
command_line_parser: CommandLineParser,
|
||||||
|
command_line_focused: bool,
|
||||||
last_stage_id: usize,
|
last_stage_id: usize,
|
||||||
stages: Vec<ImString>,
|
stages: Vec<ImString>,
|
||||||
selected_stage: i32,
|
selected_stage: i32,
|
||||||
|
@ -46,6 +47,7 @@ impl LiveDebugger {
|
||||||
npc_inspector_visible: false,
|
npc_inspector_visible: false,
|
||||||
hotkey_list_visible: false,
|
hotkey_list_visible: false,
|
||||||
command_line_parser: CommandLineParser::new(),
|
command_line_parser: CommandLineParser::new(),
|
||||||
|
command_line_focused: false,
|
||||||
last_stage_id: usize::MAX,
|
last_stage_id: usize::MAX,
|
||||||
stages: Vec::new(),
|
stages: Vec::new(),
|
||||||
selected_stage: -1,
|
selected_stage: -1,
|
||||||
|
@ -83,11 +85,19 @@ impl LiveDebugger {
|
||||||
.collapsible(false)
|
.collapsible(false)
|
||||||
.movable(false)
|
.movable(false)
|
||||||
.build(ui, || {
|
.build(ui, || {
|
||||||
ui.text("Command:");
|
self.draw_left_label(ui, "Command:");
|
||||||
ui.same_line();
|
|
||||||
|
let iw = ui.push_item_width(state.screen_size.0 - 150.0);
|
||||||
|
|
||||||
|
if !self.command_line_focused {
|
||||||
|
ui.set_keyboard_focus_here();
|
||||||
|
self.command_line_focused = true;
|
||||||
|
}
|
||||||
|
|
||||||
ui.input_text("", &mut self.command_line_parser.buffer).build();
|
ui.input_text("", &mut self.command_line_parser.buffer).build();
|
||||||
|
|
||||||
|
iw.pop(ui);
|
||||||
|
|
||||||
if ui.is_item_active() {
|
if ui.is_item_active() {
|
||||||
state.control_flags.set_tick_world(false);
|
state.control_flags.set_tick_world(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -122,6 +132,8 @@ impl LiveDebugger {
|
||||||
self.command_line_parser.last_feedback.clone(),
|
self.command_line_parser.last_feedback.clone(),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
self.command_line_focused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !state.debugger {
|
if !state.debugger {
|
||||||
|
@ -544,6 +556,23 @@ impl LiveDebugger {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_left_label(&mut self, ui: &imgui::Ui, text: &str) {
|
||||||
|
self.draw_text_with_top_padding(ui, text, 6.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_text_with_top_padding(&mut self, ui: &imgui::Ui, text: &str, padding: f32) {
|
||||||
|
let previous_cursor_pos = ui.cursor_pos();
|
||||||
|
let y = previous_cursor_pos[1] + padding;
|
||||||
|
|
||||||
|
ui.set_cursor_pos([previous_cursor_pos[0], y]);
|
||||||
|
ui.text(text);
|
||||||
|
ui.same_line();
|
||||||
|
|
||||||
|
let mut current_cursor_pos = ui.cursor_pos();
|
||||||
|
current_cursor_pos[1] = previous_cursor_pos[1];
|
||||||
|
ui.set_cursor_pos(current_cursor_pos);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cond_flags(ui: &imgui::Ui, cond: &mut crate::common::Condition) {
|
fn cond_flags(ui: &imgui::Ui, cond: &mut crate::common::Condition) {
|
||||||
|
|
|
@ -2337,7 +2337,13 @@ impl Scene for GameScene {
|
||||||
ScanCode::F10 => state.settings.debug_outlines = !state.settings.debug_outlines,
|
ScanCode::F10 => state.settings.debug_outlines = !state.settings.debug_outlines,
|
||||||
ScanCode::F11 => state.settings.fps_counter = !state.settings.fps_counter,
|
ScanCode::F11 => state.settings.fps_counter = !state.settings.fps_counter,
|
||||||
ScanCode::F12 => state.debugger = !state.debugger,
|
ScanCode::F12 => state.debugger = !state.debugger,
|
||||||
ScanCode::Grave => state.command_line = !state.command_line,
|
ScanCode::Grave => {
|
||||||
|
state.command_line = !state.command_line;
|
||||||
|
|
||||||
|
if !state.command_line {
|
||||||
|
state.control_flags.set_tick_world(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue