mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
changed font handling:
- engine doesn't see font as a low-level Cnv anymore - the Graphics class takes care of freeing memory on font changes svn-id: r25900
This commit is contained in:
parent
75af373278
commit
b2927b69c6
@ -285,7 +285,7 @@ void _c_finito(void *parm) {
|
||||
_vm->_graphics->palUnk0(_palette);
|
||||
|
||||
if (gameCompleted) {
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
uint16 _ax = _vm->_graphics->getStringWidth(v4C[_language]);
|
||||
_vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 70, v4C[_language]);
|
||||
@ -303,9 +303,8 @@ void _c_finito(void *parm) {
|
||||
strcpy(_location, "estgrotta.drki");
|
||||
|
||||
_engineFlags |= kEngineChangeLocation;
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
} else {
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
uint16 _ax = _vm->_graphics->getStringWidth(v8C[_language]);
|
||||
_vm->_graphics->displayString((SCREEN_WIDTH - _ax)/2, 70, v8C[_language]);
|
||||
@ -320,7 +319,6 @@ void _c_finito(void *parm) {
|
||||
_vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2);
|
||||
waitUntilLeftClick();
|
||||
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
_vm->_menu->selectCharacter();
|
||||
}
|
||||
|
||||
@ -357,7 +355,7 @@ void _c_testResult(void *parm) {
|
||||
_vm->parseLocation("common");
|
||||
_vm->_archive.close();
|
||||
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
|
||||
uint16 _ax = _vm->_graphics->getStringWidth(_slideText[0]);
|
||||
@ -368,8 +366,6 @@ void _c_testResult(void *parm) {
|
||||
_vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack);
|
||||
_vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2);
|
||||
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -245,7 +245,7 @@ void runDialogue(SpeakData *data) {
|
||||
_vm->_graphics->loadExternalCnv(v20, &_characterFace);
|
||||
debugC(1, kDebugDialogue, "runDialogue: 1st character head loaded");
|
||||
|
||||
_vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("comiccnv");
|
||||
|
||||
Cnv v6E;
|
||||
StaticCnv v5C, v48;
|
||||
@ -519,8 +519,6 @@ void runDialogue(SpeakData *data) {
|
||||
debugC(1, kDebugDialogue, "runDialogue: 2nd character head free'd");
|
||||
}
|
||||
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
exitDialogue();
|
||||
debugC(1, kDebugDialogue, "runDialogue: exit dialogue ok");
|
||||
|
||||
|
@ -180,7 +180,6 @@ void Graphics::palUnk0(byte *palette) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Graphics::buildBWPalette(byte *palette) {
|
||||
|
||||
for (uint16 i = 0; i < PALETTE_COLORS; i++) {
|
||||
@ -797,6 +796,14 @@ void Graphics::getStringExtent(char *text, uint16 maxwidth, int16* width, int16*
|
||||
}
|
||||
|
||||
|
||||
void Graphics::setFont(const char* name) {
|
||||
if (_font._array != NULL)
|
||||
freeCnv(&_font);
|
||||
|
||||
loadExternalCnv(name, &_font);
|
||||
}
|
||||
|
||||
|
||||
// backups background mask
|
||||
//
|
||||
//
|
||||
@ -1106,6 +1113,7 @@ void Graphics::freeCnv(Cnv *cnv) {
|
||||
memFree(cnv->_array[_si]);
|
||||
}
|
||||
memFree(cnv->_array);
|
||||
cnv->_array = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1366,6 +1374,8 @@ Graphics::Graphics(Parallaction* vm) :
|
||||
|
||||
initMouse( 0 );
|
||||
|
||||
_font._array = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1379,6 +1389,8 @@ Graphics::~Graphics() {
|
||||
memFree(_buffers[kBit2]);
|
||||
memFree(_buffers[kBit3]);
|
||||
|
||||
freeCnv(&_font);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -140,11 +140,11 @@ public:
|
||||
|
||||
void setMousePointer(int16 index);
|
||||
|
||||
void setFont(const char* name);
|
||||
|
||||
public:
|
||||
static Point _labelPosition[2];
|
||||
static bool _proportionalFont;
|
||||
static Cnv _font;
|
||||
|
||||
protected:
|
||||
Parallaction* _vm;
|
||||
@ -154,6 +154,9 @@ protected:
|
||||
static byte _mouseArrow[256];
|
||||
static StaticCnv _mouseComposedArrow;
|
||||
|
||||
static Cnv _font;
|
||||
|
||||
|
||||
protected:
|
||||
//
|
||||
// decompress a graphics block (size is *target* size)
|
||||
|
@ -132,7 +132,7 @@ void _c_startIntro(void *parm) {
|
||||
|
||||
void _c_endIntro(void *parm) {
|
||||
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &_vm->_graphics->_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
|
||||
uint16 _di;
|
||||
@ -153,7 +153,6 @@ void _c_endIntro(void *parm) {
|
||||
}
|
||||
|
||||
waitUntilLeftClick();
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
_engineFlags &= ~kEngineMouse;
|
||||
_vm->_menu->selectCharacter();
|
||||
|
@ -46,7 +46,7 @@ void Parallaction::parseLocation(const char *filename) {
|
||||
|
||||
uint16 _si = 1;
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
_vm->_graphics->loadExternalCnv("topazcnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("topazcnv");
|
||||
|
||||
char archivefile[PATH_LEN];
|
||||
|
||||
@ -189,7 +189,6 @@ void Parallaction::parseLocation(const char *filename) {
|
||||
}
|
||||
|
||||
resolveLocationForwards();
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
delete _locationScript;
|
||||
_locationScript = NULL;
|
||||
@ -404,14 +403,13 @@ void Parallaction::changeLocation(char *location) {
|
||||
debugC(1, kDebugLocation, "changeLocation: new background set");
|
||||
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
|
||||
uint16 _ax = strlen(_slideText[0]);
|
||||
_ax <<= 3; // text width
|
||||
uint16 _dx = (SCREEN_WIDTH - _ax) >> 1; // center text
|
||||
_vm->_graphics->displayString(_dx, 14, _slideText[0]); // displays text on screen
|
||||
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
waitUntilLeftClick();
|
||||
|
||||
debugC(2, kDebugLocation, "changeLocation: intro text shown");
|
||||
@ -511,7 +509,7 @@ void Parallaction::doLocationEnterTransition() {
|
||||
jobEraseAnimations(NULL, NULL);
|
||||
jobDisplayAnimations(NULL, NULL);
|
||||
|
||||
_vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("comiccnv");
|
||||
_vm->_graphics->swapBuffers();
|
||||
_vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack);
|
||||
|
||||
@ -521,8 +519,6 @@ void Parallaction::doLocationEnterTransition() {
|
||||
_vm->_graphics->floodFill(1, 6, 6, 9 + v7C, 4 + v7A, Graphics::kBitFront);
|
||||
_vm->_graphics->displayWrappedString(_locationComment, 3, 5, 130, 0);
|
||||
|
||||
_vm->_graphics->freeCnv( &Graphics::_font );
|
||||
|
||||
// FIXME: ???
|
||||
#if 0
|
||||
do {
|
||||
|
@ -104,7 +104,7 @@ void Menu::start() {
|
||||
_vm->_archive.open("disk1");
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
|
||||
_vm->_graphics->Graphics::loadBackground("intro.slide", Graphics::kBitBack);
|
||||
_vm->_graphics->palUnk0(_palette);
|
||||
@ -196,7 +196,6 @@ void Menu::newGame() {
|
||||
if (_mouseButtons != kMouseRightUp)
|
||||
return; // show intro
|
||||
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
_vm->_archive.close();
|
||||
|
||||
selectCharacter();
|
||||
@ -280,7 +279,6 @@ uint16 Menu::selectGame() {
|
||||
if (_si == 0) return 0; // new game
|
||||
|
||||
// load game
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
strcpy(_location, "fogne");
|
||||
strcpy(_engine->_characterName, "dough");
|
||||
@ -316,7 +314,7 @@ void Menu::selectCharacter() {
|
||||
_vm->_midiPlayer->stop();
|
||||
_vm->_graphics->_proportionalFont = false;
|
||||
|
||||
_vm->_graphics->loadExternalCnv("slidecnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("slidecnv");
|
||||
_vm->_archive.open("disk1");
|
||||
|
||||
_vm->_graphics->loadBackground("password.slide", Graphics::kBitBack);
|
||||
@ -416,7 +414,6 @@ void Menu::selectCharacter() {
|
||||
_vm->_archive.close();
|
||||
|
||||
memFree(v14._data0);
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
refreshInventory(_vm->_characterName);
|
||||
|
||||
|
@ -389,7 +389,7 @@ void displayCharacterComment(ExamineData *data) {
|
||||
v3C._data1 = NULL; //_characterFace.field_8[0];
|
||||
v3C._data2 = NULL;
|
||||
|
||||
_vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("comiccnv");
|
||||
_vm->_graphics->flatBlitCnv(&v3C, 190, 80, Graphics::kBitFront, v3C._data1);
|
||||
|
||||
int16 v26, v28;
|
||||
@ -397,8 +397,6 @@ void displayCharacterComment(ExamineData *data) {
|
||||
_vm->_graphics->drawBalloon(140, 10, v28, v26, 0);
|
||||
_vm->_graphics->displayWrappedString(data->_description, 140, 10, 130, 0);
|
||||
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
// printf("wait left");
|
||||
|
||||
waitUntilLeftClick();
|
||||
@ -450,13 +448,12 @@ void displayItemComment(ExamineData *data) {
|
||||
|
||||
int16 v6A = 0, v6C = 0;
|
||||
|
||||
_vm->_graphics->loadExternalCnv("comiccnv", &Graphics::_font);
|
||||
_vm->_graphics->setFont("comiccnv");
|
||||
_vm->_graphics->getStringExtent(data->_description, 130, &v6C, &v6A);
|
||||
_vm->_graphics->drawBalloon(0, 90, v6C, v6A, 0);
|
||||
_vm->_graphics->flatBlitCnv(&cnv, 100, 152, Graphics::kBitFront, cnv._data1);
|
||||
_vm->_graphics->freeStaticCnv(&cnv);
|
||||
_vm->_graphics->displayWrappedString(data->_description, 0, 90, 130, 0);
|
||||
_vm->_graphics->freeCnv(&Graphics::_font);
|
||||
|
||||
jobEraseAnimations((void*)1, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user