summaryrefslogtreecommitdiff
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
parent5eba7b23b7002a3f399afa7e51066a6b16a1f9a6 (diff)
downloadmv-2881720bca7168ca181a13bfd4dd69115a46c2f9.tar.gz
mv-2881720bca7168ca181a13bfd4dd69115a46c2f9.tar.bz2
mv-2881720bca7168ca181a13bfd4dd69115a46c2f9.tar.xz
mv-2881720bca7168ca181a13bfd4dd69115a46c2f9.zip
Redesign Chat setup page.
-rw-r--r--src/gui/setup_chat.cpp313
-rw-r--r--src/gui/setup_chat.h60
-rw-r--r--src/gui/setup_colors.cpp1
-rw-r--r--src/gui/setup_colors.h1
-rw-r--r--src/gui/setupitem.cpp133
-rw-r--r--src/gui/setupitem.h36
6 files changed, 215 insertions, 329 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();
diff --git a/src/gui/setup_chat.h b/src/gui/setup_chat.h
index 1ee325117..0b69984c8 100644
--- a/src/gui/setup_chat.h
+++ b/src/gui/setup_chat.h
@@ -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.
*
@@ -25,74 +26,19 @@
#include "guichanfwd.h"
-#include "gui/widgets/setuptab.h"
+#include "gui/widgets/setuptabscroll.h"
#include <guichan/actionlistener.hpp>
class IntTextField;
class EditDialog;
-class Setup_Chat : public SetupTab
+class Setup_Chat : public SetupTabScroll
{
public:
Setup_Chat();
void apply();
- void cancel();
-
- void action(const gcn::ActionEvent &event);
-
- private:
- gcn::CheckBox *mRemoveColorsCheckBox;
- bool mRemoveColors;
-
- gcn::CheckBox *mMagicInDebugCheckBox;
- bool mMagicInDebug;
-
- gcn::CheckBox *mAllowCommandsInChatTabsCheckBox;
- bool mAllowCommandsInChatTabs;
-
- gcn::CheckBox *mServerMsgInDebugCheckBox;
- bool mServerMsgInDebug;
-
- gcn::CheckBox *mShowChatColorsCheckBox;
- bool mShowChatColors;
-
- gcn::CheckBox *mMaxCharCheckBox;
- IntTextField *mMaxCharField;
- gcn::Button *mMaxCharButton;
- bool mMaxChar;
-
- gcn::CheckBox *mMaxLinesCheckBox;
- IntTextField *mMaxLinesField;
- gcn::Button *mMaxLinesButton;
- bool mMaxLines;
-
- gcn::CheckBox *mEnableChatLoggerCheckBox;
- bool mEnableChatLogger;
-
- gcn::CheckBox *mEnableTradeTabCheckBox;
- bool mEnableTradeTab;
-
- gcn::CheckBox *mHideShopMessagesCheckBox;
- bool mHideShopMessages;
-
- gcn::CheckBox *mShowChatHistoryCheckBox;
- bool mShowChatHistory;
-
- gcn::CheckBox *mEnableBattleTabCheckBox;
- bool mEnableBattleTab;
-
- gcn::CheckBox *mShowBattleEventsCheckBox;
- bool mShowBattleEvents;
-
- gcn::CheckBox *mHideChatInputCheckBox;
- bool mHideChatInput;
-
- gcn::CheckBox *mLocalTimeCheckBox;
- bool mLocalTime;
-
- EditDialog *mEditDialog;
};
#endif
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index c3bda11bc..d11e996a5 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -1,6 +1,7 @@
/*
* Configurable text colors
* Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
+ * Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
diff --git a/src/gui/setup_colors.h b/src/gui/setup_colors.h
index 08c558c78..d71c8fc5c 100644
--- a/src/gui/setup_colors.h
+++ b/src/gui/setup_colors.h
@@ -1,6 +1,7 @@
/*
* Configurable text colors
* Copyright (C) 2008 Douglas Boffey <dougaboffey@netscape.net>
+ * Copyright (C) 2011 The ManaPlus Developers
*
* This file is part of The ManaPlus Client.
*
diff --git a/src/gui/setupitem.cpp b/src/gui/setupitem.cpp
index 625be8580..e1b2903b2 100644
--- a/src/gui/setupitem.cpp
+++ b/src/gui/setupitem.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/horizontcontainer.h"
+#include "gui/widgets/inttextfield.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/tabbedarea.h"
@@ -303,3 +304,135 @@ void SetupItemTextField::apply(std::string eventName)
fromWidget();
save();
}
+
+
+
+
+
+
+
+
+
+
+
+
+SetupItemIntTextField::SetupItemIntTextField(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ int min, int max,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mTextField(0),
+ mButton(0),
+ mMin(min),
+ mMax(max),
+ mEditDialog(0)
+{
+ createControls();
+}
+
+SetupItemIntTextField::SetupItemIntTextField(std::string text,
+ std::string description,
+ std::string keyName,
+ SetupTabScroll *parent,
+ std::string eventName,
+ int min, int max,
+ std::string def,
+ bool mainConfig) :
+ SetupItem(text, description, keyName, parent, eventName, def, mainConfig),
+ mHorizont(0),
+ mLabel(0),
+ mTextField(0),
+ mButton(0),
+ mMin(min),
+ mMax(max),
+ mEditDialog(0)
+{
+ createControls();
+}
+
+SetupItemIntTextField::~SetupItemIntTextField()
+{
+ mHorizont = 0;
+ mWidget = 0;
+ mTextField = 0;
+ mLabel = 0;
+ mButton = 0;
+}
+
+void SetupItemIntTextField::createControls()
+{
+ load();
+ mHorizont = new HorizontContainer(32, 2);
+
+ mLabel = new Label(mText);
+ mTextField = new IntTextField(atoi(mValue.c_str()), mMin, mMax, true, 30);
+ mTextField->setActionEventId(mEventName);
+ mTextField->addActionListener(mParent);
+
+ mButton = new Button(_("Edit"), mEventName + "_EDIT", mParent);
+ mWidget = mTextField;
+ mTextField->setWidth(200);
+ mHorizont->add(mLabel);
+ mHorizont->add(mTextField);
+ mHorizont->add(mButton);
+
+ mParent->getContainer()->add(mHorizont, true, 4);
+ mParent->addControl(this);
+ mParent->addControl(this, mEventName + "_EDIT");
+ mParent->addControl(this, mEventName + "_EDIT_OK");
+ mParent->addActionListener(this);
+ mWidget->addActionListener(this);
+ mButton->addActionListener(this);
+}
+
+void SetupItemIntTextField::fromWidget()
+{
+ if (!mTextField)
+ return;
+
+ mValue = mTextField->getText();
+}
+
+void SetupItemIntTextField::toWidget()
+{
+ if (!mTextField)
+ return;
+
+ mTextField->setText(mValue);
+}
+
+void SetupItemIntTextField::action(const gcn::ActionEvent &event)
+{
+ if (!mTextField)
+ return;
+
+ if (event.getId() == mWidget->getActionEventId())
+ {
+ fromWidget();
+ }
+ else if (event.getId() == mEventName + "_EDIT")
+ {
+ mEditDialog = new EditDialog(mText, mTextField->getText(),
+ mEventName + "_EDIT_OK");
+ mEditDialog->addActionListener(this);
+ }
+ else if (event.getId() == mEventName + "_EDIT_OK")
+ {
+ mTextField->setValue(atoi(mEditDialog->getMsg().c_str()));
+ mEditDialog = 0;
+ }
+}
+
+void SetupItemIntTextField::apply(std::string eventName)
+{
+ if (eventName != mEventName)
+ return;
+
+ fromWidget();
+ save();
+}
diff --git a/src/gui/setupitem.h b/src/gui/setupitem.h
index d1cec0717..b5ea566da 100644
--- a/src/gui/setupitem.h
+++ b/src/gui/setupitem.h
@@ -44,6 +44,7 @@ class Configuration;
class ContainerPlacer;
class EditDialog;
class HorizontContainer;
+class IntTextField;
class Label;
class TextField;
@@ -172,4 +173,39 @@ class SetupItemTextField : public SetupItem
EditDialog *mEditDialog;
};
+class SetupItemIntTextField : public SetupItem
+{
+ public:
+ SetupItemIntTextField(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ bool mainConfig = true);
+
+ SetupItemIntTextField(std::string text, std::string description,
+ std::string keyName, SetupTabScroll *parent,
+ std::string eventName, int min, int max,
+ std::string def, bool mainConfig = true);
+
+ ~SetupItemIntTextField();
+
+ void createControls();
+
+ void fromWidget();
+
+ void toWidget();
+
+ void action(const gcn::ActionEvent &event);
+
+ void apply(std::string eventName);
+
+ protected:
+ HorizontContainer *mHorizont;
+ Label *mLabel;
+ IntTextField *mTextField;
+ Button *mButton;
+ int mMin;
+ int mMax;
+ EditDialog *mEditDialog;
+};
+
#endif