[Scummvm-git-logs] scummvm master -> 04cf0aa569becda57c29bbdbb4e0295ec2bd7e3b

dreammaster noreply at scummvm.org
Mon Feb 27 06:24:32 UTC 2023


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

Summary:
0a4d59b5b7 MM: MM1: Change location animations to a class structure
f9543cba7a MM: Move Sound class into Shared namespace
181eab7a06 MM: MM1: Derive Sound class from now shared Sound class
cd5962252e MM: MM1: Cleanup of Market view
d400775f49 MM: MM1: Sort animation views alphabetically
1a15f86d1a MM: MM1: Fixing game messages display
4590fe3443 MM: MM1: Fixes for location enter/exit
650d4f7edc MM: MM1: Fix center aligning signs
04cf0aa569 MM: MM1: Fix party highlight in market view


Commit: 0a4d59b5b769a8bf8a462eb78f3759a0aa3a6668
    https://github.com/scummvm/scummvm/commit/0a4d59b5b769a8bf8a462eb78f3759a0aa3a6668
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:49-08:00

Commit Message:
MM: MM1: Change location animations to a class structure

Changed paths:
    engines/mm/mm1/views_enh/game_view.cpp
    engines/mm/mm1/views_enh/game_view.h


diff --git a/engines/mm/mm1/views_enh/game_view.cpp b/engines/mm/mm1/views_enh/game_view.cpp
index 7db06e54dfd..7a50ef6314f 100644
--- a/engines/mm/mm1/views_enh/game_view.cpp
+++ b/engines/mm/mm1/views_enh/game_view.cpp
@@ -27,20 +27,62 @@ namespace ViewsEnh {
 
 #define TICKS_PER_FRAME 4
 
-struct LocationEntry {
-	const char *const _prefix;
-	uint _count;
-	uint _frameCount;
+namespace Animations {
+
+ViewAnimation::ViewAnimation(const char *prefix, uint count, uint frameCount) :
+		_frameCount(frameCount) {
+	_backgrounds.resize(count);
+
+	for (uint i = 0; i < _backgrounds.size(); ++i) {
+		Common::String name = Common::String::format(
+			"%s%d.twn", prefix, i + 1);
+		_backgrounds[i].load(name);
+	}
+}
+
+void ViewAnimation::tick() {
+	_frameIndex = (_frameIndex + 1) % _frameCount;
+}
+
+void ViewAnimation::draw(Graphics::ManagedSurface &s) {
+	_backgrounds[_frameIndex / 8].draw(&s, _frameIndex % 8,
+		Common::Point(0, 0));
+}
+
+class Training : public ViewAnimation {
+public:
+	Training() : ViewAnimation("trng", 2, 16) {}
+	~Training() override {}
+};
+
+class Market : public ViewAnimation {
+public:
+	Market() : ViewAnimation("gild", 4, 32) {}
+	~Market() override {}
+};
+
+class Temple : public ViewAnimation {
+public:
+	Temple() : ViewAnimation("tmpl", 4, 26) {}
+	~Temple() override {}
+};
+
+class Blacksmith : public ViewAnimation {
+public:
+	Blacksmith() : ViewAnimation("blck", 2, 13) {}
+	~Blacksmith() override {}
 };
 
-static const LocationEntry LOCATIONS[5] = {
-	{ "trng", 2, 16 },
-	{ "gild", 4, 32 },	// Xeen guild anim used for market
-	{ "tmpl", 4, 26 },
-	{ "blck", 2, 13 },
-	{ "tvrn", 2, 16 }
+class Tavern : public ViewAnimation {
+public:
+	Tavern() : ViewAnimation("tvrn", 2, 16) {}
+	~Tavern() override {}
 };
 
+} // namespace Animations
+
+/*------------------------------------------------------------------------*/
+
 bool GameView::msgGame(const GameMessage &msg) {
 	if (msg._name == "LOCATION") {
 		showLocation(msg._value);
@@ -58,40 +100,51 @@ bool GameView::msgGame(const GameMessage &msg) {
 
 void GameView::showLocation(int locationId) {
 	if (locationId == -1) {
-		_backgrounds.clear();
-		_frameCount = 0;
-		_locationId = -1;
+		_anim->leave();
+		delete _anim;
+		_anim = nullptr;
+
 	} else {
-		assert(LOCATIONS[locationId]._prefix);
-		_locationId = locationId;
-		_frameIndex = _timerCtr = 0;
-		_frameCount = LOCATIONS[locationId]._frameCount;
-
-		_backgrounds.resize(LOCATIONS[locationId]._count);
-		for (uint i = 0; i < _backgrounds.size(); ++i) {
-			Common::String name = Common::String::format("%s%d.twn",
-				LOCATIONS[locationId]._prefix, i + 1);
-			_backgrounds[i].load(name);
+		assert(!_anim);
+		switch (locationId) {
+		case LOC_TRAINING:
+			_anim = new Animations::Training();
+			break;
+		case LOC_MARKET:
+			_anim = new Animations::Market();
+			break;
+		case LOC_TEMPLE:
+			_anim = new Animations::Temple();
+			break;
+		case LOC_BLACKSMITH:
+			_anim = new Animations::Blacksmith();
+			break;
+		case LOC_TAVERN:
+			_anim = new Animations::Tavern();
+			break;
+		default:
+			error("Unknown location type");
+			break;
 		}
+
+		_anim->enter();
 	}
 }
 
 void GameView::draw() {
-	if (_locationId == -1) {
+	if (_anim == nullptr) {
 		Views::GameView::draw();
-
 	} else {
 		Graphics::ManagedSurface s = getSurface();
-		_backgrounds[_frameIndex / 8].draw(&s, _frameIndex % 8,
-			Common::Point(0, 0));
+		_anim->draw(s);
 	}
 }
 
 bool GameView::tick() {
-	if (_locationId != -1) {
+	if (_anim != nullptr) {
 		if (++_timerCtr >= TICKS_PER_FRAME) {
 			_timerCtr = 0;
-			_frameIndex = (_frameIndex + 1) % _frameCount;
+			_anim->tick();
 		}
 
 		redraw();
diff --git a/engines/mm/mm1/views_enh/game_view.h b/engines/mm/mm1/views_enh/game_view.h
index a09a3fdb0d3..44782a15b69 100644
--- a/engines/mm/mm1/views_enh/game_view.h
+++ b/engines/mm/mm1/views_enh/game_view.h
@@ -29,11 +29,28 @@ namespace MM {
 namespace MM1 {
 namespace ViewsEnh {
 
+namespace Animations {
+
+class ViewAnimation {
+protected:
+	Common::Array<Shared::Xeen::SpriteResource> _backgrounds;
+	uint _frameIndex = 0;
+	uint _frameCount = 0;
+public:
+	ViewAnimation(const char *prefix, uint count, uint frameCount);
+	virtual ~ViewAnimation() {}
+
+	virtual void enter() {}
+	void tick();
+	void draw(Graphics::ManagedSurface &s);
+	virtual void leave() {}
+};
+
+} // namespace Animations
+
 class GameView : public Views::GameView {
 private:
-	int _locationId = -1;
-	Common::Array<Shared::Xeen::SpriteResource> _backgrounds;
-	uint _frameIndex = 0, _frameCount = 0;
+	Animations::ViewAnimation *_anim = nullptr;
 	uint _timerCtr = 0;
 
 	/**
@@ -43,12 +60,13 @@ private:
 
 public:
 	GameView(UIElement *owner) : Views::GameView(owner) {}
-	virtual ~GameView() {}
+	virtual ~GameView() {
+		delete _anim;
+	}
 
 	void draw() override;
 	bool msgGame(const GameMessage &msg) override;
 	bool tick() override;
-	void update();
 };
 
 } // namespace ViewsEnh


Commit: f9543cba7ae9f86b654faa0b6d2257e7b15acc32
    https://github.com/scummvm/scummvm/commit/f9543cba7ae9f86b654faa0b6d2257e7b15acc32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:49-08:00

Commit Message:
MM: Move Sound class into Shared namespace

Changed paths:
  A engines/mm/shared/xeen/sound.cpp
  A engines/mm/shared/xeen/sound.h
  A engines/mm/shared/xeen/sound_driver.cpp
  A engines/mm/shared/xeen/sound_driver.h
  A engines/mm/shared/xeen/sound_driver_adlib.cpp
  A engines/mm/shared/xeen/sound_driver_adlib.h
  R engines/mm/xeen/sound.cpp
  R engines/mm/xeen/sound_driver.cpp
  R engines/mm/xeen/sound_driver.h
  R engines/mm/xeen/sound_driver_adlib.cpp
  R engines/mm/xeen/sound_driver_adlib.h
    engines/mm/mm.cpp
    engines/mm/mm.h
    engines/mm/module.mk
    engines/mm/xeen/sound.h
    engines/mm/xeen/xeen.cpp
    engines/mm/xeen/xeen.h


diff --git a/engines/mm/mm.cpp b/engines/mm/mm.cpp
index 8dfe75bc068..03c008881ca 100644
--- a/engines/mm/mm.cpp
+++ b/engines/mm/mm.cpp
@@ -23,8 +23,11 @@
 
 namespace MM {
 
+MMEngine *g_engine;
+
 MMEngine::MMEngine(OSystem *syst, const MM::MightAndMagicGameDescription *gameDesc) :
-	Engine(syst), _gameDescription(gameDesc), _randomSource("MightAndMagic") {
+		Engine(syst), _gameDescription(gameDesc), _randomSource("MightAndMagic") {
+	g_engine = this;
 }
 
 bool MMEngine::hasFeature(EngineFeature f) const {
@@ -50,4 +53,8 @@ Common::Platform MMEngine::getPlatform() const {
 	return _gameDescription->desc.platform;
 }
 
+bool MMEngine::getIsCD() const {
+	return getFeatures() & ADGF_CD;
+}
+
 } // namespace MM
diff --git a/engines/mm/mm.h b/engines/mm/mm.h
index 137d4cf2d08..526bcb4f59b 100644
--- a/engines/mm/mm.h
+++ b/engines/mm/mm.h
@@ -67,6 +67,11 @@ public:
 	 */
 	uint32 getGameID() const;
 
+	/**
+	 * Returns true if the game is the CD version
+	 */
+	bool getIsCD() const;
+
 	/**
 	 * Get a random number
 	 */
@@ -75,6 +80,8 @@ public:
 	}
 };
 
+extern MMEngine *g_engine;
+
 } // namespace MM
 
 #endif // MM_MM_H
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index a6c44557b70..3133c8fc05a 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -10,6 +10,9 @@ MODULE_OBJS := \
 	shared/utils/xeen_font.o \
 	shared/xeen/cc_archive.o \
 	shared/xeen/file.o \
+	shared/xeen/sound.o \
+	shared/xeen/sound_driver.o \
+	shared/xeen/sound_driver_adlib.o \
 	shared/xeen/sprites.o \
 	shared/xeen/xsurface.o
 
@@ -255,9 +258,6 @@ MODULE_OBJS += \
 	xeen/saves.o \
 	xeen/screen.o \
 	xeen/scripts.o \
-	xeen/sound.o \
-	xeen/sound_driver.o \
-	xeen/sound_driver_adlib.o \
 	xeen/spells.o \
 	xeen/sprites.o \
 	xeen/subtitles.o \
diff --git a/engines/mm/xeen/sound.cpp b/engines/mm/shared/xeen/sound.cpp
similarity index 95%
rename from engines/mm/xeen/sound.cpp
rename to engines/mm/shared/xeen/sound.cpp
index d9fbddbbfb2..07debccf992 100644
--- a/engines/mm/xeen/sound.cpp
+++ b/engines/mm/shared/xeen/sound.cpp
@@ -23,24 +23,25 @@
 #include "audio/decoders/voc.h"
 #include "backends/audiocd/audiocd.h"
 #include "common/config-manager.h"
-#include "mm/xeen/sound.h"
-#include "mm/xeen/sound_driver_adlib.h"
-#include "mm/xeen/xeen.h"
+#include "mm/shared/xeen/sound.h"
+#include "mm/shared/xeen/sound_driver_adlib.h"
+#include "mm/mm.h"
 
 namespace MM {
+namespace Shared {
 namespace Xeen {
 
 Sound::Sound(Audio::Mixer *mixer) : _mixer(mixer), _fxOn(true), _musicOn(true), _subtitles(false),
 _songData(nullptr), _effectsData(nullptr), _musicSide(0), _musicPercent(100),
 _musicVolume(0), _sfxVolume(0) {
 	_SoundDriver = new SoundDriverAdlib();
-	if (g_vm->getIsCD())
+	if (g_engine->getIsCD())
 		g_system->getAudioCDManager()->open();
 }
 
 Sound::~Sound() {
 	stopAllAudio();
-	if (g_vm->getIsCD())
+	if (g_engine->getIsCD())
 		g_system->getAudioCDManager()->close();
 
 	delete _SoundDriver;
@@ -111,7 +112,7 @@ void Sound::setFxOn(bool isOn) {
 		ConfMan.setBool("mute", false);
 	ConfMan.flushToDisk();
 
-	g_vm->syncSoundSettings();
+	g_engine->syncSoundSettings();
 }
 
 void Sound::loadEffectsData() {
@@ -215,7 +216,7 @@ void Sound::setMusicOn(bool isOn) {
 		ConfMan.setBool("mute", false);
 	ConfMan.flushToDisk();
 
-	g_vm->syncSoundSettings();
+	g_engine->syncSoundSettings();
 }
 
 bool Sound::isMusicPlaying() const {
@@ -250,5 +251,6 @@ void Sound::updateVolume() {
 	songCommand(SET_VOLUME, _musicPercent * _musicVolume / 100, _sfxVolume);
 }
 
-} // End of namespace Xeen
-} // End of namespace MM
+} // namespace Xeen
+} // namespace Shared
+} // namespace MM
diff --git a/engines/mm/shared/xeen/sound.h b/engines/mm/shared/xeen/sound.h
new file mode 100644
index 00000000000..8bfd0127e39
--- /dev/null
+++ b/engines/mm/shared/xeen/sound.h
@@ -0,0 +1,168 @@
+/* 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 3 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, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef MM_SHARED_XEEN_SOUND_H
+#define MM_SHARED_XEEN_SOUND_H
+
+#include "audio/mixer.h"
+#include "audio/audiostream.h"
+#include "mm/shared/xeen/file.h"
+#include "mm/shared/xeen/sound_driver.h"
+
+namespace MM {
+namespace Shared {
+namespace Xeen {
+
+class Sound {
+private:
+	SoundDriver *_SoundDriver;
+	const byte *_effectsData;
+	Common::Array<uint16> _effectsOffsets;
+	const byte *_songData;
+	Audio::Mixer *_mixer;
+	Audio::SoundHandle _soundHandle;
+	byte _musicPercent;
+	int _musicVolume, _sfxVolume;
+private:
+	/**
+	 * Loads effects data that was embedded in the music driver
+	 */
+	void loadEffectsData();
+
+	/**
+	 * Updates any playing music
+	 */
+	void update();
+
+	/**
+	 * Updates the music and sound effects playing volume
+	 */
+	void updateVolume();
+public:
+	bool _fxOn;
+	bool _musicOn;
+	Common::String _currentMusic;
+	int _musicSide;
+	bool _subtitles;
+public:
+	Sound(Audio::Mixer *mixer);
+	virtual ~Sound();
+
+	/**
+	 * Starts an effect playing
+	 */
+	void playFX(uint effectId);
+
+	/**
+	 * Stops any currently playing FX
+	 */
+	void stopFX();
+
+	/**
+	 * Executes special music command
+	 */
+	int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0);
+
+	/**
+	 * Stops any currently playing music
+	 */
+	void stopSong() {
+		songCommand(STOP_SONG);
+	}
+
+	/**
+	 * Sets the in-game music volume percent. This is separate from the ScummVM volume
+	 */
+	void setMusicPercent(byte percent);
+
+	/**
+	 * Plays a song
+	 */
+	void playSong(Common::SeekableReadStream &stream);
+
+	/**
+	 * Plays a song
+	 */
+	void playSong(const Common::String &name, int param = 0);
+
+	/**
+	 * Returns true if music is playing
+	 */
+	bool isMusicPlaying() const;
+
+	/**
+	 * Sets whether music is on
+	 */
+	void setMusicOn(bool isOn);
+
+	/**
+	* Sets whether sound effects is on
+	*/
+	void setFxOn(bool isOn);
+
+	/**
+	 * Called to reload sound settings
+	 */
+	void updateSoundSettings();
+
+	/**
+	 * Stops all playing music, FX, and sound samples
+	 */
+	void stopAllAudio();
+
+	/**
+	 * Play a given sound
+	 */
+	void playSound(Common::SeekableReadStream &s, int unused = 0);
+
+	/**
+	 * Play a given sound
+	 */
+	void playSound(const Common::String &name, int unused = 0);
+
+	/**
+	 * Play a given sound
+	 */
+	void playSound(const Common::String &name, int ccNum, int unused);
+
+	/**
+	 * Stop playing a sound loaded from a .m file
+	 * @remarks		In the original, passing 1 to playSound stopped the sound
+	 */
+	void stopSound();
+
+	/**
+	 * Returns true if a sound file is currently playing
+	 * @remarks		In the original, passing 0 to playSound returned play status
+	 */
+	bool isSoundPlaying() const;
+
+	/**
+	 * Play a given voice file
+	 */
+	void playVoice(const Common::String &name, int ccMode = -1);
+};
+
+} // namespace Xeen
+} // namespace Shared
+} // namespace MM
+
+#endif
diff --git a/engines/mm/xeen/sound_driver.cpp b/engines/mm/shared/xeen/sound_driver.cpp
similarity index 97%
rename from engines/mm/xeen/sound_driver.cpp
rename to engines/mm/shared/xeen/sound_driver.cpp
index fbab864cca1..c7ebd7f1b6f 100644
--- a/engines/mm/xeen/sound_driver.cpp
+++ b/engines/mm/shared/xeen/sound_driver.cpp
@@ -19,13 +19,15 @@
  *
  */
 
+#include "common/debug.h"
 #include "common/md5.h"
 #include "common/config-manager.h"
-#include "mm/xeen/sound_driver.h"
-#include "mm/xeen/xeen.h"
-#include "mm/xeen/files.h"
+#include "mm/shared/xeen/sound_driver.h"
+#include "mm/shared/xeen/file.h"
+#include "mm/mm.h"
 
 namespace MM {
+namespace Shared {
 namespace Xeen {
 
 SoundDriver::SoundDriver() : _frameCtr(0) {
@@ -238,5 +240,6 @@ const CommandFn SoundDriver::FX_COMMANDS[16] = {
 	&SoundDriver::cmdChangeFrequency,  &SoundDriver::fxEndSubroutine
 };
 
-} // End of namespace Xeen
-} // End of namespace MM
+} // namespace Xeen
+} // namespace Shared
+} // namespace MM
diff --git a/engines/mm/xeen/sound_driver.h b/engines/mm/shared/xeen/sound_driver.h
similarity index 96%
rename from engines/mm/xeen/sound_driver.h
rename to engines/mm/shared/xeen/sound_driver.h
index ed3f25d745f..7cc6eb66806 100644
--- a/engines/mm/xeen/sound_driver.h
+++ b/engines/mm/shared/xeen/sound_driver.h
@@ -19,8 +19,8 @@
  *
  */
 
-#ifndef XEEN_SOUND_DRIVER_H
-#define XEEN_SOUND_DRIVER_H
+#ifndef MM_SHARED_XEEN_SOUND_DRIVER_H
+#define MM_SHARED_XEEN_SOUND_DRIVER_H
 
 #include "audio/fmopl.h"
 #include "audio/mixer.h"
@@ -28,7 +28,7 @@
 #include "common/mutex.h"
 #include "common/queue.h"
 #include "common/stack.h"
-#include "mm/xeen/files.h"
+#include "mm/shared/xeen/file.h"
 
 #define CHANNEL_COUNT 9
 
@@ -37,6 +37,7 @@ namespace OPL {
 }
 
 namespace MM {
+namespace Shared {
 namespace Xeen {
 
 enum MusicCommand {
@@ -199,7 +200,8 @@ public:
 	}
 };
 
-} // End of namespace Xeen
-} // End of namespace MM
+} // namespace Xeen
+} // namespace Shared
+} // namespace MM
 
 #endif
diff --git a/engines/mm/xeen/sound_driver_adlib.cpp b/engines/mm/shared/xeen/sound_driver_adlib.cpp
similarity index 98%
rename from engines/mm/xeen/sound_driver_adlib.cpp
rename to engines/mm/shared/xeen/sound_driver_adlib.cpp
index a0b06ca2b89..240a4477c12 100644
--- a/engines/mm/xeen/sound_driver_adlib.cpp
+++ b/engines/mm/shared/xeen/sound_driver_adlib.cpp
@@ -19,10 +19,12 @@
  *
  */
 
-#include "mm/xeen/sound_driver_adlib.h"
-#include "mm/xeen/xeen.h"
+#include "common/debug.h"
+#include "mm/shared/xeen/sound_driver_adlib.h"
+#include "mm/mm.h"
 
 namespace MM {
+namespace Shared {
 namespace Xeen {
 
 #define CALLBACKS_PER_SECOND 73
@@ -424,5 +426,6 @@ byte SoundDriverAdlib::calculateLevel(byte level, bool isFx) {
 	return scaling | (0x3f - totalLevel);
 }
 
-} // End of namespace Xeen
-} // End of namespace MM
+} // namespace Xeen
+} // namespace Shared
+} // namespace MM
diff --git a/engines/mm/xeen/sound_driver_adlib.h b/engines/mm/shared/xeen/sound_driver_adlib.h
similarity index 95%
rename from engines/mm/xeen/sound_driver_adlib.h
rename to engines/mm/shared/xeen/sound_driver_adlib.h
index eb9708230e5..b01c8cf8247 100644
--- a/engines/mm/xeen/sound_driver_adlib.h
+++ b/engines/mm/shared/xeen/sound_driver_adlib.h
@@ -19,16 +19,17 @@
  *
  */
 
-#ifndef XEEN_SOUND_DRIVER_ADLIB_H
-#define XEEN_SOUND_DRIVER_ADLIB_H
+#ifndef MM_SHARED_XEEN_SOUND_DRIVER_ADLIB_H
+#define MM_SHARED_XEEN_SOUND_DRIVER_ADLIB_H
 
-#include "mm/xeen/sound_driver.h"
+#include "mm/shared/xeen/sound_driver.h"
 
 namespace OPL {
 	class OPL;
 }
 
 namespace MM {
+namespace Shared {
 namespace Xeen {
 
 class SoundDriverAdlib : public SoundDriver {
@@ -162,7 +163,8 @@ public:
 	int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0) override;
 };
 
-} // End of namespace Xeen
-} // End of namespace MM
+} // namespace Xeen
+} // namespace Shared
+} // namespace MM
 
 #endif
