SCI: rename Controls to GfxControls, gets directly called now

svn-id: r47783
This commit is contained in:
Martin Kiewitz 2010-01-31 22:20:55 +00:00
parent 12d983eaf4
commit d31f696d1f
7 changed files with 153 additions and 150 deletions

View File

@ -36,11 +36,12 @@
#include "sci/engine/kernel.h"
#include "sci/graphics/gui.h"
#include "sci/graphics/gui32.h"
#include "sci/graphics/ports.h"
#include "sci/graphics/animate.h"
#include "sci/graphics/cache.h"
#include "sci/graphics/controls.h"
#include "sci/graphics/cursor.h"
#include "sci/graphics/palette.h"
#include "sci/graphics/ports.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/view.h"
@ -812,13 +813,13 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
switch (type) {
case SCI_CONTROLS_TYPE_BUTTON:
debugC(2, kDebugLevelGraphics, "drawing button %04x:%04x to %d,%d", PRINT_REG(controlObject), x, y);
s->_gui->drawControlButton(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, style, hilite);
s->_gfxControls->kernelDrawButton(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, style, hilite);
return;
case SCI_CONTROLS_TYPE_TEXT:
alignment = GET_SEL32V(s->_segMan, controlObject, mode);
debugC(2, kDebugLevelGraphics, "drawing text %04x:%04x ('%s') to %d,%d, mode=%d", PRINT_REG(controlObject), text.c_str(), x, y, alignment);
s->_gui->drawControlText(rect, controlObject, s->strSplit(text.c_str()).c_str(), fontId, alignment, style, hilite);
s->_gfxControls->kernelDrawText(rect, controlObject, s->strSplit(text.c_str()).c_str(), fontId, alignment, style, hilite);
return;
case SCI_CONTROLS_TYPE_TEXTEDIT:
@ -826,7 +827,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
maxChars = GET_SEL32V(s->_segMan, controlObject, max);
cursorPos = GET_SEL32V(s->_segMan, controlObject, cursor);
debugC(2, kDebugLevelGraphics, "drawing edit control %04x:%04x (text %04x:%04x, '%s') to %d,%d", 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, style, cursorPos, maxChars, hilite);
s->_gfxControls->kernelDrawTextEdit(rect, controlObject, s->strSplit(text.c_str(), NULL).c_str(), fontId, mode, style, cursorPos, maxChars, hilite);
return;
case SCI_CONTROLS_TYPE_ICON:
@ -846,7 +847,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
priority = -1;
}
debugC(2, kDebugLevelGraphics, "drawing icon control %04x:%04x to %d,%d", PRINT_REG(controlObject), x, y - 1);
s->_gui->drawControlIcon(rect, controlObject, viewId, loopNo, celNo, priority, style, hilite);
s->_gfxControls->kernelDrawIcon(rect, controlObject, viewId, loopNo, celNo, priority, style, hilite);
return;
case SCI_CONTROLS_TYPE_LIST:
@ -894,7 +895,7 @@ void _k_GenericDrawControl(EngineState *s, reg_t controlObject, bool hilite) {
}
debugC(2, kDebugLevelGraphics, "drawing list control %04x:%04x to %d,%d, diff %d", PRINT_REG(controlObject), x, y, SCI_MAX_SAVENAME_LENGTH);
s->_gui->drawControlList(rect, controlObject, maxChars, listCount, listEntries, fontId, style, upperPos, cursorPos, isAlias, hilite);
s->_gfxControls->kernelDrawList(rect, controlObject, maxChars, listCount, listEntries, fontId, style, upperPos, cursorPos, isAlias, hilite);
free(listEntries);
delete[] listStrings;
return;
@ -934,8 +935,15 @@ reg_t kEditControl(EngineState *s, int argc, reg_t *argv) {
reg_t controlObject = argv[0];
reg_t eventObject = argv[1];
if (!controlObject.isNull())
s->_gui->editControl(controlObject, eventObject);
if (!controlObject.isNull()) {
int16 controlType = GET_SEL32V(s->_segMan, controlObject, type);
switch (controlType) {
case SCI_CONTROLS_TYPE_TEXTEDIT:
// Only process textedit controls in here
s->_gfxControls->kernelTexteditChange(controlObject, eventObject);
}
}
return s->r_acc;
}

