diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp index fae659ea..f3a5f551 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -3523,7 +3523,7 @@ bool COldObject::GetTooltipName(std::string& name) { GetResource(RES_OBJECT, m_type, name); if(GetTeam() != 0) { - name += " [team "+boost::lexical_cast(GetTeam())+"]"; //TODO: better way to display this + name += " ["+CRobotMain::GetInstancePointer()->GetTeamName(GetTeam())+" ("+boost::lexical_cast(GetTeam())+")]"; } return !name.empty(); } diff --git a/src/object/robotmain.cpp b/src/object/robotmain.cpp index 21d8848f..829dd0a8 100644 --- a/src/object/robotmain.cpp +++ b/src/object/robotmain.cpp @@ -193,6 +193,8 @@ CRobotMain::CRobotMain(CController* controller) m_codeBattleInit = false; m_codeBattleStarted = false; + m_teamNames.clear(); + #if DEV_BUILD m_showAll = true; // for development #else @@ -2954,6 +2956,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) m_codeBattleInit = false; m_codeBattleStarted = false; + m_teamNames.clear(); + m_missionResult = ERR_MISSION_NOTERM; } @@ -3059,6 +3063,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject) continue; } + if (line->GetCommand() == "TeamName") + { + int team = line->GetParam("team")->AsInt(); + std::string name = line->GetParam("name")->AsString(); + m_teamNames[team] = name; + continue; + } + if (line->GetCommand() == "CacheAudio" && !resetObject) { m_sound->CacheMusic(std::string("../")+line->GetParam("filename")->AsPath("music")); @@ -6155,4 +6167,11 @@ bool CRobotMain::CanPlayerInteract() return !m_codeBattleStarted; } return true; +} + +const std::string NO_TEAM_NAME = "Team"; +const std::string& CRobotMain::GetTeamName(int id) +{ + if(m_teamNames.count(id) == 0) return NO_TEAM_NAME; + return m_teamNames[id]; } \ No newline at end of file diff --git a/src/object/robotmain.h b/src/object/robotmain.h index 46f5e813..0968c80c 100644 --- a/src/object/robotmain.h +++ b/src/object/robotmain.h @@ -329,6 +329,9 @@ public: //! Returns true if player can interact with things manually bool CanPlayerInteract(); + //! Returns team name for the given team id + const std::string& GetTeamName(int id); + protected: bool EventFrame(const Event &event); bool EventObject(const Event &event); @@ -463,6 +466,8 @@ protected: bool m_codeBattleInit; bool m_codeBattleStarted; + std::map m_teamNames; + float m_fontSize; Math::Point m_windowPos; Math::Point m_windowDim;