aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gui
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-09 12:04:07 +0000
committerMartin Kiewitz2009-10-09 12:04:07 +0000
commit9f3c2c90838ff35f3b505973b4247be6da8edef8 (patch)
tree3b1dd2f4b6674eabaad6f1496356919b45c8c526 /engines/sci/gui
parent23ded6d95574e430eac527eadcd40cf6691d39a0 (diff)
downloadscummvm-rg350-9f3c2c90838ff35f3b505973b4247be6da8edef8.tar.gz
scummvm-rg350-9f3c2c90838ff35f3b505973b4247be6da8edef8.tar.bz2
scummvm-rg350-9f3c2c90838ff35f3b505973b4247be6da8edef8.zip
SCI/newgui: SciGuiFont now locks the resourcedata, fixes broken fonts in games
svn-id: r44820
Diffstat (limited to 'engines/sci/gui')
-rw-r--r--engines/sci/gui/gui_font.cpp9
-rw-r--r--engines/sci/gui/gui_font.h3
2 files changed, 8 insertions, 4 deletions
diff --git a/engines/sci/gui/gui_font.cpp b/engines/sci/gui/gui_font.cpp
index a44a2fe644..a341bb9dec 100644
--- a/engines/sci/gui/gui_font.cpp
+++ b/engines/sci/gui/gui_font.cpp
@@ -32,7 +32,7 @@
namespace Sci {
SciGuiFont::SciGuiFont(ResourceManager *resMan, GuiResourceId resourceId)
- : _resourceId(resourceId) {
+ : _resourceId(resourceId), _resMan(resMan) {
assert(resourceId != -1);
// Workaround: lsl1sci mixes its own internal fonts with the global
@@ -40,11 +40,11 @@ SciGuiFont::SciGuiFont(ResourceManager *resMan, GuiResourceId resourceId)
if (!resMan->testResource(ResourceId(kResourceTypeFont, resourceId)))
resourceId = resourceId & 0x7ff;
- Resource *fontResource = resMan->findResource(ResourceId(kResourceTypeFont, resourceId), false);
- if (!fontResource) {
+ _resource = resMan->findResource(ResourceId(kResourceTypeFont, resourceId), true);
+ if (!_resource) {
error("font resource %d not found", resourceId);
}
- _resourceData = fontResource->data;
+ _resourceData = _resource->data;
_numChars = READ_LE_UINT16(_resourceData + 2);
_fontHeight = READ_LE_UINT16(_resourceData + 4);
@@ -58,6 +58,7 @@ SciGuiFont::SciGuiFont(ResourceManager *resMan, GuiResourceId resourceId)
}
SciGuiFont::~SciGuiFont() {
+ _resMan->unlockResource(_resource);
}
GuiResourceId SciGuiFont::getResourceId() {
diff --git a/engines/sci/gui/gui_font.h b/engines/sci/gui/gui_font.h
index 4e1c41a73e..98b9fe1d3a 100644
--- a/engines/sci/gui/gui_font.h
+++ b/engines/sci/gui/gui_font.h
@@ -43,6 +43,9 @@ public:
void draw(SciGuiScreen *screen, int16 chr, int16 top, int16 left, byte color, byte textface);
private:
+ ResourceManager *_resMan;
+
+ Resource *_resource;
GuiResourceId _resourceId;
byte *_resourceData;