fixed key binding
This commit is contained in:
15
src/main.cpp
15
src/main.cpp
@ -797,6 +797,11 @@ int main(int, char **)
|
|||||||
else {
|
else {
|
||||||
// Route event to state manager handlers for per-state logic
|
// Route event to state manager handlers for per-state logic
|
||||||
stateMgr.handleEvent(e);
|
stateMgr.handleEvent(e);
|
||||||
|
// Keep the local `state` variable in sync with StateManager in case
|
||||||
|
// a state handler requested a transition (handlers may call
|
||||||
|
// stateMgr.setState()). Many branches below rely on the local
|
||||||
|
// `state` variable, so update it immediately after handling.
|
||||||
|
state = stateMgr.getState();
|
||||||
|
|
||||||
// Global key toggles (applies regardless of state)
|
// Global key toggles (applies regardless of state)
|
||||||
if (e.type == SDL_EVENT_KEY_DOWN && !e.key.repeat) {
|
if (e.type == SDL_EVENT_KEY_DOWN && !e.key.repeat) {
|
||||||
@ -1697,9 +1702,9 @@ int main(int, char **)
|
|||||||
const std::string line1 = "Are you sure you want to";
|
const std::string line1 = "Are you sure you want to";
|
||||||
const std::string line2 = "leave the current game?";
|
const std::string line2 = "leave the current game?";
|
||||||
|
|
||||||
int wTitle=0,hTitle=0; pixelFont.measure( title, 1.6f, wTitle, hTitle);
|
int wTitle=0,hTitle=0; pixelFont.measure(title, 1.6f, wTitle, hTitle);
|
||||||
int wL1=0,hL1=0; pixelFont.measure( line1, 0.9f, wL1, hL1);
|
int wL1=0,hL1=0; pixelFont.measure(line1, 0.9f, wL1, hL1);
|
||||||
int wL2=0,hL2=0; pixelFont.measure( line2, 0.9f, wL2, hL2);
|
int wL2=0,hL2=0; pixelFont.measure(line2, 0.9f, wL2, hL2);
|
||||||
|
|
||||||
float titleX = popupX + (popupW - (float)wTitle) * 0.5f;
|
float titleX = popupX + (popupW - (float)wTitle) * 0.5f;
|
||||||
float l1X = popupX + (popupW - (float)wL1) * 0.5f;
|
float l1X = popupX + (popupW - (float)wL1) * 0.5f;
|
||||||
@ -1718,13 +1723,13 @@ int main(int, char **)
|
|||||||
drawRect(yesX - 2, btnY - 2, btnW + 4, btnH + 4, {100, 120, 140, 255});
|
drawRect(yesX - 2, btnY - 2, btnW + 4, btnH + 4, {100, 120, 140, 255});
|
||||||
drawRect(yesX, btnY, btnW, btnH, {200, 60, 60, 255});
|
drawRect(yesX, btnY, btnW, btnH, {200, 60, 60, 255});
|
||||||
const std::string yes = "YES";
|
const std::string yes = "YES";
|
||||||
int wy=0,hy=0; pixelFont.measure( yes, 1.0f, wy, hy);
|
int wy=0,hy=0; pixelFont.measure(yes, 1.0f, wy, hy);
|
||||||
pixelFont.draw(renderer, yesX + (btnW - (float)wy) * 0.5f + contentOffsetX, btnY + (btnH - (float)hy) * 0.5f + contentOffsetY, yes, 1.0f, {255,255,255,255});
|
pixelFont.draw(renderer, yesX + (btnW - (float)wy) * 0.5f + contentOffsetX, btnY + (btnH - (float)hy) * 0.5f + contentOffsetY, yes, 1.0f, {255,255,255,255});
|
||||||
|
|
||||||
drawRect(noX - 2, btnY - 2, btnW + 4, btnH + 4, {100, 120, 140, 255});
|
drawRect(noX - 2, btnY - 2, btnW + 4, btnH + 4, {100, 120, 140, 255});
|
||||||
drawRect(noX, btnY, btnW, btnH, {80, 140, 80, 255});
|
drawRect(noX, btnY, btnW, btnH, {80, 140, 80, 255});
|
||||||
const std::string no = "NO";
|
const std::string no = "NO";
|
||||||
int wn=0,hn=0; pixelFont.measure( no, 1.0f, wn, hn);
|
int wn=0,hn=0; pixelFont.measure(no, 1.0f, wn, hn);
|
||||||
pixelFont.draw(renderer, noX + (btnW - (float)wn) * 0.5f + contentOffsetX, btnY + (btnH - (float)hn) * 0.5f + contentOffsetY, no, 1.0f, {255,255,255,255});
|
pixelFont.draw(renderer, noX + (btnW - (float)wn) * 0.5f + contentOffsetX, btnY + (btnH - (float)hn) * 0.5f + contentOffsetY, no, 1.0f, {255,255,255,255});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user