[Scummvm-git-logs] scummvm master -> 2e4fc11320b90db0485a937ec14b3464f3195e0a

dreammaster dreammaster at scummvm.org
Wed Sep 21 13:26:33 CEST 2016


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:
2e4fc11320 XEEN: Refactored doScroll to have it available to cutscenes


Commit: 2e4fc11320b90db0485a937ec14b3464f3195e0a
    https://github.com/scummvm/scummvm/commit/2e4fc11320b90db0485a937ec14b3464f3195e0a
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-09-21T07:26:24-04:00

Commit Message:
XEEN: Refactored doScroll to have it available to cutscenes

Changed paths:
  A engines/xeen/cutscenes.cpp
  A engines/xeen/cutscenes.h
  R engines/xeen/worldofxeen/cutscenes.cpp
  R engines/xeen/worldofxeen/cutscenes.h
    engines/xeen/dialogs.cpp
    engines/xeen/dialogs.h
    engines/xeen/dialogs_automap.h
    engines/xeen/dialogs_char_info.h
    engines/xeen/dialogs_control_panel.h
    engines/xeen/dialogs_dismiss.h
    engines/xeen/dialogs_error.h
    engines/xeen/dialogs_exchange.h
    engines/xeen/dialogs_fight_options.h
    engines/xeen/dialogs_info.h
    engines/xeen/dialogs_input.h
    engines/xeen/dialogs_items.h
    engines/xeen/dialogs_party.cpp
    engines/xeen/dialogs_query.h
    engines/xeen/dialogs_quests.h
    engines/xeen/dialogs_quick_ref.h
    engines/xeen/dialogs_spells.h
    engines/xeen/dialogs_whowill.h
    engines/xeen/interface.cpp
    engines/xeen/module.mk
    engines/xeen/town.cpp
    engines/xeen/town.h
    engines/xeen/worldofxeen/clouds_cutscenes.h
    engines/xeen/worldofxeen/darkside_cutscenes.h



