STARK: Enable onScreenChanged() in Cursor and GameWindow

This commit is contained in:
Douglas Liu 2018-06-27 21:28:06 +08:00
parent 92184a1899
commit a14744117b
6 changed files with 43 additions and 0 deletions

View File

@ -194,10 +194,16 @@ bool RenderEntry::intersectRay(const Math::Ray &ray) const {
}
VisualImageXMG *RenderEntry::getImage() const {
if (!_visual) {
return nullptr;
}
return _visual->get<VisualImageXMG>();
}
VisualText *RenderEntry::getText() const {
if (!_visual) {
return nullptr;
}
return _visual->get<VisualText>();
}

View File

@ -76,6 +76,12 @@ void Cursor::setFading(bool fading) {
_fading = fading;
}
void Cursor::onScreenChanged() {
if (_mouseText) {
_mouseText->resetTexture();
}
}
void Cursor::updateFadeLevel() {
if (_fading) {
if (_fadeLevelIncreasing) {

View File

@ -52,6 +52,9 @@ public:
/** Make cycle the cursor's brightness */
void setFading(bool fading);
/** Update when the screen resolution has changed */
void onScreenChanged();
Common::Point getMousePosition(bool unscaled = false) const;
enum CursorType {

View File

@ -122,8 +122,10 @@ void GameScreen::dispatchEvent(WindowHandler handler) {
}
void GameScreen::onScreenChanged() {
_cursor->onScreenChanged();
_dialogPanel->onScreenChanged();
_topMenu->onScreenChanged();
_gameWindow->onScreenChanged();
}
void GameScreen::notifyInventoryItemEnabled(uint16 itemIndex) {

View File

@ -41,6 +41,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 +240,25 @@ void GameWindow::reset() {
_objectRelativePosition.y = 0;
}
void GameWindow::onScreenChanged() {
// May be called when resources have not been loaded
if (!StarkGlobal->getCurrent()) {
return;
}
Resources::Location *location = StarkGlobal->getCurrent()->getLocation();
_renderEntries = location->listRenderEntries();
VisualText *text = nullptr;
Gfx::RenderEntryArray::iterator element = _renderEntries.begin();
while (element != _renderEntries.end()) {
text = (*element)->getText();
if (text) {
text->resetTexture();
}
element++;
}
}
} // End of namespace Stark

View File

@ -45,6 +45,9 @@ public:
/** Clear the location dependent state */
void reset();
/** Update when the screen resolution has changed */
void onScreenChanged();
protected:
void onMouseMove(const Common::Point &pos) override;
void onClick(const Common::Point &pos) override;