1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-15 01:24:45 +02:00

* support for numpad keyboard

* cannot build more than one capitol
* cannot build shipyard if town is not near water
This commit is contained in:
Michał W. Urbańczyk
2009-02-20 15:44:49 +00:00
parent 2e47b5ce10
commit 79ae1441ff
7 changed files with 83 additions and 40 deletions

View File

@ -1818,10 +1818,22 @@ void CPlayerInterface::handleEvent(SDL_Event *sEvent)
if (sEvent->type==SDL_KEYDOWN || sEvent->type==SDL_KEYUP)
{
SDL_KeyboardEvent key = sEvent->key;
//translate numpad keys
if (key.keysym.sym >= SDLK_KP0 && key.keysym.sym <= SDLK_KP9)
{
key.keysym.sym = (SDLKey) (key.keysym.sym - SDLK_KP0 + SDLK_0);
}
else if(key.keysym.sym == SDLK_KP_ENTER)
{
key.keysym.sym = (SDLKey)SDLK_RETURN;
}
std::list<KeyInterested*> miCopy = keyinterested;
for(std::list<KeyInterested*>::iterator i=miCopy.begin(); i != miCopy.end();i++)
if(vstd::contains(keyinterested,*i))
(**i).keyPressed(sEvent->key);
(**i).keyPressed(key);
}
else if(sEvent->type==SDL_MOUSEMOTION)
{