From 038355b1192fe2e6b00e29e1e20cbf9d535c99aa Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 10 Aug 2011 01:09:28 +0300 Subject: Add players setup tab. Move all player related settings from relation tab to players tab. --- src/CMakeLists.txt | 2 + src/Makefile.am | 2 + src/gui/setup.cpp | 3 + src/gui/setup_chat.cpp | 3 + src/gui/setup_players.cpp | 84 ++++++++++++++++++++++++++ src/gui/setup_players.h | 44 ++++++++++++++ src/gui/setup_relations.cpp | 144 +------------------------------------------- src/gui/setup_relations.h | 31 ---------- 8 files changed, 139 insertions(+), 174 deletions(-) create mode 100644 src/gui/setup_players.cpp create mode 100644 src/gui/setup_players.h (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2e05d5c69..9a9d09f97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -319,6 +319,8 @@ SET(SRCS gui/setup_perfomance.h gui/setup_relations.cpp gui/setup_relations.h + gui/setup_players.cpp + gui/setup_players.h gui/setup_video.cpp gui/setup_video.h gui/sdlfont.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 3871825e0..76010cb73 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -320,6 +320,8 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \ gui/setup_keyboard.h \ gui/setup_perfomance.cpp \ gui/setup_perfomance.h \ + gui/setup_players.cpp \ + gui/setup_players.h \ gui/setup_relations.cpp \ gui/setup_relations.h \ gui/setup_video.cpp \ diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp index e45bbb571..d73212d48 100644 --- a/src/gui/setup.cpp +++ b/src/gui/setup.cpp @@ -34,6 +34,7 @@ #include "gui/setup_theme.h" #include "gui/setup_keyboard.h" #include "gui/setup_perfomance.h" +#include "gui/setup_players.h" #include "gui/setup_relations.h" #include "gui/setup_video.h" @@ -86,6 +87,7 @@ Setup::Setup(): mPanel = new TabbedArea; mPanel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40)); + mPanel->enableScrollButtons(true); mTabs.push_back(new Setup_Video); mTabs.push_back(new Setup_Audio); @@ -94,6 +96,7 @@ Setup::Setup(): mTabs.push_back(new Setup_Keyboard); mTabs.push_back(new Setup_Colors); mTabs.push_back(new Setup_Chat); + mTabs.push_back(new Setup_Players); mTabs.push_back(new Setup_Relations); mTabs.push_back(new Setup_Theme); mTabs.push_back(new Setup_Other); diff --git a/src/gui/setup_chat.cpp b/src/gui/setup_chat.cpp index bdba4df7a..621f62810 100644 --- a/src/gui/setup_chat.cpp +++ b/src/gui/setup_chat.cpp @@ -93,6 +93,9 @@ Setup_Chat::Setup_Chat() new SetupItemLabel(_("Tabs"), "", this); + new SetupItemCheckBox(_("Put all whispers in tabs"), "", + "whispertab", this, "whispertabEvent"); + new SetupItemCheckBox(_("Log magic messages in debug tab"), "", "showMagicInDebug", this, "showMagicInDebugEvent"); diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp new file mode 100644 index 000000000..7490135cd --- /dev/null +++ b/src/gui/setup_players.cpp @@ -0,0 +1,84 @@ +/* + * The ManaPlus Client + * 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 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "gui/setup_players.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/scrollarea.h" + +#include "configuration.h" +#include "localplayer.h" +#include "log.h" + +#include "utils/gettext.h" + +#include "debug.h" + +Setup_Players::Setup_Players() +{ + setName(_("Players")); + + LayoutHelper h(this); + ContainerPlacer place = h.getPlacer(0, 0); + place(0, 0, mScroll, 10, 10); + + new SetupItemCheckBox(_("Show gender"), "", + "showgender", this, "showgenderEvent"); + + new SetupItemCheckBox(_("Show level"), "", + "showlevel", this, "showlevelEvent"); + + new SetupItemCheckBox(_("Show own name"), "", + "showownname", this, "showownnameEvent"); + + new SetupItemCheckBox(_("Target dead players"), "", + "targetDeadPlayers", this, "targetDeadPlayersEvent"); + + new SetupItemCheckBox(_("Visible names"), "", + "visiblenames", this, "visiblenamesEvent"); + + new SetupItemCheckBox(_("Secure trades"), "", + "securetrades", this, "securetradesEvent"); + + new SetupItemTextField(_("Unsecure chars in names"), "", + "unsecureChars", this, "unsecureCharsEvent"); + + new SetupItemCheckBox(_("Show statuses"), "", + "showPlayersStatus", this, "showPlayersStatusEvent"); + + setDimension(gcn::Rectangle(0, 0, 550, 350)); +} + +void Setup_Players::apply() +{ + SetupTabScroll::apply(); +} diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h new file mode 100644 index 000000000..c9ce7b3b3 --- /dev/null +++ b/src/gui/setup_players.h @@ -0,0 +1,44 @@ +/* + * The ManaPlus Client + * 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 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, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef GUI_SETUP_PLAYERS_H +#define GUI_SETUP_PLAYERS_H + +#include "guichanfwd.h" + +#include "gui/widgets/setuptabscroll.h" + +#include + +class IntTextField; +class EditDialog; + +class Setup_Players : public SetupTabScroll +{ + public: + Setup_Players(); + + void apply(); +}; + +#endif diff --git a/src/gui/setup_relations.cpp b/src/gui/setup_relations.cpp index 04bfa2343..646d47550 100644 --- a/src/gui/setup_relations.cpp +++ b/src/gui/setup_relations.cpp @@ -229,14 +229,6 @@ public: #define ACTION_TABLE "table" #define ACTION_STRATEGY "strategy" #define ACTION_WHISPER_TAB "whisper tab" -#define ACTION_SHOW_GENDER "show gender" -#define ACTION_SHOW_LEVEL "show level" -#define ACTION_TARGET_DEAD "target dead" -#define ACTION_SHOW_OWN_NAME "show own name" -#define ACTION_SECURE_TRADES "secure trades" -#define ACTION_UNSECURE "unsecure" -#define ACTION_EDIT_UNSECURE "edit unsecure" -#define ACTION_EDIT_UNSECURE_OK "edit unsecure ok" Setup_Relations::Setup_Relations(): mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), @@ -249,20 +241,7 @@ Setup_Relations::Setup_Relations(): mDefaultWhisper(new CheckBox(_("Allow whispers"), player_relations.getDefault() & PlayerRelation::WHISPER)), mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)), - mOldButton(new Button(_("Old"), ACTION_OLD, this)), - mWhisperTab(config.getBoolValue("whispertab")), - mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), - mWhisperTab)), - mShowGender(config.getBoolValue("showgender")), - mShowGenderCheckBox(new CheckBox(_("Show gender"), mShowGender)), - mShowLevel(config.getBoolValue("showlevel")), - mShowOwnName(config.getBoolValue("showownname")), - mTargetDead(config.getBoolValue("targetDeadPlayers")), - mSecureTrades(config.getBoolValue("securetrades")), - mUnsecureChars(config.getStringValue("unsecureChars")), - mVisibleNamesEnabled(config.getBoolValue("visiblenames")), - mShowPlayersStatus(config.getBoolValue("showPlayersStatus")), - mEditDialog(0) + mOldButton(new Button(_("Old"), ACTION_OLD, this)) { setName(_("Relations")); @@ -306,43 +285,6 @@ Setup_Relations::Setup_Relations(): mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); mIgnoreActionChoicesBox->adjustHeight(); - mWhisperTabCheckBox->setActionEventId(ACTION_WHISPER_TAB); - mWhisperTabCheckBox->addActionListener(this); - - mShowGenderCheckBox->setActionEventId(ACTION_SHOW_GENDER); - mShowGenderCheckBox->addActionListener(this); - - mShowLevelCheckBox = new CheckBox(_("Show level"), mShowLevel); - mShowLevelCheckBox->setActionEventId(ACTION_SHOW_LEVEL); - mShowLevelCheckBox->addActionListener(this); - - mShowOwnNameCheckBox = new CheckBox(_("Show own name"), mShowOwnName); - mShowOwnNameCheckBox->setActionEventId(ACTION_SHOW_OWN_NAME); - mShowOwnNameCheckBox->addActionListener(this); - - mTargetDeadCheckBox = new CheckBox(_("Target dead players"), mTargetDead); - mTargetDeadCheckBox->setActionEventId(ACTION_TARGET_DEAD); - mTargetDeadCheckBox->addActionListener(this); - - mSecureTradesCheckBox = new CheckBox(_("Secure trades"), mSecureTrades); - mSecureTradesCheckBox->setActionEventId(ACTION_SECURE_TRADES); - mSecureTradesCheckBox->addActionListener(this); - - mUnsecureCharsLabel = new Label(_("Unsecure chars in names")); - mUnsecureCharsField = new TextField(mUnsecureChars, - true, this, ACTION_UNSECURE); - mUnsecureCharsButton = new Button(_("Edit"), ACTION_EDIT_UNSECURE, this); - - mVisibleNamesCheckBox = new CheckBox(_("Visible names"), - mVisibleNamesEnabled); - mVisibleNamesCheckBox->setActionEventId("visiblenames"); - mVisibleNamesCheckBox->addActionListener(this); - - mShowPlayersStatusCheckBox = new CheckBox(_("Show statuses"), - mShowPlayersStatus); - mShowPlayersStatusCheckBox->setActionEventId("showPlayersStatus"); - mShowPlayersStatusCheckBox->addActionListener(this); - reset(); // Do the layout @@ -352,22 +294,11 @@ Setup_Relations::Setup_Relations(): place(0, 0, mPlayerTitleTable, 6); place(0, 1, mPlayerScrollArea, 6, 4).setPadding(2); place(0, 5, mDeleteButton); - place(0, 6, mShowGenderCheckBox, 3).setPadding(2); - place(0, 7, mShowLevelCheckBox, 3).setPadding(2); - place(0, 8, mShowOwnNameCheckBox, 3).setPadding(2); place(1, 5, mOldButton, 1); place(3, 5, ignore_action_label, 1); place(4, 5, mIgnoreActionChoicesBox, 2).setPadding(2); place(3, 6, mDefaultTrading, 3); place(3, 7, mDefaultWhisper, 3); - place(3, 8, mSecureTradesCheckBox, 3); - place(3, 9, mUnsecureCharsLabel, 3); - place(3, 10, mUnsecureCharsField, 2); - place(3, 11, mShowPlayersStatusCheckBox, 2); - place(5, 10, mUnsecureCharsButton, 1); - place(0, 9, mWhisperTabCheckBox, 3).setPadding(4); - place(0, 10, mTargetDeadCheckBox, 3).setPadding(4); - place(0, 11, mVisibleNamesCheckBox, 3).setPadding(4); player_relations.addListener(this); @@ -414,15 +345,6 @@ void Setup_Relations::apply() PlayerRelation::TRADE : 0) | (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0)); - config.setValue("whispertab", mWhisperTab); - config.setValue("showlevel", mShowLevel); - config.setValue("showownname", mShowOwnName); - config.setValue("targetDeadPlayers", mTargetDead); - config.setValue("showgender", mShowGender); - config.setValue("securetrades", mSecureTrades); - config.setValue("unsecureChars", mUnsecureCharsField->getText()); - config.setValue("visiblenames", mVisibleNamesEnabled); - config.setValue("showPlayersStatus", mShowPlayersStatus); if (actorSpriteManager) actorSpriteManager->updatePlayerNames(); @@ -433,24 +355,6 @@ void Setup_Relations::apply() void Setup_Relations::cancel() { - mWhisperTab = config.getBoolValue("whispertab"); - mWhisperTabCheckBox->setSelected(mWhisperTab); - mShowGender = config.getBoolValue("showgender"); - mShowGenderCheckBox->setSelected(mShowGender); - mShowLevel = config.getBoolValue("showlevel"); - mShowLevelCheckBox->setSelected(mShowLevel); - mShowOwnName = config.getBoolValue("showownname"); - mShowOwnNameCheckBox->setSelected(mShowOwnName); - mTargetDead = config.getBoolValue("targetDeadPlayers"); - mTargetDeadCheckBox->setSelected(mTargetDead); - mSecureTrades = config.getBoolValue("securetrades"); - mSecureTradesCheckBox->setSelected(mSecureTrades); - mUnsecureChars = config.getStringValue("unsecureChars"); - mUnsecureCharsField->setText(mUnsecureChars); - mVisibleNamesEnabled = config.getBoolValue("visiblenames"); - mVisibleNamesCheckBox->setSelected(mVisibleNamesEnabled); - mShowPlayersStatus = config.getBoolValue("showPlayersStatus"); - mShowPlayersStatusCheckBox->setSelected(mShowPlayersStatus); } void Setup_Relations::action(const gcn::ActionEvent &event) @@ -494,52 +398,6 @@ void Setup_Relations::action(const gcn::ActionEvent &event) player_relations.setPlayerIgnoreStrategy(s); } - else if (event.getId() == ACTION_WHISPER_TAB) - { - mWhisperTab = mWhisperTabCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SHOW_GENDER) - { - mShowGender = mShowGenderCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SHOW_LEVEL) - { - mShowLevel = mShowLevelCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SHOW_OWN_NAME) - { - mShowOwnName = mShowOwnNameCheckBox->isSelected(); - } - else if (event.getId() == ACTION_TARGET_DEAD) - { - mTargetDead = mTargetDeadCheckBox->isSelected(); - } - else if (event.getId() == ACTION_SECURE_TRADES) - { - mSecureTrades = mSecureTradesCheckBox->isSelected(); - } - else if (event.getId() == ACTION_EDIT_UNSECURE) - { - mEditDialog = new EditDialog(_("Unsecure chars in names"), - mUnsecureCharsField->getText(), ACTION_EDIT_UNSECURE_OK); - mEditDialog->addActionListener(this); - } - else if (event.getId() == ACTION_EDIT_UNSECURE_OK) - { - mUnsecureCharsField->setText(mEditDialog->getMsg()); - } - else if (event.getId() == ACTION_UNSECURE) - { - mUnsecureChars = mUnsecureCharsField->getText(); - } - else if (event.getId() == "visiblenames") - { - mVisibleNamesEnabled = mVisibleNamesCheckBox->isSelected(); - } - else if (event.getId() == "showPlayersStatus") - { - mShowPlayersStatus = mShowPlayersStatusCheckBox->isSelected(); - } } void Setup_Relations::updatedPlayer(const std::string &name A_UNUSED) diff --git a/src/gui/setup_relations.h b/src/gui/setup_relations.h index eab3c7661..a6627a06d 100644 --- a/src/gui/setup_relations.h +++ b/src/gui/setup_relations.h @@ -76,37 +76,6 @@ private: gcn::ListModel *mIgnoreActionChoicesModel; gcn::DropDown *mIgnoreActionChoicesBox; - - bool mWhisperTab; - gcn::CheckBox *mWhisperTabCheckBox; - - bool mShowGender; - gcn::CheckBox *mShowGenderCheckBox; - - bool mShowLevel; - gcn::CheckBox *mShowLevelCheckBox; - - bool mShowOwnName; - gcn::CheckBox *mShowOwnNameCheckBox; - - bool mTargetDead; - gcn::CheckBox *mTargetDeadCheckBox; - - bool mSecureTrades; - gcn::CheckBox *mSecureTradesCheckBox; - - gcn::Label *mUnsecureCharsLabel; - gcn::TextField *mUnsecureCharsField; - gcn::Button *mUnsecureCharsButton; - std::string mUnsecureChars; - - bool mVisibleNamesEnabled; - gcn::CheckBox *mVisibleNamesCheckBox; - - bool mShowPlayersStatus; - gcn::CheckBox *mShowPlayersStatusCheckBox; - - EditDialog *mEditDialog; }; #endif -- cgit v1.2.3-60-g2f50