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:
Ralph Sennhauser 2026-05-30 18:45:11 +02:00
parent fcbc3d3f71
commit cf5501a35b
No known key found for this signature in database

View file

@ -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();