Added TeamName

master
krzys-h 2015-07-07 21:25:13 +02:00
parent 12be88c8c9
commit a6ccd7f270
3 changed files with 25 additions and 1 deletions

View File

@ -3523,7 +3523,7 @@ bool COldObject::GetTooltipName(std::string& name)
{ {
GetResource(RES_OBJECT, m_type, name); GetResource(RES_OBJECT, m_type, name);
if(GetTeam() != 0) { if(GetTeam() != 0) {
name += " [team "+boost::lexical_cast<std::string>(GetTeam())+"]"; //TODO: better way to display this name += " ["+CRobotMain::GetInstancePointer()->GetTeamName(GetTeam())+" ("+boost::lexical_cast<std::string>(GetTeam())+")]";
} }
return !name.empty(); return !name.empty();
} }

View File

@ -193,6 +193,8 @@ CRobotMain::CRobotMain(CController* controller)
m_codeBattleInit = false; m_codeBattleInit = false;
m_codeBattleStarted = false; m_codeBattleStarted = false;
m_teamNames.clear();
#if DEV_BUILD #if DEV_BUILD
m_showAll = true; // for development m_showAll = true; // for development
#else #else
@ -2954,6 +2956,8 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_codeBattleInit = false; m_codeBattleInit = false;
m_codeBattleStarted = false; m_codeBattleStarted = false;
m_teamNames.clear();
m_missionResult = ERR_MISSION_NOTERM; m_missionResult = ERR_MISSION_NOTERM;
} }
@ -3059,6 +3063,14 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
continue; 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) if (line->GetCommand() == "CacheAudio" && !resetObject)
{ {
m_sound->CacheMusic(std::string("../")+line->GetParam("filename")->AsPath("music")); m_sound->CacheMusic(std::string("../")+line->GetParam("filename")->AsPath("music"));
@ -6155,4 +6167,11 @@ bool CRobotMain::CanPlayerInteract()
return !m_codeBattleStarted; return !m_codeBattleStarted;
} }
return true; 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];
} }

View File

@ -329,6 +329,9 @@ public:
//! Returns true if player can interact with things manually //! Returns true if player can interact with things manually
bool CanPlayerInteract(); bool CanPlayerInteract();
//! Returns team name for the given team id
const std::string& GetTeamName(int id);
protected: protected:
bool EventFrame(const Event &event); bool EventFrame(const Event &event);
bool EventObject(const Event &event); bool EventObject(const Event &event);
@ -463,6 +466,8 @@ protected:
bool m_codeBattleInit; bool m_codeBattleInit;
bool m_codeBattleStarted; bool m_codeBattleStarted;
std::map<int, std::string> m_teamNames;
float m_fontSize; float m_fontSize;
Math::Point m_windowPos; Math::Point m_windowPos;
Math::Point m_windowDim; Math::Point m_windowDim;