[Scummvm-cvs-logs] scummvm master -> 1d16677e3571add7baefecb9ee630e2e99e8e48d

dreammaster dreammaster at scummvm.org
Sun Jul 26 03:27:01 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
1d16677e35 SHERLOCK: RT: Implemented rendering of Files dialog


Commit: 1d16677e3571add7baefecb9ee630e2e99e8e48d
    https://github.com/scummvm/scummvm/commit/1d16677e3571add7baefecb9ee630e2e99e8e48d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-25T21:25:59-04:00

Commit Message:
SHERLOCK: RT: Implemented rendering of Files dialog

Changed paths:
    engines/sherlock/tattoo/tattoo_user_interface.cpp
    engines/sherlock/tattoo/tattoo_user_interface.h
    engines/sherlock/tattoo/widget_base.cpp
    engines/sherlock/tattoo/widget_base.h
    engines/sherlock/tattoo/widget_files.cpp
    engines/sherlock/tattoo/widget_files.h



diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 12d097a..6c40323 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -297,9 +297,6 @@ void TattooUserInterface::handleInput() {
 	case LOOK_MODE:
 		doLookControl();
 		break;
-	case FILES_MODE:
-		doFileControl();
-		break;
 	default:
 		break;
 	}
@@ -542,10 +539,6 @@ void TattooUserInterface::doLookControl() {
 	}
 }
 
