diff options
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 16 | ||||
-rw-r--r-- | engines/sci/gui/gui.cpp | 10 | ||||
-rw-r--r-- | engines/sci/gui/gui.h | 2 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.cpp | 55 | ||||
-rw-r--r-- | engines/sci/gui/gui_gfx.h | 2 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.cpp | 2 | ||||
-rw-r--r-- | engines/sci/gui32/gui32.h | 2 |
7 files changed, 79 insertions, 10 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index 6206c69a48..7bc589e749 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -1070,7 +1070,7 @@ static void disableCertainButtons(SegManager *segMan, Common::String gameName, r void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { SegManager *segMan = s->_segMan; int16 type = GET_SEL32V(controlObject, type); - int16 state = GET_SEL32V(controlObject, state); + int16 style = GET_SEL32V(controlObject, state); int16 x = GET_SEL32V(controlObject, nsLeft); int16 y = GET_SEL32V(controlObject, nsTop); GuiResourceId fontId = GET_SEL32V(controlObject, font); @@ -1085,6 +1085,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { reg_t listSeeker; Common::String *listStrings = NULL; const char **listEntries = NULL; + bool isAlias = false; rect = Common::Rect (x, y, (int16)GET_SEL32V(controlObject, nsRight), (int16)GET_SEL32V(controlObject, nsBottom)); if (!textReference.isNull()) @@ -1093,13 +1094,13 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { switch (type) { case K_CONTROL_BUTTON: debugC(2, kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d\n", PRINT_REG(controlObject), x, y); - s->_gui->drawControlButton(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, state, hilite); + s->_gui->drawControlButton(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, style, hilite); return; case K_CONTROL_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, state, hilite); + s->_gui->drawControlText(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, hilite); return; case K_CONTROL_TEXTEDIT: @@ -1107,7 +1108,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { maxChars = GET_SEL32V(controlObject, max); cursorPos = GET_SEL32V(controlObject, cursor); debugC(2, kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d\n", PRINT_REG(controlObject), PRINT_REG(textReference), text.c_str(), x, y); - s->_gui->drawControlTextEdit(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, mode, state, cursorPos, maxChars, hilite); + s->_gui->drawControlTextEdit(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, cursorPos, maxChars, hilite); return; case K_CONTROL_ICON: @@ -1115,11 +1116,14 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { loopNo = sign_extend_byte(GET_SEL32V(controlObject, loop)); celNo = sign_extend_byte(GET_SEL32V(controlObject, cel)); debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d\n", PRINT_REG(controlObject), x, y - 1); - s->_gui->drawControlIcon(rect, controlObject, viewId, loopNo, celNo, state, hilite); + s->_gui->drawControlIcon(rect, controlObject, viewId, loopNo, celNo, style, hilite); return; case K_CONTROL_LIST: case K_CONTROL_LIST_ALIAS: + if (type == K_CONTROL_LIST_ALIAS) + isAlias = true; + maxChars = GET_SEL32V(controlObject, x); // max chars per entry // NOTE: most types of pointer dereferencing don't like odd offsets if (maxChars & 1) { @@ -1161,7 +1165,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) { } debugC(2, kDebugLevelGraphics, "drawing list control %04x:%04x to %d,%d, diff %d\n", PRINT_REG(controlObject), x, y, SCI_MAX_SAVENAME_LENGTH); - s->_gui->drawControlList(rect, controlObject, listCount, listEntries, fontId, upperPos, cursorPos, hilite); + s->_gui->drawControlList(rect, controlObject, maxChars, listCount, listEntries, fontId, style, upperPos, cursorPos, isAlias, hilite); free(listEntries); delete[] listStrings; return; diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp index 22eff9b7fb..096688653e 100644 --- a/engines/sci/gui/gui.cpp +++ b/engines/sci/gui/gui.cpp @@ -360,7 +360,15 @@ void SciGui::drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, _screen->copyToScreen(); } -void SciGui::drawControlList(Common::Rect rect, reg_t obj, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool hilite) { +void SciGui::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) { + if (!hilite) { + rect.grow(1); + _gfx->drawListControl(rect, obj, maxChars, count, entries, fontId, upperPos, cursorPos, isAlias); + if (isAlias && (style & 8)) { + _gfx->FrameRect(rect); + } + _screen->copyToScreen(); + } } void SciGui::editControl(reg_t controlObject, reg_t eventObject) { diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h index 0a4354e3c3..df8c3b09db 100644 --- a/engines/sci/gui/gui.h +++ b/engines/sci/gui/gui.h @@ -73,7 +73,7 @@ public: virtual void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, 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 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, 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); virtual void editControl(reg_t controlObject, reg_t eventObject); virtual void graphFillBoxForeground(Common::Rect rect); diff --git a/engines/sci/gui/gui_gfx.cpp b/engines/sci/gui/gui_gfx.cpp index c3732dab98..e1ebd0fa7f 100644 --- a/engines/sci/gui/gui_gfx.cpp +++ b/engines/sci/gui/gui_gfx.cpp @@ -137,6 +137,10 @@ void SciGuiGfx::PenColor(int16 color) { _curPort->penClr = color; } +void SciGuiGfx::BackColor(int16 color) { + _curPort->backClr = color; +} + void SciGuiGfx::PenMode(int16 mode) { _curPort->penMode = mode; } @@ -741,6 +745,57 @@ void SciGuiGfx::drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo } } +const char controlListUpArrow[2] = { 0x18, 0 }; +const char controlListDownArrow[2] = { 0x19, 0 }; + +void SciGuiGfx::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias) { + Common::Rect workerRect = rect; + GuiResourceId oldFontId = GetFontId(); + int16 oldPenColor = _curPort->penClr; + uint16 fontSize = 0; + int16 i; + const char *listEntry; + int16 listEntryLen; + + // draw basic window + EraseRect(workerRect); + workerRect.grow(1); FrameRect(workerRect); + // draw UP/DOWN arrows + workerRect = rect; + TextBox(controlListUpArrow, 0, workerRect, 1, 0); + workerRect.top = workerRect.bottom - 10; + TextBox(controlListDownArrow, 0, workerRect, 1, 0); + + // Draw inner lines + workerRect = rect; + workerRect.top = rect.top + 10; + workerRect.bottom = rect.bottom - 10; + FrameRect(workerRect); + workerRect.grow(-1); + + SetFont(fontId); + fontSize = _curPort->fontHeight; + PenColor(_curPort->penClr); BackColor(_curPort->backClr); + workerRect.bottom = workerRect.top + fontSize; + + // Write actual text + for (i = 0; i < count; i++) { + EraseRect(workerRect); + listEntry = entries[i]; + if (listEntry[0]) { + MoveTo(workerRect.left, workerRect.top + 1); + listEntryLen = strlen(listEntry); + DrawText(listEntry, 0, MIN(maxChars, listEntryLen), oldFontId, oldPenColor); + if ((!isAlias) && (i == cursorPos)) { + InvertRect(workerRect); + } + } + workerRect.translate(0, fontSize); + } + + SetFont(oldFontId); +} + uint16 SciGuiGfx::onControl(uint16 screenMask, Common::Rect rect) { Common::Rect outRect(rect.left, rect.top, rect.right, rect.bottom); int16 x, y; diff --git a/engines/sci/gui/gui_gfx.h b/engines/sci/gui/gui_gfx.h index 2d99b14c2f..058b7d4659 100644 --- a/engines/sci/gui/gui_gfx.h +++ b/engines/sci/gui/gui_gfx.h @@ -66,6 +66,7 @@ public: void Move(int16 left, int16 top); void OpenPort(GuiPort *port); void PenColor(int16 color); + void BackColor(int16 color); void PenMode(int16 mode); void TextFace(int16 textFace); int16 GetPointSize(void); @@ -107,6 +108,7 @@ public: void drawPicture(GuiResourceId pictureId, int16 animationNr, bool mirroredFlag, bool addToFlag, GuiResourceId paletteId); void drawCel(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, uint16 leftPos, uint16 topPos, byte priority, uint16 paletteNo); + void drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias); uint16 onControl(uint16 screenMask, Common::Rect rect); diff --git a/engines/sci/gui32/gui32.cpp b/engines/sci/gui32/gui32.cpp index 9c7cb09229..c635262dd1 100644 --- a/engines/sci/gui32/gui32.cpp +++ b/engines/sci/gui32/gui32.cpp @@ -634,7 +634,7 @@ void SciGui32::drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewI if (!s->pic_not_valid) FULL_REDRAW(); } -void SciGui32::drawControlList(Common::Rect rect, reg_t obj, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool hilite) { +void SciGui32::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) { rect_t area = gfx_rect(rect.left, rect.top, rect.width(), rect.height()); ADD_TO_CURRENT_PICTURE_PORT(sciw_new_list_control(s->port, obj, area, fontId, entries, count, upperPos, cursorPos, (int8)hilite)); diff --git a/engines/sci/gui32/gui32.h b/engines/sci/gui32/gui32.h index 035b96b8ed..fb2a1e3143 100644 --- a/engines/sci/gui32/gui32.h +++ b/engines/sci/gui32/gui32.h @@ -64,7 +64,7 @@ public: void drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, 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 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, 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); void editControl(reg_t controlObject, reg_t eventObject); void graphFillBoxForeground(Common::Rect rect); |