aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/xeen/events.h2
-rw-r--r--engines/xeen/sprites.cpp69
-rw-r--r--engines/xeen/sprites.h44
-rw-r--r--engines/xeen/xeen.cpp31
-rw-r--r--engines/xeen/xeen.h7
5 files changed, 72 insertions, 81 deletions
diff --git a/engines/xeen/events.h b/engines/xeen/events.h
index 5a9faf14d8..7a6a65f4fb 100644
--- a/engines/xeen/events.h
+++ b/engines/xeen/events.h
@@ -41,7 +41,7 @@ private:
uint32 _gameCounter;
uint32 _priorGameCounterTime;
Common::KeyCode _keyCode;
- FramesResource _sprites;
+ SpriteResource _sprites;
void nextFrame();
public:
diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp
index 1b18e98dfd..9485bd28b8 100644
--- a/engines/xeen/sprites.cpp
+++ b/engines/xeen/sprites.cpp
@@ -29,26 +29,46 @@
namespace Xeen {
-GraphicResource::GraphicResource(const Common::String &filename) {
+SpriteResource::SpriteResource() {
+ _filesize = 0;
+ _data = nullptr;
+}
+
+SpriteResource::SpriteResource(const Common::String &filename) {
+ _data = nullptr;
+ load(filename);
+}
+
+void SpriteResource::load(const Common::String &filename) {
// Open the resource
File f(filename);
// Read in a copy of the file
_filesize = f.size();
+ delete[] _data;
_data = new byte[_filesize];
- f.seek(0);
f.read(_data, _filesize);
+
+ // Read in the index
+ f.seek(0);
+ int count = f.readUint16LE();
+ _index.resize(count);
+
+ for (int i = 0; i < count; ++i) {
+ _index[i]._offset1 = f.readUint16LE();
+ _index[i]._offset2 = f.readUint16LE();
+ }
}
-GraphicResource::~GraphicResource() {
+SpriteResource::~SpriteResource() {
delete[] _data;
}
-int GraphicResource::size() const {
- return READ_LE_UINT16(_data);
+int SpriteResource::size() const {
+ return _index.size();
}
-void GraphicResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const {
+void SpriteResource::drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const {
// Get cell header
Common::MemoryReadStream f(_data, _filesize);
f.seek(offset);
@@ -151,43 +171,6 @@ void GraphicResource::drawOffset(XSurface &dest, uint16 offset, const Common::Po
destPos.x + xOffset + width, destPos.y + yOffset + height));
}
-/*------------------------------------------------------------------------*/
-
-FramesResource::FramesResource(const Common::String &filename) :
- GraphicResource(filename) {
- // Read in the index
- Common::MemoryReadStream f(_data, _filesize);
- int count = f.readUint16LE();
- _index.resize(count);
-
- for (int i = 0; i < count; ++i) {
- _index[i] = f.readUint32LE();
- }
-}
-
-void FramesResource::draw(XSurface &dest, int frame, const Common::Point &destPos) const {
- drawOffset(dest, _index[frame], destPos);
-}
-
-void FramesResource::draw(XSurface &dest, int frame) const {
- draw(dest, frame, Common::Point());
-}
-
-/*------------------------------------------------------------------------*/
-
-SpriteResource::SpriteResource(const Common::String &filename) :
- GraphicResource(filename) {
- // Read in the index
- Common::MemoryReadStream f(_data, _filesize);
- int count = f.readUint16LE();
- _index.resize(count);
-
- for (int i = 0; i < count; ++i) {
- _index[i]._offset1 = f.readUint16LE();
- _index[i]._offset2 = f.readUint16LE();
- }
-}
-
void SpriteResource::draw(XSurface &dest, int frame, const Common::Point &destPos) const {
drawOffset(dest, _index[frame]._offset1, destPos);
if (_index[frame]._offset2)
diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h
index 6c01a9ff82..8613d90b29 100644
--- a/engines/xeen/sprites.h
+++ b/engines/xeen/sprites.h
@@ -33,53 +33,29 @@ namespace Xeen {
class XeenEngine;
-class GraphicResource {
-protected:
- int32 _filesize;
- byte *_data;
-
- void drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const;
-public:
- GraphicResource(const Common::String &filename);
-
- virtual ~GraphicResource();
-
- int size() const;
-};
-
-/**
- * Defines a resource that Contains a list of singular sprite frames
- */
-class FramesResource : public GraphicResource {
-private:
- Common::Array<uint32> _index;
-public:
- FramesResource(const Common::String &filename);
- virtual ~FramesResource() {}
-
- void draw(XSurface &dest, int frame, const Common::Point &destPos) const;
-
- void draw(XSurface &dest, int frame) const;
-};
-
-/**
- * Defines a resource that contains sets of two layered sprites per frame
- */
-class SpriteResource : public GraphicResource {
+class SpriteResource {
private:
struct IndexEntry {
uint16 _offset1, _offset2;
};
Common::Array<IndexEntry> _index;
+ int32 _filesize;
+ byte *_data;
+ void drawOffset(XSurface &dest, uint16 offset, const Common::Point &destPos) const;
public:
+ SpriteResource();
SpriteResource(const Common::String &filename);
- virtual ~SpriteResource() {}
+ virtual ~SpriteResource();
+
+ void load(const Common::String &filename);
void draw(XSurface &dest, int frame, const Common::Point &destPos) const;
void draw(XSurface &dest, int frame) const;
+
+ int size() const;
};
} // End of namespace Xeen
diff --git a/engines/xeen/xeen.cpp b/engines/xeen/xeen.cpp
index dfa05b0aa1..f2bbbe0517 100644
--- a/engines/xeen/xeen.cpp
+++ b/engines/xeen/xeen.cpp
@@ -42,7 +42,10 @@ XeenEngine::XeenEngine(OSystem *syst, const XeenGameDescription *gameDesc)
_sound = nullptr;
_eventData = nullptr;
Common::fill(&_activeRoster[0], &_activeRoster[MAX_ACTIVE_PARTY], nullptr);
+ Common::fill(&_partyFaces[0], &_partyFaces[MAX_ACTIVE_PARTY], nullptr);
+
_isEarlyGame = false;
+
}
XeenEngine::~XeenEngine() {
@@ -243,14 +246,14 @@ void XeenEngine::showMainMenu() {
void XeenEngine::playGame() {
_saves->reset();
- drawUI();
+ drawUI(true);
}
/*
* Lots of stuff in this method.
* TODO: Consider renaming method when better understood
*/
-void XeenEngine::drawUI() {
+void XeenEngine::drawUI(bool soundPlayed) {
SpriteResource sprites1("global.icn"), borderSprites("border.icn");
// Get mappings to the active characters in the party
@@ -260,6 +263,30 @@ void XeenEngine::drawUI() {
}
_isEarlyGame = _party._minutes >= 300;
+
+ if (_party._mazeId == 0) {
+ if (!soundPlayed) {
+ warning("TODO: loadSound?");
+ }
+
+ if (!_partyFaces[0]) {
+ // Xeen only uses 24 of possible 30 character slots
+ loadCharIcons(24);
+
+ for (int i = 0; i < _party._partyCount; ++i)
+ _partyFaces[i] = &_charFaces[_party._partyMembers[i]];
+ }
+ }
+}
+
+void XeenEngine::loadCharIcons(int numChars) {
+ for (int i = 0; i < numChars; ++i) {
+ // Load new character resource
+ Common::String name = Common::String::format("char%02d.fac", i);
+ _charFaces[i].load(name);
+ }
+
+ _dseFace.load("dse.fac");
}
} // End of namespace Xeen
diff --git a/engines/xeen/xeen.h b/engines/xeen/xeen.h
index 787cc3d435..7155e39483 100644
--- a/engines/xeen/xeen.h
+++ b/engines/xeen/xeen.h
@@ -81,12 +81,17 @@ private:
Common::RandomSource _randomSource;
int _loadSaveSlot;
bool _isEarlyGame;
+ SpriteResource _charFaces[TOTAL_CHARACTERS];
+ SpriteResource *_partyFaces[MAX_ACTIVE_PARTY];
+ SpriteResource _dseFace;
void showIntro();
void showMainMenu();
- void drawUI();
+ void drawUI(bool soundPlayed);
+
+ void loadCharIcons(int numChars);
protected:
/**
* Play the game