diff --git a/engines/xeen/cutscenes.cpp b/engines/xeen/cutscenes.cpp
new file mode 100644
index 0000000..230d574
--- /dev/null
+++ b/engines/xeen/cutscenes.cpp
@@ -0,0 +1,200 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "xeen/cutscenes.h"
+#include "xeen/xeen.h"
+
+namespace Xeen {
+
+static const char *SUBTITLE_LINE = "\xC" "35\x3" "c\xB" "190\x9" "000%s";
+
+void Cutscenes::resetSubtitles(uint lineNum, uint defaultSize) {
+	_subtitleLineNum = lineNum;
+	_subtitleSize = defaultSize;
+	recordTime();
+}
+
+void Cutscenes::showSubtitles(uint windowIndex) {
+	Screen &screen = *_vm->_screen;
+	Sound &sound = *_vm->_sound;
+
+	if (sound._soundOn || _vm->shouldQuit()) {
+		// Sound is on, so subtitles aren't needed
+		resetSubtitles(0, 0);
+	} else {
+		if (timeElapsed() > 1) {
+			++_subtitleSize;
+			const Common::String &line = _subtitles[_subtitleLineNum];
+			Common::String lineStr(line.c_str(), line.c_str() + _subtitleSize);
+			_subtitleLine = Common::String::format(SUBTITLE_LINE, lineStr.c_str());
+
+			// If displayed a full line, then move to the next line
+			if (_subtitleSize == line.size()) {
+				_subtitleSize = 0;
+				if (++_subtitleLineNum == _subtitles.size())
+					_subtitleLineNum = 0;
+			}
+		}
+
+		// Draw the box sprite
+		if (!_boxSprites)
+			// Not already loaded, so load it
+			_boxSprites = new SpriteResource("box.vga");
+		_boxSprites->draw(screen, 0, Common::Point(36, 189));
+
+		// Write the subtitle line
+		screen._windows[windowIndex].writeString(_subtitleLine);
+	}
+
+	screen.update();
+}
+
+void Cutscenes::freeSubtitles() {
+	delete _boxSprites;
+	_boxSprites = nullptr;
+	_subtitles.clear();
+}
+
+bool Cutscenes::subtitlesWait(uint minTime) {
+	EventsManager &events = *_vm->_events;
+
+	events.updateGameCounter();
+	recordTime();
+	while (events.timeElapsed() < minTime || _subtitleSize != 0) {
+		events.pollEventsAndWait();
+		if (events.isKeyMousePressed())
+			return false;
+
+		showSubtitles();
+	}
+
+	return true;
+}
+
+void Cutscenes::recordTime() {
+	_vm->_events->timeMark1();
+}
+
+uint Cutscenes::timeElapsed() {
+	return _vm->_events->timeElapsed1();
+}
+
+uint Cutscenes::getSpeakingFrame(uint minFrame, uint maxFrame) {
+	uint interval = g_system->getMillis() / 100;
+	return minFrame + interval % (maxFrame + 1 - minFrame);
+}
+
+void Cutscenes::doScroll(bool drawFlag, bool doFade) {
+	Screen &screen = *_vm->_screen;
+	EventsManager &events = *_vm->_events;
+
+	if (_vm->getGameID() != GType_Clouds) {
+		if (doFade) {
+			screen.fadeIn(2);
+		}
+		return;
+	}
+
+	const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 };
+	const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 };
+
+	screen.saveBackground();
+
+	// Load hand vga files
+	SpriteResource *hand[16];
+	for (int i = 0; i < 16; ++i) {
+		Common::String name = Common::String::format("hand%02d.vga", i);
+		hand[i] = new SpriteResource(name);
+	}
+
+	// Load marb vga files
+	SpriteResource *marb[5];
+	for (int i = 1; i < 5; ++i) {
+		Common::String name = Common::String::format("marb%02d.vga", i);
+		marb[i] = new SpriteResource(name);
+	}
+
+	if (drawFlag) {
+		for (int i = 22; i > 0; --i) {
+			events.updateGameCounter();
+			screen.restoreBackground();
+
+			if (i > 0 && i <= 14) {
+				hand[i - 1]->draw(screen, 0);
+			} else {
+				hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0), SPRFLAG_800);
+				marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0), SPRFLAG_800);
+			}
+
+			if (i <= 20) {
+				marb[i / 5]->draw(screen, i % 5);
+			}
+
+			while (!_vm->shouldQuit() && events.timeElapsed() == 0)
+				events.pollEventsAndWait();
+
+			screen._windows[0].update();
+			if (i == 0 && doFade)
+				screen.fadeIn(2);
+		}
+	} else {
+		for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) {
+			events.updateGameCounter();
+			screen.restoreBackground();
+
+			if (i < 14) {
+				hand[i]->draw(screen, 0);
+			} else {
+				hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0), SPRFLAG_800);
+				marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0), SPRFLAG_800);
+			}
+
+			if (i < 20) {
+				marb[i / 5]->draw(screen, i % 5);
+			}
+
+			while (!_vm->shouldQuit() && events.timeElapsed() == 0)
+				events.pollEventsAndWait();
+
+			screen._windows[0].update();
+			if (i == 0 && doFade)
+				screen.fadeIn(2);
+		}
+	}
+
+	if (drawFlag) {
+		hand[0]->draw(screen, 0);
+		marb[0]->draw(screen, 0);
+	} else {
+		screen.restoreBackground();
+	}
+
+	screen._windows[0].update();
+
+	// Free resources
+	for (int i = 1; i < 5; ++i)
+		delete marb[i];
+	for (int i = 0; i < 16; ++i)
+		delete hand[i];
+}
+
+} // End of namespace Xeen
diff --git a/engines/xeen/cutscenes.h b/engines/xeen/cutscenes.h
new file mode 100644
index 0000000..ba90f03
--- /dev/null
+++ b/engines/xeen/cutscenes.h
@@ -0,0 +1,93 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef XEEN_CUTSCENES_H
+#define XEEN_CUTSCENES_H
+
+#include "xeen/files.h"
+#include "xeen/sprites.h"
+
+namespace Xeen {
+
+#define WAIT(time) events.updateGameCounter(); \
+	if (events.wait(time)) \
+		return false
+
+class XeenEngine;
+
+class Cutscenes {
+protected:
+	XeenEngine *_vm;
+	StringArray _subtitles;
+	SpriteResource *_boxSprites;
+	uint _timeElapsed;
+	Common::String _subtitleLine;
+	uint _subtitleLineNum, _subtitleSize;
+protected:
+	Cutscenes(XeenEngine *vm) : _vm(vm), _timeElapsed(0), _boxSprites(nullptr),
+		_subtitleLineNum(0), _subtitleSize(0) {}
+
+	/**
+	 * Resets the subtitles position
+	 */
+	void resetSubtitles(uint lineNum, uint defaultSize = 1);
+
+	/**
+	 * Free subtitles
+	 */
+	void freeSubtitles();
+
+	/**
+	 * Shows subtitles
+	 */
+	void showSubtitles(uint windowIndex = 0);
+
+	/**
+	 * Delays either the specified number of frames, or until
+	 * an entire subtitle line is shown if subtitles are on
+	 */
+	bool subtitlesWait(uint minTime = 0);
+
+	/**
+	 * Records the current execution time
+	 */
+	void recordTime();
+
+	/**
+	 * Returns the number of ticks since the last recordTime
+	 */
+	uint timeElapsed();
+
+	/**
+	 * Get a speaking frame from a range
+	 */
+	uint getSpeakingFrame(uint minFrame, uint maxFrame);
+
+	/**
+	 * Draws the scroll in the background
+	 */
+	virtual void doScroll(bool drawFlag, bool doFade);
+};
+
+} // End of namespace Xeen
+
+#endif /* XEEN_CUTSCENES_H */
diff --git a/engines/xeen/dialogs.cpp b/engines/xeen/dialogs.cpp
index 4ecd1c7..02546ad 100644
--- a/engines/xeen/dialogs.cpp
+++ b/engines/xeen/dialogs.cpp
@@ -97,107 +97,6 @@ bool ButtonContainer::checkEvents(XeenEngine *vm) {
 	return false;
 }
 