View File

@ -52,10 +52,11 @@ namespace Sci {
class SciEvent;
class Menubar;
class GfxAnimate;
class GfxCache;
class GfxControls;
class GfxPalette;
class GfxPorts;
class GfxScreen;
class GfxPalette;
class GfxCache;
class SciGui;
class Cursor;
class MessageState;
@ -157,10 +158,11 @@ public:
/* Non-VM information */
GfxAnimate *_gfxAnimate; // Animate for 16-bit gfx
GfxCache *_gfxCache;
GfxControls *_gfxControls; // Controls for 16-bit gfx
GfxPalette *_gfxPalette;
GfxPorts *_gfxPorts; // Port managment for 16-bit gfx
GfxScreen *_gfxScreen;
GfxPalette *_gfxPalette;
GfxCache *_gfxCache;
SciGui *_gui; /* Currently active Gui */
#ifdef ENABLE_SCI32

View File

@ -34,27 +34,28 @@
#include "sci/graphics/ports.h"
#include "sci/graphics/paint16.h"
#include "sci/graphics/font.h"
#include "sci/graphics/screen.h"
#include "sci/graphics/text16.h"
#include "sci/graphics/controls.h"
namespace Sci {
Controls::Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16)
: _segMan(segMan), _ports(ports), _paint16(paint16), _text16(text16) {
GfxControls::GfxControls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen)
: _segMan(segMan), _ports(ports), _paint16(paint16), _text16(text16), _screen(screen) {
init();
}
Controls::~Controls() {
GfxControls::~GfxControls() {
}
void Controls::init() {
void GfxControls::init() {
_texteditCursorVisible = false;
}
const char controlListUpArrow[2] = { 0x18, 0 };
const char controlListDownArrow[2] = { 0x19, 0 };
void Controls::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias) {
void GfxControls::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 = _text16->GetFontId();
int16 oldPenColor = _ports->_curPort->penClr;
@ -109,7 +110,7 @@ void Controls::drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int
_text16->SetFont(oldFontId);
}
void Controls::TexteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos) {
void GfxControls::texteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos) {
int16 textWidth, i;
if (!_texteditCursorVisible) {
textWidth = 0;
@ -123,24 +124,24 @@ void Controls::TexteditCursorDraw(Common::Rect rect, const char *text, uint16 cu
_paint16->invertRect(_texteditCursorRect);
_paint16->bitsShow(_texteditCursorRect);
_texteditCursorVisible = true;
TexteditSetBlinkTime();
texteditSetBlinkTime();
}
}
void Controls::TexteditCursorErase() {
void GfxControls::texteditCursorErase() {
if (_texteditCursorVisible) {
_paint16->invertRect(_texteditCursorRect);
_paint16->bitsShow(_texteditCursorRect);
_texteditCursorVisible = false;
}
TexteditSetBlinkTime();
texteditSetBlinkTime();
}
void Controls::TexteditSetBlinkTime() {
void GfxControls::texteditSetBlinkTime() {
_texteditBlinkTime = g_system->getMillis() + (30 * 1000 / 60);
}
void Controls::TexteditChange(reg_t controlObject, reg_t eventObject) {
void GfxControls::kernelTexteditChange(reg_t controlObject, reg_t eventObject) {
uint16 cursorPos = GET_SEL32V(_segMan, controlObject, cursor);
uint16 maxChars = GET_SEL32V(_segMan, controlObject, max);
reg_t textReference = GET_SEL32(_segMan, controlObject, text);
@ -209,12 +210,12 @@ void Controls::TexteditChange(reg_t controlObject, reg_t eventObject) {
GuiResourceId fontId = GET_SEL32V(_segMan, controlObject, font);
rect = Common::Rect(GET_SEL32V(_segMan, controlObject, nsLeft), GET_SEL32V(_segMan, controlObject, nsTop),
GET_SEL32V(_segMan, controlObject, nsRight), GET_SEL32V(_segMan, controlObject, nsBottom));
TexteditCursorErase();
texteditCursorErase();
_paint16->eraseRect(rect);
_text16->Box(text.c_str(), 0, rect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
_paint16->bitsShow(rect);
_text16->SetFont(fontId);
TexteditCursorDraw(rect, text.c_str(), cursorPos);
texteditCursorDraw(rect, text.c_str(), cursorPos);
_text16->SetFont(oldFontId);
// Write back string
_segMan->strcpy(textReference, text.c_str());
@ -223,11 +224,103 @@ void Controls::TexteditChange(reg_t controlObject, reg_t eventObject) {
_paint16->invertRect(_texteditCursorRect);
_paint16->bitsShow(_texteditCursorRect);
_texteditCursorVisible = !_texteditCursorVisible;
TexteditSetBlinkTime();
texteditSetBlinkTime();
}
}
PUT_SEL32V(_segMan, controlObject, cursor, cursorPos);
}
int GfxControls::getPicNotValid() {
if (getSciVersion() >= SCI_VERSION_1_1)
return _screen->_picNotValidSci11;
return _screen->_picNotValid;
}
void GfxControls::kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
_paint16->eraseRect(rect);
_paint16->frameRect(rect);
rect.grow(-2);
_ports->textGreyedOutput(style & 1 ? false : true);
_text16->Box(text, 0, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId);
_ports->textGreyedOutput(false);
rect.grow(1);
if (style & 8) // selected
_paint16->frameRect(rect);
if (!getPicNotValid()) {
rect.grow(1);
_paint16->bitsShow(rect);
}
} else {
_paint16->invertRect(rect);
_paint16->bitsShow(rect);
}
}
void GfxControls::kernelDrawText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, TextAlignment alignment, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
_paint16->eraseRect(rect);
rect.grow(-1);
_text16->Box(text, 0, rect, alignment, fontId);
if (style & 8) { // selected
_paint16->frameRect(rect);
}
rect.grow(1);
if (!getPicNotValid())
_paint16->bitsShow(rect);
} else {
_paint16->invertRect(rect);
_paint16->bitsShow(rect);
}
}
void GfxControls::kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) {
Common::Rect textRect = rect;
uint16 oldFontId = _text16->GetFontId();
rect.grow(1);
texteditCursorErase();
_paint16->eraseRect(rect);
_text16->Box(text, 0, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
_paint16->frameRect(rect);
if (style & 8) {
_text16->SetFont(fontId);
rect.grow(-1);
texteditCursorDraw(rect, text, cursorPos);
_text16->SetFont(oldFontId);
rect.grow(1);
}
if (!getPicNotValid())
_paint16->bitsShow(rect);
}
void GfxControls::kernelDrawIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, int16 loopNo, int16 celNo, int16 priority, int16 style, bool hilite) {
if (!hilite) {
_paint16->drawCelAndShow(viewId, loopNo, celNo, rect.left, rect.top, priority, 0);
if (style & 0x20) {
_paint16->frameRect(rect);
}
if (!getPicNotValid())
_paint16->bitsShow(rect);
} else {
_paint16->invertRect(rect);
_paint16->bitsShow(rect);
}
}
void GfxControls::kernelDrawList(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) {
drawListControl(rect, obj, maxChars, count, entries, fontId, upperPos, cursorPos, isAlias);
rect.grow(1);
if (isAlias && (style & 8)) {
_paint16->frameRect(rect);
}
if (!getPicNotValid())
_paint16->bitsShow(rect);
}
}
} // End of namespace Sci

