From 72278cfec112e06b50ba06185fb59a2ce390d955 Mon Sep 17 00:00:00 2001 From: Jared Adams Date: Wed, 15 Apr 2009 13:39:01 -0600 Subject: Add a config option to always use whipser tabs --- src/gui/chat.cpp | 13 ++++++++----- src/gui/chat.h | 2 +- src/gui/setup_players.cpp | 16 +++++++++++++++- src/gui/setup_players.h | 3 +++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 30511ef9..46611b78 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -426,6 +426,11 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) ChatTab *tab = mWhispers[tempNick]; + if (!tab && config.getValue("whispertab", false)) + { + tab = addWhisperTab(nick); + } + if (tab) { if (own) @@ -447,7 +452,7 @@ void ChatWindow::whisper(std::string nick, std::string mes, bool own) } } -bool ChatWindow::addWhisperTab(std::string nick) +ChatTab *ChatWindow::addWhisperTab(std::string nick) { std::string playerName = player_node->getName(); std::string tempNick = nick; @@ -456,9 +461,7 @@ bool ChatWindow::addWhisperTab(std::string nick) toLower(tempNick); if (mWhispers[tempNick] || tempNick.compare(playerName) == 0) - return false; - - mWhispers[tempNick] = new WhisperTab(nick); + return NULL; - return true; + return mWhispers[tempNick] = new WhisperTab(nick); } diff --git a/src/gui/chat.h b/src/gui/chat.h index f5af7558..9f762f8e 100644 --- a/src/gui/chat.h +++ b/src/gui/chat.h @@ -173,7 +173,7 @@ class ChatWindow : public Window, void whisper(std::string nick, std::string mes, bool own = false); - bool addWhisperTab(std::string nick); + ChatTab *addWhisperTab(std::string nick); protected: friend class ChatTab; diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp index 9a3d6967..9f084e60 100644 --- a/src/gui/setup_players.cpp +++ b/src/gui/setup_players.cpp @@ -217,6 +217,7 @@ public: #define ACTION_DELETE "delete" #define ACTION_TABLE "table" #define ACTION_STRATEGY "strategy" +#define ACTION_WHISPER_TAB "whisper tab" Setup_Players::Setup_Players(): mPlayerTableTitleModel(new StaticTableModel(1, COLUMNS_NR)), @@ -230,7 +231,9 @@ Setup_Players::Setup_Players(): player_relations.getDefault() & PlayerRelation::TRADE)), mDefaultWhisper(new CheckBox(_("Allow whispers"), player_relations.getDefault() & PlayerRelation::WHISPER)), - mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)) + mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this)), + mWhisperTab(config.getValue("whispertab", false)), + mWhisperTabCheckBox(new CheckBox(_("Put all whispers in tabs"), mWhisperTab)) { setName(_("Players")); @@ -275,6 +278,9 @@ Setup_Players::Setup_Players(): mIgnoreActionChoicesBox->setSelected(ignore_strategy_index); mIgnoreActionChoicesBox->adjustHeight(); + mWhisperTabCheckBox->setActionEventId(ACTION_WHISPER_TAB); + mWhisperTabCheckBox->addActionListener(this); + reset(); // Do the layout @@ -284,6 +290,7 @@ Setup_Players::Setup_Players(): place(0, 0, mPlayerTitleTable, 4); place(0, 1, mPlayerScrollArea, 4, 4).setPadding(2); place(0, 5, mDeleteButton); + place(0, 6, mWhisperTabCheckBox); place(2, 5, ignore_action_label); place(2, 6, mIgnoreActionChoicesBox, 2).setPadding(2); place(2, 7, mPersistIgnores); @@ -334,10 +341,13 @@ void Setup_Players::apply() PlayerRelation::TRADE : 0) | (mDefaultWhisper->isSelected() ? PlayerRelation::WHISPER : 0)); + config.setValue("whispertab", mWhisperTab); } void Setup_Players::cancel() { + mWhisperTab = config.getValue("whispertab", false); + mWhisperTabCheckBox->setSelected(mWhisperTab); } void Setup_Players::action(const gcn::ActionEvent &event) @@ -377,6 +387,10 @@ void Setup_Players::action(const gcn::ActionEvent &event) player_relations.setPlayerIgnoreStrategy(s); } + else if (event.getId() == ACTION_WHISPER_TAB) + { + mWhisperTab = mWhisperTabCheckBox->isSelected(); + } } void Setup_Players::updatedPlayer(const std::string &name) diff --git a/src/gui/setup_players.h b/src/gui/setup_players.h index 491054c3..14b9a018 100644 --- a/src/gui/setup_players.h +++ b/src/gui/setup_players.h @@ -64,6 +64,9 @@ private: gcn::Button *mDeleteButton; gcn::DropDown *mIgnoreActionChoicesBox; + + bool mWhisperTab; + gcn::CheckBox *mWhisperTabCheckBox; }; #endif -- cgit v1.2.3-60-g2f50