Fix scoreboard sorting parameters
parent
1b79e8409f
commit
d371338920
|
@ -28,6 +28,7 @@
|
|||
#include "common/resources/resourcemanager.h"
|
||||
|
||||
#include "level/robotmain.h"
|
||||
#include "level/scoreboard.h"
|
||||
|
||||
#include "level/parser/parser.h"
|
||||
|
||||
|
@ -916,6 +917,26 @@ int CLevelParserParam::AsResearchFlag(int def)
|
|||
return AsResearchFlag();
|
||||
}
|
||||
|
||||
int CLevelParserParam::ToSortType(std::string value)
|
||||
{
|
||||
if (value == "Points" ) return SORT_POINTS;
|
||||
if (value == "Name" ) return SORT_ID;
|
||||
return Cast<int>(value, "sorttype");
|
||||
}
|
||||
|
||||
int CLevelParserParam::AsSortType()
|
||||
{
|
||||
if (m_empty)
|
||||
throw CLevelParserExceptionMissingParam(this);
|
||||
return ToSortType(m_value);
|
||||
}
|
||||
|
||||
int CLevelParserParam::AsSortType(int def)
|
||||
{
|
||||
if (m_empty)
|
||||
return def;
|
||||
return AsSortType();
|
||||
}
|
||||
|
||||
Gfx::PyroType CLevelParserParam::ToPyroType(std::string value)
|
||||
{
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
Gfx::EngineObjectType AsTerrainType();
|
||||
int AsBuildFlag();
|
||||
int AsResearchFlag();
|
||||
int AsSortType();
|
||||
Gfx::PyroType AsPyroType();
|
||||
Gfx::CameraType AsCameraType();
|
||||
MissionType AsMissionType();
|
||||
|
@ -108,6 +109,7 @@ public:
|
|||
Gfx::EngineObjectType AsTerrainType(Gfx::EngineObjectType def);
|
||||
int AsBuildFlag(int def);
|
||||
int AsResearchFlag(int def);
|
||||
int AsSortType(int def);
|
||||
Gfx::PyroType AsPyroType(Gfx::PyroType def);
|
||||
Gfx::CameraType AsCameraType(Gfx::CameraType def);
|
||||
MissionType AsMissionType(MissionType def);
|
||||
|
@ -139,6 +141,7 @@ private:
|
|||
Gfx::EngineObjectType ToTerrainType(std::string value);
|
||||
int ToBuildFlag(std::string value);
|
||||
int ToResearchFlag(std::string value);
|
||||
int ToSortType(std::string value);
|
||||
Gfx::PyroType ToPyroType(std::string value);
|
||||
Gfx::CameraType ToCameraType(std::string value);
|
||||
MissionType ToMissionType(std::string value);
|
||||
|
|
|
@ -3566,16 +3566,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
|
|||
|
||||
if (line->GetCommand() == "ScoreboardSortType" && !resetObject)
|
||||
{
|
||||
if (line->GetParam("SortBy")->AsString() == "Points")
|
||||
{
|
||||
// Sort teams by points
|
||||
m_scoreboard->SetSortType(SORT_POINTS);
|
||||
}
|
||||
else if (line->GetParam("SortBy")->AsString() == "Name")
|
||||
{
|
||||
// Sort teams alphabetically
|
||||
m_scoreboard->SetSortType(SORT_ID);
|
||||
}
|
||||
m_scoreboard->SetSortType(static_cast<SortType>(line->GetParam("sort")->AsSortType() ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ enum SortType
|
|||
* \section example Usage example
|
||||
* \code{.scene}
|
||||
* Scoreboard enable=true // enable the scoreboard
|
||||
* ScoreboardSortType SortBy="Name" // sort teams alphabetically, another option is SortBy="Points", sorting teams in order of points
|
||||
* ScoreboardSortType sort=Name // sort teams alphabetically, another option is sort=Points, sorting teams in order of points
|
||||
* ScoreboardKillRule type=WheeledShooter team=1 score=500 // destruction of team 1's WheeledShooter gives 100 points to the team that destroyed it
|
||||
* ScoreboardKillRule type=TargetBot score=100 // destruction of TargetBot (any team) gives 100 points
|
||||
* ScoreboardEndTakeRule score=1000 // completion of EndMissionTake objectives for any team results in 1000 points for that team
|
||||
|
|
Loading…
Reference in New Issue