tecla 9 per entrar i eixir del editor

This commit is contained in:
2026-04-02 11:25:03 +02:00
parent 20bac58814
commit dccd0d41e4
4 changed files with 20 additions and 7 deletions

View File

@@ -141,3 +141,5 @@ game:
cheat_jail_open: "JAIL OBERTA" cheat_jail_open: "JAIL OBERTA"
debug_enabled: "DEBUG ACTIVAT" debug_enabled: "DEBUG ACTIVAT"
debug_disabled: "DEBUG DESACTIVAT" debug_disabled: "DEBUG DESACTIVAT"
editor_enabled: "EDITOR ACTIVAT"
editor_disabled: "EDITOR DESACTIVAT"

View File

@@ -141,3 +141,5 @@ game:
cheat_jail_open: "JAIL IS OPEN" cheat_jail_open: "JAIL IS OPEN"
debug_enabled: "DEBUG ENABLED" debug_enabled: "DEBUG ENABLED"
debug_disabled: "DEBUG DISABLED" debug_disabled: "DEBUG DISABLED"
editor_enabled: "EDITOR ENABLED"
editor_disabled: "EDITOR DISABLED"

View File

@@ -3,15 +3,15 @@ enemies:
animation: code.yaml animation: code.yaml
boundaries: boundaries:
position1: position1:
x: 5 x: 3
y: 13 y: 2
position2: position2:
x: 16 x: 20
y: 13 y: 2
color: yellow color: yellow
position: position:
x: 11 x: 8
y: 13 y: 2
velocity: velocity:
x: 24.0 x: 24.0
y: 0 y: 0

View File

@@ -168,7 +168,16 @@ void Game::handleEvents() {
GlobalEvents::handle(event); GlobalEvents::handle(event);
#ifdef _DEBUG #ifdef _DEBUG
if (!Console::get()->isActive()) { if (!Console::get()->isActive()) {
if (MapEditor::get()->isActive()) { // Tecla 9: toggle editor (funciona tanto dentro como fuera del editor)
if (event.type == SDL_EVENT_KEY_DOWN && event.key.key == SDLK_9 && static_cast<int>(event.key.repeat) == 0) {
if (MapEditor::get()->isActive()) {
GameControl::exit_editor();
Notifier::get()->show({Locale::get()->get("game.editor_disabled")}); // NOLINT(readability-static-accessed-through-instance)
} else {
GameControl::enter_editor();
Notifier::get()->show({Locale::get()->get("game.editor_enabled")}); // NOLINT(readability-static-accessed-through-instance)
}
} else if (MapEditor::get()->isActive()) {
MapEditor::get()->handleEvent(event); MapEditor::get()->handleEvent(event);
} else { } else {
handleDebugEvents(event); handleDebugEvents(event);