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:
parent
0510e338c1
commit
4ab574150a
|
@ -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));
|
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));
|
//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("IS GROUP KEY %d scancode:%d sym:%d groupHotKey=%d \n",idx,key.keysym.scancode,key.keysym.sym,groupHotKey);
|
||||||
//if(key == groupHotKey) {
|
if(key.keysym.sym==groupHotKey){
|
||||||
if(isKeyPressed(groupHotKey,key) == true) {
|
//if(isKeyPressed(groupHotKey,key) == true) {
|
||||||
//printf("GROUP KEY!\n");
|
|
||||||
//gui.groupKey(key-'0');
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
|
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);
|
gui.groupKey(idx-1);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -349,8 +349,7 @@ void Gui::mouseDoubleClickLeftGraphics(int x, int y){
|
||||||
void Gui::groupKey(int groupIndex) {
|
void Gui::groupKey(int groupIndex) {
|
||||||
if(isKeyDown(vkControl)){
|
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);
|
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,isKeyDown(vkShift));
|
||||||
selection.assignGroup(groupIndex);
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] groupIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,groupIndex);
|
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() > 0 &&
|
||||||
lastGroupRecallTime.getMillis() <= recallGroupCenterCameraTimeout) {
|
lastGroupRecallTime.getMillis() <= recallGroupCenterCameraTimeout) {
|
||||||
|
|
||||||
selection.recallGroup(groupIndex);
|
selection.recallGroup(groupIndex,!isKeyDown(vkShift));
|
||||||
centerCameraOnSelection();
|
centerCameraOnSelection();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
selection.recallGroup(groupIndex);
|
selection.recallGroup(groupIndex,!isKeyDown(vkShift));
|
||||||
}
|
}
|
||||||
|
|
||||||
lastGroupRecallTime.start();
|
lastGroupRecallTime.start();
|
||||||
|
|
|
@ -211,13 +211,15 @@ bool Selection::hasUnit(const Unit* unit) const {
|
||||||
return find(selectedUnits.begin(), selectedUnits.end(), unit) != selectedUnits.end();
|
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) {
|
if(groupIndex < 0 || groupIndex >= maxGroups) {
|
||||||
throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
|
throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
|
||||||
}
|
}
|
||||||
|
|
||||||
//clear group
|
//clear group
|
||||||
groups[groupIndex].clear();
|
if(true==clearGroup){
|
||||||
|
groups[groupIndex].clear();
|
||||||
|
}
|
||||||
|
|
||||||
//assign new group
|
//assign new group
|
||||||
const UnitContainer *addUnits = &selectedUnits;
|
const UnitContainer *addUnits = &selectedUnits;
|
||||||
|
@ -260,12 +262,14 @@ vector<Unit*> Selection::getUnitsForGroup(int groupIndex) {
|
||||||
return groups[groupIndex];
|
return groups[groupIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Selection::recallGroup(int groupIndex){
|
void Selection::recallGroup(int groupIndex,bool clearSelection){
|
||||||
if(groupIndex < 0 || groupIndex >= maxGroups) {
|
if(groupIndex < 0 || groupIndex >= maxGroups) {
|
||||||
throw megaglest_runtime_error("Invalid value for groupIndex = " + intToStr(groupIndex));
|
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) {
|
for(int i = 0; i < (int)groups[groupIndex].size(); ++i) {
|
||||||
select(groups[groupIndex][i]);
|
select(groups[groupIndex][i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,10 +89,10 @@ public:
|
||||||
Vec3f getRefPos() const;
|
Vec3f getRefPos() const;
|
||||||
bool hasUnit(const Unit* unit) 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 addUnitToGroup(int groupIndex,Unit *unit);
|
||||||
void removeUnitFromGroup(int groupIndex,int UnitId);
|
void removeUnitFromGroup(int groupIndex,int UnitId);
|
||||||
void recallGroup(int groupIndex);
|
void recallGroup(int groupIndex, bool clearSelection=true);
|
||||||
|
|
||||||
vector<Unit*> getUnitsForGroup(int groupIndex);
|
vector<Unit*> getUnitsForGroup(int groupIndex);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue