Skip to content

Commit

Permalink
Renamed the new select field class to match the old one's name
Browse files Browse the repository at this point in the history
  • Loading branch information
mmatyas committed Mar 31, 2024
1 parent 95062d6 commit 04ceabf
Show file tree
Hide file tree
Showing 41 changed files with 327 additions and 327 deletions.
2 changes: 1 addition & 1 deletion src/common/ui/MI_ImageSelectField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ MI_ImageSelectField::MI_ImageSelectField(
std::string name,
short width, short indent,
short imageHeight, short imageWidth)
: MI_SelectFieldDyn<short>(nspr, x, y, std::move(name), width, indent)
: MI_SelectField<short>(nspr, x, y, std::move(name), width, indent)
, spr_image(nspr_image)
, iImageWidth(imageWidth)
, iImageHeight(imageHeight)
Expand Down
2 changes: 1 addition & 1 deletion src/common/ui/MI_ImageSelectField.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ui/MI_SelectField.h"


class MI_ImageSelectField : public MI_SelectFieldDyn<short> {
class MI_ImageSelectField : public MI_SelectField<short> {
public:
MI_ImageSelectField(
gfxSprite* nspr, gfxSprite* nspr_image,
Expand Down
42 changes: 21 additions & 21 deletions src/common/ui/MI_SelectField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern CResourceManager* rm;


template<typename T>
MI_SelectFieldDyn<T>::MI_SelectFieldDyn(gfxSprite* nspr, short x, short y, std::string name, short width, short indent)
MI_SelectField<T>::MI_SelectField(gfxSprite* nspr, short x, short y, std::string name, short width, short indent)
: UI_Control(x, y)
, m_spr(nspr)
, m_name(std::move(name))
Expand All @@ -27,7 +27,7 @@ MI_SelectFieldDyn<T>::MI_SelectFieldDyn(gfxSprite* nspr, short x, short y, std::


template<typename T>
MI_SelectFieldDyn<T>::MI_SelectFieldDyn(const MI_SelectFieldDyn<T>& other)
MI_SelectField<T>::MI_SelectField(const MI_SelectField<T>& other)
: UI_Control(other)
, m_spr(other.m_spr)
, m_name(other.m_name)
Expand All @@ -54,15 +54,15 @@ MI_SelectFieldDyn<T>::MI_SelectFieldDyn(const MI_SelectFieldDyn<T>& other)


template<typename T>
void MI_SelectFieldDyn<T>::Update()
void MI_SelectField<T>::Update()
{
miModifyImageRight->Update();
miModifyImageLeft->Update();
}


template<typename T>
void MI_SelectFieldDyn<T>::Draw()
void MI_SelectField<T>::Draw()
{
if (!fShow)
return;
Expand Down Expand Up @@ -96,7 +96,7 @@ void MI_SelectFieldDyn<T>::Draw()


template<typename T>
MenuCodeEnum MI_SelectFieldDyn<T>::Modify(bool modify)
MenuCodeEnum MI_SelectField<T>::Modify(bool modify)
{
if (fDisable)
return MENU_CODE_UNSELECT_ITEM;
Expand All @@ -117,7 +117,7 @@ MenuCodeEnum MI_SelectFieldDyn<T>::Modify(bool modify)


template<typename T>
MenuCodeEnum MI_SelectFieldDyn<T>::SendInput(CPlayerInput * playerInput)
MenuCodeEnum MI_SelectField<T>::SendInput(CPlayerInput * playerInput)
{
for (int iPlayer = 0; iPlayer < 4; iPlayer++) {
short iNumMoves = 1;
Expand Down Expand Up @@ -166,7 +166,7 @@ MenuCodeEnum MI_SelectFieldDyn<T>::SendInput(CPlayerInput * playerInput)


template<typename T>
MenuCodeEnum MI_SelectFieldDyn<T>::MouseClick(short iMouseX, short iMouseY) {
MenuCodeEnum MI_SelectField<T>::MouseClick(short iMouseX, short iMouseY) {
if (fDisable)
return MENU_CODE_NONE;

Expand Down Expand Up @@ -203,23 +203,23 @@ MenuCodeEnum MI_SelectFieldDyn<T>::MouseClick(short iMouseX, short iMouseY) {


template<typename T>
void MI_SelectFieldDyn<T>::Refresh()
void MI_SelectField<T>::Refresh()
{
if (m_outputPtr)
setCurrentValue(*m_outputPtr);
}


template<typename T>
T MI_SelectFieldDyn<T>::randomValue() const
T MI_SelectField<T>::randomValue() const
{
const size_t idx = m_goodRandomIndices.at(RANDOM_INT(m_goodRandomIndices.size()));
return m_items.at(idx).value;
}


template<typename T>
bool MI_SelectFieldDyn<T>::setCurrentValue(T value)
bool MI_SelectField<T>::setCurrentValue(T value)
{
for (m_index = 0; m_index < m_items.size(); m_index++) {
if (m_items[m_index].value == value) {
Expand All @@ -232,7 +232,7 @@ bool MI_SelectFieldDyn<T>::setCurrentValue(T value)


template<typename T>
bool MI_SelectFieldDyn<T>::setCurrentIndex(size_t index)
bool MI_SelectField<T>::setCurrentIndex(size_t index)
{
if (m_index < m_items.size()) {
m_index = index;
Expand All @@ -244,15 +244,15 @@ bool MI_SelectFieldDyn<T>::setCurrentIndex(size_t index)


template<typename T>
void MI_SelectFieldDyn<T>::updateOutput() const
void MI_SelectField<T>::updateOutput() const
{
if (m_outputPtr)
*m_outputPtr = currentValue();
}


template<typename T>
SF_ListItemDyn<T>& MI_SelectFieldDyn<T>::add(std::string name, T value, bool goodRandom)
SF_ListItem<T>& MI_SelectField<T>::add(std::string name, T value, bool goodRandom)
{
size_t new_idx = m_items.size();
m_items.emplace_back(std::move(name), std::move(value));
Expand All @@ -266,15 +266,15 @@ SF_ListItemDyn<T>& MI_SelectFieldDyn<T>::add(std::string name, T value, bool goo


template<typename T>
void MI_SelectFieldDyn<T>::clear()
void MI_SelectField<T>::clear()
{
m_items.clear();
m_goodRandomIndices.clear();
}


template<typename T>
void MI_SelectFieldDyn<T>::hideItem(T value, bool hide)
void MI_SelectField<T>::hideItem(T value, bool hide)
{
for (Item& item : m_items) {
if (item.value == value)
Expand All @@ -286,7 +286,7 @@ void MI_SelectFieldDyn<T>::hideItem(T value, bool hide)


template<typename T>
void MI_SelectFieldDyn<T>::hideAllItems(bool hide)
void MI_SelectField<T>::hideAllItems(bool hide)
{
for (Item& item : m_items) {
item.hidden = hide;
Expand All @@ -295,7 +295,7 @@ void MI_SelectFieldDyn<T>::hideAllItems(bool hide)


template<typename T>
bool MI_SelectFieldDyn<T>::moveNext()
bool MI_SelectField<T>::moveNext()
{
if (m_items.empty())
return false;
Expand All @@ -318,7 +318,7 @@ bool MI_SelectFieldDyn<T>::moveNext()


template<typename T>
bool MI_SelectFieldDyn<T>::movePrev()
bool MI_SelectField<T>::movePrev()
{
if (m_items.empty())
return false;
Expand All @@ -341,7 +341,7 @@ bool MI_SelectFieldDyn<T>::movePrev()


template<typename T>
bool MI_SelectFieldDyn<T>::moveRandom()
bool MI_SelectField<T>::moveRandom()
{
std::vector<size_t> valid_indices;
valid_indices.reserve(m_items.size());
Expand All @@ -360,5 +360,5 @@ bool MI_SelectFieldDyn<T>::moveRandom()


// Actual typed classes
template class MI_SelectFieldDyn<bool>;
template class MI_SelectFieldDyn<short>;
template class MI_SelectField<bool>;
template class MI_SelectField<short>;
14 changes: 7 additions & 7 deletions src/common/ui/MI_SelectField.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class MI_Image;


template<typename T>
struct SF_ListItemDyn {
SF_ListItemDyn(std::string&& name, T value)
struct SF_ListItem {
SF_ListItem(std::string&& name, T value)
: name(std::move(name))
, value(value)
{
Expand All @@ -29,13 +29,13 @@ struct SF_ListItemDyn {


template<typename T>
class MI_SelectFieldDyn : public UI_Control {
using Item = SF_ListItemDyn<T>;
class MI_SelectField : public UI_Control {
using Item = SF_ListItem<T>;

public:
MI_SelectFieldDyn(gfxSprite* nspr, short x, short y, std::string name, short width, short indent);
MI_SelectFieldDyn(const MI_SelectFieldDyn<T>&);
virtual ~MI_SelectFieldDyn() = default;
MI_SelectField(gfxSprite* nspr, short x, short y, std::string name, short width, short indent);
MI_SelectField(const MI_SelectField<T>&);
virtual ~MI_SelectField() = default;

//! Set the displayed name.
void setTitle(std::string name) {
Expand Down
6 changes: 3 additions & 3 deletions src/common/ui/MI_SliderField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ extern CResourceManager* rm;
**************************************/

MI_SliderField::MI_SliderField(gfxSprite * nspr, gfxSprite * nsprSlider, short x, short y, const char * name, short width, short indent1, short indent2)
: MI_SelectFieldDyn<short>(nspr, x, y, name, width, indent1)
: MI_SelectField<short>(nspr, x, y, name, width, indent1)
{
m_indent2 = indent2;
m_sprSlider = nsprSlider;
Expand All @@ -24,7 +24,7 @@ MI_SliderField::~MI_SliderField()

void MI_SliderField::SetPosition(short x, short y)
{
MI_SelectFieldDyn<short>::SetPosition(x, y);
MI_SelectField<short>::SetPosition(x, y);
miModifyImageLeft->SetPosition(ix + m_indent - 26, iy + 4);
miModifyImageRight->SetPosition(ix + m_width - 16, iy + 4);
}
Expand Down Expand Up @@ -80,5 +80,5 @@ MenuCodeEnum MI_SliderField::SendInput(CPlayerInput * playerInput)
}
}

return MI_SelectFieldDyn<short>::SendInput(playerInput);
return MI_SelectField<short>::SendInput(playerInput);
}
2 changes: 1 addition & 1 deletion src/common/ui/MI_SliderField.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "ui/MI_SelectField.h"


class MI_SliderField : public MI_SelectFieldDyn<short> {
class MI_SliderField : public MI_SelectField<short> {
public:
MI_SliderField(gfxSprite * nspr, gfxSprite * nsprSlider, short x, short y, const char * name, short width, short indent1, short indent2);
virtual ~MI_SliderField();
Expand Down
2 changes: 1 addition & 1 deletion src/smw/menu/GameSettingsMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ UI_GameSettingsMenu::UI_GameSettingsMenu()
miModeField->setItemChangedCode(MENU_CODE_MODE_CHANGED);

for (short iGameMode = 0; iGameMode < GAMEMODE_LAST; iGameMode++) {
miGoalField[iGameMode] = new MI_SelectFieldDyn<short>(&rm->spr_selectfield, 70, 125, gamemodes[iGameMode]->GetGoalName().c_str(), 352, 120);
miGoalField[iGameMode] = new MI_SelectField<short>(&rm->spr_selectfield, 70, 125, gamemodes[iGameMode]->GetGoalName().c_str(), 352, 120);
// miGoalField[iGameMode]->SetKey(gamemodes[iGameMode]->goal);
miGoalField[iGameMode]->Show(iGameMode == 0);

Expand Down
4 changes: 2 additions & 2 deletions src/smw/menu/GameSettingsMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class MI_ImageSelectField;
class MI_MapField;
class MI_MapFilterScroll;
class MI_Text;
template<typename T> class MI_SelectFieldDyn;
template<typename T> class MI_SelectField;


class UI_GameSettingsMenu : public UI_Menu {
Expand All @@ -30,7 +30,7 @@ class UI_GameSettingsMenu : public UI_Menu {

MI_MapFilterScroll* miMapFilterScroll = nullptr;
MI_MapField* miMapField = nullptr;
MI_SelectFieldDyn<short>* miGoalField[22];
MI_SelectField<short>* miGoalField[22];

private:
MI_ImageSelectField* miModeField = nullptr;
Expand Down
10 changes: 5 additions & 5 deletions src/smw/menu/MatchSelectionMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miMatchSelectionStartButton = new MI_Button(&rm->spr_selectfield, 270, 420, "Start", 100);
miMatchSelectionStartButton->SetCode(MENU_CODE_MATCH_SELECTION_START);

miMatchSelectionField = new MI_SelectFieldDyn<short>(&rm->spr_selectfield, 130, 340, "Match", 380, 100);
miMatchSelectionField = new MI_SelectField<short>(&rm->spr_selectfield, 130, 340, "Match", 380, 100);
miMatchSelectionField->add("Single Game", MATCH_TYPE_SINGLE_GAME);
miMatchSelectionField->add("Tournament", MATCH_TYPE_TOURNAMENT);
miMatchSelectionField->add("Tour", MATCH_TYPE_TOUR);
Expand All @@ -32,7 +32,7 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miMatchSelectionField->setCurrentValue(game_values.matchtype);
miMatchSelectionField->setItemChangedCode(MENU_CODE_MATCH_SELECTION_MATCH_CHANGED);

miTournamentField = new MI_SelectFieldDyn<short>(&rm->spr_selectfield, 130, 380, "Wins", 380, 100);
miTournamentField = new MI_SelectField<short>(&rm->spr_selectfield, 130, 380, "Wins", 380, 100);
miTournamentField->add("2", 2);
miTournamentField->add("3", 3);
miTournamentField->add("4", 4);
Expand All @@ -46,7 +46,7 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miTournamentField->setCurrentValue(game_values.tournamentgames);
miTournamentField->Show(false);

miTourField = new MI_SelectFieldDyn<short>(&rm->spr_selectfield, 130, 380, "Tour", 380, 100);
miTourField = new MI_SelectField<short>(&rm->spr_selectfield, 130, 380, "Tour", 380, 100);
for (short iTour = 0; iTour < tourlist->GetCount(); iTour++) {
std::string szTemp = GetNameFromFileName(tourlist->GetIndex(iTour), true);
// strcat(szTemp, " Tour");
Expand All @@ -56,7 +56,7 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miTourField->setCurrentValue(game_values.tourindex);
miTourField->Show(false);

miWorldField = new MI_SelectFieldDyn<short>(&rm->spr_selectfield, 130, 380, "World", 380, 100);
miWorldField = new MI_SelectField<short>(&rm->spr_selectfield, 130, 380, "World", 380, 100);
for (short iWorld = 0; iWorld < worldlist->GetCount(); iWorld++) {
std::string szTemp = GetNameFromFileName(worldlist->GetIndex(iWorld), true);
miWorldField->add(std::move(szTemp), iWorld);
Expand All @@ -66,7 +66,7 @@ UI_MatchSelectionMenu::UI_MatchSelectionMenu()
miWorldField->setItemChangedCode(MENU_CODE_WORLD_MAP_CHANGED);
miWorldField->Show(false);

miMinigameField = new MI_SelectFieldDyn<short>(&rm->spr_selectfield, 130, 380, "Game", 380, 100);
miMinigameField = new MI_SelectField<short>(&rm->spr_selectfield, 130, 380, "Game", 380, 100);
miMinigameField->add("Pipe Coin Game", 0);
miMinigameField->add("Hammer Boss Game", 1);
miMinigameField->add("Bomb Boss Game", 2);
Expand Down
12 changes: 6 additions & 6 deletions src/smw/menu/MatchSelectionMenu.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MI_Button;
class MI_Image;
class MI_Text;
class MI_WorldPreviewDisplay;
template<typename T> class MI_SelectFieldDyn;
template<typename T> class MI_SelectField;


class UI_MatchSelectionMenu : public UI_Menu {
Expand All @@ -22,11 +22,11 @@ class UI_MatchSelectionMenu : public UI_Menu {
private:
MI_Image* miMatchSelectionDisplayImage;

MI_SelectFieldDyn<short>* miMatchSelectionField;
MI_SelectFieldDyn<short>* miTournamentField;
MI_SelectFieldDyn<short>* miTourField;
MI_SelectFieldDyn<short>* miWorldField;
MI_SelectFieldDyn<short>* miMinigameField;
MI_SelectField<short>* miMatchSelectionField;
MI_SelectField<short>* miTournamentField;
MI_SelectField<short>* miTourField;
MI_SelectField<short>* miWorldField;
MI_SelectField<short>* miMinigameField;
MI_WorldPreviewDisplay* miWorldPreviewDisplay;

MI_Button* miMatchSelectionStartButton;
Expand Down
Loading

0 comments on commit 04ceabf

Please sign in to comment.