diff --git a/engines/mm/xeen/sound.h b/engines/mm/xeen/sound.h
index 22612bfdd93..133af64a2a7 100644
--- a/engines/mm/xeen/sound.h
+++ b/engines/mm/xeen/sound.h
@@ -22,143 +22,12 @@
 #ifndef XEEN_SOUND_H
 #define XEEN_SOUND_H
 
-#include "audio/mixer.h"
-#include "audio/audiostream.h"
-#include "mm/xeen/files.h"
-#include "mm/xeen/sound_driver.h"
+#include "mm/shared/xeen/sound.h"
 
 namespace MM {
 namespace Xeen {
 
-class Sound {
-private:
-	SoundDriver *_SoundDriver;
-	const byte *_effectsData;
-	Common::Array<uint16> _effectsOffsets;
-	const byte *_songData;
-	Audio::Mixer *_mixer;
-	Audio::SoundHandle _soundHandle;
-	byte _musicPercent;
-	int _musicVolume, _sfxVolume;
-private:
-	/**
-	 * Loads effects data that was embedded in the music driver
-	 */
-	void loadEffectsData();
-
-	/**
-	 * Updates any playing music
-	 */
-	void update();
-
-	/**
-	 * Updates the music and sound effects playing volume
-	 */
-	void updateVolume();
-public:
-	bool _fxOn;
-	bool _musicOn;
-	Common::String _currentMusic;
-	int _musicSide;
-	bool _subtitles;
-public:
-	Sound(Audio::Mixer *mixer);
-	virtual ~Sound();
-
-	/**
-	 * Starts an effect playing
-	 */
-	void playFX(uint effectId);
-
-	/**
-	 * Stops any currently playing FX
-	 */
-	void stopFX();
-
-	/**
-	 * Executes special music command
-	 */
-	int songCommand(uint commandId, byte musicVolume = 0, byte sfxVolume = 0);
-
-	/**
-	 * Stops any currently playing music
-	 */
-	void stopSong() {
-		songCommand(STOP_SONG);
-	}
-
-	/**
-	 * Sets the in-game music volume percent. This is separate from the ScummVM volume
-	 */
-	void setMusicPercent(byte percent);
-
-	/**
-	 * Plays a song
-	 */
-	void playSong(Common::SeekableReadStream &stream);
-
-	/**
-	 * Plays a song
-	 */
-	void playSong(const Common::String &name, int param = 0);
-
-	/**
-	 * Returns true if music is playing
-	 */
-	bool isMusicPlaying() const;
-
-	/**
-	 * Sets whether music is on
-	 */
-	void setMusicOn(bool isOn);
-
-	/**
-	* Sets whether sound effects is on
-	*/
-	void setFxOn(bool isOn);
-
-	/**
-	 * Called to reload sound settings
-	 */
-	void updateSoundSettings();
-
-	/**
-	 * Stops all playing music, FX, and sound samples
-	 */
-	void stopAllAudio();
-
-	/**
-	 * Play a given sound
-	 */
-	void playSound(Common::SeekableReadStream &s, int unused = 0);
-
-	/**
-	 * Play a given sound
-	 */
-	void playSound(const Common::String &name, int unused = 0);
-
-	/**
-	 * Play a given sound
-	 */
-	void playSound(const Common::String &name, int ccNum, int unused);
-
-	/**
-	 * Stop playing a sound loaded from a .m file
-	 * @remarks		In the original, passing 1 to playSound stopped the sound
-	 */
-	void stopSound();
-
-	/**
-	 * Returns true if a sound file is currently playing
-	 * @remarks		In the original, passing 0 to playSound returned play status
-	 */
-	bool isSoundPlaying() const;
-
-	/**
-	 * Play a given voice file
-	 */
-	void playVoice(const Common::String &name, int ccMode = -1);
-};
+using Shared::Xeen::Sound;
 
 } // End of namespace Xeen
 } // End of namespace MM
