[Scummvm-cvs-logs] SF.net SVN: scummvm:[33697] scummvm/branches/gsoc2008-gui

Tanoku at users.sourceforge.net Tanoku at users.sourceforge.net
Fri Aug 8 12:38:00 CEST 2008


Revision: 33697
          http://scummvm.svn.sourceforge.net/scummvm/?rev=33697&view=rev
Author:   Tanoku
Date:     2008-08-08 10:37:58 +0000 (Fri, 08 Aug 2008)

Log Message:
-----------
SCUMM save/load dialog.
Expanded documentation.
Added support for sub-blitting in the vector renderer.

Modified Paths:
--------------
    scummvm/branches/gsoc2008-gui/engines/scumm/dialogs.cpp
    scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
    scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp
    scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
    scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
    scummvm/branches/gsoc2008-gui/gui/themes/default.inc
    scummvm/branches/gsoc2008-gui/gui/themes/modern.stx

Modified: scummvm/branches/gsoc2008-gui/engines/scumm/dialogs.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/engines/scumm/dialogs.cpp	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/engines/scumm/dialogs.cpp	2008-08-08 10:37:58 UTC (rev 33697)
@@ -39,6 +39,7 @@
 #include "gui/eval.h"
 #include "gui/newgui.h"
 #include "gui/ListWidget.h"
+#include "gui/ThemeEval.h"
 
 #include "scumm/dialogs.h"
 #include "scumm/sound.h"
@@ -233,14 +234,14 @@
 };
 
 SaveLoadChooser::SaveLoadChooser(const String &title, const String &buttonLabel, bool saveMode, ScummEngine *engine)
