aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sword2/anims.cpp4
-rw-r--r--sword2/controls.cpp239
-rw-r--r--sword2/controls.h32
-rw-r--r--sword2/driver/d_sound.cpp4
-rw-r--r--sword2/driver/d_sound.h14
-rw-r--r--sword2/mem_view.cpp6
-rw-r--r--sword2/memory.cpp22
-rw-r--r--sword2/memory.h4
-rw-r--r--sword2/mouse.cpp13
-rw-r--r--sword2/mouse.h2
-rw-r--r--sword2/resman.cpp44
-rw-r--r--sword2/resman.h4
-rw-r--r--sword2/speech.cpp6
-rw-r--r--sword2/sword2.cpp14
14 files changed, 206 insertions, 202 deletions
diff --git a/sword2/anims.cpp b/sword2/anims.cpp
index 4e4f1bef47..fea8b02887 100644
--- a/sword2/anims.cpp
+++ b/sword2/anims.cpp
@@ -547,7 +547,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
sequence_text_list[line].speech_mem = NULL;
sequenceText[line]->speech = NULL;
- if (speechSelected) {
+ if (gui._speechSelected) {
// speech is selected, so try that first
// set up path to speech cluster
@@ -572,7 +572,7 @@ void CreateSequenceSpeech(_movieTextObject *sequenceText[]) {
// if we want subtitles, or speech failed to load
- if (subtitles || !speechRunning) {
+ if (gui._subtitles || !speechRunning) {
// open text resource & get the line
text = FetchTextLine(res_man.open(text_res), local_text);
// make the sprite
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index f681f019b7..8706dad6ca 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -39,20 +39,11 @@
#define MAX_STRING_LEN 64 // 20 was too low; better to be safe ;)
#define CHARACTER_OVERLAP 2 // overlap characters by 3 pixels
-uint8 subtitles;
-uint8 speechSelected;
-uint8 stereoReversed = 0;
-
-int baseSlot = 0;
-
-uint8 current_graphics_level;
-
-int32 WriteOptionSettings(void);
-void Control_error(char* text);
-
// our fonts start on SPACE character (32)
#define SIZE_OF_CHAR_SET (256 - 32)
+Sword2Gui gui;
+
enum {
kAlignLeft,
kAlignRight,
@@ -725,6 +716,8 @@ private:
Sword2Button *_okButton;
Sword2Button *_cancelButton;
+ int32 writeOptionSettings(void);
+
public:
Sword2OptionsDialog() {
_fontRenderer = new Sword2FontRenderer(controls_font_id);
@@ -782,11 +775,11 @@ public:
registerWidget(_okButton);
registerWidget(_cancelButton);
- ReadOptionSettings();
+ gui.readOptionSettings();
- _objectLabelsSwitch->setValue(pointerTextSelected != 0);
- _subtitlesSwitch->setValue(subtitles != 0);
- _reverseStereoSwitch->setValue(stereoReversed != 0);
+ _objectLabelsSwitch->setValue(gui._pointerTextSelected != 0);
+ _subtitlesSwitch->setValue(gui._subtitles != 0);
+ _reverseStereoSwitch->setValue(gui._stereoReversed != 0);
_musicSwitch->setValue(g_sound->isMusicMute() == 0);
_speechSwitch->setValue(g_sound->isSpeechMute() == 0);
_fxSwitch->setValue(g_sound->isFxMute() == 0);
@@ -850,9 +843,9 @@ public:
// is handled when the dialog is terminated.
if (widget == _reverseStereoSwitch) {
- if (result != stereoReversed)
+ if (result != gui._stereoReversed)
g_sound->reverseStereo();
- stereoReversed = result;
+ gui._stereoReversed = result;
} else if (widget == _musicSwitch) {
g_sound->muteMusic(result);
} else if (widget == _musicSlider) {
@@ -865,7 +858,7 @@ public:
_fxSwitch->setValue(result != 0);
} else if (widget == _gfxSlider) {
_gfxPreview->setState(result);
- UpdateGraphicsLevel(result);
+ gui.updateGraphicsLevel(result);
} else if (widget == _okButton) {
// Apply the changes
g_sound->muteMusic(_musicSwitch->getValue() == 0);
@@ -875,23 +868,56 @@ public:
g_sound->setSpeechVolume(_speechSlider->getValue());
g_sound->setFxVolume(_fxSlider->getValue());
- UpdateGraphicsLevel(_gfxSlider->getValue());
+ gui.updateGraphicsLevel(_gfxSlider->getValue());
- subtitles = _subtitlesSwitch->getValue();
- pointerTextSelected = _objectLabelsSwitch->getValue();
- speechSelected = _speechSwitch->getValue();
- stereoReversed = _reverseStereoSwitch->getValue();
+ gui._subtitles = _subtitlesSwitch->getValue();
+ gui._pointerTextSelected = _objectLabelsSwitch->getValue();
+ gui._speechSelected = _speechSwitch->getValue();
+ gui._stereoReversed = _reverseStereoSwitch->getValue();
- WriteOptionSettings();
+ writeOptionSettings();
setResult(1);
} else if (widget == _cancelButton) {
// Revert the changes
- ReadOptionSettings();
+ gui.readOptionSettings();
setResult(0);
}
}
};
+int32 Sword2OptionsDialog::writeOptionSettings(void) {
+ uint8 buff[10];
+ char filename[256];
+ SaveFile *fp;
+ SaveFileManager *mgr = g_system->get_savefile_manager();
+
+ sprintf(filename, "%s-settings.dat", g_sword2->_game_name);
+
+ buff[0] = g_sound->getMusicVolume();
+ buff[1] = g_sound->getSpeechVolume();
+ buff[2] = g_sound->getFxVolume();
+ buff[3] = g_sound->isMusicMute();
+ buff[4] = g_sound->isSpeechMute();
+ buff[5] = g_sound->isFxMute();
+ buff[6] = GetRenderType();
+ buff[7] = gui._subtitles;
+ buff[8] = gui._pointerTextSelected;
+ buff[9] = gui._stereoReversed;
+
+ if (!(fp = mgr->open_savefile(filename, g_sword2->getSavePath(), true)))
+ return 1;
+
+ if (fp->write(buff, 10) != 10) {
+ delete fp;
+ delete mgr;
+ return 2;
+ }
+
+ delete fp;
+ delete mgr;
+ return 0;
+}
+
enum {
kSaveDialog,
kLoadDialog
@@ -1015,6 +1041,8 @@ private:
Sword2Button *_okButton;
Sword2Button *_cancelButton;
+ void saveLoadError(char *text);
+
public:
Sword2SaveLoadDialog(int mode) : _mode(mode), _selectedSlot(-1) {
int i;
@@ -1080,13 +1108,13 @@ public:
void updateSlots() {
for (int i = 0; i < 8; i++) {
- Sword2Slot *slot = _slotButton[(baseSlot + i) % 8];
+ Sword2Slot *slot = _slotButton[(gui._baseSlot + i) % 8];
Sword2FontRenderer *fr;
uint8 description[SAVE_DESCRIPTION_LEN];
slot->setY(72 + i * 36);
- if (baseSlot + i == _selectedSlot) {
+ if (gui._baseSlot + i == _selectedSlot) {
slot->setEditable(_mode == kSaveDialog);
slot->setState(1);
fr = _fontRenderer2;
@@ -1096,11 +1124,11 @@ public:
fr = _fontRenderer1;
}
- if (GetSaveDescription(baseSlot + i, description) == SR_OK) {
- slot->setText(fr, baseSlot + i, (char *) description);
+ if (GetSaveDescription(gui._baseSlot + i, description) == SR_OK) {
+ slot->setText(fr, gui._baseSlot + i, (char *) description);
slot->setClickable(true);
} else {
- slot->setText(fr, baseSlot + i, NULL);
+ slot->setText(fr, gui._baseSlot + i, NULL);
slot->setClickable(_mode == kSaveDialog);
}
@@ -1113,29 +1141,29 @@ public:
virtual void onAction(Sword2Widget *widget, int result = 0) {
if (widget == _zupButton) {
- if (baseSlot > 0) {
- if (baseSlot >= 8)
- baseSlot -= 8;
+ if (gui._baseSlot > 0) {
+ if (gui._baseSlot >= 8)
+ gui._baseSlot -= 8;
else
- baseSlot = 0;
+ gui._baseSlot = 0;
updateSlots();
}
} else if (widget == _upButton) {
- if (baseSlot > 0) {
- baseSlot--;
+ if (gui._baseSlot > 0) {
+ gui._baseSlot--;
updateSlots();
}
} else if (widget == _downButton) {
- if (baseSlot < 92) {
- baseSlot++;
+ if (gui._baseSlot < 92) {
+ gui._baseSlot++;
updateSlots();
}
} else if (widget == _zdownButton) {
- if (baseSlot < 92) {
- if (baseSlot <= 84)
- baseSlot += 8;
+ if (gui._baseSlot < 92) {
+ if (gui._baseSlot <= 84)
+ gui._baseSlot += 8;
else
- baseSlot = 92;
+ gui._baseSlot = 92;
updateSlots();
}
} else if (widget == _okButton) {
@@ -1193,7 +1221,7 @@ public:
}
} else {
if (result == kSelectSlot)
- _selectedSlot = baseSlot + (slot->getY() - 72) / 35;
+ _selectedSlot = gui._baseSlot + (slot->getY() - 72) / 35;
else if (result == kDeselectSlot)
_selectedSlot = -1;
@@ -1221,7 +1249,7 @@ public:
// but I doubt that will make any noticeable difference.
slot->paint();
- _fontRenderer2->drawText(_editBuffer, 130, 78 + (_selectedSlot - baseSlot) * 36);
+ _fontRenderer2->drawText(_editBuffer, 130, 78 + (_selectedSlot - gui._baseSlot) * 36);
}
virtual void paint() {
@@ -1271,7 +1299,7 @@ public:
break;
}
- Control_error((char*) (FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff) + 2));
+ saveLoadError((char*) (FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff) + 2));
result = 0;
}
} else {
@@ -1292,7 +1320,7 @@ public:
break;
}
- Control_error((char *) (FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff) + 2));
+ saveLoadError((char *) (FetchTextLine(res_man.open(textId / SIZE), textId & 0xffff) + 2));
result = 0;
} else {
// Prime system with a game cycle
@@ -1314,7 +1342,36 @@ public:
}
};
-uint32 Restore_control(void) {
+void Sword2SaveLoadDialog::saveLoadError(char* text) {
+ // Print a message on screen. Second parameter is duration.
+ DisplayMsg((uint8 *) text, 0);
+
+ // Wait for ESC or mouse click
+ while (1) {
+ _mouseEvent *me;
+
+ ServiceWindows();
+
+ if (KeyWaiting()) {
+ _keyboardEvent ke;
+
+ ReadKey(&ke);
+ if (ke.keycode == 27)
+ break;
+ }
+
+ me = MouseEvent();
+ if (me && (me->buttons & RD_LEFTBUTTONDOWN))
+ break;
+
+ g_system->delay_msecs(20);
+ }
+
+ // Remove the message.
+ RemoveMsg();
+}
+
+uint32 Sword2Gui::restoreControl(void) {
// returns 0 for no restore
// 1 for restored ok
@@ -1322,12 +1379,12 @@ uint32 Restore_control(void) {
return loadDialog.run();
}
-void Save_control(void) {
+void Sword2Gui::saveControl(void) {
Sword2SaveLoadDialog saveDialog(kSaveDialog);
saveDialog.run();
}
-void Quit_control(void) {
+void Sword2Gui::quitControl(void) {
Sword2MiniDialog quitDialog(149618692); // quit text
if (!quitDialog.run()) {
@@ -1341,7 +1398,7 @@ void Quit_control(void) {
exit(0);
}
-void Restart_control(void) {
+void Sword2Gui::restartControl(void) {
uint32 temp_demo_flag;
Sword2MiniDialog restartDialog(149618693); // restart text
@@ -1407,36 +1464,7 @@ void Restart_control(void) {
this_screen.new_palette = 99;
}
-void Control_error(char* text) {
- // Print a message on screen. Second parameter is duration.
- DisplayMsg((uint8 *) text, 0);
-
- // Wait for ESC or mouse click
- while (1) {
- _mouseEvent *me;
-
- ServiceWindows();
-
- if (KeyWaiting()) {
- _keyboardEvent ke;
-
- ReadKey(&ke);
- if (ke.keycode == 27)
- break;
- }
-
- me = MouseEvent();
- if (me && (me->buttons & RD_LEFTBUTTONDOWN))
- break;
-
- g_system->delay_msecs(20);
- }
-
- // Remove the message.
- RemoveMsg();
-}
-
-int32 ReadOptionSettings(void) {
+int32 Sword2Gui::readOptionSettings(void) {
// settings file is 9 bytes long:
// 1 music volume
// 2 speech volume
@@ -1474,60 +1502,27 @@ int32 ReadOptionSettings(void) {
g_sound->muteSpeech(buff[4]);
g_sound->muteFx(buff[5]);
- UpdateGraphicsLevel(buff[6]);
+ updateGraphicsLevel(buff[6]);
- speechSelected = !buff[4];
- subtitles = buff[7];
- pointerTextSelected = buff[8];
+ _speechSelected = !buff[4];
+ _subtitles = buff[7];
+ _pointerTextSelected = buff[8];
- if (buff[9] != stereoReversed)
+ if (buff[9] != _stereoReversed)
g_sound->reverseStereo();
- stereoReversed = buff[9];
- return 0;
-}
-
-int32 WriteOptionSettings(void) {
- uint8 buff[10];
- char filename[256];
- SaveFile *fp;
- SaveFileManager *mgr = g_system->get_savefile_manager();
-
- sprintf(filename, "%s-settings.dat", g_sword2->_game_name);
-
- buff[0] = g_sound->getMusicVolume();
- buff[1] = g_sound->getSpeechVolume();
- buff[2] = g_sound->getFxVolume();
- buff[3] = g_sound->isMusicMute();
- buff[4] = g_sound->isSpeechMute();
- buff[5] = g_sound->isFxMute();
- buff[6] = GetRenderType();
- buff[7] = subtitles;
- buff[8] = pointerTextSelected;
- buff[9] = stereoReversed;
-
- if (!(fp = mgr->open_savefile(filename, g_sword2->getSavePath(), true)))
- return 1;
-
- if (fp->write(buff, 10) != 10) {
- delete fp;
- delete mgr;
- return 2;
- }
-
- delete fp;
- delete mgr;
+ gui._stereoReversed = buff[9];
return 0;
}
-void Option_control(void) {
+void Sword2Gui::optionControl(void) {
Sword2OptionsDialog optionsDialog;
optionsDialog.run();
return;
}
-void UpdateGraphicsLevel(uint8 newLevel) {
+void Sword2Gui::updateGraphicsLevel(uint8 newLevel) {
switch (newLevel) {
case 0:
// Lowest setting: no graphics fx
@@ -1561,5 +1556,5 @@ void UpdateGraphicsLevel(uint8 newLevel) {
// cannot be done with dimmed palette so we turn down one notch while
// dimmed, if at top level)
- current_graphics_level = newLevel;
+ _currentGraphicsLevel = newLevel;
}
diff --git a/sword2/controls.h b/sword2/controls.h
index b1416bd27e..3c7b8613d1 100644
--- a/sword2/controls.h
+++ b/sword2/controls.h
@@ -20,16 +20,28 @@
#ifndef _CONTROL_S
#define _CONTROL_S
-uint32 Restore_control(void);
-void Save_control(void);
-void Quit_control(void);
-void Restart_control(void);
-void Option_control(void);
-int32 ReadOptionSettings(void);
-void UpdateGraphicsLevel(uint8 newLevel);
+class Sword2Gui {
+public:
+ int _baseSlot;
+ uint8 _currentGraphicsLevel;
-extern uint8 subtitles; // text selected
-extern uint8 speechSelected;
-extern uint8 current_graphics_level;
+ uint8 _subtitles;
+ uint8 _speechSelected;
+ uint8 _stereoReversed;
+ uint8 _pointerTextSelected;
+
+ Sword2Gui() : _baseSlot(0), _stereoReversed(0),
+ _pointerTextSelected(0) {}
+
+ uint32 restoreControl(void);
+ void saveControl(void);
+ void quitControl(void);
+ void restartControl(void);
+ void optionControl(void);
+ int32 readOptionSettings(void);
+ void updateGraphicsLevel(uint8 newLevel);
+};
+
+extern Sword2Gui gui;
#endif
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp
index 6f2dca6851..057c3b2bb9 100644
--- a/sword2/driver/d_sound.cpp
+++ b/sword2/driver/d_sound.cpp
@@ -63,7 +63,7 @@ static int32 musicVolTable[17] = {
143, 159, 175, 191, 207, 223, 239, 255
};
-int16 MusicHandle::read() {
+int16 Sword2MusicHandle::read() {
uint8 in;
uint16 delta;
int16 out;
@@ -115,7 +115,7 @@ int16 MusicHandle::read() {
return out;
}
-bool MusicHandle::eos() const {
+bool Sword2MusicHandle::eos() const {
if (!_streaming || _filePos >= _fileEnd)
return true;
return false;
diff --git a/sword2/driver/d_sound.h b/sword2/driver/d_sound.h
index abc76f3d05..4890a5a026 100644
--- a/sword2/driver/d_sound.h
+++ b/sword2/driver/d_sound.h
@@ -36,9 +36,9 @@ typedef struct {
uint16 *_buf;
int32 _bufSize;
PlayingSoundHandle _handle;
-} FxHandle;
+} Sword2FxHandle;
-class MusicHandle : public MusicStream {
+class Sword2MusicHandle : public MusicStream {
public:
uint32 _id;
bool _firstTime;
@@ -57,9 +57,9 @@ public:
int16 read();
bool eos() const;
- MusicHandle() : MusicStream(), _firstTime(false), _streaming(false),
- _paused(false), _looping(false), _fading(0),
- _fileStart(0), _filePos(0), _fileEnd(0),
+ Sword2MusicHandle() : MusicStream(), _firstTime(false),
+ _streaming(false), _paused(false), _looping(false),
+ _fading(0), _fileStart(0), _filePos(0), _fileEnd(0),
_lastSample(0) {}
};
@@ -70,8 +70,8 @@ private:
OSystem::MutexRef _mutex;
RateConverter *_converter;
- FxHandle _fx[MAXFX];
- MusicHandle _music[MAXMUS + 1];
+ Sword2FxHandle _fx[MAXFX];
+ Sword2MusicHandle _music[MAXMUS + 1];
uint8 _musicVol;
diff --git a/sword2/mem_view.cpp b/sword2/mem_view.cpp
index 26164e8798..49a8ad32be 100644
--- a/sword2/mem_view.cpp
+++ b/sword2/mem_view.cpp
@@ -27,7 +27,7 @@
// has to be global because a local in Fetch_mem_owner is destroyed on exit
char buf[50];
-void MemoryManager::displayMemory(void) {
+void Sword2MemoryManager::displayMemory(void) {
int pass, found_end, k, j, free = 0;
_standardHeader *file_header;
int scrolls = 0;
@@ -120,7 +120,7 @@ void MemoryManager::displayMemory(void) {
(free * 100) / _totalFreeMemory);
}
-const char *MemoryManager::fetchOwner(uint32 uid) {
+const char *Sword2MemoryManager::fetchOwner(uint32 uid) {
switch (uid) {
case UID_memman:
return "MEMMAN";
@@ -146,7 +146,7 @@ const char *MemoryManager::fetchOwner(uint32 uid) {
}
}
-void MemoryManager::memoryString(char *string) {
+void Sword2MemoryManager::memoryString(char *string) {
int blockNo = _baseMemBlock;
int blocksUsed = 0;
int mem_free = 0;
diff --git a/sword2/memory.cpp b/sword2/memory.cpp
index 0b6c9baef0..2807a6c7f7 100644
--- a/sword2/memory.cpp
+++ b/sword2/memory.cpp
@@ -43,17 +43,17 @@
#include "memory.h"
#include "resman.h"
-MemoryManager memory;
+Sword2MemoryManager memory;
#define MEMORY_POOL (1024 * 12000)
// #define MEMDEBUG 1
-void MemoryManager::exit(void) {
+void Sword2MemoryManager::exit(void) {
free(_freeMemman);
}
-void MemoryManager::init(void) {
+void Sword2MemoryManager::init(void) {
uint32 j;
uint8 *memory_base;
@@ -89,7 +89,7 @@ void MemoryManager::init(void) {
_baseMemBlock = 0; // for now
}
-mem *MemoryManager::lowLevelAlloc(uint32 size, uint32 type, uint32 unique_id) {
+mem *Sword2MemoryManager::lowLevelAlloc(uint32 size, uint32 type, uint32 unique_id) {
// allocate a block of memory - locked or float
// returns 0 if fails to allocate the memory
@@ -223,7 +223,7 @@ mem *MemoryManager::lowLevelAlloc(uint32 size, uint32 type, uint32 unique_id) {
return &_memList[nu_block];
}
-void MemoryManager::freeMemory(mem *block) {
+void Sword2MemoryManager::freeMemory(mem *block) {
// kill a block of memory - which was presumably floating or locked
// once you've done this the memory may be recycled
@@ -235,7 +235,7 @@ void MemoryManager::freeMemory(mem *block) {
#endif
}
-void MemoryManager::floatMemory(mem *block) {
+void Sword2MemoryManager::floatMemory(mem *block) {
// set a block to float
// wont be trashed but will move around in memory
@@ -246,7 +246,7 @@ void MemoryManager::floatMemory(mem *block) {
#endif
}
-void MemoryManager::lockMemory(mem *block) {
+void Sword2MemoryManager::lockMemory(mem *block) {
// set a block to lock
// wont be moved - don't lock memory for any longer than necessary
// unless you know the locked memory is at the bottom of the heap
@@ -261,7 +261,7 @@ void MemoryManager::lockMemory(mem *block) {
#endif
}
-int32 MemoryManager::defragMemory(uint32 req_size) {
+int32 Sword2MemoryManager::defragMemory(uint32 req_size) {
// moves floating blocks down and/or merges free blocks until a large
// enough space is found or there is nothing left to do and a big
// enough block cannot be found we stop when we find/create a large
@@ -420,7 +420,7 @@ int32 MemoryManager::defragMemory(uint32 req_size) {
return -1; //no luck, couldn't find a big enough block
}
-void MemoryManager::debugMemory(void) {
+void Sword2MemoryManager::debugMemory(void) {
// gets called with lowLevelAlloc, Mem_free, Mem_lock & Mem_float if
// MEMDEBUG has been #defined otherwise can be called at any time
// anywhere else
@@ -458,7 +458,7 @@ void MemoryManager::debugMemory(void) {
} while (j != -1);
}
-mem *MemoryManager::allocMemory(uint32 size, uint32 type, uint32 unique_id) {
+mem *Sword2MemoryManager::allocMemory(uint32 size, uint32 type, uint32 unique_id) {
// the high level allocator
// can ask the resman to remove old resources to make space - will
@@ -497,7 +497,7 @@ mem *MemoryManager::allocMemory(uint32 size, uint32 type, uint32 unique_id) {
// Maximum allowed wasted memory.
#define MAX_WASTAGE 51200
-int32 MemoryManager::virtualDefrag(uint32 size) {
+int32 Sword2MemoryManager::virtualDefrag(uint32 size) {
// Virutually defrags memory...
//
// Used to determine if there is potentially are large enough free
diff --git a/sword2/memory.h b/sword2/memory.h
index 5c83ee12dd..1a91dd01a1 100644
--- a/sword2/memory.h
+++ b/sword2/memory.h
@@ -60,7 +60,7 @@ typedef struct {
#define UID_savegame_buffer 0xfffffff6
#define UID_restoregame_buffer 0xfffffff5
-class MemoryManager {
+class Sword2MemoryManager {
private:
// Address of init malloc to be freed later
uint8 *_freeMemman;
@@ -100,6 +100,6 @@ public:
void displayMemory(void);
};
-extern MemoryManager memory;
+extern Sword2MemoryManager memory;
#endif
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index 0cea0783ac..26f17972d2 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -99,7 +99,6 @@ uint32 old_button = 0;
uint32 button_click = 0;
uint32 pointer_text_bloc_no = 0;
-uint32 pointerTextSelected = 0;
uint32 player_activity_delay = 0; // player activity delay counter
@@ -241,19 +240,19 @@ void System_menu(void) {
// call the relevent screen
switch (hit) {
case 0:
- Option_control();
+ gui.optionControl();
break;
case 1:
- Quit_control();
+ gui.quitControl();
break;
case 2:
- Save_control();
+ gui.saveControl();
break;
case 3:
- Restore_control();
+ gui.restoreControl();
break;
case 4:
- Restart_control();
+ gui.restartControl();
break;
}
@@ -880,7 +879,7 @@ void CreatePointerText(uint32 textId, uint32 pointerRes) {
int16 xOffset, yOffset;
uint8 justification;
- if (pointerTextSelected) {
+ if (gui._pointerTextSelected) {
if (textId) {
// check what the pointer is, to set offsets
// correctly for text position
diff --git a/sword2/mouse.h b/sword2/mouse.h
index 1f455417d7..3b45fd0e39 100644
--- a/sword2/mouse.h
+++ b/sword2/mouse.h
@@ -80,8 +80,6 @@ extern uint32 mouse_mode_locked;
//last minute for pause mode
extern uint32 real_luggage_item;
-extern uint32 pointerTextSelected;
-
void Reset_mouse_list(void);
void Normal_mouse(void);
diff --git a/sword2/resman.cpp b/sword2/resman.cpp
index f059e62094..b67f097926 100644
--- a/sword2/resman.cpp
+++ b/sword2/resman.cpp
@@ -59,7 +59,7 @@
#define BUFFERSIZE 4096
-ResourceManager res_man; //declare the object global
+Sword2ResourceManager res_man; //declare the object global
// ---------------------------------------------------------------------------
//
@@ -90,7 +90,7 @@ typedef struct {
// FIXME: Should init() / exit() be moved to constructor / destructor instead?
-void ResourceManager::init(void) {
+void Sword2ResourceManager::init(void) {
// We read in the resource info which tells us the names of the
// resource cluster files ultimately, although there might be groups
// within the clusters at this point it makes no difference. We only
@@ -240,7 +240,7 @@ void ResourceManager::init(void) {
file.close();
}
-void ResourceManager::exit(void) {
+void Sword2ResourceManager::exit(void) {
// free up our mallocs
free(_resList);
free(_age);
@@ -433,7 +433,7 @@ void convertEndian(uint8 *file, uint32 len) {
}
}
-uint8 *ResourceManager::open(uint32 res) {
+uint8 *Sword2ResourceManager::open(uint32 res) {
// returns ad of resource. Loads if not in memory
// retains a count
// resource can be aged out of memory if count = 0
@@ -563,7 +563,7 @@ uint8 *ResourceManager::open(uint32 res) {
return (uint8 *) _resList[res]->ad;
}
-uint8 ResourceManager::checkValid(uint32 res) {
+uint8 Sword2ResourceManager::checkValid(uint32 res) {
// returns '1' if resource is valid, otherwise returns '0'
// used in startup.cpp to ignore invalid screen-manager resources
@@ -584,7 +584,7 @@ uint8 ResourceManager::checkValid(uint32 res) {
return 1;
}
-void ResourceManager::nextCycle(void) {
+void Sword2ResourceManager::nextCycle(void) {
// increment the cycle and calculate actual per-cycle memory useage
#ifdef _SWORD2_DEBUG
@@ -614,12 +614,12 @@ void ResourceManager::nextCycle(void) {
_resTime++;
}
-uint32 ResourceManager::fetchUsage(void) {
+uint32 Sword2ResourceManager::fetchUsage(void) {
// returns memory usage previous cycle
return _currentMemoryUsage;
}
-void ResourceManager::close(uint32 res) {
+void Sword2ResourceManager::close(uint32 res) {
// decrements the count
// resource floats when count = 0
@@ -642,7 +642,7 @@ void ResourceManager::close(uint32 res) {
}
}
-uint32 ResourceManager::fetchLen(uint32 res) {
+uint32 Sword2ResourceManager::fetchLen(uint32 res) {
// returns the total file length of a resource - i.e. all headers are
// included too
@@ -675,23 +675,23 @@ uint32 ResourceManager::fetchLen(uint32 res) {
return len;
}
-char *ResourceManager::fetchCluster(uint32 res) {
+char *Sword2ResourceManager::fetchCluster(uint32 res) {
// returns a pointer to the ascii name of the cluster file which
// contains resource res
return _resourceFiles[_resConvTable[res * 2]];
}
-uint32 ResourceManager::fetchAge(uint32 res) {
+uint32 Sword2ResourceManager::fetchAge(uint32 res) {
// return the age of res
return _age[res];
}
-uint32 ResourceManager::fetchCount(uint32 res) {
+uint32 Sword2ResourceManager::fetchCount(uint32 res) {
// return the open count of res
return _count[res];
}
-uint32 ResourceManager::helpTheAgedOut(void) {
+uint32 Sword2ResourceManager::helpTheAgedOut(void) {
// remove from memory the oldest closed resource
uint32 oldest_res; // holds id of oldest found so far when we have to chuck stuff out of memory
@@ -733,7 +733,7 @@ uint32 ResourceManager::helpTheAgedOut(void) {
return _resList[oldest_res]->size; // return bytes freed
}
-void ResourceManager::printConsoleClusters(void) {
+void Sword2ResourceManager::printConsoleClusters(void) {
uint32 j;
if (_totalClusters) {
@@ -746,7 +746,7 @@ void ResourceManager::printConsoleClusters(void) {
Scroll_console();
}
-void ResourceManager::examine(uint8 *input) {
+void Sword2ResourceManager::examine(uint8 *input) {
uint32 j = 0;
uint32 res;
_standardHeader *file_header;
@@ -859,7 +859,7 @@ void ResourceManager::examine(uint8 *input) {
}
}
-void ResourceManager::kill(uint8 *input) {
+void Sword2ResourceManager::kill(uint8 *input) {
int j = 0;
uint32 res;
@@ -897,7 +897,7 @@ void ResourceManager::kill(uint8 *input) {
}
}
-void ResourceManager::remove(uint32 res) {
+void Sword2ResourceManager::remove(uint32 res) {
if (_age[res]) {
_age[res] = 0; // effectively gone from _resList
memory.freeMemory(_resList[res]); // release the memory too
@@ -906,7 +906,7 @@ void ResourceManager::remove(uint32 res) {
debug(5, "remove(%d) not even in memory!", res);
}
-void ResourceManager::removeAll(void) {
+void Sword2ResourceManager::removeAll(void) {
// remove all res files from memory - ready for a total restart
// including player object & global variables resource
@@ -926,7 +926,7 @@ void ResourceManager::removeAll(void) {
} while (j != -1);
}
-void ResourceManager::killAll(uint8 wantInfo) {
+void Sword2ResourceManager::killAll(uint8 wantInfo) {
// remove all res files from memory
// its quicker to search the mem blocs for res files than search
// resource lists for those in memory
@@ -999,7 +999,7 @@ void ResourceManager::killAll(uint8 wantInfo) {
// disappear forever, or some plaster-filled holes in sand to crash the game &
// get James in trouble again.
-void ResourceManager::killAllObjects(uint8 wantInfo) {
+void Sword2ResourceManager::killAllObjects(uint8 wantInfo) {
// remove all object res files from memory, excluding George
// its quicker to search the mem blocs for res files than search
// resource lists for those in memory
@@ -1063,7 +1063,7 @@ void ResourceManager::killAllObjects(uint8 wantInfo) {
Print_to_console(" expelled %d object resource(s)", nuked);
}
-void ResourceManager::cacheNewCluster(uint32 newCluster) {
+void Sword2ResourceManager::cacheNewCluster(uint32 newCluster) {
// Stop any music from streaming off the CD before we start the
// cluster-copy!
//
@@ -1298,7 +1298,7 @@ void ResourceManager::cacheNewCluster(uint32 newCluster) {
fclose(file);
}
-void ResourceManager::getCd(int cd) {
+void Sword2ResourceManager::getCd(int cd) {
// TODO support a seperate path for cd data?
bool done = false;
diff --git a/sword2/resman.h b/sword2/resman.h
index d388fefdb6..4d19ba6d75 100644
--- a/sword2/resman.h
+++ b/sword2/resman.h
@@ -24,7 +24,7 @@
#define MAX_res_files 20
-class ResourceManager {
+class Sword2ResourceManager {
public:
void init(void); // read in the config file
void exit(void);
@@ -103,6 +103,6 @@ private:
char _cdDrives[24];
};
-extern ResourceManager res_man; //declare the object global
+extern Sword2ResourceManager res_man; //declare the object global
#endif
diff --git a/sword2/speech.cpp b/sword2/speech.cpp
index ba6c4ce57b..162921aecc 100644
--- a/sword2/speech.cpp
+++ b/sword2/speech.cpp
@@ -976,7 +976,7 @@ int32 FN_i_speak(int32 *params) {
// for this line either, then just quit back to script right
// now!
- if (subtitles == 0 && WantSpeechForLine(params[S_WAV]) == 0)
+ if (gui._subtitles == 0 && WantSpeechForLine(params[S_WAV]) == 0)
return IR_CONT;
if (cycle_skip == 0) {
@@ -1143,7 +1143,7 @@ int32 FN_i_speak(int32 *params) {
// if speech is selected, and this line is allowed speech
// (not if it's an fx subtitle!)
- if (speechSelected && WantSpeechForLine(officialTextNumber)) {
+ if (gui._speechSelected && WantSpeechForLine(officialTextNumber)) {
// if the wavId paramter is zero because not yet
// compiled into speech command, we can still get it
// from the 1st 2 chars of the text line
@@ -1214,7 +1214,7 @@ int32 FN_i_speak(int32 *params) {
}
// if we want subtitles, or speech failed to load
- if (subtitles || speechRunning == 0) {
+ if (gui._subtitles || speechRunning == 0) {
// then we're going to show the text
textRunning = 1;
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index 474b36a78c..ecd68d6af9 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -287,8 +287,8 @@ void Sword2State::go() {
return;
}
- debug(5, "CALLING: ReadOptionSettings");
- ReadOptionSettings(); //restore the menu settings
+ debug(5, "CALLING: readOptionSettings");
+ gui.readOptionSettings();
debug(5, "CALLING: InitialiseGame");
if (InitialiseGame()) {
@@ -301,7 +301,7 @@ void Sword2State::go() {
RestoreGame(_saveSlot);
else { // show restore menu
Set_mouse(NORMAL_MOUSE_ID);
- if (!Restore_control())
+ if (!gui.restoreControl())
Start_game();
}
} else
@@ -508,8 +508,8 @@ void PauseGame(void) {
// if level at max, turn down because palette-matching won't work
// when dimmed
- if (current_graphics_level == 3) {
- UpdateGraphicsLevel(2);
+ if (gui._currentGraphicsLevel == 3) {
+ gui.updateGraphicsLevel(2);
graphics_level_fudged = 1;
}
@@ -531,12 +531,12 @@ void UnpauseGame(void) {
UnpauseAllSound();
- // put back game screen palette; see Build_display.cpp (James26jun97)
+ // put back game screen palette; see Build_display.cpp
SetFullPalette(0xffffffff);
// If graphics level at max, turn up again
if (graphics_level_fudged) {
- UpdateGraphicsLevel(3);
+ gui.updateGraphicsLevel(3);
graphics_level_fudged = 0;
}