Revert "refactor: remove some useless code,"

This reverts commit afc26199f7.
This commit is contained in:
pavanvo 2022-08-18 05:57:20 +04:00
parent 8caa800ee1
commit d5f15d2c72
2 changed files with 23 additions and 0 deletions

View File

@ -439,6 +439,14 @@ void Gui::hotKey(SDL_KeyboardEvent key) {
if(isKeyPressed(configKeys.getSDLKey("HotKeySelectStoreUnit"),key) == true) {
selectInterestingUnit(iutStore);
}
//else if(key == configKeys.getCharKey("HotKeySelectedUnitsAttack")) {
if(isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsAttack"),key) == true) {
clickCommonCommand(ccAttack);
}
//else if(key == configKeys.getCharKey("HotKeySelectedUnitsStop")) {
if(isKeyPressed(configKeys.getSDLKey("HotKeySelectedUnitsStop"),key) == true) {
clickCommonCommand(ccStop);
}
for (int i=0; i<commandKeys; i++) {
string name = "CommandKey" + intToStr(i+1);
@ -639,6 +647,20 @@ void Gui::selectInterestingUnit(InterestingUnitType iut) {
}
}
void Gui::clickCommonCommand(CommandClass commandClass) {
for(int index = 0; index < Display::downCellCount; ++index) {
const CommandType *ct = display.getCommandType(index);
if((ct != NULL && ct->getClass() == commandClass) ||
display.getCommandClass(index) == commandClass) {
mouseDownDisplayUnitSkills(index);
break;
}
}
computeDisplay();
}
void Gui::mouseDownDisplayUnitSkills(int posDisplay) {
if(selection.isEmpty() == false) {
if(posDisplay != cancelPos) {

View File

@ -217,6 +217,7 @@ private:
//hotkeys
void centerCameraOnSelection();
void selectInterestingUnit(InterestingUnitType iut);
void clickCommonCommand(CommandClass commandClass);
//misc
int computePosDisplay(int x, int y);