-	: Dialog("scummsaveload"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) {
+	: Dialog("ScummSaveLoad"), _saveMode(saveMode), _list(0), _chooseButton(0), _gfxWidget(0), _vm(engine) {
 
 	_drawingHints |= GUI::THEME_HINT_SPECIAL_COLOR;
 
-	new StaticTextWidget(this, "scummsaveload_title", title);
+	new StaticTextWidget(this, "ScummSaveload.Title", title);
 
 	// Add choice list
-	_list = new GUI::ListWidget(this, "scummsaveload_list");
+	_list = new GUI::ListWidget(this, "ScummSaveLoad.List");
 	_list->setEditable(saveMode);
 	_list->setNumberingMode(saveMode ? GUI::kListNumberingOne : GUI::kListNumberingZero);
 
@@ -254,8 +255,8 @@
 	_playtime = new StaticTextWidget(this, 0, 0, 10, 10, "No playtime saved", kTextAlignCenter);
 
 	// Buttons
-	new GUI::ButtonWidget(this, "scummsaveload_cancel", "Cancel", kCloseCmd, 0);
-	_chooseButton = new GUI::ButtonWidget(this, "scummsaveload_choose", buttonLabel, kChooseCmd, 0);
+	new GUI::ButtonWidget(this, "ScummSaveLoad.Cancel", "Cancel", kCloseCmd, 0);
+	_chooseButton = new GUI::ButtonWidget(this, "ScummSaveLoad.Choose", buttonLabel, kChooseCmd, 0);
 	_chooseButton->setEnabled(false);
 }
 
@@ -318,17 +319,22 @@
 
 void SaveLoadChooser::reflowLayout() {
 	if (g_gui.evaluator()->getVar("scummsaveload_extinfo.visible") == 1) {
-		int thumbX = g_gui.evaluator()->getVar("scummsaveload_thumbnail.x");
-		int thumbY = g_gui.evaluator()->getVar("scummsaveload_thumbnail.y");
-		int hPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.hPad");
-		int vPad = g_gui.evaluator()->getVar("scummsaveload_thumbnail.vPad");
+		int16 x, y;
+		uint16 w, h;
+		
+		if (!g_gui.xmlEval()->getWidgetData("ScummSaveLoad.Thumbnail", x, y, w, h))
+			error("Error when loading position data for Save/Load Thumbnails.");
+			
+		_container->resize(x, y, w, h);
+			
+		int thumbW = kThumbnailWidth;	
 		int thumbH = ((g_system->getHeight() % 200 && g_system->getHeight() != 350) ? kThumbnailHeight2 : kThumbnailHeight1);
+		int thumbX = x + (w >> 1) - (thumbW >> 1);
+		int thumbY = y + kLineHeight;
+		
+		_container->resize(x, y, w, h);
+		_gfxWidget->resize(thumbX, thumbY, thumbW, thumbH); 
 
-		_container->resize(thumbX - hPad, thumbY - vPad, kThumbnailWidth + hPad * 2, thumbH + vPad * 2 + kLineHeight * 4);
-
-		// Add the thumbnail display
-		_gfxWidget->resize(thumbX, thumbY, kThumbnailWidth, thumbH);
-
 		int height = thumbY + thumbH + kLineHeight;
 
 		_date->resize(thumbX, height, kThumbnailWidth, kLineHeight);
@@ -347,9 +353,9 @@
 		_time->clearFlags(GUI::WIDGET_INVISIBLE);
 		_playtime->clearFlags(GUI::WIDGET_INVISIBLE);
 
-		_fillR = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR");
-		_fillG = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG");
-		_fillB = g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB");
+		_fillR = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillR");
+		_fillG = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillG");
+		_fillB = 0; //g_gui.evaluator()->getVar("scummsaveload_thumbnail.fillB");
 		updateInfos(false);
 	} else {
 		_container->setFlags(GUI::WIDGET_INVISIBLE);

Modified: scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h
===================================================================
--- scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/graphics/VectorRenderer.h	2008-08-08 10:37:58 UTC (rev 33697)
@@ -349,8 +349,16 @@
 			_gradientFactor = factor;
 	}
 
+	/**
+	 * Translates the position data inside a DrawStep into actual
+	 * screen drawing positions.
+	 */
 	void stepGetPositions(const DrawStep &step, const Common::Rect &area, uint16 &in_x, uint16 &in_y, uint16 &in_w, uint16 &in_h);
 
+	/**
+	 * Translates the radius data inside a drawstep into the real radius
+	 * for the shape. Used for automatic radius calculations.
+	 */
 	int stepGetRadius(const DrawStep &step, const Common::Rect &area);
 
 	/**
@@ -417,34 +425,90 @@
 	virtual void drawStep(const Common::Rect &area, const DrawStep &step, uint32 extra = 0);
 
 	/**
+	 * Copies the part of the current frame to the system overlay.
+	 *
+	 * @param sys Pointer to the global System class
+	 * @param r Zone of the surface to copy into the overlay.
+	 */
+	virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0;
+	
+	/**
 	 * Copies the current surface to the system overlay 
 	 *
 	 * @param sys Pointer to the global System class
 	 */
-	virtual void copyFrame(OSystem *sys, const Common::Rect &r) = 0;
 	virtual void copyWholeFrame(OSystem *sys) = 0;
 
 	/**
 	 * Blits a given graphics surface on top of the current drawing surface.
 	 *
+	 * Note that the source surface and the active
+	 * surface are expected to be of the same size, hence the area delimited
+	 * by "r" in the source surface will be blitted into the area delimited by 
+	 * "r" on the current surface.
+	 *
+	 * If you wish to blit a smaller surface into the active drawing area, use
+	 * VectorRenderer::blitSubSurface().
+	 *
 	 * @param source Surface to blit into the drawing surface.
 	 * @param r Position in the active drawing surface to do the blitting.
 	 */
-	virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) = 0;
+	virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
 	
+	/**
+	 * Blits a given graphics surface into a small area of the current drawing surface.
+	 *
+	 * Note that the given surface is expected to be smaller than the
+	 * active drawing surface, hence the WHOLE source surface will be
+	 * blitted into the active surface, at the position specified by "r".
+	 */
+	virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) = 0;
+	
+	/**
+	 * Draws a string into the screen. Wrapper for the Graphics::Font string drawing
+	 * method.
+	 */
 	virtual void drawString(const Graphics::Font *font, const Common::String &text, const Common::Rect &area, GUI::Theme::TextAlign alignH, GUI::Theme::TextAlignVertical alignV, int deltax) = 0;
 	
+	/**
+	 * Allows to temporarily enable/disable all shadows drawing.
+	 * i.e. for performance issues, blitting, etc
+	 */
 	virtual void disableShadows() { _disableShadows = true; }
 	virtual void enableShadows() { _disableShadows = false; }
 	
