- bugfix for multi-unit selection (pressing shift does not unselect previously selected units now)

This commit is contained in:
Mark Vejvoda
2010-07-15 19:48:28 +00:00
parent 1096e81562
commit 2ada9e7550
3 changed files with 28 additions and 1 deletions

View File

@@ -883,13 +883,16 @@ void Gui::computeSelected(bool doubleClick){
bool controlDown= isKeyDown(vkControl); bool controlDown= isKeyDown(vkControl);
if(!shiftDown && !controlDown){ if(!shiftDown && !controlDown){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to call selection.clear()\n",__FILE__,__FUNCTION__,__LINE__);
selection.clear(); selection.clear();
} }
if(!controlDown){ if(!controlDown){
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to call selection.select(units)\n",__FILE__,__FUNCTION__,__LINE__);
selection.select(units); selection.select(units);
} }
else{ else{
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] selection.unSelect(units)\n",__FILE__,__FUNCTION__,__LINE__);
selection.unSelect(units); selection.unSelect(units);
} }
} }

View File

@@ -794,8 +794,12 @@ bool isKeyDown(int virtualKey) {
char key = static_cast<char> (virtualKey); char key = static_cast<char> (virtualKey);
const Uint8* keystate = SDL_GetKeyState(0); const Uint8* keystate = SDL_GetKeyState(0);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] key = %d\n",__FILE__,__FUNCTION__,__LINE__,key);
// kinda hack and wrong... // kinda hack and wrong...
if(key >= 0) { if(key >= 0) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] keystate[key] = %d\n",__FILE__,__FUNCTION__,__LINE__,keystate[key]);
return keystate[key]; return keystate[key];
} }
switch(key) { switch(key) {
@@ -827,6 +831,7 @@ bool isKeyDown(int virtualKey) {
std::cerr << "isKeyDown called with unknown key.\n"; std::cerr << "isKeyDown called with unknown key.\n";
break; break;
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning false\n",__FILE__,__FUNCTION__,__LINE__);
return false; return false;
} }

View File

@@ -553,6 +553,15 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
case SDLK_RSHIFT: case SDLK_RSHIFT:
return vkShift; return vkShift;
} }
if(keysym.mod & (KMOD_LALT | KMOD_RALT)) {
return vkAlt;
}
else if(keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
return vkControl;
}
else if(keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
return vkShift;
}
} }
switch(keysym.sym) { switch(keysym.sym) {
case SDLK_PLUS: case SDLK_PLUS:
@@ -663,7 +672,7 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
if(c == 0) { if(c == 0) {
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(skipSpecialKeys == false) { if(skipSpecialKeys == true) {
switch(keysym.sym) { switch(keysym.sym) {
case SDLK_LALT: case SDLK_LALT:
case SDLK_RALT: case SDLK_RALT:
@@ -675,6 +684,16 @@ char Window::getKey(SDL_keysym keysym,bool skipSpecialKeys) {
case SDLK_RSHIFT: case SDLK_RSHIFT:
return vkShift; return vkShift;
} }
if(keysym.mod & (KMOD_LALT | KMOD_RALT)) {
return vkAlt;
}
else if(keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
return vkControl;
}
else if(keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
return vkShift;
}
} }
c = keysym.sym; c = keysym.sym;