-void ButtonContainer::doScroll(XeenEngine *vm, bool drawFlag, bool doFade) {
-	Screen &screen = *vm->_screen;
-	EventsManager &events = *vm->_events;
-
-	if (vm->getGameID() != GType_Clouds) {
-		if (doFade) {
-			screen.fadeIn(2);
-		}
-		return;
-	}
-
-	const int SCROLL_L[8] = { 29, 23, 15, 251, 245, 233, 207, 185 };
-	const int SCROLL_R[8] = { 165, 171, 198, 218, 228, 245, 264, 281 };
-
-	saveButtons();
-	clearButtons();
-	screen.saveBackground();
-
-	// Load hand vga files
-	SpriteResource *hand[16];
-	for (int i = 0; i < 16; ++i) {
-		Common::String name = Common::String::format("hand%02d.vga", i);
-		hand[i] = new SpriteResource(name);
-	}
-
-	// Load marb vga files
-	SpriteResource *marb[5];
-	for (int i = 1; i < 5; ++i) {
-		Common::String name = Common::String::format("marb%02d.vga", i);
-		marb[i] = new SpriteResource(name);
-	}
-
-	if (drawFlag) {
-		for (int i = 22; i > 0; --i) {
-			events.updateGameCounter();
-			screen.restoreBackground();
-
-			if (i > 0 && i <= 14) {
-				hand[i - 1]->draw(screen, 0);
-			}
-			else {
-				// TODO: Check '800h'.. horizontal reverse maybe?
-				hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 14], 0));
-				marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 14], 0));
-			}
-
-			if (i <= 20) {
-				marb[i / 5]->draw(screen, i % 5);
-			}
-
-			while (!vm->shouldQuit() && events.timeElapsed() == 0)
-				events.pollEventsAndWait();
-
-			screen._windows[0].update();
-			if (i == 0 && doFade)
-				screen.fadeIn(2);
-		}
-	} else {
-		for (int i = 0; i < 22 && !events.isKeyMousePressed(); ++i) {
-			events.updateGameCounter();
-			screen.restoreBackground();
-
-			if (i < 14) {
-				hand[i]->draw(screen, 0);
-			} else {
-				// TODO: Check '800h'.. horizontal reverse maybe?
-				hand[14]->draw(screen, 0, Common::Point(SCROLL_L[i - 7], 0));
-				marb[15]->draw(screen, 0, Common::Point(SCROLL_R[i - 7], 0));
-			}
-
-			if (i < 20) {
-				marb[i / 5]->draw(screen, i % 5);
-			}
-
-			while (!vm->shouldQuit() && events.timeElapsed() == 0)
-				events.pollEventsAndWait();
-
-			screen._windows[0].update();
-			if (i == 0 && doFade)
-				screen.fadeIn(2);
-		}
-	}
-
-	if (drawFlag) {
-		hand[0]->draw(screen, 0);
-		marb[0]->draw(screen, 0);
-	}
-	else {
-		screen.restoreBackground();
-	}
-
-	screen._windows[0].update();
-	restoreButtons();
-
-	// Free resources
-	for (int i = 1; i < 5; ++i)
-		delete marb[i];
-	for (int i = 0; i < 16; ++i)
-		delete hand[i];
-}
-
 void ButtonContainer::drawButtons(XSurface *surface) {
 	for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) {
 		UIButton &btn = _buttons[btnIndex];
@@ -208,6 +107,17 @@ void ButtonContainer::drawButtons(XSurface *surface) {
 	}
 }
 
