From b2c84f0a49cd2279069c27d5bb5a754f35dfe740 Mon Sep 17 00:00:00 2001 From: Andrettin Date: Thu, 14 Jan 2016 14:40:25 +0100 Subject: [PATCH] If a unit has spent all of its level up points, the interface now automatically exits the level up choice submenu --- src/action/action_research.cpp | 14 ++------------ src/action/command.cpp | 8 ++++++++ src/network/commands.cpp | 2 +- src/ui/botpanel.cpp | 27 ++++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/action/action_research.cpp b/src/action/action_research.cpp index d079ba96a..2f3232b2f 100644 --- a/src/action/action_research.cpp +++ b/src/action/action_research.cpp @@ -144,10 +144,7 @@ // player.Notify(NotifyGreen, unit.tilePos, _("%s: research complete"), type.Name.c_str()); player.Notify(NotifyGreen, unit.tilePos, _("%s: research complete"), type.GetDefaultName(player).c_str()); //Wyrmgus end - //Wyrmgus start -// } else { - } else if (!upgrade.Ability) { //don't show this message when abilities get learned - //Wyrmgus end + } else { player.Notify(NotifyGreen, unit.tilePos, _("%s: research complete"), upgrade.Name.c_str()); } if (&player == ThisPlayer) { @@ -160,14 +157,7 @@ if (player.AiEnabled) { AiResearchComplete(unit, &upgrade); } - //Wyrmgus start -// UpgradeAcquire(player, &upgrade); - if (!upgrade.Ability) { - UpgradeAcquire(player, &upgrade); - } else { - AbilityAcquire(unit, AllUpgrades[upgrade.ID]); - } - //Wyrmgus end + UpgradeAcquire(player, &upgrade); this->Finished = true; return ; } diff --git a/src/action/command.cpp b/src/action/command.cpp index 0d9e6b75d..2df991b42 100644 --- a/src/action/command.cpp +++ b/src/action/command.cpp @@ -1035,6 +1035,14 @@ void CommandResearch(CUnit &unit, CUpgrade &what, int flush) if (IsUnitValidForNetwork(unit) == false) { return ; } + + //Wyrmgus start + if (what.Ability) { + AbilityAcquire(unit, &what); + return; + } + //Wyrmgus end + // Check if enough resources remains? (NETWORK!) if (unit.Player->CheckCosts(what.Costs)) { return; diff --git a/src/network/commands.cpp b/src/network/commands.cpp index 0c1ad3630..b6f8aa64c 100644 --- a/src/network/commands.cpp +++ b/src/network/commands.cpp @@ -476,7 +476,7 @@ void SendCommandCancelUpgradeTo(CUnit &unit) //Wyrmgus start /** -** Send command: Building starts upgrading to. +** Send command: Unit starts upgrading to. ** ** @param unit pointer to unit. ** @param what pointer to unit-type of the unit upgrade. diff --git a/src/ui/botpanel.cpp b/src/ui/botpanel.cpp index 27017d8d4..a47974ded 100644 --- a/src/ui/botpanel.cpp +++ b/src/ui/botpanel.cpp @@ -1849,6 +1849,12 @@ void CButtonPanel::DoClicked_ExperienceUpgradeTo(int button) break; } } + + if (Selected[0]->Variable[LEVELUP_INDEX].Value == 0) { + CurrentButtonLevel = 0; + LastDrawnButtonPopup = NULL; + UI.ButtonPanel.Update(); + } } //Wyrmgus end @@ -1863,6 +1869,25 @@ void CButtonPanel::DoClicked_Research(int button) } } +//Wyrmgus start +void CButtonPanel::DoClicked_LearnAbility(int button) +{ + const int index = CurrentButtons[button].Value; + if (!Selected[0]->Player->CheckCosts(AllUpgrades[index]->Costs)) { + //PlayerSubCosts(player,Upgrades[i].Costs); + SendCommandResearch(*Selected[0], *AllUpgrades[index], !(KeyModifiers & ModifierShift)); + UI.StatusLine.Clear(); + UI.StatusLine.ClearCosts(); + } + + if (Selected[0]->Variable[LEVELUP_INDEX].Value == 0) { + CurrentButtonLevel = 0; + LastDrawnButtonPopup = NULL; + UI.ButtonPanel.Update(); + } +} +//Wyrmgus end + void CButtonPanel::DoClicked_CallbackAction(int button) { LuaCallback* callback = (LuaCallback*)(CurrentButtons[button].Payload); @@ -1928,7 +1953,7 @@ void CButtonPanel::DoClicked(int button) case ButtonResearch: { DoClicked_Research(button); break; } case ButtonCallbackAction: { DoClicked_CallbackAction(button); break; } //Wyrmgus start - case ButtonLearnAbility: { DoClicked_Research(button); break; } + case ButtonLearnAbility: { DoClicked_LearnAbility(button); break; } case ButtonExperienceUpgradeTo: { DoClicked_ExperienceUpgradeTo(button); break; } //Wyrmgus end }