summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--The Mana World.dev10
-rw-r--r--data/graphics/gui/slider.pngbin479 -> 502 bytes
-rw-r--r--docs/INSTALL/win32.txt9
-rw-r--r--src/game.cpp3
-rw-r--r--src/gui/setup.cpp191
-rw-r--r--src/gui/setup.h31
-rw-r--r--src/main.cpp5
-rw-r--r--src/sound.cpp45
-rw-r--r--src/sound.h26
9 files changed, 123 insertions, 197 deletions
diff --git a/The Mana World.dev b/The Mana World.dev
index cb2833c9..0300aefa 100644
--- a/The Mana World.dev
+++ b/The Mana World.dev
@@ -12,9 +12,9 @@ ResourceIncludes=
MakeIncludes=
Compiler=-Dmain=SDL_main_@@_
CppCompiler=-funroll-loops_@@_-ffast-math_@@_-fomit-frame-pointer_@@_-pipe_@@__@@__@@_
-Linker=-lguichan_@@_-lguichan_sdl_@@_-lguichan_opengl_@@_-lwsock32_@@_-lSDL_image_@@_-lSDL_mixer_@@_-lmingw32_@@_-lSDLmain_@@_-lSDL_@@_-llibxml2_@@_-lopengl32_@@_-lphysfs_static_@@_
+Linker=-lguichan_@@_-lguichan_sdl_@@_-lguichan_opengl_@@_-lwsock32_@@_-lSDL_image_@@_-lSDL_mixer_@@_-lmingw32_@@_-lSDLmain_@@_-lSDL_@@_-llibxml2_@@_-lopengl32_@@_-lphysfs_@@_
IsCpp=1
-Icon=data\icons\tmw-icon.ico
+Icon=The Mana World.ico
ExeOutput=
ObjectOutput=obj
OverrideOutput=1
@@ -27,13 +27,13 @@ CustomMakefile=
IncludeVersionInfo=1
SupportXPThemes=0
CompilerSet=0
-CompilerSettings=0010001001001001001001
+CompilerSettings=0010001001001001001101
[VersionInfo]
Major=0
Minor=0
-Release=11
-Build=1
+Release=12
+Build=0
LanguageID=1033
CharsetID=1252
CompanyName=The Mana World Development Team
diff --git a/data/graphics/gui/slider.png b/data/graphics/gui/slider.png
index 405bd491..60ec2392 100644
--- a/data/graphics/gui/slider.png
+++ b/data/graphics/gui/slider.png
Binary files differ
diff --git a/docs/INSTALL/win32.txt b/docs/INSTALL/win32.txt
index 706e5b82..48be71ed 100644
--- a/docs/INSTALL/win32.txt
+++ b/docs/INSTALL/win32.txt
@@ -36,7 +36,7 @@ Besides a C++ compiler, TMW depends on the following libraries:
2. Installing Dev-C++
=====================
-I recommend that you get the latest beta version, which is 4.9.9.1 at the time
+I recommend that you get the latest beta version, which is 4.9.9.2 at the time
of writing. Though this tutorial is written for and tested with that, it may
also apply to the latest stable version. Get Dev-C++ here:
@@ -71,7 +71,7 @@ Get the following DevPaks and archives:
- SDL_image (http://devpaks.org/show.php?devpak=25)
- Guichan (http://guichan.darkbits.org/downloads/guichan-0.2.0.DevPak)
- libxml2 ** (ftp://ftp.zlatkovic.com/pub/libxml/)
-- PhysFS *** (http://icculus.org/physfs/)
+- PhysFS *** (http://icculus.org/physfs/downloads/unsupported/)
Install them all through the Dev-C++ package manager. For SDL_image you may
still need to manually get the SDL_image.lib file from the SDL_image homepage
@@ -86,9 +86,8 @@ still need to manually get the SDL_image.lib file from the SDL_image homepage
From each file, copy the headers to your include directory, the libs to
the lib direcotry and the dlls (in bin direcotry) to your tmw directory.
-***) PhysFS binaries still to located. At least Elven Programmer has been able
- to add them to the tmw-cvs.DevPak above, but it seems he has forgotten
- how he did that.
+***) For PhysFS copy the headers to your include directory, the libs to
+ the lib direcotry and the dlls (in bin direcotry) to your tmw directory.
You should now be fully equipped for compiling the latest TMW CVS code!
diff --git a/src/game.cpp b/src/game.cpp
index 3ddd72a9..1aa0f9bc 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -224,8 +224,7 @@ void do_input()
}
else if ((keysym.sym == SDLK_F7))
{
- SOUND_ID id = sound.loadSfx("data/sfx/fist-swish.ogg");
- sound.playSfx(id);
+ sound.playSfx("sfx/fist-swish.ogg");
}
// Emotions, Skill dialog
diff --git a/src/gui/setup.cpp b/src/gui/setup.cpp
index 6d4dade4..87d4ef42 100644
--- a/src/gui/setup.cpp
+++ b/src/gui/setup.cpp
@@ -21,11 +21,6 @@
* $Id$
*/
-/*
- * This module takes care of everything relating to the
- * setup dialog.
- */
-
#include "setup.h"
#include "button.h"
#include "checkbox.h"
@@ -35,159 +30,172 @@
#include "slider.h"
#include "ok_dialog.h"
#include "../main.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <memory.h>
+#include <sstream>
-/*
-SDL_Rect **modes;
+#define SETUP_WIDTH 240
ModeListModel::ModeListModel()
{
- int i;
-
- modes = SDL_ListModes(NULL, SDL_FULLSCREEN | SDL_HWSURFACE);
-
- // Check if any modes available
- if (modes == (SDL_Rect**)0) {
- nmode = 0;
- logger.log("No modes");
+ SDL_Rect **modes;
+
+ /* Get available fullscreen/hardware modes */
+ modes = SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
+
+ /* Check is there are any modes available */
+ if(modes == (SDL_Rect **)0) {
+ logger.log("No modes available");
}
-
- // Check if modes restricted
- if (modes == (SDL_Rect**)-1) {
- logger.log("Modes unrestricted");
+
+ /* Check if our resolution is restricted */
+ if(modes == (SDL_Rect **)-1) {
+ logger.log("All resolutions available");
}
-
- for (nmode = 0; modes[nmode]; ++nmode);
-
- mode = (char**)calloc(nmode, sizeof(char*));
-
- for (i = 0; modes[i]; ++i) {
- char *temp = (char*)malloc(20 * sizeof(char));
- mode[i] = temp;
- if (sprintf(mode[i], "%d x %d", modes[i]->w, modes[i]->h) == -1) {
- logger.log("Cannot allocate mode list");
+ else{
+ /* Print valid modes */
+ logger.log("Available Modes");
+ for (int i = 0; modes[i]; ++i) {
+ logger.log(" %dx%d", modes[i]->w, modes[i]->h);
+ std::stringstream mode;
+ mode << (int)modes[i]->w << "x" << (int)modes[i]->h;
+ videoModes.push_back(mode.str());
}
}
}
ModeListModel::~ModeListModel()
{
- int i;
-
- // Cleanup
- for (i = 0; i < nmode; i++) {
- free(mode[i]);
- }
-
- free(mode);
+ //delete videoModes;
}
int ModeListModel::getNumberOfElements()
{
- return nmode;
+ return videoModes.size();
}
std::string ModeListModel::getElementAt(int i)
{
- return mode[i];
+ return videoModes[i];
}
-*/
+
Setup::Setup():
Window("Setup")
{
- //modeListModel = new ModeListModel();
- //displayLabel = new gcn::Label("Display settings");
- //modeList = new ListBox(modeListModel);
- //scrollArea = new ScrollArea(modeList);
+ videoLabel = new gcn::Label("Video settings");
+ modeListModel = new ModeListModel();
+ modeList = new ListBox(modeListModel);
+ modeList->setEnabled(false);
+ scrollArea = new ScrollArea(modeList);
fsCheckBox = new CheckBox("Full screen", false);
- soundLabel = new gcn::Label("Sound settings");
+ openGlCheckBox = new CheckBox("OpenGL", false);
+ openGlCheckBox->setEnabled(false);
+ alphaLabel = new gcn::Label("Gui opacity:");
+ alphaSlider = new Slider(0.2, 1.0);
+ audioLabel = new gcn::Label("Audio settings");
soundCheckBox = new CheckBox("Sound", false);
- disabledRadio = new RadioButton("Disabled", "Modes", false);
+ sfxSlider = new Slider(0, 128);
+ musicSlider = new Slider(0, 128);
+ sfxLabel = new gcn::Label("Sfx volume");
+ musicLabel = new gcn::Label("Music volume");
applyButton = new Button("Apply");
cancelButton = new Button("Cancel");
- alphaLabel = new gcn::Label("GUI opacity:");
- alphaSlider = new Slider(0.2, 1.0);
-
- // Set selections
- last_sel = 0;
- sel = 1;
// Set events
applyButton->setEventId("apply");
cancelButton->setEventId("cancel");
alphaSlider->setEventId("guialpha");
+ sfxSlider->setEventId("sfx");
+ musicSlider->setEventId("music");
// Set dimensions/positions
- setContentSize(240, 216);
- /*
- scrollArea->setDimension(gcn::Rectangle(10, 40, 90, 50));
+ setContentSize(SETUP_WIDTH, 216);
+ videoLabel->setPosition(SETUP_WIDTH - videoLabel->getWidth() - 5, 10);
+ scrollArea->setDimension(gcn::Rectangle(10, 30, 90, 50));
modeList->setDimension(gcn::Rectangle(0, 0, 60, 50));
- displayLabel->setDimension(gcn::Rectangle(10, 10, 100,16));
- */
+ fsCheckBox->setPosition(110, 30);
+ openGlCheckBox->setPosition(110, 50);
+ alphaSlider->setDimension(gcn::Rectangle(10, 90, 100, 10));
+ alphaLabel->setPosition(20 + alphaSlider->getWidth(), 87);
+ audioLabel->setPosition(SETUP_WIDTH - videoLabel->getWidth() - 5, 110);
+ soundCheckBox->setPosition(10, 130);
+ sfxSlider->setDimension(gcn::Rectangle(10, 150, 100, 10));
+ musicSlider->setDimension(gcn::Rectangle(10, 170, 100, 10));
+ sfxLabel->setPosition(20 + sfxSlider->getWidth(), 147);
+ musicLabel->setPosition(20 + musicSlider->getWidth(), 167);
cancelButton->setPosition(
- 240 - 5 - cancelButton->getWidth(),
+ SETUP_WIDTH - 5 - cancelButton->getWidth(),
216 - 5 - cancelButton->getHeight());
applyButton->setPosition(
cancelButton->getX() - 5 - applyButton->getWidth(),
216 - 5 - applyButton->getHeight());
- soundLabel->setPosition(10, 110);
- 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);
-
+ sfxSlider->addActionListener(this);
+ musicSlider->addActionListener(this);
+
// Assemble dialog
- //add(scrollArea);
- //add(displayLabel);
+ add(videoLabel);
+ add(scrollArea);
add(fsCheckBox);
- add(soundLabel);
+ add(openGlCheckBox);
+ add(audioLabel);
add(soundCheckBox);
- //add(disabledRadio);
add(applyButton);
add(cancelButton);
- add(alphaLabel);
add(alphaSlider);
+ add(alphaLabel);
+ add(sfxSlider);
+ add(musicSlider);
+ add(sfxLabel);
+ add(musicLabel);
setLocationRelativeTo(getParent());
- // load default settings
- //modeList->setSelected(1);
+ // Load default settings
+ modeList->setSelected(-1);
if (config.getValue("screen", 0) == 1) {
fsCheckBox->setMarked(true);
}
soundCheckBox->setMarked(config.getValue("sound", 0));
alphaSlider->setValue(config.getValue("guialpha", 0.8));
+ sfxSlider->setValue(config.getValue("sfxVolume", 100));
+ musicSlider->setValue(config.getValue("musicVolume", 60));
}
Setup::~Setup()
{
- //delete modeListModel;
- //delete modeList;
- //delete scrollArea;
+ delete modeListModel;
+ delete modeList;
+ delete scrollArea;
delete fsCheckBox;
delete soundCheckBox;
- delete soundLabel;
- //delete displayLabel;
+ delete audioLabel;
delete applyButton;
delete cancelButton;
- delete alphaLabel;
delete alphaSlider;
+ delete alphaLabel;
+ delete sfxSlider;
+ delete musicSlider;
+ delete sfxLabel;
+ delete musicLabel;
}
void Setup::action(const std::string &eventId)
{
- if (eventId == "guialpha")
+ if (eventId == "sfx")
+ {
+ config.setValue("sfxVolume", (int)sfxSlider->getValue());
+ sound.setSfxVolume(sfxSlider->getValue());
+ }
+ else if (eventId == "music")
+ {
+ config.setValue("musicVolume", (int)musicSlider->getValue());
+ sound.setMusicVolume(musicSlider->getValue());
+ }
+ else if (eventId == "guialpha")
{
config.setValue("guialpha", alphaSlider->getValue());
}
@@ -195,9 +203,6 @@ void Setup::action(const std::string &eventId)
{
setVisible(false);
- /*screenW = modes[sel]->w;
- screenH = modes[sel]->h;*/
-
if (fsCheckBox->isMarked()) { // Fullscreen
config.setValue("screen", 1);
displayFlags |= SDL_FULLSCREEN;
@@ -216,16 +221,6 @@ void Setup::action(const std::string &eventId)
exit(1);
}
-/* if (displayFlags & SDL_FULLSCREEN) {
-#ifdef WIN32
- displayFlags ^= SDL_FULLSCREEN;
- screen = SDL_SetVideoMode(screenW, screenH, bitDepth, displayFlags);
-#else
- SDL_WM_ToggleFullScreen(screen);
-#endif
- }*/
-
-
// Sound settings
if (soundCheckBox->isMarked()) {
config.setValue("sound", 1);
diff --git a/src/gui/setup.h b/src/gui/setup.h
index 0fe3df1b..21f65038 100644
--- a/src/gui/setup.h
+++ b/src/gui/setup.h
@@ -21,8 +21,8 @@
* $Id$
*/
-#ifndef tmw_included_setup_h
-#define tmw_included_setup_h
+#ifndef _TMW_SETUP_H
+#define _TMW_SETUP_H
#include "window.h"
#include "../sound.h"
@@ -55,8 +55,7 @@ class ModeListModel : public gcn::ListModel {
std::string getElementAt(int i);
private:
- int nmode;
- char **mode;
+ std::vector<std::string> videoModes;
};
/**
@@ -66,22 +65,20 @@ class ModeListModel : public gcn::ListModel {
*/
class Setup : public Window, public gcn::ActionListener {
private:
- // Dialog parts
- //ModeListModel *modeListModel;
- //gcn::Label *displayLabel;
+ // Dialog widgets
+ gcn::Label *videoLabel, *audioLabel;
+ gcn::ListBox *modeList;
+ ModeListModel *modeListModel;
+ gcn::ScrollArea *scrollArea;
gcn::CheckBox *fsCheckBox;
- gcn::Label *soundLabel;
+ gcn::CheckBox *openGlCheckBox;
+ gcn::Slider *alphaSlider;
+ gcn::Label *alphaLabel;
gcn::CheckBox *soundCheckBox;
- gcn::RadioButton *disabledRadio;
- //gcn::ScrollArea *scrollArea;
- //gcn::ListBox *modeList;
+ gcn::Slider *sfxSlider, *musicSlider;
+ gcn::Label *sfxLabel, *musicLabel;
gcn::Button *applyButton;
gcn::Button *cancelButton;
- gcn::Label *alphaLabel;
- gcn::Slider *alphaSlider;
-
- // Video selections
- int last_sel, sel;
public:
@@ -93,7 +90,7 @@ class Setup : public Window, public gcn::ActionListener {
/**
* Destructor.
*/
- ~Setup();
+ ~Setup();
/**
* Event handling method.
diff --git a/src/main.cpp b/src/main.cpp
index 9becaaf7..da90e701 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -182,6 +182,8 @@ void init_engine()
config.setValue("chatlog", "chatlog.txt");
#endif
config.setValue("remember", 1);
+ config.setValue("sfxVolume", 100);
+ config.setValue("musicVolume", 60);
config.write(dir);
}
@@ -294,7 +296,8 @@ void init_engine()
if (config.getValue("sound", 0) == 1) {
sound.init();
}
- //sound.setVolume(64);
+ sound.setSfxVolume(config.getValue("sfxVolume", 100));
+ sound.setMusicVolume(config.getValue("musicVolume", 60));
}
catch (const char *err) {
state = ERROR;
diff --git a/src/sound.cpp b/src/sound.cpp
index f76b6910..9b16a063 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -27,7 +27,8 @@
Sound::Sound():
installed(false),
- items(-1)
+ sfxVolume(100),
+ musicVolume(60)
{
}
@@ -187,35 +188,6 @@ void Sound::fadeOutMusic(int ms)
}
}
-SOUND_ID Sound::loadSfx(const char *path)
-{
- /* If sound system is not installed it can't load
- * samples because doesn't know how to convert them */
- if (!installed) return 0;
-
- logger.log("Sound::loadSfx() pre-caching \"%s\"", path);
-
- ResourceManager *resman = ResourceManager::getInstance();
- SoundEffect *sample = resman->getSoundEffect(path);
- if (sample) {
- soundPool[++items] = sample;
- logger.log("Sound::loadSfx() SOUND_ID = %d", items);
- return items;
- }
-
- return 0;
-}
-
-void Sound::playSfx(SOUND_ID id)
-{
- if (!installed) return;
-
- if (soundPool[id]) {
- logger.log("Sound::playSfx() Playing SOUND_ID = %d", id);
- soundPool[id]->play(0, sfxVolume);
- }
-}
-
void Sound::playSfx(const char *path)
{
if (!installed) return;
@@ -228,22 +200,9 @@ void Sound::playSfx(const char *path)
}
}
-void Sound::clearCache()
-{
- for (SOUND_ID i = 0; i <= items; i++) {
- soundPool[i]->unload();
- delete soundPool[i];
- soundPool[i] = NULL;
- }
-
- soundPool.clear();
- logger.log("Sound::clearCache() Wiped all items off the cache");
-}
-
void Sound::close()
{
installed = false;
- clearCache();
Mix_CloseAudio();
logger.log("Sound::close() Shutting down sound...");
}
diff --git a/src/sound.h b/src/sound.h
index 96cb8baf..27748fb6 100644
--- a/src/sound.h
+++ b/src/sound.h
@@ -27,12 +27,9 @@
#include <guichan.hpp>
#include <SDL.h>
#include <SDL_mixer.h>
-#include <map>
#include "resources/resourcemanager.h"
-typedef short SOUND_ID;
-
/** Sound engine
*
* \ingroup CORE
@@ -108,41 +105,18 @@ class Sound {
void setSfxVolume(int volume);
/**
- * Preloads a sound-item into buffer.
- *
- * \param path Full path to file
- */
- SOUND_ID loadSfx(const char *path);
-
- /**
- * Plays an item in soundpool.
- *
- * \param id Id returned to the item in the soundpool
- */
- void playSfx(SOUND_ID id);
-
- /**
* Plays an item.
*
* \param path Full path to file
*/
void playSfx(const char *path);
- /**
- * Wipe all items off the cache
- */
- void clearCache();
-
private:
bool installed;
int musicVolume, sfxVolume;
Mix_Music *music;
-
- /** list of preloaded sound data / items */
- std::map<int, SoundEffect*> soundPool;
- SOUND_ID items;
};
#endif