afegida hotkey per activar/desactivar el vsync
This commit is contained in:
@@ -96,6 +96,11 @@ void handleToggleIntegerScale() {
|
||||
Notifier::get()->show({"INTEGER SCALE " + std::string(Options::video.integer_scale ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
||||
}
|
||||
|
||||
void handleToggleVSync() {
|
||||
Screen::get()->toggleVSync();
|
||||
Notifier::get()->show({"V-SYNC " + std::string(Options::video.vertical_sync ? "ENABLED" : "DISABLED")}, NotificationText::CENTER);
|
||||
}
|
||||
|
||||
void handleShowDebugInfo() {
|
||||
Screen::get()->toggleDebugInfo();
|
||||
}
|
||||
@@ -111,8 +116,8 @@ InputAction getPressedAction() {
|
||||
if (Input::get()->checkAction(InputAction::TOGGLE_BORDER, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::TOGGLE_BORDER;
|
||||
}
|
||||
if (Input::get()->checkAction(InputAction::TOGGLE_VIDEOMODE, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::TOGGLE_VIDEOMODE;
|
||||
if (Input::get()->checkAction(InputAction::TOGGLE_FULLSCREEN, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::TOGGLE_FULLSCREEN;
|
||||
}
|
||||
if (Input::get()->checkAction(InputAction::WINDOW_DEC_ZOOM, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::WINDOW_DEC_ZOOM;
|
||||
@@ -132,6 +137,9 @@ InputAction getPressedAction() {
|
||||
if (Input::get()->checkAction(InputAction::TOGGLE_INTEGER_SCALE, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::TOGGLE_INTEGER_SCALE;
|
||||
}
|
||||
if (Input::get()->checkAction(InputAction::TOGGLE_VSYNC, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::TOGGLE_VSYNC;
|
||||
}
|
||||
if (Input::get()->checkAction(InputAction::SHOW_DEBUG_INFO, Input::DO_NOT_ALLOW_REPEAT)) {
|
||||
return InputAction::SHOW_DEBUG_INFO;
|
||||
}
|
||||
@@ -161,7 +169,7 @@ void handle() {
|
||||
handleToggleBorder();
|
||||
break;
|
||||
|
||||
case InputAction::TOGGLE_VIDEOMODE:
|
||||
case InputAction::TOGGLE_FULLSCREEN:
|
||||
handleToggleVideoMode();
|
||||
break;
|
||||
|
||||
@@ -189,6 +197,10 @@ void handle() {
|
||||
handleToggleIntegerScale();
|
||||
break;
|
||||
|
||||
case InputAction::TOGGLE_VSYNC:
|
||||
handleToggleVSync();
|
||||
break;
|
||||
|
||||
case InputAction::SHOW_DEBUG_INFO:
|
||||
handleShowDebugInfo();
|
||||
break;
|
||||
|
||||
@@ -70,14 +70,15 @@ class Input {
|
||||
// Inputs de sistema
|
||||
{Action::WINDOW_DEC_ZOOM, KeyState(SDL_SCANCODE_F1)},
|
||||
{Action::WINDOW_INC_ZOOM, KeyState(SDL_SCANCODE_F2)},
|
||||
{Action::TOGGLE_VIDEOMODE, KeyState(SDL_SCANCODE_F3)},
|
||||
{Action::TOGGLE_FULLSCREEN, KeyState(SDL_SCANCODE_F3)},
|
||||
{Action::TOGGLE_SHADERS, KeyState(SDL_SCANCODE_F4)},
|
||||
{Action::NEXT_PALETTE, KeyState(SDL_SCANCODE_F5)},
|
||||
{Action::PREVIOUS_PALETTE, KeyState(SDL_SCANCODE_F6)},
|
||||
{Action::TOGGLE_INTEGER_SCALE, KeyState(SDL_SCANCODE_F7)},
|
||||
{Action::TOGGLE_MUSIC, KeyState(SDL_SCANCODE_F8)},
|
||||
{Action::TOGGLE_BORDER, KeyState(SDL_SCANCODE_F9)},
|
||||
{Action::PAUSE, KeyState(SDL_SCANCODE_F10)},
|
||||
{Action::TOGGLE_VSYNC, KeyState(SDL_SCANCODE_F10)},
|
||||
{Action::PAUSE, KeyState(SDL_SCANCODE_F11)},
|
||||
{Action::SHOW_DEBUG_INFO, KeyState(SDL_SCANCODE_F12)}} {}
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@ const std::unordered_map<InputAction, std::string> ACTION_TO_STRING = {
|
||||
{InputAction::CANCEL, "CANCEL"},
|
||||
{InputAction::WINDOW_INC_ZOOM, "WINDOW_INC_ZOOM"},
|
||||
{InputAction::WINDOW_DEC_ZOOM, "WINDOW_DEC_ZOOM"},
|
||||
{InputAction::TOGGLE_VIDEOMODE, "TOGGLE_VIDEOMODE"},
|
||||
{InputAction::TOGGLE_FULLSCREEN, "TOGGLE_FULLSCREEN"},
|
||||
{InputAction::TOGGLE_VSYNC, "TOGGLE_VSYNC"},
|
||||
{InputAction::TOGGLE_INTEGER_SCALE, "TOGGLE_INTEGER_SCALE"},
|
||||
{InputAction::TOGGLE_BORDER, "TOGGLE_BORDER"},
|
||||
{InputAction::TOGGLE_MUSIC, "TOGGLE_MUSIC"},
|
||||
@@ -33,7 +34,8 @@ const std::unordered_map<std::string, InputAction> STRING_TO_ACTION = {
|
||||
{"CANCEL", InputAction::CANCEL},
|
||||
{"WINDOW_INC_ZOOM", InputAction::WINDOW_INC_ZOOM},
|
||||
{"WINDOW_DEC_ZOOM", InputAction::WINDOW_DEC_ZOOM},
|
||||
{"TOGGLE_VIDEOMODE", InputAction::TOGGLE_VIDEOMODE},
|
||||
{"TOGGLE_FULLSCREEN", InputAction::TOGGLE_FULLSCREEN},
|
||||
{"TOGGLE_VSYNC", InputAction::TOGGLE_VSYNC},
|
||||
{"TOGGLE_INTEGER_SCALE", InputAction::TOGGLE_INTEGER_SCALE},
|
||||
{"TOGGLE_BORDER", InputAction::TOGGLE_BORDER},
|
||||
{"TOGGLE_MUSIC", InputAction::TOGGLE_MUSIC},
|
||||
|
||||
@@ -21,13 +21,14 @@ enum class InputAction : int { // Acciones de entrada posibles en el juego
|
||||
// Inputs de sistema
|
||||
WINDOW_INC_ZOOM,
|
||||
WINDOW_DEC_ZOOM,
|
||||
TOGGLE_VIDEOMODE,
|
||||
TOGGLE_FULLSCREEN,
|
||||
TOGGLE_VSYNC,
|
||||
TOGGLE_INTEGER_SCALE,
|
||||
TOGGLE_SHADERS,
|
||||
TOGGLE_BORDER,
|
||||
TOGGLE_MUSIC,
|
||||
NEXT_PALETTE,
|
||||
PREVIOUS_PALETTE,
|
||||
TOGGLE_SHADERS,
|
||||
SHOW_DEBUG_INFO,
|
||||
|
||||
// Input obligatorio
|
||||
|
||||
@@ -382,6 +382,12 @@ void Screen::toggleIntegerScale() {
|
||||
SDL_SetRenderLogicalPresentation(renderer_, Options::game.width, Options::game.height, Options::video.integer_scale ? SDL_LOGICAL_PRESENTATION_INTEGER_SCALE : SDL_LOGICAL_PRESENTATION_LETTERBOX);
|
||||
}
|
||||
|
||||
// Alterna entre activar y desactivar el V-Sync
|
||||
void Screen::toggleVSync() {
|
||||
Options::video.vertical_sync = !Options::video.vertical_sync;
|
||||
SDL_SetRenderVSync(renderer_, Options::video.vertical_sync ? 1 : SDL_RENDERER_VSYNC_DISABLED);
|
||||
}
|
||||
|
||||
// Getters
|
||||
auto Screen::getRenderer() -> SDL_Renderer* { return renderer_; }
|
||||
auto Screen::getRendererSurface() -> std::shared_ptr<Surface> { return (*renderer_surface_); }
|
||||
|
||||
@@ -164,6 +164,9 @@ class Screen {
|
||||
// Alterna entre activar y desactivar el escalado entero
|
||||
void toggleIntegerScale();
|
||||
|
||||
// Alterna entre activar y desactivar el V-Sync
|
||||
void toggleVSync();
|
||||
|
||||
// Reduce el tamaño de la ventana
|
||||
auto decWindowZoom() -> bool;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user