-void TattooUserInterface::doFileControl() {
-	warning("TODO: ui control (file)");
-}
-
 void TattooUserInterface::displayObjectNames() {
 	Events &events = *_vm->_events;
 	Scene &scene = *_vm->_scene;
@@ -564,10 +557,6 @@ void TattooUserInterface::displayObjectNames() {
 	_oldArrowZone = _arrowZone;
 }
 
-void TattooUserInterface::initFileMenu() {
-	// TODO
-}
-
 void TattooUserInterface::doInventory(int mode) {
 	People &people = *_vm->_people;
 	people[HOLMES].gotoStand();
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index f894e2e..f8c00569 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -87,11 +87,6 @@ private:
 	void doVerbControl();
 
 	/**
-	 * Set up to display the Files menu
-	 */
-	void initFileMenu();
-
-	/**
 	 * Free any active menu
 	 */
 	void freeMenu();
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index ba4aee2..60d057e 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -223,15 +223,18 @@ void WidgetBase::checkTabbingKeys(int numOptions) {
 }
 
 void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
+	Common::Rect r(BUTTON_SIZE, _bounds.height() - 6);
+	r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3);
+	drawScrollBar(index, pageSize, count, r);
+}
+
+void WidgetBase::drawScrollBar(int index, int pageSize, int count, const Common::Rect &r) {
 	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
-	bool raised;
 
 	// Fill the area with transparency
-	Common::Rect r(BUTTON_SIZE, _bounds.height() - 6);
-	r.moveTo(_bounds.width() - BUTTON_SIZE - 3, 3);
 	_surface.fillRect(r, TRANSPARENCY);
 
-	raised = ui._scrollHighlight != 1;
+	bool raised = ui._scrollHighlight != 1;
 	_surface.fillRect(Common::Rect(r.left + 2, r.top + 2, r.right - 2, r.top + BUTTON_SIZE - 2), INFO_MIDDLE);
 	ui.drawDialogRect(_surface, Common::Rect(r.left, r.top, r.left + BUTTON_SIZE, r.top + BUTTON_SIZE), raised);
 
@@ -269,6 +272,10 @@ void WidgetBase::drawScrollBar(int index, int pageSize, int count) {
 }
 
 void WidgetBase::handleScrollbarEvents(int index, int pageSize, int count) {
+	handleScrollbarEvents(index, pageSize, count, Common::Rect(_bounds.right - BUTTON_SIZE - 3, _bounds.top + 3, _bounds.right - 3, _bounds.bottom - 3));
+}
+
+void WidgetBase::handleScrollbarEvents(int index, int pageSize, int count, const Common::Rect &r) {
 	Events &events = *_vm->_events;
 	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
 	Common::Point mousePos = events.mousePos();
@@ -282,8 +289,6 @@ void WidgetBase::handleScrollbarEvents(int index, int pageSize, int count) {
 	if ((!events._pressed && !events._rightReleased) || !_scroll)
 		return;
 
-	Common::Rect r(_bounds.right - BUTTON_SIZE - 3, _bounds.top + 3, _bounds.right - 3, _bounds.bottom - 3);
-
 	// Calculate the Scroll Position bar
 	int barHeight = (_bounds.height() - BUTTON_SIZE * 2) * pageSize / count;
 	barHeight = CLIP(barHeight, BUTTON_SIZE, _bounds.height() - BUTTON_SIZE * 2);
diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h
index 401dba6..87f513e 100644
--- a/engines/sherlock/tattoo/widget_base.h
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -75,11 +75,21 @@ protected:
 	void drawScrollBar(int index, int pageSize, int count);
 
 	/**
+	 * Draw a scrollbar for the dialog in a specified area
+	 */
+	void drawScrollBar(int index, int pageSize, int count, const Common::Rect &r);
+
+	/**
 	 * Handles any events when the mouse is on the scrollbar
 	 */
 	void handleScrollbarEvents(int index, int pageSize, int count);
 
 	/**
+	 * Handles any events when the mouse is on the scrollbar
+	 */
+	void handleScrollbarEvents(int index, int pageSize, int count, const Common::Rect &r);
+
+	/**
 	 * Close the dialog
 	 */
 	void close();
diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp
index 0666e17..21dd108 100644
--- a/engines/sherlock/tattoo/widget_files.cpp
+++ b/engines/sherlock/tattoo/widget_files.cpp
@@ -32,9 +32,13 @@ namespace Sherlock {
 
 namespace Tattoo {
 
+#define FILES_LINES_COUNT 5
+
 WidgetFiles::WidgetFiles(SherlockEngine *vm, const Common::String &target) :
 		SaveManager(vm, target), WidgetBase(vm), _vm(vm) {
 	_fileMode = SAVEMODE_NONE;
+	_selector = _oldSelector = -1;
+	savegameIndex = 0;
 }
 
 void WidgetFiles::show(SaveMode mode) {
@@ -45,7 +49,19 @@ void WidgetFiles::show(SaveMode mode) {
 	if (_vm->_showOriginalSavesDialog) {
 		// Render and display the file dialog
 		_fileMode = mode;
-		render();
+		ui._menuMode = FILES_MODE;
+		_selector = _oldSelector = -1;
+		_scroll = true;
+		createSavegameList();
+
+		// Set up the display area
+		_bounds = Common::Rect(SHERLOCK_SCREEN_WIDTH * 2 / 3, (_surface.fontHeight() + 1) * 
+			(FILES_LINES_COUNT + 1) + 17);
+		_bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2);
+
+		// Create the surface and render it's contents
+		_surface.create(_bounds.width(), _bounds.height());
+		render(RENDER_ALL);
 
 		summonWindow();
 		ui._menuMode = FILES_MODE;
@@ -86,34 +102,88 @@ void WidgetFiles::showScummVMRestoreDialog() {
 	}
 }
 
-void WidgetFiles::render() {
-	Events &events = *_vm->_events;
-	Common::Point mousePos = events.mousePos();
+void WidgetFiles::render(FilesRenderMode mode) {
+	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+	ImageFile &images = *ui._interfaceImages;
+	byte color;
+
+	if (mode == OP_ALL) {
+		_surface.fill(TRANSPARENCY);
+		makeInfoArea();
+
+		switch (_fileMode) {
+		case SAVEMODE_LOAD:
+			_surface.writeString(FIXED(LoadGame),
+				Common::Point((_surface.w() - _surface.stringWidth(FIXED(LoadGame))) / 2, 5), INFO_TOP);
+			break;
+
+		case SAVEMODE_SAVE:
+			_surface.writeString(FIXED(SaveGame),
+				Common::Point((_surface.w() - _surface.stringWidth(FIXED(SaveGame))) / 2, 5), INFO_TOP);
+			break;
+
+		default:
+			break;
+		}
 
-	createSavegameList();
+		_surface.hLine(3, _surface.fontHeight() + 7, _surface.w() - 4, INFO_TOP);
+		_surface.hLine(3, _surface.fontHeight() + 8, _surface.w() - 4, INFO_MIDDLE);
+		_surface.hLine(3, _surface.fontHeight() + 9, _surface.w() - 4, INFO_BOTTOM);
+		_surface.transBlitFrom(images[4], Common::Point(0, _surface.fontHeight() + 6));
+		_surface.transBlitFrom(images[5], Common::Point(_surface.w() - images[5]._width, _surface.fontHeight() + 6));
+
+		int xp = _surface.w() - BUTTON_SIZE - 6;
+		_surface.vLine(xp, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_TOP);
+		_surface.vLine(xp + 1, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_MIDDLE);
+		_surface.vLine(xp + 2, _surface.fontHeight() + 10, _bounds.height() - 4, INFO_BOTTOM);
+		_surface.transBlitFrom(images[6], Common::Point(xp - 1, _surface.fontHeight() + 8));
+		_surface.transBlitFrom(images[7], Common::Point(xp - 1, _bounds.height() - 4));
+	}
+
+	int xp = _surface.stringWidth("00.") + _surface.widestChar() + 5;
+	int yp = _surface.fontHeight() + 14;
+	
+	for (int idx = _savegameIndex; idx < (_savegameIndex + FILES_LINES_COUNT); ++idx) {
+		if (OP_NAMES || idx == _selector || idx == _oldSelector) {
+			if (idx == _selector && mode != OP_ALL)
+				color = COMMAND_HIGHLIGHTED;
+			else
+				color = INFO_TOP;
+
+			if (mode == RENDER_NAMES_AND_SCROLLBAR)
+				_surface.fillRect(Common::Rect(4, yp, _surface.w() - BUTTON_SIZE - 9, yp + _surface.fontHeight() - 1), TRANSPARENCY);
+			
+			Common::String numStr = Common::String::format("%d.", idx + 1);
+			_surface.writeString(numStr, Common::Point(_surface.widestChar(), yp), color);
+			_surface.writeString(_savegames[idx], Common::Point(xp, yp), color);
+		}
 
-	// Set up the display area
-	_bounds = Common::Rect(_surface.stringWidth(FIXED(AreYouSureYou)) + _surface.widestChar() * 2,
-		(_surface.fontHeight() + 7) * 4);
-	_bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2);
+		yp += _surface.fontHeight() + 1;
+	}
 
-	// Create the surface
-	_surface.create(_bounds.width(), _bounds.height());
-	_surface.fill(TRANSPARENCY);
-	makeInfoArea();
+	// Draw the Scrollbar if neccessary
+	if (mode != RENDER_NAMES) {
+		Common::Rect scrollRect(BUTTON_SIZE, _bounds.height() - _surface.fontHeight() - 16);
+		scrollRect.moveTo(_bounds.width() - BUTTON_SIZE - 3, _surface.fontHeight() + 13);
+		drawScrollBar(_savegameIndex, FILES_LINES_COUNT, _savegames.size(), scrollRect);
+	}
 }
 
 void WidgetFiles::handleEvents() {
 	//Events &events = *_vm->_events;
+	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
 
-}
+	// Handle scrollbar events
+	ScrollHighlight oldHighlight = ui._scrollHighlight;	
+	Common::Rect scrollRect(BUTTON_SIZE, _bounds.height() - _surface.fontHeight() - 16);
+	scrollRect.moveTo(_bounds.right - BUTTON_SIZE - 3, _bounds.top + _surface.fontHeight() + 13);
+	handleScrollbarEvents(_savegameIndex, FILES_LINES_COUNT, _savegames.size(), scrollRect);
 
-void WidgetFiles::close() {
-	TattooScene &scene = *(TattooScene *)_vm->_scene;
-	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+	// If the highlight has changed, redraw the scrollbar
+	if (ui._scrollHighlight != oldHighlight)
+		render(RENDER_NAMES_AND_SCROLLBAR);
 
-	banishWindow();
-	ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+	// TODO
 }
 
 } // End of namespace Tattoo
diff --git a/engines/sherlock/tattoo/widget_files.h b/engines/sherlock/tattoo/widget_files.h
index 495a95c..bf4eb85 100644
--- a/engines/sherlock/tattoo/widget_files.h
+++ b/engines/sherlock/tattoo/widget_files.h
@@ -33,20 +33,19 @@ class SherlockEngine;
 
 namespace Tattoo {
 
+enum FilesRenderMode { RENDER_ALL, RENDER_NAMES, RENDER_NAMES_AND_SCROLLBAR };
+
 class WidgetFiles: public WidgetBase, public SaveManager {
 private:
 	SherlockEngine *_vm;
 	SaveMode _fileMode;
+	int _selector, _oldSelector;
+	int savegameIndex;
 
 	/**
 	 * Render the dialog
 	 */
-	void render();
-
-	/**
-	 * Close the dialog
-	 */
-	void close();
+	void render(FilesRenderMode mode);
 
 	/**
 	 * Show the ScummVM Save Game dialog






More information about the Scummvm-git-logs mailing list