add UserConfigParams: m_gp_reverse, random-gp-num-tracks for GPInfoScreen (#4656)

This commit is contained in:
lokpro 2021-10-28 10:15:26 +08:00 committed by GitHub
parent ce19c9396e
commit 1fd18c8d88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 3 deletions

View File

@ -434,6 +434,12 @@ namespace UserConfigParams
PARAM_PREFIX IntUserConfigParam m_num_laps PARAM_PREFIX IntUserConfigParam m_num_laps
PARAM_DEFAULT( IntUserConfigParam(4, "numlaps", PARAM_DEFAULT( IntUserConfigParam(4, "numlaps",
&m_race_setup_group, "Default number of laps.") ); &m_race_setup_group, "Default number of laps.") );
PARAM_PREFIX IntUserConfigParam m_gp_reverse
PARAM_DEFAULT( IntUserConfigParam(0, "gp-reverse",
&m_race_setup_group, "Default direction of GP tracks. 0=default, 1=no reverse, 2=all reverse, 3=Random") );
PARAM_PREFIX IntUserConfigParam m_rand_gp_num_tracks
PARAM_DEFAULT( IntUserConfigParam(1, "random-gp-num-tracks",
&m_race_setup_group, "Default number of tracks for random GP.") );
PARAM_PREFIX IntUserConfigParam m_ffa_time_limit PARAM_PREFIX IntUserConfigParam m_ffa_time_limit
PARAM_DEFAULT(IntUserConfigParam(3, "ffa-time-limit", PARAM_DEFAULT(IntUserConfigParam(3, "ffa-time-limit",
&m_race_setup_group, "Time limit in ffa mode.")); &m_race_setup_group, "Time limit in ffa mode."));

View File

@ -78,12 +78,10 @@ void GPInfoScreen::loadedFromFile()
m_reverse_spinner->addLabel(_("None")); m_reverse_spinner->addLabel(_("None"));
m_reverse_spinner->addLabel(_("All")); m_reverse_spinner->addLabel(_("All"));
m_reverse_spinner->addLabel(_("Random")); m_reverse_spinner->addLabel(_("Random"));
m_reverse_spinner->setValue(0);
m_num_tracks_spinner = getWidget<SpinnerWidget>("track-spinner"); m_num_tracks_spinner = getWidget<SpinnerWidget>("track-spinner");
// Only init the number of tracks here, this way the previously selected // Only init the number of tracks here, this way the previously selected
// number of tracks will be the default. // number of tracks will be the default.
m_num_tracks_spinner->setValue(1);
m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner"); m_ai_kart_spinner = getWidget<SpinnerWidget>("ai-spinner");
@ -216,6 +214,8 @@ void GPInfoScreen::init()
m_ai_kart_spinner->setMin(min_ai); m_ai_kart_spinner->setMin(min_ai);
} // has_AI } // has_AI
m_reverse_spinner->setValue( UserConfigParams::m_gp_reverse );
if(random) if(random)
{ {
RibbonWidget *rb = getWidget<RibbonWidget>("buttons"); RibbonWidget *rb = getWidget<RibbonWidget>("buttons");
@ -246,6 +246,7 @@ void GPInfoScreen::init()
else else
m_group_name = stringc(m_group_names[m_group_spinner->getValue()].c_str()).c_str(); m_group_name = stringc(m_group_names[m_group_spinner->getValue()].c_str()).c_str();
m_num_tracks_spinner->setValue( UserConfigParams::m_rand_gp_num_tracks );
m_max_num_tracks = getMaxNumTracks(m_group_name); m_max_num_tracks = getMaxNumTracks(m_group_name);
m_num_tracks_spinner->setMax(m_max_num_tracks); m_num_tracks_spinner->setMax(m_max_num_tracks);
@ -377,7 +378,9 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
} }
else if (name=="track-spinner") else if (name=="track-spinner")
{ {
m_gp.changeTrackNumber(m_num_tracks_spinner->getValue(), m_group_name); const int num_tranks = m_num_tracks_spinner->getValue();
m_gp.changeTrackNumber(num_tranks, m_group_name);
UserConfigParams::m_rand_gp_num_tracks = num_tranks;
addTracks(); addTracks();
} }
else if (name=="ai-spinner") else if (name=="ai-spinner")
@ -393,6 +396,8 @@ void GPInfoScreen::eventCallback(Widget *, const std::string &name,
} }
else if(name=="reverse-spinner") else if(name=="reverse-spinner")
{ {
const int reverse = m_reverse_spinner->getValue();
UserConfigParams::m_gp_reverse = reverse;
updateHighscores(); updateHighscores();
} }