Skip to content

Commit

Permalink
TSAGE: Combined the resource files into a single generic overall Reso…
Browse files Browse the repository at this point in the history
…urceManager
  • Loading branch information
dreammaster committed Apr 25, 2011
1 parent de5ec74 commit 1d58cca
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 60 deletions.
8 changes: 4 additions & 4 deletions engines/tsage/converse.cpp
Expand Up @@ -304,7 +304,7 @@ void SequenceManager::attached(EventHandler *newOwner, EventHandler *fmt, va_lis
// Get the sequence number to use
_resNum = va_arg(va, int);

byte *seqData = _vm->_dataManager->getResource(RES_SEQUENCE, _resNum, 0);
byte *seqData = _resourceManager->getResource(RES_SEQUENCE, _resNum, 0);
uint seqSize = _vm->_memoryManager.getSize(seqData);

_sequenceData.resize(seqSize);
Expand Down Expand Up @@ -340,7 +340,7 @@ void SequenceManager::setMessage(int resNum, int lineNum, int color, const Commo
_sceneText._width = width;

// Get the display message
Common::String msg = _vm->_dataManager->getMessage(resNum, lineNum);
Common::String msg = _resourceManager->getMessage(resNum, lineNum);

// Get the needed rect, and move it to the desired position
Rect textRect;
Expand Down Expand Up @@ -560,7 +560,7 @@ void StripManager::reset() {

void StripManager::load() {
// Get the script
byte *script = _vm->_dataManager->getResource(RES_STRIP, _stripNum, 2);
byte *script = _resourceManager->getResource(RES_STRIP, _stripNum, 2);
uint scriptSize = _vm->_memoryManager.getSize(script);

_script.resize(scriptSize);
Expand All @@ -569,7 +569,7 @@ void StripManager::load() {
DEALLOCATE(script);

// Get the object list
byte *obj44List = _vm->_dataManager->getResource(RES_STRIP, _stripNum, 1);
byte *obj44List = _resourceManager->getResource(RES_STRIP, _stripNum, 1);
int dataSize = _vm->_memoryManager.getSize(obj44List);
assert((dataSize % 0x44) == 0);

Expand Down
26 changes: 13 additions & 13 deletions engines/tsage/core.cpp
Expand Up @@ -51,7 +51,7 @@ InvObject::InvObject(int sceneNumber, int rlbNum, int cursorNum, CursorType curs

// Decode the image for the inventory item to get it's display bounds
uint size;
byte *imgData = _vm->_dataManager->getSubResource(_displayResNum, _rlbNum, _cursorNum, &size);
byte *imgData = _resourceManager->getSubResource(_displayResNum, _rlbNum, _cursorNum, &size);
GfxSurface s = surfaceFromRes(imgData);
_bounds = s.getBounds();

Expand Down Expand Up @@ -1240,7 +1240,7 @@ ScenePalette::ScenePalette(int paletteNum) {
}

bool ScenePalette::loadPalette(int paletteNum) {
byte *palData = _vm->_dataManager->getResource(RES_PALETTE, paletteNum, 0, true);
byte *palData = _resourceManager->getResource(RES_PALETTE, paletteNum, 0, true);
if (!palData)
return false;

Expand Down Expand Up @@ -1481,7 +1481,7 @@ bool SceneItem::contains(const Common::Point &pt) {
}

void SceneItem::display(int resNum, int lineNum, ...) {
Common::String msg = !resNum ? Common::String() : _vm->_dataManager->getMessage(resNum, lineNum);
Common::String msg = !resNum ? Common::String() : _resourceManager->getMessage(resNum, lineNum);

if (_globals->_sceneObjects->contains(&_globals->_sceneText)) {
_globals->_sceneText.remove();
Expand Down Expand Up @@ -2646,7 +2646,7 @@ void Visage::setVisage(int resNum, int rlbNum) {
_resNum = resNum;
_rlbNum = rlbNum;
DEALLOCATE(_data);
_data = _vm->_dataManager->getResource(RES_VISAGE, resNum, rlbNum);
_data = _resourceManager->getResource(RES_VISAGE, resNum, rlbNum);
assert(_data);
}
}
Expand Down Expand Up @@ -2736,7 +2736,7 @@ void Player::synchronise(Serialiser &s) {
Region::Region(int resNum, int rlbNum, ResourceType ctlType) {
_regionId = rlbNum;

byte *regionData = _vm->_dataManager->getResource(ctlType, resNum, rlbNum);
byte *regionData = _resourceManager->getResource(ctlType, resNum, rlbNum);
assert(regionData);

// Set the region bounds
Expand Down Expand Up @@ -2948,7 +2948,7 @@ void Region::uniteRect(const Rect &rect) {
void SceneRegions::load(int sceneNum) {
clear();

byte *regionData = _vm->_dataManager->getResource(RES_CONTROL, sceneNum, 9999, true);
byte *regionData = _resourceManager->getResource(RES_CONTROL, sceneNum, 9999, true);

if (regionData) {
int regionCount = READ_LE_UINT16(regionData);
Expand Down Expand Up @@ -3212,7 +3212,7 @@ void WalkRegions::load(int sceneNum) {
clear();

_resNum = sceneNum;
byte *regionData = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 1, true);
byte *regionData = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 1, true);
if (!regionData) {
// No data, so return
_resNum = -1;
Expand All @@ -3223,7 +3223,7 @@ void WalkRegions::load(int sceneNum) {
int dataSize;

// Load the field 18 list
dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 2);
dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 2);
dataSize = _vm->_memoryManager.getSize(dataP);
assert(dataSize % 10 == 0);

Expand All @@ -3237,7 +3237,7 @@ void WalkRegions::load(int sceneNum) {
DEALLOCATE(dataP);

// Load the idx list
dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 3);
dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 3);
dataSize = _vm->_memoryManager.getSize(dataP);
assert(dataSize % 2 == 0);

Expand All @@ -3248,7 +3248,7 @@ void WalkRegions::load(int sceneNum) {
DEALLOCATE(dataP);

// Load the secondary idx list
dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 4);
dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 4);
dataSize = _vm->_memoryManager.getSize(dataP);
assert(dataSize % 2 == 0);

Expand All @@ -3259,7 +3259,7 @@ void WalkRegions::load(int sceneNum) {
DEALLOCATE(dataP);

// Handle the loading of the actual regions themselves
dataP = _vm->_dataManager->getResource(RES_WALKRGNS, sceneNum, 5);
dataP = _resourceManager->getResource(RES_WALKRGNS, sceneNum, 5);

byte *pWalkRegion = regionData + 16;
byte *srcP = dataP;
Expand Down Expand Up @@ -3305,7 +3305,7 @@ void ScenePriorities::load(int resNum) {
_resNum = resNum;
clear();

byte *regionData = _vm->_dataManager->getResource(RES_PRIORITY, resNum, 9999, true);
byte *regionData = _resourceManager->getResource(RES_PRIORITY, resNum, 9999, true);

if (regionData) {
int regionCount = READ_LE_UINT16(regionData);
Expand Down Expand Up @@ -3719,7 +3719,7 @@ void Game::restart() {

void Game::endGame(int resNum, int lineNum) {
_globals->_events.setCursor(CURSOR_WALK);
Common::String msg = _vm->_dataManager->getMessage(resNum, lineNum);
Common::String msg = _resourceManager->getMessage(resNum, lineNum);
bool savesExist = _saver->savegamesExist();

if (!savesExist) {
Expand Down
2 changes: 1 addition & 1 deletion engines/tsage/dialogs.cpp
Expand Up @@ -139,7 +139,7 @@ void RightClickButton::highlight() {
_savedButton = Surface_getArea(_globals->gfxManager().getSurface(), _bounds);

uint size;
byte *imgData = _vm->_dataManager->getSubResource(7, 2, _buttonIndex, &size);
byte *imgData = _resourceManager->getSubResource(7, 2, _buttonIndex, &size);

GfxSurface btnSelected = surfaceFromRes(imgData);
_globals->gfxManager().copyFrom(btnSelected, _bounds.left, _bounds.top);
Expand Down
8 changes: 4 additions & 4 deletions engines/tsage/events.cpp
Expand Up @@ -159,25 +159,25 @@ void EventsClass::setCursor(CursorType cursorType) {
switch (cursorType) {
case CURSOR_CROSSHAIRS:
// Crosshairs cursor
cursor = _vm->_dataManager->getSubResource(4, 1, 6, &size);
cursor = _resourceManager->getSubResource(4, 1, 6, &size);
_globals->setFlag(122);
break;

case CURSOR_LOOK:
// Look cursor
cursor = _vm->_dataManager->getSubResource(4, 1, 5, &size);
cursor = _resourceManager->getSubResource(4, 1, 5, &size);
_currentCursor = CURSOR_LOOK;
break;

case CURSOR_USE:
// Use cursor
cursor = _vm->_dataManager->getSubResource(4, 1, 4, &size);
cursor = _resourceManager->getSubResource(4, 1, 4, &size);
_currentCursor = CURSOR_USE;
break;

case CURSOR_TALK:
// Talk cursor
cursor = _vm->_dataManager->getSubResource(4, 1, 3, &size);
cursor = _resourceManager->getSubResource(4, 1, 3, &size);
_currentCursor = CURSOR_TALK;
break;

Expand Down
2 changes: 2 additions & 0 deletions engines/tsage/globals.cpp
Expand Up @@ -24,10 +24,12 @@
*/

#include "tsage/globals.h"
#include "tsage/tsage.h"

namespace tSage {

Globals *_globals = NULL;
ResourceManager *_resourceManager = NULL;

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

Expand Down
4 changes: 4 additions & 0 deletions engines/tsage/globals.h
Expand Up @@ -95,6 +95,10 @@ class Globals : public SavedObject {

extern Globals *_globals;

// Note: Currently this can't be part of the _globals structure, since it needs to be constructed
// prior to many of the fields in Globals execute their constructors
extern ResourceManager *_resourceManager;

} // End of namespace tSage

#endif
12 changes: 6 additions & 6 deletions engines/tsage/graphics.cpp
Expand Up @@ -122,7 +122,7 @@ GfxSurface surfaceFromRes(const byte *imgData) {

GfxSurface surfaceFromRes(int resNum, int rlbNum, int subNum) {
uint size;
byte *imgData = _vm->_dataManager->getSubResource(resNum, rlbNum, subNum, &size);
byte *imgData = _resourceManager->getSubResource(resNum, rlbNum, subNum, &size);
GfxSurface surface = surfaceFromRes(imgData);
DEALLOCATE(imgData);

Expand Down Expand Up @@ -390,7 +390,7 @@ void GfxSurface::loadScreenSection(Graphics::Surface &dest, int xHalf, int yHalf

if (xSection < xHalfCount && ySection < yHalfCount) {
int rlbNum = xSection * yHalfCount + ySection;
byte *data = _vm->_dataManager->getResource(RES_BITMAP, screenNum, rlbNum);
byte *data = _resourceManager->getResource(RES_BITMAP, screenNum, rlbNum);

for (int y = 0; y < updateRect.height(); ++y) {
byte *pSrc = data + y * 160;
Expand Down Expand Up @@ -713,7 +713,7 @@ void GfxImage::setDefaults() {

// Decode the image
uint size;
byte *imgData = _vm->_dataManager->getSubResource(_resNum, _rlbNum, _cursorNum, &size);
byte *imgData = _resourceManager->getSubResource(_resNum, _rlbNum, _cursorNum, &size);
_surface = surfaceFromRes(imgData);
DEALLOCATE(imgData);

Expand Down Expand Up @@ -1074,7 +1074,7 @@ void GfxManager::setDialogPalette() {
// Get the main palette information
byte palData[256 * 3];
uint count, start;
_vm->_dataManager->getPalette(0, &palData[0], &start, &count);
_resourceManager->getPalette(0, &palData[0], &start, &count);
g_system->getPaletteManager()->setPalette(&palData[0], start, count);

// Miscellaneous
Expand Down Expand Up @@ -1133,9 +1133,9 @@ void GfxFont::setFontNumber(uint32 fontNumber) {

_fontNumber = fontNumber;

_fontData = _vm->_tSageManager->getResource(RES_FONT, _fontNumber, 0, true);
_fontData = _resourceManager->getResource(RES_FONT, _fontNumber, 0, true);
if (!_fontData)
_fontData = _vm->_dataManager->getResource(RES_FONT, _fontNumber, 0);
_fontData = _resourceManager->getResource(RES_FONT, _fontNumber, 0);

_numChars = READ_LE_UINT16(_fontData + 4);
_fontSize.y = READ_LE_UINT16(_fontData + 6);
Expand Down

0 comments on commit 1d58cca

Please sign in to comment.