diff --git a/engines/mm/xeen/xeen.cpp b/engines/mm/xeen/xeen.cpp
index 8b622b4e554..c63c5c66c13 100644
--- a/engines/mm/xeen/xeen.cpp
+++ b/engines/mm/xeen/xeen.cpp
@@ -339,9 +339,5 @@ uint32 XeenEngine::getGameFeatures() const {
 	return _gameDescription->features;
 }
 
-bool XeenEngine::getIsCD() const {
-	return getFeatures() & ADGF_CD;
-}
-
 } // End of namespace Xeen
 } // End of namespace MM
diff --git a/engines/mm/xeen/xeen.h b/engines/mm/xeen/xeen.h
index 16a59760602..e3ed79f2ef0 100644
--- a/engines/mm/xeen/xeen.h
+++ b/engines/mm/xeen/xeen.h
@@ -198,11 +198,6 @@ public:
 	 */
 	uint32 getGameFeatures() const;
 
-	/**
-	 * Returns true if the game is the CD version
-	 */
-	bool getIsCD() const;
-
 	/**
 	 * Returns a random number
 	 */


Commit: 181eab7a06a703784be8bd5f896e007b1bfc8ec2
    https://github.com/scummvm/scummvm/commit/181eab7a06a703784be8bd5f896e007b1bfc8ec2
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:49-08:00

