From ea04a2bb58f0fd44660267f1bfa39a0870ced9cc Mon Sep 17 00:00:00 2001 From: titison Date: Wed, 12 Nov 2014 21:31:01 +0100 Subject: [PATCH] setLockedUnitForFaction *Showing an info in the info string ( above the requirements of the unit ) if locked --- source/glest_game/gui/gui.cpp | 26 +++++++++++++++++--- source/glest_game/type_instances/faction.cpp | 8 +++--- source/glest_game/type_instances/faction.h | 4 +-- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/source/glest_game/gui/gui.cpp b/source/glest_game/gui/gui.cpp index ef54cbd2..2a1cca78 100644 --- a/source/glest_game/gui/gui.cpp +++ b/source/glest_game/gui/gui.cpp @@ -768,6 +768,7 @@ void Gui::computeInfoString(int posDisplay){ display.setInfoText(ct->getDesc(unit->getTotalUpgrade(),game->showTranslatedTechTree())); } else{ + display.setInfoText(ct->getReqDesc(game->showTranslatedTechTree())); if(ct->getClass()==ccUpgrade){ string text=""; const UpgradeCommandType *uct= static_cast(ct); @@ -779,8 +780,19 @@ void Gui::computeInfoString(int posDisplay){ } display.setInfoText(text+ct->getReqDesc(game->showTranslatedTechTree())); } - else{ - display.setInfoText(ct->getReqDesc(game->showTranslatedTechTree())); + //locked by scenario + else if(ct->getClass()==ccProduce){ + string text=""; + const ProduceCommandType *pct= static_cast(ct); + if(unit->getFaction()->isUnitLocked(pct->getProducedUnit())){ + display.setInfoText(lang.getString("LockedByScenario")+"\n\n"+ct->getReqDesc(game->showTranslatedTechTree())); + } + } + else if(ct->getClass()==ccMorph){ + const MorphCommandType *mct= static_cast(ct); + if(unit->getFaction()->isUnitLocked(mct->getMorphUnit())){ + display.setInfoText(lang.getString("LockedByScenario")+"\n\n"+ct->getReqDesc(game->showTranslatedTechTree())); + } } } } @@ -802,8 +814,16 @@ void Gui::computeInfoString(int posDisplay){ } else{ if(activeCommandType!=NULL && activeCommandType->getClass()==ccBuild){ + //locked by scenario const BuildCommandType *bct= static_cast(activeCommandType); - display.setInfoText(bct->getBuilding(posDisplay)->getReqDesc(game->showTranslatedTechTree())); + const Unit *unit= selection.getFrontUnit(); + printf("opfaaa\n"); + if(unit->getFaction()->isUnitLocked(bct->getBuilding(posDisplay))){ + printf("OpfaUnitNameDiggaaaa:%s",bct->getBuilding(posDisplay)->getName(false).c_str()); + display.setInfoText(lang.getString("LockedByScenario")+"\n\n"+bct->getBuilding(posDisplay)->getReqDesc(game->showTranslatedTechTree())); + } else { + display.setInfoText(bct->getBuilding(posDisplay)->getReqDesc(game->showTranslatedTechTree())); + } } } } diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 295a3ea4..6b1129b0 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -675,12 +675,12 @@ bool Faction::canUnitsPathfind() { void Faction::setLockedUnitForFaction(const UnitType *ut, bool lock) { if (lock) { - LockedUnits.insert(ut); + lockedUnits.insert(ut); } else { std::set::iterator it; - it=LockedUnits.find(ut); - if(it!=LockedUnits.end()) { - LockedUnits.erase(it); + it=lockedUnits.find(ut); + if(it!=lockedUnits.end()) { + lockedUnits.erase(it); } } diff --git a/source/glest_game/type_instances/faction.h b/source/glest_game/type_instances/faction.h index 16396eb4..9d7bf8df 100644 --- a/source/glest_game/type_instances/faction.h +++ b/source/glest_game/type_instances/faction.h @@ -174,7 +174,7 @@ private: std::map unitsMovingList; std::map unitsPathfindingList; - std::set LockedUnits; + std::set lockedUnits; TechTree *techTree; const XmlNode *loadWorldNode; @@ -247,7 +247,7 @@ public: bool canUnitsPathfind(); void setLockedUnitForFaction(const UnitType *ut, bool lock); - bool isUnitLocked(const UnitType *ut) const { return LockedUnits.find(ut)!=LockedUnits.end(); } + bool isUnitLocked(const UnitType *ut) const { return lockedUnits.find(ut)!=lockedUnits.end(); } void init( FactionType *factionType, ControlType control, TechTree *techTree, Game *game,