+	/**
+	 * Applies a convolution matrix on the given surface area.
+	 * Call applyConvolutionMatrix() instead if you want to use
+	 * the embeded matrixes (blur/sharpen masks, bevels, etc).
+	 *
+	 * @param area Area in which the convolution matrix will be applied.
+	 * @param filter Convolution matrix (3X3)
+	 * @param filterDiv Divisor for the convolution matrix.
+	 *					Make sure this equals the total sum of the elements
+	 *					of the matrix or brightness data will be distorted.
+	 * @param offset Offset on the convolution area.
+	 */
 	virtual void areaConvolution(const Common::Rect &area, const int filter[3][3], int filterDiv, int offset) = 0;
 	
+	/**
+	 * Applies one of the predefined convolution effects on the given area.
+	 *
+	 * WARNING: Because of performance issues, this is currently disabled on all renderers.
+	 *
+	 * @param id Id of the convolution data set (see VectorRenderer::ConvolutionData)
+	 * @param area Area in which the convolution effect will be applied.
+	 */
 	virtual void applyConvolutionMatrix(const ConvolutionData id, const Common::Rect &area) {
 #ifdef ENABLE_CONVOLUTIONS
 		areaConvolution(area, _convolutionData[id].matrix, _convolutionData[id].divisor, _convolutionData[id].offset);
 #endif
 	}
 	
+	/**
+	 * Applies a whole-screen shading effect, used before opening a new dialog.
+	 * Currently supports screen dimmings and luminance (b&w).
+	 */
 	virtual void applyScreenShading(GUI::Theme::ShadingStyle) = 0;
 
 protected:
@@ -453,7 +517,7 @@
 	FillMode _fillMode; /** Defines in which way (if any) are filled the drawn shapes */
 	
 	int _shadowOffset; /** offset for drawn shadows */
-	int _bevel;
+	int _bevel; /** amount of fake bevel */
 	bool _disableShadows; /** Disables temporarily shadow drawing for overlayed images. */
 	int _strokeWidth; /** Width of the stroke of all drawn shapes */
 	uint32 _dynamicData; /** Dynamic data from the GUI Theme that modifies the drawing of the current shape */
@@ -463,7 +527,7 @@
 	
 	static const ConvolutionDataSet _convolutionData[kConvolutionMAX];
 	
-	static const int _dimPercentValue = 256 * 50 / 100;
+	static const int _dimPercentValue = 256 * 50 / 100; /** default value for screen dimming (50%) */
 };
 
 /**
@@ -607,7 +671,7 @@
 	/**
 	 * @see VectorRenderer::blitSurface()
 	 */
-	virtual void blitSurface(Graphics::Surface *source, const Common::Rect &r) {
+	virtual void blitSurface(const Graphics::Surface *source, const Common::Rect &r) {
 		PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.left, r.top);
 		PixelType *src_ptr = (PixelType *)source->getBasePtr(r.left, r.top);
 
@@ -623,6 +687,22 @@
 		}
 	}
 	
+	virtual void blitSubSurface(const Graphics::Surface *source, const Common::Rect &r) {
+		PixelType *dst_ptr = (PixelType *)_activeSurface->getBasePtr(r.left, r.top);
+		PixelType *src_ptr = (PixelType *)source->getBasePtr(0, 0);
+		
+		int dst_pitch = surfacePitch();
+		int src_pitch = source->pitch / source->bytesPerPixel;
+		
+		int h = r.height(), w = r.width();
+		
+		while (h--) {
+			colorCopy(src_ptr, dst_ptr, w);
+			dst_ptr += dst_pitch;
+			src_ptr += src_pitch;
+		}
+	}
+	
 	virtual void applyScreenShading(GUI::Theme::ShadingStyle shadingStyle) {
 		int pixels = _activeSurface->w * _activeSurface->h;
 		PixelType *ptr = (PixelType *)_activeSurface->getBasePtr(0, 0);

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.cpp	2008-08-08 10:37:58 UTC (rev 33697)
@@ -29,6 +29,7 @@
 #include "common/hashmap.h"
 #include "common/hash-str.h"
 #include "common/xmlparser.h"
+#include "graphics/scaler.h"
 
 #include "gui/ThemeRenderer.h"
 #include "gui/ThemeParser.h"
@@ -160,7 +161,23 @@
 	}
 }
 