Commit Message:
MM: MM1: Derive Sound class from now shared Sound class

Changed paths:
    engines/mm/mm1/mm1.cpp
    engines/mm/mm1/mm1.h
    engines/mm/mm1/sound.h
    engines/mm/mm1/views_enh/game_view.cpp
    engines/mm/mm1/views_enh/game_view.h


diff --git a/engines/mm/mm1/mm1.cpp b/engines/mm/mm1/mm1.cpp
index e1e3d5b16ad..f703b79652a 100644
--- a/engines/mm/mm1/mm1.cpp
+++ b/engines/mm/mm1/mm1.cpp
@@ -47,12 +47,17 @@ MM1Engine::MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc
 
 MM1Engine::~MM1Engine() {
 	g_engine = nullptr;
+	delete _sound;
 }
 
 Common::Error MM1Engine::run() {
 	// Initialize graphics mode
 	initGraphics(320, 200);
 
+	// Setup mixer
+	_sound = new Sound(_mixer);
+	syncSoundSettings();
+
 	if (isEnhanced()) {
 		if (!setupEnhanced())
 			return Common::kNoError;
@@ -74,6 +79,13 @@ Common::Error MM1Engine::run() {
 	return Common::kNoError;
 }
 
+void MM1Engine::syncSoundSettings() {
+	Engine::syncSoundSettings();
+
+	if (_sound)
+		_sound->updateSoundSettings();
+}
+
 bool MM1Engine::isEnhanced() const {
 	return (_gameDescription->features & GF_ENHANCED) != 0;
 }
diff --git a/engines/mm/mm1/mm1.h b/engines/mm/mm1/mm1.h
index 24021f2dc51..25e91422cf7 100644
--- a/engines/mm/mm1/mm1.h
+++ b/engines/mm/mm1/mm1.h
@@ -28,6 +28,7 @@
 #include "mm/mm.h"
 #include "mm/mm1/events.h"
 #include "mm/mm1/globals.h"
+#include "mm/mm1/sound.h"
 
 /**
  * This is the Might and Magic I engine
@@ -44,6 +45,7 @@ private:
 	bool setupEnhanced();
 public:
 	Globals _globals;
+	Sound *_sound = nullptr;
 public:
 	MM1Engine(OSystem *syst, const MightAndMagicGameDescription *gameDesc);
 	~MM1Engine() override;
@@ -64,6 +66,11 @@ public:
 		return _targetName;
 	}
 
+	/**
+	 * Sync the sound settings
+	 */
+	void syncSoundSettings() override;
+
 	/**
 	 * Returns true if a game can be saved
 	 */
diff --git a/engines/mm/mm1/sound.h b/engines/mm/mm1/sound.h
index 2c29e51e9c5..fb4c306085a 100644
--- a/engines/mm/mm1/sound.h
+++ b/engines/mm/mm1/sound.h
@@ -22,6 +22,8 @@
 #ifndef MM_MM1_SOUND_H
 #define MM_MM1_SOUND_H
 
+#include "mm/shared/xeen/sound.h"
+
 namespace MM {
 namespace MM1 {
 
@@ -30,8 +32,10 @@ enum SoundId {
 	SOUND_5 = 5, SOUND_8 = 8, SOUND_9 = 9
 };
 
-class Sound {
+class Sound : public Shared::Xeen::Sound {
 public:
+	Sound(Audio::Mixer *mixer) : Shared::Xeen::Sound(mixer) {}
+
 	static void sound(SoundId soundNum);
 	static void sound2(SoundId soundNum);
 	static void stopSound();
diff --git a/engines/mm/mm1/views_enh/game_view.cpp b/engines/mm/mm1/views_enh/game_view.cpp
index 7a50ef6314f..4537ff93e1f 100644
--- a/engines/mm/mm1/views_enh/game_view.cpp
+++ b/engines/mm/mm1/views_enh/game_view.cpp
@@ -20,6 +20,7 @@
  */
 
 #include "mm/mm1/views_enh/game_view.h"
+#include "mm/mm1/mm1.h"
 
 namespace MM {
 namespace MM1 {
@@ -30,7 +31,7 @@ namespace ViewsEnh {
 namespace Animations {
 
 ViewAnimation::ViewAnimation(const char *prefix, uint count, uint frameCount) :
-		_frameCount(frameCount) {
+		_sound(*g_engine->_sound), _frameCount(frameCount) {
 	_backgrounds.resize(count);
 
 	for (uint i = 0; i < _backgrounds.size(); ++i) {
@@ -49,34 +50,71 @@ void ViewAnimation::draw(Graphics::ManagedSurface &s) {
 		Common::Point(0, 0));
 }
 
+void ViewAnimation::leave() {
+	_sound.stopSound();
+	_sound.stopSong();
+}
+
+/*------------------------------------------------------------------------*/
+
 class Training : public ViewAnimation {
 public:
 	Training() : ViewAnimation("trng", 2, 16) {}
 	~Training() override {}
+
+	void enter() override {
+		_sound.playVoice("hello1.voc");
+		_sound.playSong("grounds.m");
+	}
 };
 
 class Market : public ViewAnimation {
 public:
 	Market() : ViewAnimation("gild", 4, 32) {}
 	~Market() override {}
+
+	void enter() override {
+		_sound.playVoice("guild10.voc");
+		_sound.playSong("guild.m");
+	}
 };
 
 class Temple : public ViewAnimation {
 public:
 	Temple() : ViewAnimation("tmpl", 4, 26) {}
 	~Temple() override {}
+
+	void enter() override {
+		_sound.playVoice("maywe2.voc");
+		_sound.playSong("temple.m");
+	}
 };
 
 class Blacksmith : public ViewAnimation {
 public:
 	Blacksmith() : ViewAnimation("blck", 2, 13) {}
 	~Blacksmith() override {}
+
+	void enter() override {
+		_sound.playVoice("whaddayo.voc");
+		_sound.playSong("smith.m");
+	}
 };
 
 class Tavern : public ViewAnimation {
 public:
 	Tavern() : ViewAnimation("tvrn", 2, 16) {}
 	~Tavern() override {}
+
+	void enter() override {
+		_sound.playVoice("hello.voc");
+		_sound.playSong("tavern.m");
+	}
+
+	void leave() override {
+		ViewAnimation::leave();
+		_sound.playVoice("goodbye.voc");
+	}
 };
 
 } // namespace Animations
diff --git a/engines/mm/mm1/views_enh/game_view.h b/engines/mm/mm1/views_enh/game_view.h
index 44782a15b69..7d2e3d7c032 100644
--- a/engines/mm/mm1/views_enh/game_view.h
+++ b/engines/mm/mm1/views_enh/game_view.h
@@ -24,6 +24,7 @@
 
 #include "mm/mm1/views/game_view.h"
 #include "mm/shared/xeen/sprites.h"
+#include "mm/mm1/sound.h"
 
 namespace MM {
 namespace MM1 {
@@ -32,10 +33,12 @@ namespace ViewsEnh {
 namespace Animations {
 
 class ViewAnimation {
-protected:
+private:
 	Common::Array<Shared::Xeen::SpriteResource> _backgrounds;
 	uint _frameIndex = 0;
 	uint _frameCount = 0;
+protected:
+	Sound &_sound;
 public:
 	ViewAnimation(const char *prefix, uint count, uint frameCount);
 	virtual ~ViewAnimation() {}
@@ -43,7 +46,7 @@ public:
 	virtual void enter() {}
 	void tick();
 	void draw(Graphics::ManagedSurface &s);
-	virtual void leave() {}
+	virtual void leave();
 };
 
 } // namespace Animations


Commit: cd5962252e1892313100957da952edb9a59365a9
    https://github.com/scummvm/scummvm/commit/cd5962252e1892313100957da952edb9a59365a9
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:49-08:00

Commit Message:
MM: MM1: Cleanup of Market view

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/locations/location.cpp
    engines/mm/mm1/views_enh/locations/location.h
    engines/mm/mm1/views_enh/locations/market.cpp
    engines/mm/mm1/views_enh/locations/temple.cpp
    engines/mm/mm1/views_enh/locations/temple.h


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 721a84fc142..01d5a544e90 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -108,11 +108,11 @@ dialogs:
 		copyright2: "All Rights Reserved"
 		scummvm: "Enhanced version provided by ScummVM"
 	market:
-		special: "special today,all you can eat! "
-		gp: "gp/ea"
-		will_you_pay: "will you pay (Y/N)?"
-		thankyou: "thank you, come again!"
-		no_gold: "no gold, no food!"
+		special: "Special today,all you can eat! "
+		gp: "GP/ea"
+		will_you_pay: "Will you pay (Y/N)?"
+		thankyou: "Thank you, come again!"
+		no_gold: "No gold, no food!"
 	order:
 		title: " re-order party  new  1  2  3  4  5  6"
 		old: "old"
@@ -493,9 +493,10 @@ enhdialogs:
 		east: "East"
 		west: "West"
 	market:
-		buy_food: "buy food"
-		thankyou: "thank you,\ncome again!"
-		no_gold: "no gold,\nno food!"
+		title: "Market"
+		buy_food: "Buy food"
+		thankyou: "Thank you,\ncome again!"
+		no_gold: "No gold,\nno food!"
 	misc:
 		exit: "Exit"
 	quickref:
diff --git a/engines/mm/mm1/views_enh/locations/location.cpp b/engines/mm/mm1/views_enh/locations/location.cpp
index 04f1d316a62..61c082a8f48 100644
--- a/engines/mm/mm1/views_enh/locations/location.cpp
+++ b/engines/mm/mm1/views_enh/locations/location.cpp
@@ -66,6 +66,12 @@ void Location::backpackFull() {
 	displayMessage(STRING["dialogs.misc.backpack_full"]);
 }
 
+bool Location::msgUnfocus(const UnfocusMessage &msg) {
+	send("View", GameMessage("LOCATION", -1));
+	(void)PartyView::msgUnfocus(msg);
+	return true;
+}
+
 void Location::draw() {
 	send("View", GameMessage("LOCATION_DRAW"));
 	PartyView::draw();
diff --git a/engines/mm/mm1/views_enh/locations/location.h b/engines/mm/mm1/views_enh/locations/location.h
index 8aec22af83b..c520b49cb23 100644
--- a/engines/mm/mm1/views_enh/locations/location.h
+++ b/engines/mm/mm1/views_enh/locations/location.h
@@ -70,15 +70,17 @@ public:
 	 */
 	void leave();
 
+	bool msgUnfocus(const UnfocusMessage &msg) override;
+
 	/**
 	 * Draw the location
 	 */
-	void draw();
+	void draw() override;
 
 	/**
 	 * Tick handler
 	 */
-	bool tick();
+	bool tick() override;
 };
 
 } // namespace Locations
diff --git a/engines/mm/mm1/views_enh/locations/market.cpp b/engines/mm/mm1/views_enh/locations/market.cpp
index 65556925226..eecbaef5844 100644
--- a/engines/mm/mm1/views_enh/locations/market.cpp
+++ b/engines/mm/mm1/views_enh/locations/market.cpp
@@ -31,25 +31,27 @@ namespace Locations {
 Market::Market() : Location("Market") {
 	addButton(&g_globals->_confirmIcons,
 		Common::Point(_innerBounds.width() / 2 - 24,
-			_innerBounds.height() - 32),
-		0, Common::KEYCODE_y);
+			_innerBounds.height() - 22), 0, Common::KEYCODE_y);
 	addButton(&g_globals->_confirmIcons,
 		Common::Point(_innerBounds.width() / 2 + 4,
-			_innerBounds.height() - 32),
-		2, Common::KEYCODE_n);
+			_innerBounds.height() - 22), 2, Common::KEYCODE_n);
 }
 
 bool Market::msgFocus(const FocusMessage &msg) {
 	Maps::Map &map = *g_maps->_currentMap;
 	_foodCost = FOOD_COST[map[Maps::MAP_ID] - 1];
+
+	(void)Location::msgFocus(msg);
+	send("View", GameMessage("LOCATION", LOC_MARKET));
+
 	return true;
 }
 
 void Market::draw() {
 	Location::draw();
 
-	writeLine(0, STRING["enhdialogs.location.store"],ALIGN_MIDDLE);
-	writeLine(1, STRING["enhdialogs.location.options"], ALIGN_MIDDLE);
+	writeLine(0, STRING["enhdialogs.market.title"],ALIGN_MIDDLE);
+	writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
 	writeLine(6, STRING["enhdialogs.market.buy_food"], ALIGN_MIDDLE);
 	writeLine(7, Common::String::format("%d %s",
 		_foodCost, STRING["dialogs.market.gp"].c_str()),
diff --git a/engines/mm/mm1/views_enh/locations/temple.cpp b/engines/mm/mm1/views_enh/locations/temple.cpp
index 29e3a995bfb..9199f00f005 100644
--- a/engines/mm/mm1/views_enh/locations/temple.cpp
+++ b/engines/mm/mm1/views_enh/locations/temple.cpp
@@ -42,12 +42,6 @@ bool Temple::msgFocus(const FocusMessage &msg) {
 	return true;
 }
 
-bool Temple::msgUnfocus(const UnfocusMessage &msg) {
-	send("View", GameMessage("LOCATION", -1));
-	(void)Location::msgUnfocus(msg);
-	return true;
-}
-
 void Temple::draw() {
 	Location::draw();
 
diff --git a/engines/mm/mm1/views_enh/locations/temple.h b/engines/mm/mm1/views_enh/locations/temple.h
index 7069f14f478..62799ae8c08 100644
--- a/engines/mm/mm1/views_enh/locations/temple.h
+++ b/engines/mm/mm1/views_enh/locations/temple.h
@@ -47,7 +47,6 @@ public:
 	Temple();
 
 	bool msgFocus(const FocusMessage &msg) override;
-	bool msgUnfocus(const UnfocusMessage &msg) override;
 	void draw() override;
 	bool msgKeypress(const KeypressMessage &msg) override;
 	bool msgAction(const ActionMessage &msg) override;


Commit: d400775f49f11e7eccfbbe2410eb3ac6db980457
    https://github.com/scummvm/scummvm/commit/d400775f49f11e7eccfbbe2410eb3ac6db980457
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:49-08:00

Commit Message:
MM: MM1: Sort animation views alphabetically

Changed paths:
    engines/mm/mm1/views_enh/game_view.cpp


diff --git a/engines/mm/mm1/views_enh/game_view.cpp b/engines/mm/mm1/views_enh/game_view.cpp
index 4537ff93e1f..02b397c3906 100644
--- a/engines/mm/mm1/views_enh/game_view.cpp
+++ b/engines/mm/mm1/views_enh/game_view.cpp
@@ -57,14 +57,16 @@ void ViewAnimation::leave() {
 
 /*------------------------------------------------------------------------*/
 
-class Training : public ViewAnimation {
+class Blacksmith : public ViewAnimation {
 public:
-	Training() : ViewAnimation("trng", 2, 16) {}
-	~Training() override {}
+	Blacksmith() : ViewAnimation("blck", 2, 13) {
+	}
+	~Blacksmith() override {
+	}
 
 	void enter() override {
-		_sound.playVoice("hello1.voc");
-		_sound.playSong("grounds.m");
+		_sound.playVoice("whaddayo.voc");
+		_sound.playSong("smith.m");
 	}
 };
 
@@ -74,46 +76,50 @@ public:
 	~Market() override {}
 
 	void enter() override {
-		_sound.playVoice("guild10.voc");
+		_sound.playVoice("hello.voc");
 		_sound.playSong("guild.m");
 	}
 };
 
-class Temple : public ViewAnimation {
+class Tavern : public ViewAnimation {
 public:
-	Temple() : ViewAnimation("tmpl", 4, 26) {}
-	~Temple() override {}
+	Tavern() : ViewAnimation("tvrn", 2, 16) {}
+	~Tavern() override {}
 
 	void enter() override {
-		_sound.playVoice("maywe2.voc");
-		_sound.playSong("temple.m");
+		_sound.playVoice("hello.voc");
+		_sound.playSong("tavern.m");
+	}
+
+	void leave() override {
+		ViewAnimation::leave();
+		_sound.playVoice("goodbye.voc");
 	}
 };
 
-class Blacksmith : public ViewAnimation {
+class Temple : public ViewAnimation {
 public:
-	Blacksmith() : ViewAnimation("blck", 2, 13) {}
-	~Blacksmith() override {}
+	Temple() : ViewAnimation("tmpl", 4, 26) {
+	}
+	~Temple() override {
+	}
 
 	void enter() override {
-		_sound.playVoice("whaddayo.voc");
-		_sound.playSong("smith.m");
+		_sound.playVoice("maywe2.voc");
+		_sound.playSong("temple.m");
 	}
 };
 
-class Tavern : public ViewAnimation {
+class Training : public ViewAnimation {
 public:
-	Tavern() : ViewAnimation("tvrn", 2, 16) {}
-	~Tavern() override {}
-
-	void enter() override {
-		_sound.playVoice("hello.voc");
-		_sound.playSong("tavern.m");
+	Training() : ViewAnimation("trng", 2, 16) {
+	}
+	~Training() override {
 	}
 
-	void leave() override {
-		ViewAnimation::leave();
-		_sound.playVoice("goodbye.voc");
+	void enter() override {
+		_sound.playVoice("hello1.voc");
+		_sound.playSong("grounds.m");
 	}
 };
 


Commit: 1a15f86d1a16090892ec63ab77a0a3caea926d0b
    https://github.com/scummvm/scummvm/commit/1a15f86d1a16090892ec63ab77a0a3caea926d0b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:50-08:00

Commit Message:
MM: MM1: Fixing game messages display

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/game_messages.cpp
    engines/mm/mm1/views_enh/game_messages.h
    engines/mm/mm1/views_enh/game_view.cpp
    engines/mm/mm1/views_enh/locations/location.cpp
    engines/mm/mm1/views_enh/locations/market.cpp
    engines/mm/mm1/views_enh/scroll_text.cpp
    engines/mm/mm1/views_enh/scroll_text.h


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 01d5a544e90..d29053dadd1 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -495,8 +495,8 @@ enhdialogs:
 	market:
 		title: "Market"
 		buy_food: "Buy food"
-		thankyou: "Thank you,\ncome again!"
-		no_gold: "No gold,\nno food!"
+		thankyou: "Thank you, come again!"
+		no_gold: "No gold, no food!"
 	misc:
 		exit: "Exit"
 	quickref:
diff --git a/engines/mm/mm1/views_enh/game_messages.cpp b/engines/mm/mm1/views_enh/game_messages.cpp
index 7b32b8cfa83..01e6d6da9c8 100644
--- a/engines/mm/mm1/views_enh/game_messages.cpp
+++ b/engines/mm/mm1/views_enh/game_messages.cpp
@@ -52,7 +52,7 @@ GameMessages::GameMessages() : ScrollText("GameMessages") {
 void GameMessages::draw() {
 	ScrollText::draw();
 
-	if (_ynCallback) {
+	if (_ynCallback && !isDelayActive()) {
 		_yesNo.resetSelectedButton();
 		_yesNo.draw();
 	}
@@ -79,7 +79,10 @@ bool GameMessages::msgInfo(const InfoMessage &msg) {
 	// Process the lines
 	clear();
 	for (auto line : msg._lines)
-		addText(line._text, line.y, 0, line._align, line.x * 8);
+		addText(line._text, line.y, 0, line._align, 0);
+
+	if (msg._delaySeconds)
+		delaySeconds(msg._delaySeconds);
 
 	return true;
 }
@@ -156,6 +159,13 @@ bool GameMessages::msgMouseUp(const MouseUpMessage &msg) {
 	return false;
 }
 
+void GameMessages::timeout() {
+	close();
+
+	if (_timeoutCallback)
+		_timeoutCallback();
+}
+
 } // namespace ViewsEnh
 } // namespace MM1
 } // namespace MM
diff --git a/engines/mm/mm1/views_enh/game_messages.h b/engines/mm/mm1/views_enh/game_messages.h
index 6ca7acf6b6d..a5bb46fb90b 100644
--- a/engines/mm/mm1/views_enh/game_messages.h
+++ b/engines/mm/mm1/views_enh/game_messages.h
@@ -38,6 +38,7 @@ class GameMessages : public ScrollText {
 private:
 	YNCallback _ynCallback = nullptr;
 	KeyCallback _keyCallback = nullptr;
+	YNCallback &_timeoutCallback = _ynCallback;
 	YesNo _yesNo;
 public:
 	GameMessages();
@@ -50,6 +51,7 @@ public:
 	bool msgAction(const ActionMessage &msg) override;
 	bool msgMouseDown(const MouseDownMessage &msg) override;
 	bool msgMouseUp(const MouseUpMessage &msg) override;
+	void timeout() override;
 };
 
 } // namespace ViewsEnh
diff --git a/engines/mm/mm1/views_enh/game_view.cpp b/engines/mm/mm1/views_enh/game_view.cpp
index 02b397c3906..cdee9d43e26 100644
--- a/engines/mm/mm1/views_enh/game_view.cpp
+++ b/engines/mm/mm1/views_enh/game_view.cpp
@@ -171,7 +171,7 @@ void GameView::showLocation(int locationId) {
 			break;
 		}
 
-		_anim->enter();
+		_anim->leave();
 	}
 }
 
diff --git a/engines/mm/mm1/views_enh/locations/location.cpp b/engines/mm/mm1/views_enh/locations/location.cpp
index 61c082a8f48..52b876c6427 100644
--- a/engines/mm/mm1/views_enh/locations/location.cpp
+++ b/engines/mm/mm1/views_enh/locations/location.cpp
@@ -35,15 +35,25 @@ Location::Location(const Common::String &name) : PartyView(name) {
 }
 
 void Location::leave() {
+	if (g_events->focusedView() == this)
+		close();
+
 	g_maps->turnAround();
-	close();
 	g_events->redraw();
 }
 
 void Location::displayMessage(const Common::String &msg) {
 	Location::draw();
 
-	writeLine(3, msg, ALIGN_MIDDLE);
+	InfoMessage infoMsg(msg, ALIGN_MIDDLE);
+	infoMsg._delaySeconds = 3;
+	infoMsg._timeoutCallback = []() {
+		Location *loc = dynamic_cast<Location *>(g_events->focusedView());
+		assert(loc);
+		loc->leave();
+	};
+
+	g_events->send(infoMsg);
 }
 
 bool Location::subtractGold(uint amount) {
diff --git a/engines/mm/mm1/views_enh/locations/market.cpp b/engines/mm/mm1/views_enh/locations/market.cpp
index eecbaef5844..57d81d78834 100644
--- a/engines/mm/mm1/views_enh/locations/market.cpp
+++ b/engines/mm/mm1/views_enh/locations/market.cpp
@@ -108,8 +108,6 @@ void Market::buyFood() {
 		STRING["enhdialogs.market.thankyou"] :
 		STRING["enhdialogs.market.no_gold"]
 	);
-
-	delaySeconds(3);
 }
 
 bool Market::buyFood(Character *c) {
diff --git a/engines/mm/mm1/views_enh/scroll_text.cpp b/engines/mm/mm1/views_enh/scroll_text.cpp
index 602fe04bac7..33084a20601 100644
--- a/engines/mm/mm1/views_enh/scroll_text.cpp
+++ b/engines/mm/mm1/views_enh/scroll_text.cpp
@@ -70,7 +70,7 @@ void ScrollText::addText(const Common::String &s,
 
 	// Add them in
 	for (uint i = 0; i < lines.size(); ++i, ++lineNum, pt.y += LINE_HEIGHT)
-		_lines.push_back(Line(lines[i], pt, color));
+		_lines.push_back(Line(lines[i], pt, color, align));
 }
 
 void ScrollText::draw() {
@@ -80,7 +80,7 @@ void ScrollText::draw() {
 	for (Lines::const_iterator i = begin();
 		i != end(); ++i) {
 		setTextColor(i->_color);
-		writeString(i->_pos.x, i->_pos.y, i->_str);
+		writeString(i->_pos.x, i->_pos.y, i->_str, i->_align);
 	}
 }
 
diff --git a/engines/mm/mm1/views_enh/scroll_text.h b/engines/mm/mm1/views_enh/scroll_text.h
index c58f34f968f..0aef29b131d 100644
--- a/engines/mm/mm1/views_enh/scroll_text.h
+++ b/engines/mm/mm1/views_enh/scroll_text.h
@@ -39,6 +39,7 @@ class ScrollText : public ScrollView {
 		Common::String _str;
 		Common::Point _pos;
 		byte _color = 0;
+		TextAlign _align = ALIGN_LEFT;
 
 		Line(const Common::String &str,
 			const Common::Point &pos, byte color = 0) :


Commit: 4590fe344381fb9b4998cdcd72b61f213c828f57
    https://github.com/scummvm/scummvm/commit/4590fe344381fb9b4998cdcd72b61f213c828f57
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:50-08:00

Commit Message:
MM: MM1: Fixes for location enter/exit

Changed paths:
    engines/mm/mm1/maps/map_town.cpp
    engines/mm/mm1/views/locations/location.cpp
    engines/mm/mm1/views/locations/location.h
    engines/mm/mm1/views_enh/game_view.cpp
    engines/mm/mm1/views_enh/locations/location.cpp
    engines/mm/mm1/views_enh/locations/location.h
    engines/mm/mm1/views_enh/locations/market.cpp
    engines/mm/mm1/views_enh/locations/temple.cpp
    engines/mm/mm1/views_enh/scroll_text.h


diff --git a/engines/mm/mm1/maps/map_town.cpp b/engines/mm/mm1/maps/map_town.cpp
index 1cb9c7c5079..99f9f12cdf9 100644
--- a/engines/mm/mm1/maps/map_town.cpp
+++ b/engines/mm/mm1/maps/map_town.cpp
@@ -35,7 +35,7 @@ void MapTown::blacksmith() {
 	send(SoundMessage(
 		STRING[Common::String::format("maps.map%.2u.blacksmith_inside", _mapIndex)],
 		[]() {
-			g_events->addView("Blacksmith");
+			g_events->send("Blacksmith", GameMessage("DISPLAY"));
 		}
 	));
 }
@@ -46,7 +46,7 @@ void MapTown::inn() {
 	send(SoundMessage(
 		STRING[Common::String::format("maps.map%.2u.inn_inside", _mapIndex)],
 		[]() {
-			g_events->replaceView("Inn");
+			g_events->send("Inn", GameMessage("DISPLAY"));
 		}
 	));
 }
@@ -57,7 +57,7 @@ void MapTown::market() {
 	send(SoundMessage(
 		STRING[Common::String::format("maps.map%.2u.market_inside", _mapIndex)],
 		[]() {
-			g_events->addView("Market");
+			g_events->send("Market", GameMessage("DISPLAY"));
 		}
 	));
 }
@@ -68,7 +68,7 @@ void MapTown::tavern() {
 	send(SoundMessage(
 		STRING["maps.tavern_inside"],
 		[]() {
-			g_events->addView("Tavern");
+			g_events->send("Tavern", GameMessage("DISPLAY"));
 		}
 	));
 }
@@ -79,7 +79,7 @@ void MapTown::temple() {
 	send(SoundMessage(
 		STRING[Common::String::format("maps.map%.2u.temple_inside", _mapIndex)],
 		[]() {
-			g_events->addView("Temple");
+			g_events->send("Temple", GameMessage("DISPLAY"));
 		}
 	));
 }
@@ -90,7 +90,7 @@ void MapTown::training() {
 	send(SoundMessage(
 		STRING[Common::String::format("maps.map%.2u.training_inside", _mapIndex)],
 		[]() {
-			g_events->addView("Training");
+			g_events->send("Training", GameMessage("DISPLAY"));
 		}
 	));
 }
diff --git a/engines/mm/mm1/views/locations/location.cpp b/engines/mm/mm1/views/locations/location.cpp
index 2b79495dd1d..467991c8d19 100644
--- a/engines/mm/mm1/views/locations/location.cpp
+++ b/engines/mm/mm1/views/locations/location.cpp
@@ -36,6 +36,15 @@ Location::Location(const Common::String &name) : TextView(name) {
 	_modeString = STRING["dialogs.location.gather"];
 }
 
+bool Location::msgGame(const GameMessage &msg) {
+	if (msg._name == "DISPLAY") {
+		addView();
+		return true;
+	}
+
+	return TextView::msgGame(msg);
+}
+
 void Location::draw() {
 	clearSurface();
 	writeString(0, 0, g_globals->_currCharacter->_name);
diff --git a/engines/mm/mm1/views/locations/location.h b/engines/mm/mm1/views/locations/location.h
index 4575b9be090..b63cfe3360d 100644
--- a/engines/mm/mm1/views/locations/location.h
+++ b/engines/mm/mm1/views/locations/location.h
@@ -76,6 +76,11 @@ public:
 	Location(const Common::String &name);
 	virtual ~Location() {}
 
+	/**
+	 * Game message handler
+	 */
+	bool msgGame(const GameMessage &msg) override;
+
 	/**
 	 * Draws the initial display for the business
 	 */
diff --git a/engines/mm/mm1/views_enh/game_view.cpp b/engines/mm/mm1/views_enh/game_view.cpp
index cdee9d43e26..02b397c3906 100644
--- a/engines/mm/mm1/views_enh/game_view.cpp
+++ b/engines/mm/mm1/views_enh/game_view.cpp
@@ -171,7 +171,7 @@ void GameView::showLocation(int locationId) {
 			break;
 		}
 
-		_anim->leave();
+		_anim->enter();
 	}
 }
 
diff --git a/engines/mm/mm1/views_enh/locations/location.cpp b/engines/mm/mm1/views_enh/locations/location.cpp
index 52b876c6427..8231cae1f6a 100644
--- a/engines/mm/mm1/views_enh/locations/location.cpp
+++ b/engines/mm/mm1/views_enh/locations/location.cpp
@@ -29,15 +29,28 @@ namespace MM1 {
 namespace ViewsEnh {
 namespace Locations {
 
-Location::Location(const Common::String &name) : PartyView(name) {
+Location::Location(const Common::String &name, int locationId) :
+		PartyView(name), _locationId(locationId) {
 	_bounds = Common::Rect(232, 0, 320, 146);
 	_escSprite.load("esc.icn");
 }
 
+bool Location::msgGame(const GameMessage &msg) {
+	if (msg._name == "DISPLAY") {
+		send("View", GameMessage("LOCATION", _locationId));
+		addView();
+		return true;
+	} else {
+		return PartyView::msgGame(msg);
+	}
+}
+
 void Location::leave() {
 	if (g_events->focusedView() == this)
 		close();
 
+	send("View", GameMessage("LOCATION", -1));
+
 	g_maps->turnAround();
 	g_events->redraw();
 }
@@ -77,7 +90,6 @@ void Location::backpackFull() {
 }
 
 bool Location::msgUnfocus(const UnfocusMessage &msg) {
-	send("View", GameMessage("LOCATION", -1));
 	(void)PartyView::msgUnfocus(msg);
 	return true;
 }
diff --git a/engines/mm/mm1/views_enh/locations/location.h b/engines/mm/mm1/views_enh/locations/location.h
index c520b49cb23..f851bbfb533 100644
--- a/engines/mm/mm1/views_enh/locations/location.h
+++ b/engines/mm/mm1/views_enh/locations/location.h
@@ -33,6 +33,7 @@ namespace Locations {
 class Location : public PartyView {
 protected:
 	Shared::Xeen::SpriteResource _escSprite;
+	int _locationId = -1;
 
 protected:
 	/**
@@ -63,7 +64,12 @@ protected:
 	void backpackFull();
 
 public:
-	Location(const Common::String &name);
+	Location(const Common::String &name, int locationId);
+
+	/**
+	 * Game message handler
+	 */
+	bool msgGame(const GameMessage &msg) override;
 
 	/**
 	 * Leave the location, turning around
diff --git a/engines/mm/mm1/views_enh/locations/market.cpp b/engines/mm/mm1/views_enh/locations/market.cpp
index 57d81d78834..5ce244aad1f 100644
--- a/engines/mm/mm1/views_enh/locations/market.cpp
+++ b/engines/mm/mm1/views_enh/locations/market.cpp
@@ -28,7 +28,7 @@ namespace MM1 {
 namespace ViewsEnh {
 namespace Locations {
 
-Market::Market() : Location("Market") {
+Market::Market() : Location("Market", LOC_MARKET) {
 	addButton(&g_globals->_confirmIcons,
 		Common::Point(_innerBounds.width() / 2 - 24,
 			_innerBounds.height() - 22), 0, Common::KEYCODE_y);
@@ -41,9 +41,6 @@ bool Market::msgFocus(const FocusMessage &msg) {
 	Maps::Map &map = *g_maps->_currentMap;
 	_foodCost = FOOD_COST[map[Maps::MAP_ID] - 1];
 
-	(void)Location::msgFocus(msg);
-	send("View", GameMessage("LOCATION", LOC_MARKET));
-
 	return true;
 }
 
diff --git a/engines/mm/mm1/views_enh/locations/temple.cpp b/engines/mm/mm1/views_enh/locations/temple.cpp
index 9199f00f005..1ea2f1fd4c8 100644
--- a/engines/mm/mm1/views_enh/locations/temple.cpp
+++ b/engines/mm/mm1/views_enh/locations/temple.cpp
@@ -30,13 +30,12 @@ namespace MM1 {
 namespace ViewsEnh {
 namespace Locations {
 
-Temple::Temple() : Location("Temple") {
+Temple::Temple() : Location("Temple", LOC_TEMPLE) {
 	addButton(&_escSprite, Common::Point(24, 100), 0, KEYBIND_ESCAPE);
 }
 
 bool Temple::msgFocus(const FocusMessage &msg) {
 	(void)Location::msgFocus(msg);
-	send("View", GameMessage("LOCATION", LOC_TEMPLE));
 	updateCosts();
 
 	return true;
diff --git a/engines/mm/mm1/views_enh/scroll_text.h b/engines/mm/mm1/views_enh/scroll_text.h
index 0aef29b131d..11310cdae55 100644
--- a/engines/mm/mm1/views_enh/scroll_text.h
+++ b/engines/mm/mm1/views_enh/scroll_text.h
@@ -41,9 +41,9 @@ class ScrollText : public ScrollView {
 		byte _color = 0;
 		TextAlign _align = ALIGN_LEFT;
 
-		Line(const Common::String &str,
-			const Common::Point &pos, byte color = 0) :
-			_str(str), _pos(pos), _color(color) {
+		Line(const Common::String &str, const Common::Point &pos,
+			byte color = 0, TextAlign align = ALIGN_LEFT) :
+			_str(str), _pos(pos), _color(color), _align(align) {
 		}
 	};
 public:


Commit: 650d4f7edcd7f1e0a3b7fbb97b1c4def58cf9391
    https://github.com/scummvm/scummvm/commit/650d4f7edcd7f1e0a3b7fbb97b1c4def58cf9391
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:50-08:00

Commit Message:
MM: MM1: Fix center aligning signs

Changed paths:
    engines/mm/mm1/views_enh/game_messages.cpp


diff --git a/engines/mm/mm1/views_enh/game_messages.cpp b/engines/mm/mm1/views_enh/game_messages.cpp
index 01e6d6da9c8..f25985d8eef 100644
--- a/engines/mm/mm1/views_enh/game_messages.cpp
+++ b/engines/mm/mm1/views_enh/game_messages.cpp
@@ -79,7 +79,8 @@ bool GameMessages::msgInfo(const InfoMessage &msg) {
 	// Process the lines
 	clear();
 	for (auto line : msg._lines)
-		addText(line._text, line.y, 0, line._align, 0);
+		addText(line._text, line.y, 0,
+			(line.x > 0) ? ALIGN_MIDDLE : line._align, 0);
 
 	if (msg._delaySeconds)
 		delaySeconds(msg._delaySeconds);


Commit: 04cf0aa569becda57c29bbdbb4e0295ec2bd7e3b
    https://github.com/scummvm/scummvm/commit/04cf0aa569becda57c29bbdbb4e0295ec2bd7e3b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-26T22:23:50-08:00

Commit Message:
MM: MM1: Fix party highlight in market view

Changed paths:
    engines/mm/mm1/views_enh/locations/market.cpp
    engines/mm/mm1/views_enh/locations/temple.cpp
    engines/mm/mm1/views_enh/spells/cast_spell.cpp


diff --git a/engines/mm/mm1/views_enh/locations/market.cpp b/engines/mm/mm1/views_enh/locations/market.cpp
index 5ce244aad1f..6d7c813b0e4 100644
--- a/engines/mm/mm1/views_enh/locations/market.cpp
+++ b/engines/mm/mm1/views_enh/locations/market.cpp
@@ -38,6 +38,8 @@ Market::Market() : Location("Market", LOC_MARKET) {
 }
 
 bool Market::msgFocus(const FocusMessage &msg) {
+	Location::msgFocus(msg);
+
 	Maps::Map &map = *g_maps->_currentMap;
 	_foodCost = FOOD_COST[map[Maps::MAP_ID] - 1];
 
@@ -49,6 +51,8 @@ void Market::draw() {
 
 	writeLine(0, STRING["enhdialogs.market.title"],ALIGN_MIDDLE);
 	writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
+	writeLine(3, camelCase(g_globals->_currCharacter->_name), ALIGN_MIDDLE);
+
 	writeLine(6, STRING["enhdialogs.market.buy_food"], ALIGN_MIDDLE);
 	writeLine(7, Common::String::format("%d %s",
 		_foodCost, STRING["dialogs.market.gp"].c_str()),
diff --git a/engines/mm/mm1/views_enh/locations/temple.cpp b/engines/mm/mm1/views_enh/locations/temple.cpp
index 1ea2f1fd4c8..89aff2fc2c3 100644
--- a/engines/mm/mm1/views_enh/locations/temple.cpp
+++ b/engines/mm/mm1/views_enh/locations/temple.cpp
@@ -35,7 +35,7 @@ Temple::Temple() : Location("Temple", LOC_TEMPLE) {
 }
 
 bool Temple::msgFocus(const FocusMessage &msg) {
-	(void)Location::msgFocus(msg);
+	Location::msgFocus(msg);
 	updateCosts();
 
 	return true;
diff --git a/engines/mm/mm1/views_enh/spells/cast_spell.cpp b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
index d04c372557b..40dc0aa353c 100644
--- a/engines/mm/mm1/views_enh/spells/cast_spell.cpp
+++ b/engines/mm/mm1/views_enh/spells/cast_spell.cpp
@@ -45,7 +45,7 @@ bool CastSpell::msgFocus(const FocusMessage &msg) {
 }
 
 void CastSpell::draw() {
-	ScrollView::draw();
+	PartyView::draw();
 	_fontReduced = false;
 
 	const Character &c = *g_globals->_currCharacter;




More information about the Scummvm-git-logs mailing list