+void ButtonContainer::doScroll(bool drawFlag, bool doFade) {
+	if (_vm->getGameID() == GType_Clouds) {
+		saveButtons();
+		clearButtons();
+		Cutscenes::doScroll(drawFlag, doFade);
+		restoreButtons();
+	} else {
+		Cutscenes::doScroll(drawFlag, doFade);
+	}
+}
+
 /*------------------------------------------------------------------------*/
 
 void SettingsBaseDialog::showContents(SpriteResource &title1, bool waitFlag) {
@@ -228,12 +138,12 @@ void CreditsScreen::execute() {
 	EventsManager &events = *_vm->_events;
 	
 	// Handle drawing the credits screen
-	doScroll(_vm, true, false);
+	doScroll(true, false);
 	screen._windows[GAME_WINDOW].close();
 
 	screen.loadBackground("marb.raw");
 	screen._windows[0].writeString(CREDITS);
-	doScroll(_vm, false, false);
+	doScroll(false, false);
 	
 	events.setCursor(0);
 	screen._windows[0].update();
@@ -243,7 +153,7 @@ void CreditsScreen::execute() {
 	while (!events.isKeyMousePressed())
 		events.pollEventsAndWait();
 
-	doScroll(_vm, true, false);
+	doScroll(true, false);
 }
 
 /*------------------------------------------------------------------------*/
diff --git a/engines/xeen/dialogs.h b/engines/xeen/dialogs.h
index 51eafa5..93e9a86 100644
--- a/engines/xeen/dialogs.h
+++ b/engines/xeen/dialogs.h
@@ -26,6 +26,7 @@
 #include "common/array.h"
 #include "common/stack.h"
 #include "common/rect.h"
+#include "xeen/cutscenes.h"
 #include "xeen/sprites.h"
 #include "xeen/xsurface.h"
 
@@ -46,21 +47,21 @@ public:
 	UIButton() : _value(0), _sprites(nullptr), _draw(false) {}
 };
 
-class ButtonContainer {
+class ButtonContainer : public Cutscenes {
 private:
 	Common::Stack< Common::Array<UIButton> > _savedButtons;
 protected:
 	Common::Array<UIButton> _buttons;
 	int _buttonValue;
 
+	bool checkEvents(XeenEngine *vm);
+
 	/**
 	 * Draws the scroll in the background
 	 */
-	void doScroll(XeenEngine *vm, bool drawFlag, bool doFade);
-
-	bool checkEvents(XeenEngine *vm);
+	virtual void doScroll(bool drawFlag, bool doFade);
 public:
-	ButtonContainer() : _buttonValue(0) {}
+	ButtonContainer(XeenEngine *vm) : Cutscenes(vm), _buttonValue(0) {}
 
 	/**
 	 * Saves the current list of buttons
@@ -85,20 +86,16 @@ public:
 
 class SettingsBaseDialog : public ButtonContainer {
 protected:
-	XeenEngine *_vm;
-
 	virtual void showContents(SpriteResource &title1, bool mode);
 public:
-	SettingsBaseDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	SettingsBaseDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	virtual ~SettingsBaseDialog() {}
 };
 
 class CreditsScreen: public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	CreditsScreen(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	CreditsScreen(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 public:
diff --git a/engines/xeen/dialogs_automap.h b/engines/xeen/dialogs_automap.h
index f20f9b0..239a73a 100644
--- a/engines/xeen/dialogs_automap.h
+++ b/engines/xeen/dialogs_automap.h
@@ -31,9 +31,7 @@ class XeenEngine;
 
 class AutoMapDialog: public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	AutoMapDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	AutoMapDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 public:
diff --git a/engines/xeen/dialogs_char_info.h b/engines/xeen/dialogs_char_info.h
index 90b35a9..cddd4ec 100644
--- a/engines/xeen/dialogs_char_info.h
+++ b/engines/xeen/dialogs_char_info.h
@@ -31,12 +31,11 @@ namespace Xeen {
 
 class CharacterInfo : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 	DrawStruct _drawList[24];
 	int _cursorCell;
 
-	CharacterInfo(XeenEngine *vm) : ButtonContainer(), _vm(vm), _cursorCell(0) {}
+	CharacterInfo(XeenEngine *vm) : ButtonContainer(vm), _cursorCell(0) {}
 
 	void execute(int charIndex);
 
diff --git a/engines/xeen/dialogs_control_panel.h b/engines/xeen/dialogs_control_panel.h
index 16c3781..ef86acf 100644
--- a/engines/xeen/dialogs_control_panel.h
+++ b/engines/xeen/dialogs_control_panel.h
@@ -29,9 +29,7 @@ namespace Xeen {
 
 class ControlPanel : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	ControlPanel(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	ControlPanel(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute();
 public:
diff --git a/engines/xeen/dialogs_dismiss.h b/engines/xeen/dialogs_dismiss.h
index ec40e87..7b73fc6 100644
--- a/engines/xeen/dialogs_dismiss.h
+++ b/engines/xeen/dialogs_dismiss.h
@@ -30,10 +30,9 @@ namespace Xeen {
 
 class Dismiss : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	Dismiss(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	Dismiss(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 
diff --git a/engines/xeen/dialogs_error.h b/engines/xeen/dialogs_error.h
index 46efdb1..56e30bc 100644
--- a/engines/xeen/dialogs_error.h
+++ b/engines/xeen/dialogs_error.h
@@ -33,9 +33,7 @@ enum ErrorWaitType { WT_FREEZE_WAIT = 0, WT_NONFREEZED_WAIT = 1,
 
 class ErrorDialog : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	ErrorDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	ErrorDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute(const Common::String &msg, ErrorWaitType waitType);
 public:
@@ -51,9 +49,7 @@ public:
 
 class CantCast: public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	CantCast(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	CantCast(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute(int spellId, int componentNum);
 public:
diff --git a/engines/xeen/dialogs_exchange.h b/engines/xeen/dialogs_exchange.h
index e8c4a2d..e67c315 100644
--- a/engines/xeen/dialogs_exchange.h
+++ b/engines/xeen/dialogs_exchange.h
@@ -30,10 +30,9 @@ namespace Xeen {
 
 class ExchangeDialog : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	ExchangeDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	ExchangeDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute(Character *&c, int &charIndex);
 
diff --git a/engines/xeen/dialogs_fight_options.h b/engines/xeen/dialogs_fight_options.h
index 7b058bc..823a716 100644
--- a/engines/xeen/dialogs_fight_options.h
+++ b/engines/xeen/dialogs_fight_options.h
@@ -29,9 +29,7 @@ namespace Xeen {
 
 class FightOptions : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	FightOptions(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	FightOptions(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 public:
diff --git a/engines/xeen/dialogs_info.h b/engines/xeen/dialogs_info.h
index 66b9157..68c8403 100644
--- a/engines/xeen/dialogs_info.h
+++ b/engines/xeen/dialogs_info.h
@@ -30,10 +30,9 @@ namespace Xeen {
 
 class InfoDialog : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	Common::StringArray _lines;
 
-	InfoDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	InfoDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 
diff --git a/engines/xeen/dialogs_input.h b/engines/xeen/dialogs_input.h
index e824d17..ce159c7 100644
--- a/engines/xeen/dialogs_input.h
+++ b/engines/xeen/dialogs_input.h
@@ -36,7 +36,6 @@ private:
 	 */
 	Common::KeyCode doCursor(const Common::String &msg);
 protected:
-	XeenEngine *_vm;
 	Window *_window;
 
 	/**
@@ -44,7 +43,7 @@ protected:
 	 */
 	int getString(Common::String &line, uint maxLen, int maxWidth, bool isNumeric);
 
-	Input(XeenEngine *vm, Window *window) : _vm(vm), _window(window) {}
+	Input(XeenEngine *vm, Window *window) : ButtonContainer(vm), _window(window) {}
 public:
 	static int show(XeenEngine *vm, Window *window, Common::String &line, 
 		uint maxLen, int maxWidth, bool isNumeric = false);
@@ -72,10 +71,9 @@ public:
 
 class Choose123 : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	Choose123(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	Choose123(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute(int numOptions);
 
diff --git a/engines/xeen/dialogs_items.h b/engines/xeen/dialogs_items.h
index 6069ca8..c161b07 100644
--- a/engines/xeen/dialogs_items.h
+++ b/engines/xeen/dialogs_items.h
@@ -37,15 +37,13 @@ enum ItemsMode {
 
 class ItemsDialog : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 	SpriteResource _equipSprites;
 	Character _itemsCharacter;
 	Character *_oldCharacter;
 	DrawStruct _itemsDrawList[INV_ITEMS_TOTAL];
 
-	ItemsDialog(XeenEngine *vm) : ButtonContainer(), 
-		_vm(vm), _oldCharacter(nullptr) {}
+	ItemsDialog(XeenEngine *vm) : ButtonContainer(vm), _oldCharacter(nullptr) {}
 
 	Character *execute(Character *c, ItemsMode mode);
 
diff --git a/engines/xeen/dialogs_party.cpp b/engines/xeen/dialogs_party.cpp
index ced778f..a297ed5 100644
--- a/engines/xeen/dialogs_party.cpp
+++ b/engines/xeen/dialogs_party.cpp
@@ -32,7 +32,7 @@
 
 namespace Xeen {
 
-PartyDialog::PartyDialog(XeenEngine *vm) : ButtonContainer(), 
+PartyDialog::PartyDialog(XeenEngine *vm) : ButtonContainer(vm), 
 		PartyDrawer(vm), _vm(vm) {
 	initDrawStructs();
 }
@@ -93,7 +93,7 @@ void PartyDialog::execute() {
 				screen._windows[0].update();
 			}
 
-			doScroll(_vm, false, false);
+			doScroll(false, false);
 			events.setCursor(0);
 
 			if (_vm->getGameID() == GType_DarkSide) {
diff --git a/engines/xeen/dialogs_query.h b/engines/xeen/dialogs_query.h
index 96ae488..0b9b268 100644
--- a/engines/xeen/dialogs_query.h
+++ b/engines/xeen/dialogs_query.h
@@ -29,9 +29,7 @@ namespace Xeen {
 
 class Confirm : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	Confirm(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	Confirm(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	bool execute(const Common::String &msg, int mode);
 public:
@@ -40,9 +38,7 @@ public:
 
 class YesNo : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	YesNo(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	YesNo(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	bool execute(bool type, bool townFlag);
 public:
diff --git a/engines/xeen/dialogs_quests.h b/engines/xeen/dialogs_quests.h
index 234accd..dd1461f 100644
--- a/engines/xeen/dialogs_quests.h
+++ b/engines/xeen/dialogs_quests.h
@@ -30,11 +30,10 @@ namespace Xeen {
 
 class Quests : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 	Common::StringArray _questNotes;
 
-	Quests(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	Quests(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 
diff --git a/engines/xeen/dialogs_quick_ref.h b/engines/xeen/dialogs_quick_ref.h
index 0c1b8e3..eaafd99 100644
--- a/engines/xeen/dialogs_quick_ref.h
+++ b/engines/xeen/dialogs_quick_ref.h
@@ -29,9 +29,7 @@ namespace Xeen {
 
 class QuickReferenceDialog : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	QuickReferenceDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	QuickReferenceDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 public:
diff --git a/engines/xeen/dialogs_spells.h b/engines/xeen/dialogs_spells.h
index 35b2708..3ccdb83 100644
--- a/engines/xeen/dialogs_spells.h
+++ b/engines/xeen/dialogs_spells.h
@@ -41,12 +41,11 @@ struct SpellEntry {
 
 class SpellsDialog : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 	SpriteResource _scrollSprites;
 	Common::Array<SpellEntry> _spells;
 
-	SpellsDialog(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	SpellsDialog(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	Character *execute(ButtonContainer *priorDialog, Character *c, int isCasting);
 
@@ -60,10 +59,9 @@ public:
 
 class CastSpell : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	CastSpell(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	CastSpell(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute(Character *&c);
 
@@ -75,9 +73,7 @@ public:
 
 class SpellOnWho : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	SpellOnWho(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	SpellOnWho(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute(int spellId);
 public:
@@ -86,10 +82,9 @@ public:
 
 class SelectElement : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	SelectElement(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	SelectElement(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute(int spellId);
 
@@ -100,9 +95,7 @@ public:
 
 class NotWhileEngaged : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	NotWhileEngaged(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	NotWhileEngaged(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute(int spellId);
 public:
@@ -111,10 +104,9 @@ public:
 
 class LloydsBeacon : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	LloydsBeacon(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	LloydsBeacon(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	bool execute();
 
@@ -125,10 +117,9 @@ public:
 
 class Teleport : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	Teleport(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	Teleport(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute();
 public:
@@ -137,9 +128,7 @@ public:
 
 class TownPortal : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	TownPortal(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	TownPortal(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute();
 public:
@@ -148,9 +137,7 @@ public:
 
 class IdentifyMonster : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	IdentifyMonster(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	IdentifyMonster(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	void execute();
 public:
diff --git a/engines/xeen/dialogs_whowill.h b/engines/xeen/dialogs_whowill.h
index 8080c36..8018cbb 100644
--- a/engines/xeen/dialogs_whowill.h
+++ b/engines/xeen/dialogs_whowill.h
@@ -29,9 +29,7 @@ namespace Xeen {
 
 class WhoWill : public ButtonContainer {
 private:
-	XeenEngine *_vm;
-
-	WhoWill(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	WhoWill(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	int execute(int message, int action, bool type);
 public:
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 6c09b05..8bf9098 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -130,7 +130,7 @@ void PartyDrawer::resetHighlight() {
 }
 /*------------------------------------------------------------------------*/
 
-Interface::Interface(XeenEngine *vm) : ButtonContainer(), InterfaceMap(vm), 
+Interface::Interface(XeenEngine *vm) : ButtonContainer(vm), InterfaceMap(vm), 
 		PartyDrawer(vm), _vm(vm) {
 	_buttonsLoaded = false;
 	_intrIndex1 = 0;
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index 833b8cf..968a30c 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -1,12 +1,12 @@
 MODULE := engines/xeen
 
 MODULE_OBJS := \
-	worldofxeen/cutscenes.o \
 	worldofxeen/clouds_cutscenes.o \
 	worldofxeen/darkside_cutscenes.o \
 	worldofxeen/worldofxeen.o \
 	character.o \
 	combat.o \
+	cutscenes.o \
 	debugger.o \
 	detection.o \
 	dialogs.o \
diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp
index 1947129..1fe0487 100644
--- a/engines/xeen/town.cpp
+++ b/engines/xeen/town.cpp
@@ -30,7 +30,7 @@
 
 namespace Xeen {
 
-Town::Town(XeenEngine *vm) : _vm(vm) {
+Town::Town(XeenEngine *vm) : ButtonContainer(vm) {
 	Common::fill(&_arr1[0], &_arr1[6], 0);
 	_townMaxId = 0;
 	_townActionId = 0;
diff --git a/engines/xeen/town.h b/engines/xeen/town.h
index f56f24c..0767638 100644
--- a/engines/xeen/town.h
+++ b/engines/xeen/town.h
@@ -37,7 +37,6 @@ class TownMessage;
 class Town: public ButtonContainer {
 	friend class TownMessage;
 private:
-	XeenEngine *_vm;
 	SpriteResource _icons1, _icons2;
 	Common::StringArray _textStrings;
 	Common::Array<SpriteResource> _townSprites;
@@ -114,10 +113,9 @@ public:
 
 class TownMessage : public ButtonContainer {
 private:
-	XeenEngine *_vm;
 	SpriteResource _iconSprites;
 
-	TownMessage(XeenEngine *vm) : ButtonContainer(), _vm(vm) {}
+	TownMessage(XeenEngine *vm) : ButtonContainer(vm) {}
 
 	bool execute(int portrait, const Common::String &name, 
 		const Common::String &text, int confirm);
diff --git a/engines/xeen/worldofxeen/clouds_cutscenes.h b/engines/xeen/worldofxeen/clouds_cutscenes.h
index ff935a7..1440458 100644
--- a/engines/xeen/worldofxeen/clouds_cutscenes.h
+++ b/engines/xeen/worldofxeen/clouds_cutscenes.h
@@ -23,7 +23,7 @@
 #ifndef XEEN_WORLDOFXEEN_CLOUDS_CUTSCENES_H
 #define XEEN_WORLDOFXEEN_CLOUDS_CUTSCENES_H
 
-#include "xeen/worldofxeen/cutscenes.h"
+#include "xeen/cutscenes.h"
 #include "xeen/xeen.h"
 
 namespace Xeen {
diff --git a/engines/xeen/worldofxeen/cutscenes.cpp b/engines/xeen/worldofxeen/cutscenes.cpp
deleted file mode 100644
index 9710704..0000000
--- a/engines/xeen/worldofxeen/cutscenes.cpp
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#include "xeen/worldofxeen/cutscenes.h"
-#include "xeen/xeen.h"
-
-namespace Xeen {
-
-static const char *SUBTITLE_LINE = "\xC" "35\x3" "c\xB" "190\x9" "000%s";
-
-void Cutscenes::resetSubtitles(uint lineNum, uint defaultSize) {
-	_subtitleLineNum = lineNum;
-	_subtitleSize = defaultSize;
-	recordTime();
-}
-
-void Cutscenes::showSubtitles(uint windowIndex) {
-	Screen &screen = *_vm->_screen;
-	Sound &sound = *_vm->_sound;
-
-	if (sound._soundOn || _vm->shouldQuit()) {
-		// Sound is on, so subtitles aren't needed
-		resetSubtitles(0, 0);
-	} else {
-		if (timeElapsed() > 1) {
-			++_subtitleSize;
-			const Common::String &line = _subtitles[_subtitleLineNum];
-			Common::String lineStr(line.c_str(), line.c_str() + _subtitleSize);
-			_subtitleLine = Common::String::format(SUBTITLE_LINE, lineStr.c_str());
-
-			// If displayed a full line, then move to the next line
-			if (_subtitleSize == line.size()) {
-				_subtitleSize = 0;
-				if (++_subtitleLineNum == _subtitles.size())
-					_subtitleLineNum = 0;
-			}
-		}
-
-		// Draw the box sprite
-		if (!_boxSprites)
-			// Not already loaded, so load it
-			_boxSprites = new SpriteResource("box.vga");
-		_boxSprites->draw(screen, 0, Common::Point(36, 189));
-
-		// Write the subtitle line
-		screen._windows[windowIndex].writeString(_subtitleLine);
-	}
-
-	screen.update();
-}
-
-void Cutscenes::freeSubtitles() {
-	delete _boxSprites;
-	_boxSprites = nullptr;
-	_subtitles.clear();
-}
-
-bool Cutscenes::subtitlesWait(uint minTime) {
-	EventsManager &events = *_vm->_events;
-
-	events.updateGameCounter();
-	recordTime();
-	while (events.timeElapsed() < minTime || _subtitleSize != 0) {
-		events.pollEventsAndWait();
-		if (events.isKeyMousePressed())
-			return false;
-
-		showSubtitles();
-	}
-
-	return true;
-}
-
-void Cutscenes::recordTime() {
-	_vm->_events->timeMark1();
-}
-
-uint Cutscenes::timeElapsed() {
-	return _vm->_events->timeElapsed1();
-}
-
-uint Cutscenes::getSpeakingFrame(uint minFrame, uint maxFrame) {
-	uint interval = g_system->getMillis() / 100;
-	return minFrame + interval % (maxFrame + 1 - minFrame);
-}
-
-} // End of namespace Xeen
diff --git a/engines/xeen/worldofxeen/cutscenes.h b/engines/xeen/worldofxeen/cutscenes.h
deleted file mode 100644
index f4cb18e..0000000
--- a/engines/xeen/worldofxeen/cutscenes.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef XEEN_WORLDOFXEEN_CUTSCENES_H
-#define XEEN_WORLDOFXEEN_CUTSCENES_H
-
-#include "xeen/files.h"
-#include "xeen/sprites.h"
-
-namespace Xeen {
-
-#define WAIT(time) events.updateGameCounter(); \
-	if (events.wait(time)) \
-		return false
-
-class XeenEngine;
-
-class Cutscenes {
-protected:
-	XeenEngine *_vm;
-	StringArray _subtitles;
-	SpriteResource *_boxSprites;
-	uint _timeElapsed;
-	Common::String _subtitleLine;
-	uint _subtitleLineNum, _subtitleSize;
-protected:
-	Cutscenes(XeenEngine *vm) : _vm(vm), _timeElapsed(0), _boxSprites(nullptr),
-		_subtitleLineNum(0), _subtitleSize(0) {}
-
-	/**
-	 * Resets the subtitles position
-	 */
-	void resetSubtitles(uint lineNum, uint defaultSize = 1);
-
-	/**
-	 * Free subtitles
-	 */
-	void freeSubtitles();
-
-	/**
-	 * Shows subtitles
-	 */
-	void showSubtitles(uint windowIndex = 0);
-
-	/**
-	 * Delays either the specified number of frames, or until
-	 * an entire subtitle line is shown if subtitles are on
-	 */
-	bool subtitlesWait(uint minTime = 0);
-
-	/**
-	 * Records the current execution time
-	 */
-	void recordTime();
-
-	/**
-	 * Returns the number of ticks since the last recordTime
-	 */
-	uint timeElapsed();
-
-	/**
-	 * Get a speaking frame from a range
-	 */
-	uint getSpeakingFrame(uint minFrame, uint maxFrame);
-};
-
-} // End of namespace Xeen
-
-#endif /* XEEN_WORLDOFXEEN_CUTSCENES_H */
diff --git a/engines/xeen/worldofxeen/darkside_cutscenes.h b/engines/xeen/worldofxeen/darkside_cutscenes.h
index cbd9610..7c6a1bf 100644
--- a/engines/xeen/worldofxeen/darkside_cutscenes.h
+++ b/engines/xeen/worldofxeen/darkside_cutscenes.h
@@ -23,7 +23,7 @@
 #ifndef XEEN_WORLDOFXEEN_DARKSIDE_CUTSCENES_H
 #define XEEN_WORLDOFXEEN_DARKSIDE_CUTSCENES_H
 
-#include "xeen/worldofxeen/cutscenes.h"
+#include "xeen/cutscenes.h"
 
 namespace Xeen {
 





More information about the Scummvm-git-logs mailing list