diff options
Diffstat (limited to 'src/gui/models')
44 files changed, 0 insertions, 3686 deletions
diff --git a/src/gui/models/avatarlistmodel.h b/src/gui/models/avatarlistmodel.h deleted file mode 100644 index 67ec6846a..000000000 --- a/src/gui/models/avatarlistmodel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_AVATARLISTMODEL_H -#define GUI_MODELS_AVATARLISTMODEL_H - -#include "avatar.h" - -#include "gui/models/listmodel.h" - -class AvatarListModel notfinal : public ListModel -{ - public: - AvatarListModel() : - ListModel() - { } - - A_DELETE_COPY(AvatarListModel) - - virtual Avatar *getAvatarAt(const int i) A_WARN_UNUSED = 0; - - std::string getElementAt(int i) override final A_WARN_UNUSED - { return getAvatarAt(i)->getName(); } -}; - -#endif // GUI_MODELS_AVATARLISTMODEL_H diff --git a/src/gui/models/beingslistmodel.h b/src/gui/models/beingslistmodel.h deleted file mode 100644 index a0a9d2920..000000000 --- a/src/gui/models/beingslistmodel.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_BEINGSLISTMODEL_H -#define GUI_MODELS_BEINGSLISTMODEL_H - -#include "gui/models/avatarlistmodel.h" - -#include "utils/cast.h" -#include "utils/dtor.h" -#include "utils/vector.h" - -class BeingsListModel final : public AvatarListModel -{ - public: - BeingsListModel() : - AvatarListModel(), - mMembers() - { - } - - A_DELETE_COPY(BeingsListModel) - - ~BeingsListModel() - { - delete_all(mMembers); - mMembers.clear(); - } - - STD_VECTOR<Avatar*> *getMembers() RETURNS_NONNULL A_WARN_UNUSED - { - return &mMembers; - } - - Avatar *getAvatarAt(int index) override final - { - return mMembers[index]; - } - - int getNumberOfElements() override final - { - return CAST_S32(mMembers.size()); - } - - STD_VECTOR<Avatar*> mMembers; -}; - -#endif // GUI_MODELS_BEINGSLISTMODEL_H diff --git a/src/gui/models/colorlistmodel.h b/src/gui/models/colorlistmodel.h deleted file mode 100644 index bb2d413c2..000000000 --- a/src/gui/models/colorlistmodel.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_COLORLISTMODEL_H -#define GUI_MODELS_COLORLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -const char *COLOR_NAME[14] = -{ - // TRANSLATORS: chat color - N_("default"), - // TRANSLATORS: chat color - N_("black"), - // TRANSLATORS: chat color - N_("red"), - // TRANSLATORS: chat color - N_("green"), - // TRANSLATORS: chat color - N_("blue"), - // TRANSLATORS: chat color - N_("gold"), - // TRANSLATORS: chat color - N_("yellow"), - // TRANSLATORS: chat color - N_("pink"), - // TRANSLATORS: chat color - N_("purple"), - // TRANSLATORS: chat color - N_("grey"), - // TRANSLATORS: chat color - N_("brown"), - // TRANSLATORS: chat color - N_("rainbow 1"), - // TRANSLATORS: chat color - N_("rainbow 2"), - // TRANSLATORS: chat color - N_("rainbow 3"), -}; - -class ColorListModel final : public ListModel -{ - public: - ColorListModel() : - ListModel() - { } - - A_DELETE_COPY(ColorListModel) - - ~ColorListModel() - { } - - int getNumberOfElements() override final - { - return 14; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(COLOR_NAME[i]); - } -}; - -#endif // GUI_MODELS_COLORLISTMODEL_H diff --git a/src/gui/models/colormodel.cpp b/src/gui/models/colormodel.cpp deleted file mode 100644 index 3bbded2e2..000000000 --- a/src/gui/models/colormodel.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/colormodel.h" - -#include "gui/widgets/widget2.h" - -#include "utils/gettext.h" - -#include "debug.h" - -ColorModel::ColorModel() : - ListModel(), - mNames(), - mColors() -{ -} - -ColorModel::~ColorModel() -{ -} - -int ColorModel::getNumberOfElements() -{ - return CAST_S32(mNames.size()); -} - -std::string ColorModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[CAST_SIZE(i)]; -} - -const ColorPair *ColorModel::getColorAt(const int i) const -{ - if (i >= CAST_S32(mColors.size()) || i < 0) - return &mColors[0]; - - return &mColors[CAST_SIZE(i)]; -} - -void ColorModel::add(const std::string &name, const Color *const color1, - const Color *const color2) -{ - mNames.push_back(name); - mColors.push_back(ColorPair(color1, color2)); -} - -#define addColor(name, color) \ - model->add(name, &widget->getThemeColor(ThemeColorId::color), \ - &widget->getThemeColor(ThemeColorId::color##_OUTLINE)); - -ColorModel *ColorModel::createDefault(const Widget2 *const widget) -{ - ColorModel *const model = new ColorModel; - if (widget == nullptr) - return model; - // TRANSLATORS: color name - addColor(_("black"), BLACK); - // TRANSLATORS: color name - addColor(_("red"), RED); - // TRANSLATORS: color name - addColor(_("green"), GREEN); - // TRANSLATORS: color name - addColor(_("blue"), BLUE); - // TRANSLATORS: color name - addColor(_("gold"), ORANGE); - // TRANSLATORS: color name - addColor(_("yellow"), YELLOW); - // TRANSLATORS: color name - addColor(_("pink"), PINK); - // TRANSLATORS: color name - addColor(_("purple"), PURPLE); - // TRANSLATORS: color name - addColor(_("grey"), GRAY); - // TRANSLATORS: color name - addColor(_("brown"), BROWN); - return model; -} diff --git a/src/gui/models/colormodel.h b/src/gui/models/colormodel.h deleted file mode 100644 index 9d621dfbe..000000000 --- a/src/gui/models/colormodel.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_COLORMODEL_H -#define GUI_MODELS_COLORMODEL_H - -#include "utils/stringvector.h" - -#include "gui/colorpair.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -class Color; -class Widget2; - -class ColorModel final : public ListModel -{ - public: - ColorModel(); - - A_DELETE_COPY(ColorModel) - - virtual ~ColorModel(); - - int getNumberOfElements() override final A_WARN_UNUSED; - - std::string getElementAt(int i) override final A_WARN_UNUSED; - - const ColorPair *getColorAt(const int i) - const RETURNS_NONNULL A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - size_t size() A_WARN_UNUSED - { return mNames.size(); } - - void add(const std::string &name, - const Color *const color1, - const Color *const color2); - - static ColorModel *createDefault(const Widget2 *const widget) - RETURNS_NONNULL; - - protected: - StringVect mNames; - STD_VECTOR<ColorPair> mColors; -}; - -#endif // GUI_MODELS_COLORMODEL_H diff --git a/src/gui/models/extendedlistmodel.h b/src/gui/models/extendedlistmodel.h deleted file mode 100644 index 981a96897..000000000 --- a/src/gui/models/extendedlistmodel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_EXTENDEDLISTMODEL_H -#define GUI_MODELS_EXTENDEDLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "resources/image/image.h" - -class ExtendedListModel notfinal : public ListModel -{ - public: - ExtendedListModel() : - ListModel() - { } - - A_DELETE_COPY(ExtendedListModel) - - virtual const Image *getImageAt(int i) A_WARN_UNUSED = 0; -}; - -#endif // GUI_MODELS_EXTENDEDLISTMODEL_H diff --git a/src/gui/models/extendednamesmodel.cpp b/src/gui/models/extendednamesmodel.cpp deleted file mode 100644 index 76191ae5a..000000000 --- a/src/gui/models/extendednamesmodel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/extendednamesmodel.h" - -#include "utils/cast.h" -#include "utils/foreach.h" - -#include "debug.h" - -ExtendedNamesModel::ExtendedNamesModel() : - mNames(), - mImages() -{ -} - -ExtendedNamesModel::~ExtendedNamesModel() -{ - clear(); -} - -int ExtendedNamesModel::getNumberOfElements() -{ - return CAST_S32(mNames.size()); -} - -std::string ExtendedNamesModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[CAST_SIZE(i)]; -} - -const Image *ExtendedNamesModel::getImageAt(int i) -{ - if (i >= CAST_S32(mImages.size()) || i < 0) - return nullptr; - - return mImages[CAST_SIZE(i)]; -} - -void ExtendedNamesModel::clear() -{ - mNames.clear(); - FOR_EACH (STD_VECTOR<Image*>::iterator, it, mImages) - { - if (*it != nullptr) - (*it)->decRef(); - } - mImages.clear(); -} diff --git a/src/gui/models/extendednamesmodel.h b/src/gui/models/extendednamesmodel.h deleted file mode 100644 index 2e85a4b2b..000000000 --- a/src/gui/models/extendednamesmodel.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_EXTENDEDNAMESMODEL_H -#define GUI_MODELS_EXTENDEDNAMESMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/extendedlistmodel.h" - -class ExtendedNamesModel notfinal : public ExtendedListModel -{ - public: - ExtendedNamesModel(); - - A_DELETE_COPY(ExtendedNamesModel) - - virtual ~ExtendedNamesModel(); - - int getNumberOfElements() override final A_WARN_UNUSED; - - std::string getElementAt(int i) override final A_WARN_UNUSED; - - const Image *getImageAt(int i) override final A_WARN_UNUSED; - - StringVect &getNames() A_WARN_UNUSED - { return mNames; } - - STD_VECTOR<Image*> &getImages() A_WARN_UNUSED - { return mImages; } - - size_t size() A_WARN_UNUSED - { return mNames.size(); } - - void add(const std::string &str) - { mNames.push_back(str); } - - void clear(); - - protected: - StringVect mNames; - STD_VECTOR<Image*> mImages; -}; - -#endif // GUI_MODELS_EXTENDEDNAMESMODEL_H diff --git a/src/gui/models/fontsizechoicelistmodel.h b/src/gui/models/fontsizechoicelistmodel.h deleted file mode 100644 index 79aecf2fb..000000000 --- a/src/gui/models/fontsizechoicelistmodel.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_FONTSIZECHOICELISTMODEL_H -#define GUI_MODELS_FONTSIZECHOICELISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -const int maxFontSizes = 16; - -const char *SIZE_NAME[maxFontSizes] = -{ - // TRANSLATORS: font size - N_("Very small (8)"), - // TRANSLATORS: font size - N_("Very small (9)"), - // TRANSLATORS: font size - N_("Tiny (10)"), - // TRANSLATORS: font size - N_("Small (11)"), - // TRANSLATORS: font size - N_("Medium (12)"), - // TRANSLATORS: font size - N_("Normal (13)"), - // TRANSLATORS: font size - N_("Large (14)"), - // TRANSLATORS: font size - N_("Large (15)"), - // TRANSLATORS: font size - N_("Large (16)"), - // TRANSLATORS: font size - N_("Big (17)"), - // TRANSLATORS: font size - N_("Big (18)"), - // TRANSLATORS: font size - N_("Big (19)"), - // TRANSLATORS: font size - N_("Very big (20)"), - // TRANSLATORS: font size - N_("Very big (21)"), - // TRANSLATORS: font size - N_("Very big (22)"), - // TRANSLATORS: font size - N_("Huge (23)") -}; - -class FontSizeChoiceListModel final : public ListModel -{ - public: - FontSizeChoiceListModel() : - ListModel() - { } - - A_DELETE_COPY(FontSizeChoiceListModel) - - ~FontSizeChoiceListModel() - { } - - int getNumberOfElements() override final A_WARN_UNUSED - { return maxFontSizes; } - - std::string getElementAt(int i) override final A_WARN_UNUSED - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return gettext(SIZE_NAME[i]); - } -}; - -#endif // GUI_MODELS_FONTSIZECHOICELISTMODEL_H diff --git a/src/gui/models/fontsmodel.h b/src/gui/models/fontsmodel.h deleted file mode 100644 index b7f5fc4be..000000000 --- a/src/gui/models/fontsmodel.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_FONTSMODEL_H -#define GUI_MODELS_FONTSMODEL_H - -#include "gui/theme.h" - -#include "gui/models/namesmodel.h" - -#include "localconsts.h" - -class FontsModel final : public NamesModel -{ - public: - FontsModel() : - NamesModel() - { Theme::fillFontsList(mNames); } - - A_DELETE_COPY(FontsModel) - - ~FontsModel() - { } -}; - -#endif // GUI_MODELS_FONTSMODEL_H diff --git a/src/gui/models/iconsmodel.h b/src/gui/models/iconsmodel.h deleted file mode 100644 index 4028895fb..000000000 --- a/src/gui/models/iconsmodel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_ICONSMODEL_H -#define GUI_MODELS_ICONSMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/foreach.h" - -#include "resources/iteminfo.h" - -#include "resources/db/itemdb.h" - -#include <list> - -#include "localconsts.h" - -class IconsModel final : public ListModel -{ - public: - IconsModel() : - mStrings() - { - const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos(); - std::list<std::string> tempStrings; - - for (std::map<int, ItemInfo*>::const_iterator - i = items.begin(), i_end = items.end(); - i != i_end; ++i) - { - if (i->first < 0) - continue; - - const ItemInfo &info = (*i->second); - const std::string &name = info.getName(); - if (name != "unnamed" && !info.getName().empty() - && info.getName() != "unnamed") - { - tempStrings.push_back(name); - } - } - tempStrings.sort(); - mStrings.push_back(""); - FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings) - mStrings.push_back(*i); - } - - A_DELETE_COPY(IconsModel) - - ~IconsModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(mStrings.size()); - } - - std::string getElementAt(int i) override final - { - if (i < 0 || i >= getNumberOfElements()) - return "???"; - return mStrings.at(i); - } - private: - StringVect mStrings; -}; - -#endif // GUI_MODELS_ICONSMODEL_H diff --git a/src/gui/models/ignorechoiceslistmodel.h b/src/gui/models/ignorechoiceslistmodel.h deleted file mode 100644 index 6cd8bbe87..000000000 --- a/src/gui/models/ignorechoiceslistmodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_IGNORECHOICESLISTMODEL_H -#define GUI_MODELS_IGNORECHOICESLISTMODEL_H - -#include "gui/models/playerrelationlistmodel.h" - -#include "being/playerignorestrategy.h" -#include "being/playerrelations.h" - -#include "utils/cast.h" - -/** - * Class for choosing one of the various `what to do when ignoring a player' options - */ -class IgnoreChoicesListModel final : public ListModel -{ - public: - IgnoreChoicesListModel() : - ListModel() - { } - - A_DELETE_COPY(IgnoreChoicesListModel) - - ~IgnoreChoicesListModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(playerRelations. - getPlayerIgnoreStrategies()->size()); - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return (*playerRelations.getPlayerIgnoreStrategies()) - [i]->mDescription; - } -}; - -#endif // GUI_MODELS_IGNORECHOICESLISTMODEL_H diff --git a/src/gui/models/itemsmodel.h b/src/gui/models/itemsmodel.h deleted file mode 100644 index a49a7cfc5..000000000 --- a/src/gui/models/itemsmodel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_ITEMSMODEL_H -#define GUI_MODELS_ITEMSMODEL_H - -#include "gui/models/listmodel.h" - -#include "resources/iteminfo.h" - -#include "resources/db/itemdb.h" - -#include "utils/foreach.h" - -#include <list> - -#include "localconsts.h" - -class ItemsModal final : public ListModel -{ - public: - ItemsModal() : - mStrings() - { - const std::map<int, ItemInfo*> &items = ItemDB::getItemInfos(); - std::list<std::string> tempStrings; - - for (std::map<int, ItemInfo*>::const_iterator - i = items.begin(), i_end = items.end(); - i != i_end; ++i) - { - if (i->first < 0) - continue; - - const ItemInfo &info = *i->second; - const std::string &name = info.getName(); - if (name != "unnamed" && !info.getName().empty() - && info.getName() != "unnamed") - { - tempStrings.push_back(name); - } - } - tempStrings.sort(); - FOR_EACH (std::list<std::string>::const_iterator, i, tempStrings) - mStrings.push_back(*i); - } - - A_DELETE_COPY(ItemsModal) - - ~ItemsModal() - { } - - int getNumberOfElements() override final - { - return CAST_S32(mStrings.size()); - } - - std::string getElementAt(int i) override final - { - if (i < 0 || i >= getNumberOfElements()) - return "???"; - return mStrings.at(i); - } - - private: - StringVect mStrings; -}; - -#endif // GUI_MODELS_ITEMSMODEL_H diff --git a/src/gui/models/keylistmodel.h b/src/gui/models/keylistmodel.h deleted file mode 100644 index 601426f8a..000000000 --- a/src/gui/models/keylistmodel.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2007 Joshua Langley <joshlangley@optusnet.com.au> - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_KEYLISTMODEL_H -#define GUI_MODELS_KEYLISTMODEL_H - -#include "gui/setupactiondata.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -extern SetupActionData *const setupActionData[]; - -/** - * The list model for key function list. - * - * \ingroup Interface - */ -class KeyListModel final : public ListModel -{ - public: - KeyListModel() : - mDataNum(0), - mSelectedData(0), - mSize(0) - { - } - - A_DELETE_COPY(KeyListModel) - - /** - * Returns the number of elements in container. - */ - int getNumberOfElements() override final - { return mSize; } - - /** - * Returns element from container. - */ - std::string getElementAt(int i) override final - { return setupActionData[mSelectedData][i].text; } - - /** - * Sets element from container. - */ - void setElementAt(const int i, const std::string &caption) - { setupActionData[mSelectedData][i].text = caption; } - - void setSize(const int size) noexcept2 - { mSize = size; } - - void setDataNum(const int num) noexcept2 - { mDataNum = num; } - - void setSelectedData(const int i) noexcept2 - { mSelectedData = i; } - - int getSelectedData() const noexcept2 A_WARN_UNUSED - { return mSelectedData; } - - private: - int mDataNum; - int mSelectedData; - int mSize; -}; - -#endif // GUI_MODELS_KEYLISTMODEL_H diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h deleted file mode 100644 index f8c67ad30..000000000 --- a/src/gui/models/langlistmodel.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_LANGLISTMODEL_H -#define GUI_MODELS_LANGLISTMODEL_H - -#include "gui/models/extendedlistmodel.h" - -#include "resources/loaders/imageloader.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -struct Language final -{ - A_DEFAULT_COPY(Language) - - std::string name; - std::string value; - std::string icon; -}; - -const int langs_count = 22; - -const Language LANG_NAME[langs_count] = -{ - // TRANSLATORS: language - {N_("(default)"), "", ""}, - // TRANSLATORS: language - {N_("Catalan"), "ca_ES", "ca.png"}, - // TRANSLATORS: language - {N_("Chinese (China)"), "zh_CN", "cn.png"}, - // TRANSLATORS: language - {N_("Chinese (Hong Kong)"), "zh_HK", "hk.png"}, - // TRANSLATORS: language - {N_("Czech"), "cs_CZ", "cz.png"}, - // TRANSLATORS: language - {N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"}, - // TRANSLATORS: language - {N_("English"), "C", "en.png"}, - // TRANSLATORS: language - {N_("Finnish"), "fi_FI", "fi.png"}, - // TRANSLATORS: language - {N_("French"), "fr_FR", "fr.png"}, - // TRANSLATORS: language - {N_("German"), "de_DE", "de.png"}, - // TRANSLATORS: language - {N_("Indonesian"), "id_ID", "id.png"}, - // TRANSLATORS: language - {N_("Italian"), "it_IT", "it.png"}, - // TRANSLATORS: language - {N_("Japanese"), "ja_JP", "jp.png"}, - // TRANSLATORS: language - {N_("Polish"), "pl_PL", "pl.png"}, - // TRANSLATORS: language - {N_("Portuguese"), "pt_PT", "pt.png"}, - // TRANSLATORS: language - {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"}, - // TRANSLATORS: language - {N_("Russian"), "ru_RU", "ru.png"}, - // TRANSLATORS: language - {N_("Spanish (Castilian)"), "es_ES", "es.png"}, - // TRANSLATORS: language - {N_("Swedish (Sweden)"), "sv_SE", "se.png"}, - // TRANSLATORS: language - {N_("Turkish"), "tr_TR", "tr.png"}, - // TRANSLATORS: language - {N_("Ukrainian"), "uk_UA", "ua.png"}, - // TRANSLATORS: language - {N_("Esperanto"), "eo", "eo.png"} -}; - -class LangListModel final : public ExtendedListModel -{ - public: - LangListModel() - { - for (int f = 0; f < langs_count; f ++) - { - const std::string icon = LANG_NAME[f].icon; - if (!icon.empty()) - { - mIcons[f] = Loader::getImage("graphics/flags/" - + icon); - } - else - { - mIcons[f] = nullptr; - } - } - } - - A_DELETE_COPY(LangListModel) - - ~LangListModel() - { - for (int f = 0; f < langs_count; f ++) - { - Image *const img = mIcons[f]; - if (img != nullptr) - img->decRef(); - } - } - - int getNumberOfElements() override final A_WARN_UNUSED - { return langs_count; } - - std::string getElementAt(int i) override final A_WARN_UNUSED - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return gettext(LANG_NAME[i].name.c_str()); - } - - const Image *getImageAt(int i) override final A_WARN_UNUSED - { - if (i >= getNumberOfElements() || i < 0) - return nullptr; - return mIcons[i]; - } - - Image *mIcons[langs_count] A_NONNULLPOINTER; -}; - -#endif // GUI_MODELS_LANGLISTMODEL_H diff --git a/src/gui/models/listmodel.h b/src/gui/models/listmodel.h deleted file mode 100644 index df8db8b54..000000000 --- a/src/gui/models/listmodel.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson - * - * - * Per Larsson a.k.a finalman - * Olof Naessén a.k.a jansem/yakslem - * - * Visit: http://guichan.sourceforge.net - * - * License: (BSD) - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 3. Neither the name of Guichan nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef GUI_MODELS_LISTMODEL_H -#define GUI_MODELS_LISTMODEL_H - -#include <string> - -#include "localconsts.h" - -/** - * An interface for a model that represents a list. It is - * used in certain widgets, like the ListBox, to handle a - * lists with string elements. If you want to use widgets - * like ListBox, make a derived class from this class that - * represents your list. - */ -class ListModel notfinal -{ - public: - ListModel() - { } - - A_DELETE_COPY(ListModel) - - /** - * Destructor. - */ - virtual ~ListModel() - { } - - /** - * Gets the number of elements in the list. - * - * @return The number of elements in the list - */ - virtual int getNumberOfElements() A_WARN_UNUSED = 0; - - /** - * Gets an element at a certain index in the list. - * - * @param i An index in the list. - * @return An element as a string at the a certain index. - */ - virtual std::string getElementAt(int i) A_WARN_UNUSED = 0; -}; - -#endif // GUI_MODELS_LISTMODEL_H diff --git a/src/gui/models/magicschoolmodel.h b/src/gui/models/magicschoolmodel.h deleted file mode 100644 index 2dcd01880..000000000 --- a/src/gui/models/magicschoolmodel.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009 The Mana World Development Team - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_MAGICSCHOOLMODEL_H -#define GUI_MODELS_MAGICSCHOOLMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -const char *MAGIC_SCHOOL_TEXT[6] = -{ - // TRANSLATORS: magic school - N_("General Magic"), - // TRANSLATORS: magic school - N_("Life Magic"), - // TRANSLATORS: magic school - N_("War Magic"), - // TRANSLATORS: magic school - N_("Transmute Magic"), - // TRANSLATORS: magic school - N_("Nature Magic"), - // TRANSLATORS: magic school - N_("Astral Magic") -}; - -class MagicSchoolModel final : public ListModel -{ - public: - MagicSchoolModel() : - ListModel() - { } - - A_DELETE_COPY(MagicSchoolModel) - - ~MagicSchoolModel() - { } - - int getNumberOfElements() override final - { - return 6; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return MAGIC_SCHOOL_TEXT[i]; - } -}; - -#endif // GUI_MODELS_MAGICSCHOOLMODEL_H diff --git a/src/gui/models/modelistmodel.cpp b/src/gui/models/modelistmodel.cpp deleted file mode 100644 index d1253b9f1..000000000 --- a/src/gui/models/modelistmodel.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "render/graphics.h" - -#include "utils/sdlhelper.h" -#include "utils/stringutils.h" - -#include "gui/models/modelistmodel.h" - -#include <algorithm> - -#include "debug.h" - -#ifndef ANDROID -static bool modeSorter(const std::string &mode1, const std::string &mode2) -{ - const int width1 = atoi(mode1.substr(0, mode1.find('x')).c_str()); - const int height1 = atoi(mode1.substr(mode1.find('x') + 1).c_str()); - if ((width1 == 0) || (height1 == 0)) - return false; - - const int width2 = atoi(mode2.substr(0, mode2.find('x')).c_str()); - const int height2 = atoi(mode2.substr(mode2.find('x') + 1).c_str()); - if ((width2 == 0) || (height2 == 0)) - return false; - if (width1 != width2) - return width1 < width2; - - if (height1 != height2) - return height1 < height2; - - return false; -} -#endif // ANDROID - -ModeListModel::ModeListModel() : - ListModel(), - mVideoModes() -{ - SDL::getAllVideoModes(mVideoModes); -#ifndef ANDROID - addCustomMode("640x480"); - addCustomMode("800x600"); - addCustomMode("1024x768"); - addCustomMode("1280x1024"); - addCustomMode("1400x900"); - addCustomMode("1500x990"); - addCustomMode(toString(mainGraphics->mActualWidth).append("x") - .append(toString(mainGraphics->mActualHeight))); - - std::sort(mVideoModes.begin(), mVideoModes.end(), &modeSorter); - mVideoModes.push_back("custom"); -#endif // ANDROID -} - -#ifndef ANDROID -void ModeListModel::addCustomMode(const std::string &mode) -{ - StringVectCIter it = mVideoModes.begin(); - const StringVectCIter it_end = mVideoModes.end(); - while (it != it_end) - { - if (*it == mode) - return; - ++ it; - } - mVideoModes.push_back(mode); -} -#endif // ANDROID - -int ModeListModel::getIndexOf(const std::string &widthXHeightMode) -{ - std::string currentMode; - for (int i = 0; i < getNumberOfElements(); i++) - { - currentMode = getElementAt(i); - if (currentMode == widthXHeightMode) - return i; - } - return -1; -} diff --git a/src/gui/models/modelistmodel.h b/src/gui/models/modelistmodel.h deleted file mode 100644 index ed4d449d7..000000000 --- a/src/gui/models/modelistmodel.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_MODELISTMODEL_H -#define GUI_MODELS_MODELISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" -#include "utils/stringvector.h" - -#include "localconsts.h" - -class ModeListModel final : public ListModel -{ - public: - ModeListModel(); - - A_DELETE_COPY(ModeListModel) - - ~ModeListModel() - { } - - /** - * Returns the number of elements in container. - */ - int getNumberOfElements() override final - { return CAST_S32(mVideoModes.size()); } - - /** - * Returns element from container. - */ - std::string getElementAt(int i) override final - { return mVideoModes[CAST_SIZE(i)]; } - - /** - * Returns the index corresponding to the given video mode. - * E.g.: "800x600". - * or -1 if not found. - */ - int getIndexOf(const std::string &widthXHeightMode); - - private: -#ifndef ANDROID - void addCustomMode(const std::string &mode); -#endif // ANDROID - - StringVect mVideoModes; -}; - -#endif // GUI_MODELS_MODELISTMODEL_H diff --git a/src/gui/models/namesmodel.cpp b/src/gui/models/namesmodel.cpp deleted file mode 100644 index 5344a7a7d..000000000 --- a/src/gui/models/namesmodel.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/namesmodel.h" - -#include "utils/cast.h" -#include "utils/foreach.h" -#include "utils/gettext.h" - -#include "debug.h" - -NamesModel::NamesModel() : - ListModel(), - mNames() -{ -} - -NamesModel::~NamesModel() -{ -} - -int NamesModel::getNumberOfElements() -{ - return CAST_S32(mNames.size()); -} - -std::string NamesModel::getElementAt(int i) -{ - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[CAST_SIZE(i)]; -} - -void NamesModel::fillFromArray(const char *const *const arr, - const std::size_t sz) -{ - if (arr == nullptr) - return; - for (size_t f = 0; f < sz; f ++) - mNames.push_back(gettext(arr[f])); -} - -void NamesModel::fillFromVector(const StringVect &vect) -{ - FOR_EACH(StringVectCIter, it, vect) - { - const std::string str = *it; - if (!str.empty()) - mNames.push_back(str); - } -} diff --git a/src/gui/models/namesmodel.h b/src/gui/models/namesmodel.h deleted file mode 100644 index a239bd9aa..000000000 --- a/src/gui/models/namesmodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_NAMESMODEL_H -#define GUI_MODELS_NAMESMODEL_H - -#include "utils/stringvector.h" - -#include "gui/models/listmodel.h" - -#include "localconsts.h" - -class NamesModel notfinal : public ListModel -{ - public: - NamesModel(); - - A_DELETE_COPY(NamesModel) - - virtual ~NamesModel(); - - int getNumberOfElements() override final A_WARN_UNUSED; - - std::string getElementAt(int i) override final A_WARN_UNUSED; - - StringVect &getNames() noexcept2 A_WARN_UNUSED - { return mNames; } - - size_t size() const noexcept2 A_WARN_UNUSED - { return mNames.size(); } - - void clear() - { mNames.clear(); } - - void add(const std::string &str) - { mNames.push_back(str); } - - void fillFromArray(const char *const *const arr, - const std::size_t size); - - void fillFromVector(const StringVect &vect); - - protected: - StringVect mNames; -}; - -#endif // GUI_MODELS_NAMESMODEL_H diff --git a/src/gui/models/opengllistmodel.h b/src/gui/models/opengllistmodel.h deleted file mode 100644 index 085dd17a5..000000000 --- a/src/gui/models/opengllistmodel.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_OPENGLLISTMODEL_H -#define GUI_MODELS_OPENGLLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "render/rendererslistsdl.h" - -#include "localconsts.h" - -class OpenGLListModel final : public ListModel -{ - public: - OpenGLListModel() : - ListModel() - { } - - A_DELETE_COPY(OpenGLListModel) - - ~OpenGLListModel() - { } - - int getNumberOfElements() override final - { return renderModesListSize; } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(OPENGL_NAME[i]); - } -}; - -#endif // GUI_MODELS_OPENGLLISTMODEL_H diff --git a/src/gui/models/playerrelationlistmodel.h b/src/gui/models/playerrelationlistmodel.h deleted file mode 100644 index 5e58d4905..000000000 --- a/src/gui/models/playerrelationlistmodel.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_PLAYERRELATIONLISTMODEL_H -#define GUI_MODELS_PLAYERRELATIONLISTMODEL_H - -#include "being/playerrelation.h" - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -static const char *const RELATION_NAMES[PlayerRelation::RELATIONS_NR] = -{ - // TRANSLATORS: relation type - N_("Neutral"), - // TRANSLATORS: relation type - N_("Friend"), - // TRANSLATORS: relation type - N_("Disregarded"), - // TRANSLATORS: relation type - N_("Ignored"), - // TRANSLATORS: relation type - N_("Erased"), - // TRANSLATORS: relation type - N_("Blacklisted"), - // TRANSLATORS: relation type - N_("Enemy") -}; - -class PlayerRelationListModel final : public ListModel -{ - public: - PlayerRelationListModel() : - ListModel() - { } - - A_DELETE_COPY(PlayerRelationListModel) - - ~PlayerRelationListModel() - { } - - int getNumberOfElements() override final - { - return PlayerRelation::RELATIONS_NR; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return ""; - return gettext(RELATION_NAMES[i]); - } -}; - -#endif // GUI_MODELS_PLAYERRELATIONLISTMODEL_H diff --git a/src/gui/models/playertablemodel.cpp b/src/gui/models/playertablemodel.cpp deleted file mode 100644 index 271b6a5bb..000000000 --- a/src/gui/models/playertablemodel.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/playertablemodel.h" - -#include "being/playerrelations.h" - -#include "gui/widgets/dropdown.h" -#include "gui/widgets/label.h" - -#include "gui/models/playerrelationlistmodel.h" - -#include "utils/delete2.h" -#include "utils/dtor.h" - -#include "debug.h" - -static const int COLUMNS_NR = 2; // name plus listbox -static const int NAME_COLUMN = 0; -static const unsigned int RELATION_CHOICE_COLUMN = 1; - -static const unsigned int ROW_HEIGHT = 12; -// The following column widths really shouldn't be hardcoded -// but should scale with the size of the widget... except -// that, right now, the widget doesn't exactly scale either. -static const unsigned int NAME_COLUMN_WIDTH = 230; -static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80; - -#define WIDGET_AT(row, column) (((row) * COLUMNS_NR) + column) - -PlayerTableModel::PlayerTableModel(const Widget2 *const widget) : - Widget2(widget), - TableModel(), - mPlayers(nullptr), - mWidgets(), - mListModel(new PlayerRelationListModel) -{ - playerRelationsUpdated(); -} - -PlayerTableModel::~PlayerTableModel() -{ - freeWidgets(); - delete2(mListModel) - delete2(mPlayers) -} - -int PlayerTableModel::getRows() const -{ - if (mPlayers != nullptr) - return CAST_S32(mPlayers->size()); - return 0; -} - -int PlayerTableModel::getColumns() const -{ - return COLUMNS_NR; -} - -int PlayerTableModel::getRowHeight() const -{ - return ROW_HEIGHT; -} - -int PlayerTableModel::getColumnWidth(const int index) const -{ - if (index == NAME_COLUMN) - return NAME_COLUMN_WIDTH; - return RELATION_CHOICE_COLUMN_WIDTH; -} - -void PlayerTableModel::playerRelationsUpdated() -{ - signalBeforeUpdate(); - - freeWidgets(); - StringVect *const player_names = playerRelations.getPlayers(); - delete mPlayers; - mPlayers = player_names; - - // set up widgets - for (unsigned int r = 0, fsz = CAST_U32( - player_names->size()); r < fsz; ++r) - { - const std::string name = (*player_names)[r]; - Widget *const widget = new Label(this, name); - mWidgets.push_back(widget); - - DropDown *const choicebox = new DropDown(this, mListModel); - choicebox->setSelected(CAST_S32( - playerRelations.getRelation(name))); - mWidgets.push_back(choicebox); - } - - signalAfterUpdate(); -} - -void PlayerTableModel::updateModelInRow(const int row) const -{ - const DropDown *const choicebox = static_cast<DropDown *>( - getElementAt(row, RELATION_CHOICE_COLUMN)); - if (choicebox == nullptr) - return; - playerRelations.setRelation(getPlayerAt(row), - static_cast<RelationT>( - choicebox->getSelected())); -} - -Widget *PlayerTableModel::getElementAt(int row, int column) const -{ - return mWidgets[WIDGET_AT(row, column)]; -} - -void PlayerTableModel::freeWidgets() -{ - delete2(mPlayers) - delete_all(mWidgets); - mWidgets.clear(); -} - -std::string PlayerTableModel::getPlayerAt(const int index) const -{ - if ((mPlayers == nullptr) || index < 0 - || index >= CAST_S32(mPlayers->size())) - { - return std::string(); - } - return (*mPlayers)[index]; -} diff --git a/src/gui/models/playertablemodel.h b/src/gui/models/playertablemodel.h deleted file mode 100644 index dfb00eeb4..000000000 --- a/src/gui/models/playertablemodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_PLAYERTABLEMODEL_H -#define GUI_MODELS_PLAYERTABLEMODEL_H - -#include "gui/widgets/widget2.h" - -#include "gui/models/tablemodel.h" - -#include "localconsts.h" - -class PlayerRelationListModel; - -class PlayerTableModel final : public Widget2, - public TableModel -{ - public: - explicit PlayerTableModel(const Widget2 *const widget); - - A_DELETE_COPY(PlayerTableModel) - - ~PlayerTableModel(); - - int getRows() const override final; - - int getColumns() const override final A_CONST; - - int getRowHeight() const override final A_CONST; - - int getColumnWidth(const int index) const override final A_CONST; - - void playerRelationsUpdated(); - - void updateModelInRow(const int row) const; - - Widget *getElementAt(int row, int column) const override final; - - void freeWidgets(); - - std::string getPlayerAt(const int index) const; - - protected: - StringVect *mPlayers; - STD_VECTOR<Widget *> mWidgets; - PlayerRelationListModel *mListModel; -}; - -#endif // GUI_MODELS_PLAYERTABLEMODEL_H diff --git a/src/gui/models/questsmodel.h b/src/gui/models/questsmodel.h deleted file mode 100644 index f80e7a32d..000000000 --- a/src/gui/models/questsmodel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_QUESTSMODEL_H -#define GUI_MODELS_QUESTSMODEL_H - -#include "gui/models/extendednamesmodel.h" - -class QuestsModel final : public ExtendedNamesModel -{ - public: - QuestsModel() : - ExtendedNamesModel() - { - } - - A_DELETE_COPY(QuestsModel) - - ~QuestsModel() - { } -}; - -#endif // GUI_MODELS_QUESTSMODEL_H diff --git a/src/gui/models/serverslistmodel.h b/src/gui/models/serverslistmodel.h deleted file mode 100644 index 8e236ebe0..000000000 --- a/src/gui/models/serverslistmodel.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_SERVERSLISTMODEL_H -#define GUI_MODELS_SERVERSLISTMODEL_H - -#include "gui/gui.h" - -#include "gui/fonts/font.h" - -#include "gui/windows/serverdialog.h" - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -/** - * Server and Port List Model - */ -class ServersListModel final : public ListModel -{ - public: - typedef std::pair<int, std::string> VersionString; - - ServersListModel(ServerInfos *const servers, - ServerDialog *const parent) : - mServers(servers), - mVersionStrings(servers != nullptr ? servers->size() : 0, - VersionString(0, "")), - mParent(parent) - { - } - - A_DELETE_COPY(ServersListModel) - - /** - * Used to get number of line in the list - */ - int getNumberOfElements() override final A_WARN_UNUSED - { - MutexLocker lock = mParent->lock(); - return CAST_S32(mServers->size()); - } - - /** - * Used to get an element from the list - */ - std::string getElementAt(int elementIndex) - override final A_WARN_UNUSED - { - MutexLocker lock = mParent->lock(); - const ServerInfo &server = mServers->at(elementIndex); - std::string myServer; - if (server.freeType == ServerFreeType::NonFree) - { - // TRANSLATORS: server license comment - myServer.append(_("(NON FREE)")); - myServer.append(" "); - } - else if (server.freeType == ServerFreeType::Unknown) - { - // TRANSLATORS: server license comment - myServer.append(_("(UNKNOWN)")); - myServer.append(" "); - } - myServer.append(server.hostname); - return myServer; - } - - /** - * Used to get the corresponding Server struct - */ - const ServerInfo &getServer(const int elementIndex) const A_WARN_UNUSED - { return mServers->at(elementIndex); } - - void setVersionString(const int index, const std::string &version) - { - if (index < 0 || index >= CAST_S32(mVersionStrings.size())) - return; - - if (version.empty() || (gui == nullptr)) - { - mVersionStrings[index] = VersionString(0, ""); - } - else - { - mVersionStrings[index] = VersionString( - gui->getFont()->getWidth(version), version); - } - } - - private: - typedef STD_VECTOR<VersionString> VersionStrings; - - ServerInfos *mServers; - VersionStrings mVersionStrings; - ServerDialog *mParent; -}; - -#endif // GUI_MODELS_SERVERSLISTMODEL_H diff --git a/src/gui/models/shopitems.cpp b/src/gui/models/shopitems.cpp deleted file mode 100644 index 27e05ff12..000000000 --- a/src/gui/models/shopitems.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/shopitems.h" - -#include "resources/item/shopitem.h" - -#include "utils/dtor.h" -#include "utils/foreach.h" - -#include "debug.h" - -ShopItems::ShopItems(const bool mergeDuplicates, - const std::string ¤cy) : - ListModel(), - mAllShopItems(), - mShopItems(), - mCurrency(currency), - mMergeDuplicates(mergeDuplicates) -{ -} - -ShopItems::~ShopItems() -{ - clear(); -} - -std::string ShopItems::getElementAt(int i) -{ - if (i < 0 || CAST_U32(i) - >= CAST_U32(mShopItems.size()) || (mShopItems.at(i) == nullptr)) - { - return ""; - } - - return mShopItems.at(i)->getDisplayName(); -} - -ShopItem *ShopItems::addItem(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price) -{ - ShopItem *const item = new ShopItem(-1, - id, - type, - color, - amount, - price, - mCurrency); - mShopItems.push_back(item); - mAllShopItems.push_back(item); - return item; -} - -ShopItem *ShopItems::addItemNoDup(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price) -{ - ShopItem *item = findItem(id, color); - if (item == nullptr) - { - item = new ShopItem(-1, - id, - type, - color, - amount, - price, - mCurrency); - mShopItems.push_back(item); - mAllShopItems.push_back(item); - } - return item; -} - -ShopItem *ShopItems::addItem2(const int inventoryIndex, - const int id, - const ItemTypeT type, - const ItemColor color, - const int quantity, - const int price) -{ - ShopItem *item = nullptr; - if (mMergeDuplicates) - item = findItem(id, color); - - if (item != nullptr) - { - item->addDuplicate(inventoryIndex, quantity); - } - else - { - item = new ShopItem(inventoryIndex, - id, - type, - color, - quantity, - price, - mCurrency); - mShopItems.push_back(item); - mAllShopItems.push_back(item); - } - return item; -} - -ShopItem *ShopItems::at(const size_t i) const -{ - if (i >= mShopItems.size()) - return nullptr; - - return mShopItems.at(i); -} - -bool ShopItems::findInAllItems(STD_VECTOR<ShopItem*>::iterator &it, - const ShopItem *const item) -{ - const STD_VECTOR<ShopItem*>::iterator it_end = mAllShopItems.end(); - for (it = mAllShopItems.begin(); it != it_end; ++ it) - { - if (*it == item) - return true; - } - return false; -} - -void ShopItems::erase(const unsigned int i) -{ - if (i >= CAST_U32(mShopItems.size())) - return; - - const ShopItem *const item = *(mShopItems.begin() + i); - STD_VECTOR<ShopItem*>::iterator it; - if (findInAllItems(it, item)) - mAllShopItems.erase(it); - mShopItems.erase(mShopItems.begin() + i); -} - -void ShopItems::del(const unsigned int i) -{ - if (i >= CAST_U32(mShopItems.size())) - return; - - ShopItem *item = *(mShopItems.begin() + i); - STD_VECTOR<ShopItem*>::iterator it; - if (findInAllItems(it, item)) - mAllShopItems.erase(it); - mShopItems.erase(mShopItems.begin() + i); - delete item; -} - -void ShopItems::clear() -{ - delete_all(mAllShopItems); - mAllShopItems.clear(); - mShopItems.clear(); -} - -ShopItem *ShopItems::findItem(const int id, - const ItemColor color) const -{ - STD_VECTOR<ShopItem*>::const_iterator it = mShopItems.begin(); - const STD_VECTOR<ShopItem*>::const_iterator e = mShopItems.end(); - while (it != e) - { - ShopItem *const item = *it; - if (item->getId() == id && item->getColor() == color) - return item; - - ++it; - } - - return nullptr; -} - -void ShopItems::updateList() -{ - mShopItems.clear(); - FOR_EACH (STD_VECTOR<ShopItem*>::iterator, it, mAllShopItems) - { - ShopItem *const item = *it; - if ((item != nullptr) && item->isVisible()) - mShopItems.push_back(item); - } -} diff --git a/src/gui/models/shopitems.h b/src/gui/models/shopitems.h deleted file mode 100644 index 26c5a94e4..000000000 --- a/src/gui/models/shopitems.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_SHOPITEMS_H -#define GUI_MODELS_SHOPITEMS_H - -#include "enums/resources/item/itemtype.h" - -#include "enums/simpletypes/itemcolor.h" - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" -#include "utils/vector.h" - -#include "localconsts.h" - -class ShopItem; - -/** - * This class handles the list of items available in a shop. - * - * The addItem routine can automatically check, if an item already exists and - * only adds duplicates to the old item, if one is found. The original - * distribution of the duplicates can be retrieved from the item. - * - * This functionality can be enabled in the constructor. - */ -class ShopItems final : public ListModel -{ - public: - /** - * Constructor. - * - * @param mergeDuplicates lets the Shop look for duplicate entries and - * merges them to one item. - */ - ShopItems(const bool mergeDuplicates, - const std::string ¤cy); - - A_DELETE_COPY(ShopItems) - - ~ShopItems(); - - /** - * Adds an item to the list. - */ - ShopItem *addItem(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price); - - /** - * Adds an item to the list (used by sell dialog). Looks for - * duplicate entries, if mergeDuplicates was turned on. - * - * @param inventoryIndex the inventory index of the item - * @param id the id of the item - * @param amount number of available copies of the item - * @param price price of the item - */ - ShopItem *addItem2(const int inventoryIndex, - const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price); - - ShopItem *addItemNoDup(const int id, - const ItemTypeT type, - const ItemColor color, - const int amount, - const int price); - - /** - * Returns the number of items in the shop. - */ - int getNumberOfElements() override final A_WARN_UNUSED - { return CAST_S32(mShopItems.size()); } - - bool empty() const noexcept2 A_WARN_UNUSED - { return mShopItems.empty(); } - - /** - * Returns the name of item number i in the shop. - * - * @param i the index to retrieve - */ - std::string getElementAt(int i) override final A_WARN_UNUSED; - - /** - * Returns the item number i in the shop. - */ - ShopItem *at(const size_t i) const A_WARN_UNUSED; - - /** - * Removes an element from the shop. - * - * @param i index to remove - */ - void erase(const unsigned int i); - - /** - * Removes an element from the shop and destroy it. - * - * @param i index to remove - */ - void del(const unsigned int i); - - /** - * Clears the list of items in the shop. - */ - void clear(); - - STD_VECTOR<ShopItem*> &items() A_WARN_UNUSED - { return mShopItems; } - - STD_VECTOR<ShopItem*> &allItems() A_WARN_UNUSED - { return mAllShopItems; } - - void setMergeDuplicates(const bool b) - { mMergeDuplicates = b; } - - void updateList(); - - private: - /** - * Searches the current items in the shop for the specified - * id and returns the item if found, or 0 else. - * - * @return the item found or 0 - */ - ShopItem *findItem(const int id, - const ItemColor color) const A_WARN_UNUSED; - - bool findInAllItems(STD_VECTOR<ShopItem*>::iterator &it, - const ShopItem *const item); - - /** The list of items in the shop. */ - STD_VECTOR<ShopItem*> mAllShopItems; - - STD_VECTOR<ShopItem*> mShopItems; - - std::string mCurrency; - - /** Look for duplicate entries on addition. */ - bool mMergeDuplicates; -}; - -#endif // GUI_MODELS_SHOPITEMS_H diff --git a/src/gui/models/skillmodel.cpp b/src/gui/models/skillmodel.cpp deleted file mode 100644 index 4d22280d8..000000000 --- a/src/gui/models/skillmodel.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/skillmodel.h" - -#include "utils/foreach.h" - -#include "resources/skill/skilldata.h" - -#include "debug.h" - -SkillModel::SkillModel() : - ListModel(), - mSkills(), - mVisibleSkills() -{ -} - -SkillInfo *SkillModel::getSkillAt(const int i) const -{ - if (i < 0 || i >= CAST_S32(mVisibleSkills.size())) - return nullptr; - return mVisibleSkills.at(i); -} - -std::string SkillModel::getElementAt(int i) -{ - const SkillInfo *const info = getSkillAt(i); - if (info != nullptr) - return info->data->name; - return std::string(); -} - -void SkillModel::updateVisibilities() -{ - mVisibleSkills.clear(); - - FOR_EACH (SkillList::const_iterator, it, mSkills) - { - if (((*it) != nullptr) && (*it)->visible == Visible_true) - mVisibleSkills.push_back((*it)); - } -} diff --git a/src/gui/models/skillmodel.h b/src/gui/models/skillmodel.h deleted file mode 100644 index 6c7792508..000000000 --- a/src/gui/models/skillmodel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_SKILLMODEL_H -#define GUI_MODELS_SKILLMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" - -#include "resources/skill/skillinfo.h" - -#include "localconsts.h" - -class SkillModel final : public ListModel -{ - public: - SkillModel(); - - A_DELETE_COPY(SkillModel) - - SkillInfo *getSkillAt(const int i) const; - - std::string getElementAt(int i) override final; - - int getNumberOfElements() override final - { return CAST_S32(mVisibleSkills.size()); } - - void addSkill(SkillInfo *const info) - { mSkills.push_back(info); } - - void updateVisibilities(); - - private: - SkillList mSkills; - SkillList mVisibleSkills; -}; - -#endif // GUI_MODELS_SKILLMODEL_H diff --git a/src/gui/models/sortlistmodelbuy.h b/src/gui/models/sortlistmodelbuy.h deleted file mode 100644 index 3af489222..000000000 --- a/src/gui/models/sortlistmodelbuy.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_SORTLISTMODELBUY_H -#define GUI_MODELS_SORTLISTMODELBUY_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -static const char *const SORT_NAME_BUY[7] = -{ - // TRANSLATORS: buy dialog sort type. - N_("unsorted"), - // TRANSLATORS: buy dialog sort type. - N_("by price"), - // TRANSLATORS: buy dialog sort type. - N_("by name"), - // TRANSLATORS: buy dialog sort type. - N_("by id"), - // TRANSLATORS: buy dialog sort type. - N_("by weight"), - // TRANSLATORS: buy dialog sort type. - N_("by amount"), - // TRANSLATORS: buy dialog sort type. - N_("by type") -}; - -class SortListModelBuy final : public ListModel -{ - public: - SortListModelBuy() : - ListModel() - { } - - A_DELETE_COPY(SortListModelBuy) - - ~SortListModelBuy() - { } - - int getNumberOfElements() override final - { return 7; } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(SORT_NAME_BUY[i]); - } -}; - -#endif // GUI_MODELS_SORTLISTMODELBUY_H diff --git a/src/gui/models/sortlistmodelinv.h b/src/gui/models/sortlistmodelinv.h deleted file mode 100644 index 3561d2621..000000000 --- a/src/gui/models/sortlistmodelinv.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_SORTLISTMODELINV_H -#define GUI_MODELS_SORTLISTMODELINV_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -static const char *const SORT_NAME_INVENTORY[6] = -{ - // TRANSLATORS: inventory sort mode - N_("default"), - // TRANSLATORS: inventory sort mode - N_("by name"), - // TRANSLATORS: inventory sort mode - N_("by id"), - // TRANSLATORS: inventory sort mode - N_("by weight"), - // TRANSLATORS: inventory sort mode - N_("by amount"), - // TRANSLATORS: inventory sort mode - N_("by type") -}; - -class SortListModelInv final : public ListModel -{ - public: - SortListModelInv() : - ListModel() - { } - - A_DELETE_COPY(SortListModelInv) - - ~SortListModelInv() - { } - - int getNumberOfElements() override final - { return 6; } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - - return gettext(SORT_NAME_INVENTORY[i]); - } -}; - -#endif // GUI_MODELS_SORTLISTMODELINV_H diff --git a/src/gui/models/soundsmodel.h b/src/gui/models/soundsmodel.h deleted file mode 100644 index ad66049a3..000000000 --- a/src/gui/models/soundsmodel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_SOUNDSMODEL_H -#define GUI_MODELS_SOUNDSMODEL_H - -#include "gui/theme.h" - -#include "gui/models/namesmodel.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -class SoundsModel final : public NamesModel -{ - public: - SoundsModel() : - NamesModel() - { - mNames.push_back(gettext("(no sound)")); - Theme::fillSoundsList(mNames); - } - - A_DELETE_COPY(SoundsModel) - - ~SoundsModel() - { } -}; - -#endif // GUI_MODELS_SOUNDSMODEL_H diff --git a/src/gui/models/tablemodel.cpp b/src/gui/models/tablemodel.cpp deleted file mode 100644 index 08cfb6d83..000000000 --- a/src/gui/models/tablemodel.cpp +++ /dev/null @@ -1,182 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/models/tablemodel.h" - -#include "utils/dtor.h" - -#include "gui/widgets/widget.h" - -#include "listeners/tablemodellistener.h" - -#include "debug.h" - -void TableModel::installListener(TableModelListener *const listener) -{ - if (listener != nullptr) - listeners.insert(listener); -} - -void TableModel::removeListener(TableModelListener *const listener) -{ - if (listener != nullptr) - listeners.erase(listener); -} - -void TableModel::signalBeforeUpdate() -{ - for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); - it != listeners.end(); ++it) - { - (*it)->modelUpdated(false); - } -} - -void TableModel::signalAfterUpdate() -{ - for (std::set<TableModelListener *>::const_iterator it = listeners.begin(); - it != listeners.end(); ++it) - { - if (*it != nullptr) - (*it)->modelUpdated(true); - } -} - - -#define WIDGET_AT(row, column) (((row) * mColumns) + (column)) -#define DYN_SIZE(h) ((h) >= 0) - -StaticTableModel::StaticTableModel(const int row, const int column) : - TableModel(), - mRows(row), - mColumns(column), - mHeight(1), - mTableModel(), - mWidths() -{ - mTableModel.resize(row * column, nullptr); - mWidths.resize(column, 1); -} - -StaticTableModel::~StaticTableModel() -{ - delete_all(mTableModel); - mTableModel.clear(); -} - -void StaticTableModel::resize() -{ - mRows = getRows(); - mColumns = getColumns(); - mTableModel.resize(mRows * mColumns, nullptr); -} - -void StaticTableModel::set(const int row, const int column, - Widget *const widget) -{ - if ((widget == nullptr) || row >= mRows || row < 0 - || column >= mColumns || column < 0) - { - // raise exn? - return; - } - - if (DYN_SIZE(mHeight) - && widget->getHeight() > mHeight) - { - mHeight = widget->getHeight(); - } - - if (DYN_SIZE(mWidths[column]) - && widget->getWidth() > mWidths[column]) - { - mWidths[column] = widget->getWidth(); - } - - signalBeforeUpdate(); - - delete mTableModel[WIDGET_AT(row, column)]; - - mTableModel[WIDGET_AT(row, column)] = widget; - - signalAfterUpdate(); -} - -Widget *StaticTableModel::getElementAt(const int row, - const int column) const -{ - return mTableModel[WIDGET_AT(row, column)]; -} - -void StaticTableModel::fixColumnWidth(const int column, const int width) -{ - if (width < 0 || column < 0 || column >= mColumns) - return; - - mWidths[column] = -width; // Negate to tag as fixed -} - -void StaticTableModel::fixRowHeight(const int height) -{ - if (height < 0) - return; - - mHeight = -height; -} - -int StaticTableModel::getRowHeight() const -{ - return abs(mHeight); -} - -int StaticTableModel::getColumnWidth(const int column) const -{ - if (column < 0 || column >= mColumns) - return 0; - - return abs(mWidths[column]); -} - -int StaticTableModel::getRows() const -{ - return mRows; -} - -int StaticTableModel::getColumns() const -{ - return mColumns; -} - -int StaticTableModel::getWidth() const -{ - int width = 0; - - for (size_t i = 0, sz = mWidths.size(); i < sz; i++) - width += mWidths[i]; - - return width; -} - -int StaticTableModel::getHeight() const -{ - return mColumns * mHeight; -} diff --git a/src/gui/models/tablemodel.h b/src/gui/models/tablemodel.h deleted file mode 100644 index 23f286c2e..000000000 --- a/src/gui/models/tablemodel.h +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_TABLEMODEL_H -#define GUI_MODELS_TABLEMODEL_H - -#include "utils/vector.h" - -#include <set> - -#include "localconsts.h" - -class Widget; - -class TableModelListener; - -/** - * A model for a regular table of widgets. - */ -class TableModel notfinal -{ - public: - A_DELETE_COPY(TableModel) - - virtual ~TableModel() - { } - - /** - * Determines the number of rows (lines) in the table - */ - virtual int getRows() const A_WARN_UNUSED = 0; - - /** - * Determines the number of columns in each row - */ - virtual int getColumns() const A_WARN_UNUSED = 0; - - /** - * Determines the height for each row - */ - virtual int getRowHeight() const A_WARN_UNUSED = 0; - - /** - * Determines the width of each individual column - */ - virtual int getColumnWidth(const int index) const A_WARN_UNUSED = 0; - - /** - * Retrieves the widget stored at the specified location - * within the table. - */ - virtual Widget *getElementAt(const int row, const int column) - const A_WARN_UNUSED = 0; - - virtual void installListener(TableModelListener *const listener); - - virtual void removeListener(TableModelListener *const listener); - - protected: - TableModel() : - listeners() - { - } - - /** - * Tells all listeners that the table is about to see an update - */ - virtual void signalBeforeUpdate(); - - /** - * Tells all listeners that the table has seen an update - */ - virtual void signalAfterUpdate(); - - private: - std::set<TableModelListener *> listeners; -}; - - -class StaticTableModel final : public TableModel -{ - public: - StaticTableModel(const int width, const int height); - - A_DELETE_COPY(StaticTableModel) - - ~StaticTableModel(); - - /** - * Inserts a widget into the table model. - * The model is resized to accomodate the widget's width and height, - * unless column width / row height have been fixed. - */ - void set(const int row, const int column, Widget *const widget); - - /** - * Fixes the column width for a given column; this overrides dynamic - * width inference. - * - * Semantics are undefined for width 0. - */ - void fixColumnWidth(const int column, const int width); - - /** - * Fixes the row height; this overrides dynamic height inference. - * - * Semantics are undefined for width 0. - */ - void fixRowHeight(const int height); - - /** - * Resizes the table model - */ - void resize(); - - int getRows() const override final A_WARN_UNUSED; - int getColumns() const override final A_WARN_UNUSED; - int getRowHeight() const override final A_WARN_UNUSED; - int getWidth() const A_WARN_UNUSED; - int getHeight() const A_WARN_UNUSED; - int getColumnWidth(const int index) const override final A_WARN_UNUSED; - Widget *getElementAt(const int row, - const int column) const override final - A_WARN_UNUSED; - - protected: - int mRows; - int mColumns; - int mHeight; - STD_VECTOR<Widget *> mTableModel; - STD_VECTOR<int> mWidths; -}; - -#endif // GUI_MODELS_TABLEMODEL_H diff --git a/src/gui/models/targettypemodel.h b/src/gui/models/targettypemodel.h deleted file mode 100644 index ec049bf66..000000000 --- a/src/gui/models/targettypemodel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_TARGETTYPEMODEL_H -#define GUI_MODELS_TARGETTYPEMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/gettext.h" - -const char *TARGET_TYPE_TEXT[3] = -{ - // TRANSLATORS: target type - N_("No Target"), - // TRANSLATORS: target type - N_("Allow Target"), - // TRANSLATORS: target type - N_("Need Target") -}; - -class TargetTypeModel final : public ListModel -{ - public: - TargetTypeModel() : - ListModel() - { } - - A_DELETE_COPY(TargetTypeModel) - - ~TargetTypeModel() - { } - - int getNumberOfElements() override final - { - return 3; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return TARGET_TYPE_TEXT[i]; - } -}; - -#endif // GUI_MODELS_TARGETTYPEMODEL_H diff --git a/src/gui/models/themesmodel.h b/src/gui/models/themesmodel.h deleted file mode 100644 index c68cc0a2f..000000000 --- a/src/gui/models/themesmodel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 Andrei Karas - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_THEMESMODEL_H -#define GUI_MODELS_THEMESMODEL_H - -#include "gui/theme.h" - -#include "gui/models/namesmodel.h" - -#include "utils/gettext.h" - -#include "localconsts.h" - -class ThemesModel final : public NamesModel -{ - public: - ThemesModel() : - NamesModel() - { - mNames.push_back(gettext("(default)")); - Theme::fillSkinsList(mNames); - } - - A_DELETE_COPY(ThemesModel) - - ~ThemesModel() - { } -}; - -#endif // GUI_MODELS_THEMESMODEL_H diff --git a/src/gui/models/touchactionmodel.cpp b/src/gui/models/touchactionmodel.cpp deleted file mode 100644 index 1998d2752..000000000 --- a/src/gui/models/touchactionmodel.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "gui/setupactiondata.h" -#include "gui/touchactiondata.h" - -#include "gui/models/touchactionmodel.h" - -#include "utils/foreach.h" - -#include <algorithm> - -#include "debug.h" - -const int touchActionDataSize = 5; - -static class SortTouchActionFunctor final -{ - public: - A_DEFAULT_COPY(SortTouchActionFunctor) - - bool operator() (const SetupActionData *const data1, - const SetupActionData *const data2) const - { - if ((data1 == nullptr) || (data2 == nullptr)) - return false; - return data1->name < data2->name; - } -} touchActionSorter; - -TouchActionsModel::TouchActionsModel() : - NamesModel(), - mActionId(), - mActionToSelection() -{ - STD_VECTOR<SetupActionData*> data; - - for (int f = 0, fsz = touchActionDataSize; f < fsz; f ++) - { - int k = 0; - while (!touchActionData[f][k].name.empty()) - { - data.push_back(&touchActionData[f][k]); - k ++; - } - } - - std::sort(data.begin(), data.end(), touchActionSorter); - int cnt = 0; - FOR_EACH (STD_VECTOR<SetupActionData*>::iterator, it, data) - { - const SetupActionData *const data1 = *it; - mNames.push_back(data1->name); - mActionId.push_back(data1->actionId); - mActionToSelection[data1->actionId] = cnt; - cnt ++; - } -} - -InputActionT TouchActionsModel::getActionFromSelection(const int sel) const -{ - if (sel < 0 || sel > static_cast<signed int>(mActionId.size())) - return InputAction::NO_VALUE; - return mActionId[sel]; -} - -int TouchActionsModel::getSelectionFromAction(const InputActionT action) const -{ - const std::map<InputActionT, int>::const_iterator it - = mActionToSelection.find(action); - if (it == mActionToSelection.end()) - return 0; - return (*it).second; -} diff --git a/src/gui/models/touchactionmodel.h b/src/gui/models/touchactionmodel.h deleted file mode 100644 index 2d8cff02a..000000000 --- a/src/gui/models/touchactionmodel.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_TOUCHACTIONMODEL_H -#define GUI_MODELS_TOUCHACTIONMODEL_H - -#include "enums/input/inputaction.h" - -#include "gui/models/namesmodel.h" - -#include <map> - -class TouchActionsModel final : public NamesModel -{ - public: - TouchActionsModel(); - - A_DELETE_COPY(TouchActionsModel) - - ~TouchActionsModel() - { } - - InputActionT getActionFromSelection(const int sel) const; - - int getSelectionFromAction(const InputActionT action) const; - - private: - STD_VECTOR<InputActionT> mActionId; - std::map<InputActionT, int> mActionToSelection; -}; - -#endif // GUI_MODELS_TOUCHACTIONMODEL_H diff --git a/src/gui/models/typelistmodel.h b/src/gui/models/typelistmodel.h deleted file mode 100644 index 681e019fc..000000000 --- a/src/gui/models/typelistmodel.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2011-2012 The Mana Developers - * Copyright (C) 2012-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_TYPELISTMODEL_H -#define GUI_MODELS_TYPELISTMODEL_H - -#include "gui/models/listmodel.h" - -/** - * Server Type List Model - */ -class TypeListModel final : public ListModel -{ - public: - TypeListModel() : - ListModel() - { } - - A_DELETE_COPY(TypeListModel) - - /** - * Used to get number of line in the list - */ - int getNumberOfElements() override final A_WARN_UNUSED -#if defined(TMWA_SUPPORT) - { return 3; } -#else // defined(TMWA_SUPPORT) - { return 2; } -#endif // defined(TMWA_SUPPORT) - - /** - * Used to get an element from the list - */ - std::string getElementAt(int elementIndex) - override final A_WARN_UNUSED - { -#ifdef TMWA_SUPPORT - if (elementIndex == 0) - return "TmwAthena"; - else if (elementIndex == 1) - return "Hercules"; - else if (elementIndex == 2) - return "Evol2"; - else -#else // TMWA_SUPPORT - if (elementIndex == 0) - return "Hercules"; - else if (elementIndex == 1) - return "Evol2"; - else -#endif // TMWA_SUPPORT - return "Unknown"; - } -}; - -#endif // GUI_MODELS_TYPELISTMODEL_H diff --git a/src/gui/models/updatelistmodel.h b/src/gui/models/updatelistmodel.h deleted file mode 100644 index cd4ba50c3..000000000 --- a/src/gui/models/updatelistmodel.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_UPDATELISTMODEL_H -#define GUI_MODELS_UPDATELISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "net/serverinfo.h" - -#include "utils/cast.h" -#include "utils/foreach.h" - -#include "localconsts.h" - -class UpdateListModel final : public ListModel -{ - public: - explicit UpdateListModel(ServerInfo *const server) : - ListModel(), - mNames(), - mServer(server) - { - FOR_EACH(STD_VECTOR<HostsGroup>::const_iterator, - it, - server->updateHosts) - { - const HostsGroup &group = *it; - mNames.push_back(group.name); - } - } - - A_DELETE_COPY(UpdateListModel) - - ~UpdateListModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(mNames.size()); - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return mNames[i]; - } - - bool empty() const - { - return mNames.empty(); - } - - protected: - StringVect mNames; - ServerInfo *mServer; -}; - -#endif // GUI_MODELS_UPDATELISTMODEL_H diff --git a/src/gui/models/updatetypemodel.h b/src/gui/models/updatetypemodel.h deleted file mode 100644 index 232be8223..000000000 --- a/src/gui/models/updatetypemodel.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_UPDATETYPEMODEL_H -#define GUI_MODELS_UPDATETYPEMODEL_H - -#include "utils/gettext.h" - -#include "gui/models/listmodel.h" - -const char *UPDATE_TYPE_TEXT[3] = -{ - // TRANSLATORS: update type - N_("Normal"), - // TRANSLATORS: update type - N_("Auto Close"), - // TRANSLATORS: update type - N_("Skip"), -}; - -class UpdateTypeModel final : public ListModel -{ - public: - UpdateTypeModel() - { } - - A_DELETE_COPY(UpdateTypeModel) - - ~UpdateTypeModel() - { } - - int getNumberOfElements() override final - { - return 3; - } - - std::string getElementAt(int i) override final - { - if (i >= getNumberOfElements() || i < 0) - return "???"; - return gettext(UPDATE_TYPE_TEXT[i]); - } -}; - -#endif // GUI_MODELS_UPDATETYPEMODEL_H diff --git a/src/gui/models/worldlistmodel.h b/src/gui/models/worldlistmodel.h deleted file mode 100644 index 3be179c61..000000000 --- a/src/gui/models/worldlistmodel.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2004-2009 The Mana World Development Team - * Copyright (C) 2009-2010 The Mana Developers - * Copyright (C) 2011-2017 The ManaPlus Developers - * - * This file is part of The ManaPlus Client. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef GUI_MODELS_WORLDLISTMODEL_H -#define GUI_MODELS_WORLDLISTMODEL_H - -#include "gui/models/listmodel.h" - -#include "utils/cast.h" -#include "utils/stringutils.h" - -#include "net/worldinfo.h" - -/** - * The list model for the server list. - */ -class WorldListModel final : public ListModel -{ - public: - explicit WorldListModel(const Worlds &worlds) : - mWorlds(worlds) - { - } - - A_DELETE_COPY(WorldListModel) - - ~WorldListModel() - { } - - int getNumberOfElements() override final - { - return CAST_S32(mWorlds.size()); - } - - std::string getElementAt(int i) override final - { - const WorldInfo *const si = mWorlds[i]; - if (si != nullptr) - { - return std::string(si->name).append(" (").append( - toString(si->online_users)).append(")"); - } - return "???"; - } - private: - Worlds mWorlds; -}; - -#endif // GUI_MODELS_WORLDLISTMODEL_H |