mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Support numpad with player hotkey in ActorViewer
KEY_DOWN means we need to check for the "down" values instead of "char" value which differer for numpad. Ref: #501 Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit is contained in:
parent
fcbc3d3f71
commit
cf5501a35b
1 changed files with 10 additions and 6 deletions
|
|
@ -164,14 +164,18 @@ public:
|
|||
|
||||
bool OnKey(ActorViewerTool* obj, wxKeyEvent& evt, KeyEventType type)
|
||||
{
|
||||
if (type == KEY_DOWN && (evt.GetKeyCode() >= '0' && evt.GetKeyCode() <= '8'))
|
||||
// (TODO: this should probably be 'char' not 'down'; but we don't get
|
||||
// 'char' unless we return false from this function, in which case the
|
||||
// scenario editor intercepts some other keys for itself)
|
||||
if (type == KEY_DOWN)
|
||||
{
|
||||
// (TODO: this should probably be 'char' not 'down'; but we don't get
|
||||
// 'char' unless we return false from this function, in which case the
|
||||
// scenario editor intercepts some other keys for itself)
|
||||
const int maxPlayerID = obj->GetScenarioEditor().GetMapSettings()["PlayerData"]["item"].count();
|
||||
int playerID = evt.GetKeyCode() - '0';
|
||||
if (playerID <= maxPlayerID)
|
||||
int playerID = -1;
|
||||
if (evt.GetKeyCode() >= '0' && evt.GetKeyCode() <= '8')
|
||||
playerID = evt.GetKeyCode() - '0';
|
||||
else if (evt.GetKeyCode() >= WXK_NUMPAD0 && evt.GetKeyCode() <= WXK_NUMPAD8)
|
||||
playerID = evt.GetKeyCode() - WXK_NUMPAD0;
|
||||
if (playerID >= 0 && playerID <= maxPlayerID)
|
||||
{
|
||||
obj->GetScenarioEditor().GetObjectSettings().SetPlayerID(playerID);
|
||||
obj->GetScenarioEditor().GetObjectSettings().NotifyObservers();
|
||||
|
|
|
|||
Loading…
Reference in a new issue