Skip to content

Commit

Permalink
Removed string and bool support from the old MI_SelectField
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Mar 30, 2024
1 parent 996c466 commit 38a1090
Show file tree
Hide file tree
Showing 17 changed files with 990 additions and 1,008 deletions.
15 changes: 7 additions & 8 deletions src/common/ui/MI_SelectField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ bool MI_SelectField::SetIndex(unsigned short index)
return true;
}

void MI_SelectField::Add(std::string name, short ivalue, std::string svalue, bool fvalue, bool fhidden, bool fGoodRandom, short iIconOverride)
void MI_SelectField::Add(std::string name, short ivalue)
{
SF_ListItem * item = new SF_ListItem(name, ivalue, svalue, fvalue, fhidden, iIconOverride);
Add(std::move(name), ivalue, false);
}

void MI_SelectField::Add(std::string name, short ivalue, bool fhidden, bool fGoodRandom, short iIconOverride)
{
SF_ListItem * item = new SF_ListItem(name, ivalue, fhidden, iIconOverride);
items.push_back(item);

if (fGoodRandom)
Expand Down Expand Up @@ -306,12 +311,6 @@ void MI_SelectField::SetValues()
{
if (iValue)
*iValue = (*current)->iValue;

if (sValue)
*sValue = (*current)->sValue;

if (fValue)
*fValue = (*current)->fValue;
}

bool MI_SelectField::MoveNext()
Expand Down
23 changes: 3 additions & 20 deletions src/common/ui/MI_SelectField.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,30 @@ class SF_ListItem
public:
SF_ListItem() {
sName = "";

iValue = 0;
sValue = "";
fValue = false;
fHidden = false;
iIconOverride = -1;
}

SF_ListItem(std::string sname, short ivalue, std::string svalue, bool fvalue, bool fhidden, short iiconoverride) {
SF_ListItem(std::string sname, short ivalue, bool fhidden, short iiconoverride) {
sName = sname;

iValue = ivalue;
sValue = svalue;
fValue = fvalue;
fHidden = fhidden;
iIconOverride = iiconoverride;
}

SF_ListItem(const SF_ListItem& other) {
sName = other.sName;

iValue = other.iValue;
sValue = other.sValue;
fValue = other.fValue;

fHidden = other.fHidden;
iIconOverride = other.iIconOverride;
}

~SF_ListItem() {}

std::string sName; //Display name

short iValue; //int data
std::string sValue; //string data
bool fValue; //bool data for toggle controls

bool fHidden;

short iIconOverride;
};

Expand All @@ -82,9 +67,6 @@ class MI_SelectField : public UI_Control
short GetShortValue() {
return (*current)->iValue;
}
std::string GetStringValue() {
return (*current)->sValue;
}

//Gets a random value, but does not set the control to that value
short GetRandomShortValue() {
Expand All @@ -104,7 +86,8 @@ class MI_SelectField : public UI_Control
MenuCodeEnum Modify(bool modify);

//Adds an item to the list
void Add(std::string name, short ivalue, std::string svalue, bool fvalue, bool fhidden, bool fGoodRandom = true, short iIconOverride = -1);
void Add(std::string name, short ivalue);
void Add(std::string name, short ivalue, bool fhidden, bool fGoodRandom = true, short iIconOverride = -1);
void Clear() {
items.clear();
}
Expand Down
38 changes: 19 additions & 19 deletions src/smw/menu/MatchSelectionMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miMatchSelectionStartButton->SetCode(MENU_CODE_MATCH_SELECTION_START);

miMatchSelectionField = new MI_SelectField(&rm->spr_selectfield, 130, 340, "Match", 380, 100);
miMatchSelectionField->Add("Single Game", MATCH_TYPE_SINGLE_GAME, "", false, false);
miMatchSelectionField->Add("Tournament", MATCH_TYPE_TOURNAMENT, "", false, false);
miMatchSelectionField->Add("Tour", MATCH_TYPE_TOUR, "", false, false);
miMatchSelectionField->Add("World", MATCH_TYPE_WORLD, "", false, false);
miMatchSelectionField->Add("Minigame", MATCH_TYPE_MINIGAME, "", false, false);
miMatchSelectionField->Add("Single Game", MATCH_TYPE_SINGLE_GAME);
miMatchSelectionField->Add("Tournament", MATCH_TYPE_TOURNAMENT);
miMatchSelectionField->Add("Tour", MATCH_TYPE_TOUR);
miMatchSelectionField->Add("World", MATCH_TYPE_WORLD);
miMatchSelectionField->Add("Minigame", MATCH_TYPE_MINIGAME);
miMatchSelectionField->SetData(&game_values.matchtype, NULL, NULL);
miMatchSelectionField->SetKey(game_values.matchtype);
miMatchSelectionField->SetItemChangedCode(MENU_CODE_MATCH_SELECTION_MATCH_CHANGED);

miTournamentField = new MI_SelectField(&rm->spr_selectfield, 130, 380, "Wins", 380, 100);
miTournamentField->Add("2", 2, "", false, false);
miTournamentField->Add("3", 3, "", false, false);
miTournamentField->Add("4", 4, "", false, false);
miTournamentField->Add("5", 5, "", false, false);
miTournamentField->Add("6", 6, "", false, false);
miTournamentField->Add("7", 7, "", false, false);
miTournamentField->Add("8", 8, "", false, false);
miTournamentField->Add("9", 9, "", false, false);
miTournamentField->Add("10", 10, "", false, false);
miTournamentField->Add("2", 2);
miTournamentField->Add("3", 3);
miTournamentField->Add("4", 4);
miTournamentField->Add("5", 5);
miTournamentField->Add("6", 6);
miTournamentField->Add("7", 7);
miTournamentField->Add("8", 8);
miTournamentField->Add("9", 9);
miTournamentField->Add("10", 10);
miTournamentField->SetData(&game_values.tournamentgames, NULL, NULL);
miTournamentField->SetKey(game_values.tournamentgames);
miTournamentField->Show(false);
Expand All @@ -67,11 +67,11 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miWorldField->Show(false);

miMinigameField = new MI_SelectField(&rm->spr_selectfield, 130, 380, "Game", 380, 100);
miMinigameField->Add("Pipe Coin Game", 0, "", false, false);
miMinigameField->Add("Hammer Boss Game", 1, "", false, false);
miMinigameField->Add("Bomb Boss Game", 2, "", false, false);
miMinigameField->Add("Fire Boss Game", 3, "", false, false);
miMinigameField->Add("Boxes Game", 4, "", false, false);
miMinigameField->Add("Pipe Coin Game", 0);
miMinigameField->Add("Hammer Boss Game", 1);
miMinigameField->Add("Bomb Boss Game", 2);
miMinigameField->Add("Fire Boss Game", 3);
miMinigameField->Add("Boxes Game", 4);
miMinigameField->SetData(&game_values.selectedminigame, NULL, NULL);
miMinigameField->SetKey(game_values.selectedminigame);
miMinigameField->Show(false);
Expand Down
Loading

0 comments on commit 38a1090

Please sign in to comment.