Map compiles now and can be set
This commit is contained in:
parent
f10feb77fd
commit
ca330b1ac0
@ -426,10 +426,9 @@ void MapUserConfigParam<T, U>::findYourDataInAChildOf(const XMLNode* node)
|
||||
|
||||
for (const auto& kv : m_elements) {
|
||||
std::pair<T,U> elt;
|
||||
std::string str;
|
||||
child->get(kv.first, &str);
|
||||
elt.first = kv.first;
|
||||
elt.second = str.c_str();
|
||||
elt.second = kv.second;
|
||||
|
||||
|
||||
bool there = false;
|
||||
|
||||
|
@ -169,17 +169,19 @@ public:
|
||||
{
|
||||
return m_elements;
|
||||
}
|
||||
float& operator=(const std::map<T,U>& v)
|
||||
std::map<T, U>& operator=(const std::map<T,U>& v)
|
||||
{
|
||||
m_elements = std::map<T, U>(v); return m_elements;
|
||||
m_elements = std::map<T, U>(v);
|
||||
return m_elements;
|
||||
}
|
||||
float& operator=(const MapUserConfigParam& v)
|
||||
std::map<T, U>& operator=(const MapUserConfigParam& v)
|
||||
{
|
||||
m_elements = std::map<T,U>(v); return m_elements;
|
||||
m_elements = std::map<T,U>(v);
|
||||
return m_elements;
|
||||
}
|
||||
}; // ListUserConfigParam
|
||||
typedef MapUserConfigParam<const char*, const char*> StringToStringUserConfigParam;
|
||||
|
||||
typedef MapUserConfigParam<int, int> IntToIntUserConfigParam;
|
||||
// ============================================================================
|
||||
class IntUserConfigParam : public UserConfigParam
|
||||
{
|
||||
@ -753,14 +755,14 @@ namespace UserConfigParams
|
||||
"stun.voxalot.com",
|
||||
"stun.voxgratia.org",
|
||||
"stun.xten.com") );
|
||||
PARAM_PREFIX StringToStringUserConfigParam m_karts_per_gamemode
|
||||
PARAM_DEFAULT(StringToStringUserConfigParam("karts_per_gamemode", "The karts per gamemode"
|
||||
PARAM_PREFIX IntToIntUserConfigParam m_karts_per_gamemode
|
||||
PARAM_DEFAULT(IntToIntUserConfigParam("karts_per_gamemode", "The karts per gamemode"
|
||||
"Number of karts per gamemode. Order corresponds to Enum value",
|
||||
4,
|
||||
std::make_pair("3", "1"),
|
||||
std::make_pair("f", "2"),
|
||||
std::make_pair("e", "4"),
|
||||
std::make_pair("te", "5")
|
||||
std::make_pair(0, 1),
|
||||
std::make_pair(1, 2),
|
||||
std::make_pair(3, 4),
|
||||
std::make_pair(4, 5)
|
||||
));
|
||||
PARAM_PREFIX BoolUserConfigParam m_log_packets
|
||||
PARAM_DEFAULT( BoolUserConfigParam(false, "log-network-packets",
|
||||
|
@ -165,21 +165,24 @@ void TrackInfoScreen::init()
|
||||
getWidget<LabelWidget>("ai-text")->setVisible(has_AI);
|
||||
|
||||
UserConfigParams::m_num_karts;
|
||||
std::map<const char* , const char*> karts_per_gamemode = UserConfigParams::m_karts_per_gamemode;
|
||||
auto data = UserConfigParams::m_karts_per_gamemode;
|
||||
std::map<int , int> karts_per_gamemode = UserConfigParams::m_karts_per_gamemode;
|
||||
|
||||
if (has_AI)
|
||||
{
|
||||
m_ai_kart_spinner->setActive(true);
|
||||
int gamemode = race_manager->getMinorMode();
|
||||
//Temp fix
|
||||
//int num_ai = stoi(karts_per_gamemode[ "3"/*gamemode*/]) - local_players; //TODO error caused by enums not being sequential
|
||||
int num_ai = 1;
|
||||
int num_ai = karts_per_gamemode[gamemode];
|
||||
|
||||
// Avoid negative numbers (which can happen if e.g. the number of karts
|
||||
// Avoid negative numbers (which can happen if e.g. the number of karts
|
||||
// in a previous race was lower than the number of players now.
|
||||
|
||||
if (num_ai < 0) num_ai = 0;
|
||||
if (num_ai < 0)
|
||||
{
|
||||
num_ai = 0;
|
||||
karts_per_gamemode[race_manager->getMinorMode()] = race_manager->getNumPlayers();
|
||||
UserConfigParams::m_karts_per_gamemode = karts_per_gamemode;
|
||||
}
|
||||
|
||||
m_ai_kart_spinner->setValue(num_ai);
|
||||
|
||||
race_manager->setNumKarts(num_ai + local_players);
|
||||
@ -251,10 +254,8 @@ void TrackInfoScreen::init()
|
||||
m_ai_kart_spinner->setActive(false);
|
||||
race_manager->setNumKarts(race_manager->getNumLocalPlayers());
|
||||
|
||||
//This is causing an error
|
||||
/// karts_per_gamemode[race_manager->getMinorMode()] = std::to_string(race_manager->getNumLocalPlayers());
|
||||
// UserConfigParams::m_karts_per_gamemode = karts_per_gamemode; //TODO Causes error
|
||||
UserConfigParams::m_num_karts = race_manager->getNumLocalPlayers();
|
||||
karts_per_gamemode[race_manager->getMinorMode()] = race_manager->getNumPlayers();
|
||||
UserConfigParams::m_karts_per_gamemode = karts_per_gamemode;
|
||||
}
|
||||
else if (record_available)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user