[Scummvm-cvs-logs] scummvm master -> cb9aab65b0b49770f3552bbe001be012d45827e6

dreammaster dreammaster at scummvm.org
Sat Jul 25 17:27:13 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:
cb9aab65b0 SHERLOCK: RT: Clean up handling of WidgetLab for lab table scene


Commit: cb9aab65b0b49770f3552bbe001be012d45827e6
    https://github.com/scummvm/scummvm/commit/cb9aab65b0b49770f3552bbe001be012d45827e6
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-25T11:26:09-04:00

Commit Message:
SHERLOCK: RT: Clean up handling of WidgetLab for lab table scene

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



diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index 9b5c5b2..17c27a0 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -49,7 +49,7 @@ static bool sortImagesY(const ShapeEntry &s1, const ShapeEntry &s2) {
 
 /*----------------------------------------------------------------*/
 
-TattooScene::TattooScene(SherlockEngine *vm) : Scene(vm) {
+TattooScene::TattooScene(SherlockEngine *vm) : Scene(vm), _labWidget(vm) {
 	_labTableScene = false;
 }
 
@@ -103,7 +103,7 @@ bool TattooScene::loadScene(const Common::String &filename) {
 		ui._menuMode = _labTableScene ? LAB_MODE : STD_MODE;
 
 		if (_labTableScene)
-			ui._labWidget.summonWindow();
+			ui.addFixedWidget(&_labWidget);
 	}
 
 	return result;
diff --git a/engines/sherlock/tattoo/tattoo_scene.h b/engines/sherlock/tattoo/tattoo_scene.h
index c432849..d9e4ae3 100644
--- a/engines/sherlock/tattoo/tattoo_scene.h
+++ b/engines/sherlock/tattoo/tattoo_scene.h
@@ -25,6 +25,7 @@
 
 #include "common/scummsys.h"
 #include "sherlock/scene.h"
+#include "sherlock/tattoo/widget_lab.h"
 
 namespace Sherlock {
 
@@ -46,6 +47,8 @@ struct SceneTripEntry {
 
 class TattooScene : public Scene {
 private:
+	WidgetLab _labWidget;
+
 	void doBgAnimCheckCursor();
 
 	/**
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index bbe93b5..12d097a 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -29,9 +29,20 @@ namespace Sherlock {
 
 namespace Tattoo {
 
+bool WidgetList::contains(const WidgetBase *item) const {
+	for (const_iterator i = begin(); i != end(); ++i) {
+		if ((*i) == item)
+			return true;
+	}
+
+	return false;
+}
+
+/*-------------------------------------------------------------------------*/
+
 TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm),
-		_inventoryWidget(vm), _messageWidget(vm), _textWidget(vm), _tooltipWidget(vm), _verbsWidget(vm),
-		_labWidget(vm), _creditsWidget(vm), _optionsWidget(vm), _quitWidget(vm) {
+		_inventoryWidget(vm), _messageWidget(vm), _textWidget(vm), _tooltipWidget(vm), 
+		_verbsWidget(vm), _creditsWidget(vm), _optionsWidget(vm), _quitWidget(vm) {
 	Common::fill(&_lookupTable[0], &_lookupTable[PALETTE_COUNT], 0);
 	Common::fill(&_lookupTable1[0], &_lookupTable1[PALETTE_COUNT], 0);
 	_scrollSize = 0;
@@ -224,6 +235,7 @@ void TattooUserInterface::reset() {
 	_lookPos = Common::Point(SHERLOCK_SCREEN_WIDTH / 2, SHERLOCK_SCREEN_HEIGHT / 2);
 	_tooltipWidget.setText("");
 	_widgets.clear();
+	_fixedWidgets.clear();
 }
 
 void TattooUserInterface::handleInput() {
@@ -274,6 +286,8 @@ void TattooUserInterface::handleInput() {
 	// If there's any active widgets/windows, let the most recently open one do event processing
 	if (!_widgets.empty())
 		_widgets.back()->handleEvents();
+	else if (!_fixedWidgets.empty())
+		_fixedWidgets.back()->handleEvents();
 
 	// Handle input depending on what mode we're in
 	switch (_menuMode) {
@@ -295,10 +309,13 @@ void TattooUserInterface::drawInterface(int bufferNum) {
 	Screen &screen = *_vm->_screen;
 
 	// Draw any active on-screen widgets
+	for (Common::List<WidgetBase *>::iterator i = _fixedWidgets.begin(); i != _fixedWidgets.end(); ++i)
+		(*i)->draw();
 	for (Common::List<WidgetBase *>::iterator i = _widgets.begin(); i != _widgets.end(); ++i)
 		(*i)->draw();
 
 	// Handle drawing credits
+	// TODO: See if credits are only shown on a single screen. If so, _fixedWidgets could be used
 	if (_creditsWidget.active())
 		_creditsWidget.drawCredits();
 
@@ -321,6 +338,8 @@ void TattooUserInterface::doBgAnimRestoreUI() {
 	// If there are any on-screen widgets, then erase them
 	for (Common::List<WidgetBase *>::iterator i = _widgets.begin(); i != _widgets.end(); ++i)
 		(*i)->erase();
+	for (Common::List<WidgetBase *>::iterator i = _fixedWidgets.begin(); i != _fixedWidgets.end(); ++i)
+		(*i)->erase();
 
 	// If there is a Text Tag being display, restore the area underneath it
 	_tooltipWidget.erase();
@@ -859,15 +878,8 @@ void TattooUserInterface::drawDialogRect(Surface &s, const Common::Rect &r, bool
 }
 
 void TattooUserInterface::banishWindow(bool slideUp) {
-	TattooScene &scene = *(TattooScene *)_vm->_scene;
 	if (!_widgets.empty())
 		_widgets.back()->banishWindow();
-
-	if (scene._labTableScene && !_labWidget.active()) {
-		// In the lab table scene, so ensure 
-		_labWidget.summonWindow();
-		_menuMode = LAB_MODE;
-	}
 }
 
 void TattooUserInterface::freeMenu() {
@@ -890,6 +902,11 @@ void TattooUserInterface::saveGame() {
 	files.show(SAVEMODE_SAVE);
 }
 
+void TattooUserInterface::addFixedWidget(WidgetBase *widget) {
+	_fixedWidgets.push_back(widget);
+	widget->summonWindow();
+}
+
 } // End of namespace Tattoo
 
 } // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index a5a678f..f894e2e 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -31,7 +31,6 @@
 #include "sherlock/tattoo/widget_credits.h"
 #include "sherlock/tattoo/widget_files.h"
 #include "sherlock/tattoo/widget_inventory.h"
-#include "sherlock/tattoo/widget_lab.h"
 #include "sherlock/tattoo/widget_options.h"
 #include "sherlock/tattoo/widget_quit.h"
 #include "sherlock/tattoo/widget_text.h"
@@ -48,6 +47,11 @@ class WidgetBase;
 
 enum ScrollHighlight { SH_NONE = 0, SH_SCROLL_UP = 1, SH_PAGE_UP = 2, SH_THUMBNAIL = 3, SH_PAGE_DOWN = 4, SH_SCROLL_DOWN = 5 };
 
+class WidgetList : public Common::List <WidgetBase *> {
+public:
+	bool contains(const WidgetBase *item) const;
+};
+
 class TattooUserInterface : public UserInterface {
 	friend class WidgetBase;
 private:
@@ -57,7 +61,8 @@ private:
 	WidgetInventory _inventoryWidget;
 	WidgetMessage _messageWidget;
 	WidgetQuit _quitWidget;
-	Common::List<WidgetBase *> _widgets;
+	WidgetList _fixedWidgets;
+	WidgetList _widgets;
 	byte _lookupTable[PALETTE_COUNT];
 	byte _lookupTable1[PALETTE_COUNT];
 private:
@@ -106,7 +111,6 @@ public:
 	int _maskCounter;
 	ImageFile *_interfaceImages;
 	WidgetCredits _creditsWidget;
-	WidgetLab _labWidget;
 	WidgetOptions _optionsWidget;
 	WidgetText _textWidget;
 	WidgetSceneTooltip _tooltipWidget;
@@ -216,6 +220,12 @@ public:
 	 * Show the save game dialog, and allow the user to save the game
 	 */
 	void saveGame();
+
+	/**
+	 * Add a widget to the current scene to be executed if there are no active widgets in the
+	 * main _widgets list
+	 */
+	void addFixedWidget(WidgetBase *widget);
 public:
 	/**
 	 * Resets the user interface
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index 3a4e331..ba4aee2 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -38,13 +38,12 @@ void WidgetBase::summonWindow() {
 	TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
 
 	// Double-check that the same widget isn't added twice
-	for (Common::List<WidgetBase *>::iterator i = ui._widgets.begin(); i != ui._widgets.end(); ++i) {
-		if ((*i) == this)
-			error("Tried to add a widget twice");
-	}
+	if (ui._widgets.contains(this))
+		error("Tried to add a widget multiple times");
 
 	// Add widget to the screen
-	ui._widgets.push_back(this);
+	if (!ui._fixedWidgets.contains(this))
+		ui._widgets.push_back(this);
 	_outsideMenu = false;
 
 	draw();






More information about the Scummvm-git-logs mailing list