diff options
-rw-r--r-- | src/gui/models/typelistmodel.h | 31 | ||||
-rw-r--r-- | src/gui/windows/editserverdialog.cpp | 31 |
2 files changed, 23 insertions, 39 deletions
diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h index 52b9afeed..9b0b9deb8 100644 --- a/src/gui/models/typelistmodel.h +++ b/src/gui/models/typelistmodel.h @@ -25,6 +25,14 @@ #include "gui/models/listmodel.h" +// Yes, I could've swapped TMWA and Evol2 in type list, but Hello=) +// would've screamed at me. +#ifdef TMWA_SUPPORT +#define SERVER_TYPE_INDEX_OFFSET 0 +#else // TMWA_SUPPORT +#define SERVER_TYPE_INDEX_OFFSET 1 +#endif // TMWA_SUPPORT + /** * Server Type List Model */ @@ -53,22 +61,15 @@ class TypeListModel final : public ListModel std::string getElementAt(int elementIndex) override final A_WARN_UNUSED { + switch (elementIndex) + { #ifdef TMWA_SUPPORT - if (elementIndex == 0) - return "TMW Athena"; - else if (elementIndex == 1) - return "Hercules"; - else if (elementIndex == 2) - return "Evol2 Hercules"; - else -#else // TMWA_SUPPORT - if (elementIndex == 0) - return "Hercules"; - else if (elementIndex == 1) - return "Evol2 Hercules"; - else -#endif // TMWA_SUPPORT - return "Unknown"; + case 0: return "TMW Athena"; break; +#endif // defined(TMWA_SUPPORT) + case 1 - SERVER_TYPE_INDEX_OFFSET: return "Hercules"; break; + case 2 - SERVER_TYPE_INDEX_OFFSET: return "Evol2 Hercules"; break; + default: return "Unknown"; break; + } } }; diff --git a/src/gui/windows/editserverdialog.cpp b/src/gui/windows/editserverdialog.cpp index e73e1ab43..80dfe60ea 100644 --- a/src/gui/windows/editserverdialog.cpp +++ b/src/gui/windows/editserverdialog.cpp @@ -165,24 +165,16 @@ EditServerDialog::EditServerDialog(ServerDialog *const parent, switch (mServer.type) { - case ServerType::EATHENA: -#ifdef TMWA_SUPPORT - mTypeField->setSelected(1); -#else // TMWA_SUPPORT - mTypeField->setSelected(0); -#endif // TMWA_SUPPORT - break; default: case ServerType::UNKNOWN: case ServerType::TMWATHENA: mTypeField->setSelected(0); break; + case ServerType::EATHENA: + mTypeField->setSelected(1 - SERVER_TYPE_INDEX_OFFSET); + break; case ServerType::EVOL2: -#ifdef TMWA_SUPPORT - mTypeField->setSelected(2); -#else // TMWA_SUPPORT - mTypeField->setSelected(1); -#endif // TMWA_SUPPORT + mTypeField->setSelected(2 - SERVER_TYPE_INDEX_OFFSET); break; } @@ -253,22 +245,13 @@ void EditServerDialog::action(const ActionEvent &event) case 0: mServer.type = ServerType::TMWATHENA; break; - case 1: - mServer.type = ServerType::EATHENA; - break; - case 2: +#endif // TMWA_SUPPORT + case 1 - SERVER_TYPE_INDEX_OFFSET: mServer.type = ServerType::EVOL2; break; -#else // TMWA_SUPPORT - - case 0: + case 2 - SERVER_TYPE_INDEX_OFFSET: mServer.type = ServerType::EATHENA; break; - case 1: - mServer.type = ServerType::EVOL2; - break; -#endif // TMWA_SUPPORT - default: mServer.type = ServerType::UNKNOWN; break; |