summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-08 00:44:12 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-08 00:51:30 +0200
commitaefbc69aac9f7c793725153eefce2631555bfd1f (patch)
treedc43d7d5cb5cf84373ee43a02998349d1deb3e0c
parent3b229e19c2b7545a71a066383872acd5d9348e41 (diff)
downloadmana-client-aefbc69aac9f7c793725153eefce2631555bfd1f.tar.gz
mana-client-aefbc69aac9f7c793725153eefce2631555bfd1f.tar.bz2
mana-client-aefbc69aac9f7c793725153eefce2631555bfd1f.tar.xz
mana-client-aefbc69aac9f7c793725153eefce2631555bfd1f.zip
Associated setup tab name with the tab itself
Keeps things together in the right place and allowed writing a bit more generic code in the Setup class.
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/setup.cpp38
-rw-r--r--src/gui/setup.h17
-rw-r--r--src/gui/setup_audio.cpp2
-rw-r--r--src/gui/setup_colors.cpp2
-rw-r--r--src/gui/setup_joystick.cpp2
-rw-r--r--src/gui/setup_keyboard.cpp2
-rw-r--r--src/gui/setup_keyboard.h4
-rw-r--r--src/gui/setup_players.cpp3
-rw-r--r--src/gui/setup_video.cpp2
-rw-r--r--src/gui/setuptab.cpp27
-rw-r--r--src/gui/setuptab.h34
-rw-r--r--src/net/ea/charserverhandler.cpp2
-rw-r--r--src/net/ea/generalhandler.cpp1
-rw-r--r--src/net/ea/maphandler.cpp1
16 files changed, 92 insertions, 47 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 87392c8b..7bce856b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -206,6 +206,7 @@ SET(SRCS
gui/setup_players.h
gui/setup_video.cpp
gui/setup_video.h
+ gui/setuptab.cpp
gui/setuptab.h
gui/shop.cpp
gui/shop.h
diff --git a/src/Makefile.am b/src/Makefile.am
index bfb487fe..df2a11d9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -154,6 +154,7 @@ tmw_SOURCES = gui/widgets/avatar.cpp \
gui/setup_players.h \
gui/setup_video.cpp \
gui/setup_video.h \
+ gui/setuptab.cpp \
gui/setuptab.h \
gui/shop.cpp \
gui/shop.h \
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 7eb740b1..50068c6e 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -85,31 +85,19 @@ Setup::Setup():
TabbedArea *panel = new TabbedArea;
panel->setDimension(gcn::Rectangle(5, 5, width - 10, height - 40));
- SetupTab *tab;
-
- tab = new Setup_Video();
- panel->addTab(_("Video"), tab);
- mTabs.push_back(tab);
-
- tab = new Setup_Audio();
- panel->addTab(_("Audio"), tab);
- mTabs.push_back(tab);
-
- tab = new Setup_Joystick();
- panel->addTab(_("Joystick"), tab);
- mTabs.push_back(tab);
-
- tab = new Setup_Keyboard();
- panel->addTab(_("Keyboard"), tab);
- mTabs.push_back(tab);
-
- tab = new Setup_Colors();
- panel->addTab(_("Colors"), tab);
- mTabs.push_back(tab);
-
- tab = new Setup_Players();
- panel->addTab(_("Players"), tab);
- mTabs.push_back(tab);
+ mTabs.push_back(new Setup_Video);
+ mTabs.push_back(new Setup_Audio);
+ mTabs.push_back(new Setup_Joystick);
+ mTabs.push_back(new Setup_Keyboard);
+ mTabs.push_back(new Setup_Colors);
+ mTabs.push_back(new Setup_Players);
+
+ for (std::list<SetupTab*>::iterator i = mTabs.begin(), i_end = mTabs.end();
+ i != i_end; ++i)
+ {
+ SetupTab *tab = *i;
+ panel->addTab(tab->getName(), tab);
+ }
add(panel);
diff --git a/src/gui/setup.h b/src/gui/setup.h
index 0c97370f..630d5eaa 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -33,21 +33,22 @@
class SetupTab;
/**
- * The setup dialog.
+ * The setup dialog. Displays several tabs for configuring different aspects
+ * of the game.
+ *
+ * @see Setup_Audio
+ * @see Setup_Colors
+ * @see Setup_Joystick
+ * @see Setup_Keyboard
+ * @see Setup_Players
+ * @see Setup_Video
*
* \ingroup GUI
*/
class Setup : public Window, public gcn::ActionListener
{
public:
- /**
- * Constructor.
- */
Setup();
-
- /**
- * Destructor.
- */
~Setup();
/**
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index 78817328..c0c2b9e4 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -44,7 +44,7 @@ Setup_Audio::Setup_Audio():
mSfxSlider(new Slider(0, 128)),
mMusicSlider(new Slider(0, 128))
{
- setOpaque(false);
+ setName(_("Audio"));
setDimension(gcn::Rectangle(0, 0, 250, 200));
gcn::Label *sfxLabel = new Label(_("Sfx volume"));
diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp
index fec503ef..6aad1023 100644
--- a/src/gui/setup_colors.cpp
+++ b/src/gui/setup_colors.cpp
@@ -46,7 +46,7 @@ const std::string Setup_Colors::rawmsg = _("This is what the color looks like");
Setup_Colors::Setup_Colors() :
mSelected(-1)
{
- setOpaque(false);
+ setName(_("Colors"));
mColorBox = new ListBox(guiPalette);
mColorBox->setActionEventId("color_box");
diff --git a/src/gui/setup_joystick.cpp b/src/gui/setup_joystick.cpp
index 4a78d1ef..08a80bf7 100644
--- a/src/gui/setup_joystick.cpp
+++ b/src/gui/setup_joystick.cpp
@@ -38,7 +38,7 @@ Setup_Joystick::Setup_Joystick():
mCalibrateButton(new Button(_("Calibrate"), "calibrate", this)),
mJoystickEnabled(new CheckBox(_("Enable joystick")))
{
- setOpaque(false);
+ setName(_("Joystick"));
mOriginalJoystickEnabled = !config.getValue("joystickEnabled", false);
mJoystickEnabled->setSelected(mOriginalJoystickEnabled);
diff --git a/src/gui/setup_keyboard.cpp b/src/gui/setup_keyboard.cpp
index 8383af97..9e43b322 100644
--- a/src/gui/setup_keyboard.cpp
+++ b/src/gui/setup_keyboard.cpp
@@ -74,7 +74,7 @@ Setup_Keyboard::Setup_Keyboard():
mKeySetting(false)
{
keyboard.setSetupKeyboard(this);
- setOpaque(false);
+ setName(_("Keyboard"));
refreshKeys();
diff --git a/src/gui/setup_keyboard.h b/src/gui/setup_keyboard.h
index dee12135..cd1c57fb 100644
--- a/src/gui/setup_keyboard.h
+++ b/src/gui/setup_keyboard.h
@@ -26,9 +26,9 @@
#include <guichan/actionlistener.hpp>
-#include "setuptab.h"
+#include "gui/setuptab.h"
-#include "../guichanfwd.h"
+#include "guichanfwd.h"
class Setup_Keyboard : public SetupTab, public gcn::ActionListener
{
diff --git a/src/gui/setup_players.cpp b/src/gui/setup_players.cpp
index 3f3ea446..8925016b 100644
--- a/src/gui/setup_players.cpp
+++ b/src/gui/setup_players.cpp
@@ -232,7 +232,8 @@ Setup_Players::Setup_Players():
player_relations.getDefault() & PlayerRelation::WHISPER)),
mDeleteButton(new Button(_("Delete"), ACTION_DELETE, this))
{
- setOpaque(false);
+ setName(_("Players"));
+
mPlayerTable->setOpaque(false);
mPlayerTableTitleModel->fixColumnWidth(NAME_COLUMN, NAME_COLUMN_WIDTH);
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 45ec29b9..e8db997e 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -148,7 +148,7 @@ Setup_Video::Setup_Video():
mParticleDetailSlider(new Slider(0, 3)),
mParticleDetailField(new Label(""))
{
- setOpaque(false);
+ setName(_("Video"));
ScrollArea *scrollArea = new ScrollArea(mModeList);
scrollArea->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
diff --git a/src/gui/setuptab.cpp b/src/gui/setuptab.cpp
new file mode 100644
index 00000000..917e15db
--- /dev/null
+++ b/src/gui/setuptab.cpp
@@ -0,0 +1,27 @@
+/*
+ * The Mana World
+ * Copyright (C) 2009 The Mana World Development Team
+ *
+ * This file is part of The Mana World.
+ *
+ * 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/setuptab.h"
+
+SetupTab::SetupTab()
+{
+ setOpaque(false);
+}
diff --git a/src/gui/setuptab.h b/src/gui/setuptab.h
index c4f9f1dd..7b92e2fe 100644
--- a/src/gui/setuptab.h
+++ b/src/gui/setuptab.h
@@ -24,11 +24,39 @@
#include "gui/widgets/gccontainer.h"
+#include <string>
+
+/**
+ * A container for the contents of a tab in the setup window.
+ */
class SetupTab : public GCContainer
{
- public:
- virtual void apply() = 0;
- virtual void cancel() = 0;
+public:
+ SetupTab();
+
+ const std::string &getName() const
+ { 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;
+
+protected:
+ /**
+ * Sets the name displayed on the tab. Should be set in the
+ * constructor of a subclass.
+ */
+ void setName(const std::string &name)
+ { mName = name; }
+
+private:
+ std::string mName;
};
#endif
diff --git a/src/net/ea/charserverhandler.cpp b/src/net/ea/charserverhandler.cpp
index 0fcc2cb0..2973fc4c 100644
--- a/src/net/ea/charserverhandler.cpp
+++ b/src/net/ea/charserverhandler.cpp
@@ -61,7 +61,7 @@ CharServerHandler::CharServerHandler():
void CharServerHandler::handleMessage(MessageIn &msg)
{
- int slot, flags, code;
+ int slot, flags;
LocalPlayer *tempPlayer;
logger->log("CharServerHandler: Packet ID: %x, Length: %d",
diff --git a/src/net/ea/generalhandler.cpp b/src/net/ea/generalhandler.cpp
index 5d204ab5..e0974e63 100644
--- a/src/net/ea/generalhandler.cpp
+++ b/src/net/ea/generalhandler.cpp
@@ -85,7 +85,6 @@ GeneralHandler::GeneralHandler():
void GeneralHandler::handleMessage(MessageIn &msg)
{
int code;
- unsigned char direction;
switch (msg.getId())
{
diff --git a/src/net/ea/maphandler.cpp b/src/net/ea/maphandler.cpp
index 6fd27755..de60059f 100644
--- a/src/net/ea/maphandler.cpp
+++ b/src/net/ea/maphandler.cpp
@@ -54,7 +54,6 @@ MapHandler::MapHandler()
void MapHandler::handleMessage(MessageIn &msg)
{
- int code;
unsigned char direction;
switch (msg.getId())