- Move engine to a different crate - Add engine trait - Refactor the rest of the codebase to work with these changes - Add debug ui buffer, use it to finish imgui support
40 lines
811 B
Rust
40 lines
811 B
Rust
pub enum UICommand {
|
|
Text(String),
|
|
Separator,
|
|
}
|
|
|
|
pub struct DebugUIBuffer {
|
|
cmds: Vec<UICommand>,
|
|
}
|
|
|
|
impl DebugUIBuffer {
|
|
pub fn new() -> DebugUIBuffer {
|
|
DebugUIBuffer { cmds: vec![] }
|
|
}
|
|
|
|
// Commands
|
|
pub fn text(&mut self, text: String) {
|
|
self.cmds.push(UICommand::Text(text));
|
|
}
|
|
|
|
pub fn separator(&mut self) {
|
|
self.cmds.push(UICommand::Separator);
|
|
}
|
|
|
|
pub fn write_buffer(&self, ui: &imgui::Ui) {
|
|
for cmd in &self.cmds {
|
|
match cmd {
|
|
UICommand::Text(s) => {
|
|
ui.text(s);
|
|
}
|
|
UICommand::Separator => {
|
|
ui.separator();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn reset_buffer(&mut self) {
|
|
self.cmds = vec![];
|
|
}
|
|
}
|