summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS12
-rw-r--r--ChangeLog6
-rw-r--r--src/configuration.cpp52
-rw-r--r--src/configuration.h41
-rw-r--r--src/gui/setup.cpp20
-rw-r--r--src/gui/setup.h1
-rw-r--r--src/gui/window.cpp16
-rw-r--r--src/gui/window.h8
8 files changed, 125 insertions, 31 deletions
diff --git a/AUTHORS b/AUTHORS
index ba52fca6..97bf5117 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -8,7 +8,7 @@ The Mana World Dev Team
== Programmers ==
Bertram (SDL input, progress bar drawing, Debian package)
- Bjorn lindeijer (various parts, GUI, graphics, A* and map rewrites)
+ Bjørn lindeijer (various parts, GUI, graphics, A* and map rewrites)
nym (several GUI parts)
Shura (configuration, sound, misc. ports)
zenogais (resource manager)
@@ -16,11 +16,12 @@ The Mana World Dev Team
== Artists ==
- Chetic (maps)
+ Clef (tiles, concepts)
Gnulia (conceptual art)
Neko-mon (player sprites, various things)
Neorice (monster sprites, tiles)
Rotonen (backstory, art director, music, sound)
+ Talaroc (sprites)
== Misc thanks ==
@@ -28,6 +29,7 @@ The Mana World Dev Team
== Inactive/retired ==
- SimEdw (network code) <- Computer broke
- Sull (hosting CVS and related services) <- Went missing
- Vlady (several items) <- In the army
+ Chetic (maps)
+ SimEdw (network code)
+ Sull (hosting CVS and related services)
+ Vlady (several items)
diff --git a/ChangeLog b/ChangeLog
index ded372d8..2bf175de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,5 @@
-0.0.11 (.... 2005)
-- Fixed get item button and chatWindow: Enter (de)focuses chat window
+0.0.11 (... April 2005)
+- Changed chat entry behaviour to focus on enter and defocus on send message
- Added walking with mouse by clicking where you want to go
- Added diagonal walking with keyboard
- Added a choice dialog of how many items to drop
@@ -8,7 +8,7 @@
- Upgraded to Guichan 0.3.0
- Chat now appears in a window
- Beings now walk a lot smoother
-- More complete support for new map format (collision, compression)
+- Completed support for new map format (collision, compression)
- Fixed problem where players would often turn up with black hair
- Fixed not showing other players dead when they die
- Fixed multiple crashes in being path handling
diff --git a/src/configuration.cpp b/src/configuration.cpp
index 2167aae2..dbf44baf 100644
--- a/src/configuration.cpp
+++ b/src/configuration.cpp
@@ -41,7 +41,7 @@
#define xmlFree(x) ;
#endif
-void Configuration::init(std::string filename)
+void Configuration::init(const std::string &filename)
{
xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
@@ -74,7 +74,7 @@ void Configuration::init(std::string filename)
xmlFreeDoc(doc);
}
-bool Configuration::write(std::string filename)
+bool Configuration::write(const std::string &filename)
{
xmlTextWriterPtr writer = xmlNewTextWriterFilename(filename.c_str(), 0);
@@ -108,29 +108,40 @@ bool Configuration::write(std::string filename)
return false;
}
-void Configuration::setValue(std::string key, std::string value)
+void Configuration::setValue(const std::string &key, std::string value)
{
#ifdef __DEBUG
std::cout << "Configuration::setValue(" << key << ", " << value << ")\n";
#endif
options[key] = value;
+
+ // Notify listeners
+ std::map<std::string, std::list<ConfigListener*> >::iterator list =
+ listeners.find(key);
+
+ if (list != listeners.end()) {
+ std::list<ConfigListener*>::iterator listener = (*list).second.begin();
+
+ while (listener != (*list).second.end())
+ {
+ (*listener)->optionChanged(key);
+ listener++;
+ }
+ }
}
-void Configuration::setValue(std::string key, float value)
+void Configuration::setValue(const std::string &key, float value)
{
-#ifdef __DEBUG
- std::cout << "Configuration::setValue(" << key << ", " << value << ")\n";
-#endif
std::stringstream ss;
if (value == floor(value)) {
ss << (int)value;
} else {
ss << value;
}
- options[key] = ss.str();
+ setValue(key, ss.str());
}
-std::string Configuration::getValue(std::string key, std::string deflt)
+std::string Configuration::getValue(const std::string &key, std::string deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
if (iter != options.end()) {
@@ -139,7 +150,7 @@ std::string Configuration::getValue(std::string key, std::string deflt)
return deflt;
}
-float Configuration::getValue(std::string key, float deflt)
+float Configuration::getValue(const std::string &key, float deflt)
{
std::map<std::string, std::string>::iterator iter = options.find(key);
if (iter != options.end()) {
@@ -147,3 +158,24 @@ float Configuration::getValue(std::string key, float deflt)
}
return deflt;
}
+
+void Configuration::addListener(
+ const std::string &key, ConfigListener *listener)
+{
+ listeners[key].push_front(listener);
+}
+
+void Configuration::removeListener(
+ const std::string &key, ConfigListener *listener)
+{
+ std::list<ConfigListener*>::iterator i = listeners[key].begin();
+
+ while (i != listeners[key].end())
+ {
+ if ((*i) == listener) {
+ listeners[key].erase(i);
+ return;
+ }
+ i++;
+ }
+}
diff --git a/src/configuration.h b/src/configuration.h
index 6f1cfb11..8c5a0470 100644
--- a/src/configuration.h
+++ b/src/configuration.h
@@ -24,12 +24,23 @@
#ifndef __INIREAD_H
#define __INIREAD_H
-#define INI_DELIMITER "="
-#define INI_COMMENTER "#"
-
#include <map>
+#include <list>
#include <string>
+
+/**
+ * The listener interface for receiving notifications about changes to
+ * configuration options.
+ *
+ * \ingroup CORE
+ */
+class ConfigListener
+{
+ public:
+ virtual void optionChanged(const std::string &name) = 0;
+};
+
/**
* INI configuration handler for reading (and writing).
*
@@ -41,44 +52,56 @@ class Configuration {
* \brief Reads INI file and parse all options into memory.
* \param filename Full path to INI file (~/.manaworld/tmw.ini)
*/
- void init(std::string filename);
+ void init(const std::string &filename);
/**
* \brief Writes the current settings back to an ini-file.
* \param filename Full path to INI file (~/.manaworld/tmw.ini)
*/
- bool write(std::string filename);
+ bool write(const std::string &filename);
/**
* \brief Sets an option using a string value.
* \param key Option identifier.
* \param value Value.
*/
- void setValue(std::string key, std::string value);
+ void setValue(const std::string &key, std::string value);
/**
* \brief Sets an option using a numeric value.
* \param key Option identifier.
* \param value Value.
*/
- void setValue(std::string key, float value);
+ void setValue(const std::string &key, float value);
/**
* \brief Gets a value as string.
* \param key Option identifier.
* \param deflt Default option if not there or error.
*/
- std::string getValue(std::string key, std::string deflt);
+ std::string getValue(const std::string &key, std::string deflt);
/**
* \brief Gets a value as numeric (float).
* \param key Option identifier.
* \param deflt Default option if not there or error.
*/
- float getValue(std::string key, float deflt);
+ float getValue(const std::string &key, float deflt);
+
+ /**
+ * Adds a listener to the listen list of the specified config option.
+ */
+ void addListener(const std::string &key, ConfigListener *listener);
+
+ /**
+ * Removes a listener from the listen list of the specified config
+ * option.
+ */
+ void removeListener(const std::string &key, ConfigListener *listener);
private:
std::map<std::string, std::string> options;
+ std::map<std::string, std::list<ConfigListener*> > listeners;
};
#endif
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 4502dbac..85aa900d 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -107,7 +107,8 @@ Setup::Setup():
disabledRadio = new RadioButton("Disabled", "Modes", false);
applyButton = new Button("Apply");
cancelButton = new Button("Cancel");
- //alphaSlider = new Slider(1.0);
+ alphaLabel = new gcn::Label("GUI opacity:");
+ alphaSlider = new Slider(0.2, 1.0);
// Set selections
last_sel = 0;
@@ -116,6 +117,7 @@ Setup::Setup():
// Set events
applyButton->setEventId("apply");
cancelButton->setEventId("cancel");
+ alphaSlider->setEventId("guialpha");
// Set dimensions/positions
setContentSize(240, 216);
@@ -132,10 +134,14 @@ Setup::Setup():
fsCheckBox->setPosition(120, 36);
soundCheckBox->setPosition(10, 130);
disabledRadio->setPosition(10, 140);
+ alphaLabel->setPosition(10, 157);
+ alphaSlider->setDimension(gcn::Rectangle(
+ alphaLabel->getWidth() + 20, 160, 100, 10));
// Listen for actions
applyButton->addActionListener(this);
cancelButton->addActionListener(this);
+ alphaSlider->addActionListener(this);
// Assemble dialog
add(scrollArea);
@@ -146,7 +152,8 @@ Setup::Setup():
//add(disabledRadio);
add(applyButton);
add(cancelButton);
- //add(alphaSlider);
+ add(alphaLabel);
+ add(alphaSlider);
setLocationRelativeTo(getParent());
@@ -156,6 +163,7 @@ Setup::Setup():
fsCheckBox->setMarked(true);
}
soundCheckBox->setMarked(config.getValue("sound", 0));
+ alphaSlider->setValue(config.getValue("guialpha", 0.8));
}
Setup::~Setup()
@@ -169,11 +177,17 @@ Setup::~Setup()
delete displayLabel;
delete applyButton;
delete cancelButton;
+ delete alphaLabel;
+ delete alphaSlider;
}
void Setup::action(const std::string &eventId)
{
- if (eventId == "apply")
+ if (eventId == "guialpha")
+ {
+ config.setValue("guialpha", alphaSlider->getValue());
+ }
+ else if (eventId == "apply")
{
setVisible(false);
diff --git a/src/gui/setup.h b/src/gui/setup.h
index a7ed422e..7a38bfd5 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -77,6 +77,7 @@ class Setup : public Window, public gcn::ActionListener {
gcn::ListBox *modeList;
gcn::Button *applyButton;
gcn::Button *cancelButton;
+ gcn::Label *alphaLabel;
gcn::Slider *alphaSlider;
// Video selections
diff --git a/src/gui/window.cpp b/src/gui/window.cpp
index ab37dae8..c24b50ab 100644
--- a/src/gui/window.cpp
+++ b/src/gui/window.cpp
@@ -73,6 +73,7 @@ Window::Window(const std::string& caption, bool modal, Window *parent):
// Set GUI alpha level
dBackground->setAlpha(guiAlpha);
dBorders->setAlpha(guiAlpha);
+ config.addListener("guialpha", this);
}
Window::~Window()
@@ -84,6 +85,7 @@ Window::~Window()
//release_bitmap(dMid);
//release_bitmap(dRight);
+ config.removeListener("guialpha", this);
delete chrome;
}
@@ -196,3 +198,17 @@ void Window::mouseMotion(int mx, int my)
setPosition(x, y);
}
}
+
+void Window::optionChanged(const std::string &name)
+{
+ if (name == "guialpha")
+ {
+ guiAlpha = config.getValue("guialpha", 0.8);
+
+ if (dBackground->getAlpha() != guiAlpha)
+ {
+ dBackground->setAlpha(guiAlpha);
+ dBorders->setAlpha(guiAlpha);
+ }
+ }
+}
diff --git a/src/gui/window.h b/src/gui/window.h
index 126fe2f4..972c58cd 100644
--- a/src/gui/window.h
+++ b/src/gui/window.h
@@ -29,13 +29,14 @@
#include "windowcontainer.h"
#include "../resources/image.h"
#include "../graphics.h"
+#include "../configuration.h"
/**
* A window. This window can be dragged around and has a title bar.
*
* \ingroup GUI
*/
-class Window : public gcn::Window
+class Window : public gcn::Window, public ConfigListener
{
protected:
gcn::Container *chrome; /**< Contained container */
@@ -134,6 +135,11 @@ class Window : public gcn::Window
* dragged outside of the screen.
*/
void mouseMotion(int mx, int my);
+
+ /**
+ * Called when an config option changes.
+ */
+ void optionChanged(const std::string &name);
};
#endif