Conversation
What happens is indeed related to how the engine loads its resources. Resources can be loaded from two kinds of resource trees. The residualvm/engines/stark/stark.cpp Line 154 in c1284ad
The call to
What a great occasion to make yourself familiar with the interactive rebase feature of git. You should be able to rebase your branch on top of master and remove the unwanted commits with it. Read some documentation about it to understand it. But the gist is to run |
de2e9f6
to
57c5f99
Compare
I have rebased my branches to clean up the mess I left before now. Thanks for the help 😄 Right now the game shall open with the main menu. But now there is another major problem: For some reason, all buttons on the main menu separate the clicking area and the helping text. Due to this reason, the original There is another small problem: there are two special widgets on the main menu: "VERSION INFO" and "VERSION INFO REALLY". Strange names and the current version renders them differently compared to the steam version, as below: Seems like those texts are generated by other things. Not sure about this. |
Seems like the buttons use an empty
Yes, this is a special case that should be handled in the main menu code. |
The I'll add the version information issue into the project and tackle it later. |
engines/stark/visual/text.cpp
Outdated
@@ -144,4 +159,13 @@ void VisualText::resetTexture() { | |||
createTexture(); | |||
} | |||
|
|||
bool VisualText::isBlank() { | |||
for (auto c : _text) { | |||
if (c != ' ' && c != '\r' && c != '\n' && c != '\t') { |
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.
You can use isSpace
from util.h
instead.
engines/stark/visual/text.cpp
Outdated
@@ -144,4 +159,13 @@ void VisualText::resetTexture() { | |||
createTexture(); | |||
} | |||
|
|||
bool VisualText::isBlank() { | |||
for (auto c : _text) { |
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.
We can't use c++11 features yet. That means no foreach and no auto :(
ResidualVM follows the same rules as ScummVM, and we don't do c++11 there either. This is mostly because the CI server has not yet been updated with c++11 compatible compilers for all platforms.
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.
I see that the override
specifier is used heavily so I thought c++11 is available. Looks like the c++11-compat.h redefines it. Neat.
engines/stark/visual/text.h
Outdated
@@ -62,6 +63,9 @@ class VisualText : public Visual { | |||
void createTexture(); | |||
void freeTexture(); | |||
|
|||
// Check whether the text is blank |
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 use Doxygen style comments when documenting methods/classes (so they appear in http://doxygen.residualvm.org/).
engines/stark/ui/menu/mainmenu.cpp
Outdated
"NewGame", | ||
nullptr, | ||
nullptr)); | ||
_widgets.back()->setupSounds(0, 1); |
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 fix the whitespaces here. We use tabs for indentation and spaces for alignment (see http://wiki.scummvm.org/index.php/Code_Formatting_Conventions).
engines/stark/visual/text.cpp
Outdated
_originalRect.right = _originalRect.left + maxScaledLineWidth; | ||
_originalRect.bottom = _originalRect.top + StarkGfx->scaleHeightOriginalToCurrent(_targetHeight); | ||
_originalRect.right = _originalRect.left + _targetWidth; | ||
_originalRect.bottom = _originalRect.top + _targetHeight; |
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 previous implementation is wrong. The width and height should not be scaled according to the resolution since the testing of the bounding box is based on original resolution.
This is working quite well now 👍 |
@@ -67,9 +69,14 @@ UserInterface::~UserInterface() { | |||
void UserInterface::init() { | |||
_cursor = new Cursor(_gfx); | |||
|
|||
_currentScreen = _gameScreen = new GameScreen(_gfx, _cursor); | |||
_mainMenuScreen = new MainMenuScreen(_gfx, _cursor); |
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.
_mainMenuScreen
is never freed (memory leak).
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.
Fixed.
@@ -0,0 +1,111 @@ | |||
#include "engines/stark/ui/menu/mainmenu.h" |
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 include the standard ResidualVM licence header for new files.
engines/stark/services/services.h
Outdated
@@ -97,7 +97,7 @@ class StarkServices : public Common::Singleton<StarkServices> { | |||
#define StarkGameInterface StarkServices::instance().gameInterface | |||
#define StarkUserInterface StarkServices::instance().userInterface | |||
#define StarkFontProvider StarkServices::instance().fontProvider | |||
#define StarkGameDescription StarkServices::instance().gameDescription | |||
#define StarkGameDescription StarkServices::instance().gameDescription |
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.
Add this field so that MainMenuScreen
may check the game version.
@@ -180,6 +180,9 @@ void StaticLocationWidget::onClick() { | |||
_soundMouseClick->play(); | |||
} | |||
|
|||
// Ensure the click sound is played completely | |||
while (_soundMouseClick->isPlaying()) {}; | |||
|
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.
Based on the original game (steam version here), the click sound is completely played before the action is executed. Although using while
loop here will freeze the game, that will also happen in the original game, so this should be enough "original...ish".
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.
Wait the pointer needs to be checked beforehand.
I am planning to implement the Quit and Credits, but I am not sure how to find out their corresponding resources. For Credits I need to load the credits fmv but right now I have no idea how to find the name. As for Quit, according to the original game (steam version), when the user hits the button, there will be a message box coming up to let user chooses "yes" or "no" with either mouse or keyboard, no idea how to find those resources. I can't screenshot the message box since the steam version has problems rendering it properly. @bgK Maybe we can discuss on email if the solution is a bit complex. |
I don't have enough time to write a full answer right now. The credits video is There are a few other confirmation dialog boxes. I believe those are actually skinned Windows dialogs. We'll have to come up with a replacement solution. Perhaps we could use ResidualVM GUI dialogs. |
engines/stark/ui/menu/mainmenu.cpp
Outdated
@@ -132,6 +132,12 @@ void MainMenuScreen::helpTextHandler(StaticLocationWidget &widget, const Common: | |||
} | |||
} | |||
|
|||
void MainMenuScreen::creditsHandler() { | |||
if (!isDemo()) { | |||
StarkUserInterface->requestFMVPlayback("0e02.bbb"); |
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.
There is no 0e02.bbb in the demo game data. So demo has no credits video or with a different name?
One small |
@@ -171,6 +178,8 @@ void StaticLocationWidget::onClick() { | |||
|
|||
if (_soundMouseClick) { | |||
_soundMouseClick->play(); | |||
// Ensure the click sound is played completely | |||
while (_soundMouseClick->isPlaying()) {}; |
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.
It's not good to busy-wait for something to complete. The game appears unresponsive while waiting and the CPU is used at 100%.
In game engine design it's best to have a single game loop that roughly checks for user input, updates the simulated world and then renders. So far, Stark has managed to follow that rule. So here, we'll need to find another solution to let the sound fully play. Perhaps something is stopping the sound, preventing it from completing while it should not. Perhaps this code needs to wait for the sound to complete by checking each frame if it is finished.
f69be9f
to
992ea67
Compare
Commits are discarded. |
88d997c
to
f3886fb
Compare
You're right, this is quite a mess. Maybe it's better to just synchronously wait. But in that case there should at least be a delay in the loop body to keep the CPU usage down. |
f3886fb
to
7a6a8fd
Compare
_diaryIndexScreen->onScreenChanged(); | ||
|
||
if (!isInGameScreen()) { | ||
_currentScreen->onScreenChanged(); |
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.
There will be more Screen
added to UserInterface
later. Since StaticLocationScreen
will release all the resources when it is closed, there is no need to notify the change of screen resolution for a not currently displayed screen.
One problem: even though now the game will "quit" to the main menu, if choose to start the game again, the game will just go back to the previous state, not start a completely new one. Is there a way to reset the whole |
31cb6e1
to
90c0bd1
Compare
A rebasing has been done to sync with the master. |
92a1544
to
1ecb316
Compare
engines/stark/stark.cpp
Outdated
if (ConfMan.hasKey("save_slot")) { | ||
// Load game from specified slot, if any | ||
_resourceProvider->initGlobal(); |
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.
Those two calls are redundant now. loadGameState
already calls them.
This pull request is corresponding to the task of implementing the main menu in TLJ.
The first attempt I just did some simple things.
I move
onScreenChanged()
to theStaticLocationScreen
since I think all of the menus will need to resize text.Now I just make a simple
MainMenuScreen
class with nothing in it and let the game load it when it starts, so that I can use the debug mode to dump the resources. But now there is a major problem. When I do this, an assertion failed in resourcereference.cpp, line 61, as belowI printed out those values. Most of the time both of them are zeros but at a point
element.getIndex()
becomes 69.I guess this is related to how TLG loads its resources and now I am still not very clear about it.
FYI, I add the line
_currentScreen->open()
inUserInterface::init()
, which I think is necessary. The reason why it wasn't there before, I guess, is that the game will trigger a video to play when it starts, which triggers thechangeScreen()
and therefore trigger theopen()
.I made some stupid things in sync my branch and a typo in the name of commits. Hope it is fine.