Skip to content

Commit

Permalink
If a unit has spent all of its level up points, the interface now aut…
Browse files Browse the repository at this point in the history
…omatically exits the level up choice submenu
  • Loading branch information
Andrettin committed Jan 14, 2016
1 parent 67e1923 commit b2c84f0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
14 changes: 2 additions & 12 deletions src/action/action_research.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 ;
}
Expand Down
8 changes: 8 additions & 0 deletions src/action/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/network/commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
27 changes: 26 additions & 1 deletion src/ui/botpanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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);
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit b2c84f0

Please sign in to comment.