aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMatthew Stewart2018-05-08 22:48:40 -0400
committerEugene Sandulenko2018-08-09 08:37:30 +0200
commitd37e2aba0e932c3d9c082823caf526fcb415fd50 (patch)
treec29ea741cf473c8da2f7c41c01185b3df14b7a68 /engines
parente206d8e19875f2545b59e68c753d45b864228f21 (diff)
downloadscummvm-rg350-d37e2aba0e932c3d9c082823caf526fcb415fd50.tar.gz
scummvm-rg350-d37e2aba0e932c3d9c082823caf526fcb415fd50.tar.bz2
scummvm-rg350-d37e2aba0e932c3d9c082823caf526fcb415fd50.zip
STARTREK: Options menu
Diffstat (limited to 'engines')
-rw-r--r--engines/startrek/graphics.cpp6
-rw-r--r--engines/startrek/graphics.h18
-rw-r--r--engines/startrek/sound.cpp8
-rw-r--r--engines/startrek/sprite.h2
-rw-r--r--engines/startrek/startrek.cpp14
-rw-r--r--engines/startrek/startrek.h11
-rw-r--r--engines/startrek/text.cpp259
7 files changed, 221 insertions, 97 deletions
diff --git a/engines/startrek/graphics.cpp b/engines/startrek/graphics.cpp
index 41bc6f2231..dedbf932ca 100644
--- a/engines/startrek/graphics.cpp
+++ b/engines/startrek/graphics.cpp
@@ -383,7 +383,7 @@ void Graphics::drawAllSprites() {
for (int i=0; i<_numSprites; i++) {
Sprite *spr = _sprites[i];
- if (spr->field16 == 0 && spr->isOnScreen) {
+ if (!spr->field16 && spr->isOnScreen) {
bool mustRedrawSprite = false;
Common::Rect rect2;
@@ -403,7 +403,7 @@ void Graphics::drawAllSprites() {
drawSprite(*spr, rect2);
}
- spr->field16 = 0;
+ spr->field16 = false;
spr->bitmapChanged = 0;
spr->lastDrawRect = spr->drawRect;
}
@@ -418,7 +418,7 @@ void Graphics::addSprite(Sprite *sprite) {
// Initialize some fields
sprite->drawMode = 0;
sprite->field8 = 0;
- sprite->field16 = 0;
+ sprite->field16 = false;
sprite->lastDrawRect.top = -1;
sprite->lastDrawRect.left = -1;
diff --git a/engines/startrek/graphics.h b/engines/startrek/graphics.h
index b684ced05e..c63b2f6943 100644
--- a/engines/startrek/graphics.h
+++ b/engines/startrek/graphics.h
@@ -44,7 +44,7 @@ const int SCREEN_WIDTH = 320;
const int SCREEN_HEIGHT = 200;
const int MAX_SPRITES = 32;
-const int MAX_MENUBUTTONS = 16; // This is arbitrary, the original game has no such limit
+const int MAX_MENUBUTTONS = 32;
const int TEXTBOX_WIDTH = 26;
const int MAX_TEXTBOX_LINES = 12;
@@ -59,8 +59,6 @@ struct Menu {
uint16 numButtons;
int16 selectedButton;
SharedPtr<Menu> nextMenu;
-
- Menu() : nextMenu(SharedPtr<Menu>()) {}
};
class Graphics;
@@ -122,7 +120,7 @@ public:
String readTextFromArray(int choiceIndex, uintptr data, String *headerTextOutput);
private:
- int handleTextboxEvents(uint32 ticksUntilClickingEnabled, bool arg4);
+ int handleMenuEvents(uint32 ticksUntilClickingEnabled, bool arg4);
SharedPtr<TextBitmap> initTextSprite(int *xoffsetPtr, int *yoffsetPtr, byte textColor, int numTextLines, bool withHeader, Sprite *sprite);
void drawMainText(SharedPtr<TextBitmap> bitmap, int numTextLines, int numTextboxLines, const String &text, bool withHeader);
@@ -140,11 +138,13 @@ private:
int getMenuButtonAt(const Menu &menu, int x, int y);
void drawMenuButtonOutline(SharedPtr<Bitmap> bitmap, byte color);
void loadMenuButtons(String mnuFilename, int xpos, int ypos);
- void disableMenuButton(uint32 bits);
- void enableMenuButton(uint32 bits);
+ void unloadMenuButtons();
+ void disableMenuButtons(uint32 bits);
+ void enableMenuButtons(uint32 bits);
public:
- void openTextConfigurationMenu(bool fromOptionMenu);
+ void showOptionsMenu(int x, int y);
+ void showTextConfigurationMenu(bool fromOptionMenu);
int loadTextDisplayMode();
void saveTextDisplayMode(int value);
@@ -153,12 +153,12 @@ private:
uint32 _textboxVar2;
uint32 _textboxVar3;
uint16 _textboxVar6;
- uint16 _textboxVar7;
bool _textboxHasMultipleChoices;
SharedPtr<Menu> _activeMenu;
- uint16 _textboxButtonVar4;
+ // Saved value of StarTrekEngine::_keyboardControlsMouse when menus are up
+ bool _keyboardControlsMouseOutsideMenu;
};
}
diff --git a/engines/startrek/sound.cpp b/engines/startrek/sound.cpp
index c5e63239ae..ac23cf620e 100644
--- a/engines/startrek/sound.cpp
+++ b/engines/startrek/sound.cpp
@@ -79,12 +79,8 @@ Sound::~Sound() {
void Sound::playMidiTrack(int track) {
- if (!_vm->_musicEnabled)
+ if (!_vm->_musicEnabled || !_vm->_musicWorking)
return;
- /*
- if (!_vm->_word_467a8)
- return;
- */
assert(loadedSoundData != NULL);
@@ -137,7 +133,7 @@ void Sound::playSoundEffect(const char *baseSoundName) {
if (scumm_stricmp(baseSoundName+4, "loop") == 0)
_loopingAudioName = Common::String(baseSoundName);
- if (!_vm->_sfxEnabled || !_vm->_audioEnabled)
+ if (!_vm->_sfxEnabled || !_vm->_sfxWorking)
return;
/*
diff --git a/engines/startrek/sprite.h b/engines/startrek/sprite.h
index 5fdc0f511f..c7a26dee4a 100644
--- a/engines/startrek/sprite.h
+++ b/engines/startrek/sprite.h
@@ -54,7 +54,7 @@ struct Sprite {
bool bitmapChanged;
bool rect2Valid;
bool isOnScreen;
- uint16 field16; // When set, sprite isn't drawn next refresh? (Gets reset to 0 after)
+ bool field16; // When set, sprite isn't drawn next refresh? (Gets reset to 0 after)
Common::Rect lastDrawRect; // Rect encompassing the sprite last time it was drawn
Common::Rect drawRect; // Rect encompassing the sprite currently
Common::Rect rectangle2;
diff --git a/engines/startrek/startrek.cpp b/engines/startrek/startrek.cpp
index 44e4713c4b..de851b36a2 100644
--- a/engines/startrek/startrek.cpp
+++ b/engines/startrek/startrek.cpp
@@ -47,9 +47,17 @@ StarTrekEngine::StarTrekEngine(OSystem *syst, const StarTrekGameDescription *gam
_macResFork = nullptr;
_room = nullptr;
- _audioEnabled = true;
+ _clockTicks = 0;
+
_musicEnabled = true;
_sfxEnabled = true;
+ _word_467a6 = true;
+ _musicWorking = true;
+ _sfxWorking = true;
+ _finishedPlayingSpeech = false;
+
+ _mouseControllingShip = false;
+ _keyboardControlsMouse = true;
}
StarTrekEngine::~StarTrekEngine() {
@@ -139,7 +147,9 @@ Common::Error StarTrekEngine::run() {
*/
- _gfx->openTextConfigurationMenu(false);
+ while (true) {
+ _gfx->showOptionsMenu(0, 0);
+ }
_gfx->showText(&Graphics::readTextFromRdf, 0x2220, 150, 160, 0xb3, 0, 10, 0);
while (!shouldQuit()) {
diff --git a/engines/startrek/startrek.h b/engines/startrek/startrek.h
index 440773f918..5f57f9bf33 100644
--- a/engines/startrek/startrek.h
+++ b/engines/startrek/startrek.h
@@ -150,10 +150,17 @@ public:
bool _musicEnabled;
bool _sfxEnabled;
uint16 _word_467a6;
- uint16 _word_467a8;
- bool _audioEnabled;
+ uint16 _musicWorking;
+ bool _sfxWorking;
bool _finishedPlayingSpeech;
+ bool _mouseControllingShip;
+
+ // TODO: make this work.
+ // When false, the keyboard generally acts in a more specific way (ie. move mouse
+ // between items in a menu).
+ bool _keyboardControlsMouse;
+
private:
Graphics *_gfx;
diff --git a/engines/startrek/text.cpp b/engines/startrek/text.cpp
index b7a642caca..8c4f05ca1e 100644
--- a/engines/startrek/text.cpp
+++ b/engines/startrek/text.cpp
@@ -26,22 +26,39 @@
#include "startrek/graphics.h"
-// List of events that can be returned by handleTextboxEvents.
-enum TextEvent {
- TEXTEVENT_RCLICK_OFFBUTTON = -4,
- TEXTEVENT_ENABLEINPUT, // Makes buttons selectable (occurs after a delay)
- TEXTEVENT_RCLICK_ONBUTTON,
- TEXTEVENT_LCLICK_OFFBUTTON,
- TEXTEVENT_CONFIRM = 0,
- TEXTEVENT_SCROLLUP,
- TEXTEVENT_SCROLLDOWN,
- TEXTEVENT_PREVCHOICE,
- TEXTEVENT_NEXTCHOICE,
- TEXTEVENT_SCROLLUP_ONELINE,
- TEXTEVENT_SCROLLDOWN_ONELINE,
- TEXTEVENT_GOTO_TOP,
- TEXTEVENT_GOTO_BOTTOM,
- TEXTEVENT_SPEECH_DONE
+// Special events that can be returned by handleMenuEvents.
+enum MenuEvent {
+ MENUEVENT_RCLICK_OFFBUTTON = -4,
+ MENUEVENT_ENABLEINPUT, // Makes buttons selectable (occurs after a delay)
+ MENUEVENT_RCLICK_ONBUTTON,
+ MENUEVENT_LCLICK_OFFBUTTON,
+};
+
+// Buttons for standard text display
+enum TextButtons {
+ TEXTBUTTON_CONFIRM = 0,
+ TEXTBUTTON_SCROLLUP,
+ TEXTBUTTON_SCROLLDOWN,
+ TEXTBUTTON_PREVCHOICE,
+ TEXTBUTTON_NEXTCHOICE,
+ TEXTBUTTON_SCROLLUP_ONELINE,
+ TEXTBUTTON_SCROLLDOWN_ONELINE,
+ TEXTBUTTON_GOTO_TOP,
+ TEXTBUTTON_GOTO_BOTTOM,
+ TEXTBUTTON_SPEECH_DONE // "Virtual" button?
+};
+
+// Buttons for option menu (corresponding to button indices, not button retvals, which are
+// different for some reason)
+enum OptionMenuButtons {
+ OPTIONBUTTON_TEXT,
+ OPTIONBUTTON_SAVE,
+ OPTIONBUTTON_LOAD,
+ OPTIONBUTTON_ENABLEMUSIC,
+ OPTIONBUTTON_DISABLEMUSIC,
+ OPTIONBUTTON_ENABLESFX,
+ OPTIONBUTTON_DISABLESFX,
+ OPTIONBUTTON_QUIT
};
namespace StarTrek {
@@ -88,13 +105,13 @@ int Graphics::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int
int choiceIndex = 0;
int scrollOffset = 0;
if (tmpTextDisplayMode != TEXTDISPLAY_WAIT && tmpTextDisplayMode != TEXTDISPLAY_SUBTITLES
- && numChoices == 1 && _vm->_sfxEnabled && !_vm->_audioEnabled)
+ && numChoices == 1 && _vm->_sfxEnabled && !_vm->_sfxWorking)
_textboxHasMultipleChoices = false;
else
_textboxHasMultipleChoices = true;
if (tmpTextDisplayMode >= TEXTDISPLAY_WAIT && tmpTextDisplayMode <= TEXTDISPLAY_NONE
- && _vm->_sfxEnabled && !_vm->_audioEnabled)
+ && _vm->_sfxEnabled && !_vm->_sfxWorking)
_textboxVar6 = true;
else
_textboxVar6 = false;
@@ -106,7 +123,7 @@ int Graphics::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int
// TODO
}
else {
- loadMenuButtons("textbtns", xoffset+0x96, yoffset-0x11);
+ loadMenuButtons("textbtns", xoffset + 0x96, yoffset - 0x11);
Common::Point oldMousePos = getMousePos();
SharedPtr<Bitmap> oldMouseBitmap = _mouseBitmap;
@@ -114,35 +131,35 @@ int Graphics::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int
_vm->_system->warpMouse(xoffset + 0xde, yoffset - 0x08);
setMouseCursor(loadBitmap("pushbtn"));
- uint16 tmpTextboxVar7 = _textboxVar7;
- _textboxVar7 = 0;
+ bool tmpMouseControllingShip = _vm->_mouseControllingShip;
+ _vm->_mouseControllingShip = false;
int var80 = (numChoices > 1 ? 0x18 : 0);
// TODO: sub_288FB function call
- disableMenuButton(0x0002); // Disable scroll up
+ disableMenuButtons(1 << TEXTBUTTON_SCROLLUP); // Disable scroll up
if (var7c == 0) { // Disable done button
- disableMenuButton(0x0001);
+ disableMenuButtons(1 << TEXTBUTTON_CONFIRM);
}
if (!loopChoices) { // Disable prev button
- disableMenuButton(0x0008);
+ disableMenuButtons(1 << TEXTBUTTON_PREVCHOICE);
}
bool doneShowingText = false;
// Loop until text is done being displayed
while (!doneShowingText) {
- int textboxReturnCode = handleTextboxEvents(var7c, true);
+ int textboxReturnCode = handleMenuEvents(var7c, true);
if (var7c == 0) {
- enableMenuButton(0x0001);
+ enableMenuButtons(1 << TEXTBUTTON_CONFIRM);
}
switch(textboxReturnCode) {
- case TEXTEVENT_RCLICK_OFFBUTTON:
- case TEXTEVENT_RCLICK_ONBUTTON:
+ case MENUEVENT_RCLICK_OFFBUTTON:
+ case MENUEVENT_RCLICK_ONBUTTON:
if (var7c == 0) {
doneShowingText = true;
if (arg10)
@@ -150,50 +167,50 @@ int Graphics::showText(TextGetterFunc textGetter, uintptr var, int xoffset, int
}
break;
- case TEXTEVENT_CONFIRM:
+ case TEXTBUTTON_CONFIRM:
doneShowingText = true;
break;
- case TEXTEVENT_SCROLLUP:
+ case TEXTBUTTON_SCROLLUP:
scrollOffset -= numTextboxLines;
goto readjustScrollUp;
- case TEXTEVENT_SCROLLDOWN:
+ case TEXTBUTTON_SCROLLDOWN:
scrollOffset += numTextboxLines;
goto readjustScrollDown;
- case TEXTEVENT_SCROLLUP_ONELINE:
+ case TEXTBUTTON_SCROLLUP_ONELINE:
scrollOffset--;
goto readjustScrollUp;
- case TEXTEVENT_SCROLLDOWN_ONELINE:
+ case TEXTBUTTON_SCROLLDOWN_ONELINE:
scrollOffset++;
goto readjustScrollDown;
- case TEXTEVENT_GOTO_TOP:
+ case TEXTBUTTON_GOTO_TOP:
scrollOffset = 0;
goto readjustScrollUp;
- case TEXTEVENT_GOTO_BOTTOM:
+ case TEXTBUTTON_GOTO_BOTTOM:
scrollOffset = numTextLines - numTextboxLines;
goto readjustScrollDown;
readjustScrollUp:
- enableMenuButton(0x0004);
+ enableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
if (scrollOffset < 0)
scrollOffset = 0;
if (scrollOffset == 0)
- disableMenuButton(0x0002);
+ disableMenuButtons(1 << TEXTBUTTON_SCROLLUP);
goto readjustScroll;
readjustScrollDown:
- enableMenuButton(0x0002);
+ enableMenuButtons(1 << TEXTBUTTON_SCROLLUP);
if (scrollOffset >= numTextLines)
scrollOffset -= numTextboxLines;
if (scrollOffset > numTextLines-1)
scrollOffset = numTextLines-1;
if (scrollOffset+numTextboxLines >= numTextLines)
- disableMenuButton(0x0004);
+ disableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
goto readjustScroll;
readjustScroll:
@@ -206,23 +223,23 @@ readjustScroll:
numChoicesWithNames != 0);
break;
- case TEXTEVENT_PREVCHOICE:
+ case TEXTBUTTON_PREVCHOICE:
choiceIndex--;
if (!loopChoices && choiceIndex == 0) {
- disableMenuButton(0x0008);
+ disableMenuButtons(1 << TEXTBUTTON_PREVCHOICE);
}
else {
if (choiceIndex < 0)
choiceIndex = numChoices-1;
}
- enableMenuButton(0x0010);
+ enableMenuButtons(1 << TEXTBUTTON_NEXTCHOICE);
goto reloadText;
- case TEXTEVENT_NEXTCHOICE:
- enableMenuButton(0x0008);
+ case TEXTBUTTON_NEXTCHOICE:
+ enableMenuButtons(1 << TEXTBUTTON_PREVCHOICE);
choiceIndex++;
if (!loopChoices && choiceIndex == numChoices-1) {
- disableMenuButton(0x0010);
+ disableMenuButtons(1 << TEXTBUTTON_NEXTCHOICE);
}
else {
choiceIndex %= numChoices;
@@ -238,18 +255,18 @@ reloadText:
else {
// sub_288FB(0x001F);
}
- enableMenuButton(0x0004);
- disableMenuButton(0x0002);
+ enableMenuButtons(1 << TEXTBUTTON_SCROLLDOWN);
+ disableMenuButtons(1 << TEXTBUTTON_SCROLLUP);
textboxSprite.bitmapChanged = true;
break;
- case TEXTEVENT_SPEECH_DONE:
+ case TEXTBUTTON_SPEECH_DONE:
if (numChoices == 1)
doneShowingText = true;
break;
- case TEXTEVENT_ENABLEINPUT:
- case TEXTEVENT_LCLICK_OFFBUTTON:
+ case MENUEVENT_ENABLEINPUT:
+ case MENUEVENT_LCLICK_OFFBUTTON:
default:
break;
}
@@ -258,10 +275,10 @@ reloadText:
setMouseCursor(oldMouseBitmap);
_vm->_system->warpMouse(oldMousePos.x, oldMousePos.y);
- _textboxVar7 = tmpTextboxVar7;
- // sub_29326();
- textboxSprite.field16 = 1;
- textboxSprite.bitmapChanged = 1;
+ _vm->_mouseControllingShip = tmpMouseControllingShip;
+ unloadMenuButtons();
+ textboxSprite.field16 = true;
+ textboxSprite.bitmapChanged = true;
drawAllSprites();
delSprite(&textboxSprite);
@@ -273,7 +290,11 @@ reloadText:
return choiceIndex;
}
-int Graphics::handleTextboxEvents(uint32 ticksUntilClickingEnabled, bool arg4) {
+/**
+ * This returns either a special menu event (negative number) or the retval of the button
+ * clicked (usually an index, always positive).
+ */
+int Graphics::handleMenuEvents(uint32 ticksUntilClickingEnabled, bool arg4) {
// TODO: finish
uint32 tickWhenClickingEnabled = _vm->_clockTicks + ticksUntilClickingEnabled;
@@ -316,14 +337,14 @@ int Graphics::handleTextboxEvents(uint32 ticksUntilClickingEnabled, bool arg4) {
if (_vm->_finishedPlayingSpeech != 0) {
_vm->_finishedPlayingSpeech = 0;
if (_textDisplayMode != TEXTDISPLAY_WAIT) {
- return TEXTEVENT_SPEECH_DONE;
+ return TEXTBUTTON_SPEECH_DONE;
}
}
// sub_1E88C();
_textboxVar3++;
if (ticksUntilClickingEnabled != 0 && _vm->_clockTicks >= tickWhenClickingEnabled)
- return TEXTEVENT_ENABLEINPUT;
+ return MENUEVENT_ENABLEINPUT;
break;
}
@@ -336,7 +357,7 @@ int Graphics::handleTextboxEvents(uint32 ticksUntilClickingEnabled, bool arg4) {
Common::Point mouse = getMousePos();
if (getMenuButtonAt(*_activeMenu, mouse.x, mouse.y) == -1) {
_vm->playSoundEffectIndex(0x10);
- return TEXTEVENT_LCLICK_OFFBUTTON;
+ return MENUEVENT_LCLICK_OFFBUTTON;
}
}
break;
@@ -559,14 +580,14 @@ String Graphics::readLineFormattedText(TextGetterFunc textGetter, uintptr var, i
String headerText;
String text = (this->*textGetter)(choiceIndex, var, &headerText);
- if (_textDisplayMode == TEXTDISPLAY_NONE && _vm->_sfxEnabled && _vm->_audioEnabled) {
+ if (_textDisplayMode == TEXTDISPLAY_NONE && _vm->_sfxEnabled && _vm->_sfxWorking) {
uint32 oldSize = text.size();
text = playTextAudio(text);
if (oldSize != text.size())
_textboxHasMultipleChoices = true;
}
else if ((_textDisplayMode == TEXTDISPLAY_WAIT || _textDisplayMode == TEXTDISPLAY_SUBTITLES)
- && _vm->_sfxEnabled && _vm->_audioEnabled) {
+ && _vm->_sfxEnabled && _vm->_sfxWorking) {
text = playTextAudio(text);
}
else {
@@ -732,7 +753,7 @@ String Graphics::playTextAudio(const String &str) {
* Returns the index of the button at the given position, or -1 if none.
*/
int Graphics::getMenuButtonAt(const Menu &menu, int x, int y) {
- for (int i=0; i<menu.numButtons; i++) {
+ for (int i = 0; i < menu.numButtons; i++) {
const Sprite &spr = menu.sprites[i];
if (spr.drawMode != 2)
@@ -780,7 +801,13 @@ void Graphics::drawMenuButtonOutline(SharedPtr<Bitmap> bitmap, byte color) {
}
}
+/**
+ * Loads a .MNU file, which is a list of buttons to display.
+ */
void Graphics::loadMenuButtons(String mnuFilename, int xpos, int ypos) {
+ if (_activeMenu == nullptr)
+ _keyboardControlsMouseOutsideMenu = _vm->_keyboardControlsMouse;
+
SharedPtr<Menu> oldMenu = _activeMenu;
_activeMenu = SharedPtr<Menu>(new Menu());
_activeMenu->nextMenu = oldMenu;
@@ -790,7 +817,7 @@ void Graphics::loadMenuButtons(String mnuFilename, int xpos, int ypos) {
_activeMenu->menuFile = stream;
_activeMenu->numButtons = _activeMenu->menuFile->size()/16;
- for (int i=0; i<_activeMenu->numButtons; i++) {
+ for (int i = 0; i < _activeMenu->numButtons; i++) {
memset(&_activeMenu->sprites[i], 0, sizeof(Sprite));
addSprite(&_activeMenu->sprites[i]);
_activeMenu->sprites[i].drawMode = 2;
@@ -814,25 +841,49 @@ void Graphics::loadMenuButtons(String mnuFilename, int xpos, int ypos) {
if (_activeMenu->retvals[_activeMenu->numButtons-1] == 0) {
// Set default retvals for buttons
- for (int i=0; i<_activeMenu->numButtons; i++)
+ for (int i = 0; i < _activeMenu->numButtons; i++)
_activeMenu->retvals[i] = i;
}
_activeMenu->selectedButton = -1;
_activeMenu->disabledButtons = 0;
- _textboxButtonVar4 = 0;
+ _vm->_keyboardControlsMouse = false;
}
-// Values for standard text displays:
-// 0x0001: Disable done button
-// 0x0002: Disable scroll up
-// 0x0004: Disable scroll down
-// 0x0008: Disable prev choice
-// 0x0010: Disable next choice
-void Graphics::disableMenuButton(uint32 bits) {
+void Graphics::unloadMenuButtons() {
+ if (_activeMenu->selectedButton != -1)
+ drawMenuButtonOutline(_activeMenu->sprites[_activeMenu->selectedButton].bitmap, 0x00);
+
+ for (int i = 0; i < _activeMenu->numButtons; i++) {
+ Sprite *sprite = &_activeMenu->sprites[i];
+ if (sprite->drawMode == 2) {
+ sprite->field16 = true;
+ sprite->bitmapChanged = true;
+ }
+ }
+
+ drawAllSprites();
+
+ for (int i = 0; i < _activeMenu->numButtons; i++) {
+ Sprite *sprite = &_activeMenu->sprites[i];
+ sprite->bitmap.reset();
+ if (sprite->drawMode == 2)
+ delSprite(sprite);
+ }
+
+ _activeMenu = _activeMenu->nextMenu;
+
+ if (_activeMenu == nullptr)
+ _vm->_keyboardControlsMouse = _keyboardControlsMouseOutsideMenu;
+}
+
+/**
+ * Disables the given bitmask of buttons.
+ */
+void Graphics::disableMenuButtons(uint32 bits) {
_activeMenu->disabledButtons |= bits;
if (_activeMenu->selectedButton != -1
- && (_activeMenu->disabledButtons & (1<<_activeMenu->selectedButton))) {
+ && (_activeMenu->disabledButtons & (1 << _activeMenu->selectedButton))) {
Sprite *sprite = &_activeMenu->sprites[_activeMenu->selectedButton];
drawMenuButtonOutline(sprite->bitmap, 0x00);
@@ -841,15 +892,75 @@ void Graphics::disableMenuButton(uint32 bits) {
}
}
-void Graphics::enableMenuButton(uint32 bits) {
+void Graphics::enableMenuButtons(uint32 bits) {
_activeMenu->disabledButtons &= ~bits;
}
+
+void Graphics::showOptionsMenu(int x, int y) {
+ bool tmpMouseControllingShip = _vm->_mouseControllingShip;
+ _vm->_mouseControllingShip = false;
+
+ Common::Point oldMousePos = getMousePos();
+ SharedPtr<Bitmap> oldMouseBitmap = _mouseBitmap;
+
+ setMouseCursor(loadBitmap("options"));
+ loadMenuButtons("options", x, y);
+
+ uint32 disabledButtons = 0;
+ if (_vm->_musicWorking) {
+ if (_vm->_musicEnabled)
+ disabledButtons |= (1 << OPTIONBUTTON_ENABLEMUSIC);
+ else
+ disabledButtons |= (1 << OPTIONBUTTON_DISABLEMUSIC);
+ }
+ else
+ disabledButtons |= (1 << OPTIONBUTTON_ENABLEMUSIC) | (1 << OPTIONBUTTON_DISABLEMUSIC);
+
+ if (_vm->_sfxWorking) {
+ if (_vm->_sfxEnabled)
+ disabledButtons |= (1 << OPTIONBUTTON_ENABLESFX);
+ else
+ disabledButtons |= (1 << OPTIONBUTTON_DISABLESFX);
+ }
+ else
+ disabledButtons |= (1 << OPTIONBUTTON_ENABLESFX) | (1 << OPTIONBUTTON_DISABLESFX);
+
+ disableMenuButtons(disabledButtons);
+ // sub_28b5d();
+ int event = handleMenuEvents(0, false);
+
+ unloadMenuButtons();
+ _vm->_mouseControllingShip = tmpMouseControllingShip;
+ setMouseCursor(oldMouseBitmap);
+
+ if (event != MENUEVENT_LCLICK_OFFBUTTON && event != MENUEVENT_RCLICK_OFFBUTTON)
+ _vm->_system->warpMouse(oldMousePos.x, oldMousePos.y);
+
+
+ // Can't use OPTIONBUTTON constants since the button retvals differ from the button
+ // indices...
+ switch(event) { // TODO
+ case 0: // Save
+ case 1: // Load
+ case 2: // Enable music
+ case 3: // Disable music
+ case 4: // Enable sfx
+ case 5: // Disable sfx
+ case 6: // Quit
+ case 7: // Text
+ showTextConfigurationMenu(true);
+ break;
+ default:
+ break;
+ }
+}
+
/**
* This can be called from startup or from the options menu.
* On startup, this tries to load the setting without user input.
*/
-void Graphics::openTextConfigurationMenu(bool fromOptionMenu) {
+void Graphics::showTextConfigurationMenu(bool fromOptionMenu) {
const char *options[] = { // TODO: languages...
"Text display",
"Text subtitles.",