group selections can be recalled with shift down.

Group selections can be recalled with shift down and the 
group is added to the current selection.
This commit is contained in:
titiger 2015-06-10 00:42:03 +02:00
parent 0510e338c1
commit 4ab574150a
4 changed files with 16 additions and 15 deletions

View File

@ -4859,11 +4859,9 @@ void Game::keyDown(SDL_KeyboardEvent key) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKeyPressed(groupHotKey,key));
//printf("input.keysym.mod = %d groupHotKey = %d key = %d (%d) [%s] isgroup = %d\n",key.keysym.mod,groupHotKey,key.keysym.sym,key.keysym.unicode,keyName.c_str(),isKeyPressed(groupHotKey,key));
//if(key == groupHotKey) {
if(isKeyPressed(groupHotKey,key) == true) {
//printf("GROUP KEY!\n");
//gui.groupKey(key-'0');
//printf("IS GROUP KEY %d scancode:%d sym:%d groupHotKey=%d \n",idx,key.keysym.scancode,key.keysym.sym,groupHotKey);
if(key.keysym.sym==groupHotKey){
//if(isKeyPressed(groupHotKey,key) == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
gui.groupKey(idx-1);
break;

View File

@ -349,8 +349,7 @@ void Gui::mouseDoubleClickLeftGraphics(int x, int y){
void Gui::groupKey(int groupIndex) {
if(isKeyDown(vkControl)){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex);
selection.assignGroup(groupIndex);
selection.assignGroup(groupIndex,isKeyDown(vkShift));
}
else{
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex);
@ -361,11 +360,11 @@ void Gui::groupKey(int groupIndex) {
lastGroupRecallTime.getMillis() > 0 &&
lastGroupRecallTime.getMillis() <= recallGroupCenterCameraTimeout) {
selection.recallGroup(groupIndex);
selection.recallGroup(groupIndex,!isKeyDown(vkShift));
centerCameraOnSelection();
}
else {
selection.recallGroup(groupIndex);
selection.recallGroup(groupIndex,!isKeyDown(vkShift));
}
lastGroupRecallTime.start();

View File

@ -211,13 +211,15 @@ bool Selection::hasUnit(const Unit* unit) const {
return find(selectedUnits.begin(), selectedUnits.end(), unit) != selectedUnits.end();
}
void Selection::assignGroup(int groupIndex,const UnitContainer *pUnits) {
void Selection::assignGroup(int groupIndex, bool clearGroup,const UnitContainer *pUnits) {
if(groupIndex < 0 || groupIndex >= maxGroups) {
throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
}
//clear group
groups[groupIndex].clear();
if(true==clearGroup){
groups[groupIndex].clear();
}
//assign new group
const UnitContainer *addUnits = &selectedUnits;
@ -260,12 +262,14 @@ vector<Unit*> Selection::getUnitsForGroup(int groupIndex) {
return groups[groupIndex];
}
void Selection::recallGroup(int groupIndex){
void Selection::recallGroup(int groupIndex,bool clearSelection){
if(groupIndex < 0 || groupIndex >= maxGroups) {
throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
}
clear();
if(clearSelection==true){
clear();
}
for(int i = 0; i < (int)groups[groupIndex].size(); ++i) {
select(groups[groupIndex][i]);
}

View File

@ -89,10 +89,10 @@ public:
Vec3f getRefPos() const;
bool hasUnit(const Unit* unit) const;
void assignGroup(int groupIndex,const UnitContainer *pUnits=NULL);
void assignGroup(int groupIndex, bool clearGroup=true, const UnitContainer *pUnits=NULL);
void addUnitToGroup(int groupIndex,Unit *unit);
void removeUnitFromGroup(int groupIndex,int UnitId);
void recallGroup(int groupIndex);
void recallGroup(int groupIndex, bool clearSelection=true);
vector<Unit*> getUnitsForGroup(int groupIndex);