Conversation
return _visual->get<VisualImageXMG>(); | ||
} | ||
|
||
VisualText *RenderEntry::getText() const { | ||
if (!_visual) { | ||
return nullptr; |
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 no Visual
. It feels strange to me since a RenderEntry
without a Visual
seems pretty useless. But anyway it needs to be handled.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Just follow the name in "w_world.ini" :p
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Script
needs to request quitting to the main menu. In the previous implementation, immediately quitting will trigger the deallocation of the Script
object and therefore crash the game and it took me an eternity to realize this!!! . So it is cached here and is performed later in the update part of the game's main loop.
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah now I know the good of Linux...
engines/stark/ui/menu/mainmenu.cpp
Outdated
if (!StarkSettings->isDemo() && StarkSettings->hasBookOfSecrets()) { | ||
StarkUserInterface->changeScreen(kScreenGame); | ||
StarkResourceProvider->initGlobal(); | ||
StarkScene->setFadeLevel(1.0f); |
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.
The "Book of Secrets" will not handle the fade level by itself. I don't find a problem setting it here before the actual game starts.
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.
Shouldn't the fade level be initialized to 1.0 in the Scene class rather than here?
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 comment
The 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.
Common::String text = _copyrightSymbol + Common::String("1999 Funcom"); | ||
_renderEntry->getText()->setText(text); | ||
_renderEntry->setPosition(Common::Point(_posX, _posY)); |
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.
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.
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 comment
The 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.
A quick way to test the Book of Secrets: Ensure that the "xoBfOsterceS" is not set in the configuration, use the debug console to change to location 3c 00, enable inventory item 15, and plant the organic leaf in the flower bed. The Book of Secrets will then be enabled. |
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.
This is looking Ok. I've added a few very minor comments.
engines/stark/ui/menu/mainmenu.cpp
Outdated
if (!StarkSettings->isDemo() && StarkSettings->hasBookOfSecrets()) { | ||
StarkUserInterface->changeScreen(kScreenGame); | ||
StarkResourceProvider->initGlobal(); | ||
StarkScene->setFadeLevel(1.0f); |
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.
Shouldn't the fade level be initialized to 1.0 in the Scene class rather than here?
engines/stark/ui/menu/mainmenu.h
Outdated
virtual ~VersionInfoText() {} | ||
|
||
private: | ||
static const int _copyrightSymbol = -87, _posX = 16, _posY = 419; |
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.
_copyrightSymbol
is the ISO-8859-1 code for the copyright symbol. It would be easier to understand what it is as a hexadecimal number (0xA9).
Also please don't put the position on the same line, they are really unrelated.
engines/stark/stark.cpp
Outdated
@@ -247,6 +247,11 @@ void StarkEngine::updateDisplayScene() { | |||
// Clear the screen | |||
_gfx->clearScreen(); | |||
|
|||
// Quit to main menu screen, if needed | |||
if (_userInterface->hasQuitToMainMenuRequest()) { |
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.
This check feels like it does not belong here. Couldn't it be in StarkEngine::mainLoop
with the quit check and the location change check?
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 comment
The 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 comment
The 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 comment
The 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 RenderEntryArray
outside of the loop may prevent Return Value Optimization.
@bgK If there's nothing left I think we can do the merge. |
Thanks! |
Implement the version info text (#1439) and the Book of Secrets in the main menu.