[Scummvm-git-logs] scummvm master -> b9997c740668fa27017a38dd88fb5e87615076a3

dreammaster noreply at scummvm.org
Wed Mar 1 06:34:16 UTC 2023


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

Summary:
895c70a71b MM: MM1: More interaction display
ad795f109a MM: MM1: Add interaction view titles
b9997c7406 MM: MM1: In progress training view


Commit: 895c70a71b18dfdd59d9d5ec3d28fae170229714
    https://github.com/scummvm/scummvm/commit/895c70a71b18dfdd59d9d5ec3d28fae170229714
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-28T20:26:14-08:00

Commit Message:
MM: MM1: More interaction display

Changed paths:
    engines/mm/mm1/views_enh/interactions/interaction.cpp
    engines/mm/mm1/views_enh/interactions/interaction.h
    engines/mm/mm1/views_enh/interactions/statue.cpp
    engines/mm/mm1/views_enh/interactions/statue.h


diff --git a/engines/mm/mm1/views_enh/interactions/interaction.cpp b/engines/mm/mm1/views_enh/interactions/interaction.cpp
index d0cb802c7b1..b8a4e79af25 100644
--- a/engines/mm/mm1/views_enh/interactions/interaction.cpp
+++ b/engines/mm/mm1/views_enh/interactions/interaction.cpp
@@ -23,6 +23,7 @@
 #include "mm/mm1/globals.h"
 #include "mm/mm1/mm1.h"
 #include "mm/mm1/sound.h"
+#include "mm/shared/utils/strings.h"
 
 namespace MM {
 namespace MM1 {
@@ -35,6 +36,10 @@ Interaction::Interaction(const Common::String &name, int portrait) : ScrollView(
 	_portrait.load(Common::String::format("face%02d.fac", portrait));
 }
 
+void Interaction::addText(const Common::String &str) {
+	_lines = splitLines(searchAndReplace(str, "\n", " "));
+}
+
 bool Interaction::msgGame(const GameMessage &msg) {
 	if (msg._name == "DISPLAY") {
 		addView(this);
@@ -53,8 +58,12 @@ void Interaction::draw() {
   	ScrollView::draw();
 
 	Graphics::ManagedSurface s = getSurface();
-	_frame.draw(&s, 0, Common::Point(16, 16));
-	_portrait.draw(&s, _portraitFrameNum, Common::Point(23, 22));
+	_frame.draw(&s, 0, Common::Point(8, 8));
+	_portrait.draw(&s, _portraitFrameNum, Common::Point(15, 14));
+
+	for (uint i = 0; i < _lines.size(); ++i) {
+		writeLine(6 + i, _lines[i], ALIGN_MIDDLE);
+	}
 }
 
 bool Interaction::tick() {
@@ -75,6 +84,38 @@ void Interaction::leave() {
 	g_events->redraw();
 }
 
+bool Interaction::msgKeypress(const KeypressMessage &msg) {
+	viewAction();
+	return true;
+}
+
+bool Interaction::msgAction(const ActionMessage &msg) {
+	if (msg._action == KEYBIND_ESCAPE) {
+		leave();
+
+	} else if (msg._action == KEYBIND_SELECT) {
+		// ***DEBUG*** - Used for cycling through portraits.
+		// To let me pick good portraits from Xeen
+		_animated = false;
+		_lines.clear();
+		++_portraitNum;
+		_portrait.load(Common::String::format("face%02d.fac", _portraitNum));
+
+		Interaction::draw();
+		writeNumber(20, 70, _portraitNum);
+
+	} else {
+		viewAction();
+	}
+
+	return true;
+}
+
+bool Interaction::msgMouseDown(const MouseDownMessage &msg) {
+	viewAction();
+	return true;
+}
+
 } // namespace Interactions
 } // namespace ViewsEnh
 } // namespace MM1
diff --git a/engines/mm/mm1/views_enh/interactions/interaction.h b/engines/mm/mm1/views_enh/interactions/interaction.h
index e97eceeff07..c8d7a04461b 100644
--- a/engines/mm/mm1/views_enh/interactions/interaction.h
+++ b/engines/mm/mm1/views_enh/interactions/interaction.h
@@ -37,7 +37,22 @@ private:
 	int _tickCtr = 0;
 	int _portraitFrameNum = 0;
 protected:
+	Common::StringArray _lines;
 	bool _animated = true;
+	int _portraitNum = 0;
+protected:
+	/**
+	 * Handles any action/press
+	 */
+	virtual void viewAction() {
+		leave();
+	}
+
+	/**
+	 * Adds text for display
+	 */
+	void addText(const Common::String &str);
+
 public:
 	Interaction(const Common::String &name, int portrait);
 
@@ -65,6 +80,21 @@ public:
 	 * Leave the location, turning around
 	 */
 	void leave();
+
+	/**
+	 * Keypress handler
+	 */
+	bool msgKeypress(const KeypressMessage &msg) override;
+
+	/**
+	 * Action handler
+	 */
+	bool msgAction(const ActionMessage &msg) override;
+
+	/**
+	 * Mouse click handler
+	 */
+	bool msgMouseDown(const MouseDownMessage &msg) override;
 };
 
 } // namespace Interactions
