summaryrefslogtreecommitdiff
path: root/src/gui/setup_chat.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-06-19 21:00:17 +0300
committerAndrei Karas <akaras@inbox.ru>2011-06-19 21:00:17 +0300
commit2881720bca7168ca181a13bfd4dd69115a46c2f9 (patch)
tree13d52ee1266e7dbcd9532f3324a5de039df88b46 /src/gui/setup_chat.cpp
parent5eba7b23b7002a3f399afa7e51066a6b16a1f9a6 (diff)
downloadmanaverse-2881720bca7168ca181a13bfd4dd69115a46c2f9.tar.gz
manaverse-2881720bca7168ca181a13bfd4dd69115a46c2f9.tar.bz2
manaverse-2881720bca7168ca181a13bfd4dd69115a46c2f9.tar.xz
manaverse-2881720bca7168ca181a13bfd4dd69115a46c2f9.zip
Redesign Chat setup page.
Diffstat (limited to 'src/gui/setup_chat.cpp')
-rw-r--r--src/gui/setup_chat.cpp313
1 files changed, 41 insertions, 272 deletions
diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp
index 4dd5feefc..87425b46c 100644
--- a/src/gui/setup_chat.cpp
+++ b/src/gui/setup_chat.cpp
@@ -2,6 +2,7 @@
* The Mana World
* Copyright (C) 2009 The Mana World Development Team
* Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The Mana World.
*
@@ -21,15 +22,18 @@
*/
#include "gui/setup_chat.h"
-#include "gui/editdialog.h"
+
#include "gui/chatwindow.h"
+#include "gui/editdialog.h"
+#include "gui/setupitem.h"
#include "gui/widgets/button.h"
+#include "gui/widgets/chattab.h"
#include "gui/widgets/checkbox.h"
+#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
-#include "gui/widgets/inttextfield.h"
-#include "gui/widgets/chattab.h"
+#include "gui/widgets/scrollarea.h"
#include "configuration.h"
#include "localplayer.h"
@@ -39,301 +43,66 @@
#include "debug.h"
-#define ACTION_REMOVE_COLORS "remove colors"
-#define ACTION_MAGIC_IN_DEBUG "magic in debug"
-#define ACTION_ALLOW_COMMANDS_IN_CHATTABS "allow commands"
-#define ACTION_SERVER_MSG_IN_DEBUG "server in debug"
-#define ACTION_SHOW_CHAT_COLORS "show chat colors"
-#define ACTION_MAX_CHAR_LIMIT "char limit"
-#define ACTION_EDIT_CHAR_LIMIT "edit char limit"
-#define ACTION_EDIT_CHAR_OK "edit char ok"
-#define ACTION_MAX_LINES_LIMIT "lines limit"
-#define ACTION_EDIT_LINES_LIMIT "edit lines limit"
-#define ACTION_EDIT_LINES_OK "edit lines ok"
-#define ACTION_CHAT_LOGGER "chat logger"
-#define ACTION_TRADE_TAB "trade tab"
-#define ACTION_HIDE_SHOP_MESSAGES "hide shop messages"
-#define ACTION_SHOW_CHAT_HISTORY "show chat history"
-#define ACTION_ENABLE_BATTLE_TAB "show battle tab"
-#define ACTION_SHOW_BATTLE_EVENTS "show battle events"
-#define ACTION_RESIZE_CHAT "resize chat"
-#define ACTION_LOCAL_TIME "local time"
-
-Setup_Chat::Setup_Chat() :
- mEditDialog(0)
+Setup_Chat::Setup_Chat()
{
setName(_("Chat"));
- mRemoveColors = config.getBoolValue("removeColors");
- mRemoveColorsCheckBox = new CheckBox(
- _("Remove colors from received chat messages"),
- mRemoveColors, this, ACTION_REMOVE_COLORS);
-
- mMagicInDebug = config.getBoolValue("showMagicInDebug");
- mMagicInDebugCheckBox = new CheckBox(_("Log magic messages in debug tab"),
- mMagicInDebug, this, ACTION_MAGIC_IN_DEBUG);
-
- mAllowCommandsInChatTabs = config.getBoolValue(
- "allowCommandsInChatTabs");
-
- mAllowCommandsInChatTabsCheckBox = new CheckBox(
- _("Allow magic and GM commands in all chat tabs"),
- mAllowCommandsInChatTabs, this, ACTION_ALLOW_COMMANDS_IN_CHATTABS);
-
- mServerMsgInDebug = config.getBoolValue("serverMsgInDebug");
- mServerMsgInDebugCheckBox = new CheckBox(
- _("Show server messages in debug tab"),
- mServerMsgInDebug, this, ACTION_SERVER_MSG_IN_DEBUG);
-
- mEnableChatLogger = config.getBoolValue("enableChatLog");
- mEnableChatLoggerCheckBox = new CheckBox(_("Enable chat Log"),
- mEnableChatLogger, this, ACTION_CHAT_LOGGER);
-
- mEnableTradeTab = config.getBoolValue("enableTradeTab");
- mEnableTradeTabCheckBox = new CheckBox(_("Enable trade tab"),
- mEnableTradeTab, this, ACTION_TRADE_TAB);
-
- mHideShopMessages = config.getBoolValue("hideShopMessages");
- mHideShopMessagesCheckBox = new CheckBox(_("Hide shop messages"),
- mHideShopMessages, this, ACTION_HIDE_SHOP_MESSAGES);
-
- mShowChatHistory = config.getBoolValue("showChatHistory");
- mShowChatHistoryCheckBox = new CheckBox(_("Show chat history"),
- mShowChatHistory, this, ACTION_SHOW_CHAT_HISTORY);
-
- mEnableBattleTab = config.getBoolValue("enableBattleTab");
- mEnableBattleTabCheckBox = new CheckBox(_("Enable battle tab"),
- mEnableBattleTab, this, ACTION_ENABLE_BATTLE_TAB);
-
- mShowBattleEvents = config.getBoolValue("showBattleEvents");
- mShowBattleEventsCheckBox = new CheckBox(_("Show battle events"),
- mShowBattleEvents, this, ACTION_SHOW_BATTLE_EVENTS);
-
- mShowChatColors = config.getBoolValue("showChatColorsList");
- mShowChatColorsCheckBox = new CheckBox(_("Show chat colors list"),
- mShowChatColors, this, ACTION_SHOW_CHAT_COLORS);
-
- mMaxCharButton = new Button(_("Edit"), ACTION_EDIT_CHAR_LIMIT, this);
- int maxCharLimit = config.getIntValue("chatMaxCharLimit");
- mMaxChar = (maxCharLimit != 0);
- mMaxCharCheckBox = new CheckBox(_("Limit max chars in chat line"),
- mMaxChar, this, ACTION_MAX_CHAR_LIMIT);
-
- mMaxCharField = new IntTextField(maxCharLimit, 0, 500, mMaxChar, 20);
-
- mMaxLinesButton = new Button(_("Edit"), ACTION_EDIT_LINES_LIMIT, this);
- int maxLinesLimit = config.getIntValue("chatMaxLinesLimit");
- mMaxLines = (maxLinesLimit != 0);
-
- mMaxLinesCheckBox = new CheckBox(_("Limit max lines in chat"),
- mMaxLines,
- this, ACTION_MAX_LINES_LIMIT);
-
- mMaxLinesField = new IntTextField(maxLinesLimit, 0, 500, mMaxLines, 20);
-
- mHideChatInput = config.getBoolValue("hideChatInput");
- mHideChatInputCheckBox = new CheckBox(_("Resize chat tabs if need"),
- mHideChatInput, this, ACTION_RESIZE_CHAT);
-
- mLocalTime = config.getBoolValue("useLocalTime");
- mLocalTimeCheckBox = new CheckBox(_("Use local time"),
- mLocalTime, this, ACTION_LOCAL_TIME);
-
// Do the layout
LayoutHelper h(this);
ContainerPlacer place = h.getPlacer(0, 0);
+ place(0, 0, mScroll, 10, 10);
- place(0, 0, mRemoveColorsCheckBox, 10);
- place(0, 1, mMagicInDebugCheckBox, 10);
- place(0, 2, mAllowCommandsInChatTabsCheckBox, 10);
- place(0, 3, mServerMsgInDebugCheckBox, 10);
- place(0, 4, mShowChatColorsCheckBox, 10);
- place(0, 5, mMaxCharCheckBox, 6);
- place(6, 5, mMaxCharField, 2);
- place(8, 5, mMaxCharButton, 2);
- place(0, 6, mEnableChatLoggerCheckBox, 10);
- place(0, 7, mMaxLinesCheckBox, 6);
- place(6, 7, mMaxLinesField, 2);
- place(8, 7, mMaxLinesButton, 2);
- place(0, 8, mEnableTradeTabCheckBox, 10);
- place(0, 9, mHideShopMessagesCheckBox, 10);
- place(0, 10, mShowChatHistoryCheckBox, 10);
- place(0, 11, mEnableBattleTabCheckBox, 10);
- place(0, 12, mShowBattleEventsCheckBox, 10);
- place(0, 13, mHideChatInputCheckBox, 10);
- place(0, 14, mLocalTimeCheckBox, 10);
-
- place.getCell().matchColWidth(0, 0);
- place = h.getPlacer(0, 1);
-
- setDimension(gcn::Rectangle(0, 0, 500, 500));
-}
-
-void Setup_Chat::action(const gcn::ActionEvent &event)
-{
- if (event.getId() == ACTION_REMOVE_COLORS)
- {
- mRemoveColors = mRemoveColorsCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_MAGIC_IN_DEBUG)
- {
- mMagicInDebug = mMagicInDebugCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_ALLOW_COMMANDS_IN_CHATTABS)
- {
- mAllowCommandsInChatTabs
- = mAllowCommandsInChatTabsCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SERVER_MSG_IN_DEBUG)
- {
- mServerMsgInDebug = mServerMsgInDebugCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SHOW_CHAT_COLORS)
- {
- mShowChatColors = mShowChatColorsCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_MAX_CHAR_LIMIT)
- {
- mMaxChar = mMaxCharCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_EDIT_CHAR_LIMIT)
- {
- mEditDialog = new EditDialog("Limit max chars in chat line",
- toString(mMaxCharField->getValue()),
- ACTION_EDIT_CHAR_OK);
- mEditDialog->addActionListener(this);
- }
- else if (event.getId() == ACTION_EDIT_CHAR_OK)
- {
- mMaxCharField->setValue(atoi(mEditDialog->getMsg().c_str()));
- }
- else if (event.getId() == ACTION_MAX_LINES_LIMIT)
- {
- mMaxLines = mMaxLinesCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_EDIT_LINES_LIMIT)
- {
- mEditDialog = new EditDialog("Limit max lines in chat",
- toString(mMaxLinesField->getValue()),
- ACTION_EDIT_LINES_OK);
- mEditDialog->addActionListener(this);
- }
- else if (event.getId() == ACTION_EDIT_LINES_OK)
- {
- mMaxLinesField->setValue(atoi(mEditDialog->getMsg().c_str()));
- }
- else if (event.getId() == ACTION_CHAT_LOGGER)
- {
- mEnableChatLogger = mEnableChatLoggerCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_TRADE_TAB)
- {
- mEnableTradeTab = mEnableTradeTabCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_HIDE_SHOP_MESSAGES)
- {
- mHideShopMessages = mHideShopMessagesCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SHOW_CHAT_HISTORY)
- {
- mShowChatHistory = mShowChatHistoryCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_ENABLE_BATTLE_TAB)
- {
- mEnableBattleTab = mEnableBattleTabCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_SHOW_BATTLE_EVENTS)
- {
- mShowBattleEvents = mShowBattleEventsCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_RESIZE_CHAT)
- {
- mHideChatInput = mHideChatInputCheckBox->isSelected();
- }
- else if (event.getId() == ACTION_LOCAL_TIME)
- {
- mLocalTime = mLocalTimeCheckBox->isSelected();
- }
-}
+ new SetupItemCheckBox(_("Remove colors from received chat messages"), "",
+ "removeColors", this, "removeColorsEvent");
-void Setup_Chat::cancel()
-{
- mRemoveColors = config.getBoolValue("removeColors");
- mRemoveColorsCheckBox->setSelected(mRemoveColors);
+ new SetupItemCheckBox(_("Log magic messages in debug tab"), "",
+ "showMagicInDebug", this, "showMagicInDebugEvent");
- mMagicInDebug = config.getBoolValue("showMagicInDebug");
- mMagicInDebugCheckBox->setSelected(mMagicInDebug);
+ new SetupItemCheckBox(_("Allow magic and GM commands in all chat tabs"),
+ "", "allowCommandsInChatTabs", this, "allowCommandsInChatTabsEvent");
- mAllowCommandsInChatTabs
- = config.getBoolValue("allowCommandsInChatTabs");
- mAllowCommandsInChatTabsCheckBox->setSelected(mAllowCommandsInChatTabs);
+ new SetupItemCheckBox(_("Show server messages in debug tab"), "",
+ "serverMsgInDebug", this, "serverMsgInDebugEvent");
- mServerMsgInDebug = config.getBoolValue("serverMsgInDebug");
- mServerMsgInDebugCheckBox->setSelected(mServerMsgInDebug);
+ new SetupItemCheckBox(_("Show chat colors list"), "",
+ "showChatColorsList", this, "showChatColorsListEvent");
- mShowChatColors = config.getBoolValue("showChatColorsList");
- mShowChatColorsCheckBox->setSelected(mShowChatColors);
+ new SetupItemIntTextField(_("Limit max chars in chat line"), "",
+ "chatMaxCharLimit", this, "chatMaxCharLimitEvent", 0, 500);
- int maxCharLimit = config.getIntValue("chatMaxCharLimit");
- mMaxChar = (maxCharLimit != 0);
- mMaxCharCheckBox->setSelected(mMaxChar);
- mMaxCharField->setValue(maxCharLimit);
- mMaxCharField->setEnabled(mMaxChar);
+ new SetupItemCheckBox(_("Enable chat Log"), "",
+ "enableChatLog", this, "enableChatLogEvent");
- int maxLinesLimit = config.getIntValue("chatMaxLinesLimit");
- mMaxLines = (maxLinesLimit != 0);
- mMaxLinesCheckBox->setSelected(mMaxLines);
- mMaxLinesField->setValue(maxLinesLimit);
- mMaxLinesField->setEnabled(mMaxLines);
+ new SetupItemIntTextField(_("Limit max lines in chat"), "",
+ "chatMaxLinesLimit", this, "chatMaxLinesLimitEvent", 0, 500);
- mEnableChatLogger = config.getBoolValue("enableChatLog");
- mEnableChatLoggerCheckBox->setSelected(mEnableChatLogger);
+ new SetupItemCheckBox(_("Enable trade tab"), "",
+ "enableTradeTab", this, "enableTradeTabEvent");
- mEnableTradeTab = config.getBoolValue("enableTradeTab");
- mEnableTradeTabCheckBox->setSelected(mEnableTradeTab);
+ new SetupItemCheckBox(_("Hide shop messages"), "",
+ "hideShopMessages", this, "hideShopMessagesEvent");
- mHideShopMessages = config.getBoolValue("hideShopMessages");
- mHideShopMessagesCheckBox->setSelected(mHideShopMessages);
+ new SetupItemCheckBox(_("Show chat history"), "",
+ "showChatHistory", this, "showChatHistoryEvent");
- mShowChatHistory = config.getBoolValue("showChatHistory");
- mShowChatHistoryCheckBox->setSelected(mShowChatHistory);
+ new SetupItemCheckBox(_("Enable battle tab"), "",
+ "enableBattleTab", this, "enableBattleTabEvent");
- mEnableBattleTab = config.getBoolValue("enableBattleTab");
- mEnableBattleTabCheckBox->setSelected(mEnableBattleTab);
+ new SetupItemCheckBox(_("Show battle events"), "",
+ "showBattleEvents", this, "showBattleEventsEvent");
- mShowBattleEvents = config.getBoolValue("showBattleEvents");
- mShowBattleEventsCheckBox->setSelected(mShowBattleEvents);
+ new SetupItemCheckBox(_("Resize chat tabs if need"), "",
+ "hideChatInput", this, "hideChatInputEvent");
- mHideChatInput = config.getBoolValue("hideChatInput");
- mHideChatInputCheckBox->setSelected(mHideChatInput);
+ new SetupItemCheckBox(_("Use local time"), "",
+ "useLocalTime", this, "useLocalTimeEvent");
- mLocalTime = config.getBoolValue("useLocalTime");
- mLocalTimeCheckBox->setSelected(mLocalTime);
+ setDimension(gcn::Rectangle(0, 0, 550, 350));
}
void Setup_Chat::apply()
{
- config.setValue("removeColors", mRemoveColors);
- config.setValue("showMagicInDebug", mMagicInDebug);
- config.setValue("allowCommandsInChatTabs", mAllowCommandsInChatTabs);
- config.setValue("serverMsgInDebug", mServerMsgInDebug);
- config.setValue("showChatColorsList", mShowChatColors);
- if (mMaxChar)
- config.setValue("chatMaxCharLimit", mMaxCharField->getValue());
- else
- config.setValue("chatMaxCharLimit", 0);
- if (mMaxLines)
- config.setValue("chatMaxLinesLimit", mMaxLinesField->getValue());
- else
- config.setValue("chatMaxLinesLimit", 0);
- config.setValue("enableChatLog", mEnableChatLogger);
- config.setValue("enableTradeTab", mEnableTradeTab);
- config.setValue("hideShopMessages", mHideShopMessages);
- config.setValue("showChatHistory", mShowChatHistory);
- config.setValue("enableBattleTab", mEnableBattleTab);
- config.setValue("showBattleEvents", mShowBattleEvents);
- config.setValue("hideChatInput", mHideChatInput);
- config.setValue("useLocalTime", mLocalTime);
+ SetupTabScroll::apply();
if (chatWindow)
chatWindow->adjustTabSize();