aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/gui.cpp94
-rw-r--r--engines/kyra/kyra.cpp7
-rw-r--r--engines/kyra/kyra.h5
-rw-r--r--engines/kyra/saveload.cpp23
-rw-r--r--engines/kyra/staticres.cpp2
5 files changed, 109 insertions, 22 deletions
diff --git a/engines/kyra/gui.cpp b/engines/kyra/gui.cpp
index 4fd520e785..e86dd7304c 100644
--- a/engines/kyra/gui.cpp
+++ b/engines/kyra/gui.cpp
@@ -26,11 +26,92 @@
#include "kyra/text.h"
#include "kyra/animator.h"
+#include "common/config-manager.h"
#include "common/savefile.h"
#include "common/system.h"
namespace Kyra {
+void KyraEngine::registerDefaultSettings() {
+ // Most settings already have sensible defaults. This one, however, is
+ // specific to the Kyra engine.
+ ConfMan.registerDefault("walkspeed", 2);
+}
+
+void KyraEngine::readSettings() {
+ int talkspeed = ConfMan.getInt("talkspeed");
+
+ // The default talk speed is 60. This should be mapped to "Normal".
+
+ if (talkspeed == 0)
+ _configTextspeed = 3; // Clickable
+ if (talkspeed <= 50)
+ _configTextspeed = 0; // Slow
+ else if (talkspeed <= 150)
+ _configTextspeed = 1; // Normal
+ else
+ _configTextspeed = 2; // Fast
+
+ _configWalkspeed = ConfMan.getInt("walkspeed");
+ _configMusic = ConfMan.getBool("music_mute") ? 0 : 1;
+ _configSounds = ConfMan.getBool("sfx_mute") ? 0 : 1;
+
+ bool speechMute = ConfMan.getBool("speech_mute");
+ bool subtitles = ConfMan.getBool("subtitles");
+
+ if (!speechMute && subtitles)
+ _configVoice = 2; // Voice & Text
+ else if (!speechMute && !subtitles)
+ _configVoice = 1; // Voice only
+ else
+ _configVoice = 0; // Text only
+}
+
+void KyraEngine::writeSettings() {
+ bool speechMute, subtitles;
+ int talkspeed;
+
+ switch (_configTextspeed) {
+ case 0: // Slow
+ talkspeed = 1;
+ break;
+ case 1: // Normal
+ talkspeed = 60;
+ break;
+ case 2: // Fast
+ talkspeed = 255;
+ break;
+ default: // Clickable
+ talkspeed = 0;
+ break;
+ }
+
+ ConfMan.setInt("talkspeed", talkspeed);
+ ConfMan.setInt("walkspeed", _configWalkspeed);
+ ConfMan.setBool("music_mute", _configMusic == 0);
+ ConfMan.setBool("sfx_mute", _configSounds == 0);
+
+ switch (_configVoice) {
+ case 0: // Text only
+ speechMute = true;
+ subtitles = true;
+ break;
+ case 1: // Voice only
+ speechMute = false;
+ subtitles = false;
+ break;
+ default: // Voice & Text
+ speechMute = false;
+ subtitles = true;
+ break;
+ }
+
+ ConfMan.setBool("speech_mute", speechMute);
+ ConfMan.setBool("subtitles", subtitles);
+
+ ConfMan.flushToDisk();
+}
+
void KyraEngine::initMainButtonList() {
_haveScrollButtons = false;
_buttonList = &_buttonData[0];
@@ -385,7 +466,6 @@ void KyraEngine::processMenuButton(Button *button) {
button->flags2 &= 0xfb;
processButton(button);
-
}
int KyraEngine::drawBoxCallback(Button *button) {
@@ -1071,6 +1151,8 @@ int KyraEngine::gui_quitConfirmNo(Button *button) {
int KyraEngine::gui_gameControlsMenu(Button *button) {
debugC(9, kDebugLevelGUI, "KyraEngine::gui_gameControlsMenu()");
+ readSettings();
+
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_screen->savePageToDisk("SEENPAGE.TMP", 0);
@@ -1169,10 +1251,10 @@ void KyraEngine::gui_setupControls(Menu &menu) {
menu.item[3].itemString = _configStrings[5]; //"Text only"
break;
case 1:
- menu.item[3].itemString = _configStrings[6]; //"Voice & Text"
+ menu.item[3].itemString = _configStrings[6]; //"Voice only"
break;
case 2:
- menu.item[3].itemString = _configStrings[7]; //"Voice only"
+ menu.item[3].itemString = _configStrings[7]; //"Voice & Text"
break;
default:
menu.item[3].itemString = "ERROR";
@@ -1248,6 +1330,12 @@ int KyraEngine::gui_controlsChangeVoice(Button *button) {
return 0;
}
+int KyraEngine::gui_controlsApply(Button *button) {
+ debugC(9, kDebugLevelGUI, "KyraEngine::gui_controlsApply()");
+ writeSettings();
+ return gui_cancelSubMenu(button);
+}
+
int KyraEngine::gui_scrollUp(Button *button) {
debugC(9, kDebugLevelGUI, "KyraEngine::gui_scrollUp()");
processMenuButton(button);
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index 209b5cb79f..7e00383793 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -274,11 +274,8 @@ int KyraEngine::init() {
assert(_movFacingTable);
_movFacingTable[0] = 8;
- _configTextspeed = 1;
- _configWalkspeed = 2;
- _configMusic = true;
- _configSounds = true;
- _configVoice = 1;
+ registerDefaultSettings();
+ readSettings();
_skipFlag = false;
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index 25e105ddc8..f262dd5dd5 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -295,6 +295,10 @@ public:
void quitGame();
void loadBitmap(const char *filename, int tempPage, int dstPage, uint8 *palData);
+ void registerDefaultSettings();
+ void readSettings();
+ void writeSettings();
+
void snd_playTheme(int file, int track = 0);
void snd_playVoiceFile(int id);
void snd_voiceWaitForFinish(bool ingame = true);
@@ -675,6 +679,7 @@ protected:
int gui_controlsChangeWalk(Button *button);
int gui_controlsChangeText(Button *button);
int gui_controlsChangeVoice(Button *button);
+ int gui_controlsApply(Button *button);
bool gui_quitConfirm(const char *str);
void gui_getInput();
diff --git a/engines/kyra/saveload.cpp b/engines/kyra/saveload.cpp
index cb34bd957d..d7deab6e77 100644
--- a/engines/kyra/saveload.cpp
+++ b/engines/kyra/saveload.cpp
@@ -30,7 +30,7 @@
#include "kyra/screen.h"
#include "kyra/resource.h"
-#define CURRENT_VERSION 4
+#define CURRENT_VERSION 5
namespace Kyra {
void KyraEngine::loadGame(const char *fileName) {
@@ -179,13 +179,16 @@ void KyraEngine::loadGame(const char *fileName) {
if (_lastMusicCommand != -1)
snd_playWanderScoreViaMap(_lastMusicCommand, 1);
}
+
+ // Version 4 stored settings in the savegame. As of version 5, they are
+ // handled by the config manager.
- if (version >= 4) {
- _configTextspeed = in->readByte();
- _configWalkspeed = in->readByte();
- _configMusic = in->readByte() != 0;
- _configSounds = in->readByte() != 0;
- _configVoice = in->readByte();
+ if (version == 4) {
+ in->readByte(); // Text speed
+ in->readByte(); // Walk speed
+ in->readByte(); // Music
+ in->readByte(); // Sound
+ in->readByte(); // Voice
}
loadMainScreen(8);
@@ -317,12 +320,6 @@ void KyraEngine::saveGame(const char *fileName, const char *saveName) {
out->writeSint16BE(_lastMusicCommand);
- out->writeByte(_configTextspeed);
- out->writeByte(_configWalkspeed);
- out->writeByte(_configMusic);
- out->writeByte(_configSounds);
- out->writeByte(_configVoice);
-
out->flush();
// check for errors
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 04695c4464..6a820a6164 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -1178,7 +1178,7 @@ Menu KyraEngine::_menu[] = {
248, 249, 250, &KyraEngine::gui_controlsChangeText, -1, 0, 34, 100, 0, 0 },
{1, 0, 0, 0, 64, 0, 127, 92, 15, 252, 253, -1, 255,
- 248, 249, 250, &KyraEngine::gui_cancelSubMenu, -1, -0, 0, 0, 0, 0}
+ 248, 249, 250, &KyraEngine::gui_controlsApply, -1, -0, 0, 0, 0, 0}
}
}
};