summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--src/gui/login.cpp3
-rw-r--r--src/gui/setup.cpp33
-rw-r--r--src/gui/setup_audio.cpp9
-rw-r--r--src/gui/setup_audio.h6
-rw-r--r--src/gui/setup_video.cpp17
-rw-r--r--src/gui/setup_video.h10
7 files changed, 36 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ec488d4..9c0a1f2a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2006-03-19 Björn Steinbrink <B.Steinbrink@gmx.de>
+ * src/gui/login.cpp, src/gui/setup_audio.h, src/gui/setup.cpp,
+ src/gui/setup_audio.cpp, src/gui/setup_video.cpp,
+ src/gui/setup_video.h: Removed some duplicated initializations.
* src/gui/setup_audio.h, src/gui/setup.cpp, src/gui/setup_audio.cpp,
src/gui/setup_joystick.h, src/gui/setup_video.cpp, src/gui/setuptab.h,
src/gui/setup.h, src/gui/setup_joystick.cpp, src/gui/setup_video.h,
diff --git a/src/gui/login.cpp b/src/gui/login.cpp
index ee648669..c0dd9245 100644
--- a/src/gui/login.cpp
+++ b/src/gui/login.cpp
@@ -63,7 +63,7 @@ LoginDialog::LoginDialog(LoginData *loginData):
mUserField = new TextField(mLoginData->username);
mPassField = new PasswordField(mLoginData->password);
mServerField = new TextField(mLoginData->hostname);
- mKeepCheck = new CheckBox("Keep", false);
+ mKeepCheck = new CheckBox("Keep", mLoginData->remember);
mOkButton = new Button("OK", "ok", this);
mCancelButton = new Button("Cancel", "cancel", this);
mRegisterButton = new Button("Register", "register", this);
@@ -82,7 +82,6 @@ LoginDialog::LoginDialog(LoginData *loginData):
mPassField->setWidth(130);
mServerField->setWidth(130);
mKeepCheck->setPosition(4, 77);
- mKeepCheck->setMarked(mLoginData->remember);
mCancelButton->setPosition(
200 - mCancelButton->getWidth() - 5,
100 - mCancelButton->getHeight() - 5);
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 82b77284..91bd5ce7 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -42,24 +42,20 @@ extern Window *skillDialog;
Setup::Setup():
Window("Setup")
{
- Button *applyButton = new Button("Apply", "apply", this);
- Button *cancelButton = new Button("Cancel", "cancel", this);
- Button *resetWinsToDefault = new Button("Reset Windows", "winsToDefault", this);
-
- // Set dimensions/positions
int width = 230;
int height = 185;
setContentSize(width, height);
- cancelButton->setPosition(
- width - cancelButton->getWidth() - 5,
- height - cancelButton->getHeight() - 5);
- applyButton->setPosition(
- cancelButton->getX() - applyButton->getWidth() - 5,
- cancelButton->getY());
- resetWinsToDefault->setPosition(
- applyButton->getX() - resetWinsToDefault->getWidth() - 5,
- applyButton->getY());
+ const char *buttonNames[] = {
+ "Apply", "Cancel", "Reset Windows", 0
+ };
+ int x = width;
+ for (const char **curBtn = buttonNames; *curBtn; ++curBtn) {
+ Button *btn = new Button(*curBtn, *curBtn, this);
+ x -= btn->getWidth() + 5;
+ btn->setPosition(x, height - btn->getHeight() - 5);
+ add(btn);
+ }
TabbedContainer *panel = new TabbedContainer();
panel->setDimension(gcn::Rectangle(5, 5, 220, 130));
@@ -80,9 +76,6 @@ Setup::Setup():
mTabs.push_back(tab);
add(panel);
- add(resetWinsToDefault);
- add(applyButton);
- add(cancelButton);
setLocationRelativeTo(getParent());
}
@@ -94,17 +87,17 @@ Setup::~Setup()
void Setup::action(const std::string &event)
{
- if (event == "apply")
+ if (event == "Apply")
{
setVisible(false);
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::apply));
}
- else if (event == "cancel")
+ else if (event == "Cancel")
{
setVisible(false);
for_each(mTabs.begin(), mTabs.end(), std::mem_fun(&SetupTab::cancel));
}
- else if (event == "winsToDefault")
+ else if (event == "Reset Windows")
{
statusWindow->resetToDefaultSize();
minimap->resetToDefaultSize();
diff --git a/src/gui/setup_audio.cpp b/src/gui/setup_audio.cpp
index a640887b..6f884e2f 100644
--- a/src/gui/setup_audio.cpp
+++ b/src/gui/setup_audio.cpp
@@ -34,12 +34,12 @@
#include "../sound.h"
Setup_Audio::Setup_Audio():
- mSoundCheckBox(new CheckBox("Sound", false)),
- mSfxSlider(new Slider(0, 128)),
- mMusicSlider(new Slider(0, 128)),
mMusicVolume((int)config.getValue("musicVolume", 60)),
mSfxVolume((int)config.getValue("sfxVolume", 100)),
- mSoundEnabled(config.getValue("sound", 0))
+ mSoundEnabled(config.getValue("sound", 0)),
+ mSoundCheckBox(new CheckBox("Sound", mSoundEnabled)),
+ mSfxSlider(new Slider(0, 128)),
+ mMusicSlider(new Slider(0, 128))
{
setOpaque(false);
@@ -58,7 +58,6 @@ Setup_Audio::Setup_Audio():
sfxLabel->setPosition(20 + mSfxSlider->getWidth(), 27);
musicLabel->setPosition(20 + mMusicSlider->getWidth(), 47);
- mSoundCheckBox->setMarked(mSoundEnabled);
mSfxSlider->setValue(mSfxVolume);
mMusicSlider->setValue(mMusicVolume);
diff --git a/src/gui/setup_audio.h b/src/gui/setup_audio.h
index e89ab093..706d6a50 100644
--- a/src/gui/setup_audio.h
+++ b/src/gui/setup_audio.h
@@ -41,11 +41,11 @@ class Setup_Audio : public SetupTab, public gcn::ActionListener
void action(const std::string&);
private:
- gcn::CheckBox *mSoundCheckBox;
- gcn::Slider *mSfxSlider, *mMusicSlider;
-
int mMusicVolume, mSfxVolume;
bool mSoundEnabled;
+
+ gcn::CheckBox *mSoundCheckBox;
+ gcn::Slider *mSfxSlider, *mMusicSlider;
};
#endif
diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp
index 2c314342..a009d2d5 100644
--- a/src/gui/setup_video.cpp
+++ b/src/gui/setup_video.cpp
@@ -99,16 +99,16 @@ ModeListModel::ModeListModel()
}
Setup_Video::Setup_Video():
- mModeListModel(new ModeListModel()),
- mModeList(new ListBox(mModeListModel)),
- mFsCheckBox(new CheckBox("Full screen", false)),
- mOpenGLCheckBox(new CheckBox("OpenGL", false)),
- mCustomCursorCheckBox(new CheckBox("Custom cursor")),
- mAlphaSlider(new Slider(0.2, 1.0)),
mFullScreenEnabled(config.getValue("screen", 0)),
mOpenGLEnabled(config.getValue("opengl", 0)),
mCustomCursorEnabled(config.getValue("customcursor", 1)),
- mOpacity(config.getValue("guialpha", 0.8))
+ mOpacity(config.getValue("guialpha", 0.8)),
+ mModeListModel(new ModeListModel()),
+ mModeList(new ListBox(mModeListModel)),
+ mFsCheckBox(new CheckBox("Full screen", mFullScreenEnabled)),
+ mOpenGLCheckBox(new CheckBox("OpenGL", mOpenGLEnabled)),
+ mCustomCursorCheckBox(new CheckBox("Custom cursor", mCustomCursorEnabled)),
+ mAlphaSlider(new Slider(0.2, 1.0))
{
setOpaque(false);
@@ -129,9 +129,6 @@ Setup_Video::Setup_Video():
alphaLabel->setPosition(20 + mAlphaSlider->getWidth(), mAlphaSlider->getY());
mModeList->setSelected(-1);
- mFsCheckBox->setMarked(mFullScreenEnabled);
- mOpenGLCheckBox->setMarked(mOpenGLEnabled);
- mCustomCursorCheckBox->setMarked(mCustomCursorEnabled);
mAlphaSlider->setValue(mOpacity);
mCustomCursorCheckBox->setEventId("customcursor");
diff --git a/src/gui/setup_video.h b/src/gui/setup_video.h
index 4aa13fd3..d7129950 100644
--- a/src/gui/setup_video.h
+++ b/src/gui/setup_video.h
@@ -42,6 +42,11 @@ class Setup_Video : public SetupTab, public gcn::ActionListener
void action(const std::string&);
private:
+ bool mFullScreenEnabled;
+ bool mOpenGLEnabled;
+ bool mCustomCursorEnabled;
+ double mOpacity;
+
class ModeListModel *mModeListModel;
gcn::ListBox *mModeList;
@@ -49,11 +54,6 @@ class Setup_Video : public SetupTab, public gcn::ActionListener
gcn::CheckBox *mOpenGLCheckBox;
gcn::CheckBox *mCustomCursorCheckBox;
gcn::Slider *mAlphaSlider;
-
- bool mFullScreenEnabled;
- bool mOpenGLEnabled;
- bool mCustomCursorEnabled;
- double mOpacity;
};
#endif