+void ThemeEval::buildBuiltinVars() {
+	_builtin["kThumbnailWidth"] = kThumbnailWidth;
+	_builtin["kThumbnailHeight"] = kThumbnailHeight1;
+	_builtin["kThumbnailHeight2"] = kThumbnailHeight2;
+	
+	_builtin["kButtonWidth"] = GUI::kButtonWidth;
+	_builtin["kButtonHeight"] = GUI::kButtonHeight;
+	_builtin["kSliderWidth"] = GUI::kSliderWidth;
+	_builtin["kSliderHeight"] = GUI::kSliderHeight;
+	_builtin["kBigButtonWidth"] = GUI::kBigButtonWidth;
+	_builtin["kBigButtonHeight"] = GUI::kBigButtonHeight;
+	_builtin["kBigSliderWidth"] = GUI::kBigSliderWidth;
+	_builtin["kBigSliderWidth"] = GUI::kBigSliderWidth;
+	_builtin["kBigSliderHeight"] = GUI::kBigSliderHeight;	
+}
 
+
 void ThemeEval::addWidget(const Common::String &name, int w, int h, const Common::String &type, bool enabled) {	
 	int typeW = -1;
 	int typeH = -1;

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeEval.h
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeEval.h	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeEval.h	2008-08-08 10:37:58 UTC (rev 33697)
@@ -91,8 +91,7 @@
 			width += p->_paddingRight + p->_paddingLeft;
 			if (p->getLayoutType() == kLayoutHorizontal) {
 				for (uint i = 0; i < p->_children.size(); ++i)
-					if (p->_children[i]->getLayoutType() == kLayoutWidget)
-						width += p->_children[i]->getHeight() + p->_spacing;
+					width += p->_children[i]->getHeight() + p->_spacing;
 			}
 			p = p->_parent;
 		}
@@ -108,8 +107,7 @@
 			height += p->_paddingBottom + p->_paddingTop;
 			if (p->getLayoutType() == kLayoutVertical) {
 				for (uint i = 0; i < p->_children.size(); ++i)
-					if (p->_children[i]->getLayoutType() == kLayoutWidget)
-						height += p->_children[i]->getHeight() + p->_spacing;
+					height += p->_children[i]->getHeight() + p->_spacing;
 			}
 			p = p->_parent;
 		}
@@ -304,25 +302,37 @@
 	typedef Common::HashMap<Common::String, ThemeLayout*> LayoutsMap;
 	
 public:
-	ThemeEval() {}
+	ThemeEval() {
+		buildBuiltinVars();
+	}
 	~ThemeEval() {}
 	
+	void buildBuiltinVars();
+	
 	int getVar(const Common::String &s) {
-		if (!_vars.contains(s)) {
-			error("CRITICAL: Missing variable: '%s'", s.c_str());
-			return -13375; //EVAL_UNDEF_VAR
-		} 
-		
-		return _vars[s];
+		if (_vars.contains(s))
+			return _vars[s];
+			
+		if (_builtin.contains(s))
+			return _builtin[s];
+
+		error("CRITICAL: Missing variable: '%s'", s.c_str());
+		return -13375; //EVAL_UNDEF_VAR 
 	}
 	
 	int getVar(const Common::String &s, int def) {
-		return (_vars.contains(s)) ? _vars[s] : def;
+		if (_vars.contains(s))
+			return _vars[s];
+			
+		if (_builtin.contains(s))
+			return _builtin[s];
+
+		return def;
 	}
 	
 	void setVar(const String &name, int val) { _vars[name] = val; }
 	
-	bool hasVar(const Common::String &name) { return _vars.contains(name); }
+	bool hasVar(const Common::String &name) { return _vars.contains(name) || _builtin.contains(name); }
 	
 	void addDialog(const Common::String &name, const Common::String &overlays, bool enabled = true);
 	void addLayout(ThemeLayout::LayoutType type, int spacing, bool reverse, bool center = false);
@@ -365,12 +375,14 @@
 	}
 
 	void debugDraw(Graphics::Surface *screen, const Graphics::Font *font) {
-		_layouts["Dialog.ScummConfig"]->debugDraw(screen, font);
+		_layouts["Dialog.ScummSaveLoad"]->debugDraw(screen, font);
 //		_layouts["Dialog.GameOptions_Graphics"]->debugDraw(screen, font);
 	}
 	
 private:
 	VariablesMap _vars;