diff --git a/engines/mm/mm1/views_enh/interactions/statue.cpp b/engines/mm/mm1/views_enh/interactions/statue.cpp
index a571fb4e9c2..ac64dbdd166 100644
--- a/engines/mm/mm1/views_enh/interactions/statue.cpp
+++ b/engines/mm/mm1/views_enh/interactions/statue.cpp
@@ -20,18 +20,21 @@
  */
 
 #include "mm/mm1/views_enh/interactions/statue.h"
+#include "mm/mm1/globals.h"
+
 
 namespace MM {
 namespace MM1 {
 namespace ViewsEnh {
 namespace Interactions {
 
-Statue::Statue() : Interaction("Statue", 1) {
+Statue::Statue() : Interaction("Statue", 33) {
+	_animated = false;
 }
 
 bool Statue::msgGame(const GameMessage &msg) {
 	if (msg._name == "STATUE") {
-		_topLine = 0;
+		_pageNum = 0;
 		_statueNum = msg._value;
 		addView(this);
 		return true;
@@ -40,6 +43,32 @@ bool Statue::msgGame(const GameMessage &msg) {
 	return false;
 }
 
+bool Statue::msgFocus(const FocusMessage &msg) {
+	Common::String statueType = STRING[Common::String::format(
+		"dialogs.statues.names.%d", _statueNum)];
+	Common::String str = Common::String::format("%s%s. %s",
+		STRING["dialogs.statues.stone"].c_str(),
+		statueType.c_str(),
+		STRING["dialogs.statues.plaque"].c_str()
+	);
+
+	addText(str);
+	return true;
+}
+
+void Statue::viewAction() {
+	switch (++_pageNum) {
+	case 1:
+		addText(STRING[Common::String::format(
+			"dialogs.statues.messages.%d", _statueNum)]);
+		redraw();
+		break;
+	default:
+		leave();
+		break;
+	}
+}
+
 } // namespace Interactions
 } // namespace ViewsEnh
 } // namespace MM1
diff --git a/engines/mm/mm1/views_enh/interactions/statue.h b/engines/mm/mm1/views_enh/interactions/statue.h
index 270e5e173cc..4a80fea697c 100644
--- a/engines/mm/mm1/views_enh/interactions/statue.h
+++ b/engines/mm/mm1/views_enh/interactions/statue.h
@@ -32,7 +32,14 @@ namespace Interactions {
 class Statue : public Interaction {
 private:
 	int _statueNum = 0;
-	int _topLine = 0;
+	int _pageNum = 0;
+
+protected:
+	/**
+	 * Handles any action/press
+	 */
+	void viewAction() override;
+
 public:
 	Statue();
 
@@ -40,6 +47,11 @@ public:
 	 * Handles game message
 	 */
 	bool msgGame(const GameMessage &msg) override;
+
+	/**
+	 * Handles focus
+	 */
+	bool msgFocus(const FocusMessage &msg) override;
 };
 
 } // namespace Interactions


Commit: ad795f109a96efa2217203b07983e2c8f7cb7ab7
    https://github.com/scummvm/scummvm/commit/ad795f109a96efa2217203b07983e2c8f7cb7ab7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-28T20:26:14-08:00

Commit Message:
MM: MM1: Add interaction view titles

Changed paths:
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/interactions/interaction.cpp
    engines/mm/mm1/views_enh/interactions/interaction.h
    engines/mm/mm1/views_enh/interactions/statue.cpp
    engines/mm/mm1/views_enh/interactions/statue.h
    engines/mm/mm1/views_enh/text_view.cpp
    engines/mm/mm1/views_enh/text_view.h


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index d29053dadd1..642d7ab3c9f 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -177,6 +177,7 @@ dialogs:
 	statues:
 		stone: "On this stone statue of "
 		plaque: "A plaque reads..."
+		statue: "Statue"
 		names:
 			0: "a human knight"
 			1: "an elven wizard"
diff --git a/engines/mm/mm1/views_enh/interactions/interaction.cpp b/engines/mm/mm1/views_enh/interactions/interaction.cpp
index b8a4e79af25..47c93a2aa01 100644
--- a/engines/mm/mm1/views_enh/interactions/interaction.cpp
+++ b/engines/mm/mm1/views_enh/interactions/interaction.cpp
@@ -61,6 +61,11 @@ void Interaction::draw() {
 	_frame.draw(&s, 0, Common::Point(8, 8));
 	_portrait.draw(&s, _portraitFrameNum, Common::Point(15, 14));
 
+	if (!_title.empty()) {
+		size_t strWidth = getStringWidth(_title);
+		writeString(125 - strWidth / 2, 20, _title);
+	}
+
 	for (uint i = 0; i < _lines.size(); ++i) {
 		writeLine(6 + i, _lines[i], ALIGN_MIDDLE);
 	}
diff --git a/engines/mm/mm1/views_enh/interactions/interaction.h b/engines/mm/mm1/views_enh/interactions/interaction.h
index c8d7a04461b..8fa116c8a2d 100644
--- a/engines/mm/mm1/views_enh/interactions/interaction.h
+++ b/engines/mm/mm1/views_enh/interactions/interaction.h
@@ -37,6 +37,7 @@ private:
 	int _tickCtr = 0;
 	int _portraitFrameNum = 0;
 protected:
+	Common::String _title;
 	Common::StringArray _lines;
 	bool _animated = true;
 	int _portraitNum = 0;
diff --git a/engines/mm/mm1/views_enh/interactions/statue.cpp b/engines/mm/mm1/views_enh/interactions/statue.cpp
index ac64dbdd166..cedb5e2f0d7 100644
--- a/engines/mm/mm1/views_enh/interactions/statue.cpp
+++ b/engines/mm/mm1/views_enh/interactions/statue.cpp
@@ -29,6 +29,7 @@ namespace ViewsEnh {
 namespace Interactions {
 
 Statue::Statue() : Interaction("Statue", 33) {
+	_title = STRING["dialogs.statues.statue"];
 	_animated = false;
 }
 
diff --git a/engines/mm/mm1/views_enh/interactions/statue.h b/engines/mm/mm1/views_enh/interactions/statue.h
index 4a80fea697c..f718e9abc1a 100644
--- a/engines/mm/mm1/views_enh/interactions/statue.h
+++ b/engines/mm/mm1/views_enh/interactions/statue.h
@@ -33,7 +33,6 @@ class Statue : public Interaction {
 private:
 	int _statueNum = 0;
 	int _pageNum = 0;
-
 protected:
 	/**
 	 * Handles any action/press
diff --git a/engines/mm/mm1/views_enh/text_view.cpp b/engines/mm/mm1/views_enh/text_view.cpp
index e82773c48d0..0e66786255e 100644
--- a/engines/mm/mm1/views_enh/text_view.cpp
+++ b/engines/mm/mm1/views_enh/text_view.cpp
@@ -171,6 +171,10 @@ void TextView::writeLine(int lineNum, const Common::String &str,
 	writeString(xp, lineNum * ROW_HEIGHT, str, align);
 }
 
+size_t TextView::getStringWidth(const Common::String &str) {
+	return getFont()->getStringWidth(str);
+}
+
 void TextView::newLine() {
 	_textPos.x = 0;
 	_textPos.y += ROW_HEIGHT;
diff --git a/engines/mm/mm1/views_enh/text_view.h b/engines/mm/mm1/views_enh/text_view.h
index 3e3828129f4..5ec95099906 100644
--- a/engines/mm/mm1/views_enh/text_view.h
+++ b/engines/mm/mm1/views_enh/text_view.h
@@ -74,6 +74,11 @@ protected:
 	void writeLine(int lineNum, const Common::String &str,
 		TextAlign align = ALIGN_LEFT, int xp = 0);
 
+	/**
+	 * Gets the string width
+	 */
+	size_t getStringWidth(const Common::String &str);
+
 	/**
 	 * Move the text position to the next line
 	 */


Commit: b9997c740668fa27017a38dd88fb5e87615076a3
    https://github.com/scummvm/scummvm/commit/b9997c740668fa27017a38dd88fb5e87615076a3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-28T22:33:57-08:00

Commit Message:
MM: MM1: In progress training view

Changed paths:
  A engines/mm/mm1/views_enh/locations/training.cpp
  A engines/mm/mm1/views_enh/locations/training.h
    devtools/create_mm/files/mm1/strings_en.yml
    engines/mm/mm1/views_enh/dialogs.h
    engines/mm/mm1/views_enh/game_view.cpp
    engines/mm/mm1/views_enh/interactions/interaction.cpp
    engines/mm/mm1/views_enh/locations/temple.cpp
    engines/mm/module.mk


diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 642d7ab3c9f..db413c4bf1f 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -522,6 +522,10 @@ enhdialogs:
 		donate: "\x01""37Donate"
 		uncurse: "\x01""37Uncurse"
 		realign: "\x01""37Re-align"
+	training:
+		title: "Training"
+		train: "\x01""37Train"
+		esc: "ESC"
 stats:
 	none: "None"
 	inventory: "-----<Equipped>----------<Backpack>----"
diff --git a/engines/mm/mm1/views_enh/dialogs.h b/engines/mm/mm1/views_enh/dialogs.h
index 65cbb3f26c3..13be24d3482 100644
--- a/engines/mm/mm1/views_enh/dialogs.h
+++ b/engines/mm/mm1/views_enh/dialogs.h
@@ -37,6 +37,7 @@
 #include "mm/mm1/views_enh/interactions/statue.h"
 #include "mm/mm1/views_enh/locations/market.h"
 #include "mm/mm1/views_enh/locations/temple.h"
+#include "mm/mm1/views_enh/locations/training.h"
 #include "mm/mm1/views_enh/spells/cast_spell.h"
 #include "mm/mm1/views_enh/spells/spellbook.h"
 
@@ -54,6 +55,7 @@ private:
 	ViewsEnh::Interactions::Statue _statue;
 	ViewsEnh::Locations::Market _market;
 	ViewsEnh::Locations::Temple _temple;
+	ViewsEnh::Locations::Training _training;
 	ViewsEnh::Spells::CastSpell _castSpell;
 	ViewsEnh::Spells::Spellbook _spellbook;
 	ViewsEnh::CharacterInfo _characterInfo;
diff --git a/engines/mm/mm1/views_enh/game_view.cpp b/engines/mm/mm1/views_enh/game_view.cpp
index 02b397c3906..f1df338ee6c 100644
--- a/engines/mm/mm1/views_enh/game_view.cpp
+++ b/engines/mm/mm1/views_enh/game_view.cpp
@@ -118,7 +118,7 @@ public:
 	}
 
 	void enter() override {
-		_sound.playVoice("hello1.voc");
+		_sound.playVoice("training.voc");
 		_sound.playSong("grounds.m");
 	}
 };
diff --git a/engines/mm/mm1/views_enh/interactions/interaction.cpp b/engines/mm/mm1/views_enh/interactions/interaction.cpp
index 47c93a2aa01..45c969d16ba 100644
--- a/engines/mm/mm1/views_enh/interactions/interaction.cpp
+++ b/engines/mm/mm1/views_enh/interactions/interaction.cpp
@@ -74,7 +74,7 @@ void Interaction::draw() {
 bool Interaction::tick() {
 	if (_animated && ++_tickCtr >= 10) {
 		_tickCtr = 0;
-		_portraitFrameNum = g_engine->getRandomNumber(3);
+		_portraitFrameNum = g_engine->getRandomNumber(0, 3);
 		redraw();
 	}
 
diff --git a/engines/mm/mm1/views_enh/locations/temple.cpp b/engines/mm/mm1/views_enh/locations/temple.cpp
index 89aff2fc2c3..a3521266e12 100644
--- a/engines/mm/mm1/views_enh/locations/temple.cpp
+++ b/engines/mm/mm1/views_enh/locations/temple.cpp
@@ -107,7 +107,7 @@ bool Temple::msgAction(const ActionMessage &msg) {
 		leave();
 		return true;
 	default:
-		return Location::msgAction(msg);;
+		return Location::msgAction(msg);
 	}
 }
 
diff --git a/engines/mm/mm1/views_enh/locations/training.cpp b/engines/mm/mm1/views_enh/locations/training.cpp
new file mode 100644
index 00000000000..298ebf313e4
--- /dev/null
+++ b/engines/mm/mm1/views_enh/locations/training.cpp
@@ -0,0 +1,176 @@
+/* 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/>.
+ *
+ */
+
+#include "mm/mm1/views_enh/locations/training.h"
+#include "mm/mm1/globals.h"
+#include "mm/mm1/mm1.h"
+#include "mm/mm1/sound.h"
+#include "mm/shared/utils/strings.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+namespace Locations {
+
+Training::Training() : Location("Training", LOC_TRAINING) {
+	_trainSprite.load("train.icn");
+	addButton(&_trainSprite, Common::Point(5, 100), 2, Common::KEYCODE_t);
+	addButton(&_escSprite, Common::Point(40, 100), 0, KEYBIND_ESCAPE);
+}
+
+bool Training::msgFocus(const FocusMessage &msg) {
+	Location::msgFocus(msg);
+	return true;
+}
+
+void Training::draw() {
+	Location::draw();
+
+	setReduced(false);
+	writeLine(0, STRING["enhdialogs.training.title"], ALIGN_MIDDLE);
+	writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
+	writeLine(3, camelCase(g_globals->_currCharacter->_name), ALIGN_MIDDLE);
+
+	writeLine(10, STRING["enhdialogs.location.gold"]);
+	writeLine(10, Common::String::format("%d",
+		g_globals->_currCharacter->_gold), ALIGN_RIGHT);
+
+	setReduced(true);
+	writeString(5, 122, STRING["enhdialogs.training.train"]);
+	writeString(43, 122, STRING["enhdialogs.training.esc"]);
+}
+
+bool Training::msgKeypress(const KeypressMessage &msg) {
+	// If a delay is active, end it
+	if (endDelay())
+		return true;
+
+	switch (msg.keycode) {
+	case Common::KEYCODE_a:
+		if (_canTrain)
+			train();
+		break;
+	case Common::KEYCODE_g:
+		g_globals->_currCharacter->gatherGold();
+		redraw();
+		break;
+	default:
+		break;
+	}
+
+	return true;
+}
+
+bool Training::msgAction(const ActionMessage &msg) {
+	if (endDelay())
+		return true;
+
+	if (msg._action == KEYBIND_ESCAPE) {
+		leave();
+		return true;
+	}
+
+	return false;
+}
+
+void Training::checkCharacter() {
+	Character &c = *g_globals->_currCharacter;
+
+	_currLevel = c._level._base;
+	if (_currLevel >= MAX_LEVEL)
+		return;
+
+	// Initialize fields
+	_expTotal = 0;
+	_remainingExp = 0;
+	_expAmount = 0;
+	_cost = _cost2 = 0;
+	_canTrain = false;
+	_canAfford = false;
+	_class = c._class;
+
+	if (_class == KNIGHT || _class == CLERIC || _class == ROBBER) {
+		_expTotal = 1500;
+		_expAmount = 150000;
+
+		if (_currLevel != 0) {
+			_cost = _currLevel >= 8 ? 3000 :
+				TRAINING_COSTS1[_currLevel - 1];
+		}
+	} else {
+		_expTotal = 2000;
+		_expAmount = 200000;
+		_cost = _currLevel >= 8 ? 4000 :
+			TRAINING_COSTS2[_currLevel - 1];
+	}
+
+	for (int level = _currLevel - 1, ctr = 0; level > 0; --level) {
+		_expTotal *= 16;
+
+		if (++ctr >= 7) {
+			while (--level > 0)
+				_expTotal += _expAmount;
+			break;
+		}
+	}
+
+	_remainingExp = _expTotal - c._exp;
+	_canTrain = _remainingExp <= 0;
+	_canAfford = (int)c._gold >= _cost;
+}
+
+void Training::train() {
+	Character &c = *g_globals->_currCharacter;
+
+	if (c._condition) {
+		Sound::sound(SOUND_3);
+		clearSurface();
+		writeString(8, 5, STRING["dialogs.training.condition"]);
+		delaySeconds(3);
+
+	} else if (!_canAfford) {
+		notEnoughGold();
+
+	} else {
+		// Do the actual training
+		c._gold -= _cost;
+		Character::LevelIncrease lvl = c.increaseLevel();
+		Sound::sound(SOUND_2);
+
+		clearSurface();
+		writeString(0, 3, STRING["dialogs.training.congrats"]);
+		writeNumber(c._level._base);
+
+		writeString(7, 5, Common::String::format(
+			STRING["dialogs.training.hp"].c_str(), lvl._numHP));
+
+		if (lvl._numSpells != 0)
+			writeString(7, 6, STRING["dialogs.training.new_spells"]);
+
+		Sound::sound(SOUND_2);
+		delaySeconds(10);
+	}
+}
+
+} // namespace Location
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/locations/training.h b/engines/mm/mm1/views_enh/locations/training.h
new file mode 100644
index 00000000000..088c104c5c1
--- /dev/null
+++ b/engines/mm/mm1/views_enh/locations/training.h
@@ -0,0 +1,70 @@
+/* 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 MM1_VIEWS_ENH_LOCATIONS_TRAINING_H
+#define MM1_VIEWS_ENH_LOCATIONS_TRAINING_H
+
+#include "mm/mm1/views_enh/locations/location.h"
+#include "mm/mm1/data/character.h"
+#include "mm/mm1/data/locations.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+namespace Locations {
+
+class Training : public Location, public TrainingData {
+private:
+	Shared::Xeen::SpriteResource _trainSprite;
+	int _currLevel = 0;
+	CharacterClass _class = KNIGHT;
+	int _expTotal = 0;
+	int _remainingExp = 0;
+	int _expAmount = 0;
+	int _cost = 0, _cost2;
+	bool _canTrain = false;
+	bool _canAfford = false;
+private:
+	/**
+	 * Checks whether a character can train
+	 */
+	void checkCharacter();
+
+	/**
+	 * Validates if training is allowed, then trains.
+	 */
+	void train();
+
+public:
+	Training();
+
+	bool msgFocus(const FocusMessage &msg) override;
+	void draw() override;
+	bool msgKeypress(const KeypressMessage &msg) override;
+	bool msgAction(const ActionMessage &msg) override;
+};
+
+} // namespace Locations
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 6a8d63cfcb6..d3eb315d750 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -147,6 +147,7 @@ MODULE_OBJS += \
 	mm1/views_enh/locations/location.o \
 	mm1/views_enh/locations/market.o \
 	mm1/views_enh/locations/temple.o \
+	mm1/views_enh/locations/training.o \
 	mm1/maps/maps.o \
 	mm1/maps/map.o \
 	mm1/maps/map_desert.o \




More information about the Scummvm-git-logs mailing list