Browse Source

Add print screen to event handler for UI (#6058)

pull/6063/head
DakkJaniels 3 years ago committed by GitHub
parent
commit
b0cb925a5e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      Source/DiabloUI/diabloui.cpp
  2. 7
      Source/diablo.cpp
  3. 1
      Source/diablo.h

6
Source/DiabloUI/diabloui.cpp

@ -10,6 +10,7 @@
#include "controls/input.h"
#include "controls/menu_controls.h"
#include "controls/plrctrls.h"
#include "diablo.h"
#include "discord/discord.h"
#include "engine/assets.hpp"
#include "engine/clx_sprite.hpp"
@ -461,6 +462,11 @@ void UiHandleEvents(SDL_Event *event)
return;
}
if (event->type == SDL_KEYUP && event->key.keysym.sym == SDLK_PRINTSCREEN) {
PrintScreen(SDLK_PRINTSCREEN);
return;
}
if (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_RETURN) {
const Uint8 *state = SDLC_GetKeyState();
if (state[SDLC_KEYSTATE_LALT] != 0 || state[SDLC_KEYSTATE_RALT] != 0) {

7
Source/diablo.cpp

@ -439,7 +439,7 @@ void RightMouseDown(bool isShiftHeld)
void ReleaseKey(SDL_Keycode vkey)
{
remap_keyboard_key(&vkey);
if (sgnTimeoutCurs != CURSOR_NONE || dropGoldFlag)
if ((sgnTimeoutCurs != CURSOR_NONE || dropGoldFlag) && vkey != SDLK_PRINTSCREEN)
return;
sgOptions.Keymapper.KeyReleased(vkey);
}
@ -3025,4 +3025,9 @@ bool IsDiabloAlive(bool playSFX)
return true;
}
void PrintScreen(SDL_Keycode vkey)
{
ReleaseKey(vkey);
}
} // namespace devilution

1
Source/diablo.h

@ -96,6 +96,7 @@ bool PressEscKey();
void DisableInputEventHandler(const SDL_Event &event, uint16_t modState);
void LoadGameLevel(bool firstflag, lvl_entry lvldir);
bool IsDiabloAlive(bool playSFX);
void PrintScreen(SDL_Keycode vkey);
/**
* @param bStartup Process additional ticks before returning

Loading…
Cancel
Save