summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-09-12 23:00:11 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-09-12 23:00:11 +0000
commit07b3632e605488221f34bff48f298b394af7083a (patch)
tree185dba6ce8342687cc7215d24e9848e0acb771d6 /src
parent8a598e713f504c88402ff204907044c0d62c5f29 (diff)
downloadmana-07b3632e605488221f34bff48f298b394af7083a.tar.gz
mana-07b3632e605488221f34bff48f298b394af7083a.tar.bz2
mana-07b3632e605488221f34bff48f298b394af7083a.tar.xz
mana-07b3632e605488221f34bff48f298b394af7083a.zip
Enabled OpenGL checkbox and added messagebox informing the user that apply this
change requires restarting the client. Also made progress of update downloads start displaying at 0%.
Diffstat (limited to 'src')
-rw-r--r--src/gui/setup.cpp58
-rw-r--r--src/gui/setup.h11
-rw-r--r--src/gui/updatewindow.cpp28
3 files changed, 58 insertions, 39 deletions
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 4d00255b..4026679e 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -97,8 +97,7 @@ Setup::Setup():
modeList->setEnabled(false);
scrollArea = new ScrollArea(modeList);
fsCheckBox = new CheckBox("Full screen", false);
- openGlCheckBox = new CheckBox("OpenGL", false);
- openGlCheckBox->setEnabled(false);
+ openGLCheckBox = new CheckBox("OpenGL", false);
customCursorCheckBox = new CheckBox("Custom cursor");
alphaLabel = new gcn::Label("Gui opacity");
alphaSlider = new Slider(0.2, 1.0);
@@ -126,7 +125,7 @@ Setup::Setup():
scrollArea->setDimension(gcn::Rectangle(10, 30, 90, 50));
modeList->setDimension(gcn::Rectangle(0, 0, 60, 50));
fsCheckBox->setPosition(110, 30);
- openGlCheckBox->setPosition(110, 50);
+ openGLCheckBox->setPosition(110, 50);
customCursorCheckBox->setPosition(110, 70);
alphaSlider->setDimension(gcn::Rectangle(10, 100, 100, 10));
alphaLabel->setPosition(20 + alphaSlider->getWidth(), 97);
@@ -156,7 +155,7 @@ Setup::Setup():
add(videoLabel);
add(scrollArea);
add(fsCheckBox);
- add(openGlCheckBox);
+ add(openGLCheckBox);
add(customCursorCheckBox);
add(audioLabel);
add(soundCheckBox);
@@ -173,31 +172,30 @@ Setup::Setup():
// Load default settings
modeList->setSelected(-1);
-
+
// Full Screen
fullScreenEnabled = config.getValue("screen", 0);
fsCheckBox->setMarked(fullScreenEnabled);
-
+
// Sound
soundEnabled = config.getValue("sound", 0);
soundCheckBox->setMarked(soundEnabled);
-
+
sfxVolume = (int)config.getValue("sfxVolume", 100);
sfxSlider->setValue(sfxVolume);
-
+
musicVolume = (int)config.getValue("musicVolume", 60);
musicSlider->setValue(musicVolume);
// Graphics
customCursorEnabled = config.getValue("customcursor", 1);
customCursorCheckBox->setMarked(customCursorEnabled);
-
+
opacity = config.getValue("guialpha", 0.8);
alphaSlider->setValue(opacity);
- openGlEnabled = config.getValue("openGL", 0);
- openGlCheckBox->setMarked(openGlEnabled);
-
+ openGLEnabled = config.getValue("opengl", 0);
+ openGLCheckBox->setMarked(openGLEnabled);
}
Setup::~Setup()
@@ -206,7 +204,7 @@ Setup::~Setup()
delete modeList;
delete scrollArea;
delete fsCheckBox;
- delete openGlCheckBox;
+ delete openGLCheckBox;
delete soundCheckBox;
delete audioLabel;
delete applyButton;
@@ -270,25 +268,32 @@ void Setup::action(const std::string &eventId)
try {
sound.init();
}
- catch (const char *err)
+ catch (const char *err)
{
new OkDialog(this, "Sound Engine", err);
logger->log("Warning: %s", err);
}
- }
+ }
else
{
config.setValue("sound", 0);
sound.close();
}
- //TODO: OpenGL changes at apply time
+ // OpenGL change
+ if (openGLCheckBox->isMarked() != openGLEnabled)
+ {
+ config.setValue("opengl", openGLCheckBox->isMarked() ? 1 : 0);
+ // OpenGL can currently only be changed by restarting, notify user.
+ new OkDialog(this, "Changing OpenGL",
+ "Applying change to OpenGL requires restart.");
+ }
// We sync old and new values at apply time
// Screen
fullScreenEnabled = config.getValue("screen", 0);
-
+
// Sound
soundEnabled = config.getValue("sound", 0);
sfxVolume = (int)config.getValue("sfxVolume", 100);
@@ -297,9 +302,8 @@ void Setup::action(const std::string &eventId)
// Graphics
customCursorEnabled = config.getValue("customcursor", 1);
opacity = config.getValue("guialpha", 0.8);
- openGlEnabled = config.getValue("openGL", 0);
-
- }
+ openGLEnabled = config.getValue("opengl", 0);
+ }
else if (eventId == "cancel")
{
setVisible(false);
@@ -308,15 +312,15 @@ void Setup::action(const std::string &eventId)
// Screen
config.setValue("screen", fullScreenEnabled ? 1 : 0);
fsCheckBox->setMarked(fullScreenEnabled);
-
+
// Sound
config.getValue("sound", soundEnabled ? 1 : 0);
soundCheckBox->setMarked(soundEnabled);
-
+
config.getValue("sfxVolume", sfxVolume ? 1 : 0);
sound.setSfxVolume(sfxVolume);
sfxSlider->setValue(sfxVolume);
-
+
config.setValue("musicVolume", musicVolume);
sound.setMusicVolume(musicVolume);
musicSlider->setValue(musicVolume);
@@ -324,11 +328,11 @@ void Setup::action(const std::string &eventId)
// Graphics
config.setValue("customcursor", customCursorEnabled ? 1 : 0);
customCursorCheckBox->setMarked(customCursorEnabled);
-
+
config.setValue("guialpha", opacity);
alphaSlider->setValue(opacity);
-
- config.setValue("openGL", openGlEnabled ? 1 : 0);
- openGlCheckBox->setMarked(openGlEnabled);
+
+ config.setValue("opengl", openGLEnabled ? 1 : 0);
+ openGLCheckBox->setMarked(openGLEnabled);
}
}
diff --git a/src/gui/setup.h b/src/gui/setup.h
index 3fa41dd4..7e75c2b0 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -82,7 +82,7 @@ class Setup : public Window, public gcn::ActionListener
gcn::Label *alphaLabel;
gcn::Label *sfxLabel, *musicLabel;
gcn::CheckBox *fsCheckBox;
- gcn::CheckBox *openGlCheckBox;
+ gcn::CheckBox *openGLCheckBox;
gcn::CheckBox *soundCheckBox;
gcn::CheckBox *customCursorCheckBox;
gcn::Slider *alphaSlider;
@@ -93,9 +93,12 @@ class Setup : public Window, public gcn::ActionListener
// Variables that keeps old settings until the user "apply" them...
int musicVolume, sfxVolume;
double opacity;
- bool fullScreenEnabled, openGlEnabled, customCursorEnabled, soundEnabled;
+ bool fullScreenEnabled;
+ bool openGLEnabled;
+ bool customCursorEnabled;
+ bool soundEnabled;
- public:
+ public:
/**
* Constructor.
*/
@@ -105,7 +108,7 @@ class Setup : public Window, public gcn::ActionListener
* Destructor.
*/
~Setup();
-
+
/**
* Event handling method.
*/
diff --git a/src/gui/updatewindow.cpp b/src/gui/updatewindow.cpp
index 0ec591b1..4f53495c 100644
--- a/src/gui/updatewindow.cpp
+++ b/src/gui/updatewindow.cpp
@@ -178,17 +178,20 @@ void UpdaterWindow::addRow(const std::string &row)
mScrollArea->setVerticalScrollAmount(mScrollArea->getVerticalMaxScroll());
}
-int UpdaterWindow::updateProgress(void *ptr, double dt, double dn, double ut, double un)
+int UpdaterWindow::updateProgress(void *ptr,
+ double dt, double dn, double ut, double un)
{
- float progress = dn/dt;
+ float progress = dn / dt;
UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr);
if (progress < 0)
{
progress = 0.0f;
}
+
std::stringstream progressString;
- progressString << uw->mCurrentFile << " (" << ((int)(progress*100)) << "%)";
+ progressString << uw->mCurrentFile
+ << " (" << ((int)(progress * 100)) << "%)";
uw->setLabel(progressString.str().c_str());
uw->setProgress(progress);
@@ -200,17 +203,25 @@ int UpdaterWindow::updateProgress(void *ptr, double dt, double dn, double ut, do
return 0;
}
-size_t UpdaterWindow::memoryWrite(void *ptr, size_t size, size_t nmemb, FILE *stream)
+size_t UpdaterWindow::memoryWrite(void *ptr,
+ size_t size, size_t nmemb, FILE *stream)
{
UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(stream);
- uw->mMemoryBuffer = (char *)realloc(uw->mMemoryBuffer, uw->mDownloadedBytes + nmemb * size + 1);
+ size_t totalMem = size * nmemb;
+ uw->mMemoryBuffer = (char*)realloc(uw->mMemoryBuffer,
+ uw->mDownloadedBytes + totalMem + 1);
if (uw->mMemoryBuffer)
{
- memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, nmemb * size);
- uw->mDownloadedBytes += nmemb;
+ memcpy(&(uw->mMemoryBuffer[uw->mDownloadedBytes]), ptr, totalMem);
+ uw->mDownloadedBytes += totalMem;
+
+ // Make sure the memory buffer is NULL terminated, because this
+ // function is used to download text files that are later parsed as a
+ // string.
uw->mMemoryBuffer[uw->mDownloadedBytes] = 0;
}
- return nmemb;
+
+ return totalMem;
}
int UpdaterWindow::downloadThread(void *ptr)
@@ -221,6 +232,7 @@ int UpdaterWindow::downloadThread(void *ptr)
UpdaterWindow *uw = reinterpret_cast<UpdaterWindow *>(ptr);
std::string outFilename;
std::string url(uw->mUpdateHost + "/" + uw->mCurrentFile);
+ uw->setLabel(uw->mCurrentFile + " (0%)");
curl = curl_easy_init();