aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kgraphics.cpp7
-rw-r--r--engines/sci/gui/gui.cpp14
-rw-r--r--engines/sci/gui/gui.h2
-rw-r--r--engines/sci/gui/gui_gfx.cpp20
-rw-r--r--engines/sci/gui/gui_gfx.h6
-rw-r--r--engines/sci/gui/gui_helpers.h2
-rw-r--r--engines/sci/gui/gui_windowmgr.cpp2
-rw-r--r--engines/sci/gui32/gui32.cpp4
-rw-r--r--engines/sci/gui32/gui32.h2
9 files changed, 35 insertions, 24 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index c7e44028f5..7c3763740d 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -670,6 +670,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
reg_t textReference = GET_SEL32(controlObject, text);
Common::String text;
Common::Rect rect;
+ GuiTextAlignment alignment;
int16 mode, maxChars, cursorPos, upperPos, listCount, i;
int16 upperOffset, cursorOffset;
GuiResourceId viewId;
@@ -692,9 +693,9 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
return;
case SCI_CONTROLS_TYPE_TEXT:
- mode = GET_SEL32V(controlObject, mode);
- debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d\n", PRINT_REG(controlObject), text.c_str(), x, y, mode);
- s->_gui->drawControlText(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, hilite);
+ alignment = GET_SEL32V(controlObject, mode);
+ debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d\n", PRINT_REG(controlObject), text.c_str(), x, y, alignment);
+ s->_gui->drawControlText(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, alignment, style, hilite);
return;
case SCI_CONTROLS_TYPE_TEXTEDIT:
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index e2295ac689..958cf279af 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -174,7 +174,7 @@ void SciGui::disposeWindow(uint16 windowPtr, int16 arg2) {
void SciGui::display(const char *text, int argc, reg_t *argv) {
int displayArg;
- int16 align = 0;
+ GuiTextAlignment alignment = SCI_TEXT_ALIGNMENT_LEFT;
int16 bgcolor = -1, width = -1, bRedraw = 1;
bool doSaveUnder = false;
Common::Rect rect, *orect = &((GuiWindow *)_gfx->GetPort())->dims;
@@ -196,7 +196,7 @@ void SciGui::display(const char *text, int argc, reg_t *argv) {
argc -= 2; argv += 2;
break;
case SCI_DISPLAY_SETALIGNMENT:
- align = argv[0].toUint16();
+ alignment = argv[0].toSint16();
argc--; argv++;
break;
case SCI_DISPLAY_SETPENCOLOR:
@@ -247,7 +247,7 @@ void SciGui::display(const char *text, int argc, reg_t *argv) {
_s->r_acc = _gfx->BitsSave(rect, SCI_SCREEN_MASK_VISUAL);
if (bgcolor != -1)
_gfx->FillRect(rect, SCI_SCREEN_MASK_VISUAL, bgcolor, 0, 0);
- _gfx->TextBox(text, 0, rect, align, -1);
+ _gfx->TextBox(text, 0, rect, alignment, -1);
if (_screen->_picNotValid == 0 && bRedraw)
_gfx->BitsShow(rect);
// restoring port and cursor pos
@@ -321,7 +321,7 @@ void SciGui::drawControlButton(Common::Rect rect, reg_t obj, const char *text, i
_gfx->FrameRect(rect);
rect.grow(-2);
_gfx->TextFace(style & 1 ? 0 : 1);
- _gfx->TextBox(text, 0, rect, 1, fontId);
+ _gfx->TextBox(text, 0, rect, SCI_TEXT_ALIGNMENT_CENTER, fontId);
_gfx->TextFace(0);
rect.grow(1);
if (style & 8) // selected
@@ -336,12 +336,12 @@ void SciGui::drawControlButton(Common::Rect rect, reg_t obj, const char *text, i
}
}
-void SciGui::drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite) {
+void SciGui::drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, GuiTextAlignment alignment, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
_gfx->EraseRect(rect);
rect.grow(-1);
- _gfx->TextBox(text, 0, rect, mode, fontId);
+ _gfx->TextBox(text, 0, rect, alignment, fontId);
if (style & 8) { // selected
_gfx->FrameRect(rect);
}
@@ -362,7 +362,7 @@ void SciGui::drawControlTextEdit(Common::Rect rect, reg_t obj, const char *text,
rect.grow(1);
_gfx->TexteditCursorErase();
_gfx->EraseRect(rect);
- _gfx->TextBox(text, 0, textRect, 0, fontId);
+ _gfx->TextBox(text, 0, textRect, SCI_TEXT_ALIGNMENT_LEFT, fontId);
_gfx->FrameRect(rect);
if (style & 8) {
_gfx->SetFont(fontId);
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index 3073aeed38..b0101c7781 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -83,7 +83,7 @@ public:
virtual void drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
virtual void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo);
virtual void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
- virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);
+ virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 alignment, int16 style, bool hilite);
virtual void drawControlTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite);
virtual void drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 style, bool hilite);
virtual void drawControlList(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 style, int16 upperPos, int16 cursorPos, bool isAlias, bool hilite);
diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp
index e798ac7bd7..bb0879652a 100644
--- a/engines/sci/gui/gui_gfx.cpp
+++ b/engines/sci/gui/gui_gfx.cpp
@@ -545,7 +545,7 @@ void SciGuiGfx::ShowText(const char *text, int16 from, int16 len, GuiResourceId
}
// Draws a text in rect.
-void SciGuiGfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect, int16 align, GuiResourceId fontId) {
+void SciGuiGfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect, GuiTextAlignment alignment, GuiResourceId fontId) {
int16 textWidth, textHeight, charCount, offset;
int16 hline = 0;
GuiResourceId orgFontId = GetFontId();
@@ -563,15 +563,19 @@ void SciGuiGfx::TextBox(const char *text, int16 bshow, const Common::Rect &rect,
if (charCount == 0)
break;
TextWidth(text, 0, charCount, orgFontId, textWidth, textHeight);
- switch (align) {
- case -1: // right-aligned
+ switch (alignment) {
+ case SCI_TEXT_ALIGNMENT_RIGHT:
offset = rect.width() - textWidth;
break;
- case 1: // center text
+ case SCI_TEXT_ALIGNMENT_CENTER:
offset = (rect.width() - textWidth) / 2;
break;
- default: // left-aligned
+ case SCI_TEXT_ALIGNMENT_LEFT:
offset = 0;
+ break;
+
+ default: // left-aligned
+ warning("Invalid alignment %d used in TextBox()", alignment);
}
MoveTo(rect.left + offset, rect.top + hline);
@@ -754,9 +758,9 @@ void SciGuiGfx::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, in
// draw UP/DOWN arrows
workerRect.top++;
- TextBox(controlListUpArrow, 0, workerRect, 1, 0);
+ TextBox(controlListUpArrow, 0, workerRect, SCI_TEXT_ALIGNMENT_CENTER, 0);
workerRect.top = workerRect.bottom - 10;
- TextBox(controlListDownArrow, 0, workerRect, 1, 0);
+ TextBox(controlListDownArrow, 0, workerRect, SCI_TEXT_ALIGNMENT_CENTER, 0);
// Draw inner lines
workerRect.top = rect.top + 9;
@@ -891,7 +895,7 @@ void SciGuiGfx::TexteditChange(reg_t controlObject, reg_t eventObject) {
rect.top++;
TexteditCursorErase();
EraseRect(rect);
- TextBox(text.c_str(), 0, rect, 0, fontId);
+ TextBox(text.c_str(), 0, rect, SCI_TEXT_ALIGNMENT_LEFT, fontId);
BitsShow(rect);
SetFont(fontId);
rect.top--;
diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h
index 64c34516e1..22c473dc00 100644
--- a/engines/sci/gui/gui_gfx.h
+++ b/engines/sci/gui/gui_gfx.h
@@ -30,6 +30,10 @@
namespace Sci {
+#define SCI_TEXT_ALIGNMENT_RIGHT -1
+#define SCI_TEXT_ALIGNMENT_CENTER 1
+#define SCI_TEXT_ALIGNMENT_LEFT 0
+
class SciGuiScreen;
class SciGuiPalette;
class SciGuiFont;
@@ -87,7 +91,7 @@ public:
void DrawString(const char *str, GuiResourceId orgFontId, int16 orgPenColor) {
DrawText(str, 0, (int16)strlen(str), orgFontId, orgPenColor);
}
- void TextBox(const char *str, int16 bshow, const Common::Rect &rect, int16 align, GuiResourceId fontId);
+ void TextBox(const char *str, int16 bshow, const Common::Rect &rect, GuiTextAlignment alignment, GuiResourceId fontId);
void BitsShow(const Common::Rect &r);
GuiMemoryHandle BitsSave(const Common::Rect &rect, byte screenFlags);
void BitsGetRect(GuiMemoryHandle memoryHandle, Common::Rect *destRect);
diff --git a/engines/sci/gui/gui_helpers.h b/engines/sci/gui/gui_helpers.h
index c7ad8d8a33..65ba397f23 100644
--- a/engines/sci/gui/gui_helpers.h
+++ b/engines/sci/gui/gui_helpers.h
@@ -40,6 +40,8 @@ typedef reg_t GuiMemoryHandle;
typedef int16 GuiViewLoopNo;
typedef int16 GuiViewCelNo;
+typedef int16 GuiTextAlignment;
+
struct GuiPort {
uint16 id;
int16 top, left;
diff --git a/engines/sci/gui/gui_windowmgr.cpp b/engines/sci/gui/gui_windowmgr.cpp
index 664cf751f4..cf34537e22 100644
--- a/engines/sci/gui/gui_windowmgr.cpp
+++ b/engines/sci/gui/gui_windowmgr.cpp
@@ -223,7 +223,7 @@ void SciGuiWindowMgr::DrawWindow(GuiWindow *pWnd) {
if (!pWnd->title.empty()) {
int16 oldcolor = _gfx->GetPort()->penClr;
_gfx->PenColor(255);
- _gfx->TextBox(pWnd->title.c_str(), 1, r, 1, 0);
+ _gfx->TextBox(pWnd->title.c_str(), 1, r, SCI_TEXT_ALIGNMENT_CENTER, 0);
_gfx->PenColor(oldcolor);
}
diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp
index 8cf6d2cfa1..3aed195eaf 100644
--- a/engines/sci/gui32/gui32.cpp
+++ b/engines/sci/gui32/gui32.cpp
@@ -965,10 +965,10 @@ void SciGui32::drawControlButton(Common::Rect rect, reg_t obj, const char *text,
if (!_s->pic_not_valid) FULL_REDRAW();
}
-void SciGui32::drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite) {
+void SciGui32::drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 alignment, int16 style, bool hilite) {
rect_t area = gfx_rect(rect.left, rect.top, rect.width(), rect.height());
- ADD_TO_CURRENT_PICTURE_PORT(sciw_new_text_control(_s->port, obj, area, text, fontId, (gfx_alignment_t) mode,
+ ADD_TO_CURRENT_PICTURE_PORT(sciw_new_text_control(_s->port, obj, area, text, fontId, (gfx_alignment_t) alignment,
(int8)(!!(style & kControlStateDitherFramed)), (int8)hilite));
if (!_s->pic_not_valid) FULL_REDRAW();
}
diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h
index e529addc1e..da4aa229b6 100644
--- a/engines/sci/gui32/gui32.h
+++ b/engines/sci/gui32/gui32.h
@@ -61,7 +61,7 @@ public:
void drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo);
void drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
- void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, bool hilite);
+ void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 alignment, int16 style, bool hilite);
void drawControlTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite);
void drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo, int16 style, bool hilite);
void drawControlList(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 style, int16 upperPos, int16 cursorPos, bool isAlias, bool hilite);