Skip to content

Commit

Permalink
TSAGE: Further work on standardising user interface for use in Blue F…
Browse files Browse the repository at this point in the history
…orce and Return to Ringworld
  • Loading branch information
dreammaster committed Oct 24, 2011
1 parent 364bc27 commit 8b66b16
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion engines/tsage/core.cpp
Expand Up @@ -71,7 +71,7 @@ InvObject::InvObject(int strip, int frame) {
_strip = strip;
_frame = frame;

_visage = 0;
_visage = 7;
_sceneNumber = 0;
_iconResNum = 10;
}
Expand Down
13 changes: 10 additions & 3 deletions engines/tsage/globals.cpp
Expand Up @@ -205,6 +205,12 @@ void TsAGE2Globals::reset() {
T2_GLOBALS._uiElements._active = false;
}

void TsAGE2Globals::synchronize(Serializer &s) {
Globals::synchronize(s);

s.syncAsSint16LE(_interfaceY);
}

/*--------------------------------------------------------------------------*/

namespace BlueForce {
Expand All @@ -213,7 +219,7 @@ BlueForceGlobals::BlueForceGlobals(): TsAGE2Globals() {
}

void BlueForceGlobals::synchronize(Serializer &s) {
Globals::synchronize(s);
TsAGE2Globals::synchronize(s);

s.syncAsSint16LE(_dayNumber);
s.syncAsSint16LE(_v4CEA4);
Expand Down Expand Up @@ -252,7 +258,6 @@ void BlueForceGlobals::synchronize(Serializer &s) {
s.syncAsSint16LE(_v50CC8);
s.syncAsSint16LE(_v51C42);
s.syncAsSint16LE(_v51C44);
s.syncAsSint16LE(_interfaceY);
s.syncAsSint16LE(_bookmark);
s.syncAsSint16LE(_mapLocationId);
s.syncAsSint16LE(_clip1Bullets);
Expand Down Expand Up @@ -361,7 +366,9 @@ void Ringworld2Globals::reset() {
T2_GLOBALS._uiElements._active = false;
}


void Ringworld2Globals::synchronize(Serializer &s) {
TsAGE2Globals::synchronize(s);
}

} // end of namespace Ringworld2

Expand Down
7 changes: 5 additions & 2 deletions engines/tsage/globals.h
Expand Up @@ -108,9 +108,11 @@ class TsAGE2Globals: public Globals {
UIElements _uiElements;
SelectItemProc _onSelectItem;
int _interfaceY;
ASoundExt _inventorySound;

TsAGE2Globals() { _onSelectItem = NULL; }
virtual void reset();
virtual void synchronize(Serializer &s);
};

extern Globals *g_globals;
Expand Down Expand Up @@ -182,7 +184,7 @@ enum Flag {

class BlueForceGlobals: public TsAGE2Globals {
public:
ASoundExt _sound1, _sound2, _sound3;
ASoundExt _sound1, _sound3;
StripProxy _stripProxy;
int _dayNumber;
int _v4CEA4;
Expand Down Expand Up @@ -228,8 +230,8 @@ class BlueForceGlobals: public TsAGE2Globals {
bool getHasBullets();

virtual Common::String getClassName() { return "BFGlobals"; }
virtual void synchronize(Serializer &s);
virtual void reset();
virtual void synchronize(Serializer &s);
void set2Flags(int flagNum);
bool removeFlag(int flagNum);
};
Expand All @@ -243,6 +245,7 @@ class Ringworld2Globals: public TsAGE2Globals {
ASoundExt _sound1, _sound2, _sound3, _sound4;

virtual void reset();
virtual void synchronize(Serializer &s);
};

} // End of namespace Ringworld2
Expand Down
33 changes: 17 additions & 16 deletions engines/tsage/user_interface.cpp
Expand Up @@ -25,6 +25,7 @@
#include "tsage/tsage.h"
#include "tsage/blue_force/blueforce_dialogs.h"
#include "tsage/blue_force/blueforce_logic.h"
#include "tsage/ringworld2/ringworld2_logic.h"

namespace TsAGE {

Expand Down Expand Up @@ -96,16 +97,16 @@ void UIQuestion::showItem(int resNum, int rlbNum, int frameNum) {
imgRect.center(SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2);

// Save the area behind where the image will be displayed
GfxSurface *savedArea = Surface_getArea(BF_GLOBALS.gfxManager().getSurface(), imgRect);
GfxSurface *savedArea = Surface_getArea(GLOBALS.gfxManager().getSurface(), imgRect);

// Draw the image
BF_GLOBALS.gfxManager().copyFrom(objImage, imgRect);
GLOBALS.gfxManager().copyFrom(objImage, imgRect);

// Wait for a press
BF_GLOBALS._events.waitForPress();
GLOBALS._events.waitForPress();

// Restore the old area
BF_GLOBALS.gfxManager().copyFrom(*savedArea, imgRect);
GLOBALS.gfxManager().copyFrom(*savedArea, imgRect);
delete savedArea;
}

Expand Down Expand Up @@ -232,8 +233,8 @@ void UICollection::show() {
void UICollection::erase() {
if (_clearScreen) {
Rect tempRect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT);
BF_GLOBALS._screenSurface.fillRect(tempRect, 0);
BF_GLOBALS._sceneManager._scene->_backSurface.fillRect(tempRect, 0);
GLOBALS._screenSurface.fillRect(tempRect, 0);
GLOBALS._sceneManager._scene->_backSurface.fillRect(tempRect, 0);
_clearScreen = false;
}
}
Expand All @@ -253,7 +254,7 @@ void UICollection::draw() {
_objList[idx]->draw();

// Draw the resulting UI onto the screen
BF_GLOBALS._screenSurface.copyFrom(BF_GLOBALS._sceneManager._scene->_backSurface,
GLOBALS._screenSurface.copyFrom(GLOBALS._sceneManager._scene->_backSurface,
Rect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT),
Rect(0, UI_INTERFACE_Y, SCREEN_WIDTH, SCREEN_HEIGHT));

Expand Down Expand Up @@ -301,16 +302,16 @@ void UIElements::synchronize(Serializer &s) {
}

void UIElements::process(Event &event) {
if (_clearScreen && BF_GLOBALS._player._enabled && (BF_GLOBALS._sceneManager._sceneNumber != 50)) {
if (_clearScreen && GLOBALS._player._enabled && (GLOBALS._sceneManager._sceneNumber != 50)) {
if (_bounds.contains(event.mousePos)) {
// Cursor inside UI area
if (!_cursorChanged) {
if (BF_GLOBALS._events.isInventoryIcon()) {
if (GLOBALS._events.isInventoryIcon()) {
// Inventory icon being displayed, so leave alone
} else {
// Change to the inventory use cursor
GfxSurface surface = _cursorVisage.getFrame(6);
BF_GLOBALS._events.setCursor(surface);
GLOBALS._events.setCursor(surface);
}
_cursorChanged = true;
}
Expand All @@ -329,13 +330,13 @@ void UIElements::process(Event &event) {

} else if (_cursorChanged) {
// Cursor outside UI area, so reset as necessary
BF_GLOBALS._events.setCursor(BF_GLOBALS._events.getCursor());
GLOBALS._events.setCursor(GLOBALS._events.getCursor());
_cursorChanged = false;
/*
SceneExt *scene = (SceneExt *)BF_GLOBALS._sceneManager._scene;
SceneExt *scene = (SceneExt *)GLOBALS._sceneManager._scene;
if (scene->_focusObject) {
GfxSurface surface = _cursorVisage.getFrame(7);
BF_GLOBALS._events.setCursor(surface);
GLOBALS._events.setCursor(surface);
}
*/
}
Expand Down Expand Up @@ -459,7 +460,7 @@ void UIElements::updateInventory() {
// Loop through the inventory objects
SynchronizedList<InvObject *>::iterator i;
int objIndex = 0;
for (i = BF_INVENTORY._itemList.begin(); i != BF_INVENTORY._itemList.end(); ++i, ++objIndex) {
for (i = GLOBALS._inventory->_itemList.begin(); i != GLOBALS._inventory->_itemList.end(); ++i, ++objIndex) {
InvObject *obj = *i;

// Check whether the object is in any of the four inventory slots
Expand Down Expand Up @@ -493,7 +494,7 @@ void UIElements::updateInvList() {

SynchronizedList<InvObject *>::iterator i;
int itemIndex = 0;
for (i = BF_GLOBALS._inventory->_itemList.begin(); i != BF_GLOBALS._inventory->_itemList.end(); ++i, ++itemIndex) {
for (i = GLOBALS._inventory->_itemList.begin(); i != GLOBALS._inventory->_itemList.end(); ++i, ++itemIndex) {
InvObject *invObject = *i;
if (invObject->inInventory())
_itemList.push_back(itemIndex);
Expand All @@ -505,7 +506,7 @@ void UIElements::updateInvList() {
*/
void UIElements::addScore(int amount) {
_scoreValue += amount;
BF_GLOBALS._sound2.play(0);
T2_GLOBALS._inventorySound.play(0);
updateInventory();
}

Expand Down

0 comments on commit 8b66b16

Please sign in to comment.