diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-10-10 22:14:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-10-10 22:15:57 +0300 |
commit | aa3f63fd497558a02feb3ddbc44f31eac091f39b (patch) | |
tree | 0e28b9b1f0501dd8be9e1a38db4ec1777fa3fbfa /src/gui/widgets/tabs | |
parent | 7c10a6b61e9d06a4ae9cc9f942dfacb6fcfd9d3d (diff) | |
download | manaverse-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.gz manaverse-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.bz2 manaverse-aa3f63fd497558a02feb3ddbc44f31eac091f39b.tar.xz manaverse-aa3f63fd497558a02feb3ddbc44f31eac091f39b.zip |
Remove most unused files.
Diffstat (limited to 'src/gui/widgets/tabs')
71 files changed, 0 insertions, 10794 deletions
diff --git a/src/gui/widgets/tabs/chat/battletab.cpp b/src/gui/widgets/tabs/chat/battletab.cpp deleted file mode 100644 index fc45fd5e1..000000000 --- a/src/gui/widgets/tabs/chat/battletab.cpp +++ /dev/null @@ -1,44 +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/widgets/tabs/chat/battletab.h" - -#include "configuration.h" - -#include "utils/gettext.h" - -#include "debug.h" - -BattleTab *battleChatTab = nullptr; - -BattleTab::BattleTab(const Widget2 *const widget) : - // TRANSLATORS: battle chat tab name - ChatTab(widget, _("Battle"), "", "#Battle", ChatTabType::BATTLE) -{ - setTabColors(ThemeColorId::BATTLE_CHAT_TAB); - if (config.getBoolValue("showChatHistory")) - loadFromLogFile("#Battle"); -} - -BattleTab::~BattleTab() -{ -} diff --git a/src/gui/widgets/tabs/chat/battletab.h b/src/gui/widgets/tabs/chat/battletab.h deleted file mode 100644 index 24f69c8b9..000000000 --- a/src/gui/widgets/tabs/chat/battletab.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_BATTLETAB_H -#define GUI_WIDGETS_TABS_CHAT_BATTLETAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for a party chat channel. - */ -class BattleTab final : public ChatTab -{ - public: - explicit BattleTab(const Widget2 *const widget); - - A_DELETE_COPY(BattleTab) - - ~BattleTab(); -}; - -extern BattleTab *battleChatTab; - -#endif // GUI_WIDGETS_TABS_CHAT_BATTLETAB_H diff --git a/src/gui/widgets/tabs/chat/channeltab.cpp b/src/gui/widgets/tabs/chat/channeltab.cpp deleted file mode 100644 index 37e6237a0..000000000 --- a/src/gui/widgets/tabs/chat/channeltab.cpp +++ /dev/null @@ -1,77 +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/widgets/tabs/chat/channeltab.h" - -#include "gui/widgets/windowcontainer.h" - -#include "gui/windows/chatwindow.h" - -#include "net/chathandler.h" - -#include "debug.h" - -ChannelTab::ChannelTab(const Widget2 *const widget, - const std::string &channel) : - ChatTab(widget, channel, channel, channel, ChatTabType::CHANNEL) -{ - setTabColors(ThemeColorId::CHANNEL_CHAT_TAB); -} - -ChannelTab::~ChannelTab() -{ - if (chatWindow != nullptr) - chatWindow->removeChannel(mChannelName); -} - -void ChannelTab::handleInput(const std::string &msg) -{ - std::string newMsg; - newMsg = ChatWindow::doReplace(msg); - chatHandler->channelMessage(mChannelName, newMsg); -} - -bool ChannelTab::handleCommand(const std::string &restrict type, - const std::string &restrict args A_UNUSED) -{ - if (type == "close") - { - if (windowContainer != nullptr) - windowContainer->scheduleDelete(this); - else - delete this; - if (chatWindow != nullptr) - chatWindow->defaultTab(); - } - else - { - return false; - } - - return true; -} - -void ChannelTab::getAutoCompleteCommands(StringVect& commands) const -{ - commands.push_back("/close"); - commands.push_back(mChannelName); -} diff --git a/src/gui/widgets/tabs/chat/channeltab.h b/src/gui/widgets/tabs/chat/channeltab.h deleted file mode 100644 index 3ac51e59d..000000000 --- a/src/gui/widgets/tabs/chat/channeltab.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_CHANNELTAB_H -#define GUI_WIDGETS_TABS_CHAT_CHANNELTAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for a chat channel. - */ -class ChannelTab final : public ChatTab -{ - public: - ChannelTab(const Widget2 *const widget, - const std::string &channel); - - A_DELETE_COPY(ChannelTab) - - ~ChannelTab(); - - protected: - void handleInput(const std::string &msg) override final; - - bool handleCommand(const std::string &restrict type, - const std::string &restrict args) override final; - - void getAutoCompleteCommands(StringVect& commands) - const override final; -}; - -#endif // GUI_WIDGETS_TABS_CHAT_CHANNELTAB_H diff --git a/src/gui/widgets/tabs/chat/chattab.cpp b/src/gui/widgets/tabs/chat/chattab.cpp deleted file mode 100644 index e4f6d751a..000000000 --- a/src/gui/widgets/tabs/chat/chattab.cpp +++ /dev/null @@ -1,563 +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/widgets/tabs/chat/chattab.h" - -#include "chatlogger.h" -#include "configuration.h" -#include "settings.h" -#include "soundmanager.h" - -#include "being/localplayer.h" - -#include "const/sound.h" - -#include "gui/chatlog.h" -#include "gui/windowmanager.h" - -#include "gui/windows/chatwindow.h" -#include "gui/windows/helpwindow.h" - -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/itemlinkhandler.h" -#include "gui/widgets/tabbedarea.h" - -#include "input/inputmanager.h" - -#include "net/chathandler.h" -#include "net/net.h" - -#include "utils/chatutils.h" -#include "utils/delete2.h" -#include "utils/gettext.h" - -#ifdef WIN32 -#include <sys/time.h> -#endif // WIN32 - -#include <sstream> - -#include "debug.h" - -ChatTab *localChatTab = nullptr; -ChatTab *debugChatTab = nullptr; - -static const unsigned int MAX_WORD_SIZE = 50; - -ChatTab::ChatTab(const Widget2 *const widget, - const std::string &name, - const std::string &channel, - const std::string &logName, - const ChatTabTypeT &type) : - Tab(widget), - mTextOutput(new BrowserBox(this, Opaque_true, - "browserbox.xml")), - mScrollArea(new ScrollArea(this, mTextOutput, Opaque_false)), - mChannelName(channel), - mLogName(logName), - mType(type), - mAllowHightlight(true), - mRemoveNames(false), - mNoAway(false), - mShowOnline(false) -{ - setCaption(name); - - mTextOutput->setOpaque(Opaque_false); - mTextOutput->setMaxRow(config.getIntValue("ChatLogLength")); - if (chatWindow != nullptr) - mTextOutput->setLinkHandler(chatWindow->mItemLinkHandler); - mTextOutput->setAlwaysUpdate(false); - - mScrollArea->setScrollPolicy(ScrollArea::SHOW_NEVER, - ScrollArea::SHOW_ALWAYS); - mScrollArea->setScrollAmount(0, 1); - - if (chatWindow != nullptr) - chatWindow->addTab(this); - mTextOutput->updateSize(true); -} - -ChatTab::~ChatTab() -{ - if (chatWindow != nullptr) - chatWindow->removeTab(this); - - delete2(mTextOutput); - delete2(mScrollArea); -} - -void ChatTab::chatLog(std::string line, - ChatMsgTypeT own, - const IgnoreRecord ignoreRecord, - const TryRemoveColors tryRemoveColors) -{ - // Trim whitespace - trim(line); - - if (line.empty()) - return; - - if (tryRemoveColors == TryRemoveColors_true && - own == ChatMsgType::BY_OTHER && - config.getBoolValue("removeColors")) - { - line = removeColors(line); - if (line.empty()) - return; - } - - const unsigned lineLim = config.getIntValue("chatMaxCharLimit"); - if (lineLim > 0 && line.length() > lineLim) - line = line.substr(0, lineLim); - - if (line.empty()) - return; - - CHATLOG tmp; - tmp.own = own; - tmp.nick.clear(); - tmp.text = line; - - const size_t pos = line.find(" : "); - if (pos != std::string::npos) - { - if (line.length() <= pos + 3) - return; - - tmp.nick = line.substr(0, pos); - tmp.text = line.substr(pos + 3); - } - else - { - // Fix the owner of welcome message. - if (line.length() > 7 && line.substr(0, 7) == "Welcome") - own = ChatMsgType::BY_SERVER; - } - - // *implements actions in a backwards compatible way* - if ((own == ChatMsgType::BY_PLAYER || own == ChatMsgType::BY_OTHER) && - tmp.text.at(0) == '*' && - tmp.text.at(tmp.text.length()-1) == '*') - { - tmp.text[0] = ' '; - tmp.text.erase(tmp.text.length() - 1); - own = ChatMsgType::ACT_IS; - } - - std::string lineColor("##C"); - switch (own) - { - case ChatMsgType::BY_GM: - if (tmp.nick.empty()) - { - // TRANSLATORS: chat message - tmp.nick = std::string(_("Global announcement:")).append(" "); - lineColor = "##G"; - } - else - { - // TRANSLATORS: chat message - tmp.nick = strprintf(_("Global announcement from %s:"), - tmp.nick.c_str()).append(" "); - lineColor = "##g"; // Equiv. to BrowserBox::RED - } - break; - case ChatMsgType::BY_PLAYER: - tmp.nick.append(": "); - lineColor = "##Y"; - break; - case ChatMsgType::BY_OTHER: - case ChatMsgType::BY_UNKNOWN: - tmp.nick.append(": "); - lineColor = "##C"; - break; - case ChatMsgType::BY_SERVER: - // TRANSLATORS: chat message - tmp.nick.clear(); - tmp.text = line; - lineColor = "##S"; - break; - case ChatMsgType::BY_CHANNEL: - tmp.nick.clear(); - lineColor = "##2"; // Equiv. to BrowserBox::GREEN - break; - case ChatMsgType::ACT_WHISPER: - // TRANSLATORS: chat message - tmp.nick = strprintf(_("%s whispers: %s"), tmp.nick.c_str(), ""); - lineColor = "##W"; - break; - case ChatMsgType::ACT_IS: - lineColor = "##I"; - break; - case ChatMsgType::BY_LOGGER: - tmp.nick.clear(); - tmp.text = line; - lineColor = "##L"; - break; - default: - break; - } - - if (tmp.nick == ": ") - { - tmp.nick.clear(); - lineColor = "##S"; - } - - // if configured, move magic messages log to debug chat tab - if (Net::getNetworkType() == ServerType::TMWATHENA - && (localChatTab != nullptr) && this == localChatTab - && ((config.getBoolValue("showMagicInDebug") - && own == ChatMsgType::BY_PLAYER - && tmp.text.length() > 1 - && tmp.text.at(0) == '#' - && tmp.text.at(1) != '#') - || (config.getBoolValue("serverMsgInDebug") - && (own == ChatMsgType::BY_SERVER - || tmp.nick.empty())))) - { - if (debugChatTab != nullptr) - debugChatTab->chatLog(line, own, ignoreRecord, tryRemoveColors); - return; - } - - // Get the current system time - time_t t; - time(&t); - - if (config.getBoolValue("useLocalTime")) - { - const tm *const timeInfo = localtime(&t); - if (timeInfo != nullptr) - { - line = strprintf("%s[%02d:%02d] %s%s", lineColor.c_str(), - timeInfo->tm_hour, timeInfo->tm_min, tmp.nick.c_str(), - tmp.text.c_str()); - } - else - { - line = strprintf("%s %s%s", lineColor.c_str(), - tmp.nick.c_str(), tmp.text.c_str()); - } - } - else - { - // Format the time string properly - std::stringstream timeStr; - timeStr << "[" << ((((t / 60) / 60) % 24 < 10) ? "0" : "") - << CAST_S32(((t / 60) / 60) % 24) - << ":" << (((t / 60) % 60 < 10) ? "0" : "") - << CAST_S32((t / 60) % 60) - << "] "; - line = std::string(lineColor).append(timeStr.str()).append( - tmp.nick).append(tmp.text); - } - - if (config.getBoolValue("enableChatLog")) - saveToLogFile(line); - - mTextOutput->setMaxRow(config.getIntValue("chatMaxLinesLimit")); - - // We look if the Vertical Scroll Bar is set at the max before - // adding a row, otherwise the max will always be a row higher - // at comparison. - if (mScrollArea->getVerticalScrollAmount() + 2 >= - mScrollArea->getVerticalMaxScroll()) - { - addRow(line); - mScrollArea->setVerticalScrollAmount( - mScrollArea->getVerticalMaxScroll()); - } - else - { - addRow(line); - } - - if ((chatWindow != nullptr) && this == localChatTab) - chatWindow->addToAwayLog(line); - - mScrollArea->logic(); - if (own != ChatMsgType::BY_PLAYER) - { - if (own == ChatMsgType::BY_SERVER && - (getType() == ChatTabType::PARTY || - getType() == ChatTabType::CHANNEL || - getType() == ChatTabType::GUILD)) - { - return; - } - - const TabbedArea *const tabArea = getTabbedArea(); - if (tabArea == nullptr) - return; - - const bool notFocused = WindowManager::getIsMinimized() || - (!settings.mouseFocused && - settings.inputFocused == KeyboardFocus::Unfocused); - - if (this != tabArea->getSelectedTab() || notFocused) - { - if (getFlash() == 0) - { - if (chatWindow != nullptr && - chatWindow->findHighlight(tmp.text)) - { - setFlash(2); - soundManager.playGuiSound(SOUND_HIGHLIGHT); - } - else - { - setFlash(1); - } - } - else if (getFlash() == 2) - { - if (chatWindow != nullptr && - chatWindow->findHighlight(tmp.text)) - { - soundManager.playGuiSound(SOUND_HIGHLIGHT); - } - } - } - - if ((getAllowHighlight() || - own == ChatMsgType::BY_GM) && - (this != tabArea->getSelectedTab() || - notFocused)) - { - if (own == ChatMsgType::BY_GM) - { - if (chatWindow != nullptr) - chatWindow->unHideWindow(); - soundManager.playGuiSound(SOUND_GLOBAL); - } - else if (own != ChatMsgType::BY_SERVER) - { - if (chatWindow != nullptr) - chatWindow->unHideWindow(); - playNewMessageSound(); - } - WindowManager::newChatMessage(); - } - } -} - -void ChatTab::chatLog(const std::string &nick, std::string msg) -{ - if (localPlayer == nullptr) - return; - - const ChatMsgTypeT byWho = (nick == localPlayer->getName() - ? ChatMsgType::BY_PLAYER : ChatMsgType::BY_OTHER); - if (byWho == ChatMsgType::BY_OTHER && config.getBoolValue("removeColors")) - msg = removeColors(msg); - chatLog(std::string(nick).append(" : ").append(msg), - byWho, - IgnoreRecord_false, - TryRemoveColors_false); -} - -void ChatTab::chatInput(const std::string &message) -{ - std::string msg = message; - trim(msg); - - if (msg.empty()) - return; - - replaceItemLinks(msg); - replaceVars(msg); - - switch (msg[0]) - { - case '/': - handleCommandStr(std::string(msg, 1)); - break; - case '?': - if (msg.size() > 1 && - msg[1] != '!' && - msg[1] != '?' && - msg[1] != '.' && - msg[1] != ' ' && - msg[1] != ',') - { - handleHelp(std::string(msg, 1)); - } - else - { - handleInput(msg); - } - break; - default: - handleInput(msg); - break; - } -} - -void ChatTab::scroll(const int amount) -{ - const int range = mScrollArea->getHeight() / 8 * amount; - Rect scr; - scr.y = mScrollArea->getVerticalScrollAmount() + range; - scr.height = abs(range); - mTextOutput->showPart(scr); -} - -void ChatTab::clearText() -{ - mTextOutput->clearRows(); -} - -void ChatTab::handleInput(const std::string &msg) -{ - if (chatHandler) - { - chatHandler->talk(ChatWindow::doReplace(msg), - mChannelName); - } -} - -void ChatTab::handleCommandStr(const std::string &msg) -{ - const size_t pos = msg.find(' '); - const std::string type(msg, 0, pos); - std::string args(msg, pos == std::string::npos ? msg.size() : pos + 1); - - args = trim(args); - if (!handleCommand(type, args)) - inputManager.executeChatCommand(type, args, this); -} - -void ChatTab::handleHelp(const std::string &msg) -{ - if (helpWindow != nullptr) - { - helpWindow->search(msg); - helpWindow->requestMoveToTop(); - } -} - -bool ChatTab::handleCommands(const std::string &type, const std::string &args) -{ - // need split to commands and call each - - return handleCommand(type, args); -} - -void ChatTab::saveToLogFile(const std::string &msg) const -{ - if (chatLogger != nullptr) - { - if (getType() == ChatTabType::INPUT) - { - chatLogger->log(msg); - } - else if (getType() == ChatTabType::DEBUG) - { - if (config.getBoolValue("enableDebugLog")) - chatLogger->log("#Debug", msg); - } - else if (!mLogName.empty()) - { - chatLogger->log(mLogName, msg); - } - } -} - -void ChatTab::addRow(std::string &line) -{ - if (line.find("[@@http") == std::string::npos) - { - size_t idx = 0; - for (size_t f = 0; f < line.length(); f++) - { - if (line.at(f) == ' ') - { - idx = f; - } - else if (f - idx > MAX_WORD_SIZE) - { - line.insert(f, " "); - idx = f; - } - } - } - mTextOutput->addRow(line); -} - -void ChatTab::loadFromLogFile(const std::string &name) -{ - if (chatLogger != nullptr) - { - std::list<std::string> list; - chatLogger->loadLast(name, list, 5); - std::list<std::string>::const_iterator i = list.begin(); - while (i != list.end()) - { - std::string line("##o" + *i); - addRow(line); - ++i; - } - } -} - -void ChatTab::addNewRow(std::string &line) -{ - if (mScrollArea->getVerticalScrollAmount() >= - mScrollArea->getVerticalMaxScroll()) - { - addRow(line); - mScrollArea->setVerticalScrollAmount( - mScrollArea->getVerticalMaxScroll()); - } - else - { - addRow(line); - } - mScrollArea->logic(); -} - -void ChatTab::playNewMessageSound() const -{ - soundManager.playGuiSound(SOUND_WHISPER); -} - -void ChatTab::showOnline(const std::string &nick, - const Online online) -{ - if (!mShowOnline) - return; - - if (online == Online_true) - { - // TRANSLATORS: chat message - chatLog(strprintf(_("%s is now Online."), nick.c_str()), - ChatMsgType::BY_SERVER); - } - else - { - // TRANSLATORS: chat message - chatLog(strprintf(_("%s is now Offline."), nick.c_str()), - ChatMsgType::BY_SERVER); - } -} diff --git a/src/gui/widgets/tabs/chat/chattab.h b/src/gui/widgets/tabs/chat/chattab.h deleted file mode 100644 index 440501af4..000000000 --- a/src/gui/widgets/tabs/chat/chattab.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_CHATTAB_H -#define GUI_WIDGETS_TABS_CHAT_CHATTAB_H - -#include "enums/gui/chatmsgtype.h" -#include "enums/gui/chattabtype.h" - -#include "enums/simpletypes/ignorerecord.h" -#include "enums/simpletypes/online.h" -#include "enums/simpletypes/tryremovecolors.h" - -#include "gui/widgets/browserbox.h" - -#include "gui/widgets/tabs/tab.h" - -#include "localconsts.h" - -class ScrollArea; - -#define debugMsg(str) \ - if (debugChatTab) \ - debugChatTab->chatLog(str, ChatMsgType::BY_SERVER); - -#define setTabColors(name) \ - setTabColor(&getThemeColor(name), \ - &getThemeColor(name##_OUTLINE)); \ - setHighlightedTabColor(&getThemeColor(name##_HIGHLIGHTED), \ - &getThemeColor(name##_HIGHLIGHTED_OUTLINE)); \ - setSelectedTabColor(&getThemeColor(name##_SELECTED), \ - &getThemeColor(name##_SELECTED_OUTLINE)) - -/** - * A tab for the chat window. This is special to ease chat handling. - */ -class ChatTab notfinal : public Tab -{ - public: - /** - * Constructor. - */ - ChatTab(const Widget2 *const widget, - const std::string &name, - const std::string &channel, - const std::string &logName, - const ChatTabTypeT &type); - - A_DELETE_COPY(ChatTab) - - virtual ~ChatTab(); - - /** - * Adds a line of text to our message list. Parameters: - * - * @param line Text message. - * @param own Type of message (usually the owner-type). - * @param ignoreRecord should this not be recorded? - * @param tryRemoveColors try remove color if configured - */ - void chatLog(std::string line, - ChatMsgTypeT own, - const IgnoreRecord ignoreRecord = IgnoreRecord_false, - const TryRemoveColors tryRemoveColors - = TryRemoveColors_true); - - /** - * Adds the text to the message list - * - * @param msg The message text which is to be sent. - */ - void chatLog(const std::string &nick, std::string msg); - - /** - * Determines whether the message is a command or message, then - * sends the given message to the game server to be said, or to the - * command handler - * - * @param msg The message text which is to be sent. - */ - void chatInput(const std::string &msg); - - /** - * Scrolls the chat window - * - * @param amount direction and amount to scroll. Negative numbers scroll - * up, positive numbers scroll down. The absolute amount indicates the - * amount of 1/8ths of chat window real estate that should be scrolled. - */ - void scroll(const int amount); - - /** - * Clears the text from the tab - */ - void clearText(); - - /** - * Handle special commands. Allows a tab to handle commands it - * defines itself. - * - * @returns true if the command was handled - * false if the command was not handled - */ - virtual bool handleCommand(const std::string &restrict type A_UNUSED, - const std::string &restrict args A_UNUSED) - { return false; } - - /** - * Handle special commands. Allows a tab to handle commands it - * defines itself. - * - * @returns true if the command was handled - * false if the command was not handled - */ - virtual bool handleCommands(const std::string &type, - const std::string &args); - - /** - * Returns type of the being. - */ - ChatTabTypeT getType() const noexcept2 A_WARN_UNUSED - { return mType; } - - void saveToLogFile(const std::string &msg) const; - - const std::list<std::string> &getRows() const A_WARN_UNUSED - { return mTextOutput->getRows(); } - - bool hasRows() const A_WARN_UNUSED - { return mTextOutput->hasRows(); } - - void loadFromLogFile(const std::string &name); - - bool getAllowHighlight() const noexcept2 A_WARN_UNUSED - { return mAllowHightlight; } - - void setAllowHighlight(const bool n) noexcept2 - { mAllowHightlight = n; } - - bool getRemoveNames() const noexcept2 A_WARN_UNUSED - { return mRemoveNames; } - - void setRemoveNames(const bool n) noexcept2 - { mRemoveNames = n; } - - bool getNoAway() const noexcept2 A_WARN_UNUSED - { return mNoAway; } - - void setNoAway(const bool n) noexcept2 - { mNoAway = n; } - - void addNewRow(std::string &line); - - void showOnline(const std::string &nick, - const Online online); - - virtual void playNewMessageSound() const; - - const std::string &getChannelName() const - { return mChannelName; } - - protected: - friend class ChatWindow; - friend class WhisperWindow; - - void setCurrent() override final - { setFlash(0); } - - virtual void handleInput(const std::string &msg); - - virtual void handleCommandStr(const std::string &msg); - - virtual void handleHelp(const std::string &msg); - - virtual void getAutoCompleteList(StringVect &names A_UNUSED) const - {} - - virtual void getAutoCompleteCommands(StringVect &names A_UNUSED) const - {} - - void addRow(std::string &line); - - BrowserBox *mTextOutput A_NONNULLPOINTER; - ScrollArea *mScrollArea; - std::string mChannelName; - std::string mLogName; - ChatTabTypeT mType; - bool mAllowHightlight; - bool mRemoveNames; - bool mNoAway; - bool mShowOnline; -}; - -extern ChatTab *localChatTab; -extern ChatTab *debugChatTab; - -#endif // GUI_WIDGETS_TABS_CHAT_CHATTAB_H diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.cpp b/src/gui/widgets/tabs/chat/emulateguildtab.cpp deleted file mode 100644 index 4e94bf11d..000000000 --- a/src/gui/widgets/tabs/chat/emulateguildtab.cpp +++ /dev/null @@ -1,108 +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/>. - */ - -#ifdef TMWA_SUPPORT - -#include "gui/widgets/tabs/chat/emulateguildtab.h" - -#include "configuration.h" -#include "soundmanager.h" - -#include "const/sound.h" - -#include "gui/windows/chatwindow.h" - -#include "utils/gettext.h" - -#include "net/tmwa/guildmanager.h" - -#include "debug.h" - -EmulateGuildTab::EmulateGuildTab(const Widget2 *const widget) : - // TRANSLATORS: guild chat tab name - ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD), - ConfigListener() -{ - setTabColors(ThemeColorId::GUILD_CHAT_TAB); - mShowOnline = config.getBoolValue("showGuildOnline"); - config.addListener("showGuildOnline", this); -} - -EmulateGuildTab::~EmulateGuildTab() -{ - config.removeListeners(this); - CHECKLISTENERS -} - -bool EmulateGuildTab::handleCommand(const std::string &restrict type, - const std::string &restrict args) -{ - if (type == "invite") - GuildManager::invite(args); - else if (type == "leave") - GuildManager::leave(); - else if (type == "kick") - GuildManager::kick(args); - else if (type == "notice") - GuildManager::notice(args); - else - return false; - - return true; -} - -void EmulateGuildTab::handleInput(const std::string &msg) -{ - if (guildManager == nullptr) - return; - guildManager->chat(ChatWindow::doReplace(msg)); -} - -void EmulateGuildTab::getAutoCompleteList(StringVect &names) const -{ - if (guildManager == nullptr) - return; - - guildManager->getNames(names); -} - -void EmulateGuildTab::getAutoCompleteCommands(StringVect &names) const -{ - names.push_back("/help"); - names.push_back("/invite "); - names.push_back("/leave"); - names.push_back("/kick "); - names.push_back("/notice "); -} - -void EmulateGuildTab::playNewMessageSound() const -{ - soundManager.playGuiSound(SOUND_GUILD); -} - -void EmulateGuildTab::optionChanged(const std::string &value) -{ - if (value == "showGuildOnline") - mShowOnline = config.getBoolValue("showGuildOnline"); -} - -#endif // TMWA_SUPPORT diff --git a/src/gui/widgets/tabs/chat/emulateguildtab.h b/src/gui/widgets/tabs/chat/emulateguildtab.h deleted file mode 100644 index 3cf3a0e59..000000000 --- a/src/gui/widgets/tabs/chat/emulateguildtab.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_EMULATEGUILDTAB_H -#define GUI_WIDGETS_TABS_CHAT_EMULATEGUILDTAB_H - -#ifdef TMWA_SUPPORT - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * Emulate guild tab, because server not support normal guilds. - */ -class EmulateGuildTab final : public ChatTab, - public ConfigListener -{ - public: - explicit EmulateGuildTab(const Widget2 *const widget); - - A_DELETE_COPY(EmulateGuildTab) - - ~EmulateGuildTab(); - - bool handleCommand(const std::string &restrict type, - const std::string &restrict args) override final; - - void playNewMessageSound() const override final; - - void optionChanged(const std::string &value) override final; - - protected: - void handleInput(const std::string &msg) override final; - - void getAutoCompleteList(StringVect &names) const override final; - - void getAutoCompleteCommands(StringVect &names) const override final; -}; - -#endif // TMWA_SUPPORT -#endif // GUI_WIDGETS_TABS_CHAT_EMULATEGUILDTAB_H diff --git a/src/gui/widgets/tabs/chat/gmtab.cpp b/src/gui/widgets/tabs/chat/gmtab.cpp deleted file mode 100644 index 3a63cbd2d..000000000 --- a/src/gui/widgets/tabs/chat/gmtab.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-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/widgets/tabs/chat/gmtab.h" - -#include "const/gui/chat.h" - -#include "gui/windows/chatwindow.h" - -#include "utils/gettext.h" - -#include "net/chathandler.h" - -#include "debug.h" - -GmTab *gmChatTab = nullptr; - -GmTab::GmTab(const Widget2 *const widget) : - // TRANSLATORS: gb tab name - ChatTab(widget, _("GM"), GM_CHANNEL, "#GM", ChatTabType::GM) -{ - setTabColors(ThemeColorId::GM_CHAT_TAB); -} - -GmTab::~GmTab() -{ -} - -void GmTab::handleInput(const std::string &msg) -{ - chatHandler->channelMessage(mChannelName, ChatWindow::doReplace(msg)); -} - -void GmTab::handleCommandStr(const std::string &msg A_UNUSED) -{ -} - -void GmTab::getAutoCompleteList(StringVect &names A_UNUSED) const -{ -} diff --git a/src/gui/widgets/tabs/chat/gmtab.h b/src/gui/widgets/tabs/chat/gmtab.h deleted file mode 100644 index a8dd46fd3..000000000 --- a/src/gui/widgets/tabs/chat/gmtab.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2013-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_WIDGETS_TABS_CHAT_GMTAB_H -#define GUI_WIDGETS_TABS_CHAT_GMTAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for whispers from a single player. - */ -class GmTab final : public ChatTab -{ - public: - explicit GmTab(const Widget2 *const widget); - - A_DELETE_COPY(GmTab) - - ~GmTab(); - - protected: - void getAutoCompleteList(StringVect &names) const - override final A_CONST; - - void handleInput(const std::string &msg) override final; - - void handleCommandStr(const std::string &msg) override final A_CONST; -}; - -extern GmTab *gmChatTab; - -#endif // GUI_WIDGETS_TABS_CHAT_GMTAB_H diff --git a/src/gui/widgets/tabs/chat/guildtab.cpp b/src/gui/widgets/tabs/chat/guildtab.cpp deleted file mode 100644 index 51416b8ef..000000000 --- a/src/gui/widgets/tabs/chat/guildtab.cpp +++ /dev/null @@ -1,125 +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/widgets/tabs/chat/guildtab.h" - -#include "configuration.h" -#include "soundmanager.h" - -#include "const/sound.h" - -#include "gui/windows/chatwindow.h" - -#include "input/inputmanager.h" - -#include "net/guildhandler.h" - -#include "utils/gettext.h" - -#include "debug.h" - -namespace EAthena -{ - extern Guild *taGuild; -} // namespace EAthena - -GuildTab::GuildTab(const Widget2 *const widget) : - // TRANSLATORS: guild chat tab name - ChatTab(widget, _("Guild"), "", "#Guild", ChatTabType::GUILD) -{ - setTabColors(ThemeColorId::GUILD_CHAT_TAB); - mShowOnline = config.getBoolValue("showGuildOnline"); - config.addListener("showGuildOnline", this); -} - -GuildTab::~GuildTab() -{ - config.removeListeners(this); - CHECKLISTENERS -} - -bool GuildTab::handleCommand(const std::string &restrict type, - const std::string &restrict args) -{ - if (type == "invite" && (EAthena::taGuild != nullptr)) - { - guildHandler->invite(args); - } - else if (type == "leave" && (EAthena::taGuild != nullptr)) - { - inputManager.executeChatCommand(InputAction::LEAVE_GUILD, - std::string(), - this); - } - else if (type == "kick" && (EAthena::taGuild != nullptr)) - { - inputManager.executeChatCommand(InputAction::KICK_GUILD, - args, - this); - } - else if (type == "notice" && (EAthena::taGuild != nullptr)) - { - inputManager.executeChatCommand(InputAction::GUILD_NOTICE, - args, - this); - } - else - { - return false; - } - - return true; -} - -void GuildTab::handleInput(const std::string &msg) -{ - if (EAthena::taGuild == nullptr) - return; - - guildHandler->chat(ChatWindow::doReplace(msg)); -} - -void GuildTab::getAutoCompleteList(StringVect &names) const -{ - if (EAthena::taGuild != nullptr) - EAthena::taGuild->getNames(names); -} - -void GuildTab::getAutoCompleteCommands(StringVect &names) const -{ - names.push_back("/help"); - names.push_back("/invite "); - names.push_back("/kick "); - names.push_back("/notice "); - names.push_back("/leave"); -} - -void GuildTab::playNewMessageSound() const -{ - soundManager.playGuiSound(SOUND_GUILD); -} - -void GuildTab::optionChanged(const std::string &value) -{ - if (value == "showGuildOnline") - mShowOnline = config.getBoolValue("showGuildOnline"); -} diff --git a/src/gui/widgets/tabs/chat/guildtab.h b/src/gui/widgets/tabs/chat/guildtab.h deleted file mode 100644 index 5aa540ecb..000000000 --- a/src/gui/widgets/tabs/chat/guildtab.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_GUILDTAB_H -#define GUI_WIDGETS_TABS_CHAT_GUILDTAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for a guild chat channel. - */ -class GuildTab notfinal : public ChatTab, - public ConfigListener -{ - public: - explicit GuildTab(const Widget2 *const widget); - - A_DELETE_COPY(GuildTab) - - virtual ~GuildTab(); - - bool handleCommand(const std::string &restrict type, - const std::string &restrict args) override final; - - void playNewMessageSound() const override final; - - void optionChanged(const std::string &value) override final; - - protected: - void handleInput(const std::string &msg) override final; - - void getAutoCompleteList(StringVect &names) const override final; - - void getAutoCompleteCommands(StringVect &names) const override final; -}; - -#endif // GUI_WIDGETS_TABS_CHAT_GUILDTAB_H diff --git a/src/gui/widgets/tabs/chat/langtab.cpp b/src/gui/widgets/tabs/chat/langtab.cpp deleted file mode 100644 index ba1e21711..000000000 --- a/src/gui/widgets/tabs/chat/langtab.cpp +++ /dev/null @@ -1,38 +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/>. - */ - -#include "gui/widgets/tabs/chat/langtab.h" - -#include "utils/gettext.h" - -#include "debug.h" - -LangTab *langChatTab = nullptr; - -LangTab::LangTab(const Widget2 *const widget, - const std::string &lang) : - // TRANSLATORS: lang chat tab name - ChatTab(widget, _("Lang"), lang + " ", "#Lang", ChatTabType::LANG) -{ -} - -LangTab::~LangTab() -{ -} diff --git a/src/gui/widgets/tabs/chat/langtab.h b/src/gui/widgets/tabs/chat/langtab.h deleted file mode 100644 index 773431e85..000000000 --- a/src/gui/widgets/tabs/chat/langtab.h +++ /dev/null @@ -1,39 +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_WIDGETS_TABS_CHAT_LANGTAB_H -#define GUI_WIDGETS_TABS_CHAT_LANGTAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -class LangTab final : public ChatTab -{ - public: - LangTab(const Widget2 *const widget, - const std::string &lang); - - A_DELETE_COPY(LangTab) - - ~LangTab(); -}; - -extern LangTab *langChatTab; - -#endif // GUI_WIDGETS_TABS_CHAT_LANGTAB_H diff --git a/src/gui/widgets/tabs/chat/partytab.cpp b/src/gui/widgets/tabs/chat/partytab.cpp deleted file mode 100644 index befbb0393..000000000 --- a/src/gui/widgets/tabs/chat/partytab.cpp +++ /dev/null @@ -1,151 +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/widgets/tabs/chat/partytab.h" - -#include "configuration.h" -#include "party.h" -#include "soundmanager.h" - -#include "being/localplayer.h" - -#include "const/sound.h" - -#include "gui/windows/chatwindow.h" - -#include "input/inputmanager.h" - -#include "net/net.h" -#include "net/partyhandler.h" - -#include "utils/gettext.h" - -#include "debug.h" - -PartyTab *partyTab = nullptr; - -PartyTab::PartyTab(const Widget2 *const widget) : - // TRANSLATORS: party chat tab name - ChatTab(widget, _("Party"), "", "#Party", ChatTabType::PARTY) -{ - setTabColors(ThemeColorId::PARTY_CHAT_TAB); - mShowOnline = config.getBoolValue("showPartyOnline"); - config.addListener("showPartyOnline", this); -} - -PartyTab::~PartyTab() -{ - config.removeListeners(this); - CHECKLISTENERS -} - -void PartyTab::handleInput(const std::string &msg) -{ - partyHandler->chat(ChatWindow::doReplace(msg)); -} - -bool PartyTab::handleCommand(const std::string &restrict type, - const std::string &restrict args) -{ - if (type == "invite") - { - partyHandler->invite(args); - } - else if (type == "leave") - { - inputManager.executeChatCommand(InputAction::LEAVE_PARTY, - args, - this); - } - else if (type == "kick") - { - inputManager.executeChatCommand(InputAction::KICK_PARTY, - args, - this); - } - else if (type == "item") - { - inputManager.executeChatCommand(InputAction::PARTY_ITEM_SHARE, - args, - this); - } - else if (type == "autoitem") - { - inputManager.executeChatCommand(InputAction::PARTY_AUTO_ITEM_SHARE, - args, - this); - } - else if (type == "exp") - { - inputManager.executeChatCommand(InputAction::PARTY_EXP_SHARE, - args, - this); - } - else if (type == "setleader" && - Net::getNetworkType() != ServerType::TMWATHENA) - { - inputManager.executeChatCommand( - InputAction::COMMAND_CHANGE_PARTY_LEADER, - args, - this); - } - else - { - return false; - } - - return true; -} - -void PartyTab::getAutoCompleteList(StringVect &names) const -{ - if (localPlayer == nullptr) - return; - - const Party *const p = localPlayer->getParty(); - - if (p != nullptr) - p->getNames(names); -} - -void PartyTab::getAutoCompleteCommands(StringVect &names) const -{ - names.push_back("/help"); - names.push_back("/invite "); - names.push_back("/leave"); - names.push_back("/kick "); - names.push_back("/item"); - names.push_back("/exp"); - if (Net::getNetworkType() != ServerType::TMWATHENA) - names.push_back("/setleader "); -} - -void PartyTab::playNewMessageSound() const -{ - soundManager.playGuiSound(SOUND_GUILD); -} - -void PartyTab::optionChanged(const std::string &value) -{ - if (value == "showPartyOnline") - mShowOnline = config.getBoolValue("showPartyOnline"); -} diff --git a/src/gui/widgets/tabs/chat/partytab.h b/src/gui/widgets/tabs/chat/partytab.h deleted file mode 100644 index a987c9362..000000000 --- a/src/gui/widgets/tabs/chat/partytab.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_PARTYTAB_H -#define GUI_WIDGETS_TABS_CHAT_PARTYTAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for a party chat channel. - */ -class PartyTab notfinal : public ChatTab, - public ConfigListener -{ - public: - explicit PartyTab(const Widget2 *const widget); - - A_DELETE_COPY(PartyTab) - - virtual ~PartyTab(); - - bool handleCommand(const std::string &restrict type, - const std::string &restrict args) override final; - - void playNewMessageSound() const override final; - - void optionChanged(const std::string &value) override final; - - protected: - void handleInput(const std::string &msg) override final; - - void getAutoCompleteList(StringVect &names) const override final; - - void getAutoCompleteCommands(StringVect &names) const override final; -}; - -extern PartyTab *partyTab; - -#endif // GUI_WIDGETS_TABS_CHAT_PARTYTAB_H diff --git a/src/gui/widgets/tabs/chat/tradetab.cpp b/src/gui/widgets/tabs/chat/tradetab.cpp deleted file mode 100644 index e16e5c08b..000000000 --- a/src/gui/widgets/tabs/chat/tradetab.cpp +++ /dev/null @@ -1,50 +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/widgets/tabs/chat/tradetab.h" - -#include "const/gui/chat.h" - -#include "gui/windows/chatwindow.h" - -#include "net/chathandler.h" - -#include "utils/gettext.h" - -#include "debug.h" - -TradeTab *tradeChatTab = nullptr; - -TradeTab::TradeTab(const Widget2 *const widget) : - // TRANSLATORS: trade chat tab name - ChatTab(widget, _("Trade"), TRADE_CHANNEL, "#Trade", ChatTabType::TRADE) -{ -} - -TradeTab::~TradeTab() -{ -} - -void TradeTab::handleInput(const std::string &msg) -{ - chatHandler->channelMessage(mChannelName, ChatWindow::doReplace(msg)); -} diff --git a/src/gui/widgets/tabs/chat/tradetab.h b/src/gui/widgets/tabs/chat/tradetab.h deleted file mode 100644 index 26c9bf8f6..000000000 --- a/src/gui/widgets/tabs/chat/tradetab.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_TRADETAB_H -#define GUI_WIDGETS_TABS_CHAT_TRADETAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for a party chat channel. - */ -class TradeTab final : public ChatTab -{ - public: - explicit TradeTab(const Widget2 *const widget); - - A_DELETE_COPY(TradeTab) - - ~TradeTab(); - - protected: - void handleInput(const std::string &msg) override final; -}; - -extern TradeTab *tradeChatTab; - -#endif // GUI_WIDGETS_TABS_CHAT_TRADETAB_H diff --git a/src/gui/widgets/tabs/chat/whispertab.cpp b/src/gui/widgets/tabs/chat/whispertab.cpp deleted file mode 100644 index 73b73a17c..000000000 --- a/src/gui/widgets/tabs/chat/whispertab.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The ManaPlus Client - * 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/>. - */ - -#include "gui/widgets/tabs/chat/whispertab.h" - -#include "being/localplayer.h" - -#include "net/chathandler.h" - -#include "gui/windows/chatwindow.h" - -#include "gui/widgets/windowcontainer.h" - -#include "utils/chatutils.h" - -#include "debug.h" - -WhisperTab::WhisperTab(const Widget2 *const widget, - const std::string &caption, - const std::string &nick) : - ChatTab(widget, caption, nick, nick, ChatTabType::WHISPER), - mNick(nick) -{ - setWhisperTabColors(); -} - -WhisperTab::~WhisperTab() -{ - if (chatWindow != nullptr) - chatWindow->removeWhisper(mNick); -} - -void WhisperTab::handleInput(const std::string &msg) -{ - std::string newMsg; - newMsg = ChatWindow::doReplace(msg); - chatHandler->privateMessage(mNick, newMsg); - - if (localPlayer != nullptr) - chatLog(localPlayer->getName(), newMsg); - else - chatLog("?", newMsg); -} - -void WhisperTab::handleCommandStr(const std::string &msg) -{ - if (msg == "close") - { - delete this; - return; - } - - const size_t pos = msg.find(' '); - const std::string type(msg, 0, pos); - - if (type == "me") - { - const std::string args(msg, pos == std::string::npos - ? msg.size() : pos + 1); - std::string str = textToMe(args); - chatHandler->privateMessage(mNick, str); - if (localPlayer != nullptr) - chatLog(localPlayer->getName(), str); - else - chatLog("?", str); - } - else - { - ChatTab::handleCommandStr(msg); - } -} - -bool WhisperTab::handleCommand(const std::string &restrict type, - const std::string &restrict args A_UNUSED) -{ - if (type == "close") - { - if (windowContainer != nullptr) - windowContainer->scheduleDelete(this); - else - delete this; - if (chatWindow != nullptr) - chatWindow->defaultTab(); - } - else - { - return false; - } - - return true; -} - -void WhisperTab::getAutoCompleteList(StringVect &names) const -{ - names.push_back(mNick); -} - -void WhisperTab::getAutoCompleteCommands(StringVect& commands) const -{ - commands.push_back("/close"); -} - -void WhisperTab::setWhisperTabColors() -{ - setTabColors(ThemeColorId::WHISPER_TAB); -} - -void WhisperTab::setWhisperTabOfflineColors() -{ - setTabColors(ThemeColorId::WHISPER_TAB_OFFLINE); -} diff --git a/src/gui/widgets/tabs/chat/whispertab.h b/src/gui/widgets/tabs/chat/whispertab.h deleted file mode 100644 index 1d3c03857..000000000 --- a/src/gui/widgets/tabs/chat/whispertab.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The ManaPlus Client - * 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_WIDGETS_TABS_CHAT_WHISPERTAB_H -#define GUI_WIDGETS_TABS_CHAT_WHISPERTAB_H - -#include "gui/widgets/tabs/chat/chattab.h" - -/** - * A tab for whispers from a single player. - */ -class WhisperTab final : public ChatTab -{ - public: - A_DELETE_COPY(WhisperTab) - - const std::string &getNick() const noexcept2 A_WARN_UNUSED - { return mNick; } - - bool handleCommand(const std::string &restrict type, - const std::string &restrict args) override final; - - void setWhisperTabColors(); - - void setWhisperTabOfflineColors(); - - protected: - friend class ChatWindow; - - void getAutoCompleteList(StringVect &names) const override final; - - void getAutoCompleteCommands(StringVect& commands) - const override final; - - /** - * Constructor. - * - * @param nick the name of the player this tab is whispering to - */ - WhisperTab(const Widget2 *const widget, - const std::string &caption, - const std::string &nick); - - ~WhisperTab(); - - void handleInput(const std::string &msg) override final; - - void handleCommandStr(const std::string &msg) override final; - - private: - std::string mNick; -}; - -#endif // GUI_WIDGETS_TABS_CHAT_WHISPERTAB_H diff --git a/src/gui/widgets/tabs/debugwindowtabs.cpp b/src/gui/widgets/tabs/debugwindowtabs.cpp deleted file mode 100644 index 321c3bcad..000000000 --- a/src/gui/widgets/tabs/debugwindowtabs.cpp +++ /dev/null @@ -1,492 +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/widgets/tabs/debugwindowtabs.h" - -#include "game.h" - -#include "being/localplayer.h" - -#include "particle/particleengine.h" - -#include "gui/viewport.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layouthelper.h" - -#ifdef USE_OPENGL -#include "resources/imagehelper.h" -#endif // USE_OPENGL - -#include "resources/map/map.h" - -#include "net/packetcounters.h" - -#include "utils/gettext.h" -#include "utils/stringutils.h" -#include "utils/timer.h" - -#include "debug.h" - -MapDebugTab::MapDebugTab(const Widget2 *const widget) : - DebugTab(widget), - // TRANSLATORS: debug window label - mMusicFileLabel(new Label(this, _("Music:"))), - // TRANSLATORS: debug window label - mMapLabel(new Label(this, _("Map:"))), - // TRANSLATORS: debug window label - mMapNameLabel(new Label(this, _("Map name:"))), - // TRANSLATORS: debug window label - mMinimapLabel(new Label(this, _("Minimap:"))), - mTileMouseLabel(new Label(this, strprintf("%s (%d, %d)", - // TRANSLATORS: debug window label - _("Cursor:"), 0, 0))), - mParticleCountLabel(new Label(this, strprintf("%s %d", - // TRANSLATORS: debug window label - _("Particle count:"), 88888))), - mMapActorCountLabel(new Label(this, strprintf("%s %d", - // TRANSLATORS: debug window label - _("Map actors count:"), 88888))), - // TRANSLATORS: debug window label - mXYLabel(new Label(this, strprintf("%s (?,?)", _("Player Position:")))), - mTexturesLabel(nullptr), - mUpdateTime(0), -#ifdef DEBUG_DRAW_CALLS - mDrawCallsLabel(new Label(this, strprintf("%s %s", - // TRANSLATORS: debug window label - _("Draw calls:"), "?"))), -#endif // DEBUG_DRAW_CALLS -#ifdef DEBUG_BIND_TEXTURE - mBindsLabel(new Label(this, strprintf("%s %s", - // TRANSLATORS: debug window label - _("Texture binds:"), "?"))), -#endif // DEBUG_BIND_TEXTURE - // TRANSLATORS: debug window label, frames per second - mFPSLabel(new Label(this, strprintf(_("%d FPS"), 0))), - // TRANSLATORS: debug window label, logic per second - mLPSLabel(new Label(this, strprintf(_("%d LPS"), 0))), - mFPSText() -{ - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - -#ifdef USE_OPENGL - switch (imageHelper->useOpenGL()) - { - case RENDER_SOFTWARE: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (Software)"); - break; - case RENDER_NORMAL_OPENGL: - case RENDER_NULL: - case RENDER_LAST: - default: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (normal OpenGL)"); - break; - case RENDER_SAFE_OPENGL: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (safe OpenGL)"); - break; - case RENDER_GLES_OPENGL: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (mobile OpenGL ES)"); - break; - case RENDER_GLES2_OPENGL: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (mobile OpenGL ES 2)"); - break; - case RENDER_MODERN_OPENGL: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (modern OpenGL)"); - break; - case RENDER_SDL2_DEFAULT: - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (SDL2 default)"); - break; - }; -#else // USE_OPENGL - - // TRANSLATORS: debug window label - mFPSText = _("%d FPS (Software)"); -#endif // USE_OPENGL - - place(0, 0, mFPSLabel, 2); - place(0, 1, mLPSLabel, 2); - place(0, 2, mMusicFileLabel, 2); - place(0, 3, mMapLabel, 2); - place(0, 4, mMapNameLabel, 2); - place(0, 5, mMinimapLabel, 2); - place(0, 6, mXYLabel, 2); - place(0, 7, mTileMouseLabel, 2); - place(0, 8, mParticleCountLabel, 2); - place(0, 9, mMapActorCountLabel, 2); -#ifdef USE_OPENGL -#if defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) \ - || defined(DEBUG_BIND_TEXTURE) - int n = 10; -#endif // defined (DEBUG_OPENGL_LEAKS) || defined(DEBUG_DRAW_CALLS) - // || defined(DEBUG_BIND_TEXTURE) -#ifdef DEBUG_OPENGL_LEAKS - mTexturesLabel = new Label(this, strprintf("%s %s", - // TRANSLATORS: debug window label - _("Textures count:"), "?")); - place(0, n, mTexturesLabel, 2); - n ++; -#endif // DEBUG_OPENGL_LEAKS -#ifdef DEBUG_DRAW_CALLS - place(0, n, mDrawCallsLabel, 2); - n ++; -#endif // DEBUG_DRAW_CALLS -#ifdef DEBUG_BIND_TEXTURE - place(0, n, mBindsLabel, 2); -#endif // DEBUG_BIND_TEXTURE -#endif // USE_OPENGL - - place.getCell().matchColWidth(0, 0); - place = h.getPlacer(0, 1); - setDimension(Rect(0, 0, 600, 300)); -} - -void MapDebugTab::logic() -{ - BLOCK_START("MapDebugTab::logic") - if (localPlayer != nullptr) - { - // TRANSLATORS: debug window label - mXYLabel->setCaption(strprintf("%s (%d, %d)", _("Player Position:"), - localPlayer->getTileX(), localPlayer->getTileY())); - } - else - { - // TRANSLATORS: debug window label - mXYLabel->setCaption(strprintf("%s (?, ?)", _("Player Position:"))); - } - - Game *const game = Game::instance(); - const Map *const map = game != nullptr ? game->getCurrentMap() : nullptr; - if (map != nullptr && - viewport != nullptr) - { - // Get the current mouse position - const int mouseTileX = (viewport->mMouseX + viewport->getCameraX()) - / map->getTileWidth(); - const int mouseTileY = (viewport->mMouseY + viewport->getCameraY()) - / map->getTileHeight(); - mTileMouseLabel->setCaption(strprintf("%s (%d, %d)", - // TRANSLATORS: debug window label - _("Cursor:"), mouseTileX, mouseTileY)); - - // TRANSLATORS: debug window label - mMusicFileLabel->setCaption(strprintf("%s %s", _("Music:"), - map->getProperty("music").c_str())); - // TRANSLATORS: debug window label - mMinimapLabel->setCaption(strprintf("%s %s", _("Minimap:"), - map->getProperty("minimap").c_str())); - // TRANSLATORS: debug window label - mMapLabel->setCaption(strprintf("%s %s", _("Map:"), - map->getProperty("_realfilename").c_str())); - // TRANSLATORS: debug window label - mMapNameLabel->setCaption(strprintf("%s %s", _("Map name:"), - map->getProperty("name").c_str())); - - if (mUpdateTime != cur_time) - { - mUpdateTime = cur_time; - // TRANSLATORS: debug window label - mParticleCountLabel->setCaption(strprintf(_("Particle count: %d"), - ParticleEngine::particleCount)); - - mMapActorCountLabel->setCaption( - // TRANSLATORS: debug window label - strprintf("%s %d", _("Map actors count:"), - map->getActorsCount())); -#ifdef USE_OPENGL -#ifdef DEBUG_OPENGL_LEAKS - mTexturesLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Textures count:"), textures_count)); -#endif // DEBUG_OPENGL_LEAKS -#ifdef DEBUG_DRAW_CALLS - if (mainGraphics) - { - mDrawCallsLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Draw calls:"), mainGraphics->getDrawCalls())); - } -#endif // DEBUG_DRAW_CALLS -#ifdef DEBUG_BIND_TEXTURE - if (mainGraphics) - { - mBindsLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Texture binds:"), mainGraphics->getBinds())); - } -#endif // DEBUG_BIND_TEXTURE -#endif // USE_OPENGL - } - } - else - { - // TRANSLATORS: debug window label - mTileMouseLabel->setCaption(strprintf("%s (?, ?)", _("Cursor:"))); - // TRANSLATORS: debug window label - mMusicFileLabel->setCaption(strprintf("%s ?", _("Music:"))); - // TRANSLATORS: debug window label - mMinimapLabel->setCaption(strprintf("%s ?", _("Minimap:"))); - // TRANSLATORS: debug window label - mMapLabel->setCaption(strprintf("%s ?", _("Map:"))); - // TRANSLATORS: debug window label - mMapNameLabel->setCaption(strprintf("%s ?", _("Map name:"))); - - mMapActorCountLabel->setCaption( - // TRANSLATORS: debug window label - strprintf("%s ?", _("Map actors count:"))); - } - - mMapActorCountLabel->adjustSize(); - mParticleCountLabel->adjustSize(); - - mFPSLabel->setCaption(strprintf(mFPSText.c_str(), fps)); - // TRANSLATORS: debug window label, logic per second - mLPSLabel->setCaption(strprintf(_("%d LPS"), lps)); - BLOCK_END("MapDebugTab::logic") -} - -TargetDebugTab::TargetDebugTab(const Widget2 *const widget) : - DebugTab(widget), - // TRANSLATORS: debug window label - mTargetLabel(new Label(this, strprintf("%s ?", _("Target:")))), - // TRANSLATORS: debug window label - mTargetIdLabel(new Label(this, strprintf("%s ? ", _("Target Id:")))), - mTargetTypeLabel(new Label(this, strprintf( - // TRANSLATORS: debug window label - "%s ? ", _("Target type:")))), - // TRANSLATORS: debug window label - mTargetLevelLabel(new Label(this, strprintf("%s ?", _("Target level:")))), - // TRANSLATORS: debug window label - mTargetRaceLabel(new Label(this, strprintf("%s ?", _("Target race:")))), - // TRANSLATORS: debug window label - mTargetPartyLabel(new Label(this, strprintf("%s ?", _("Target party:")))), - // TRANSLATORS: debug window label - mTargetGuildLabel(new Label(this, strprintf("%s ?", _("Target guild:")))), - // TRANSLATORS: debug window label - mAttackDelayLabel(new Label(this, strprintf("%s ?", _("Attack delay:")))), - // TRANSLATORS: debug window label - mMinHitLabel(new Label(this, strprintf("%s ?", _("Minimal hit:")))), - // TRANSLATORS: debug window label - mMaxHitLabel(new Label(this, strprintf("%s ?", _("Maximum hit:")))), - // TRANSLATORS: debug window label - mCriticalHitLabel(new Label(this, strprintf("%s ?", _("Critical hit:")))), - // TRANSLATORS: debug window label - mKarmaLabel(new Label(this, strprintf("%s ?", _("Karma:")))), - // TRANSLATORS: debug window label - mMannerLabel(new Label(this, strprintf("%s ?", _("Manner:")))), - // TRANSLATORS: debug window label - mEffectsLabel(new Label(this, strprintf("%s ?", _("Effects:")))) -{ - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mTargetLabel, 2); - place(0, 1, mTargetIdLabel, 2); - place(0, 2, mTargetTypeLabel, 2); - place(0, 3, mTargetLevelLabel, 2); - place(0, 4, mTargetRaceLabel, 2); - place(0, 5, mAttackDelayLabel, 2); - place(0, 6, mTargetPartyLabel, 2); - place(0, 7, mTargetGuildLabel, 2); - place(0, 8, mMinHitLabel, 2); - place(0, 9, mMaxHitLabel, 2); - place(0, 10, mCriticalHitLabel, 2); - place(0, 11, mKarmaLabel, 2); - place(0, 12, mMannerLabel, 2); - place(0, 13, mEffectsLabel, 2); - - place.getCell().matchColWidth(0, 0); - place = h.getPlacer(0, 1); - setDimension(Rect(0, 0, 600, 300)); -} - -void TargetDebugTab::logic() -{ - BLOCK_START("TargetDebugTab::logic") - if ((localPlayer != nullptr) && (localPlayer->getTarget() != nullptr)) - { - const Being *const target = localPlayer->getTarget(); - - // TRANSLATORS: debug window label - mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"), - target->getName().c_str(), target->getTileX(), - target->getTileY())); - - mTargetIdLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Target Id:"), toInt(target->getId(), int))); - mTargetTypeLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Target type:"), toInt(target->getSubType(), int))); - if (target->getLevel() != 0) - { - mTargetLevelLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Target Level:"), target->getLevel())); - } - else - { - mTargetLevelLabel->setCaption(strprintf("%s ?", - // TRANSLATORS: debug window label - _("Target Level:"))); - } - - mTargetRaceLabel->setCaption(strprintf("%s %s", - // TRANSLATORS: debug window label - _("Target race:"), target->getRaceName().c_str())); - - // TRANSLATORS: debug window label - mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"), - target->getPartyName().c_str())); - - // TRANSLATORS: debug window label - mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"), - target->getGuildName().c_str())); - - mMinHitLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Minimal hit:"), target->getMinHit())); - mMaxHitLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Maximum hit:"), target->getMaxHit())); - mCriticalHitLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Critical hit:"), target->getCriticalHit())); - mKarmaLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Karma:"), target->getKarma())); - mMannerLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Manner:"), target->getManner())); - mEffectsLabel->setCaption(strprintf("%s %s", - // TRANSLATORS: debug window label - _("Effects:"), target->getStatusEffectsString().c_str())); - - const int delay = target->getAttackDelay(); - if (delay != 0) - { - mAttackDelayLabel->setCaption(strprintf("%s %d", - // TRANSLATORS: debug window label - _("Attack delay:"), delay)); - } - else - { - mAttackDelayLabel->setCaption(strprintf( - // TRANSLATORS: debug window label - "%s ?", _("Attack delay:"))); - } - } - else - { - // TRANSLATORS: debug window label - mTargetLabel->setCaption(strprintf("%s ?", _("Target:"))); - // TRANSLATORS: debug window label - mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:"))); - // TRANSLATORS: debug window label - mTargetTypeLabel->setCaption(strprintf("%s ?", _("Target type:"))); - // TRANSLATORS: debug window label - mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:"))); - // TRANSLATORS: debug window label - mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:"))); - // TRANSLATORS: debug window label - mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:"))); - // TRANSLATORS: debug window label - mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:"))); - // TRANSLATORS: debug window label - mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:"))); - // TRANSLATORS: debug window label - mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:"))); - // TRANSLATORS: debug window label - mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:"))); - // TRANSLATORS: debug window label - mKarmaLabel->setCaption(strprintf("%s ?", _("Karma:"))); - // TRANSLATORS: debug window label - mMannerLabel->setCaption(strprintf("%s ?", _("Manner:"))); - // TRANSLATORS: debug window label - mEffectsLabel->setCaption(strprintf("%s ?", _("Effects:"))); - } - - mTargetLabel->adjustSize(); - mTargetIdLabel->adjustSize(); - mTargetTypeLabel->adjustSize(); - mTargetLevelLabel->adjustSize(); - mTargetPartyLabel->adjustSize(); - mTargetGuildLabel->adjustSize(); - mAttackDelayLabel->adjustSize(); - mMinHitLabel->adjustSize(); - mMaxHitLabel->adjustSize(); - mCriticalHitLabel->adjustSize(); - mKarmaLabel->adjustSize(); - mMannerLabel->adjustSize(); - mEffectsLabel->adjustSize(); - BLOCK_END("TargetDebugTab::logic") -} - -NetDebugTab::NetDebugTab(const Widget2 *const widget) : - DebugTab(widget), - mPingLabel(new Label(this, " ")), - mInPackets1Label(new Label(this, " ")), - mOutPackets1Label(new Label(this, " ")) -{ - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mPingLabel, 2); - place(0, 1, mInPackets1Label, 2); - place(0, 2, mOutPackets1Label, 2); - - place.getCell().matchColWidth(0, 0); - place = h.getPlacer(0, 1); - setDimension(Rect(0, 0, 600, 300)); -} - -void NetDebugTab::logic() -{ - BLOCK_START("NetDebugTab::logic") - if (localPlayer != nullptr) - { - // TRANSLATORS: debug window label - mPingLabel->setCaption(strprintf(_("Ping: %s ms"), - localPlayer->getPingTime().c_str())); - } - else - { - // TRANSLATORS: debug window label - mPingLabel->setCaption(strprintf(_("Ping: %s ms"), "0")); - } - // TRANSLATORS: debug window label - mInPackets1Label->setCaption(strprintf(_("In: %d bytes/s"), - PacketCounters::getInBytes())); - // TRANSLATORS: debug window label - mOutPackets1Label->setCaption(strprintf(_("Out: %d bytes/s"), - PacketCounters::getOutBytes())); - BLOCK_END("NetDebugTab::logic") -} diff --git a/src/gui/widgets/tabs/debugwindowtabs.h b/src/gui/widgets/tabs/debugwindowtabs.h deleted file mode 100644 index 566987cd0..000000000 --- a/src/gui/widgets/tabs/debugwindowtabs.h +++ /dev/null @@ -1,129 +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_WIDGETS_TABS_DEBUGWINDOWTABS_H -#define GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H - -#include "gui/widgets/container.h" - -class Label; - -class DebugTab notfinal : public Container -{ - friend class DebugWindow; - - public: - A_DELETE_COPY(DebugTab) - - void logic() override - { - } - - void resize(const int x, const int y) - { setDimension(Rect(0, 0, x, y)); } - - protected: - explicit DebugTab(const Widget2 *const widget) : - Container(widget) - { setSelectable(false); } -}; - -class MapDebugTab final : public DebugTab -{ - friend class DebugWindow; - - public: - explicit MapDebugTab(const Widget2 *const widget); - - A_DELETE_COPY(MapDebugTab) - - void logic() override final; - - private: - Label *mMusicFileLabel A_NONNULLPOINTER; - Label *mMapLabel A_NONNULLPOINTER; - Label *mMapNameLabel A_NONNULLPOINTER; - Label *mMinimapLabel A_NONNULLPOINTER; - Label *mTileMouseLabel A_NONNULLPOINTER; - Label *mParticleCountLabel A_NONNULLPOINTER; - Label *mMapActorCountLabel A_NONNULLPOINTER; - Label *mXYLabel A_NONNULLPOINTER; - Label *mTexturesLabel A_NONNULLPOINTER; - time_t mUpdateTime; -#ifdef DEBUG_DRAW_CALLS - Label *mDrawCallsLabel A_NONNULLPOINTER; -#endif // DEBUG_DRAW_CALLS -#ifdef DEBUG_BIND_TEXTURE - Label *mBindsLabel A_NONNULLPOINTER; -#endif // DEBUG_BIND_TEXTURE - - Label *mFPSLabel A_NONNULLPOINTER; - Label *mLPSLabel A_NONNULLPOINTER; - std::string mFPSText; -}; - -class TargetDebugTab final : public DebugTab -{ - friend class DebugWindow; - - public: - explicit TargetDebugTab(const Widget2 *const widget); - - A_DELETE_COPY(TargetDebugTab) - - void logic() override final; - - private: - Label *mTargetLabel A_NONNULLPOINTER; - Label *mTargetIdLabel A_NONNULLPOINTER; - Label *mTargetTypeLabel A_NONNULLPOINTER; - Label *mTargetLevelLabel A_NONNULLPOINTER; - Label *mTargetRaceLabel A_NONNULLPOINTER; - Label *mTargetPartyLabel A_NONNULLPOINTER; - Label *mTargetGuildLabel A_NONNULLPOINTER; - Label *mAttackDelayLabel A_NONNULLPOINTER; - Label *mMinHitLabel A_NONNULLPOINTER; - Label *mMaxHitLabel A_NONNULLPOINTER; - Label *mCriticalHitLabel A_NONNULLPOINTER; - Label *mKarmaLabel A_NONNULLPOINTER; - Label *mMannerLabel A_NONNULLPOINTER; - Label *mEffectsLabel A_NONNULLPOINTER; -}; - -class NetDebugTab final : public DebugTab -{ - friend class DebugWindow; - - public: - explicit NetDebugTab(const Widget2 *const widget); - - A_DELETE_COPY(NetDebugTab) - - void logic() override final; - - private: - Label *mPingLabel A_NONNULLPOINTER; - Label *mInPackets1Label A_NONNULLPOINTER; - Label *mOutPackets1Label A_NONNULLPOINTER; -}; - -#endif // GUI_WIDGETS_TABS_DEBUGWINDOWTABS_H diff --git a/src/gui/widgets/tabs/setup_audio.cpp b/src/gui/widgets/tabs/setup_audio.cpp deleted file mode 100644 index 6275ff59a..000000000 --- a/src/gui/widgets/tabs/setup_audio.cpp +++ /dev/null @@ -1,214 +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/widgets/tabs/setup_audio.h" - -#include "resources/map/map.h" - -#include "configuration.h" -#include "soundmanager.h" - -#include "gui/viewport.h" - -#include "gui/models/soundsmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/scrollarea.h" - -#include "utils/delete2.h" - -#include "debug.h" - -Setup_Audio::Setup_Audio(const Widget2 *const widget) : - SetupTabScroll(widget), - mSoundModel(new SoundsModel), - mChannelsList(new SetupItemNames) -{ - // TRANSLATORS: audio tab in settings - setName(_("Audio")); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - // TRANSLATORS: settings option - new SetupItemLabel(_("Basic settings"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable Audio"), "", "sound", this, "soundEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable music"), "", - "playMusic", this, "playMusicEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable game sfx"), "", - "playBattleSound", this, "playBattleSoundEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable gui sfx"), "", - "playGuiSound", this, "playGuiSoundEvent"); - - // TRANSLATORS: settings option - new SetupItemSlider(_("Sfx volume"), "", "sfxVolume", - this, "sfxVolumeEvent", 0, SoundManager::getMaxVolume(), 1, - 150, - OnTheFly_true, - MainConfig_true); - - // TRANSLATORS: settings option - new SetupItemSlider(_("Music volume"), "", "musicVolume", - this, "musicVolumeEvent", 0, SoundManager::getMaxVolume(), 1, - 150, - OnTheFly_true, - MainConfig_true); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable music fade out"), "", - "fadeoutmusic", this, "fadeoutmusicEvent"); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Audio frequency"), "", - "audioFrequency", this, "audioFrequencyEvent", 14000, 192000); - - // TRANSLATORS: audio type - mChannelsList->push_back(_("mono")); - // TRANSLATORS: audio type - mChannelsList->push_back(_("stereo")); - // TRANSLATORS: audio type - mChannelsList->push_back(_("surround")); - // TRANSLATORS: audio type - mChannelsList->push_back(_("surround+center+lfe")); - // TRANSLATORS: settings option - new SetupItemSlider2(_("Audio channels"), "", "audioChannels", this, - "audioChannels", 1, 4, 1, mChannelsList, - OnTheFly_false, - MainConfig_true, - DoNotAlign_false); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Parallel number of sounds"), "", - "parallelAudioChannels", this, "parallelAudioChannelsEvent", 1, 1000); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Sound effects"), "", this); - - // TRANSLATORS: settings option - new SetupItemSound(_("Information dialog sound"), "", - "soundinfo", this, "soundinfoEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Request dialog sound"), "", - "soundrequest", this, "soundrequestEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Whisper message sound"), "", - "soundwhisper", this, "soundwhisperEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Guild / Party message sound"), "", - "soundguild", this, "soundguildEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Highlight message sound"), "", - "soundhighlight", this, "soundhighlightEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Global message sound"), "", - "soundglobal", this, "soundglobalEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Error message sound"), "", - "sounderror", this, "sounderrorEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Trade request sound"), "", - "soundtrade", this, "soundtradeEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Show window sound"), "", - "soundshowwindow", this, "soundshowwindowEvent", mSoundModel); - - // TRANSLATORS: settings option - new SetupItemSound(_("Hide window sound"), "", - "soundhidewindow", this, "soundhidewindowEvent", mSoundModel); - - // TRANSLATORS: settings group - new SetupItemLabel(_("Other"), "", this); - -#ifdef USE_MUMBLE - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable mumble voice chat"), "", - "enableMumble", this, "enableMumbleEvent"); -#endif // USE_MUMBLE - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Download music"), "", - "download-music", this, "download-musicEvent"); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Audio::~Setup_Audio() -{ - delete2(mSoundModel); - delete2(mChannelsList); -} - -void Setup_Audio::apply() -{ - SetupTabScroll::apply(); - if (config.getBoolValue("sound")) - { - soundManager.init(); - if (config.getBoolValue("playMusic")) - { - if (viewport != nullptr) - { // in game - const Map *const map = viewport->getMap(); - if (map != nullptr) - { - soundManager.playMusic(map->getMusicFile(), - SkipError_false); - } - } - else - { // not in game - soundManager.playMusic(branding.getValue( - "loginMusic", - "keprohm.ogg"), - SkipError_true); - } - } - else - { - soundManager.stopMusic(); - } - } - else - { - soundManager.close(); - } -} diff --git a/src/gui/widgets/tabs/setup_audio.h b/src/gui/widgets/tabs/setup_audio.h deleted file mode 100644 index d76add16c..000000000 --- a/src/gui/widgets/tabs/setup_audio.h +++ /dev/null @@ -1,47 +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_WIDGETS_TABS_SETUP_AUDIO_H -#define GUI_WIDGETS_TABS_SETUP_AUDIO_H - -#include "gui/widgets/setupitem.h" - -#include "gui/widgets/tabs/setuptabscroll.h" - -class Setup_Audio final : public SetupTabScroll -{ - public: - explicit Setup_Audio(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Audio) - - ~Setup_Audio(); - - void apply() override final; - - private: - ListModel *mSoundModel; - - SetupItemNames *mChannelsList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_AUDIO_H diff --git a/src/gui/widgets/tabs/setup_chat.cpp b/src/gui/widgets/tabs/setup_chat.cpp deleted file mode 100644 index b27e1ec53..000000000 --- a/src/gui/widgets/tabs/setup_chat.cpp +++ /dev/null @@ -1,347 +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/>. - */ - -#include "gui/widgets/tabs/setup_chat.h" - -#include "gui/windows/chatwindow.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/setupitem.h" - -#include "utils/gettext.h" - -#include "debug.h" - -Setup_Chat::Setup_Chat(const Widget2 *const widget) : - SetupTabScroll(widget) -{ - // TRANSLATORS: settings tab name - setName(_("Chat")); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - // TRANSLATORS: settings group - new SetupItemLabel(_("Window"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Auto hide chat window"), - // TRANSLATORS: settings description - _("Chat window will be automatically hidden when not in use.\n\n" - "Hit Enter or hover mouse to show chat again."), - "autohideChat", this, "autohideChatEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Protect chat focus"), - // TRANSLATORS: settings description - _("Enables aggressive protection of input focus in chat window.\n\n" - "Note: no other text inputs will be allowed to receive text input " - "when you typing in chat window."), - "protectChatFocus", this, "protectChatFocusEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Colors"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Remove colors from received chat messages"), - // TRANSLATORS: settings description - _("Enable this setting to strip colors from incoming chat messages. " - "All messages will use default chat text color if this enabled."), - "removeColors", this, "removeColorsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show chat colors list"), - // TRANSLATORS: settings description - _("Enable this setting to show color selection drop-down in chat " - "window. Chat window will display color selection drop-down.\n\n" - "It allows one to select default color of outgoing chat messages " - "easily, but also occupies some space in chat window."), - "showChatColorsList", this, "showChatColorsListEvent"); - - - // TRANSLATORS: settings option - new SetupItemLabel(_("Commands"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Allow magic and GM commands in all chat tabs"), - // TRANSLATORS: settings description - _("Enable this setting to be able to type spells and GM commands in " - "any tab."), - "allowCommandsInChatTabs", this, "allowCommandsInChatTabsEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Limits"), "", this); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Limit max chars in chat line"), - // TRANSLATORS: settings description - _("Limits how many characters will be shown in longest lines " - "of text displayed in chat.\n\n" - "Note: long lines can make client slower. Lines longer than this " - "limit will be truncated."), - "chatMaxCharLimit", this, "chatMaxCharLimitEvent", 0, 500); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Limit max lines in chat"), - // TRANSLATORS: settings description - _("Limits how many lines chat will keep in scrollback buffer. Chat " - "keeps specified number of last lines of text. Oldest lines exceeding " - "this limit are discarded from scrollback buffer.\n\n" - "Note: keeping too many lines in scroll buffer can slow client down."), - "chatMaxLinesLimit", this, "chatMaxLinesLimitEvent", 0, 500); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Logs"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable chat Log"), - // TRANSLATORS: settings description - _("If you enable this setting, chat logs will be written to disk.\n\n" - "Note: chat logs can take noticeable amount of disk space over time."), - "enableChatLog", this, "enableChatLogEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable debug chat Log"), - // TRANSLATORS: settings description - _("If you enable this, debug chat tab also will be logged to disk."), - "enableDebugLog", this, "enableDebugLogEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show chat history"), - // TRANSLATORS: settings description - _("If this setting enabled, client will load old chat tabs content " - "from logs on startup instead of starting with empty chat tabs."), - "showChatHistory", this, "showChatHistoryEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show party online messages"), - // TRANSLATORS: settings description - _("If this setting is enabled, online status changes of party members" - " will be shown in party tab of chat.\n\nThis adds some extra noise " - "to chat, but allows one to see when your buddies are coming online."), - "showPartyOnline", this, "showPartyOnlineEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show guild online messages"), - // TRANSLATORS: settings description - _("If this setting is enabled, online status changes of guild members" - " will be shown in guild tab of chat.\n\nThis adds some extra noise " - "to chat, but allows one to see when your buddies are coming online."), - "showGuildOnline", this, "showGuildOnlineEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Messages"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Hide shop messages"), - // TRANSLATORS: settings description - _("If this setting enabled, no messages related to built-in ManaPlus " - "shop will be displayed in chat. Disable this setting if you want " - "to see shop-related messages.\n\nNote: technically, ManaPlus shop " - "implemented as usual private messages with special content. If you " - "disable this setting, you will be able to see these messages and get " - "idea when other players are looking at your shop."), - "hideShopMessages", this, "hideShopMessagesEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show MVP messages"), - // TRANSLATORS: settings description - _("Enable this setting to see MVP messages from server.\n\n" - "Note: MVP messages are not used on TMW/Evol/etc servers, so this " - "feature usually makes little difference."), - "showMVP", this, "showMVPEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Tabs"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Put all whispers in tabs"), - // TRANSLATORS: settings description - _("If this setting enabled, all whispers (private messages) will " - "be placed in separate tabs, separate tab for each player. If this " - "setting disabled, all whispers will appear in General tab.\n\n" - "Note: putting all whispers to single General tab is known to be " - "confusing. Think twice before disabling this feature."), - "whispertab", this, "whispertabEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Log magic messages in debug tab"), - // TRANSLATORS: settings description - _("If this setting is enabled, spell invocation will be shown in " - "Debug tab. If disabled, it will be shown in General tab instead.\n\n" - "Note: it does not affects server replies related to spells."), - "showMagicInDebug", this, "showMagicInDebugEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show server messages in debug tab"), - // TRANSLATORS: settings description - _("If this setting is enabled, server messages will be shown in " - "Debug tab of chat. If disabled, server messages will appear in " - "General chat instead.\n\nNote: according to 4144, disabling this " - "could also make you to lose some debug messages from client in " - "Debug tab since these are fake server messages."), - "serverMsgInDebug", this, "serverMsgInDebugEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable trade tab"), - // TRANSLATORS: settings description - _("Enables trade tab. Trade tab is basically some filter. Messages " - "containing words typical for trades will go to Trade tab. This " - "will make General tab less noisy. If this setting is disabled, all " - "trade related players messages will stay in General tab."), - "enableTradeTab", this, "enableTradeTabEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable gm tab"), - // TRANSLATORS: settings description - _("If enabled, GM tab will appear in chat. It displays text related " - "GM activity.\n\nNote: this setting only makes difference for " - "GMs (Game Masters) since this tab only appears for GMs."), - "enableGmTab", this, "enableGmTabEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable language tab"), - // TRANSLATORS: settings description - _("If this feature enabled, language tab will appear if server " - "supports this feature.\n\nNote: only supported by Evol server yet."), - "enableLangTab", this, "enableLangTabEvent", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show all languages messages"), - // TRANSLATORS: settings description - _("If this setting enabled and server supports different chats " - "for different languages, you will see messages for all languages, " - "regardless of your language preferences.\n\nNote: it only works " - "on servers supporting language tabs feature, like Evol."), - "showAllLang", this, "showAllLangEvent", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable battle tab"), - // TRANSLATORS: settings description - _("If this setting enabled, Battle tab will appear in chat. This " - "tab will contain messages related to battles, like damage and " - "experience gain, if battle messages are enabled.\n\n" - "Note: client restart required to take effect."), - "enableBattleTab", this, "enableBattleTabEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show battle events"), - // TRANSLATORS: settings description - _("If this setting enabled, messages related to battle like damage " - "or experience gain will be displayed in Debug or Battle tab. If " - "disabled, no battle messages will be displayed."), - "showBattleEvents", this, "showBattleEventsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Resize chat tabs if need"), - // TRANSLATORS: settings description - _("If this feature enabled, text in chat will be automatically " - "adjusted to adapt to appearance of chat input field when you " - "typing message and when input field of chat disappears. If disabled, " - "chat input area will always occupy its place, which could be " - "otherwise usable for text.\n\n" - "Note: its mostly about jumpy attitude vs " - "less usable space for text."), - "hideChatInput", this, "hideChatInputEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable trade spam filter"), - "", "enableTradeFilter", this, "enableTradeFilterEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Time"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Use local time"), - // TRANSLATORS: settings description - _("If this feature enabled, timestamps in chat will use local times. " - "If disabled, server time will be used (often it is GMT+0)."), - "useLocalTime", this, "useLocalTimeEvent"); - - // TRANSLATORS: settings group - new SetupItemLabel(_("Other"), "", this); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Highlight words (separated by comma)"), - // TRANSLATORS: settings description - _("Here you can specify some extra words which will also cause " - "highlighting. Use comma to separate words.\n\nNote: frequent " - "highlights are annoying - use it with caution."), - "highlightWords", this, "highlightWordsEvent"); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Globals ignore names (separated by comma)"), - // TRANSLATORS: settings description - _("This setting allows you to ignore some global messages if " - "particular sender (NPC, GM) annoys you too much. Global will be " - "moved to Debug instead.\n\nNote: careless use of this feature can " - "make you to miss important announces!"), - "globalsFilter", this, "globalsFilterEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show emotes button in chat"), - // TRANSLATORS: settings description - _("If this setting enabled, button will appear near text input " - "field. This button allows one to invoke composing window, which " - "allows one to insert smiles and text formatting easily.\n\n" - "Note: same window can also be invoked by hotkey when typing, usually " - "F1 by default."), - "showEmotesButton", this, "showEmotesButtonEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show motd server message on start"), - // TRANSLATORS: settings description - _("If this setting enabled, client will display server MOTD (message" - " of the day) once you connect to server. Disable it to hide MOTD."), - "showmotd", this, "showmotdEvent"); - - setDimension(Rect(0, 0, 550, 350)); -} - -void Setup_Chat::apply() -{ - SetupTabScroll::apply(); - - if (chatWindow != nullptr) - { - chatWindow->adjustTabSize(); - chatWindow->parseHighlights(); - } -} - -void Setup_Chat::externalUpdated() -{ - reread("enableLangTab"); - reread("showAllLang"); -} diff --git a/src/gui/widgets/tabs/setup_chat.h b/src/gui/widgets/tabs/setup_chat.h deleted file mode 100644 index 2b18b0489..000000000 --- a/src/gui/widgets/tabs/setup_chat.h +++ /dev/null @@ -1,40 +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_WIDGETS_TABS_SETUP_CHAT_H -#define GUI_WIDGETS_TABS_SETUP_CHAT_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class Setup_Chat final : public SetupTabScroll -{ - public: - explicit Setup_Chat(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Chat) - - void apply() override final; - - void externalUpdated() override final; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_CHAT_H diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp deleted file mode 100644 index 4f2b35113..000000000 --- a/src/gui/widgets/tabs/setup_colors.cpp +++ /dev/null @@ -1,491 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> - * 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/widgets/tabs/setup_colors.h" - -#include "gui/gui.h" -#include "gui/userpalette.h" - -#include "gui/fonts/font.h" - -#include "gui/widgets/browserbox.h" -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/listbox.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/slider.h" -#include "gui/widgets/textfield.h" -#include "gui/widgets/textpreview.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include <cmath> - -#include "debug.h" - -const char *const Setup_Colors::rawmsg = - // TRANSLATORS: color selection preview message - N_("This is what the color looks like"); - -Setup_Colors::Setup_Colors(const Widget2 *const widget) : - SetupTab(widget), - SelectionListener(), - mColorBox(CREATEWIDGETR(ListBox, this, userPalette, "")), - mScroll(new ScrollArea(this, mColorBox, - Opaque_true, "setup_colors_background.xml")), - mPreview(new BrowserBox(this, Opaque_true, - "browserbox.xml")), - mTextPreview(new TextPreview(this, gettext(rawmsg))), - mPreviewBox(new ScrollArea(this, mPreview, Opaque_true, - "setup_colors_preview_background.xml")), - mSelected(-1), - // TRANSLATORS: colors tab. label. - mGradTypeLabel(new Label(this, _("Type:"))), - mGradTypeSlider(new Slider(this, 0.0, 3.0, 1.0)), - mGradTypeText(new Label(this)), - // TRANSLATORS: colors tab. label. - mGradDelayLabel(new Label(this, _("Delay:"))), - mGradDelaySlider(new Slider(this, 20.0, 100.0, 1.0)), - mGradDelayText(new TextField(this)), - // TRANSLATORS: colors tab. label. - mRedLabel(new Label(this, _("Red:"))), - mRedSlider(new Slider(this, 0.0, 255.0, 1.0)), - mRedText(new TextField(this)), - // TRANSLATORS: colors tab. label. - mGreenLabel(new Label(this, _("Green:"))), - mGreenSlider(new Slider(this, 0.0, 255.0, 1.0)), - mGreenText(new TextField(this)), - // TRANSLATORS: colors tab. label. - mBlueLabel(new Label(this, _("Blue:"))), - mBlueSlider(new Slider(this, 0.0, 255.0, 1.0)), - mBlueText(new TextField(this)) -{ - // TRANSLATORS: settings colors tab name - setName(_("Colors")); - mColorBox->addSelectionListener(this); - mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mPreview->setOpaque(Opaque_false); - - // don't do anything with links - mPreview->setLinkHandler(nullptr); - - mPreviewBox->setHeight(20); - mPreviewBox->setScrollPolicy(ScrollArea::SHOW_NEVER, - ScrollArea::SHOW_NEVER); - - mGradTypeSlider->setWidth(180); - mGradTypeSlider->setActionEventId("slider_grad"); - mGradTypeSlider->setValue(0); - mGradTypeSlider->addActionListener(this); - mGradTypeSlider->setEnabled(false); - - // TRANSLATORS: color type - std::string longText = _("Static"); - - const Font *const font = getFont(); - // TRANSLATORS: color type - if (getFont()->getWidth(_("Pulse")) > font->getWidth(longText)) - { - // TRANSLATORS: color type - longText = _("Pulse"); - } - // TRANSLATORS: color type - if (getFont()->getWidth(_("Rainbow")) > font->getWidth(longText)) - { - // TRANSLATORS: color type - longText = _("Rainbow"); - } - // TRANSLATORS: color type - if (getFont()->getWidth(_("Spectrum")) > font->getWidth(longText)) - { - // TRANSLATORS: color type - longText = _("Spectrum"); - } - - mGradTypeText->setCaption(longText); - - mGradDelayText->setWidth(40); - mGradDelayText->setRange(20, 100); - mGradDelayText->setNumeric(true); - mGradDelayText->setEnabled(false); - - mGradDelaySlider->setWidth(180); - mGradDelaySlider->setValue(mGradDelayText->getValue()); - mGradDelaySlider->setActionEventId("slider_graddelay"); - mGradDelaySlider->addActionListener(this); - mGradDelaySlider->setEnabled(false); - - mRedText->setWidth(40); - mRedText->setRange(0, 255); - mRedText->setNumeric(true); - mRedText->setEnabled(false); - - mRedSlider->setWidth(180); - mRedSlider->setValue(mRedText->getValue()); - mRedSlider->setActionEventId("slider_red"); - mRedSlider->addActionListener(this); - mRedSlider->setEnabled(false); - - mGreenText->setWidth(40); - mGreenText->setRange(0, 255); - mGreenText->setNumeric(true); - mGreenText->setEnabled(false); - - mGreenSlider->setWidth(180); - mGreenSlider->setValue(mGreenText->getValue()); - mGreenSlider->setActionEventId("slider_green"); - mGreenSlider->addActionListener(this); - mGreenSlider->setEnabled(false); - - mBlueText->setWidth(40); - mBlueText->setRange(0, 255); - mBlueText->setNumeric(true); - mBlueText->setEnabled(false); - - mBlueSlider->setWidth(180); - mBlueSlider->setValue(mBlueText->getValue()); - mBlueSlider->setActionEventId("slider_blue"); - mBlueSlider->addActionListener(this); - mBlueSlider->setEnabled(false); - - setOpaque(Opaque_false); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mScroll, 6, 6).setPadding(2); - place(0, 6, mPreviewBox, 6).setPadding(2); - place(0, 7, mGradTypeLabel, 3); - place(3, 7, mGradTypeSlider); - place(4, 7, mGradTypeText, 2).setPadding(1); - place(0, 8, mRedLabel, 3); - place(3, 8, mRedSlider); - place(5, 8, mRedText).setPadding(1); - place(0, 9, mGreenLabel, 3); - place(3, 9, mGreenSlider); - place(5, 9, mGreenText).setPadding(1); - place(0, 10, mBlueLabel, 3); - place(3, 10, mBlueSlider); - place(5, 10, mBlueText).setPadding(1); - place(0, 11, mGradDelayLabel, 3); - place(3, 11, mGradDelaySlider); - place(5, 11, mGradDelayText).setPadding(1); - - mGradTypeText->setCaption(""); - - setDimension(Rect(0, 0, 365, 350)); -} - -Setup_Colors::~Setup_Colors() -{ - if ((mPreviewBox != nullptr) && mPreviewBox->getContent() == mPreview) - delete2(mTextPreview) - else - delete2(mPreview) -} - -void Setup_Colors::action(const ActionEvent &event) -{ - const std::string &eventId = event.getId(); - if (eventId == "slider_grad") - { - updateGradType(); - updateColor(); - return; - } - - if (eventId == "slider_graddelay") - { - mGradDelayText->setText(toString( - std::floor(mGradDelaySlider->getValue()))); - updateColor(); - return; - } - if (eventId == "slider_red") - { - mRedText->setText(toString(std::floor(mRedSlider->getValue()))); - updateColor(); - return; - } - if (eventId == "slider_green") - { - mGreenText->setText(toString(std::floor(mGreenSlider->getValue()))); - updateColor(); - return; - } - if (eventId == "slider_blue") - { - mBlueText->setText(toString(std::floor(mBlueSlider->getValue()))); - updateColor(); - return; - } -} - -void Setup_Colors::valueChanged(const SelectionEvent &event A_UNUSED) -{ - if (userPalette == nullptr) - return; - - mSelected = mColorBox->getSelected(); - const UserColorIdT type = static_cast<UserColorIdT>( - userPalette->getColorTypeAt(mSelected)); - const Color *col = &userPalette->getColor(type); - const GradientTypeT grad = userPalette->getGradientType(type); - const int delay = userPalette->getGradientDelay(type); - const Visible showControls = fromBool(grad != GradientType::LABEL, - Visible); - mPreview->setVisible(showControls); - mPreviewBox->setVisible(showControls); - mTextPreview->setVisible(showControls); - mGradTypeLabel->setVisible(showControls); - mGradTypeSlider->setVisible(showControls); - mGradTypeText->setVisible(showControls); - mGradDelayLabel->setVisible(showControls); - mGradDelaySlider->setVisible(showControls); - mGradDelayText->setVisible(showControls); - mRedLabel->setVisible(showControls); - mRedSlider->setVisible(showControls); - mRedText->setVisible(showControls); - mGreenLabel->setVisible(showControls); - mGreenSlider->setVisible(showControls); - mGreenText->setVisible(showControls); - mBlueLabel->setVisible(showControls); - mBlueSlider->setVisible(showControls); - mBlueText->setVisible(showControls); - - mPreview->clearRows(); - mPreviewBox->setContent(mTextPreview); - mTextPreview->setFont(boldFont); - mTextPreview->setTextColor(col); - mTextPreview->setTextBGColor(nullptr); - mTextPreview->setOpaque(Opaque_false); - mTextPreview->setShadow(true); - mTextPreview->setOutline(true); - mTextPreview->useTextAlpha(false); - -// probably need combite both switches and add all mssing color ids. - - PRAGMA45(GCC diagnostic push) - PRAGMA45(GCC diagnostic ignored "-Wswitch-enum") - switch (type) - { - case UserColorId::AIR_COLLISION_HIGHLIGHT: - case UserColorId::WATER_COLLISION_HIGHLIGHT: - case UserColorId::MONSTER_COLLISION_HIGHLIGHT: - case UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT: - case UserColorId::COLLISION_HIGHLIGHT: - case UserColorId::PORTAL_HIGHLIGHT: - case UserColorId::HOME_PLACE: - case UserColorId::ROAD_POINT: - case UserColorId::NET: - mTextPreview->setBGColor(col); - mTextPreview->setOpaque(Opaque_true); - mTextPreview->setOutline(false); - mTextPreview->setShadow(false); - break; - case UserColorId::ATTACK_RANGE_BORDER: - case UserColorId::HOME_PLACE_BORDER: - if (gui != nullptr) - mTextPreview->setFont(gui->getFont()); - mTextPreview->setTextColor(col); - mTextPreview->setOutline(false); - mTextPreview->setShadow(false); - break; - case UserColorId::PARTICLE: - case UserColorId::EXP_INFO: - case UserColorId::PICKUP_INFO: - case UserColorId::HIT_PLAYER_MONSTER: - case UserColorId::HIT_MONSTER_PLAYER: - case UserColorId::HIT_CRITICAL: - case UserColorId::MISS: - case UserColorId::HIT_LOCAL_PLAYER_MONSTER: - case UserColorId::HIT_LOCAL_PLAYER_CRITICAL: - case UserColorId::HIT_LOCAL_PLAYER_MISS: - case UserColorId::ATTACK_RANGE: - case UserColorId::MONSTER_ATTACK_RANGE: - case UserColorId::FLOOR_ITEM_TEXT: - case UserColorId::SKILL_ATTACK_RANGE: - mTextPreview->setShadow(false); - break; - default: - break; - } - - switch (type) - { - case UserColorId::PORTAL_HIGHLIGHT: - case UserColorId::ATTACK_RANGE: - case UserColorId::ATTACK_RANGE_BORDER: - case UserColorId::MONSTER_ATTACK_RANGE: - case UserColorId::SKILL_ATTACK_RANGE: - case UserColorId::HOME_PLACE: - case UserColorId::HOME_PLACE_BORDER: - case UserColorId::AIR_COLLISION_HIGHLIGHT: - case UserColorId::WATER_COLLISION_HIGHLIGHT: - case UserColorId::MONSTER_COLLISION_HIGHLIGHT: - case UserColorId::GROUNDTOP_COLLISION_HIGHLIGHT: - case UserColorId::COLLISION_HIGHLIGHT: - case UserColorId::WALKABLE_HIGHLIGHT: - case UserColorId::ROAD_POINT: - case UserColorId::MONSTER_HP: - case UserColorId::MONSTER_HP2: - case UserColorId::HOMUN_HP: - case UserColorId::HOMUN_HP2: - case UserColorId::MERC_HP: - case UserColorId::MERC_HP2: - case UserColorId::ELEMENTAL_HP: - case UserColorId::ELEMENTAL_HP2: - case UserColorId::PLAYER_HP: - case UserColorId::PLAYER_HP2: - case UserColorId::FLOOR_ITEM_TEXT: - case UserColorId::NET: - // TRANSLATORS: colors tab. label. - mGradDelayLabel->setCaption(_("Alpha:")); - mGradDelayText->setRange(0, 255); - mGradDelaySlider->setScale(0, 255); - break; - default: - // TRANSLATORS: colors tab. label. - mGradDelayLabel->setCaption(_("Delay:")); - mGradDelayText->setRange(20, 100); - mGradDelaySlider->setScale(20, 100); - break; - } - PRAGMA45(GCC diagnostic pop) - if (grad != GradientType::STATIC && grad != GradientType::PULSE) - { // If nonstatic color, don't display the current, but the committed - // color at the sliders - col = &userPalette->getCommittedColor(type); - } - else if (grad == GradientType::PULSE) - { - col = &userPalette->getTestColor(type); - } - - setEntry(mGradDelaySlider, mGradDelayText, delay); - setEntry(mRedSlider, mRedText, col->r); - setEntry(mGreenSlider, mGreenText, col->g); - setEntry(mBlueSlider, mBlueText, col->b); - - mGradTypeSlider->setValue(CAST_S32(grad)); - updateGradType(); - mGradTypeSlider->setEnabled(true); -} - -void Setup_Colors::setEntry(Slider *const s, TextField *const t, - const int value) -{ - if (s != nullptr) - s->setValue(value); - if (t != nullptr) - t->setText(toString(value)); -} - -void Setup_Colors::apply() -{ - if (userPalette != nullptr) - userPalette->commit(); -} - -void Setup_Colors::cancel() -{ - if (userPalette == nullptr) - return; - - userPalette->rollback(); - const UserColorIdT type = static_cast<UserColorIdT>( - userPalette->getColorTypeAt(mSelected)); - const Color *const col = &userPalette->getColor(type); - mGradTypeSlider->setValue(CAST_S32( - userPalette->getGradientType(type))); - const int delay = userPalette->getGradientDelay(type); - setEntry(mGradDelaySlider, mGradDelayText, delay); - setEntry(mRedSlider, mRedText, col->r); - setEntry(mGreenSlider, mGreenText, col->g); - setEntry(mBlueSlider, mBlueText, col->b); -} - -void Setup_Colors::updateGradType() -{ - if (mSelected == -1 || (userPalette == nullptr)) - return; - - mSelected = mColorBox->getSelected(); - const UserColorIdT type = static_cast<UserColorIdT>( - userPalette->getColorTypeAt(mSelected)); - const GradientTypeT grad = userPalette->getGradientType(type); - - mGradTypeText->setCaption( - // TRANSLATORS: color type - (grad == GradientType::STATIC) ? _("Static") : - // TRANSLATORS: color type - (grad == GradientType::PULSE) ? _("Pulse") : - // TRANSLATORS: color type - (grad == GradientType::RAINBOW) ? _("Rainbow") : _("Spectrum")); - - const bool enable = (grad == GradientType::STATIC || - grad == GradientType::PULSE); - const bool delayEnable = true; - - mGradDelayText->setEnabled(delayEnable); - mGradDelaySlider->setEnabled(delayEnable); - - mRedText->setEnabled(enable); - mRedSlider->setEnabled(enable); - mGreenText->setEnabled(enable); - mGreenSlider->setEnabled(enable); - mBlueText->setEnabled(enable); - mBlueSlider->setEnabled(enable); -} - -void Setup_Colors::updateColor() const -{ - if (mSelected == -1 || (userPalette == nullptr)) - return; - - const UserColorIdT type = static_cast<UserColorIdT>( - userPalette->getColorTypeAt(mSelected)); - const GradientTypeT grad = static_cast<GradientTypeT>( - CAST_S32(mGradTypeSlider->getValue())); - const int delay = CAST_S32(mGradDelaySlider->getValue()); - userPalette->setGradient(type, grad); - userPalette->setGradientDelay(type, delay); - - if (grad == GradientType::STATIC) - { - userPalette->setColor(type, - CAST_S32(mRedSlider->getValue()), - CAST_S32(mGreenSlider->getValue()), - CAST_S32(mBlueSlider->getValue())); - } - else if (grad == GradientType::PULSE) - { - userPalette->setTestColor(type, Color( - CAST_S32(mRedSlider->getValue()), - CAST_S32(mGreenSlider->getValue()), - CAST_S32(mBlueSlider->getValue()))); - } -} diff --git a/src/gui/widgets/tabs/setup_colors.h b/src/gui/widgets/tabs/setup_colors.h deleted file mode 100644 index 1ba74f340..000000000 --- a/src/gui/widgets/tabs/setup_colors.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * The ManaPlus Client - * Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net> - * 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_WIDGETS_TABS_SETUP_COLORS_H -#define GUI_WIDGETS_TABS_SETUP_COLORS_H - -#include "gui/widgets/tabs/setuptab.h" - -#include "listeners/selectionlistener.h" - -class BrowserBox; -class Label; -class ListBox; -class ScrollArea; -class Slider; -class TextField; -class TextPreview; - -class Setup_Colors final : public SetupTab, - public SelectionListener -{ - public: - explicit Setup_Colors(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Colors) - - ~Setup_Colors(); - - void apply() override final; - - void cancel() override final; - - void action(const ActionEvent &event) override final; - - void valueChanged(const SelectionEvent &event) override final; - - private: - static const char *const rawmsg; - - ListBox *mColorBox A_NONNULLPOINTER; - ScrollArea *mScroll A_NONNULLPOINTER; - BrowserBox *mPreview A_NONNULLPOINTER; - TextPreview *mTextPreview A_NONNULLPOINTER; - ScrollArea *mPreviewBox A_NONNULLPOINTER; - int mSelected; - - Label *mGradTypeLabel A_NONNULLPOINTER; - Slider *mGradTypeSlider A_NONNULLPOINTER; - Label *mGradTypeText A_NONNULLPOINTER; - - Label *mGradDelayLabel A_NONNULLPOINTER; - Slider *mGradDelaySlider A_NONNULLPOINTER; - TextField *mGradDelayText A_NONNULLPOINTER; - - Label *mRedLabel A_NONNULLPOINTER; - Slider *mRedSlider A_NONNULLPOINTER; - TextField *mRedText A_NONNULLPOINTER; - - Label *mGreenLabel A_NONNULLPOINTER; - Slider *mGreenSlider A_NONNULLPOINTER; - TextField *mGreenText A_NONNULLPOINTER; - - Label *mBlueLabel A_NONNULLPOINTER; - Slider *mBlueSlider A_NONNULLPOINTER; - TextField *mBlueText A_NONNULLPOINTER; - - static void setEntry(Slider *const s, TextField *const t, - const int value); - void updateColor() const; - void updateGradType(); -}; - -#endif // GUI_WIDGETS_TABS_SETUP_COLORS_H diff --git a/src/gui/widgets/tabs/setup_input.cpp b/src/gui/widgets/tabs/setup_input.cpp deleted file mode 100644 index dc1e531f8..000000000 --- a/src/gui/widgets/tabs/setup_input.cpp +++ /dev/null @@ -1,399 +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/>. - */ - -#include "gui/widgets/tabs/setup_input.h" - -#include "configuration.h" - -#include "const/gui/pages.h" - -#include "input/inputactionoperators.h" -#include "input/inputmanager.h" -#include "input/keyboardconfig.h" - -#include "input/pages/craft.h" -#include "input/pages/emotes.h" -#include "input/pages/move.h" -#include "input/pages/outfits.h" -#include "input/pages/shortcuts.h" - -#include "gui/gui.h" -#include "gui/setupinputpages.h" - -#include "gui/windows/okdialog.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/listbox.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/tabstrip.h" - -#include "gui/models/keylistmodel.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "debug.h" - -Setup_Input::Setup_Input(const Widget2 *const widget) : - SetupTab(widget), - mKeyListModel(new KeyListModel), - mKeyList(CREATEWIDGETR(ListBox, this, mKeyListModel, "")), - // TRANSLATORS: button in input settings tab - mAssignKeyButton(new Button(this, _("Assign"), "assign", this)), - // TRANSLATORS: button in input settings tab - mUnassignKeyButton(new Button(this, _("Unassign"), "unassign", this)), - // TRANSLATORS: button in input settings tab - mDefaultButton(new Button(this, _("Default"), "default", this)), - // TRANSLATORS: button in input settings tab - mResetKeysButton(new Button(this, _("Reset all keys"), "resetkeys", this)), - mTabs(new TabStrip(this, config.getIntValue("fontSize") + 10)), - mScrollArea(new ScrollArea(this, mKeyList, - Opaque_true, "setup_input_background.xml")), - mKeySetting(false), - mActionDataSize(new int [SETUP_PAGES]) -{ - inputManager.setSetupInput(this); - // TRANSLATORS: setting tab name - setName(_("Input")); - - mKeyListModel->setSelectedData(0); - - for (int f = 0; f < SETUP_PAGES; f ++) - { - int cnt = 0; - while (!setupActionData[f][cnt].name.empty()) - cnt ++; - mActionDataSize[f] = cnt; - } - - mKeyListModel->setSize(mActionDataSize[0]); - refreshKeys(); - if (gui != nullptr) - mKeyList->setFont(gui->getHelpFont()); - mKeyList->addActionListener(this); - - mScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mAssignKeyButton->addActionListener(this); - mAssignKeyButton->setEnabled(false); - mUnassignKeyButton->addActionListener(this); - mUnassignKeyButton->setEnabled(false); - mResetKeysButton->addActionListener(this); - mDefaultButton->addActionListener(this); - - mTabs->addActionListener(this); - mTabs->setActionEventId("tabs_"); - int k = 0; - while (pages[k] != nullptr) - { - mTabs->addButton(gettext(pages[k]), pages[k], false); - k ++; - } - - fixTranslations(); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mTabs, 5); - place(0, 1, mScrollArea, 5, 5).setPadding(2); - place(0, 6, mResetKeysButton); - place(2, 6, mAssignKeyButton); - place(3, 6, mUnassignKeyButton); - place(4, 6, mDefaultButton); - - int width = 600; - if (config.getIntValue("screenwidth") >= 730) - width += 100; - - setDimension(Rect(0, 0, width, 350)); -} - -Setup_Input::~Setup_Input() -{ - delete2(mKeyList); - delete2(mKeyListModel); - delete2(mAssignKeyButton); - delete2(mUnassignKeyButton); - delete2(mResetKeysButton); - delete [] mActionDataSize; - mActionDataSize = nullptr; - delete2(mScrollArea); -} - -void Setup_Input::apply() -{ - keyUnresolved(); - InputActionT key1, key2; - - if (inputManager.hasConflicts(key1, key2)) - { - const std::string str1 = keyToString(key1); - const std::string str2 = keyToString(key2); - - CREATEWIDGET(OkDialog, - // TRANSLATORS: input settings error header - _("Key Conflict(s) Detected."), - // TRANSLATORS: input settings error - strprintf(_("Conflict \"%s\" and \"%s\" keys. " - "Resolve them, or gameplay may result in strange behaviour."), - gettext(str1.c_str()), gettext(str2.c_str())), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::ERROR, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } - keyboard.setEnabled(true); - inputManager.store(); -} - -void Setup_Input::cancel() -{ - keyUnresolved(); - inputManager.retrieve(); - keyboard.setEnabled(true); - refreshKeys(); -} - -void Setup_Input::action(const ActionEvent &event) -{ - const std::string &id = event.getId(); - const int selectedData = mKeyListModel->getSelectedData(); - - if (event.getSource() == mKeyList) - { - if (!mKeySetting) - { - const int i(mKeyList->getSelected()); - if (i >= 0 && i < mActionDataSize[selectedData]) - { - if (setupActionData[selectedData][i].actionId - == InputAction::NO_VALUE) - { - mAssignKeyButton->setEnabled(false); - mUnassignKeyButton->setEnabled(false); - } - else - { - mAssignKeyButton->setEnabled(true); - mUnassignKeyButton->setEnabled(true); - } - } - } - } - else if (id == "assign") - { - mKeySetting = true; - mAssignKeyButton->setEnabled(false); - keyboard.setEnabled(false); - const int i(mKeyList->getSelected()); - if (i >= 0 && i < mActionDataSize[selectedData]) - { - const SetupActionData &key = setupActionData[selectedData][i]; - const InputActionT ik = key.actionId; - inputManager.setNewKeyIndex(ik); - mKeyListModel->setElementAt(i, std::string( - gettext(key.name.c_str())).append(": ?")); - } - } - else if (id == "unassign") - { - const int i(mKeyList->getSelected()); - if (i >= 0 && i < mActionDataSize[selectedData]) - { - const SetupActionData &key = setupActionData[selectedData][i]; - const InputActionT ik = key.actionId; - inputManager.setNewKeyIndex(ik); - refreshAssignedKey(mKeyList->getSelected()); - inputManager.unassignKey(); - inputManager.setNewKeyIndex(InputAction::NO_VALUE); - } - mAssignKeyButton->setEnabled(true); - } - else if (id == "resetkeys") - { - inputManager.resetKeys(); - InputManager::update(); - refreshKeys(); - } - else if (id == "default") - { - const int i(mKeyList->getSelected()); - if (i >= 0 && i < mActionDataSize[selectedData]) - { - const SetupActionData &key = setupActionData[selectedData][i]; - const InputActionT ik = key.actionId; - inputManager.makeDefault(ik); - refreshKeys(); - } - } - else if (strStartWith(id, "tabs_")) - { - int k = 0; - std::string str("tabs_"); - while (pages[k] != nullptr) - { - if (str + pages[k] == id) - break; - k ++; - } - if ((pages[k] != nullptr) && str + pages[k] == id) - { - mKeyListModel->setSelectedData(k); - mKeyListModel->setSize(mActionDataSize[k]); - refreshKeys(); - mKeyList->setSelected(0); - } - } -} - -void Setup_Input::refreshAssignedKey(const int index) -{ - const int selectedData = mKeyListModel->getSelectedData(); - const SetupActionData &key = setupActionData[selectedData][index]; - if (key.actionId == InputAction::NO_VALUE) - { - const std::string str(" \342\200\225\342\200\225\342\200\225" - "\342\200\225\342\200\225 "); - mKeyListModel->setElementAt(index, - str + gettext(key.name.c_str()) + str); - } - else - { - std::string str = gettext(key.name.c_str()); - unsigned int sz = 20; - if (mainGraphics->mWidth > 800) - sz = 30; - while (str.size() < sz) - str.append(" "); - mKeyListModel->setElementAt(index, strprintf("%s: %s", str.c_str(), - inputManager.getKeyStringLong(key.actionId).c_str())); - } -} - -void Setup_Input::newKeyCallback(const InputActionT index) -{ - mKeySetting = false; - const int i = keyToSetupData(index); - if (i >= 0) - refreshAssignedKey(i); - mAssignKeyButton->setEnabled(true); -} - -int Setup_Input::keyToSetupData(const InputActionT index) const -{ - const int selectedData = mKeyListModel->getSelectedData(); - for (int i = 0; i < mActionDataSize[selectedData]; i++) - { - const SetupActionData &key = setupActionData[selectedData][i]; - if (key.actionId == index) - return i; - } - return -1; -} - -std::string Setup_Input::keyToString(const InputActionT index) const -{ - for (int f = 0; f < SETUP_PAGES; f ++) - { - for (int i = 0; i < mActionDataSize[f]; i++) - { - const SetupActionData &key = setupActionData[f][i]; - if (key.actionId == index) - return key.name; - } - } - // TRANSLATORS: unknown key name - return _("unknown"); -} - -void Setup_Input::refreshKeys() -{ - const int selectedData = mKeyListModel->getSelectedData(); - for (int i = 0; i < mActionDataSize[selectedData]; i++) - refreshAssignedKey(i); -} - -void Setup_Input::keyUnresolved() -{ - if (mKeySetting) - { - newKeyCallback(inputManager.getNewKeyIndex()); - inputManager.setNewKeyIndex(InputAction::NO_VALUE); - } -} - -void Setup_Input::fixTranslation(SetupActionData *const actionDatas, - const InputActionT actionStart, - const InputActionT actionEnd, - const std::string &text) -{ - int k = 0; - - while (!actionDatas[k].name.empty()) - { - SetupActionData &data = actionDatas[k]; - - const InputActionT actionId = data.actionId; - if (actionId >= actionStart && actionId <= actionEnd) - { - data.name = strprintf(gettext(text.c_str()), - actionId - actionStart + 1); - } - k ++; - } -} - -void Setup_Input::fixTranslations() -{ - fixTranslation(setupActionDataShortcuts, - InputAction::SHORTCUT_1, - InputAction::SHORTCUT_20, - "Item Shortcut %d"); - - fixTranslation(setupActionDataEmotes, - InputAction::EMOTE_1, - InputAction::EMOTE_48, - "Emote Shortcut %d"); - - fixTranslation(setupActionDataCraft, - InputAction::CRAFT_1, - InputAction::CRAFT_9, - "Craft shortcut %d"); - - fixTranslation(setupActionDataOutfits, - InputAction::OUTFIT_1, - InputAction::OUTFIT_48, - "Outfit Shortcut %d"); - - fixTranslation(setupActionDataMove, - InputAction::MOVE_TO_POINT_1, - InputAction::MOVE_TO_POINT_48, - "Move to point Shortcut %d"); -} diff --git a/src/gui/widgets/tabs/setup_input.h b/src/gui/widgets/tabs/setup_input.h deleted file mode 100644 index 2da411b2c..000000000 --- a/src/gui/widgets/tabs/setup_input.h +++ /dev/null @@ -1,105 +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_WIDGETS_TABS_SETUP_INPUT_H -#define GUI_WIDGETS_TABS_SETUP_INPUT_H - -#include "enums/input/inputaction.h" - -#include "gui/widgets/tabs/setuptab.h" - -class Button; -class ListBox; -class KeyListModel; -class ScrollArea; -class TabStrip; - -struct SetupActionData; - -class Setup_Input final : public SetupTab -{ - public: - /** - * Constructor - */ - explicit Setup_Input(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Input) - - /** - * Destructor - */ - ~Setup_Input(); - - void apply() override final; - - void cancel() override final; - - void action(const ActionEvent &event) override final; - - /** - * Get an update on the assigned key. - */ - void refreshAssignedKey(const int index); - - /** - * The callback function when a new key has been pressed. - */ - void newKeyCallback(const InputActionT index); - - /** - * Shorthand method to update all the keys. - */ - void refreshKeys(); - - /** - * If a key function is unresolved, then this reverts it. - */ - void keyUnresolved(); - - int keyToSetupData(const InputActionT index) const A_WARN_UNUSED; - - std::string keyToString(const InputActionT index) const A_WARN_UNUSED; - - private: - static void fixTranslations(); - - static void fixTranslation(SetupActionData *const actionDatas, - const InputActionT actionStart, - const InputActionT actionEnd, - const std::string &text) A_NONNULL(1); - - KeyListModel *mKeyListModel; - ListBox *mKeyList; - - Button *mAssignKeyButton; - Button *mUnassignKeyButton; - Button *mDefaultButton; - Button *mResetKeysButton; - TabStrip *mTabs; - ScrollArea *mScrollArea; - bool mKeySetting; /**< flag to check if key being set. */ - int *mActionDataSize; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_INPUT_H diff --git a/src/gui/widgets/tabs/setup_joystick.cpp b/src/gui/widgets/tabs/setup_joystick.cpp deleted file mode 100644 index 84cd60521..000000000 --- a/src/gui/widgets/tabs/setup_joystick.cpp +++ /dev/null @@ -1,184 +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/widgets/tabs/setup_joystick.h" - -#include "configuration.h" - -#include "input/joystick.h" - -#include "gui/models/namesmodel.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/checkbox.h" -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/dropdown.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layouthelper.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "debug.h" - -Setup_Joystick::Setup_Joystick(const Widget2 *const widget) : - SetupTab(widget), - mCalibrateLabel(new Label(this, - // TRANSLATORS: joystick settings tab label - _("Press the button to start calibration"))), - // TRANSLATORS: joystick settings tab button - mCalibrateButton(new Button(this, _("Calibrate"), "calibrate", this)), - // TRANSLATORS: joystick settings tab button - mDetectButton(new Button(this, _("Detect joysticks"), "detect", this)), - // TRANSLATORS: joystick settings tab checkbox - mJoystickEnabled(new CheckBox(this, _("Enable joystick"))), - mNamesModel(new NamesModel), - mNamesDropDown(new DropDown(this, mNamesModel)), - // TRANSLATORS: joystick settings tab checkbox - mUseInactiveCheckBox(new CheckBox(this, _("Use joystick if client " - "window inactive"), config.getBoolValue("useInactiveJoystick"))), - mOriginalJoystickEnabled(config.getBoolValue("joystickEnabled")) -{ - // TRANSLATORS: joystick settings tab name - setName(_("Joystick")); - - Joystick::getNames(mNamesModel->getNames()); - - mJoystickEnabled->setSelected(mOriginalJoystickEnabled); - mJoystickEnabled->setActionEventId("joystick"); - mJoystickEnabled->addActionListener(this); - mCalibrateButton->setEnabled(mOriginalJoystickEnabled); - - mNamesDropDown->setActionEventId("name"); - mNamesDropDown->addActionListener(this); - - if (joystick != nullptr) - { - mNamesDropDown->setSelected(joystick->getNumber()); - } - else - { - unsigned int sel = config.getIntValue("selectedJoystick"); - if (sel >= CAST_U32(mNamesModel->size())) - sel = 0; - mNamesDropDown->setSelected(sel); - } - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mJoystickEnabled); - place(0, 1, mNamesDropDown); - place(0, 2, mUseInactiveCheckBox); - place(0, 3, mDetectButton); - place(0, 4, mCalibrateLabel); - place(0, 5, mCalibrateButton); - - setDimension(Rect(0, 0, 365, 75)); -} - -Setup_Joystick::~Setup_Joystick() -{ - delete2(mNamesModel); -} - -void Setup_Joystick::action(const ActionEvent &event) -{ - const Widget *const source = event.getSource(); - if (source == mJoystickEnabled) - { - setTempEnabled(mJoystickEnabled->isSelected()); - } - else if (source == mNamesDropDown) - { - if (joystick != nullptr) - joystick->setNumber(mNamesDropDown->getSelected()); - } - else if (source == mDetectButton) - { - if (joystick != nullptr) - { - joystick->reload(); - Joystick::getNames(mNamesModel->getNames()); - mNamesDropDown->setSelected(joystick->getNumber()); - } - } - else - { - if (joystick == nullptr) - return; - - if (joystick->isCalibrating()) - { - // TRANSLATORS: joystick settings tab button - mCalibrateButton->setCaption(_("Calibrate")); - mCalibrateLabel->setCaption - // TRANSLATORS: joystick settings tab label - (_("Press the button to start calibration")); - joystick->finishCalibration(); - } - else - { - // TRANSLATORS: joystick settings tab button - mCalibrateButton->setCaption(_("Stop")); - mCalibrateLabel->setCaption( - // TRANSLATORS: joystick settings tab label - _("Rotate the stick and don't press buttons")); - joystick->startCalibration(); - } - } -} - -void Setup_Joystick::setTempEnabled(const bool sel) -{ - Joystick::setEnabled(sel); - mCalibrateButton->setEnabled(sel); - if (joystick != nullptr) - { - if (sel) - joystick->open(); - else - joystick->close(); - } -} - -void Setup_Joystick::cancel() -{ - Joystick::setEnabled(mOriginalJoystickEnabled); - - if (mOriginalJoystickEnabled != mJoystickEnabled->isSelected()) - setTempEnabled(mOriginalJoystickEnabled); - - mJoystickEnabled->setSelected(mOriginalJoystickEnabled); -} - -void Setup_Joystick::apply() -{ - if (joystick == nullptr) - return; - - config.setValue("joystickEnabled", Joystick::isEnabled()); - - config.setValue("useInactiveJoystick", mUseInactiveCheckBox->isSelected()); - joystick->setUseInactive(mUseInactiveCheckBox->isSelected()); -} diff --git a/src/gui/widgets/tabs/setup_joystick.h b/src/gui/widgets/tabs/setup_joystick.h deleted file mode 100644 index c66ab8687..000000000 --- a/src/gui/widgets/tabs/setup_joystick.h +++ /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/>. - */ - -#ifndef GUI_WIDGETS_TABS_SETUP_JOYSTICK_H -#define GUI_WIDGETS_TABS_SETUP_JOYSTICK_H - -#include "gui/widgets/tabs/setuptab.h" - -class Button; -class CheckBox; -class DropDown; -class Label; -class NamesModel; - -class Setup_Joystick final : public SetupTab -{ - public: - explicit Setup_Joystick(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Joystick) - - ~Setup_Joystick(); - - void apply() override final; - - void cancel() override final; - - void action(const ActionEvent &event) override final; - - void setTempEnabled(const bool sel); - - private: - Label *mCalibrateLabel A_NONNULLPOINTER; - Button *mCalibrateButton A_NONNULLPOINTER; - Button *mDetectButton A_NONNULLPOINTER; - CheckBox *mJoystickEnabled A_NONNULLPOINTER; - NamesModel *mNamesModel A_NONNULLPOINTER; - DropDown *mNamesDropDown A_NONNULLPOINTER; - CheckBox *mUseInactiveCheckBox A_NONNULLPOINTER; - bool mOriginalJoystickEnabled A_NONNULLPOINTER; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_JOYSTICK_H diff --git a/src/gui/widgets/tabs/setup_misc.cpp b/src/gui/widgets/tabs/setup_misc.cpp deleted file mode 100644 index 07b4c5193..000000000 --- a/src/gui/widgets/tabs/setup_misc.cpp +++ /dev/null @@ -1,518 +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/>. - */ - -#include "gui/widgets/tabs/setup_misc.h" - -#include "configuration.h" - -#include "const/resources/map/map.h" - -#include "gui/models/namesmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/setupbuttonitem.h" -#include "gui/widgets/scrollarea.h" - -#include "listeners/uploadlistener.h" - -#include "net/net.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "debug.h" - -static const int shortcutsListSize = 3; - -static const char *const shortcutsList[] = -{ - // TRANSLATORS: show buttons at top right corner type - N_("Always show"), - // TRANSLATORS: show buttons at top right corner type - N_("Auto hide in small resolution"), - // TRANSLATORS: show buttons at top right corner type - N_("Always auto hide") -}; - -static const int proxyTypeListSize = 8; - -static const char *const proxyTypeList[] = -{ - // TRANSLATORS: Proxy type selection - N_("System proxy"), - // TRANSLATORS: Proxy type selection - N_("Direct connection"), - "HTTP", - "HTTP 1.0", - "SOCKS4", - "SOCKS4A", - "SOCKS5", - // TRANSLATORS: Proxy type selection - N_("SOCKS5 hostname") -}; - -static const int densityListSize = 7; - -static const char *const densityList[] = -{ - // TRANSLATORS: screen density type - N_("default"), - // TRANSLATORS: screen density type - N_("low"), - // TRANSLATORS: screen density type - N_("medium"), - // TRANSLATORS: screen density type - N_("tv"), - // TRANSLATORS: screen density type - N_("high"), - // TRANSLATORS: screen density type - N_("xhigh"), - // TRANSLATORS: screen density type - N_("xxhigh") -}; - -#ifdef USE_SDL2 -static const int sdlLogListSize = 7; - -static const char *const sdlLogList[] = -{ - // TRANSLATORS: sdl2 log level - N_("default"), - // TRANSLATORS: sdl2 log level - N_("verbose"), - // TRANSLATORS: sdl2 log level - N_("debug"), - // TRANSLATORS: sdl2 log level - N_("info"), - // TRANSLATORS: sdl2 log level - N_("warn"), - // TRANSLATORS: sdl2 log level - N_("error"), - // TRANSLATORS: sdl2 log level - N_("critical") -}; -#endif // USE_SDL2 - -Setup_Misc::Setup_Misc(const Widget2 *const widget) : - SetupTabScroll(widget), - mProxyTypeList(new NamesModel), - mShortcutsList(new NamesModel), -#ifdef USE_SDL2 - mSdlLogList(new NamesModel), -#endif // USE_SDL2 - mDensityList(new NamesModel) -{ - // TRANSLATORS: misc tab in settings - setName(_("Misc")); - - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - // TRANSLATORS: settings option - new SetupItemLabel(_("Monsters"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show damage inflicted to monsters"), "", - "showMonstersTakedDamage", this, "showMonstersTakedDamageEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Auto target only reachable monsters"), "", - "targetOnlyReachable", this, "targetOnlyReachableEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Select auto target for attack skills"), "", - "skillAutotarget", this, "skillAutotargetEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Highlight monster attack range"), "", - "highlightMonsterAttackRange", this, - "highlightMonsterAttackRangeEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show monster hp bar"), "", - "showMobHP", this, "showMobHPEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Cycle monster targets"), "", - "cycleMonsters", this, "cycleMonstersEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Map"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show warps particles"), "", - "warpParticle", this, "warpParticleEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Highlight map portals"), "", - "highlightMapPortals", this, "highlightMapPortalsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Highlight floor items"), "", - "floorItemsHighlight", this, "floorItemsHighlightEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Highlight player attack range"), "", - "highlightAttackRange", this, "highlightAttackRangeEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show extended minimaps"), "", - "showExtMinimaps", this, "showExtMinimapsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Draw path"), "", "drawPath", - this, "drawPathEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Draw hotkeys on map"), "", "drawHotKeys", - this, "drawHotKeysEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable lazy scrolling"), "", - "enableLazyScrolling", this, "enableLazyScrollingEvent"); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Scroll laziness"), "", "ScrollLaziness", - this, "ScrollLazinessEvent", 1, 160); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Scroll radius"), "", "ScrollRadius", - this, "ScrollRadiusEvent", 0, mapTileSize); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Auto resize minimaps"), "", "autoresizeminimaps", - this, "autoresizeminimapsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Play map animations"), "", "playMapAnimations", - this, "playMapAnimationsEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Moving"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Auto fix position"), "", - "autofixPos", this, "autofixPosEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show server side position"), "", - "showserverpos", this, "showserverposEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Attack while moving"), "", - "attackMoving", this, "attackMovingEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Attack next target"), "", - "attackNext", this, "attackNextEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Sync player move"), "", "syncPlayerMove", - this, "syncPlayerMoveEvent"); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Sync player move distance"), "", - "syncPlayerMoveDistance", - this, "syncPlayerMoveDistanceEvent", 1, 30); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Crazy move A program"), "", - "crazyMoveProgram", this, "crazyMoveProgramEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Mouse relative moves " - "(good for touch interfaces)"), "", "mouseDirectionMove", - this, "mouseDirectionMoveEvent"); - - // TRANSLATORS: settings group - new SetupItemLabel(_("Player"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show own hp bar"), "", - "showOwnHP", this, "showOwnHPEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable quick stats"), "", - "quickStats", this, "quickStatsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Cycle player targets"), "", - "cyclePlayers", this, "cyclePlayersEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show job exp messages"), "", - "showJobExp", this, "showJobExpEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show players popups"), "", - "showBeingPopup", this, "showBeingPopupEvent"); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Afk message"), "", - "afkMessage", this, "afkMessageEvent", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show job"), "", "showJob", - this, "showJobEvent", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable attack filter"), "", - "enableAttackFilter", this, "enableAttackFilterEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable pickup filter"), "", - "enablePickupFilter", this, "enablePickupFilterEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable advert protocol"), "", - "enableAdvert", this, "enableAdvertEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enabled pets support"), - "", "usepets", this, "usepetsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable weight notifications"), "", - "weightMsg", this, "weightMsgEvent"); - - // TRANSLATORS: settings group - new SetupItemLabel(_("Shop"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Accept sell/buy requests"), "", - "autoShop", this, "autoShopEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable shop mode"), "", - "tradebot", this, "tradebotEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("NPC"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Cycle npc targets"), "", - "cycleNPC", this, "cycleNPCEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Log NPC dialogue"), "", "logNpcInGui", - this, "logNpcInGuiEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Bots support"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable guild bot support and disable native " - "guild support"), "", "enableGuildBot", this, - "enableGuildBotEvent", - "0", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable manamarket bot support"), - "", "enableManaMarketBot", this, - "enableManaMarketBotEvent", - "0", - MainConfig_false); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Keyboard"), "", this); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Repeat delay"), "", - "repeateDelay", this, "repeateDelayEvent", 0, 10000); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Repeat interval"), "", - "repeateInterval", this, "repeateIntervalEvent", 0, 10000); - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Custom repeat interval"), "", - "repeateInterval2", this, "repeateInterval2Event", 0, 10000); - -#ifdef USE_SDL2 - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable alt-tab workaround"), "", - "blockAltTab", this, "blockAltTabEvent"); -#endif // USE_SDL2 - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Windows"), "", this); - - mShortcutsList->fillFromArray(&shortcutsList[0], shortcutsListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Shortcut buttons"), "", "autohideButtons", this, - "autohideButtonsEvent", mShortcutsList, 200); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Proxy server"), "", this); - - mProxyTypeList->fillFromArray(&proxyTypeList[0], proxyTypeListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Proxy type"), "", "downloadProxyType", this, - "downloadProxyTypeEvent", mProxyTypeList, 200); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Proxy address:port"), "", - "downloadProxy", this, "downloadProxyEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Tunnel through HTTP proxy"), "", - "downloadProxyTunnel", this, "downloadProxyTunnelEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Logging"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable OpenGL version check " - "(do not disable)"), "", "checkOpenGLVersion", this, - "checkOpenGLVersionEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable debug log"), "", - "debugLog", this, "debugLogEvent"); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Ignore logging packets"), "", - "ignorelogpackets", this, "ignorelogpacketsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Log unimplemented packets"), "", - "unimplimentedLog", this, "unimplimentedLogEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable OpenGL log"), "", - "debugOpenGL", this, "debugOpenGLEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable input log"), "", - "logInput", this, "logInputEvent"); - -#ifdef USE_SDL2 - mSdlLogList->fillFromArray(&sdlLogList[0], sdlLogListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("SDL logging level"), "", - "sdlLogLevel", this, "sdlLogLevelEvent", mSdlLogList, 100); -#endif // USE_SDL2 - - // TRANSLATORS: settings option - new SetupButtonItem(_("Upload log file"), "", "upload", - this, "uploadLog", &uploadListener); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Other"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable server side attack"), "", - "serverAttack", this, "serverAttackEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Hide support page link on error"), "", - "hidesupport", this, "hidesupportEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable double clicks"), "", - "doubleClick", this, "doubleClickEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable bot checker"), "", - "enableBotCheker", this, "enableBotChekerEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable buggy servers protection " - "(do not disable)"), "", "enableBuggyServers", this, - "enableBuggyServersEvent", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Low traffic mode"), "", "lowTraffic", - this, "lowTrafficEvent"); - -#ifndef ANDROID - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Use FBO for screenshots (only for opengl)"), - "", "usefbo", this, "usefboEvent"); -#endif // ANDROID - -#ifndef WIN32 - // TRANSLATORS: settings option - new SetupItemTextField(_("Screenshot directory"), "", - "screenshotDirectory3", this, "screenshotDirectory3Event", - MainConfig_true, - UseBase64_true); -#endif // WIN32 - - // TRANSLATORS: settings option - new SetupItemIntTextField(_("Network delay between sub servers"), - "", "networksleep", this, "networksleepEvent", 0, 10000); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show background"), "", "showBackground", - this, "showBackgroundEvent"); - - mDensityList->fillFromArray(&densityList[0], densityListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Screen density override"), "", - "screenDensity", this, "screenDensityEvent", mDensityList, 100); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Misc::~Setup_Misc() -{ - delete2(mProxyTypeList); - delete2(mShortcutsList); - delete2(mDensityList); -#ifdef USE_SDL2 - delete2(mSdlLogList); -#endif // USE_SDL2 -} - -void Setup_Misc::apply() -{ - SetupTabScroll::apply(); - - logger->setDebugLog(config.getBoolValue("debugLog")); - logger->setReportUnimplemented(config.getBoolValue("unimplimentedLog")); - Net::loadIgnorePackets(); -} - -void Setup_Misc::externalUpdated() -{ - reread("showJob"); - reread("enableGuildBot"); - reread("enableManaMarketBot"); - reread("enableBuggyServers"); - reread("afkMessage"); -} diff --git a/src/gui/widgets/tabs/setup_misc.h b/src/gui/widgets/tabs/setup_misc.h deleted file mode 100644 index 787f4c181..000000000 --- a/src/gui/widgets/tabs/setup_misc.h +++ /dev/null @@ -1,52 +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_WIDGETS_TABS_SETUP_MISC_H -#define GUI_WIDGETS_TABS_SETUP_MISC_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class NamesModel; - -class Setup_Misc final : public SetupTabScroll -{ - public: - explicit Setup_Misc(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Misc) - - ~Setup_Misc(); - - void apply() override final; - - void externalUpdated() override final; - - protected: - NamesModel *mProxyTypeList; - NamesModel *mShortcutsList; -#ifdef USE_SDL2 - NamesModel *mSdlLogList; -#endif // USE_SDL2 - NamesModel *mDensityList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_MISC_H diff --git a/src/gui/widgets/tabs/setup_mods.cpp b/src/gui/widgets/tabs/setup_mods.cpp deleted file mode 100644 index c3ca23245..000000000 --- a/src/gui/widgets/tabs/setup_mods.cpp +++ /dev/null @@ -1,129 +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/>. - */ - -#include "gui/widgets/tabs/setup_mods.h" - -#include "configuration.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/setupitem.h" -#include "gui/widgets/scrollarea.h" - -#include "resources/db/moddb.h" - -#include "utils/foreach.h" -#include "utils/gettext.h" - -#include "debug.h" - -Setup_Mods::Setup_Mods(const Widget2 *const widget) : - SetupTabScroll(widget) -{ - // TRANSLATORS: mods tab in settings - setName(_("Mods")); - - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Mods::~Setup_Mods() -{ -} - -void Setup_Mods::apply() -{ - SetupTabScroll::apply(); - saveMods(); -} - -void Setup_Mods::externalUpdated() -{ - clear(); - loadMods(); -} - -void Setup_Mods::loadMods() -{ - std::string modsString = serverConfig.getValue("mods", ""); - std::set<std::string> modsList; - splitToStringSet(modsList, modsString, '|'); - - const ModInfos &mods = ModDB::getAll(); - if (mods.empty()) - { - // TRANSLATORS: settings label - new SetupItemLabel(_("No mods present"), "", this, - Separator_false); - return; - } - - FOR_EACH (ModInfoCIterator, it, mods) - { - const ModInfo *const info = (*it).second; - if (info == nullptr) - continue; - - std::string name = info->getName(); - replaceAll(name, "|", ""); - SetupItem *const item = new SetupItemCheckBox( - info->getDescription(), "", "", this, name); - if (modsList.find(name) != modsList.end()) - item->setValue("1"); - else - item->setValue("0"); - item->toWidget(); - } -} - -void Setup_Mods::saveMods() const -{ - const ModInfos &mods = ModDB::getAll(); - if (mods.empty()) - return; - - std::string modsString; - const std::set<SetupItem*> &modsList = getAllItems(); - FOR_EACH (std::set<SetupItem*>::const_iterator, it, modsList) - { - const SetupItem *const item = *it; - if (item == nullptr) - continue; - const std::string val = item->getValue(); - if (val == "1") - { - const std::string key = item->getEventName(); - if (!modsString.empty()) - modsString.append("|"); - modsString.append(key); - } - } - serverConfig.setValue("mods", modsString); -} - -void Setup_Mods::externalUnloaded() -{ - clear(); -} diff --git a/src/gui/widgets/tabs/setup_mods.h b/src/gui/widgets/tabs/setup_mods.h deleted file mode 100644 index 488915d31..000000000 --- a/src/gui/widgets/tabs/setup_mods.h +++ /dev/null @@ -1,50 +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_WIDGETS_TABS_SETUP_MODS_H -#define GUI_WIDGETS_TABS_SETUP_MODS_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class Setup_Mods final : public SetupTabScroll -{ - public: - explicit Setup_Mods(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Mods) - - ~Setup_Mods(); - - void apply() override final; - - void externalUpdated() override final; - - void externalUnloaded() override final; - - void loadMods(); - - void saveMods() const; - - protected: -}; - -#endif // GUI_WIDGETS_TABS_SETUP_MODS_H diff --git a/src/gui/widgets/tabs/setup_perfomance.cpp b/src/gui/widgets/tabs/setup_perfomance.cpp deleted file mode 100644 index e12bd2872..000000000 --- a/src/gui/widgets/tabs/setup_perfomance.cpp +++ /dev/null @@ -1,209 +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/>. - */ - -#include "gui/widgets/tabs/setup_perfomance.h" - -#include "gui/models/namesmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/setupitem.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" -#ifdef USE_SDL2 -#include "configuration.h" -#include "utils/sdlhelper.h" -#endif // USE_SDL2 - -#include "debug.h" - -static const int texturesListSize = 5; - -static const char *const texturesList[] = -{ - // TRANSLATORS: texture compression type - N_("No"), - "s3tc", - "fxt1", - "ARB", - "bptc" -}; - -Setup_Perfomance::Setup_Perfomance(const Widget2 *const widget) : - SetupTabScroll(widget), -#ifdef USE_SDL2 - mSdlDriversList(new NamesModel), -#endif // USE_SDL2 - mTexturesList(new NamesModel) -{ - // TRANSLATORS: settings tab name - setName(_("Performance")); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - -#ifdef USE_SDL2 - StringVect sdlDriversList; - SDL::getRenderers(sdlDriversList, - config.getStringValue("sdlDriver")); - sdlDriversList.insert(sdlDriversList.begin(), - // TRANSLATORS: sdl driver name - N_("default")); -#endif // USE_SDL2 - - // TRANSLATORS: settings option - new SetupItemLabel(_("Better performance (enable for better performance)"), - "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Auto adjust performance"), "", - "adjustPerfomance", this, "adjustPerfomanceEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Hw acceleration"), "", - "hwaccel", this, "hwaccelEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable opacity cache (Software, can " - "use much memory)"), "", "alphaCache", this, "alphaCacheEvent"); - -#ifndef USE_SDL2 - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable map reduce (Software)"), "", - "enableMapReduce", this, "enableMapReduceEvent"); -#endif // USE_SDL2 - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable compound sprite delay (Software)"), "", - "enableCompoundSpriteDelay", this, "enableCompoundSpriteDelayEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable delayed images load (OpenGL)"), "", - "enableDelayedAnimations", this, "enableDelayedAnimationsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable texture sampler (OpenGL)"), "", - "useTextureSampler", this, "useTextureSamplerEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable OpenGL context creation"), - "", "openglContext", this, "openglContextEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable OpenGL direct state access"), - "", "enableDSA", this, "enableDSAEvent"); - - - // TRANSLATORS: settings option - new SetupItemLabel(_("Better quality (disable for better performance)"), - "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable alpha channel fix (Software, can " - "be very slow)"), "Can slow down drawing", "enableAlphaFix", - this, "enableAlphaFixEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show beings transparency"), "", - "beingopacity", this, "beingopacityEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable reorder sprites (need for mods support)."), - "", "enableReorderSprites", this, "enableReorderSpritesEvent"); - - -#ifndef USE_SDL2 - // TRANSLATORS: settings option - new SetupItemLabel(_("Small memory (enable for lower memory usage)"), - "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Disable advanced beings caching (Software)"), "", - "disableAdvBeingCaching", this, "disableAdvBeingCachingEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Disable beings caching (Software)"), "", - "disableBeingCaching", this, "disableBeingCachingEvent"); -#endif // USE_SDL2 - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Different options (enable or disable can " - "improve performance)"), "", this); - -#ifdef USE_SDL2 - mSdlDriversList->fillFromVector(sdlDriversList); - new SetupItemDropDownStr( - // TRANSLATORS: settings option - _("Try first sdl driver (only for SDL2 default mode)"), - "", "sdlDriver", this, "sdlDriverEvent", mSdlDriversList, 100); -#endif // USE_SDL2 - - mTexturesList->fillFromArray(&texturesList[0], texturesListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Enable texture compression (OpenGL)"), "", - "compresstextures", this, "compresstexturesEvent", mTexturesList, 100); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable rectangular texture extension (OpenGL)"), - "", "rectangulartextures", this, "rectangulartexturesEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Use new texture internal format (OpenGL)"), - "", "newtextures", this, "newtexturesEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable texture atlases (OpenGL)"), "", - "useAtlases", this, "useAtlasesEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Cache all sprites per map (can use " - "additional memory)"), "", "uselonglivesprites", this, - "uselonglivespritesEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Cache all sounds (can use additional memory)"), - "", "uselonglivesounds", this, - "uselonglivesoundsEvent"); - - // TRANSLATORS: settings group - new SetupItemLabel(_("Critical options (DO NOT change if you don't " - "know what you're doing)"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Disable logging in game (do not enable)"), - "", "disableLoggingInGame", this, "disableLoggingInGameEvent"); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Perfomance::~Setup_Perfomance() -{ - delete2(mTexturesList); -#ifdef USE_SDL2 - delete2(mSdlDriversList); -#endif // USE_SDL2 -} diff --git a/src/gui/widgets/tabs/setup_perfomance.h b/src/gui/widgets/tabs/setup_perfomance.h deleted file mode 100644 index 95030a8e5..000000000 --- a/src/gui/widgets/tabs/setup_perfomance.h +++ /dev/null @@ -1,46 +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_WIDGETS_TABS_SETUP_PERFOMANCE_H -#define GUI_WIDGETS_TABS_SETUP_PERFOMANCE_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class NamesModel; - -class Setup_Perfomance final : public SetupTabScroll -{ - public: - explicit Setup_Perfomance(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Perfomance) - - ~Setup_Perfomance(); - - private: -#ifdef USE_SDL2 - NamesModel *mSdlDriversList; -#endif // USE_SDL2 - NamesModel *mTexturesList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_PERFOMANCE_H diff --git a/src/gui/widgets/tabs/setup_players.cpp b/src/gui/widgets/tabs/setup_players.cpp deleted file mode 100644 index 6d964799d..000000000 --- a/src/gui/widgets/tabs/setup_players.cpp +++ /dev/null @@ -1,211 +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/>. - */ - -#include "gui/widgets/tabs/setup_players.h" - -#include "configuration.h" -#include "settings.h" - -#include "gui/models/namesmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/setupitem.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "debug.h" - -static const int badgesListSize = 4; - -static const char *const badgesList[] = -{ - // TRANSLATORS: screen badges type - N_("hide"), - // TRANSLATORS: screen badges type - N_("show at top"), - // TRANSLATORS: screen badges type - N_("show at right"), - // TRANSLATORS: screen badges type - N_("show at bottom"), -}; - -static const int visibleNamesListSize = 3; - -static const char *const visibleNamesList[] = -{ - // TRANSLATORS: visible name type - N_("hide"), - // TRANSLATORS: visible name type - N_("show"), - // TRANSLATORS: visible name type - N_("show on selection") -}; - -static const int topDownListSize = 2; - -static const char *const topDownList[] = -{ - // TRANSLATORS: show on top or down - N_("top"), - // TRANSLATORS: show on top or down - N_("bottom") -}; - -Setup_Players::Setup_Players(const Widget2 *const widget) : - SetupTabScroll(widget), - mBadgesList(new NamesModel), - mVisibleNamesList(new NamesModel), - mVisibleNamesPosList(new NamesModel) -{ - // TRANSLATORS: settings tab name - setName(_("Players")); - - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show gender"), "", - "showgender", this, "showgenderEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show level"), "", - "showlevel", this, "showlevelEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show own name"), "", - "showownname", this, "showownnameEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable extended mouse targeting"), "", - "extMouseTargeting", this, "extMouseTargetingEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Target dead players"), "", - "targetDeadPlayers", this, "targetDeadPlayersEvent"); - - mVisibleNamesList->fillFromArray(&visibleNamesList[0], - visibleNamesListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Show player names"), "", - "visiblenames", this, "visiblenamesEvent", - mVisibleNamesList, 150); - - mVisibleNamesPosList->fillFromArray(&topDownList[0], - topDownListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Show player names at"), "", - "visiblenamespos", this, "visiblenamesposEvent", - mVisibleNamesPosList, 150); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Auto move names"), "", - "moveNames", this, "moveNamesEvent"); - - mBadgesList->fillFromArray(&badgesList[0], badgesListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Badges"), "", - "showBadges", this, "showBadgesEvent", mBadgesList, 150); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Secure trades"), "", - "securetrades", this, "securetradesEvent"); - - // TRANSLATORS: settings option - new SetupItemTextField(_("Unsecure chars in names"), "", - "unsecureChars", this, "unsecureCharsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show statuses"), "", - "showPlayersStatus", this, "showPlayersStatusEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show ip addresses on screenshots"), "", - "showip", this, "showipEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Allow self heal with mouse click"), "", - "selfMouseHeal", this, "selfMouseHealEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Group friends in who is online window"), "", - "groupFriends", this, "groupFriendsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Hide erased players nicks"), "", - "hideErased", this, "hideErasedEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Collect players id and seen log"), - "", "enableIdCollecting", this, "enableIdCollectingEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Use special diagonal speed in players moving"), - "", "useDiagonalSpeed", this, "useDiagonalSpeedEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Log players actions (for GM)"), - "", "logPlayerActions", this, "logPlayerActionsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Create screenshots for each complete trades"), - "", "tradescreenshot", this, "tradescreenshotEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Emulate right mouse button by long mouse click" - " (useful for touch interfaces)"), - "", "longmouseclick", this, "longmouseclickEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable remote commands"), - "", "enableRemoteCommands", this, "enableRemoteCommandsEvent", - "1", - MainConfig_false); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Allow move character by mouse"), - "", "allowMoveByMouse", this, "allowMoveByMouseEvent"); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Players::~Setup_Players() -{ - delete2(mBadgesList); - delete2(mVisibleNamesList); - delete2(mVisibleNamesPosList); -} - -void Setup_Players::externalUpdated() -{ - reread("enableRemoteCommands"); -} - -void Setup_Players::apply() -{ - SetupTabScroll::apply(); - settings.enableRemoteCommands = (serverConfig.getValue( - "enableRemoteCommands", 1) != 0); -} diff --git a/src/gui/widgets/tabs/setup_players.h b/src/gui/widgets/tabs/setup_players.h deleted file mode 100644 index d29d41781..000000000 --- a/src/gui/widgets/tabs/setup_players.h +++ /dev/null @@ -1,49 +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_WIDGETS_TABS_SETUP_PLAYERS_H -#define GUI_WIDGETS_TABS_SETUP_PLAYERS_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class NamesModel; - -class Setup_Players final : public SetupTabScroll -{ - public: - explicit Setup_Players(const Widget2 *const widget); - - ~Setup_Players(); - - A_DELETE_COPY(Setup_Players) - - void apply() override final; - - void externalUpdated() override final; - - private: - NamesModel *mBadgesList; - NamesModel *mVisibleNamesList; - NamesModel *mVisibleNamesPosList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_PLAYERS_H diff --git a/src/gui/widgets/tabs/setup_quick.cpp b/src/gui/widgets/tabs/setup_quick.cpp deleted file mode 100644 index f86707fe1..000000000 --- a/src/gui/widgets/tabs/setup_quick.cpp +++ /dev/null @@ -1,118 +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/>. - */ - -#include "gui/widgets/tabs/setup_quick.h" - -#include "gamemodifiers.h" - -#include "gui/models/namesmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/setupquickitem.h" -#include "gui/widgets/scrollarea.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "debug.h" - -Setup_Quick::Setup_Quick(const Widget2 *const widget) : - SetupTabScroll(widget), - mMoveTypeList(new NamesModel), - mCrazyMoveTypeList(new NamesModel) -{ - // TRANSLATORS: quick tab in settings - setName(_("Quick")); - - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - new SetupQuickItem("", this, "moveTypeEvent", - &GameModifiers::getMoveTypeString, - &GameModifiers::changeMoveType); - - new SetupQuickItem("", this, "crazyMoveTypeEvent", - &GameModifiers::getCrazyMoveTypeString, - &GameModifiers::changeCrazyMoveType); - - new SetupQuickItem("", this, "moveToTargetTypeEvent", - &GameModifiers::getMoveToTargetTypeString, - &GameModifiers::changeMoveToTargetType); - - new SetupQuickItem("", this, "followModeEvent", - &GameModifiers::getFollowModeString, - &GameModifiers::changeFollowMode); - - new SetupQuickItem("", this, "attackWeaponTypeEvent", - &GameModifiers::getAttackWeaponTypeString, - &GameModifiers::changeAttackWeaponType); - - new SetupQuickItem("", this, "attackTypeEvent", - &GameModifiers::getAttackTypeString, - &GameModifiers::changeAttackType); - - new SetupQuickItem("", this, "magicAttackTypeEvent", - &GameModifiers::getMagicAttackTypeString, - &GameModifiers::changeMagicAttackType); - - new SetupQuickItem("", this, "pvpAttackTypeEvent", - &GameModifiers::getPvpAttackTypeString, - &GameModifiers::changePvpAttackType); - - new SetupQuickItem("", this, "quickDropCounterEvent", - &GameModifiers::getQuickDropCounterString, - &GameModifiers::changeQuickDropCounter); - - new SetupQuickItem("", this, "pickUpTypeEvent", - &GameModifiers::getPickUpTypeString, - &GameModifiers::changePickUpType); - - new SetupQuickItem("", this, "mapDrawTypeEvent", - &GameModifiers::getMapDrawTypeString, - &GameModifiers::changeMapDrawType); - - new SetupQuickItem("", this, "imitationModeEvent", - &GameModifiers::getImitationModeString, - &GameModifiers::changeImitationMode); - - new SetupQuickItem("", this, "CameraModeEvent", - &GameModifiers::getCameraModeString, - &GameModifiers::changeCameraMode); - - new SetupQuickItem("", this, "awayModeEvent", - &GameModifiers::getAwayModeString, - &GameModifiers::changeAwayMode); - - new SetupQuickItem("", this, "targetingTypeEvent", - &GameModifiers::getTargetingTypeString, - &GameModifiers::changeTargetingType); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Quick::~Setup_Quick() -{ - delete2(mMoveTypeList); - delete2(mCrazyMoveTypeList); -} diff --git a/src/gui/widgets/tabs/setup_quick.h b/src/gui/widgets/tabs/setup_quick.h deleted file mode 100644 index f174153ee..000000000 --- a/src/gui/widgets/tabs/setup_quick.h +++ /dev/null @@ -1,45 +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_WIDGETS_TABS_SETUP_QUICK_H -#define GUI_WIDGETS_TABS_SETUP_QUICK_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class NamesModel; - -class Setup_Quick final : public SetupTabScroll -{ - public: - explicit Setup_Quick(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Quick) - - ~Setup_Quick(); - - protected: - NamesModel *mMoveTypeList; - - NamesModel *mCrazyMoveTypeList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_QUICK_H diff --git a/src/gui/widgets/tabs/setup_relations.cpp b/src/gui/widgets/tabs/setup_relations.cpp deleted file mode 100644 index 4cc81a300..000000000 --- a/src/gui/widgets/tabs/setup_relations.cpp +++ /dev/null @@ -1,266 +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/widgets/tabs/setup_relations.h" - -#include "actormanager.h" - -#include "being/localplayer.h" - -#include "gui/models/ignorechoiceslistmodel.h" -#include "gui/models/playertablemodel.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/checkbox.h" -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/dropdown.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/guitable.h" - -#include "utils/delete2.h" - -#include "debug.h" - -static const int COLUMNS_NR = 2; // name plus listbox -static const int NAME_COLUMN = 0; -static const unsigned int NAME_COLUMN_WIDTH = 230; -static const unsigned int RELATION_CHOICE_COLUMN = 1; -static const unsigned int RELATION_CHOICE_COLUMN_WIDTH = 80; - -static const std::string ACTION_DELETE("delete"); -static const std::string ACTION_TABLE("table"); -static const std::string ACTION_STRATEGY("strategy"); - -static const char *const table_titles[COLUMNS_NR] = -{ - // TRANSLATORS: relations table header - N_("Name"), - // TRANSLATORS: relations table header - N_("Relation") -}; - -Setup_Relations::Setup_Relations(const Widget2 *const widget) : - SetupTab(widget), - PlayerRelationsListener(), - mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), - mPlayerTableModel(new PlayerTableModel(this)), - mPlayerTable(new GuiTable(this, mPlayerTableModel)), - mPlayerTitleTable(new GuiTable(this, mPlayerTableTitleModel)), - mPlayerScrollArea(new ScrollArea(this, mPlayerTable)), - // TRANSLATORS: relation dialog button - mDefaultTrading(new CheckBox(this, _("Allow trading"), - (playerRelations.getDefault() & PlayerRelation::TRADE) != 0u)), - // TRANSLATORS: relation dialog button - mDefaultWhisper(new CheckBox(this, _("Allow whispers"), - (playerRelations.getDefault() & PlayerRelation::WHISPER) != 0u)), - // TRANSLATORS: relation dialog button - mDeleteButton(new Button(this, _("Delete"), ACTION_DELETE, this)), - mIgnoreActionChoicesModel(new IgnoreChoicesListModel), - mIgnoreActionChoicesBox(new DropDown(widget, mIgnoreActionChoicesModel)) -{ - // TRANSLATORS: relation dialog name - setName(_("Relations")); - - mPlayerTable->setOpaque(Opaque_false); - - mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH); - mPlayerTableTitleModel->fixColumnWidth(RELATION_CHOICE_COLUMN, - RELATION_CHOICE_COLUMN_WIDTH); - mPlayerTitleTable->setBackgroundColor(getThemeColor( - ThemeColorId::TABLE_BACKGROUND)); - mPlayerTitleTable->setSelectableGui(false); - - for (int i = 0; i < COLUMNS_NR; i++) - { - mPlayerTableTitleModel->set(0, i, new Label( - this, gettext(table_titles[i]))); - } - - mPlayerTitleTable->setLinewiseSelection(true); - - mPlayerScrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mPlayerTable->setActionEventId(ACTION_TABLE); - mPlayerTable->setLinewiseSelection(true); - mPlayerTable->addActionListener(this); - - // TRANSLATORS: relation dialog label - Label *const ignore_action_label = new Label(this, _("When ignoring:")); - - mIgnoreActionChoicesBox->setActionEventId(ACTION_STRATEGY); - mIgnoreActionChoicesBox->addActionListener(this); - - int ignore_strategy_index = 0; // safe default - - if (playerRelations.getPlayerIgnoreStrategy() != nullptr) - { - ignore_strategy_index = playerRelations.getPlayerIgnoreStrategyIndex( - playerRelations.getPlayerIgnoreStrategy()->mShortName); - if (ignore_strategy_index < 0) - ignore_strategy_index = 0; - } - mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); - mIgnoreActionChoicesBox->adjustHeight(); - - reset(); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mPlayerTitleTable, 6); - place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2); - place(0, 5, mDeleteButton); - place(3, 5, ignore_action_label, 1); - place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2); - place(3, 6, mDefaultTrading, 3); - place(3, 7, mDefaultWhisper, 3); - - playerRelations.addListener(this); - - setDimension(Rect(0, 0, 500, 350)); -} - -Setup_Relations::~Setup_Relations() -{ - playerRelations.removeListener(this); - delete2(mIgnoreActionChoicesModel); -} - - -void Setup_Relations::reset() -{ - // We now have to search through the list of ignore choices to find the - // current selection. We could use an index into the table of config - // options in playerRelations instead of strategies to sidestep this. - int selection = 0; - for (size_t i = 0, sz = playerRelations.getPlayerIgnoreStrategies() - ->size(); i < sz; ++ i) - { - if ((*playerRelations.getPlayerIgnoreStrategies())[i] == - playerRelations.getPlayerIgnoreStrategy()) - { - selection = CAST_S32(i); - break; - } - } - mIgnoreActionChoicesBox->setSelected(selection); -} - -void Setup_Relations::apply() -{ - playerRelations.store(); - - const unsigned int old_default_relations = playerRelations.getDefault() & - ~(PlayerRelation::TRADE | PlayerRelation::WHISPER); - playerRelations.setDefault(old_default_relations - | (mDefaultTrading->isSelected() ? PlayerRelation::TRADE : 0) - | (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0)); - - if (actorManager != nullptr) - actorManager->updatePlayerNames(); - - if (localPlayer != nullptr) - localPlayer->setCheckNameSetting(true); -} - -void Setup_Relations::cancel() -{ -} - -void Setup_Relations::action(const ActionEvent &event) -{ - const std::string &eventId = event.getId(); - if (eventId == ACTION_TABLE) - { - // temporarily eliminate ourselves: we are fully aware of this change, - // so there is no need for asynchronous updates. (In fact, thouse - // might destroy the widet that triggered them, which would be rather - // embarrassing.) - playerRelations.removeListener(this); - - const int row = mPlayerTable->getSelectedRow(); - if (row >= 0) - mPlayerTableModel->updateModelInRow(row); - - playerRelations.addListener(this); - } - else if (eventId == ACTION_DELETE) - { - const int player_index = mPlayerTable->getSelectedRow(); - - if (player_index < 0) - return; - - playerRelations.removePlayer(mPlayerTableModel->getPlayerAt( - player_index)); - } - else if (eventId == ACTION_STRATEGY) - { - const int sel = mIgnoreActionChoicesBox->getSelected(); - if (sel < 0) - return; - PlayerIgnoreStrategy *const s = - (*playerRelations.getPlayerIgnoreStrategies())[sel]; - - playerRelations.setPlayerIgnoreStrategy(s); - } -} - -void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED) -{ - mPlayerTableModel->playerRelationsUpdated(); - mDefaultTrading->setSelected( - (playerRelations.getDefault() & PlayerRelation::TRADE) != 0u); - mDefaultWhisper->setSelected( - (playerRelations.getDefault() & PlayerRelation::WHISPER) != 0u); - if (localPlayer != nullptr) - localPlayer->updateName(); -} - -void Setup_Relations::updateAll() -{ - PlayerTableModel *const model = new PlayerTableModel(this); - mPlayerTable->setModel(model); - delete mPlayerTableModel; - mPlayerTableModel = model; - int ignore_strategy_index = 0; // safe default - - if (playerRelations.getPlayerIgnoreStrategy() != nullptr) - { - ignore_strategy_index = playerRelations.getPlayerIgnoreStrategyIndex( - playerRelations.getPlayerIgnoreStrategy()->mShortName); - if (ignore_strategy_index < 0) - ignore_strategy_index = 0; - } - mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); - mIgnoreActionChoicesBox->adjustHeight(); - reset(); -} -void Setup_Relations::externalUpdated() -{ - mDefaultTrading->setSelected( - (playerRelations.getDefault() & PlayerRelation::TRADE) != 0u); - mDefaultWhisper->setSelected( - (playerRelations.getDefault() & PlayerRelation::WHISPER) != 0u); -} diff --git a/src/gui/widgets/tabs/setup_relations.h b/src/gui/widgets/tabs/setup_relations.h deleted file mode 100644 index 879450891..000000000 --- a/src/gui/widgets/tabs/setup_relations.h +++ /dev/null @@ -1,79 +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_WIDGETS_TABS_SETUP_RELATIONS_H -#define GUI_WIDGETS_TABS_SETUP_RELATIONS_H - -#include "gui/widgets/tabs/setuptab.h" - -#include "listeners/playerrelationslistener.h" - -class Button; -class CheckBox; -class DropDown; -class GuiTable; -class ListModel; -class PlayerTableModel; -class ScrollArea; -class StaticTableModel; - -class Setup_Relations final : public SetupTab, - public PlayerRelationsListener -{ - public: - explicit Setup_Relations(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Relations) - - ~Setup_Relations(); - - void apply() override final; - - void cancel() override final A_CONST; - - void reset(); - - void action(const ActionEvent &event) override final; - - void updatedPlayer(const std::string &name) override final; - - void updateAll() override final; - - void externalUpdated() override final; - - private: - StaticTableModel *mPlayerTableTitleModel; - PlayerTableModel *mPlayerTableModel; - GuiTable *mPlayerTable; - GuiTable *mPlayerTitleTable; - ScrollArea *mPlayerScrollArea; - - CheckBox *mDefaultTrading; - CheckBox *mDefaultWhisper; - - Button *mDeleteButton; - - ListModel *mIgnoreActionChoicesModel; - DropDown *mIgnoreActionChoicesBox; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_RELATIONS_H diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp deleted file mode 100644 index 47cbb2b92..000000000 --- a/src/gui/widgets/tabs/setup_theme.cpp +++ /dev/null @@ -1,415 +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/>. - */ - -#include "gui/widgets/tabs/setup_theme.h" - -#include "gui/gui.h" -#include "gui/themeinfo.h" - -#include "gui/windows/okdialog.h" - -#include "gui/models/fontsizechoicelistmodel.h" -#include "gui/models/fontsmodel.h" -#include "gui/models/langlistmodel.h" -#include "gui/models/themesmodel.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/dropdown.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layouthelper.h" - -#include "configuration.h" - -#include "utils/delete2.h" - -#include "debug.h" - -const char* ACTION_THEME = "theme"; -const char* ACTION_FONT = "font"; -const char* ACTION_LANG = "lang"; -const char* ACTION_BOLD_FONT = "bold font"; -const char* ACTION_PARTICLE_FONT = "particle font"; -const char* ACTION_HELP_FONT = "help font"; -const char* ACTION_SECURE_FONT = "secure font"; -const char* ACTION_NPC_FONT = "npc font"; -const char* ACTION_JAPAN_FONT = "japanese font"; -const char* ACTION_CHINA_FONT = "chinese font"; -const char* ACTION_INFO = "info"; - -Setup_Theme::Setup_Theme(const Widget2 *const widget) : - SetupTab(widget), - // TRANSLATORS: theme settings label - mThemeLabel(new Label(this, _("Gui theme"))), - mThemesModel(new ThemesModel), - mThemeDropDown(new DropDown(this, mThemesModel)), - mTheme(config.getStringValue("theme")), - mInfo(Theme::loadInfo(mTheme)), - mFontsModel(new FontsModel), - // TRANSLATORS: theme settings label - mFontLabel(new Label(this, _("Main Font"))), - mFontDropDown(new DropDown(this, mFontsModel)), - mFont(config.getStringValue("font")), - mLangListModel(new LangListModel), - // TRANSLATORS: theme settings label - mLangLabel(new Label(this, _("Language"))), - mLangDropDown(new DropDown(this, mLangListModel, true)), - mLang(config.getStringValue("lang")), - // TRANSLATORS: theme settings label - mBoldFontLabel(new Label(this, _("Bold font"))), - mBoldFontDropDown(new DropDown(this, mFontsModel)), - mBoldFont(config.getStringValue("boldFont")), - // TRANSLATORS: theme settings label - mParticleFontLabel(new Label(this, _("Particle font"))), - mParticleFontDropDown(new DropDown(this, mFontsModel)), - mParticleFont(config.getStringValue("particleFont")), - // TRANSLATORS: theme settings label - mHelpFontLabel(new Label(this, _("Help font"))), - mHelpFontDropDown(new DropDown(this, mFontsModel)), - mHelpFont(config.getStringValue("helpFont")), - // TRANSLATORS: theme settings label - mSecureFontLabel(new Label(this, _("Secure font"))), - mSecureFontDropDown(new DropDown(this, mFontsModel)), - mSecureFont(config.getStringValue("secureFont")), - // TRANSLATORS: theme settings label - mNpcFontLabel(new Label(this, _("Npc font"))), - mNpcFontDropDown(new DropDown(this, mFontsModel)), - mNpcFont(config.getStringValue("npcFont")), - // TRANSLATORS: theme settings label - mJapanFontLabel(new Label(this, _("Japanese font"))), - mJapanFontDropDown(new DropDown(this, mFontsModel)), - mJapanFont(config.getStringValue("japanFont")), - // TRANSLATORS: theme settings label - mChinaFontLabel(new Label(this, _("Chinese font"))), - mChinaFontDropDown(new DropDown(this, mFontsModel)), - mChinaFont(config.getStringValue("chinaFont")), - mFontSizeListModel(new FontSizeChoiceListModel), - // TRANSLATORS: theme settings label - mFontSizeLabel(new Label(this, _("Font size"))), - mFontSize(config.getIntValue("fontSize")), - mFontSizeDropDown(new DropDown(this, mFontSizeListModel)), - mNpcFontSizeListModel(new FontSizeChoiceListModel), - // TRANSLATORS: theme settings label - mNpcFontSizeLabel(new Label(this, _("Npc font size"))), - mNpcFontSize(config.getIntValue("npcfontSize")), - mNpcFontSizeDropDown(new DropDown(this, mNpcFontSizeListModel)), - // TRANSLATORS: button name with information about selected theme - mInfoButton(new Button(this, _("i"), ACTION_INFO, this)), - mThemeInfo() -{ - // TRANSLATORS: theme settings tab name - setName(_("Theme")); - - mThemeDropDown->setActionEventId(ACTION_THEME); - mThemeDropDown->addActionListener(this); - mFontDropDown->setActionEventId(ACTION_FONT); - mFontDropDown->addActionListener(this); - mLangDropDown->setActionEventId(ACTION_LANG); - mLangDropDown->addActionListener(this); - mBoldFontDropDown->setActionEventId(ACTION_BOLD_FONT); - mBoldFontDropDown->addActionListener(this); - mParticleFontDropDown->setActionEventId(ACTION_PARTICLE_FONT); - mParticleFontDropDown->addActionListener(this); - mHelpFontDropDown->setActionEventId(ACTION_HELP_FONT); - mHelpFontDropDown->addActionListener(this); - mSecureFontDropDown->setActionEventId(ACTION_SECURE_FONT); - mSecureFontDropDown->addActionListener(this); - mNpcFontDropDown->setActionEventId(ACTION_NPC_FONT); - mNpcFontDropDown->addActionListener(this); - mJapanFontDropDown->setActionEventId(ACTION_JAPAN_FONT); - mJapanFontDropDown->addActionListener(this); - mChinaFontDropDown->setActionEventId(ACTION_CHINA_FONT); - mChinaFontDropDown->addActionListener(this); - mFontSizeDropDown->setSelected(mFontSize - 9); - mFontSizeDropDown->adjustHeight(); - mNpcFontSizeDropDown->setSelected(mNpcFontSize - 9); - mNpcFontSizeDropDown->adjustHeight(); - - const std::string skin = Theme::getThemeName(); - if (!skin.empty()) - mThemeDropDown->setSelectedString(skin); - else - mThemeDropDown->setSelected(0); - - const std::string str = config.getStringValue("lang"); - for (int f = 0; f < langs_count; f ++) - { - if (LANG_NAME[f].value == str) - { - mLangDropDown->setSelected(f); - break; - } - } - - mFontDropDown->setSelectedString(getFileName( - config.getStringValue("font"))); - mBoldFontDropDown->setSelectedString(getFileName( - config.getStringValue("boldFont"))); - mParticleFontDropDown->setSelectedString(getFileName( - config.getStringValue("particleFont"))); - mHelpFontDropDown->setSelectedString(getFileName( - config.getStringValue("helpFont"))); - mSecureFontDropDown->setSelectedString(getFileName( - config.getStringValue("secureFont"))); - mNpcFontDropDown->setSelectedString(getFileName( - config.getStringValue("npcFont"))); - mJapanFontDropDown->setSelectedString(getFileName( - config.getStringValue("japanFont"))); - mChinaFontDropDown->setSelectedString(getFileName( - config.getStringValue("chinaFont"))); - - updateInfo(); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, mThemeLabel, 5); - place(0, 1, mLangLabel, 5); - place(0, 2, mFontSizeLabel, 5); - place(0, 3, mNpcFontSizeLabel, 5); - place(0, 4, mFontLabel, 5); - place(0, 5, mBoldFontLabel, 5); - place(0, 6, mParticleFontLabel, 5); - place(0, 7, mHelpFontLabel, 5); - place(0, 8, mSecureFontLabel, 5); - place(0, 9, mNpcFontLabel, 5); - place(0, 10, mJapanFontLabel, 5); - place(0, 11, mChinaFontLabel, 5); - - place(6, 0, mThemeDropDown, 10); - place(6, 1, mLangDropDown, 10); - place(6, 2, mFontSizeDropDown, 10); - place(6, 3, mNpcFontSizeDropDown, 10); - place(6, 4, mFontDropDown, 10); - place(6, 5, mBoldFontDropDown, 10); - place(6, 6, mParticleFontDropDown, 10); - place(6, 7, mHelpFontDropDown, 10); - place(6, 8, mSecureFontDropDown, 10); - place(6, 9, mNpcFontDropDown, 10); - place(6, 10, mJapanFontDropDown, 10); - place(6, 11, mChinaFontDropDown, 10); - - place(17, 0, mInfoButton, 1); - - int size = mainGraphics->mWidth - 10; - const int maxWidth = mFontSize * 30 + 290; - if (size < 465) - size = 465; - else if (size > maxWidth) - size = maxWidth; - - setDimension(Rect(0, 0, size, 500)); -} - -Setup_Theme::~Setup_Theme() -{ - delete2(mInfo); - delete2(mThemesModel); - delete2(mFontsModel); - delete2(mFontSizeListModel); - delete2(mNpcFontSizeListModel); - delete2(mLangListModel); - delete2(mInfo); -} - -void Setup_Theme::updateInfo() -{ - delete mInfo; - mInfo = Theme::loadInfo(mTheme); - if (mInfo != nullptr) - { - // TRANSLATORS: theme name - mThemeInfo = std::string(_("Name: ")).append(mInfo->name) - // TRANSLATORS: theme copyright - .append("\n").append(_("Copyright:")).append("\n") - .append(mInfo->copyright); - } - else - { - mThemeInfo.clear(); - } - replaceAll(mThemeInfo, "\\n", "\n"); - mInfoButton->setEnabled(!mThemeInfo.empty()); -} - -void Setup_Theme::action(const ActionEvent &event) -{ - const std::string &eventId = event.getId(); - if (eventId == ACTION_THEME) - { - if (mThemeDropDown->getSelected() == 0) - mTheme.clear(); - else - mTheme = mThemeDropDown->getSelectedString(); - updateInfo(); - } - else if (eventId == ACTION_FONT) - { - mFont = mFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_LANG) - { - const int id = mLangDropDown->getSelected(); - if (id < 0 || id >= langs_count) - mLang.clear(); - else - mLang = LANG_NAME[id].value; - } - else if (eventId == ACTION_BOLD_FONT) - { - mBoldFont = mBoldFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_PARTICLE_FONT) - { - mParticleFont = mParticleFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_HELP_FONT) - { - mHelpFont = mHelpFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_SECURE_FONT) - { - mSecureFont = mSecureFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_NPC_FONT) - { - mNpcFont = mNpcFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_JAPAN_FONT) - { - mJapanFont = mJapanFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_CHINA_FONT) - { - mChinaFont = mChinaFontDropDown->getSelectedString(); - } - else if (eventId == ACTION_INFO) - { - CREATEWIDGET(OkDialog, - // TRANSLATORS: theme info dialog header - _("Theme info"), - mThemeInfo, - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 600); - } -} - -void Setup_Theme::cancel() -{ - mTheme = config.getStringValue("theme"); - mLang = config.getStringValue("lang"); - mFont = getFileName(config.getStringValue("font")); - mBoldFont = getFileName(config.getStringValue("boldFont")); - mParticleFont = getFileName(config.getStringValue("particleFont")); - mHelpFont = getFileName(config.getStringValue("helpFont")); - mSecureFont = getFileName(config.getStringValue("secureFont")); - mNpcFont = getFileName(config.getStringValue("npcFont")); - mJapanFont = getFileName(config.getStringValue("japanFont")); - mChinaFont = getFileName(config.getStringValue("chinaFont")); -} - -#define updateField(name1, name2) if (!mInfo->name1.empty()) \ - name2 = mInfo->name1; - -void Setup_Theme::apply() -{ - if (config.getStringValue("theme") != mTheme) - { - CREATEWIDGET(OkDialog, - // TRANSLATORS: theme message dialog - _("Theme Changed"), - // TRANSLATORS: ok dialog message - _("Restart your client for the change to take effect."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } - - config.setValue("selectedSkin", ""); - if (config.getStringValue("theme") != mTheme && (mInfo != nullptr)) - { - updateField(font, mFont); - updateField(boldFont, mBoldFont); - updateField(particleFont, mParticleFont); - updateField(helpFont, mHelpFont); - updateField(secureFont, mSecureFont); - updateField(npcFont, mNpcFont); - updateField(japanFont, mJapanFont); - updateField(chinaFont, mChinaFont); - if (mInfo->fontSize != 0) - { - const int size = mInfo->fontSize - 9; - if (size >= 0) - mFontSizeDropDown->setSelected(size); - } - if (mInfo->npcfontSize != 0) - { - const int size = mInfo->npcfontSize - 9; - if (size >= 0) - mNpcFontSizeDropDown->setSelected(size); - } - if (mInfo->guiAlpha > 0.01F) - config.setValue("guialpha", mInfo->guiAlpha); - } - config.setValue("theme", mTheme); - config.setValue("lang", mLang); - if (config.getValue("font", "dejavusans.ttf") != mFont - || config.getValue("boldFont", "dejavusans-bold.ttf") != mBoldFont - || config.getValue("particleFont", "dejavusans.ttf") != mParticleFont - || config.getValue("helpFont", "dejavusansmono.ttf") != mHelpFont - || config.getValue("secureFont", "dejavusansmono.ttf") != mSecureFont - || config.getValue("npcFont", "dejavusans.ttf") != mNpcFont - || config.getValue("japanFont", "mplus-1p-regular.ttf") != mJapanFont - || config.getValue("chinaFont", "fonts/wqy-microhei.ttf") - != mChinaFont - || config.getIntValue("fontSize") - != CAST_S32(mFontSizeDropDown->getSelected()) + 9 - || config.getIntValue("npcfontSize") - != CAST_S32(mNpcFontSizeDropDown->getSelected()) + 9) - { - config.setValue("font", "fonts/" + getFileName(mFont)); - config.setValue("boldFont", "fonts/" + getFileName(mBoldFont)); - config.setValue("particleFont", "fonts/" + getFileName(mParticleFont)); - config.setValue("helpFont", "fonts/" + getFileName(mHelpFont)); - config.setValue("secureFont", "fonts/" + getFileName(mSecureFont)); - config.setValue("npcFont", "fonts/" + getFileName(mNpcFont)); - config.setValue("japanFont", "fonts/" + getFileName(mJapanFont)); - config.setValue("chinaFont", "fonts/" + getFileName(mChinaFont)); - config.setValue("fontSize", mFontSizeDropDown->getSelected() + 9); - config.setValue("npcfontSize", - mNpcFontSizeDropDown->getSelected() + 9); - gui->updateFonts(); - } -} - -#undef updateField diff --git a/src/gui/widgets/tabs/setup_theme.h b/src/gui/widgets/tabs/setup_theme.h deleted file mode 100644 index 57798f243..000000000 --- a/src/gui/widgets/tabs/setup_theme.h +++ /dev/null @@ -1,113 +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_WIDGETS_TABS_SETUP_THEME_H -#define GUI_WIDGETS_TABS_SETUP_THEME_H - -#include "gui/widgets/tabs/setuptab.h" - -class Button; -class DropDown; -class FontsModel; -class FontSizeChoiceListModel; -class Label; -class LangListModel; -class ThemesModel; - -class Setup_Theme final : public SetupTab -{ - public: - explicit Setup_Theme(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Theme) - - ~Setup_Theme(); - - void apply() override final; - - void cancel() override final; - - void action(const ActionEvent &event) override final; - - void updateInfo(); - - private: - Label *mThemeLabel; - ThemesModel *mThemesModel A_NONNULLPOINTER; - DropDown *mThemeDropDown; - std::string mTheme; - ThemeInfo *mInfo; - - FontsModel *mFontsModel A_NONNULLPOINTER; - Label *mFontLabel A_NONNULLPOINTER; - DropDown *mFontDropDown A_NONNULLPOINTER; - std::string mFont; - - LangListModel *mLangListModel A_NONNULLPOINTER; - - Label *mLangLabel A_NONNULLPOINTER; - DropDown *mLangDropDown A_NONNULLPOINTER; - std::string mLang; - - Label *mBoldFontLabel A_NONNULLPOINTER; - DropDown *mBoldFontDropDown A_NONNULLPOINTER; - std::string mBoldFont; - - Label *mParticleFontLabel A_NONNULLPOINTER; - DropDown *mParticleFontDropDown A_NONNULLPOINTER; - std::string mParticleFont; - - Label *mHelpFontLabel A_NONNULLPOINTER; - DropDown *mHelpFontDropDown A_NONNULLPOINTER; - std::string mHelpFont; - - Label *mSecureFontLabel A_NONNULLPOINTER; - DropDown *mSecureFontDropDown A_NONNULLPOINTER; - std::string mSecureFont; - - Label *mNpcFontLabel A_NONNULLPOINTER; - DropDown *mNpcFontDropDown A_NONNULLPOINTER; - std::string mNpcFont; - - Label *mJapanFontLabel A_NONNULLPOINTER; - DropDown *mJapanFontDropDown A_NONNULLPOINTER; - std::string mJapanFont; - - Label *mChinaFontLabel A_NONNULLPOINTER; - DropDown *mChinaFontDropDown A_NONNULLPOINTER; - std::string mChinaFont; - - FontSizeChoiceListModel *mFontSizeListModel A_NONNULLPOINTER; - Label *mFontSizeLabel; - int mFontSize; - DropDown *mFontSizeDropDown; - - FontSizeChoiceListModel *mNpcFontSizeListModel A_NONNULLPOINTER; - Label *mNpcFontSizeLabel; - int mNpcFontSize; - DropDown *mNpcFontSizeDropDown A_NONNULLPOINTER; - - Button *mInfoButton A_NONNULLPOINTER; - std::string mThemeInfo; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_THEME_H diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp deleted file mode 100644 index c8558fef9..000000000 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ /dev/null @@ -1,134 +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/widgets/tabs/setup_touch.h" - -#include "gui/models/touchactionmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/setuptouchitem.h" -#include "gui/widgets/scrollarea.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "debug.h" - -static const int sizeListSize = 4; - -static const char *const sizeList[] = -{ - // TRANSLATORS: onscreen button size - N_("Small"), - // TRANSLATORS: onscreen button size - N_("Normal"), - // TRANSLATORS: onscreen button size - N_("Medium"), - // TRANSLATORS: onscreen button size - N_("Large") -}; - -static const int formatListSize = 6; - -static const char *const formatList[] = -{ - "2x1", - "2x2", - "3x3", - "4x2", - "4x3", - "3x2" -}; - -Setup_Touch::Setup_Touch(const Widget2 *const widget) : - SetupTabScroll(widget), - mSizeList(new NamesModel), - mFormatList(new NamesModel), - mActionsList(new TouchActionsModel) -{ - // TRANSLATORS: touch settings tab - setName(_("Touch")); - - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - mSizeList->fillFromArray(&sizeList[0], sizeListSize); - mFormatList->fillFromArray(&formatList[0], formatListSize); - - // TRANSLATORS: settings option - new SetupItemLabel(_("Onscreen keyboard"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show onscreen keyboard icon"), "", - "showScreenKeyboard", this, "showScreenKeyboardEvent"); - - // TRANSLATORS: settings option - new SetupActionDropDown(_("Keyboard icon action"), "", - "screenActionKeyboard", this, "screenActionKeyboardEvent", - mActionsList, 250); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Onscreen joystick"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show onscreen joystick"), "", - "showScreenJoystick", this, "showScreenJoystickEvent"); - - // TRANSLATORS: settings option - new SetupItemDropDown(_("Joystick size"), "", "screenJoystickSize", this, - "screenJoystickEvent", mSizeList, 100); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Onscreen buttons"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show onscreen buttons"), "", - "showScreenButtons", this, "showScreenButtonsEvent"); - - // TRANSLATORS: settings option - new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this, - "screenButtonsFormatEvent", mFormatList, 100); - - // TRANSLATORS: settings option - new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this, - "screenButtonsSizeEvent", mSizeList, 100); - - for (unsigned int f = 0; f < 12; f ++) - { - std::string key = strprintf("screenActionButton%u", f); - std::string event = strprintf("screenActionButton%uEvent", f); - // TRANSLATORS: settings option - new SetupActionDropDown(strprintf(_("Button %u action"), f + 1), "", - key, this, event, mActionsList, 250); - } - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Touch::~Setup_Touch() -{ - delete2(mSizeList); - delete2(mFormatList); - delete2(mActionsList); -} diff --git a/src/gui/widgets/tabs/setup_touch.h b/src/gui/widgets/tabs/setup_touch.h deleted file mode 100644 index a87a46c77..000000000 --- a/src/gui/widgets/tabs/setup_touch.h +++ /dev/null @@ -1,44 +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_WIDGETS_TABS_SETUP_TOUCH_H -#define GUI_WIDGETS_TABS_SETUP_TOUCH_H - -#include "gui/widgets/tabs/setuptabscroll.h" - -class NamesModel; -class TouchActionsModel; - -class Setup_Touch final : public SetupTabScroll -{ - public: - explicit Setup_Touch(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Touch) - - ~Setup_Touch(); - - protected: - NamesModel *mSizeList; - NamesModel *mFormatList; - TouchActionsModel *mActionsList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_TOUCH_H diff --git a/src/gui/widgets/tabs/setup_video.cpp b/src/gui/widgets/tabs/setup_video.cpp deleted file mode 100644 index b5b74e2b9..000000000 --- a/src/gui/widgets/tabs/setup_video.cpp +++ /dev/null @@ -1,534 +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/widgets/tabs/setup_video.h" - -#include "gui/windowmanager.h" - -#include "gui/windows/okdialog.h" -#include "gui/windows/textdialog.h" - -#include "gui/widgets/button.h" -#include "gui/widgets/checkbox.h" -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/label.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/listbox.h" -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/slider.h" -#include "gui/widgets/dropdown.h" - -#include "utils/delete2.h" - -#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) -#include "graphicsmanager.h" - -#include "test/testmain.h" -#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) - -#if defined(ANDROID) || defined(__APPLE__) || !defined(USE_OPENGL) -#include "configuration.h" -#endif // defined(ANDROID) || defined(__APPLE__) || !defined(USE_OPENGL) - -#if defined(ANDROID) || defined(__APPLE__) -#include "utils/stringutils.h" -#endif // defined(ANDROID) || defined(__APPLE__) - -#include "gui/models/modelistmodel.h" -#include "gui/models/opengllistmodel.h" - -#include <sstream> - -#include "debug.h" - -Setup_Video::Setup_Video(const Widget2 *const widget) : - SetupTab(widget), - KeyListener(), - mFullScreenEnabled(config.getBoolValue("screen")), - mOpenGLEnabled(intToRenderType(config.getIntValue("opengl"))), - mFps(config.getIntValue("fpslimit")), - mAltFps(config.getIntValue("altfpslimit")), - mModeListModel(new ModeListModel), - mOpenGLListModel(new OpenGLListModel), - mModeList(CREATEWIDGETR(ListBox, widget, mModeListModel, "")), - // TRANSLATORS: video settings checkbox - mFsCheckBox(new CheckBox(this, _("Full screen"), mFullScreenEnabled)), - mOpenGLDropDown(new DropDown(widget, mOpenGLListModel)), - // TRANSLATORS: video settings checkbox - mFpsCheckBox(new CheckBox(this, _("FPS limit:"))), - mFpsSlider(new Slider(this, 2.0, 160.0, 1.0)), - mFpsLabel(new Label(this)), - mAltFpsSlider(new Slider(this, 2.0, 160.0, 1.0)), - // TRANSLATORS: video settings label - mAltFpsLabel(new Label(this, _("Alt FPS limit: "))), -#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) - // TRANSLATORS: video settings button - mDetectButton(new Button(this, _("Detect best mode"), "detect", this)), -#endif // !defined(ANDROID) && !defined(__APPLE__) && - // !defined(__native_client__) - mDialog(nullptr), - mCustomCursorEnabled(config.getBoolValue("customcursor")), - mEnableResize(config.getBoolValue("enableresize")), - mNoFrame(config.getBoolValue("noframe")), -#ifdef USE_SDL2 - mAllowHighDPI(config.getBoolValue("allowHighDPI")), - // TRANSLATORS: video settings checkbox - mAllowHighDPICheckBox(new CheckBox(this, _("High DPI"), mAllowHighDPI)), -#endif // USE_SDL2 - mCustomCursorCheckBox(new CheckBox(this, -#ifdef ANDROID - // TRANSLATORS: video settings checkbox - _("Show cursor"), -#else // ANDROID - // TRANSLATORS: video settings checkbox - _("Custom cursor"), -#endif // ANDROID - mCustomCursorEnabled)), - // TRANSLATORS: video settings checkbox - mEnableResizeCheckBox(new CheckBox(this, _("Enable resize"), - mEnableResize)), - // TRANSLATORS: video settings checkbox - mNoFrameCheckBox(new CheckBox(this, _("No frame"), mNoFrame)) -{ - // TRANSLATORS: video settings tab name - setName(_("Video")); - - ScrollArea *const scrollArea = new ScrollArea(this, mModeList, - Opaque_true, "setup_video_background.xml"); - scrollArea->setWidth(150); - scrollArea->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - - mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]); - - mModeList->setEnabled(true); - - // TRANSLATORS: video settings label - mFpsLabel->setCaption(mFps > 0 ? toString(mFps) : _("None")); - mFpsLabel->setWidth(60); - // TRANSLATORS: video settings label - mAltFpsLabel->setCaption(_("Alt FPS limit: ") + (mAltFps > 0 ? - // TRANSLATORS: video settings label value - toString(mAltFps) : _("None"))); - mAltFpsLabel->setWidth(150); - mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue(mFps); - mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue(mAltFps); - mFpsCheckBox->setSelected(mFps > 0); - - // Pre-select the current video mode. - const std::string videoMode = toString( - mainGraphics->mActualWidth).append("x").append( - toString(mainGraphics->mActualHeight)); - mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - - mModeList->setActionEventId("videomode"); - mCustomCursorCheckBox->setActionEventId("customcursor"); - mFpsCheckBox->setActionEventId("fpslimitcheckbox"); - mFpsSlider->setActionEventId("fpslimitslider"); - mAltFpsSlider->setActionEventId("altfpslimitslider"); - mOpenGLDropDown->setActionEventId("opengl"); - mEnableResizeCheckBox->setActionEventId("enableresize"); - mNoFrameCheckBox->setActionEventId("noframe"); -#ifdef USE_SDL2 - mAllowHighDPICheckBox->setActionEventId("allowHighDPI"); - mAllowHighDPICheckBox->addActionListener(this); -#endif // USE_SDL2 - - mModeList->addActionListener(this); - mCustomCursorCheckBox->addActionListener(this); - mFpsCheckBox->addActionListener(this); - mFpsSlider->addActionListener(this); - mAltFpsSlider->addActionListener(this); - mOpenGLDropDown->addActionListener(this); - mEnableResizeCheckBox->addActionListener(this); - mNoFrameCheckBox->addActionListener(this); - - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - - place(0, 0, scrollArea, 1, 5).setPadding(2); - place(0, 5, mOpenGLDropDown, 1); - - place(1, 0, mFsCheckBox, 2); - - place(1, 1, mCustomCursorCheckBox, 3); - - place(1, 2, mEnableResizeCheckBox, 2); - place(1, 3, mNoFrameCheckBox, 2); -#ifdef USE_SDL2 - place(1, 4, mAllowHighDPICheckBox, 2); -#endif // USE_SDL2 - - place(0, 6, mFpsSlider); - place(1, 6, mFpsCheckBox).setPadding(3); - place(2, 6, mFpsLabel).setPadding(1); - - place(0, 7, mAltFpsSlider); - place(1, 7, mAltFpsLabel).setPadding(3); - -#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) - place(0, 8, mDetectButton); -#else // !defined(ANDROID) && !defined(__APPLE__) && - // !defined(__native_client__) - mNoFrameCheckBox->setEnabled(false); - mEnableResizeCheckBox->setEnabled(false); -#ifndef __native_client__ - mFsCheckBox->setEnabled(false); -#endif // __native_client__ -#endif // !defined(ANDROID) && !defined(__APPLE__) && - // !defined(__native_client__) - - int width = 600; - - if (config.getIntValue("screenwidth") >= 730) - width += 100; - - setDimension(Rect(0, 0, width, 300)); -} - -Setup_Video::~Setup_Video() -{ - delete2(mModeListModel); - delete2(mModeList); - delete2(mOpenGLListModel); - delete2(mDialog); -} - -void Setup_Video::apply() -{ - // Full screen changes - bool fullscreen = mFsCheckBox->isSelected(); - if (fullscreen != config.getBoolValue("screen")) - { - /* The OpenGL test is only necessary on Windows, since switching - * to/from full screen works fine on Linux. On Windows we'd have to - * reinitialize the OpenGL state and reload all textures. - * - * See http://libsdl.org/cgi/docwiki.cgi/SDL_SetVideoMode - */ - -#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - // checks for opengl usage - if (intToRenderType(config.getIntValue("opengl")) == RENDER_SOFTWARE) - { -#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - if (!WindowManager::setFullScreen(fullscreen)) - { - fullscreen = !fullscreen; - if (!WindowManager::setFullScreen(fullscreen)) - { - std::stringstream errorMsg; - if (fullscreen) - { - // TRANSLATORS: video error message - errorMsg << _("Failed to switch to windowed mode " - "and restoration of old mode also " - "failed!") << std::endl; - } - else - { - // TRANSLATORS: video error message - errorMsg << _("Failed to switch to fullscreen mode" - " and restoration of old mode also " - "failed!") << std::endl; - } - logger->safeError(errorMsg.str()); - } - } -#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - } - else - { - CREATEWIDGET(OkDialog, - // TRANSLATORS: video settings warning - _("Switching to Full Screen"), - // TRANSLATORS: video settings warning - _("Restart needed for changes to take effect."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } -#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - - config.setValue("screen", fullscreen); - } - - const int sel = mOpenGLDropDown->getSelected(); - RenderType mode = RENDER_SOFTWARE; - if (sel >= 0 && CAST_U32(sel) < sizeof(indexToRender)) - mode = indexToRender[mOpenGLDropDown->getSelected()]; - - // OpenGL change - if (mode != mOpenGLEnabled) - { - config.setValue("opengl", CAST_S32(mode)); - - // OpenGL can currently only be changed by restarting, notify user. - CREATEWIDGET(OkDialog, - // TRANSLATORS: video settings warning - _("Changing to OpenGL"), - // TRANSLATORS: video settings warning - _("Applying change to OpenGL requires restart."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } - - mFps = mFpsCheckBox->isSelected() ? - CAST_S32(mFpsSlider->getValue()) : 0; - - mAltFps = CAST_S32(mAltFpsSlider->getValue()); - - mFpsSlider->setEnabled(mFps > 0); - - mAltFpsSlider->setEnabled(mAltFps > 0); - - // FPS change - config.setValue("fpslimit", mFps); - config.setValue("altfpslimit", mAltFps); - - // We sync old and new values at apply time - mFullScreenEnabled = config.getBoolValue("screen"); - mCustomCursorEnabled = config.getBoolValue("customcursor"); - - mOpenGLEnabled = intToRenderType(config.getIntValue("opengl")); - mEnableResize = config.getBoolValue("enableresize"); - mNoFrame = config.getBoolValue("noframe"); -#ifdef USE_SDL2 - mAllowHighDPI = config.getBoolValue("allowHighDPI"); -#endif // USE_SDL2 -} - -void Setup_Video::cancel() -{ - mFpsCheckBox->setSelected(mFps > 0); - mFsCheckBox->setSelected(mFullScreenEnabled); - mOpenGLDropDown->setSelected(renderToIndex[mOpenGLEnabled]); - mCustomCursorCheckBox->setSelected(mCustomCursorEnabled); - mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue(mFps); - mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue(mAltFps); - mFpsLabel->setCaption(mFpsCheckBox->isSelected() - // TRANSLATORS: video settings label - ? toString(mFps) : _("None")); - // TRANSLATORS: video settings label - mAltFpsLabel->setCaption(_("Alt FPS limit: ") + toString(mAltFps)); - mEnableResizeCheckBox->setSelected(mEnableResize); - mNoFrameCheckBox->setSelected(mNoFrame); -#ifdef USE_SDL2 - mAllowHighDPICheckBox->setSelected(mAllowHighDPI); -#endif // USE_SDL2 - - config.setValue("screen", mFullScreenEnabled); - - // Set back to the current video mode. - std::string videoMode = toString(mainGraphics->mActualWidth).append("x") - .append(toString(mainGraphics->mActualHeight)); - mModeList->setSelected(mModeListModel->getIndexOf(videoMode)); - config.setValue("screenwidth", mainGraphics->mActualWidth); - config.setValue("screenheight", mainGraphics->mActualHeight); - - config.setValue("customcursor", mCustomCursorEnabled); - config.setValue("opengl", CAST_S32(mOpenGLEnabled)); - config.setValue("enableresize", mEnableResize); -#ifdef USE_SDL2 - config.setValue("allowHighDPI", mAllowHighDPI); -#endif // USE_SDL2 -} - -void Setup_Video::action(const ActionEvent &event) -{ - const std::string &id = event.getId(); - - if (id == "videomode") - { - std::string mode = mModeListModel->getElementAt( - mModeList->getSelected()); - - if (mode == "custom") - { - if (mDialog != nullptr) - { - mode = mDialog->getText(); - mDialog = nullptr; - } - else - { - CREATEWIDGETV(mDialog, TextDialog, - // TRANSLATORS: resolution question dialog - _("Custom resolution (example: 1024x768)"), - // TRANSLATORS: resolution question dialog - _("Enter new resolution: ")); - mDialog->setActionEventId("videomode"); - mDialog->addActionListener(this); - return; - } - } - const int width = atoi(mode.substr(0, mode.find('x')).c_str()); - const int height = atoi(mode.substr(mode.find('x') + 1).c_str()); - if ((width == 0) || (height == 0)) - return; - - if (width != mainGraphics->mActualWidth - || height != mainGraphics->mActualHeight) - { -#if defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - if (intToRenderType(config.getIntValue("opengl")) - == RENDER_SOFTWARE) - { - WindowManager::doResizeVideo(width, height, false); - } - else - { - if (width < mainGraphics->mActualWidth - || height < mainGraphics->mActualHeight) - { - CREATEWIDGET(OkDialog, - // TRANSLATORS: video settings warning - _("Screen Resolution Changed"), - // TRANSLATORS: video settings warning - _("Restart your client for the change to take effect.") - // TRANSLATORS: video settings warning - + std::string("\n") + _("Some windows may be moved to " - "fit the lowered resolution."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } - else - { - CREATEWIDGET(OkDialog, - // TRANSLATORS: video settings warning - _("Screen Resolution Changed"), - // TRANSLATORS: video settings warning - _("Restart your client for the change" - " to take effect."), - // TRANSLATORS: ok dialog button - _("OK"), - DialogType::OK, - Modal_true, - ShowCenter_true, - nullptr, - 260); - } - } -#else // defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - - mainGraphics->setWindowSize(width, height); - WindowManager::doResizeVideo(width, height, false); -#endif // defined(WIN32) || defined(__APPLE__) || defined(ANDROID) - } - - config.setValue("oldscreen", config.getBoolValue("screen")); - config.setValue("oldscreenwidth", mainGraphics->mActualWidth); - config.setValue("oldscreenheight", mainGraphics->mActualHeight); - config.setValue("screenwidth", width); - config.setValue("screenheight", height); - } - if (id == "~videomode") - { - mDialog = nullptr; - } - else if (id == "customcursor") - { - config.setValue("customcursor", mCustomCursorCheckBox->isSelected()); - } - else if (id == "fpslimitcheckbox" || id == "fpslimitslider") - { - int tempFps = CAST_S32(mFpsSlider->getValue()); - if (id == "fpslimitcheckbox" && !mFpsSlider->isEnabled()) - tempFps = 60; - else - tempFps = tempFps > 0 ? tempFps : 60; - mFps = mFpsCheckBox->isSelected() ? tempFps : 0; - // TRANSLATORS: video settings label - const std::string text = mFps > 0 ? toString(mFps) : _("None"); - - mFpsLabel->setCaption(text); - mFpsSlider->setEnabled(mFps > 0); - mFpsSlider->setValue(mFps); - } - else if (id == "altfpslimitslider") - { - int tempFps = CAST_S32(mAltFpsSlider->getValue()); - tempFps = tempFps > 0 ? tempFps : CAST_S32( - mAltFpsSlider->getScaleStart()); - mAltFps = tempFps; - // TRANSLATORS: video settings label - const std::string text = mAltFps > 0 ? toString(mAltFps) : _("None"); - - // TRANSLATORS: video settings label - mAltFpsLabel->setCaption(_("Alt FPS limit: ") + text); - mAltFpsSlider->setEnabled(mAltFps > 0); - mAltFpsSlider->setValue(mAltFps); - } - else if (id == "enableresize") - { - config.setValue("enableresize", mEnableResizeCheckBox->isSelected()); - } - else if (id == "noframe") - { - config.setValue("noframe", mNoFrameCheckBox->isSelected()); - } -#ifdef USE_SDL2 - else if (id == "allowHighDPI") - { - config.setValue("allowHighDPI", mAllowHighDPICheckBox->isSelected()); - } -#endif // USE_SDL2 -#if defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) - else if (id == "detect") - { - TestMain *test = graphicsManager.startDetection(); - if (test != nullptr) - { - Configuration &conf = test->getConfig(); - const int val = conf.getValueInt("opengl", -1); - if (val >= 0 && CAST_U32(val) - < sizeof(renderToIndex) / sizeof(int)) - { - mOpenGLDropDown->setSelected(renderToIndex[val]); - } - config.setValue("textureSize", - conf.getValue("textureSize", "1024,1024,1024,1024,1024,1024")); - config.setValue("testInfo", conf.getValue("testInfo", "")); - delete test; - } - } -#endif // defined(USE_OPENGL) && !defined(ANDROID) && !defined(__APPLE__) -} diff --git a/src/gui/widgets/tabs/setup_video.h b/src/gui/widgets/tabs/setup_video.h deleted file mode 100644 index e327a29d8..000000000 --- a/src/gui/widgets/tabs/setup_video.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_WIDGETS_TABS_SETUP_VIDEO_H -#define GUI_WIDGETS_TABS_SETUP_VIDEO_H - -#include "gui/widgets/tabs/setuptab.h" - -#include "listeners/keylistener.h" - -class Button; -class CheckBox; -class DropDown; -class Label; -class ListBox; -class ModeListModel; -class OpenGLListModel; -class Slider; -class TextDialog; - -class Setup_Video final : public SetupTab, - public KeyListener -{ - public: - explicit Setup_Video(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Video) - - ~Setup_Video(); - - void apply() override final; - - void cancel() override final; - - void action(const ActionEvent &event) override final; - - private: - bool mFullScreenEnabled; - RenderType mOpenGLEnabled; - int mFps; - int mAltFps; - ModeListModel *mModeListModel; - OpenGLListModel *mOpenGLListModel; - ListBox *mModeList; - CheckBox *mFsCheckBox; - DropDown *mOpenGLDropDown; - CheckBox *mFpsCheckBox; - Slider *mFpsSlider; - Label *mFpsLabel; - Slider *mAltFpsSlider; - Label *mAltFpsLabel; -#if !defined(ANDROID) && !defined(__APPLE__) && !defined(__native_client__) - Button *mDetectButton; -#endif // !defined(ANDROID) && !defined(__APPLE__) && - // !defined(__native_client__) - TextDialog *mDialog; - bool mCustomCursorEnabled; - bool mEnableResize; - bool mNoFrame; -#ifdef USE_SDL2 - bool mAllowHighDPI; - CheckBox *mAllowHighDPICheckBox; -#endif // USE_SDL2 - CheckBox *mCustomCursorCheckBox; - CheckBox *mEnableResizeCheckBox; - CheckBox *mNoFrameCheckBox; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_VIDEO_H diff --git a/src/gui/widgets/tabs/setup_visual.cpp b/src/gui/widgets/tabs/setup_visual.cpp deleted file mode 100644 index de5cc8b3b..000000000 --- a/src/gui/widgets/tabs/setup_visual.cpp +++ /dev/null @@ -1,252 +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/>. - */ - -#include "gui/widgets/tabs/setup_visual.h" - -#include "gui/windowmanager.h" - -#include "gui/models/namesmodel.h" - -#include "gui/widgets/containerplacer.h" -#include "gui/widgets/layouthelper.h" -#include "gui/widgets/scrollarea.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "debug.h" - -static const int speachListSize = 4; - -static const char *const speachList[] = -{ - // TRANSLATORS: speach type - N_("No text"), - // TRANSLATORS: speach type - N_("Text"), - // TRANSLATORS: speach type - N_("Bubbles, no names"), - // TRANSLATORS: speach type - N_("Bubbles with names") -}; - -static const int ambientFxListSize = 3; - -static const char *const ambientFxList[] = -{ - // TRANSLATORS: ambient effect type - N_("off"), - // TRANSLATORS: ambient effect type - N_("low"), - // TRANSLATORS: ambient effect type - N_("high") -}; - -static const int particleTypeListSize = 3; - -static const char *const particleTypeList[] = -{ - // TRANSLATORS: patricle effects type - N_("best quality"), - // TRANSLATORS: patricle effects type - N_("normal"), - // TRANSLATORS: patricle effects type - N_("best performance") -}; - -static const int vSyncListSize = 3; - -static const char *const vSyncList[] = -{ - // TRANSLATORS: vsync type - N_("default"), - // TRANSLATORS: vsync type - N_("off"), - // TRANSLATORS: vsync type - N_("on") -}; - -Setup_Visual::Setup_Visual(const Widget2 *const widget) : - SetupTabScroll(widget), - mSpeachList(new NamesModel), - mAmbientFxList(new NamesModel), - mParticleList(new SetupItemNames), - mParticleTypeList(new NamesModel), - mVSyncList(new NamesModel), - mScaleList(new NamesModel) -{ - // TRANSLATORS: settings tab name - setName(_("Visual")); - // Do the layout - LayoutHelper h(this); - ContainerPlacer place = h.getPlacer(0, 0); - place(0, 0, mScroll, 10, 10); - - mPreferredFirstItemSize = 150; - - // TRANSLATORS: settings option - new SetupItemLabel(_("Scale"), "", this); - - for (int f = 1; f <= 7; f ++) - { - // TRANSLATORS: particle details - mScaleList->add(toString(f) + "x"); - } - // TRANSLATORS: settings option - new SetupItemSliderInt(_("Scale"), "", - "scale", this, "scaleEvent", mScaleList, 1); - - // TRANSLATORS: settings option - new SetupItemLabel(_("Notifications"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show pickup notifications in chat"), "", - "showpickupchat", this, "showpickupchatEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show pickup notifications as particle effects"), - "", "showpickupparticle", this, "showpickupparticleEvent"); - - // TRANSLATORS: settings option - new SetupItemLabel(_("Effects"), "", this); - -#ifndef ANDROID - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Grab mouse and keyboard input"), - "", "grabinput", this, "grabinputEvent"); -#endif // ANDROID - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Blurring textures (OpenGL)"), - "", "blur", this, "blurEvent"); - - // TRANSLATORS: settings option - new SetupItemSlider(_("Gui opacity"), "", "guialpha", - this, "guialphaEvent", 0.1, 1.01, 0.1, 150, - OnTheFly_true, - MainConfig_true); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable gui opacity"), - "", "enableGuiOpacity", this, "enableGuiOpacityEvent"); - - mSpeachList->fillFromArray(&speachList[0], speachListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Overhead text"), "", "speech", this, - "speechEvent", mSpeachList, 200); - - mAmbientFxList->fillFromArray(&ambientFxList[0], ambientFxListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Ambient FX"), "", "OverlayDetail", this, - "OverlayDetailEvent", mAmbientFxList, 100); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show particle effects"), "", - "particleeffects", this, "particleeffectsEvent"); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Show particle effects from maps"), "", - "mapparticleeffects", this, "mapparticleeffectsEvent"); - - // TRANSLATORS: particle details - mParticleList->push_back(_("low")); - // TRANSLATORS: particle details - mParticleList->push_back(_("medium")); - // TRANSLATORS: particle details - mParticleList->push_back(_("high")); - // TRANSLATORS: particle details - mParticleList->push_back(_("max")); - // TRANSLATORS: settings option - (new SetupItemSlider2(_("Particle detail"), "", "particleEmitterSkip", - this, "particleEmitterSkipEvent", 0, 3, 1, mParticleList, - OnTheFly_true, - MainConfig_true, - DoNotAlign_false))->setInvertValue(3); - - mParticleTypeList->fillFromArray(&particleTypeList[0], - particleTypeListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Particle physics"), "", "particleFastPhysics", - this, "particleFastPhysicsEvent", mParticleTypeList, 200); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Gamma"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Enable gamma control"), - "", "enableGamma", this, "enableGammaEvent"); - - // TRANSLATORS: settings option - new SetupItemSlider(_("Gamma"), "", "gamma", - this, "gammeEvent", 1, 20, 1, 350, - OnTheFly_true, - MainConfig_true); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Other"), "", this); - - mVSyncList->fillFromArray(&vSyncList[0], vSyncListSize); - // TRANSLATORS: settings option - new SetupItemDropDown(_("Vsync"), "", "vsync", this, - "vsyncEvent", mVSyncList, 100); - -#if defined(WIN32) || defined(__APPLE__) - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Center game window"), - "", "centerwindow", this, "centerwindowEvent"); -#endif // defined(WIN32) || defined(__APPLE__) - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Allow screensaver to run"), - "", "allowscreensaver", this, "allowscreensaverEvent"); - - - // TRANSLATORS: settings group - new SetupItemLabel(_("Screenshots"), "", this); - - // TRANSLATORS: settings option - new SetupItemCheckBox(_("Add water mark into screenshots"), - "", "addwatermark", this, "addwatermarkEvent"); - - setDimension(Rect(0, 0, 550, 350)); -} - -Setup_Visual::~Setup_Visual() -{ - delete2(mSpeachList); - delete2(mAmbientFxList); - delete2(mParticleList); - delete2(mParticleTypeList); - delete2(mVSyncList); - delete2(mScaleList); -} - -void Setup_Visual::apply() -{ - SetupTabScroll::apply(); - WindowManager::applyGrabMode(); -#ifndef WIN32 - WindowManager::applyScale(); -#endif // WIN32 -} diff --git a/src/gui/widgets/tabs/setup_visual.h b/src/gui/widgets/tabs/setup_visual.h deleted file mode 100644 index 08d1c7848..000000000 --- a/src/gui/widgets/tabs/setup_visual.h +++ /dev/null @@ -1,51 +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_WIDGETS_TABS_SETUP_VISUAL_H -#define GUI_WIDGETS_TABS_SETUP_VISUAL_H - -#include "gui/widgets/setupitem.h" - -#include "gui/widgets/tabs/setuptabscroll.h" - -class NamesModel; - -class Setup_Visual final : public SetupTabScroll -{ - public: - explicit Setup_Visual(const Widget2 *const widget); - - A_DELETE_COPY(Setup_Visual) - - ~Setup_Visual(); - - void apply() override final; - - private: - NamesModel *mSpeachList; - NamesModel *mAmbientFxList; - SetupItemNames *mParticleList; - NamesModel *mParticleTypeList; - NamesModel *mVSyncList; - NamesModel *mScaleList; -}; - -#endif // GUI_WIDGETS_TABS_SETUP_VISUAL_H diff --git a/src/gui/widgets/tabs/setuptab.cpp b/src/gui/widgets/tabs/setuptab.cpp deleted file mode 100644 index d5f43b4b8..000000000 --- a/src/gui/widgets/tabs/setuptab.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * The ManaPlus Client - * 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/>. - */ - -#include "gui/widgets/tabs/setuptab.h" - -#include "debug.h" - -SetupTab::SetupTab(const Widget2 *const widget) : - Container(widget), - ActionListener(), - WidgetListener(), - mName() -{ - setOpaque(Opaque_false); - addWidgetListener(this); - setSelectable(false); -} - -void SetupTab::externalUpdated() -{ -} - -void SetupTab::externalUnloaded() -{ -} diff --git a/src/gui/widgets/tabs/setuptab.h b/src/gui/widgets/tabs/setuptab.h deleted file mode 100644 index 6b1082088..000000000 --- a/src/gui/widgets/tabs/setuptab.h +++ /dev/null @@ -1,74 +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_WIDGETS_TABS_SETUPTAB_H -#define GUI_WIDGETS_TABS_SETUPTAB_H - -#include "gui/widgets/container.h" - -#include "listeners/actionlistener.h" -#include "listeners/widgetlistener.h" - -#include "localconsts.h" - -/** - * A container for the contents of a tab in the setup window. - */ -class SetupTab notfinal : public Container, - public ActionListener, - public WidgetListener -{ - public: - A_DELETE_COPY(SetupTab) - - const std::string &getName() const noexcept2 A_WARN_UNUSED - { return mName; } - - /** - * Called when the Apply button is pressed in the setup window. - */ - virtual void apply() = 0; - - /** - * Called when the Cancel button is pressed in the setup window. - */ - virtual void cancel() = 0; - - virtual void externalUpdated() A_CONST; - - virtual void externalUnloaded() A_CONST; - - protected: - explicit SetupTab(const Widget2 *const widget); - - /** - * Sets the name displayed on the tab. Should be set in the - * constructor of a subclass. - */ - void setName(const std::string &name) noexcept2 - { mName = name; } - - private: - std::string mName; -}; - -#endif // GUI_WIDGETS_TABS_SETUPTAB_H diff --git a/src/gui/widgets/tabs/setuptabscroll.cpp b/src/gui/widgets/tabs/setuptabscroll.cpp deleted file mode 100644 index 0cb623687..000000000 --- a/src/gui/widgets/tabs/setuptabscroll.cpp +++ /dev/null @@ -1,163 +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/>. - */ - -#include "gui/widgets/tabs/setuptabscroll.h" - -#include "gui/widgets/scrollarea.h" -#include "gui/widgets/setupitem.h" -#include "gui/widgets/vertcontainer.h" - -#include "utils/delete2.h" - -#include "debug.h" - -SetupTabScroll::SetupTabScroll(const Widget2 *const widget) : - SetupTab(widget), - mContainer(new VertContainer(this, 25, false, 8)), - mScroll(new ScrollArea(this, mContainer, Opaque_false)), - mItems(), - mAllItems(), - mPreferredFirstItemSize(200) -{ - mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_NEVER); - mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_AUTO); - mScroll->setSelectable(false); - mContainer->setSelectable(false); -} - -SetupTabScroll::~SetupTabScroll() -{ - mScroll = nullptr; - delete2(mContainer); - removeItems(); -} - -void SetupTabScroll::removeItems() -{ - std::set<SetupItem*>::iterator it = mAllItems.begin(); - const std::set<SetupItem*>::iterator it_end = mAllItems.end(); - while (it != it_end) - { - delete *it; - ++ it; - } - mAllItems.clear(); - - mItems.clear(); -} - -void SetupTabScroll::clear() -{ - removeItems(); - mContainer->removeControls(); - mContainer->clear(); -} - -void SetupTabScroll::addControl(SetupItem *const widget) -{ - if (widget == nullptr) - return; - const std::string actionId = widget->getActionEventId(); - if (!actionId.empty()) - { - const std::map<std::string, SetupItem*>::iterator iter - = mItems.find(actionId); - if (iter != mItems.end()) - { - delete (*iter).second; - mItems.erase(iter); - } - mItems[actionId] = widget; - } - mAllItems.insert(widget); -} - -void SetupTabScroll::addControl(SetupItem *const widget, - const std::string &event) -{ - const std::map<std::string, SetupItem*>::iterator iter - = mItems.find(event); - if (iter != mItems.end()) - { - delete (*iter).second; - mItems.erase(iter); - } - mItems[event] = widget; - mAllItems.insert(widget); -} - -void SetupTabScroll::apply() -{ - for (std::map<std::string, SetupItem*>::const_iterator - iter = mItems.begin(), iter_end = mItems.end(); - iter != iter_end; ++ iter) - { - if ((*iter).second != nullptr) - (*iter).second->apply((*iter).first); - } -} - -void SetupTabScroll::cancel() -{ - for (std::map<std::string, SetupItem*>::const_iterator - iter = mItems.begin(), iter_end = mItems.end(); - iter != iter_end; ++ iter) - { - if ((*iter).second != nullptr) - (*iter).second->cancel((*iter).first); - } -} - -void SetupTabScroll::externalUpdated() -{ - for (std::map<std::string, SetupItem*>::const_iterator - iter = mItems.begin(), iter_end = mItems.end(); - iter != iter_end; ++ iter) - { - SetupItem *const widget = (*iter).second; - if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false) - widget->externalUpdated((*iter).first); - } -} - -void SetupTabScroll::externalUnloaded() -{ - for (std::map<std::string, SetupItem*>::const_iterator - iter = mItems.begin(), iter_end = mItems.end(); - iter != iter_end; ++ iter) - { - SetupItem *const widget = (*iter).second; - if ((widget != nullptr) && widget->isMainConfig() == MainConfig_false) - widget->externalUnloaded((*iter).first); - } -} - -void SetupTabScroll::widgetResized(const Event &event A_UNUSED) -{ - mScroll->setWidth(getWidth() - 12); - mScroll->setHeight(getHeight() - 12 - 12); -} - -void SetupTabScroll::reread(const std::string &name) -{ - SetupItem *const item = mItems[name + "Event"]; - if (item != nullptr) - item->rereadValue(); -} diff --git a/src/gui/widgets/tabs/setuptabscroll.h b/src/gui/widgets/tabs/setuptabscroll.h deleted file mode 100644 index 655b98c85..000000000 --- a/src/gui/widgets/tabs/setuptabscroll.h +++ /dev/null @@ -1,81 +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_WIDGETS_TABS_SETUPTABSCROLL_H -#define GUI_WIDGETS_TABS_SETUPTABSCROLL_H - -#include "gui/widgets/tabs/setuptab.h" - -#include "localconsts.h" - -class SetupItem; -class ScrollArea; -class VertContainer; - -class SetupTabScroll notfinal : public SetupTab -{ - public: - explicit SetupTabScroll(const Widget2 *const widget); - - A_DELETE_COPY(SetupTabScroll) - - virtual ~SetupTabScroll(); - - void addControl(SetupItem *const widget); - - void addControl(SetupItem *const widget, const std::string &event); - - VertContainer *getContainer() const noexcept2 A_WARN_UNUSED - { return mContainer; } - - void apply() override; - - void cancel() override final; - - void externalUpdated() override; - - void externalUnloaded() override; - - void action(const ActionEvent &event A_UNUSED) override final - { } - - int getPreferredFirstItemSize() const noexcept2 A_WARN_UNUSED - { return mPreferredFirstItemSize; } - - void widgetResized(const Event &event) override final; - - void reread(const std::string &name); - - void clear() override final; - - const std::set<SetupItem*> &getAllItems() const noexcept2 - { return mAllItems; } - - protected: - void removeItems(); - - VertContainer *mContainer; - ScrollArea *mScroll; - std::map<std::string, SetupItem*> mItems; - std::set<SetupItem*> mAllItems; - int mPreferredFirstItemSize; -}; - -#endif // GUI_WIDGETS_TABS_SETUPTABSCROLL_H diff --git a/src/gui/widgets/tabs/shortcuttab.h b/src/gui/widgets/tabs/shortcuttab.h deleted file mode 100644 index 61652777f..000000000 --- a/src/gui/widgets/tabs/shortcuttab.h +++ /dev/null @@ -1,47 +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_WIDGETS_TABS_SHORTCUTTAB_H -#define GUI_WIDGETS_TABS_SHORTCUTTAB_H - -#include "gui/widgets/tabs/tab.h" - -#include "localconsts.h" - -class ShortcutContainer; - -class ShortcutTab final : public Tab -{ - public: - ShortcutTab(const Widget2 *const widget, - const std::string &name, - ShortcutContainer *const content) : - Tab(widget), - mContent(content) - { - setCaption(name); - } - - A_DELETE_COPY(ShortcutTab) - - ShortcutContainer* mContent; -}; - -#endif // GUI_WIDGETS_TABS_SHORTCUTTAB_H diff --git a/src/gui/widgets/tabs/skilltab.h b/src/gui/widgets/tabs/skilltab.h deleted file mode 100644 index 9086a4d0c..000000000 --- a/src/gui/widgets/tabs/skilltab.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_WIDGETS_TABS_SKILLTAB_H -#define GUI_WIDGETS_TABS_SKILLTAB_H - -#include "gui/windows/skilldialog.h" - -#include "gui/widgets/skilllistbox.h" -#include "gui/widgets/skillrectanglelistbox.h" - -#include "gui/widgets/tabs/tab.h" - -#include "localconsts.h" - -class SkillTab final : public Tab -{ - public: - SkillTab(const Widget2 *const widget, - const std::string &name, - SkillListBox *const listBox) : - Tab(widget), - mListBox(listBox), - mRectangleListBox(nullptr) - { - setCaption(name); - } - - SkillTab(const Widget2 *const widget, - const std::string &name, - SkillRectangleListBox *const listBox) : - Tab(widget), - mListBox(nullptr), - mRectangleListBox(listBox) - { - setCaption(name); - } - - A_DELETE_COPY(SkillTab) - - ~SkillTab() - { - delete2(mListBox) - delete2(mRectangleListBox) - } - - SkillInfo *getSelectedInfo() const - { - if (mListBox != nullptr) - return mListBox->getSelectedInfo(); - else if (mRectangleListBox != nullptr) - return mRectangleListBox->getSelectedInfo(); - else - return nullptr; - } - - protected: - void setCurrent() override - { - if (skillDialog != nullptr) - skillDialog->updateTabSelection(); - } - - private: - SkillListBox *mListBox; - SkillRectangleListBox *mRectangleListBox; -}; - -#endif // GUI_WIDGETS_TABS_SKILLTAB_H diff --git a/src/gui/widgets/tabs/socialattacktab.h b/src/gui/widgets/tabs/socialattacktab.h deleted file mode 100644 index e876a60ae..000000000 --- a/src/gui/widgets/tabs/socialattacktab.h +++ /dev/null @@ -1,77 +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_WIDGETS_TABS_SOCIALATTACKTAB_H -#define GUI_WIDGETS_TABS_SOCIALATTACKTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "being/localplayer.h" - -#include "gui/models/beingslistmodel.h" - -#include "gui/widgets/tabs/socialtabbase.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "localconsts.h" - -class SocialAttackTab final : public SocialTab -{ - public: - SocialAttackTab(const Widget2 *const widget, - const Opaque showBackground) : - SocialTab(widget), - mBeings(new BeingsListModel) - { - createControls(mBeings, showBackground); - - // TRANSLATORS: Attack filter tab name in social window. - // TRANSLATORS: Should be small - setCaption(_("Atk")); - mMenuAction = "attack"; - } - - A_DELETE_COPY(SocialAttackTab) - - ~SocialAttackTab() - { - delete2(mList) - delete2(mScroll) - delete2(mBeings) - } - - void updateList() override final - { - updateAtkListStart(); - // TRANSLATORS: mobs group name in social window - addAvatars(PriorityAttackMob, _("Priority mobs"), PRIORITY); - // TRANSLATORS: mobs group name in social window - addAvatars(AttackMob, _("Attack mobs"), ATTACK); - // TRANSLATORS: mobs group name in social window - addAvatars(IgnoreAttackMob, _("Ignore mobs"), IGNORE_); - } - - private: - BeingsListModel *mBeings; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALATTACKTAB_H diff --git a/src/gui/widgets/tabs/socialfriendsfunctor.h b/src/gui/widgets/tabs/socialfriendsfunctor.h deleted file mode 100644 index e68647a77..000000000 --- a/src/gui/widgets/tabs/socialfriendsfunctor.h +++ /dev/null @@ -1,59 +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_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H -#define GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H - -#include "avatar.h" - -#include "utils/stringutils.h" - -#include "localconsts.h" - -class SortFriendsFunctor final -{ - public: - A_DEFAULT_COPY(SortFriendsFunctor) - - bool operator() (const Avatar *const m1, - const Avatar *const m2) const - { - if ((m1 == nullptr) || (m2 == nullptr)) - return false; - - if (m1->getOnline() != m2->getOnline()) - { - return static_cast<int>(m1->getOnline()) > - static_cast<int>(m2->getOnline()); - } - - if (m1->getName() != m2->getName()) - { - std::string s1 = m1->getName(); - std::string s2 = m2->getName(); - toLower(s1); - toLower(s2); - return s1 < s2; - } - return false; - } -}; - -#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSFUNCTOR_H diff --git a/src/gui/widgets/tabs/socialfriendstab.h b/src/gui/widgets/tabs/socialfriendstab.h deleted file mode 100644 index d1cd942cd..000000000 --- a/src/gui/widgets/tabs/socialfriendstab.h +++ /dev/null @@ -1,127 +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_WIDGETS_TABS_SOCIALFRIENDSTAB_H -#define GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "actormanager.h" - -#include "being/playerrelations.h" - -#include "gui/models/beingslistmodel.h" - -#include "gui/windows/whoisonline.h" - -#include "gui/widgets/tabs/socialfriendsfunctor.h" - -#include "utils/delete2.h" -#include "utils/foreach.h" -#include "utils/gettext.h" - -#include "localconsts.h" - -class SocialFriendsTab final : public SocialTab -{ - public: - SocialFriendsTab(const Widget2 *const widget, - const std::string &name, - const Opaque showBackground) : - SocialTab(widget), - mBeings(new BeingsListModel), - mFriendSorter() - { - createControls(mBeings, showBackground); - - getPlayersAvatars(); - setCaption(name); - mMenuAction = "friends"; - } - - A_DELETE_COPY(SocialFriendsTab) - - ~SocialFriendsTab() - { - delete2(mList) - delete2(mScroll) - delete2(mBeings) - } - - void updateList() override final - { - getPlayersAvatars(); - } - - void getPlayersAvatars() - { - if (actorManager == nullptr) - return; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - - STD_VECTOR<Avatar*>::iterator ia = avatars->begin(); - while (ia != avatars->end()) - { - delete *ia; - ++ ia; - } - avatars->clear(); - - const StringVect *const players - = playerRelations.getPlayersByRelation(Relation::FRIEND); - - const std::set<std::string> &players2 - = whoIsOnline->getOnlineNicks(); - - if (players == nullptr) - return; - - int online = 0; - int total = 0; - - FOR_EACHP (StringVectCIter, it, players) - { - Avatar *const ava = new Avatar(*it); - if (actorManager->findBeingByName(*it, ActorType::Player) != - nullptr || players2.find(*it) != players2.end()) - { - ava->setOnline(true); - online ++; - } - total ++; - avatars->push_back(ava); - } - std::sort(avatars->begin(), avatars->end(), mFriendSorter); - delete players; - - // TRANSLATORS: social window label - mCounterString = strprintf(_("Friends: %u/%u"), - CAST_U32(online), - CAST_U32(total)); - updateCounter(); - } - - private: - BeingsListModel *mBeings; - SortFriendsFunctor mFriendSorter; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALFRIENDSTAB_H diff --git a/src/gui/widgets/tabs/socialguildtab.h b/src/gui/widgets/tabs/socialguildtab.h deleted file mode 100644 index 8652a54fe..000000000 --- a/src/gui/widgets/tabs/socialguildtab.h +++ /dev/null @@ -1,179 +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_WIDGETS_TABS_SOCIALGUILDTAB_H -#define GUI_WIDGETS_TABS_SOCIALGUILDTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "being/localplayer.h" - -#include "utils/delete2.h" -#include "utils/foreach.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "net/guildhandler.h" - -#include "localconsts.h" - -class SocialGuildTab final : public SocialTab, - public ActionListener -{ - public: - SocialGuildTab(const Widget2 *const widget, - Guild *const guild, - const Opaque showBackground) : - SocialTab(widget), - ActionListener(), - mGuild(guild) - { - // TRANSLATORS: tab in social window - setCaption(_("Guild")); - - setTabColor(&getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB), - &getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB_OUTLINE)); - setHighlightedTabColor(&getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_SELECTED), - &getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); - - createControls(guild, showBackground); - mMenuAction = "guild"; - } - - A_DELETE_COPY(SocialGuildTab) - - ~SocialGuildTab() - { - delete2(mList) - delete2(mScroll) - } - - void action(const ActionEvent &event) override final - { - const std::string &eventId = event.getId(); - if (eventId == "do invite") - { - const std::string name = mInviteDialog->getText(); - guildHandler->invite(name); - - if (localChatTab != nullptr) - { - localChatTab->chatLog(strprintf( - // TRANSLATORS: chat message - _("Invited user %s to guild %s."), - name.c_str(), - mGuild->getName().c_str()), - ChatMsgType::BY_SERVER); - } - mInviteDialog = nullptr; - } - else if (eventId == "~do invite") - { - mInviteDialog = nullptr; - } - else if (eventId == "yes") - { - guildHandler->leave(mGuild->getId()); - if (localChatTab != nullptr) - { - localChatTab->chatLog(strprintf( - // TRANSLATORS: chat message - _("Guild %s quit requested."), - mGuild->getName().c_str()), - ChatMsgType::BY_SERVER); - } - mConfirmDialog = nullptr; - } - else if (eventId == "~yes") - { - mConfirmDialog = nullptr; - } - } - - void invite() override final - { - CREATEWIDGETV(mInviteDialog, TextDialog, - // TRANSLATORS: guild invite message - _("Member Invite to Guild"), - // TRANSLATORS: guild invite message - strprintf(_("Who would you like to invite to guild %s?"), - mGuild->getName().c_str()), socialWindow); - mInviteDialog->setActionEventId("do invite"); - mInviteDialog->addActionListener(this); - } - - void leave() override final - { - CREATEWIDGETV(mConfirmDialog, ConfirmDialog, - // TRANSLATORS: guild leave message - _("Leave Guild?"), - // TRANSLATORS: guild leave message - strprintf(_("Are you sure you want to leave guild %s?"), - mGuild->getName().c_str()), SOUND_REQUEST, socialWindow); - mConfirmDialog->addActionListener(this); - } - - void buildCounter(const int online0, const int total0) override final - { - if ((online0 != 0) || (total0 != 0)) - { - // TRANSLATORS: social window label - mCounterString = strprintf(_("Members: %u/%u"), - CAST_U32(online0), - CAST_U32(total0)); - } - else - { - if (localPlayer == nullptr) - return; - - const Guild *const guild = localPlayer->getGuild(); - if (guild == nullptr) - return; - - const Guild::MemberList *const members = guild->getMembers(); - int online = 0; - int total = 0; - FOR_EACHP (Guild::MemberList::const_iterator, it, members) - { - if ((*it)->getOnline()) - online ++; - total ++; - } - - // TRANSLATORS: social window label - mCounterString = strprintf(_("Players: %u/%u"), - CAST_U32(online), - CAST_U32(total)); - } - updateCounter(); - } - - private: - Guild *mGuild; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALGUILDTAB_H diff --git a/src/gui/widgets/tabs/socialguildtab2.h b/src/gui/widgets/tabs/socialguildtab2.h deleted file mode 100644 index ff8544232..000000000 --- a/src/gui/widgets/tabs/socialguildtab2.h +++ /dev/null @@ -1,106 +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_WIDGETS_TABS_SOCIALGUILDTAB2_H -#define GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "guild.h" - -#include "being/localplayer.h" - -#include "utils/delete2.h" -#include "utils/foreach.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "localconsts.h" - -class SocialGuildTab2 final : public SocialTab, - public ActionListener -{ - public: - SocialGuildTab2(const Widget2 *const widget, - Guild *const guild, - const Opaque showBackground) : - SocialTab(widget), - ActionListener() - { - // TRANSLATORS: tab in social window - setCaption(_("Guild")); - - setTabColor(&getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB), - &getThemeColor(ThemeColorId::GUILD_SOCIAL_TAB_OUTLINE)); - setHighlightedTabColor(&getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED), - &getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_SELECTED), - &getThemeColor( - ThemeColorId::GUILD_SOCIAL_TAB_SELECTED_OUTLINE)); - - createControls(guild, showBackground); - mMenuAction = "guild"; - } - - A_DELETE_COPY(SocialGuildTab2) - - ~SocialGuildTab2() - { - delete2(mList) - delete2(mScroll) - } - - void action(const ActionEvent &event A_UNUSED) override final - { - } - - void buildCounter(const int online0 A_UNUSED, - const int total0 A_UNUSED) override final - { - if (localPlayer == nullptr) - return; - - const Guild *const guild = localPlayer->getGuild(); - if (guild == nullptr) - return; - - const Guild::MemberList *const members = guild->getMembers(); - int online = 0; - int total = 0; - FOR_EACHP (Guild::MemberList::const_iterator, it, members) - { - if ((*it)->getOnline()) - online ++; - total ++; - } - - // TRANSLATORS: social window label - mCounterString = strprintf(_("Players: %u/%u"), - CAST_U32(online), - CAST_U32(total)); - updateCounter(); - } -}; - -#endif // GUI_WIDGETS_TABS_SOCIALGUILDTAB2_H diff --git a/src/gui/widgets/tabs/socialnavigationtab.h b/src/gui/widgets/tabs/socialnavigationtab.h deleted file mode 100644 index 1b049f055..000000000 --- a/src/gui/widgets/tabs/socialnavigationtab.h +++ /dev/null @@ -1,308 +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_WIDGETS_TABS_SOCIALNAVIGATIONTAB_H -#define GUI_WIDGETS_TABS_SOCIALNAVIGATIONTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "actormanager.h" -#include "configuration.h" - -#include "gui/models/beingslistmodel.h" - -#include "gui/windows/outfitwindow.h" - -#include "being/localplayer.h" - -#include "input/keyboardconfig.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "resources/map/map.h" -#include "resources/map/mapitem.h" -#include "resources/map/speciallayer.h" - -#include "localconsts.h" - -class Avatar; - -class SocialNavigationTab final : public SocialTab -{ - public: - SocialNavigationTab(const Widget2 *const widget, - const Opaque showBackground) : - SocialTab(widget), - mBeings(new BeingsListModel) - { - createControls(mBeings, showBackground); - - // TRANSLATORS: Navigation tab name in social window. - // TRANSLATORS: Should be small - setCaption(_("Nav")); - mMenuAction = "navigation"; - } - - A_DELETE_COPY(SocialNavigationTab) - - ~SocialNavigationTab() - { - delete2(mList) - delete2(mScroll) - delete2(mBeings) - } - - void updateList() override final - { - if ((socialWindow == nullptr) || (localPlayer == nullptr)) - return; - - const Map *const map = socialWindow->getMap(); - if ((map == nullptr) || map->empty()) - return; - - if (socialWindow->getProcessedPortals()) - return; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - STD_VECTOR<MapItem*> portals = map->getPortals(); - - STD_VECTOR<MapItem*>::const_iterator i = portals.begin(); - const SpecialLayer *const specialLayer = map->getSpecialLayer(); - - STD_VECTOR<Avatar*>::iterator ia = avatars->begin(); - - while (ia != avatars->end()) - { - delete *ia; - ++ ia; - } - - avatars->clear(); - - int online = 0; - int total = 0; - - int idx = 0; - while (i != portals.end()) - { - MapItem *portal = *i; - if (portal == nullptr) - continue; - - const int x = portal->getX(); - const int y = portal->getY(); - - const std::string name = strprintf("%s [%d %d]", - portal->getComment().c_str(), x, y); - - Avatar *const ava = new Avatar(name); - if (localPlayer != nullptr) - ava->setOnline(localPlayer->isReachable(x, y, true)); - else - ava->setOnline(false); - ava->setLevel(-1); - ava->setType(portal->getType()); - ava->setX(x); - ava->setY(y); - avatars->push_back(ava); - - if (ava->getOnline()) - online ++; - total ++; - - if (config.getBoolValue("drawHotKeys") - && idx < 80 && (outfitWindow != nullptr)) - { - Being *const being = actorManager - ->findPortalByTile(x, y); - if (being != nullptr) - { - being->setName(KeyboardConfig::getKeyShortString( - OutfitWindow::keyName(idx))); - } - - if (specialLayer != nullptr) - { - portal = specialLayer->getTile( - ava->getX(), ava->getY()); - if (portal != nullptr) - { - portal->setName(KeyboardConfig::getKeyShortString( - OutfitWindow::keyName(idx))); - } - } - } - - ++i; - idx ++; - } - if (socialWindow != nullptr) - socialWindow->setProcessedPortals(true); - - // TRANSLATORS: social window label - mCounterString = strprintf(_("Portals: %u/%u"), - CAST_U32(online), - CAST_U32(total)); - updateCounter(); - } - - void selectIndex(const unsigned num) override final - { - if (localPlayer == nullptr) - return; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - if (avatars->size() <= CAST_SIZE(num)) - return; - - const Avatar *const ava = avatars->at(num); - if ((ava != nullptr) && (localPlayer != nullptr)) - localPlayer->navigateTo(ava->getX(), ava->getY()); - } - - void updateNames() - { - if (socialWindow == nullptr) - return; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - - const Map *const map = socialWindow->getMap(); - if (map == nullptr) - return; - - STD_VECTOR<Avatar*>::const_iterator i = avatars->begin(); - const STD_VECTOR<Avatar*>::const_iterator i_end = avatars->end(); - while (i != i_end) - { - Avatar *const ava = *i; - if (ava == nullptr) - break; - - const MapItem *const item = map->findPortalXY( - ava->getX(), ava->getY()); - if (item != nullptr) - { - const std::string name = strprintf("%s [%d %d]", - item->getComment().c_str(), - item->getX(), item->getY()); - ava->setName(name); - ava->setOriginalName(name); - } - - ++i; - } - } - - int getPortalIndex(const int x, const int y) - { - if (socialWindow == nullptr) - return -1; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - const Map *const map = socialWindow->getMap(); - if (map == nullptr) - return -1; - - STD_VECTOR<Avatar*>::const_iterator i = avatars->begin(); - const STD_VECTOR<Avatar*>::const_iterator i_end = avatars->end(); - unsigned num = 0; - while (i != i_end) - { - const Avatar *const ava = *i; - if (ava == nullptr) - break; - - if (ava->getX() == x && ava->getY() == y) - return num; - - ++i; - num ++; - } - return -1; - } - - void addPortal(const int x, const int y) - { - if ((socialWindow == nullptr) || (localPlayer == nullptr)) - return; - - const Map *const map = socialWindow->getMap(); - if (map == nullptr) - return; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - const MapItem *const portal = map->findPortalXY(x, y); - if (portal == nullptr) - return; - - const std::string name = strprintf("%s [%d %d]", - portal->getComment().c_str(), x, y); - - Avatar *const ava = new Avatar(name); - if (localPlayer != nullptr) - ava->setOnline(localPlayer->isReachable(x, y, true)); - else - ava->setOnline(false); - ava->setLevel(-1); - ava->setType(portal->getType()); - ava->setX(x); - ava->setY(y); - avatars->push_back(ava); - } - - void removePortal(const int x, const int y) - { - if ((socialWindow == nullptr) || (localPlayer == nullptr)) - return; - - const Map *const map = socialWindow->getMap(); - if (map == nullptr) - return; - - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - STD_VECTOR<Avatar*>::iterator i = avatars->begin(); - const STD_VECTOR<Avatar*>::iterator i_end = avatars->end(); - - while (i != i_end) - { - Avatar *ava = (*i); - - if (ava == nullptr) - break; - - if (ava->getX() == x && ava->getY() == y) - { - delete ava; - avatars->erase(i); - return; - } - - ++ i; - } - } - - private: - BeingsListModel *mBeings; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALNAVIGATIONTAB_H diff --git a/src/gui/widgets/tabs/socialpartytab.h b/src/gui/widgets/tabs/socialpartytab.h deleted file mode 100644 index d7f22c1f7..000000000 --- a/src/gui/widgets/tabs/socialpartytab.h +++ /dev/null @@ -1,171 +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_WIDGETS_TABS_SOCIALPARTYTAB_H -#define GUI_WIDGETS_TABS_SOCIALPARTYTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "party.h" - -#include "being/localplayer.h" - -#include "net/partyhandler.h" - -#include "utils/delete2.h" -#include "utils/foreach.h" -#include "utils/gettext.h" -#include "utils/stringutils.h" - -#include "localconsts.h" - -class SocialPartyTab final : public SocialTab, - public ActionListener -{ - public: - SocialPartyTab(const Widget2 *const widget, - Party *const party, - const Opaque showBackground) : - SocialTab(widget), - ActionListener(), - mParty(party) - { - // TRANSLATORS: tab in social window - setCaption(_("Party")); - - setTabColor(&getThemeColor(ThemeColorId::PARTY_SOCIAL_TAB), - &getThemeColor(ThemeColorId::PARTY_SOCIAL_TAB_OUTLINE)); - setHighlightedTabColor(&getThemeColor( - ThemeColorId::PARTY_SOCIAL_TAB_HIGHLIGHTED), &getThemeColor( - ThemeColorId::PARTY_SOCIAL_TAB_HIGHLIGHTED_OUTLINE)); - setSelectedTabColor(&getThemeColor( - ThemeColorId::PARTY_SOCIAL_TAB_SELECTED), - &getThemeColor( - ThemeColorId::PARTY_SOCIAL_TAB_SELECTED_OUTLINE)); - - createControls(party, showBackground); - mMenuAction = "party"; - } - - A_DELETE_COPY(SocialPartyTab) - - ~SocialPartyTab() - { - delete2(mList) - delete2(mScroll) - } - - void action(const ActionEvent &event) override final - { - const std::string &eventId = event.getId(); - if (eventId == "do invite") - { - const std::string name = mInviteDialog->getText(); - partyHandler->invite(name); - - if (localChatTab != nullptr) - { - localChatTab->chatLog(strprintf( - // TRANSLATORS: chat message - _("Invited user %s to party."), - name.c_str()), - ChatMsgType::BY_SERVER); - } - mInviteDialog = nullptr; - } - else if (eventId == "~do invite") - { - mInviteDialog = nullptr; - } - else if (eventId == "yes") - { - partyHandler->leave(); - if (localChatTab != nullptr) - { - localChatTab->chatLog(strprintf( - // TRANSLATORS: tab in social window - _("Party %s quit requested."), - mParty->getName().c_str()), - ChatMsgType::BY_SERVER); - } - mConfirmDialog = nullptr; - } - else if (eventId == "~yes") - { - mConfirmDialog = nullptr; - } - } - - void invite() override final - { - CREATEWIDGETV(mInviteDialog, TextDialog, - // TRANSLATORS: party invite message - _("Member Invite to Party"), - // TRANSLATORS: party invite message - strprintf(_("Who would you like to invite to party %s?"), - mParty->getName().c_str()), socialWindow); - mInviteDialog->setActionEventId("do invite"); - mInviteDialog->addActionListener(this); - } - - void leave() override final - { - CREATEWIDGETV(mConfirmDialog, ConfirmDialog, - // TRANSLATORS: party leave message - _("Leave Party?"), - // TRANSLATORS: party leave message - strprintf(_("Are you sure you want to leave party %s?"), - mParty->getName().c_str()), SOUND_REQUEST, socialWindow); - mConfirmDialog->addActionListener(this); - } - - void buildCounter(const int online0 A_UNUSED, - const int total0 A_UNUSED) override final - { - if (localPlayer == nullptr) - return; - - const Party *const party = localPlayer->getParty(); - if (party == nullptr) - return; - - const Party::MemberList *const members = party->getMembers(); - int online = 0; - int total = 0; - FOR_EACHP (Party::MemberList::const_iterator, it, members) - { - if ((*it)->getOnline()) - online ++; - total ++; - } - - // TRANSLATORS: social window label - mCounterString = strprintf(_("Players: %u/%u"), - CAST_U32(online), - CAST_U32(total)); - updateCounter(); - } - - private: - Party *mParty; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALPARTYTAB_H diff --git a/src/gui/widgets/tabs/socialpickuptab.h b/src/gui/widgets/tabs/socialpickuptab.h deleted file mode 100644 index 93d00e81a..000000000 --- a/src/gui/widgets/tabs/socialpickuptab.h +++ /dev/null @@ -1,75 +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_WIDGETS_TABS_SOCIALPICKUPTAB_H -#define GUI_WIDGETS_TABS_SOCIALPICKUPTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "being/localplayer.h" - -#include "gui/models/beingslistmodel.h" - -#include "gui/widgets/tabs/socialtabbase.h" - -#include "utils/delete2.h" -#include "utils/gettext.h" - -#include "localconsts.h" - -class SocialPickupTab final : public SocialTab -{ - public: - SocialPickupTab(const Widget2 *const widget, - const Opaque showBackground) : - SocialTab(widget), - mBeings(new BeingsListModel) - { - createControls(mBeings, showBackground); - - // TRANSLATORS: Pickup filter tab name in social window. - // TRANSLATORS: Should be small - setCaption(_("Pik")); - mMenuAction = "pickup"; - } - - A_DELETE_COPY(SocialPickupTab) - - ~SocialPickupTab() - { - delete2(mList) - delete2(mScroll) - delete2(mBeings) - } - - void updateList() override final - { - updateAtkListStart(); - // TRANSLATORS: items group name in social window - addAvatars(PickupItem, _("Pickup items"), PICKUP); - // TRANSLATORS: items group name in social window - addAvatars(IgnorePickupItem, _("Ignore items"), NOPICKUP); - } - - private: - BeingsListModel *mBeings; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALPICKUPTAB_H diff --git a/src/gui/widgets/tabs/socialplayerstab.h b/src/gui/widgets/tabs/socialplayerstab.h deleted file mode 100644 index c43093fca..000000000 --- a/src/gui/widgets/tabs/socialplayerstab.h +++ /dev/null @@ -1,198 +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_WIDGETS_TABS_SOCIALPLAYERSTAB_H -#define GUI_WIDGETS_TABS_SOCIALPLAYERSTAB_H - -#include "gui/widgets/tabs/socialtab.h" - -#include "actormanager.h" -#include "party.h" - -#include "being/being.h" - -#include "gui/models/beingslistmodel.h" - -#include "utils/gettext.h" -#include "utils/delete2.h" -#include "utils/stringutils.h" - -#include "localconsts.h" - -class Avatar; -class Being; - -class SocialPlayersTab final : public SocialTab -{ - public: - SocialPlayersTab(const Widget2 *const widget, - const std::string &name, - const Opaque showBackground) : - SocialTab(widget), - mBeings(new BeingsListModel) - { - createControls(mBeings, showBackground); - - getPlayersAvatars(); - setCaption(name); - mMenuAction = "players"; - } - - A_DELETE_COPY(SocialPlayersTab) - - ~SocialPlayersTab() - { - delete2(mList) - delete2(mScroll) - delete2(mBeings) - } - - void updateList() override final - { - getPlayersAvatars(); - } - - void updateAvatar(const std::string &name) override final - { - if (actorManager == nullptr) - return; - - BLOCK_START("SocialPlayersTab::updateAvatar") - Avatar *const avatar = findAvatarbyName(name); - if (avatar == nullptr) - return; - if (Party::getParty(1) != nullptr) - { - const PartyMember *const - pm = Party::getParty(1)->getMember(name); - if ((pm != nullptr) && pm->getMaxHp() > 0) - { - avatar->setMaxHp(pm->getMaxHp()); - avatar->setHp(pm->getHp()); - } - } - const Being *const being = actorManager->findBeingByName( - name, ActorType::Player); - if (being != nullptr) - { - avatar->setDamageHp(being->getDamageTaken()); - avatar->setLevel(being->getLevel()); - avatar->setGender(being->getGender()); - avatar->setIp(being->getIp()); - avatar->setPoison(being->getPoison()); - } - BLOCK_END("SocialPlayersTab::updateAvatar") - } - - void resetDamage(const std::string &name) override final - { - if (actorManager == nullptr) - return; - - Avatar *const avatar = findAvatarbyName(name); - if (avatar == nullptr) - return; - avatar->setDamageHp(0); - Being *const being = actorManager->findBeingByName( - name, ActorType::Player); - - if (being != nullptr) - being->setDamageTaken(0); - } - - Avatar* findAvatarbyName(const std::string &name) - { - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - Avatar *ava = nullptr; - STD_VECTOR<Avatar*>::const_iterator i = avatars->begin(); - const STD_VECTOR<Avatar*>::const_iterator i_end = avatars->end(); - while (i != i_end) - { - ava = (*i); - if ((ava != nullptr) && ava->getName() == name) - return ava; - ++i; - } - ava = new Avatar(name); - ava->setOnline(true); - avatars->push_back(ava); - return ava; - } - - void getPlayersAvatars() - { - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers(); - if (actorManager != nullptr) - { - StringVect names; - actorManager->getPlayerNames(names, NpcNames_false); - - STD_VECTOR<Avatar*>::iterator ai = avatars->begin(); - while (ai != avatars->end()) - { - bool finded = false; - const Avatar *const ava = (*ai); - if (ava == nullptr) - break; - - StringVectCIter i = names.begin(); - const StringVectCIter i_end = names.end(); - while (i != i_end) - { - if (ava->getName() == (*i) && !(*i).empty()) - { - finded = true; - break; - } - ++i; - } - - if (!finded) - { - delete *ai; - ai = avatars->erase(ai); - } - else - { - ++ai; - } - } - - StringVectCIter i = names.begin(); - const StringVectCIter i_end = names.end(); - - while (i != i_end) - { - if (!(*i).empty()) - updateAvatar(*i); - ++i; - } - } - // TRANSLATORS: social window label - mCounterString = strprintf(_("Visible players: %d"), - CAST_S32(avatars->size())); - updateCounter(); - } - - private: - BeingsListModel *mBeings; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALPLAYERSTAB_H diff --git a/src/gui/widgets/tabs/socialtab.h b/src/gui/widgets/tabs/socialtab.h deleted file mode 100644 index 1c94aaede..000000000 --- a/src/gui/widgets/tabs/socialtab.h +++ /dev/null @@ -1,143 +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_WIDGETS_TABS_SOCIALTAB_H -#define GUI_WIDGETS_TABS_SOCIALTAB_H - -#include "gui/windows/socialwindow.h" - -#include "gui/windows/confirmdialog.h" -#include "gui/windows/textdialog.h" - -#include "gui/widgets/avatarlistbox.h" -#include "gui/widgets/createwidget.h" -#include "gui/widgets/scrollarea.h" - -#include "gui/widgets/tabs/tab.h" - -#include "localconsts.h" - -class AvatarListModel; - -class SocialTab notfinal : public Tab -{ - public: - A_DELETE_COPY(SocialTab) - - virtual void invite() - { - } - - virtual void leave() - { - } - - virtual void updateList() - { - } - - virtual void updateAvatar(const std::string &name A_UNUSED) - { - } - - virtual void resetDamage(const std::string &name A_UNUSED) - { - } - - virtual void selectIndex(const unsigned num A_UNUSED) - { - } - - virtual void buildCounter(const int online A_UNUSED, - const int total A_UNUSED) - { - } - - protected: - friend class SocialWindow; - - explicit SocialTab(const Widget2 *const widget) : - Tab(widget), - mInviteDialog(nullptr), - mConfirmDialog(nullptr), - mScroll(nullptr), - mList(nullptr), - mCounterString(), - mMenuAction("menu") - { - } - - virtual ~SocialTab() - { - // Cleanup dialogs - if (mInviteDialog != nullptr) - { - mInviteDialog->close(); - mInviteDialog->scheduleDelete(); - mInviteDialog = nullptr; - } - - if (mConfirmDialog != nullptr) - { - mConfirmDialog->close(); - mConfirmDialog->scheduleDelete(); - mConfirmDialog = nullptr; - } - } - - void createControls(AvatarListModel *const listModel, - const Opaque showBackground) - { - CREATEWIDGETV(mList, AvatarListBox, this, listModel); - mScroll = new ScrollArea(this, mList, showBackground, - "social_background.xml"); - - mScroll->setHorizontalScrollPolicy(ScrollArea::SHOW_AUTO); - mScroll->setVerticalScrollPolicy(ScrollArea::SHOW_ALWAYS); - } - - void setCurrent() override final - { - updateCounter(); - updateMenu(); - } - - void updateCounter() const - { - if (socialWindow != nullptr) - socialWindow->updateCounter(this, mCounterString); - } - - void updateMenu() const - { - if (socialWindow != nullptr) - socialWindow->updateMenu(this, mMenuAction); - } - - TextDialog *mInviteDialog; - ConfirmDialog *mConfirmDialog; - ScrollArea *mScroll; - AvatarListBox *mList; - std::string mCounterString; - std::string mMenuAction; -}; - -#endif // GUI_WIDGETS_TABS_SOCIALTAB_H diff --git a/src/gui/widgets/tabs/socialtabbase.h b/src/gui/widgets/tabs/socialtabbase.h deleted file mode 100644 index 03a02bb1f..000000000 --- a/src/gui/widgets/tabs/socialtabbase.h +++ /dev/null @@ -1,84 +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_WIDGETS_TABS_SOCIALTABBASE_H -#define GUI_WIDGETS_TABS_SOCIALTABBASE_H - -#include "actormanager.h" - -ACTORMANAGER_H - -#include "enums/resources/map/mapitemtype.h" - -ENUMS_RESOURCES_MAP_MAPITEMTYPE_H - -#define addAvatars(mob, str, type) \ -{\ - ava = new Avatar(str);\ - ava->setOnline(false);\ - ava->setLevel(-1);\ - ava->setType(MapItemType::SEPARATOR);\ - ava->setX(0);\ - ava->setY(0);\ - avatars->push_back(ava);\ - mobs = actorManager->get##mob##s();\ - i = mobs.begin();\ - i_end = mobs.end();\ - while (i != i_end)\ - {\ - std::string name;\ - int level = -1;\ - if ((*i).empty())\ - {\ - name = _("(default)");\ - level = 0;\ - }\ - else\ - {\ - name = *i;\ - }\ - ava = new Avatar(name);\ - ava->setOnline(true);\ - ava->setLevel(level);\ - ava->setType(MapItemType::type);\ - ava->setX(0);\ - ava->setY(0);\ - avatars->push_back(ava);\ - ++ i;\ - }\ -} - -#define updateAtkListStart() \ - if (!socialWindow || !localPlayer || !actorManager)\ - return;\ - STD_VECTOR<Avatar*> *const avatars = mBeings->getMembers();\ - STD_VECTOR<Avatar*>::iterator ia = avatars->begin();\ - while (ia != avatars->end())\ - {\ - delete *ia;\ - ++ ia;\ - }\ - avatars->clear();\ - Avatar *ava = nullptr;\ - std::list<std::string> mobs;\ - std::list<std::string>::const_iterator i;\ - std::list<std::string>::const_iterator i_end; - -#endif // GUI_WIDGETS_TABS_SOCIALTABBASE_H diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp deleted file mode 100644 index 36c2a3f40..000000000 --- a/src/gui/widgets/tabs/tab.cpp +++ /dev/null @@ -1,488 +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/>. - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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. - */ - -#include "gui/widgets/tabs/tab.h" - -#include "settings.h" - -#include "gui/gui.h" -#include "gui/skin.h" - -#include "gui/widgets/label.h" -#include "gui/widgets/tabbedarea.h" - -#include "render/vertexes/imagecollection.h" - -#include "resources/imagerect.h" - -#include "resources/image/image.h" - -#include "utils/delete2.h" - -#include "debug.h" - -int Tab::mInstances = 0; -float Tab::mAlpha = 1.0; - -namespace -{ - std::string const data[Tab::TAB_COUNT] = - { - "tab.xml", - "tab_highlighted.xml", - "tab_selected.xml", - "tab_unused.xml" - }; -} // namespace - -Skin *Tab::tabImg[Tab::TAB_COUNT]; - -Tab::Tab(const Widget2 *const widget) : - BasicContainer(widget), - MouseListener(), - WidgetListener(), - mLabel(new Label(this)), - mTabbedArea(nullptr), - mTabColor(&getThemeColor(ThemeColorId::TAB)), - mTabOutlineColor(&getThemeColor(ThemeColorId::TAB_OUTLINE)), - mTabHighlightedColor(&getThemeColor(ThemeColorId::TAB_HIGHLIGHTED)), - mTabHighlightedOutlineColor(&getThemeColor( - ThemeColorId::TAB_HIGHLIGHTED_OUTLINE)), - mTabSelectedColor(&getThemeColor(ThemeColorId::TAB_SELECTED)), - mTabSelectedOutlineColor(&getThemeColor( - ThemeColorId::TAB_SELECTED_OUTLINE)), - mFlashColor(&getThemeColor(ThemeColorId::TAB_FLASH)), - mFlashOutlineColor(&getThemeColor(ThemeColorId::TAB_FLASH_OUTLINE)), - mPlayerFlashColor(&getThemeColor(ThemeColorId::TAB_PLAYER_FLASH)), - mPlayerFlashOutlineColor(&getThemeColor( - ThemeColorId::TAB_PLAYER_FLASH_OUTLINE)), - mFlash(0), - mVertexes(new ImageCollection), - mImage(nullptr), - mMode(0), - mLabelMode(-1), - mHasMouse(false) -{ - init(); -} - -Tab::~Tab() -{ - if (gui != nullptr) - gui->removeDragged(this); - - mInstances--; - if (mInstances == 0 && (theme != nullptr)) - { - for (int mode = 0; mode < TAB_COUNT; mode ++) - theme->unload(tabImg[mode]); - } - - delete2(mLabel); - - if (mImage != nullptr) - { - mImage->decRef(); - mImage = nullptr; - } - delete2(mVertexes); -} - -void Tab::init() -{ - addMouseListener(this); - setFocusable(false); - setFrameSize(0); - mFlash = 0; - - addWidgetListener(this); - - if (mInstances == 0) - { - // Load the skin - if (theme != nullptr) - { - for (int mode = 0; mode < TAB_COUNT; mode ++) - tabImg[mode] = theme->load(data[mode], "tab.xml"); - } - updateAlpha(); - } - mInstances++; - - add(mLabel); - - const Skin *const skin = tabImg[TAB_STANDARD]; - if (skin == nullptr) - return; - const int padding = skin->getPadding(); - - mLabel->setPosition(padding, padding); -} - -void Tab::updateAlpha() -{ - const float alpha = std::max(settings.guiAlpha, - theme->getMinimumOpacity()); - - if (alpha != mAlpha) - { - mAlpha = alpha; - for (int a = 0; a < 9; a++) - { - for (int t = 0; t < TAB_COUNT; t++) - { - Skin *const skin = tabImg[t]; - if (skin != nullptr) - { - const ImageRect &rect = skin->getBorder(); - Image *const image = rect.grid[a]; - if (image != nullptr) - image->setAlpha(mAlpha); - } - } - } - } -} - -void Tab::draw(Graphics *const graphics) -{ - BLOCK_START("Tab::draw") - int mode = TAB_STANDARD; - - // check which type of tab to draw - if (mTabbedArea != nullptr) - { - int labelMode = mFlash; - - if (mTabbedArea->isTabSelected(this)) - { - labelMode = 3; - mode = TAB_SELECTED; - // if tab is selected, it doesnt need to highlight activity - mFlash = 0; - } - else if (labelMode == 0) - { - if (mHasMouse) - { - labelMode = 4; - mode = TAB_HIGHLIGHTED; - } - } - else if (mHasMouse) - { - mode = TAB_HIGHLIGHTED; - } - - // mRedraw need here because no other way to say label to change color - // +++ text from label must be moved to tab itself - if (labelMode != mLabelMode || mRedraw) - { - mLabelMode = labelMode; - switch (labelMode) - { - case 0: // default state - default: - mLabel->setForegroundColorAll(*mTabColor, - *mTabOutlineColor); - break; - case 1: // mFlash == 1 - mLabel->setForegroundColorAll(*mFlashColor, - *mFlashOutlineColor); - break; - case 2: // mFlash == 2 - mLabel->setForegroundColorAll(*mPlayerFlashColor, - *mPlayerFlashOutlineColor); - break; - case 3: // mTabbedArea->isTabSelected(this) - mLabel->setForegroundColorAll(*mTabSelectedColor, - *mTabSelectedOutlineColor); - break; - case 4: // mHasMouse - mLabel->setForegroundColorAll(*mTabHighlightedColor, - *mTabHighlightedOutlineColor); - break; - } - } - } - - const Skin *const skin = tabImg[mode]; - if (skin == nullptr) - { - BLOCK_END("Tab::draw") - return; - } - - updateAlpha(); - - const ImageRect &rect = skin->getBorder(); - if (mRedraw || mode != mMode || graphics->getRedraw()) - { - mMode = mode; - mRedraw = false; - mVertexes->clear(); - graphics->calcWindow(mVertexes, - 0, 0, - mDimension.width, mDimension.height, - rect); - - if (mImage != nullptr) - { - const Skin *const skin1 = tabImg[TAB_STANDARD]; - if (skin1 != nullptr) - { - const int padding = skin1->getPadding(); - graphics->calcTileCollection(mVertexes, - mImage, - padding, - padding); - } - } - graphics->finalize(mVertexes); - } - - graphics->drawTileCollection(mVertexes); - - drawChildren(graphics); - BLOCK_END("Tab::draw") -} - -void Tab::safeDraw(Graphics *const graphics) -{ - BLOCK_START("Tab::draw") - int mode = TAB_STANDARD; - - // check which type of tab to draw - if (mTabbedArea != nullptr) - { - int labelMode = mFlash; - - if (mTabbedArea->isTabSelected(this)) - { - labelMode = 3; - mode = TAB_SELECTED; - // if tab is selected, it doesnt need to highlight activity - mFlash = 0; - } - else if (labelMode == 0) - { - if (mHasMouse) - { - labelMode = 4; - mode = TAB_HIGHLIGHTED; - } - } - else if (mHasMouse) - { - mode = TAB_HIGHLIGHTED; - } - - if (labelMode != mLabelMode) - { - mLabelMode = labelMode; - switch (labelMode) - { - case 0: // default state - default: - mLabel->setForegroundColorAll(*mTabColor, - *mTabOutlineColor); - break; - case 1: // mFlash == 1 - mLabel->setForegroundColorAll(*mFlashColor, - *mFlashOutlineColor); - break; - case 2: // mFlash == 2 - mLabel->setForegroundColorAll(*mPlayerFlashColor, - *mPlayerFlashOutlineColor); - break; - case 3: // mTabbedArea->isTabSelected(this) - mLabel->setForegroundColorAll(*mTabSelectedColor, - *mTabSelectedOutlineColor); - break; - case 4: // mHasMouse - mLabel->setForegroundColorAll(*mTabHighlightedColor, - *mTabHighlightedOutlineColor); - break; - } - } - } - - const Skin *const skin = tabImg[mode]; - if (skin == nullptr) - { - BLOCK_END("Tab::draw") - return; - } - - updateAlpha(); - - graphics->drawImageRect(0, 0, - mDimension.width, mDimension.height, - skin->getBorder()); - if (mImage != nullptr) - { - const Skin *const skin1 = tabImg[TAB_STANDARD]; - if (skin1 != nullptr) - { - const int padding = skin1->getPadding(); - graphics->drawImage(mImage, padding, padding); - } - } - - safeDrawChildren(graphics); - BLOCK_END("Tab::draw") -} - -void Tab::widgetResized(const Event &event A_UNUSED) -{ - mRedraw = true; -} - -void Tab::widgetMoved(const Event &event A_UNUSED) -{ - mRedraw = true; -} - -void Tab::setLabelFont(Font *const font) -{ - if (mLabel == nullptr) - return; - - mLabel->setFont(font); - mLabel->adjustSize(); - adjustSize(); - mRedraw = true; -} - - -void Tab::adjustSize() -{ - const Skin *const skin = tabImg[TAB_STANDARD]; - if (skin == nullptr) - return; - const int pad2 = skin->getPadding() * 2; - - if (mImage != nullptr) - { - const SDL_Rect &rect = mImage->mBounds; - setSize(rect.w + pad2, rect.h + pad2); - } - else - { - setSize(mLabel->getWidth() + pad2, - mLabel->getHeight() + pad2); - } - - if (mTabbedArea != nullptr) - mTabbedArea->adjustTabPositions(); -} - -void Tab::setTabbedArea(TabbedArea* tabbedArea) -{ - mTabbedArea = tabbedArea; -} - -TabbedArea* Tab::getTabbedArea() const -{ - return mTabbedArea; -} - -void Tab::setCaption(const std::string &caption) -{ - mLabel->setCaption(caption); - mLabel->adjustSize(); - adjustSize(); -} - -void Tab::setImage(Image *const image) -{ - if (mImage != nullptr) - mImage->decRef(); - mImage = image; - adjustSize(); -} - -const std::string &Tab::getCaption() const -{ - return mLabel->getCaption(); -} - -void Tab::mouseEntered(MouseEvent& event A_UNUSED) -{ - mHasMouse = true; -} - -void Tab::mouseExited(MouseEvent& event A_UNUSED) -{ - mHasMouse = false; -} - -void Tab::finalCleanup() -{ - for (int f = 0; f < TAB_COUNT; f ++) - { - tabImg[f] = nullptr; - } -} diff --git a/src/gui/widgets/tabs/tab.h b/src/gui/widgets/tabs/tab.h deleted file mode 100644 index e6a816072..000000000 --- a/src/gui/widgets/tabs/tab.h +++ /dev/null @@ -1,245 +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/>. - */ - -/* _______ __ __ __ ______ __ __ _______ __ __ - * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\ - * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / / - * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / / - * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / / - * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ / - * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/ - * - * 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_WIDGETS_TABS_TAB_H -#define GUI_WIDGETS_TABS_TAB_H - -#include "gui/widgets/basiccontainer.h" - -#include "listeners/mouselistener.h" -#include "listeners/widgetlistener.h" - -#include "localconsts.h" - -class ImageCollection; -class Label; -class Skin; -class TabbedArea; - -/** - * A tab, the same as the Guichan tab in 0.8, but extended - */ -class Tab notfinal : public BasicContainer, - public MouseListener, - public WidgetListener -{ - public: - explicit Tab(const Widget2 *const widget); - - A_DELETE_COPY(Tab) - - virtual ~Tab(); - - enum - { - TAB_STANDARD = 0, - TAB_HIGHLIGHTED = 1, - TAB_SELECTED = 2, - TAB_UNUSED = 3, - TAB_COUNT = 4 // Must be last - }; - - /** - * Update the alpha value to the graphic components. - */ - void updateAlpha(); - - /** - * Draw the tabbed area. - */ - void draw(Graphics *const graphics) override final A_NONNULL(2); - - void safeDraw(Graphics *const graphics) override final A_NONNULL(2); - - /** - * Set the normal color for the tab's text. - */ - void setTabColor(const Color *const color1, - const Color *const color2) - { - mTabColor = color1; - mTabOutlineColor = color2; - mRedraw = true; - } - - /** - * Set the highlighted color for the tab's text. - */ - void setHighlightedTabColor(const Color *const color1, - const Color *const color2) - { - mTabHighlightedColor = color1; - mTabHighlightedOutlineColor = color2; - mRedraw = true; - } - - /** - * Set the selected color for the tab's text. - */ - void setSelectedTabColor(const Color *const color1, - const Color *const color2) - { - mTabSelectedColor = color1; - mTabSelectedOutlineColor = color2; - mRedraw = true; - } - - /** - * Set the flash color for the tab's text. - */ - void setFlashTabColor(const Color *const color1, - const Color *const color2) - { - mFlashColor = color1; - mFlashOutlineColor = color2; - mRedraw = true; - } - - /** - * Set the player flash color for the tab's text. - */ - void setPlayerFlashTabColor(const Color *const color1, - const Color *const color2) - { - mPlayerFlashColor = color1; - mPlayerFlashOutlineColor = color2; - mRedraw = true; - } - - /** - * Set tab flashing state - */ - void setFlash(const int flash) - { mFlash = flash; mRedraw = true; } - - int getFlash() const noexcept2 A_WARN_UNUSED - { return mFlash; } - - void widgetResized(const Event &event) override final; - - void widgetMoved(const Event &event) override final; - - void setLabelFont(Font *const font); - - Label *getLabel() const noexcept2 A_WARN_UNUSED - { return mLabel; } - - void adjustSize(); - - void setTabbedArea(TabbedArea* tabbedArea); - - TabbedArea* getTabbedArea() const A_WARN_UNUSED; - - void setCaption(const std::string& caption); - - const std::string &getCaption() const A_WARN_UNUSED; - - void mouseEntered(MouseEvent &event) override final; - - void mouseExited(MouseEvent &event) override final; - - void setImage(Image *const image); - - static void finalCleanup(); - - protected: - friend class TabbedArea; - - virtual void setCurrent() - { } - - Label* mLabel A_NONNULLPOINTER; - - TabbedArea* mTabbedArea; - - private: - /** Load images if no other instances exist yet */ - void init(); - - static Skin *tabImg[TAB_COUNT]; /**< Tab state graphics */ - static int mInstances; /**< Number of tab instances */ - static float mAlpha; - - const Color *mTabColor; - const Color *mTabOutlineColor; - const Color *mTabHighlightedColor; - const Color *mTabHighlightedOutlineColor; - const Color *mTabSelectedColor; - const Color *mTabSelectedOutlineColor; - const Color *mFlashColor; - const Color *mFlashOutlineColor; - const Color *mPlayerFlashColor; - const Color *mPlayerFlashOutlineColor; - int mFlash; - ImageCollection *mVertexes A_NONNULLPOINTER; - Image *mImage; - int mMode; - int mLabelMode; - - protected: - bool mHasMouse; -}; - -#endif // GUI_WIDGETS_TABS_TAB_H |