View File

@ -32,24 +32,33 @@ class GfxPorts;
class GfxPaint16;
class Font;
class GfxText16;
class Controls {
class GfxScreen;
class GfxControls {
public:
Controls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16);
~Controls();
GfxControls(SegManager *segMan, GfxPorts *ports, GfxPaint16 *paint16, GfxText16 *text16, GfxScreen *screen);
~GfxControls();
void drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias);
void TexteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos);
void TexteditCursorErase();
void TexteditChange(reg_t controlObject, reg_t eventObject);
void kernelDrawButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite);
void kernelDrawText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 alignment, int16 style, bool hilite);
void kernelDrawTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite);
void kernelDrawIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, int16 loopNo, int16 celNo, int16 priority, int16 style, bool hilite);
void kernelDrawList(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 kernelTexteditChange(reg_t controlObject, reg_t eventObject);
private:
void init();
void TexteditSetBlinkTime();
void texteditSetBlinkTime();
void drawListControl(Common::Rect rect, reg_t obj, int16 maxChars, int16 count, const char **entries, GuiResourceId fontId, int16 upperPos, int16 cursorPos, bool isAlias);
void texteditCursorDraw(Common::Rect rect, const char *text, uint16 curPos);
void texteditCursorErase();
int getPicNotValid();
SegManager *_segMan;
GfxPorts *_ports;
GfxPaint16 *_paint16;
GfxText16 *_text16;
GfxScreen *_screen;
// Textedit-Control related
Common::Rect _texteditCursorRect;

View File

@ -59,7 +59,8 @@ SciGui::SciGui(EngineState *state, GfxScreen *screen, GfxPalette *palette, GfxCa
_animate = new GfxAnimate(_s, _cache, _ports, _paint16, _screen, _palette, _cursor, _transitions);
_s->_gfxAnimate = _animate;
_text16 = new GfxText16(_s->resMan, _cache, _ports, _paint16, _screen);
_controls = new Controls(_s->_segMan, _ports, _paint16, _text16);
_controls = new GfxControls(_s->_segMan, _ports, _paint16, _text16, _screen);
_s->_gfxControls = _controls;
_menu = new Menu(_s->_event, _s->_segMan, this, _ports, _paint16, _text16, _screen, _cursor);
}
@ -320,109 +321,6 @@ void SciGui::drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 lef
_palette->setOnScreen();
}
int SciGui::getControlPicNotValid() {
if (getSciVersion() >= SCI_VERSION_1_1)
return _screen->_picNotValidSci11;
return _screen->_picNotValid;
}
void SciGui::drawControlButton(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
_paint16->eraseRect(rect);
_paint16->frameRect(rect);
rect.grow(-2);
_ports->textGreyedOutput(style & 1 ? false : true);
_text16->Box(text, 0, rect, SCI_TEXT16_ALIGNMENT_CENTER, fontId);
_ports->textGreyedOutput(false);
rect.grow(1);
if (style & 8) // selected
_paint16->frameRect(rect);
if (!getControlPicNotValid()) {
rect.grow(1);
_paint16->bitsShow(rect);
}
} else {
_paint16->invertRect(rect);
_paint16->bitsShow(rect);
}
}
void SciGui::drawControlText(Common::Rect rect, reg_t obj, const char *text, int16 fontId, TextAlignment alignment, int16 style, bool hilite) {
if (!hilite) {
rect.grow(1);
_paint16->eraseRect(rect);
rect.grow(-1);
_text16->Box(text, 0, rect, alignment, fontId);
if (style & 8) { // selected
_paint16->frameRect(rect);
}
rect.grow(1);
if (!getControlPicNotValid())
_paint16->bitsShow(rect);
} else {
_paint16->invertRect(rect);
_paint16->bitsShow(rect);
}
}
void SciGui::drawControlTextEdit(Common::Rect rect, reg_t obj, const char *text, int16 fontId, int16 mode, int16 style, int16 cursorPos, int16 maxChars, bool hilite) {
Common::Rect textRect = rect;
uint16 oldFontId = _text16->GetFontId();
rect.grow(1);
_controls->TexteditCursorErase();
_paint16->eraseRect(rect);
_text16->Box(text, 0, textRect, SCI_TEXT16_ALIGNMENT_LEFT, fontId);
_paint16->frameRect(rect);
if (style & 8) {
_text16->SetFont(fontId);
rect.grow(-1);
_controls->TexteditCursorDraw(rect, text, cursorPos);
_text16->SetFont(oldFontId);
rect.grow(1);
}
if (!getControlPicNotValid())
_paint16->bitsShow(rect);
}
void SciGui::drawControlIcon(Common::Rect rect, reg_t obj, GuiResourceId viewId, int16 loopNo, int16 celNo, int16 priority, int16 style, bool hilite) {
if (!hilite) {
_paint16->drawCelAndShow(viewId, loopNo, celNo, rect.left, rect.top, priority, 0);
if (style & 0x20) {
_paint16->frameRect(rect);
}
if (!getControlPicNotValid())
_paint16->bitsShow(rect);
} else {
_paint16->invertRect(rect);
_paint16->bitsShow(rect);
}
}
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) {
_controls->drawListControl(rect, obj, maxChars, count, entries, fontId, upperPos, cursorPos, isAlias);
rect.grow(1);
if (isAlias && (style & 8)) {
_paint16->frameRect(rect);
}
if (!getControlPicNotValid())
_paint16->bitsShow(rect);
}
}
void SciGui::editControl(reg_t controlObject, reg_t eventObject) {
int16 controlType = GET_SEL32V(_s->_segMan, controlObject, type);
switch (controlType) {
case SCI_CONTROLS_TYPE_TEXTEDIT:
// Only process textedit controls in here
_controls->TexteditChange(controlObject, eventObject);
return;
}
}
void SciGui::graphFillBoxForeground(Common::Rect rect) {
_paint16->paintRect(rect);
}

