[Scummvm-cvs-logs] SF.net SVN: scummvm: [31717] scummvm/trunk/engines/made
john_doe at users.sourceforge.net
john_doe at users.sourceforge.net
Fri Apr 25 13:05:56 CEST 2008
Revision: 31717
http://scummvm.svn.sourceforge.net/scummvm/?rev=31717&view=rev
Author: john_doe
Date: 2008-04-25 04:05:56 -0700 (Fri, 25 Apr 2008)
Log Message:
-----------
Added FontResource type
Modified Paths:
--------------
scummvm/trunk/engines/made/resource.cpp
scummvm/trunk/engines/made/resource.h
Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp 2008-04-25 11:02:37 UTC (rev 31716)
+++ scummvm/trunk/engines/made/resource.cpp 2008-04-25 11:05:56 UTC (rev 31717)
@@ -205,33 +205,59 @@
return NULL;
}
-/* XmidiResource */
+/* FontResource */
-XmidiResource::XmidiResource() : _data(NULL), _size(0) {
+FontResource::FontResource() : _data(NULL), _size(0) {
}
-XmidiResource::~XmidiResource() {
+FontResource::~FontResource() {
if (_data)
delete[] _data;
}
-void XmidiResource::load(byte *source, int size) {
+void FontResource::load(byte *source, int size) {
_data = new byte[size];
_size = size;
memcpy(_data, source, size);
}
-/* FontResource */
+int FontResource::getHeight() const {
+ return _data[0];
+}
-FontResource::FontResource() : _data(NULL), _size(0) {
+int FontResource::getCharWidth(char c) const {
+ byte *charData = getCharData(c);
+ if (charData)
+ return charData[0];
+ else
+ return 0;
}
-FontResource::~FontResource() {
+byte *FontResource::getChar(char c) const {
+ byte *charData = getCharData(c);
+ if (charData)
+ return charData + 1;
+ else
+ return NULL;
+}
+
+byte *FontResource::getCharData(char c) const {
+ if (c < 28 || c > 255)
+ return NULL;
+ return _data + 1 + (c - 28) * (getHeight() + 1);
+}
+
+/* XmidiResource */
+
+XmidiResource::XmidiResource() : _data(NULL), _size(0) {
+}
+
+XmidiResource::~XmidiResource() {
if (_data)
delete[] _data;
}
-void FontResource::load(byte *source, int size) {
+void XmidiResource::load(byte *source, int size) {
_data = new byte[size];
_size = size;
memcpy(_data, source, size);
@@ -301,14 +327,14 @@
return createResource<MenuResource>(kResMENU, index);
}
+FontResource *ProjectReader::getFont(int index) {
+ return createResource<FontResource>(kResFONT, index);
+}
+
XmidiResource *ProjectReader::getXmidi(int index) {
return createResource<XmidiResource>(kResXMID, index);
}
-FontResource *ProjectReader::getFont(int index) {
- return createResource<FontResource>(kResFONT, index);
-}
-
void ProjectReader::loadIndex(ResourceSlots *slots) {
_fd->readUint32LE(); // skip INDX
_fd->readUint32LE(); // skip index size
Modified: scummvm/trunk/engines/made/resource.h
===================================================================
--- scummvm/trunk/engines/made/resource.h 2008-04-25 11:02:37 UTC (rev 31716)
+++ scummvm/trunk/engines/made/resource.h 2008-04-25 11:05:56 UTC (rev 31717)
@@ -45,8 +45,8 @@
kResSNDS = MKID_BE('SNDS'),
kResANIM = MKID_BE('ANIM'),
kResMENU = MKID_BE('MENU'),
- kResXMID = MKID_BE('XMID'),
- kResFONT = MKID_BE('FONT')
+ kResFONT = MKID_BE('FONT'),
+ kResXMID = MKID_BE('XMID')
};
struct ResourceSlot;
@@ -112,23 +112,24 @@
Common::Array<Common::String> _strings;
};
-class XmidiResource : public Resource {
+class FontResource : public Resource {
public:
- XmidiResource();
- ~XmidiResource();
+ FontResource();
+ ~FontResource();
void load(byte *source, int size);
- byte *getData() const { return _data; }
- int getSize() const { return _size; }
+ int getHeight() const;
+ int getCharWidth(char c) const;
+ byte *getChar(char c) const;
protected:
byte *_data;
int _size;
+ byte *getCharData(char c) const;
};
-// TODO
-class FontResource : public Resource {
+class XmidiResource : public Resource {
public:
- FontResource();
- ~FontResource();
+ XmidiResource();
+ ~XmidiResource();
void load(byte *source, int size);
byte *getData() const { return _data; }
int getSize() const { return _size; }
@@ -160,8 +161,8 @@
AnimationResource *getAnimation(int index);
SoundResource *getSound(int index);
MenuResource *getMenu(int index);
+ FontResource *getFont(int index);
XmidiResource *getXmidi(int index);
- FontResource *getFont(int index);
void freeResource(Resource *resource);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list