STARK: Improve the main menu #1467
Changes from 9 commits
eaa0fab
92184a1
a147441
6120877
8121a28
16da3ce
f1b3cab
0d2641a
47ba0fd
d653b9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,15 @@ class Settings { | |
/** Check whether low-resolution fmv is available */ | ||
bool hasLowResFMV() { return _hasLowRes; } | ||
|
||
/** Enable the book of secrets */ | ||
void enableBookOfSecrets() { | ||
ConfMan.setBool("xoBfOsterceS", true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just follow the name in "w_world.ini" :p |
||
ConfMan.flushToDisk(); | ||
} | ||
|
||
/** Check whether the book of secrets is enabled */ | ||
bool hasBookOfSecrets() { return ConfMan.hasKey("xoBfOsterceS"); } | ||
|
||
private: | ||
Audio::Mixer *_mixer; | ||
bool _hasLowRes; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,9 @@ class UserInterface { | |
void backPrevScreen(); | ||
|
||
/** Back to the main menu screen and rest resources */ | ||
void quitToMainMenu(); | ||
void requestQuitToMainMenu() { _quitToMainMenu = true; } | ||
bool hasQuitToMainMenuRequest() { return _quitToMainMenu; } | ||
void performQuitToMainMenu(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Building with Address Sanitizer enabled helps a lot to understand these issues. It tells precisely the cause of the use after free. It's probably a bit of a pain to get it working on Windows, and IMO it's well worth having a Linux install somewhere just to be able to use it when needed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah now I know the good of Linux... |
||
|
||
/** Restore the screen travelling history to the initial state*/ | ||
void restoreScreenHistory(); | ||
|
@@ -173,6 +175,7 @@ class UserInterface { | |
Gfx::Driver *_gfx; | ||
Cursor *_cursor; | ||
bool _exitGame; | ||
bool _quitToMainMenu; | ||
|
||
bool _interactive; | ||
bool _interactionAttemptDenied; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,13 +26,12 @@ | |
#include "engines/stark/services/global.h" | ||
#include "engines/stark/services/settings.h" | ||
|
||
#include "common/config-manager.h" | ||
#include "common/translation.h" | ||
#include "engines/stark/gfx/renderentry.h" | ||
#include "engines/stark/visual/text.h" | ||
|
||
#include "gui/saveload.h" | ||
#include "gui/message.h" | ||
#include "engines/stark/scene.h" | ||
|
||
#include "engines/engine.h" | ||
#include "common/config-manager.h" | ||
|
||
namespace Stark { | ||
|
||
|
@@ -72,7 +71,7 @@ void MainMenuScreen::open() { | |
|
||
_widgets.push_back(new StaticLocationWidget( | ||
"Box", | ||
nullptr, | ||
CLICK_HANDLER(MainMenuScreen, boxHandler), | ||
MOVE_HANDLER(MainMenuScreen, helpTextHandler<kBox>))); | ||
_widgets.back()->setupSounds(0, 1); | ||
|
||
|
@@ -124,15 +123,7 @@ void MainMenuScreen::open() { | |
nullptr)); | ||
_widgets.back()->setVisible(false); | ||
|
||
_widgets.push_back(new StaticLocationWidget( | ||
"VERSION INFO", | ||
nullptr, | ||
nullptr)); | ||
|
||
_widgets.push_back(new StaticLocationWidget( | ||
"VERSION INFO REALLY", | ||
nullptr, | ||
nullptr)); | ||
_widgets.push_back(new VersionInfoText()); | ||
} | ||
|
||
template<MainMenuScreen::HelpTextIndex N> | ||
|
@@ -181,8 +172,23 @@ void MainMenuScreen::settingsHandler() { | |
StarkUserInterface->changeScreen(Screen::kScreenSettingsMenu); | ||
} | ||
|
||
void MainMenuScreen::boxHandler() { | ||
if (!StarkSettings->isDemo() && StarkSettings->hasBookOfSecrets()) { | ||
StarkUserInterface->changeScreen(kScreenGame); | ||
StarkResourceProvider->initGlobal(); | ||
StarkResourceProvider->requestLocationChange(0x7c, 0x00); | ||
} | ||
} | ||
|
||
void MainMenuScreen::quitHandler() { | ||
StarkUserInterface->notifyShouldExit(); | ||
} | ||
|
||
} // End of namespace Stark | ||
VersionInfoText::VersionInfoText() : | ||
StaticLocationWidget("VERSION INFO REALLY", nullptr, nullptr) { | ||
Common::String text = _copyrightSymbol + Common::String("1999 Funcom"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we cannot access the build version of the original executable and we are not using the Audiere library, I chose to just display the Funcom text. |
||
_renderEntry->getText()->setText(text); | ||
_renderEntry->setPosition(Common::Point(_posX, _posY)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default positions of the "VERSION INFO HERE" widget in the released game and the demo are different, and both of them needs to be moved, so I chose to hard-code it. |
||
} | ||
|
||
} // End of namespace Stark |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
#include "engines/stark/resources/knowledgeset.h" | ||
#include "engines/stark/resources/item.h" | ||
#include "engines/stark/resources/location.h" | ||
#include "engines/stark/resources/layer.h" | ||
|
||
#include "engines/stark/services/global.h" | ||
#include "engines/stark/services/services.h" | ||
|
@@ -41,6 +42,8 @@ | |
#include "engines/stark/ui/world/actionmenu.h" | ||
#include "engines/stark/ui/world/inventorywindow.h" | ||
|
||
#include "engines/stark/visual/text.h" | ||
|
||
namespace Stark { | ||
|
||
GameWindow::GameWindow(Gfx::Driver *gfx, Cursor *cursor, ActionMenu *actionMenu, InventoryWindow *inventory) : | ||
|
@@ -238,4 +241,25 @@ void GameWindow::reset() { | |
_objectRelativePosition.y = 0; | ||
} | ||
|
||
void GameWindow::onScreenChanged() { | ||
// May be called when resources have not been loaded | ||
if (!StarkGlobal->getCurrent()) { | ||
return; | ||
} | ||
|
||
Common::Array<Resources::Layer *> layers = StarkGlobal->getCurrent()->getLocation()->listLayers(); | ||
|
||
VisualText *text = nullptr; | ||
Gfx::RenderEntryArray renderEntries; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please reduce the scope of these variables. That'd makes the code a bit easier to read, IMO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean putting the declaration into the loop? I am not sure how compilers can optimize this these days but isn't that may potentially cause unnecessary variable creations and deallocations, especially since we have an array here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. C++ compilers are very good with these little details. For non performance critical code it's better to focus on writing simple and readable code. In this particular case, constructing |
||
for (uint i = 0; i < layers.size(); ++i) { | ||
renderEntries = layers[i]->listRenderEntries(); | ||
for (uint j = 0; j < renderEntries.size(); ++j) { | ||
text = renderEntries[j]->getText(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Texts in not only the current layer but all the layers within the same location need to reset their textures when the resolution has changed, otherwise, the user may change the screen, go back to a previous layer and find size-unmatched texts. |
||
if (text) { | ||
text->resetTexture(); | ||
} | ||
} | ||
} | ||
} | ||
|
||
} // End of namespace Stark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the implementation of
GameWindow::onScreenChanged()
I came across with render entries with noVisual
. It feels strange to me since aRenderEntry
without aVisual
seems pretty useless. But anyway it needs to be handled.