aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/cge/cge.cpp7
-rw-r--r--engines/cge/gettext.cpp4
-rw-r--r--engines/cge/talk.cpp25
-rw-r--r--engines/cge/talk.h6
4 files changed, 29 insertions, 13 deletions
diff --git a/engines/cge/cge.cpp b/engines/cge/cge.cpp
index 2fd196f509..f2bebef258 100644
--- a/engines/cge/cge.cpp
+++ b/engines/cge/cge.cpp
@@ -32,6 +32,7 @@
#include "cge/cge.h"
#include "cge/vga13h.h"
#include "cge/cge_main.h"
+#include "cge/talk.h"
#include "cge/text.h"
#include "cge/bitmaps.h"
#include "cge/vol.h"
@@ -54,9 +55,10 @@ void CGEEngine::setup() {
_console = new CGEConsole(this);
// Initialise classes that have static members
- BITMAP::init();
- VFILE::init();
VGA::init();
+ VFILE::init();
+ BITMAP::init();
+ TALK::init();
// Initialise engine objects
Text = new TEXT(this, ProgName(), 128);
@@ -102,6 +104,7 @@ CGEEngine::~CGEEngine() {
debug("CGEEngine::~CGEEngine");
// Call classes with static members to clear them up
+ TALK::deinit();
BITMAP::deinit();
VFILE::deinit();
VGA::deinit();
diff --git a/engines/cge/gettext.cpp b/engines/cge/gettext.cpp
index 69e19b175c..d444b75ab4 100644
--- a/engines/cge/gettext.cpp
+++ b/engines/cge/gettext.cpp
@@ -39,7 +39,7 @@ GET_TEXT *GET_TEXT::Ptr = NULL;
GET_TEXT::GET_TEXT(CGEEngine *vm, const char *info, char *text, int size, void (*click)(void))
: TALK(vm), Text(text), Size(min<int>(size, GTMAX)), Len(min<int>(Size, strlen(text))),
Cntr(GTBLINK), Click(click), OldKeybClient(KEYBOARD::SetClient(this)), _vm(vm) {
- int i = 2 * TEXT_HM + Font->Width(info);
+ int i = 2 * TEXT_HM + _Font->Width(info);
Ptr = this;
Mode = RECT;
TS[0] = Box((i + 3) & ~3, 2 * TEXT_VM + 2 * FONT_HIG + TEXT_LS);
@@ -107,7 +107,7 @@ void GET_TEXT::Touch(uint16 mask, int x, int y) {
if (p)
x = ogon[p - bezo];
}
- if (Len < Size && 2 * TEXT_HM + Font->Width(Buff) + Font->Wid[x] <= W) {
+ if (Len < Size && 2 * TEXT_HM + _Font->Width(Buff) + _Font->Wid[x] <= W) {
Buff[Len + 2] = Buff[Len + 1];
Buff[Len + 1] = Buff[Len];
Buff[Len++] = x;
diff --git a/engines/cge/talk.cpp b/engines/cge/talk.cpp
index b67d9082ac..ae94233464 100644
--- a/engines/cge/talk.cpp
+++ b/engines/cge/talk.cpp
@@ -102,7 +102,6 @@ TALK::TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode)
TS[0] = TS[1] = NULL;
Flags.Syst = true;
Update(tx);
- Font = new FONT(ProgName());
}
@@ -124,6 +123,16 @@ TALK::~TALK (void) {
}
*/
+FONT *TALK::_Font;
+
+void TALK::init() {
+ _Font = new FONT(ProgName());
+}
+
+void TALK::deinit() {
+ delete _Font;
+}
+
void TALK::Update(const char *tx) {
uint16 vmarg = (Mode) ? TEXT_VM : 0;
@@ -142,7 +151,7 @@ void TALK::Update(const char *tx) {
mw = k;
k = 2 * hmarg;
} else
- k += Font->Wid[*p];
+ k += _Font->Wid[*p];
}
if (k > mw)
mw = k;
@@ -155,8 +164,8 @@ void TALK::Update(const char *tx) {
if (*tx == '|' || *tx == '\n')
m = TS[0]->M + (ln += FONT_HIG + TEXT_LS) * mw + hmarg;
else {
- int cw = Font->Wid[*tx], i;
- uint8 *f = Font->Map + Font->Pos[*tx];
+ int cw = _Font->Wid[*tx], i;
+ uint8 *f = _Font->Map + _Font->Pos[*tx];
for (i = 0; i < cw; i++) {
uint8 *p = m;
uint16 n;
@@ -253,8 +262,8 @@ void TALK::PutLine(int line, const char *text) {
q = v + size;
while (* text) {
- uint16 cw = Font->Wid[*text], i;
- uint8 *fp = Font->Map + Font->Pos[*text];
+ uint16 cw = _Font->Wid[*text], i;
+ uint8 *fp = _Font->Map + _Font->Pos[*text];
for (i = 0; i < cw; i++) {
register uint16 b = fp[i];
@@ -301,8 +310,8 @@ void INFO_LINE::Update(const char *tx) {
uint8 *p = v + 2, * q = p + size;
while (*tx) {
- uint16 cw = Font->Wid[*tx];
- uint8 *fp = Font->Map + Font->Pos[*tx];
+ uint16 cw = _Font->Wid[*tx];
+ uint8 *fp = _Font->Map + _Font->Pos[*tx];
for (uint16 i = 0; i < cw; i++) {
register uint16 b = fp[i];
diff --git a/engines/cge/talk.h b/engines/cge/talk.h
index ba4952c3e6..184b84e553 100644
--- a/engines/cge/talk.h
+++ b/engines/cge/talk.h
@@ -74,10 +74,14 @@ protected:
BITMAP *TS[2];
BITMAP *Box(uint16 w, uint16 h);
public:
- FONT *Font;
TALK(CGEEngine *vm, const char *tx, TBOX_STYLE mode = PURE);
TALK(CGEEngine *vm);
//~TALK (void);
+
+ static FONT *_Font;
+ static void init();
+ static void deinit();
+
virtual void Update(const char *tx);
virtual void Update(void) {}
void PutLine(int line, const char *text);