Skip to content

Commit

Permalink
TSAGE: Synchronise UI fields in savegames so it is correctly shown wh…
Browse files Browse the repository at this point in the history
…en restoring
  • Loading branch information
dreammaster committed Sep 13, 2011
1 parent dd75ebd commit e20647e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
33 changes: 33 additions & 0 deletions engines/tsage/blue_force/blueforce_ui.cpp
Expand Up @@ -264,6 +264,34 @@ void UICollection::draw() {

UIElements::UIElements(): UICollection() {
_cursorVisage.setVisage(1, 5);
_saver->addLoadNotifier(&UIElements::loadNotifierProc);
}

void UIElements::synchronize(Serializer &s) {
UICollection::synchronize(s);

s.syncAsSint16LE(_slotStart);
s.syncAsSint16LE(_scoreValue);
s.syncAsByte(_active);

int count = _itemList.size();
s.syncAsSint16LE(count);
if (s.isLoading()) {
// Load in item list
_itemList.clear();

for (int idx = 0; idx < count; ++idx) {
int itemId;
s.syncAsSint16LE(itemId);
_itemList.push_back(itemId);
}
} else {
// Save item list
for (int idx = 0; idx < count; ++idx) {
int itemId = _itemList[idx];
s.syncAsSint16LE(itemId);
}
}
}

void UIElements::process(Event &event) {
Expand Down Expand Up @@ -471,6 +499,11 @@ void UIElements::scrollInventory(bool isLeft) {
updateInventory();
}

void UIElements::loadNotifierProc(bool postFlag) {
if (postFlag && BF_GLOBALS._uiElements._active)
BF_GLOBALS._uiElements.show();
}

} // End of namespace BlueForce

} // End of namespace TsAGE
4 changes: 4 additions & 0 deletions engines/tsage/blue_force/blueforce_ui.h
Expand Up @@ -136,13 +136,17 @@ class UIElements: public UICollection {
Visage _cursorVisage;

UIElements();
virtual Common::String getClassName() { return "UIElements"; }
virtual void synchronize(Serializer &s);
virtual void postInit(SceneObjectList *OwnerList = NULL) { error("Wrong init() called"); }
virtual void process(Event &event);

void setup(const Common::Point &pt);
void updateInventory();
void addScore(int amount);
void scrollInventory(bool isLeft);

static void loadNotifierProc(bool postFlag);
};

} // End of namespace BlueForce
Expand Down
6 changes: 5 additions & 1 deletion engines/tsage/core.cpp
Expand Up @@ -1423,8 +1423,12 @@ void ScenePalette::changeBackground(const Rect &bounds, FadeMode fadeMode) {
}
}

Rect tempRect = bounds;
if (_vm->getGameID() == GType_BlueForce)
tempRect.setHeight(BF_GLOBALS._interfaceY);

_globals->_screenSurface.copyFrom(_globals->_sceneManager._scene->_backSurface,
bounds, Rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT), NULL);
tempRect, Rect(0, 0, tempRect.width(), tempRect.height()), NULL);

for (SynchronizedList<PaletteModifier *>::iterator i = tempPalette._listeners.begin(); i != tempPalette._listeners.end(); ++i)
delete *i;
Expand Down
2 changes: 1 addition & 1 deletion engines/tsage/globals.cpp
Expand Up @@ -224,7 +224,7 @@ void BlueForceGlobals::reset() {
_driveFromScene = 300;
_driveToScene = 0;

_interfaceY = 0;
_interfaceY = BF_INTERFACE_Y;
_v51C44 = 1;
_dayNumber = 0;
_v4CEA4 = 0;
Expand Down

0 comments on commit e20647e

Please sign in to comment.