View File

@ -48,9 +48,8 @@ class GfxCache;
class GfxCompare;
class GfxPorts;
class GfxPaint16;
class WindowMgr;
class SciGuiAnimate;
class Controls;
class GfxAnimate;
class GfxControls;
class Menu;
class GfxText16;
class Transitions;
@ -84,12 +83,6 @@ public:
virtual void drawPicture(GuiResourceId pictureId, int16 animationNr, bool animationBlackoutFlag, bool mirroredFlag, bool addToFlag, int16 EGApaletteNo);
virtual void drawCel(GuiResourceId viewId, int16 loopNo, int16 celNo, uint16 leftPos, uint16 topPos, int16 priority, uint16 paletteNo, bool hiresMode = false, reg_t upscaledHiresHandle = NULL_REG);
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 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, int16 loopNo, int16 celNo, int16 priority, 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);
virtual void editControl(reg_t controlObject, reg_t eventObject);
virtual void graphFillBoxForeground(Common::Rect rect);
virtual void graphFillBoxBackground(Common::Rect rect);
@ -150,13 +143,12 @@ protected:
private:
virtual void initPriorityBands();
virtual int getControlPicNotValid();
static void palVaryCallback(void *refCon);
void doPalVary();
AudioPlayer *_audio;
GfxAnimate *_animate;
Controls *_controls;
GfxControls *_controls;
Menu *_menu;
GfxText16 *_text16;
Transitions *_transitions;

View File

@ -173,8 +173,9 @@ Common::Error SciEngine::run() {
#ifdef ENABLE_SCI32
if (getSciVersion() >= SCI_VERSION_2) {
_gamestate->_gfxPorts = 0;
_gamestate->_gfxAnimate = 0;
_gamestate->_gfxControls = 0;
_gamestate->_gfxPorts = 0;
_gamestate->_gui = 0;
_gamestate->_gui32 = new SciGui32(_gamestate, screen, palette, cache, cursor);
} else {