add keybind for saving

This commit is contained in:
Crispy 2025-04-04 23:24:06 +02:00
parent dbb478f9ec
commit 8425e89254
2 changed files with 7 additions and 3 deletions

View file

@ -620,7 +620,7 @@ impl Editor {
self.draw_board(d, &globals.textures); self.draw_board(d, &globals.textures);
self.board_overlay(d, &globals.textures); self.board_overlay(d, &globals.textures);
self.draw_bottom_bar(d, globals); self.draw_bottom_bar(d, globals);
self.draw_top_bar(d, &globals.textures); self.draw_top_bar(d, globals);
if self.active_tool == Tool::Blueprint { if self.active_tool == Tool::Blueprint {
self.draw_blueprint_sidebar(d, &globals.textures); self.draw_blueprint_sidebar(d, &globals.textures);
@ -786,7 +786,8 @@ impl Editor {
} }
} }
fn draw_top_bar(&mut self, d: &mut RaylibDrawHandle, textures: &Textures) { fn draw_top_bar(&mut self, d: &mut RaylibDrawHandle, globals: &Globals) {
let textures = &globals.textures;
// background // background
d.draw_rectangle( d.draw_rectangle(
0, 0,
@ -822,7 +823,8 @@ impl Editor {
(40, 4), (40, 4),
textures.get("save"), textures.get("save"),
(&mut self.tooltip, "save"), (&mut self.tooltip, "save"),
) { ) || globals.is_pressed(ActionId::Save)
{
self.exit_state = ExitState::Save; self.exit_state = ExitState::Save;
} }

View file

@ -25,6 +25,7 @@ pub enum ActionId {
Paste, Paste,
Erase, Erase,
ToggleMenu, ToggleMenu,
Save,
StartSim, StartSim,
StopSim, StopSim,
StepSim, StepSim,
@ -65,6 +66,7 @@ impl Default for Input {
bind_key(ActionId::Paste, vec![LCtrl], V); bind_key(ActionId::Paste, vec![LCtrl], V);
bind_key(ActionId::Erase, vec![], Backspace); bind_key(ActionId::Erase, vec![], Backspace);
bind_key(ActionId::ToggleMenu, vec![], Escape); bind_key(ActionId::ToggleMenu, vec![], Escape);
bind_key(ActionId::Save, vec![LCtrl], S);
bind_key(ActionId::StartSim, vec![], Enter); bind_key(ActionId::StartSim, vec![], Enter);
bind_key(ActionId::StopSim, vec![], Enter); bind_key(ActionId::StopSim, vec![], Enter);
bind_key(ActionId::StepSim, vec![], Space); bind_key(ActionId::StepSim, vec![], Space);