[Scummvm-cvs-logs] SF.net SVN: scummvm:[44929] scummvm/trunk/engines/sci

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Sun Oct 11 17:41:53 CEST 2009


Revision: 44929
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44929&view=rev
Author:   m_kiewitz
Date:     2009-10-11 15:41:52 +0000 (Sun, 11 Oct 2009)

Log Message:
-----------
SCI/newgui: list control implemented

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kgraphics.cpp
    scummvm/trunk/engines/sci/gui/gui.cpp
    scummvm/trunk/engines/sci/gui/gui.h
    scummvm/trunk/engines/sci/gui/gui_gfx.cpp
    scummvm/trunk/engines/sci/gui/gui_gfx.h
    scummvm/trunk/engines/sci/gui32/gui32.cpp
    scummvm/trunk/engines/sci/gui32/gui32.h

Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp	2009-10-11 15:41:52 UTC (rev 44929)
@@ -1070,7 +1070,7 @@
 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 @@
 	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 @@
 	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 @@
 		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 @@
 		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 @@
 		}
 
 		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;

Modified: scummvm/trunk/engines/sci/gui/gui.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/gui/gui.cpp	2009-10-11 15:41:52 UTC (rev 44929)
@@ -360,7 +360,15 @@
 	_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) {

Modified: scummvm/trunk/engines/sci/gui/gui.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui.h	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/gui/gui.h	2009-10-11 15:41:52 UTC (rev 44929)
@@ -73,7 +73,7 @@
 	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);

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.cpp	2009-10-11 15:41:52 UTC (rev 44929)
@@ -137,6 +137,10 @@
 	_curPort->penClr = color;
 }
 
+void SciGuiGfx::BackColor(int16 color) {
+	_curPort->backClr = color;
+}
+
 void SciGuiGfx::PenMode(int16 mode) {
 	_curPort->penMode = mode;
 }
@@ -741,6 +745,57 @@
 	}
 }
 
+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;

Modified: scummvm/trunk/engines/sci/gui/gui_gfx.h
===================================================================
--- scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/gui/gui_gfx.h	2009-10-11 15:41:52 UTC (rev 44929)
@@ -66,6 +66,7 @@
 	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 @@
 	
 	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);
 

Modified: scummvm/trunk/engines/sci/gui32/gui32.cpp
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/gui32/gui32.cpp	2009-10-11 15:41:52 UTC (rev 44929)
@@ -634,7 +634,7 @@
 	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));

Modified: scummvm/trunk/engines/sci/gui32/gui32.h
===================================================================
--- scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-11 15:32:22 UTC (rev 44928)
+++ scummvm/trunk/engines/sci/gui32/gui32.h	2009-10-11 15:41:52 UTC (rev 44929)
@@ -64,7 +64,7 @@
 	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);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list