From beb0e8084932c437d68bbbf7efb82734e5d01ef1 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Fri, 24 Aug 2012 17:34:36 +0100 Subject: Prevent key overlap for Stickman movement and Gravity/Debug/Stamp actions, fixes #81 diff --git a/src/game/GameController.cpp b/src/game/GameController.cpp index 48632a7..47c9c0f 100644 --- a/src/game/GameController.cpp +++ b/src/game/GameController.cpp @@ -590,6 +590,22 @@ bool GameController::KeyPress(int key, Uint16 character, bool shift, bool ctrl, { sim->player2.comm = (int)(sim->player2.comm)|0x04; //Jump command } + + if((!sim->elementCount[PT_STKM2] || ctrl) && gameView->GetSelectMode() == SelectNone) + { + switch(key) + { + case 'w': + SwitchGravity(); + break; + case 'd': + gameView->ToggleDebug(); + break; + case 's': + gameView->BeginStampSelection(); + break; + } + } } return ret; } diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 26477e0..4a9bd93 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -1179,6 +1179,19 @@ void GameView::OnMouseWheel(int x, int y, int d) } } +void GameView::ToggleDebug() +{ + showDebug = !showDebug; +} + +void GameView::BeginStampSelection() +{ + selectMode = SelectStamp; + selectPoint1 = ui::Point(-1, -1); + infoTip = "\x0F\xEF\xEF\x10Select an area to create a stamp"; + infoTipPresence = 120; +} + void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt) { if(colourRValue->IsFocused() || colourGValue->IsFocused() || colourBValue->IsFocused() || colourAValue->IsFocused()) @@ -1300,9 +1313,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool else c->AdjustGridSize(1); break; - case 'd': - showDebug = !showDebug; - break; case KEY_F1: if(!introText) introText = 8047; @@ -1324,15 +1334,6 @@ void GameView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool if(ctrl) c->SetDecoration(); break; - case 's': - selectMode = SelectStamp; - selectPoint1 = ui::Point(-1, -1); - infoTip = "\x0F\xEF\xEF\x10Select an area to create a stamp"; - infoTipPresence = 120; - break; - case 'w': - c->SwitchGravity(); - break; case 'y': c->SwitchAir(); break; diff --git a/src/game/GameView.h b/src/game/GameView.h index c449ba2..02dadc8 100644 --- a/src/game/GameView.h +++ b/src/game/GameView.h @@ -138,6 +138,10 @@ public: void SetSample(SimulationSample sample); bool CtrlBehaviour(){ return ctrlBehaviour; } bool ShiftBehaviour(){ return shiftBehaviour; } + void ExitPrompt(); + void ToggleDebug(); + SelectMode GetSelectMode() { return selectMode; } + void BeginStampSelection(); void AttachController(GameController * _c){ c = _c; } void NotifyRendererChanged(GameModel * sender); @@ -160,7 +164,6 @@ public: void NotifyQuickOptionsChanged(GameModel * sender); void NotifyLastToolChanged(GameModel * sender); - void ExitPrompt(); virtual void ToolTip(ui::Component * sender, ui::Point mousePosition, std::string toolTip); -- cgit v0.9.2-21-gd62e