Skip to content

Commit

Permalink
allow screentextentry to reset an input redirect to its prior state
Browse files Browse the repository at this point in the history
gamebuttons overlapping type-text cause issues and this lets us ignore them (but still disabled by default)
  • Loading branch information
poco0317 committed Nov 12, 2021
1 parent f8d1b0e commit 790a1f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Etterna/Screen/Others/ScreenTextEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ static const char* g_szKeys[NUM_KeyboardRow][KEYS_PER_ROW] = {
};

std::string ScreenTextEntry::s_sLastAnswer = "";
bool ScreenTextEntry::s_bMustResetInputRedirAtClose = false;
bool ScreenTextEntry::s_bResetInputRedirTo = false;


// Settings:
namespace {
Expand Down Expand Up @@ -386,6 +389,11 @@ ScreenTextEntry::BeginScreen()

ScreenWithMenuElements::BeginScreen();

if (s_bMustResetInputRedirAtClose) {
s_bResetInputRedirTo = SCREENMAN->get_input_redirected(PLAYER_1);
SCREENMAN->set_input_redirected(PLAYER_1, false);
}

if (sQuestion != "")
m_textQuestion.SetText(sQuestion);
else
Expand Down Expand Up @@ -593,6 +601,10 @@ ScreenTextEntry::End(bool bCancelled)

s_bCancelledLast = bCancelled;
s_sLastAnswer = bCancelled ? std::string("") : WStringToString(m_sAnswer);
if (s_bMustResetInputRedirAtClose) {
s_bMustResetInputRedirAtClose = false;
SCREENMAN->set_input_redirected(PLAYER_1, s_bResetInputRedirTo);
}
}

bool
Expand Down
3 changes: 3 additions & 0 deletions src/Etterna/Screen/Others/ScreenTextEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ class ScreenTextEntry : public ScreenWithMenuElements
static std::string s_sLastAnswer;
static bool s_bCancelledLast;

static bool s_bMustResetInputRedirAtClose;
static bool s_bResetInputRedirTo;

// Lua
void PushSelf(lua_State* L) override;

Expand Down

0 comments on commit 790a1f3

Please sign in to comment.