+	VariablesMap _builtin;
+	
 	LayoutsMap _layouts;
 	Common::Stack<ThemeLayout*> _curLayout;
 	Common::String _curDialog;

Modified: scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/gui/ThemeRenderer.cpp	2008-08-08 10:37:58 UTC (rev 33697)
@@ -592,8 +592,9 @@
 void ThemeRenderer::drawSurface(const Common::Rect &r, const Graphics::Surface &surface, WidgetStateInfo state, int alpha, bool themeTrans) {
 	if (!ready())
 		return;
-
-	debugWidgetPosition("Surface", r);
+	
+	_vectorRenderer->blitSubSurface(&surface, r);
+	addDirtyRect(r);
 }
 
 void ThemeRenderer::drawWidgetBackground(const Common::Rect &r, uint16 hints, WidgetBackground background, WidgetStateInfo state) {
@@ -718,9 +719,9 @@
 		
 	renderDirtyScreen();
 
-//	_vectorRenderer->fillSurface();
-//	themeEval()->debugDraw(_screen, _font);
-//	_vectorRenderer->copyWholeFrame(_system);
+	// _vectorRenderer->fillSurface();
+	// themeEval()->debugDraw(_screen, _font);
+	// _vectorRenderer->copyWholeFrame(_system);
 }
 
 void ThemeRenderer::renderDirtyScreen() {

Modified: scummvm/branches/gsoc2008-gui/gui/themes/default.inc
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/default.inc	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/gui/themes/default.inc	2008-08-08 10:37:58 UTC (rev 33697)
@@ -858,4 +858,27 @@
 "</layout> "
 "</layout> "
 "</dialog> "
+"<dialog name = 'ScummSaveLoad' overlays = 'screen'> "
+"<layout type = 'vertical' padding = '8, 8, 8, 8' center = 'true' direction = 'bottom2top'> "
+"<layout type = 'horizontal' padding = '0, 0, 16, 0' direction = 'right2left'> "
+"<widget name = 'Choose' "
+"type = 'Button' "
+"/> "
+"<widget name = 'Cancel' "
+"type = 'Button' "
+"/> "
+"<space/> "
+"</layout> "
+"<layout type = 'horizontal' padding = '0, 0, 0, 0' direction = 'right2left' spacing = '16'> "
+"<layout type = 'vertical' padding = '0, 0, 0, 0'> "
+"<widget name = 'Thumbnail' "
+"width = '180' "
+"height = '200' "
+"/> "
+"<space/> "
+"</layout> "
+"<widget name = 'List' /> "
+"</layout> "
+"</layout> "
+"</dialog> "
 "</layout_info> "

Modified: scummvm/branches/gsoc2008-gui/gui/themes/modern.stx
===================================================================
--- scummvm/branches/gsoc2008-gui/gui/themes/modern.stx	2008-08-08 02:49:51 UTC (rev 33696)
+++ scummvm/branches/gsoc2008-gui/gui/themes/modern.stx	2008-08-08 10:37:58 UTC (rev 33697)
@@ -938,4 +938,28 @@
 			</layout>			
 		</layout>
 	</dialog>
+	
+	<dialog name = 'ScummSaveLoad' overlays = 'screen'>
+		<layout type = 'vertical' padding = '8, 8, 8, 8' center = 'true' direction = 'bottom2top'>
+			<layout type = 'horizontal' padding = '0, 0, 16, 0' direction = 'right2left'>
+				<widget name = 'Choose'
+						type = 'Button'
+				/>
+				<widget name = 'Cancel'
+						type = 'Button'
+				/>
+				<space/>
+			</layout>
+			<layout type = 'horizontal' padding = '0, 0, 0, 0' direction = 'right2left' spacing = '16'>
+				<layout type = 'vertical' padding = '0, 0, 0, 0'>
+					<widget name = 'Thumbnail'
+							width = '180'
+							height = '200'
+					/>
+					<space/>
+				</layout>
+				<widget name = 'List' />
+			</layout>
+		</layout>
+	</dialog>
 </layout_info>
\ No newline at end of file


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