[Scummvm-git-logs] scummvm master -> c41ec578b3e172082bfb41f1d79f3979012d30dc
dreammaster
noreply at scummvm.org
Sat Apr 8 04:37:21 UTC 2023
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:
c41ec578b3 MM: MM1: Refactored Wheel Spin result into it's own view
Commit: c41ec578b3e172082bfb41f1d79f3979012d30dc
https://github.com/scummvm/scummvm/commit/c41ec578b3e172082bfb41f1d79f3979012d30dc
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-04-07T21:37:14-07:00
Commit Message:
MM: MM1: Refactored Wheel Spin result into it's own view
Changed paths:
A engines/mm/mm1/game/wheel_spin.cpp
A engines/mm/mm1/game/wheel_spin.h
A engines/mm/mm1/views/wheel_spin.cpp
A engines/mm/mm1/views/wheel_spin.h
A engines/mm/mm1/views_enh/wheel_spin.cpp
A engines/mm/mm1/views_enh/wheel_spin.h
engines/mm/mm1/maps/map16.cpp
engines/mm/mm1/maps/map16.h
engines/mm/mm1/views/dialogs.h
engines/mm/mm1/views_enh/dialogs.h
engines/mm/module.mk
diff --git a/engines/mm/mm1/game/wheel_spin.cpp b/engines/mm/mm1/game/wheel_spin.cpp
new file mode 100644
index 00000000000..d50db9f7476
--- /dev/null
+++ b/engines/mm/mm1/game/wheel_spin.cpp
@@ -0,0 +1,97 @@
+/* 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/game/wheel_spin.h"
+#include "mm/mm1/maps/map16.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace Game {
+
+#define VAL2 84
+#define VAL3 85
+#define VAL4 87
+
+void WheelSpin::spin() {
+ Maps::Map16 &map = *static_cast<Maps::Map16 *>(g_maps->_currentMap);
+ _results.clear();
+
+
+ for (uint i = 0; i < g_globals->_party.size(); ++i) {
+ Character &c = g_globals->_party[i];
+ g_globals->_currCharacter = &c;
+ map[VAL2] = i;
+
+ // Count set flags
+ map[VAL4] = 0;
+ byte v = c._flags[2];
+ for (int j = 0; j < 4; ++j, v >>= 1) {
+ if (v & 1)
+ map[VAL4]++;
+ }
+
+ Common::String line;
+
+ if (map[VAL4] == 0) {
+ line = STRING["maps.map16.loser"];
+ } else {
+ c._flags[2] |= CHARFLAG2_80;
+ int val;
+
+ switch (getRandomNumber(6)) {
+ case 1:
+ val = 2000 << map[VAL4];
+ WRITE_LE_UINT16(&map[VAL3], val);
+ c._exp += val;
+ line = Common::String::format("+%d %s", val,
+ STRING["maps.map16.exp"].c_str());
+ break;
+
+ case 2:
+ val = 500 << map[VAL4];
+ WRITE_LE_UINT16(&map[VAL3], val);
+ c._gold += val;
+ line = Common::String::format("+%d %s", val,
+ STRING["maps.map16.gold"].c_str());
+ break;
+
+ case 3:
+ val = 15 << map[VAL4];
+ WRITE_LE_UINT16(&map[VAL3], val);
+ c._gems += val;
+ line = Common::String::format("+%d %s", val,
+ STRING["maps.map16.gems"].c_str());
+ break;
+
+ default:
+ line = STRING["maps.map16.loser"];
+ break;
+ }
+ }
+
+ _results.push_back(line);
+ }
+}
+
+} // namespace Game
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/game/wheel_spin.h b/engines/mm/mm1/game/wheel_spin.h
new file mode 100644
index 00000000000..d13760dd49c
--- /dev/null
+++ b/engines/mm/mm1/game/wheel_spin.h
@@ -0,0 +1,47 @@
+/* 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_GAME_WHEEL_SPIN_H
+#define MM1_GAME_WHEEL_SPIN_H
+
+#include "common/str-array.h"
+#include "mm/mm1/game/game_logic.h"
+
+namespace MM {
+namespace MM1 {
+namespace Game {
+
+class WheelSpin : public GameLogic {
+protected:
+ Common::StringArray _results;
+public:
+ /**
+ * Spins the wheel for the party, and loads _results with
+ * the result for each character
+ */
+ void spin();
+};
+
+} // namespace Game
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/maps/map16.cpp b/engines/mm/mm1/maps/map16.cpp
index d8fd0b635b6..474d8fbb07c 100644
--- a/engines/mm/mm1/maps/map16.cpp
+++ b/engines/mm/mm1/maps/map16.cpp
@@ -30,9 +30,6 @@ namespace MM1 {
namespace Maps {
#define VAL1 83
-#define VAL2 84
-#define VAL3 85
-#define VAL4 87
void Map16::special() {
Game::Encounter &enc = g_globals->_encounters;
@@ -119,7 +116,7 @@ void Map16::special01() {
for (int i = 0; i < 20; ++i)
Sound::sound(SOUND_1);
- static_cast<Map16 *>(g_maps->_currentMap)->wheelSpin();
+ g_events->addView("WheelSpin");
}
));
}
@@ -134,72 +131,6 @@ void Map16::special03() {
g_globals->_encounters.execute();
}
-void Map16::wheelSpin() {
- Common::String line;
- int val;
- SoundMessage msg;
- msg._largeMessage = true;
-
- for (uint i = 0; i < g_globals->_party.size(); ++i) {
- Character &c = g_globals->_party[i];
- g_globals->_currCharacter = &c;
- _data[VAL2] = i;
-
- // Count set flags
- _data[VAL4] = 0;
- byte v = c._flags[2];
- for (int j = 0; j < 4; ++j, v >>= 1) {
- if (v & 1)
- _data[VAL4]++;
- }
-
- line = c._name;
- while (line.size() < 17)
- line += ' ';
-
- if (_data[VAL4] == 0) {
- line += STRING["maps.map16.loser"];
- } else {
- c._flags[2] |= CHARFLAG2_80;
-
- switch (getRandomNumber(6)) {
- case 1:
- val = 2000 << _data[VAL4];
- WRITE_LE_UINT16(&_data[VAL3], val);
- c._exp += val;
- line += Common::String::format("+%d %s", val,
- STRING["maps.map16.exp"].c_str());
- break;
-
- case 2:
- val = 500 << _data[VAL4];
- WRITE_LE_UINT16(&_data[VAL3], val);
- c._gold += val;
- line += Common::String::format("+%d %s", val,
- STRING["maps.map16.gold"].c_str());
- break;
-
- case 3:
- val = 15 << _data[VAL4];
- WRITE_LE_UINT16(&_data[VAL3], val);
- c._gems += val;
- line += Common::String::format("+%d %s", val,
- STRING["maps.map16.gems"].c_str());
- break;
-
- default:
- line += STRING["maps.map16.loser"];
- break;
- }
- }
-
- msg._lines.push_back(Line(0, 1 + i, line));
- }
-
- // Display the results
- send(msg);
-}
-
} // namespace Maps
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/maps/map16.h b/engines/mm/mm1/maps/map16.h
index 3b8f1e88b9f..4d1b02a9d39 100644
--- a/engines/mm/mm1/maps/map16.h
+++ b/engines/mm/mm1/maps/map16.h
@@ -53,11 +53,6 @@ public:
* Handles all special stuff that happens on the map
*/
void special() override;
-
- /**
- * Spins the wheel and grants each party member a result
- */
- void wheelSpin();
};
} // namespace Maps
diff --git a/engines/mm/mm1/views/dialogs.h b/engines/mm/mm1/views/dialogs.h
index 0ba78eca792..8aa44257b8a 100644
--- a/engines/mm/mm1/views/dialogs.h
+++ b/engines/mm/mm1/views/dialogs.h
@@ -44,6 +44,7 @@
#include "mm/mm1/views/search.h"
#include "mm/mm1/views/trap.h"
#include "mm/mm1/views/unlock.h"
+#include "mm/mm1/views/wheel_spin.h"
#include "mm/mm1/views/locations/blacksmith.h"
#include "mm/mm1/views/locations/inn.h"
#include "mm/mm1/views/locations/market.h"
@@ -90,6 +91,7 @@ struct Dialogs {
private:
Views::AreYouReady _areYouReady;
Views::Bash _bash;
+ Views::CharacterInfo _characterInfo;
Views::Characters _characters;
Views::CharacterViewCombat _characterViewCombat;
Views::Combat _combat;
@@ -106,7 +108,7 @@ private:
Views::Title _title;
Views::Trap _trap;
Views::Unlock _unlock;
- Views::CharacterInfo _characterInfo;
+ Views::WheelSpin _wheelSpin;
Views::Locations::Blacksmith _blacksmith;
Views::Locations::Inn _inn;
diff --git a/engines/mm/mm1/views/wheel_spin.cpp b/engines/mm/mm1/views/wheel_spin.cpp
new file mode 100644
index 00000000000..90b1b5a0339
--- /dev/null
+++ b/engines/mm/mm1/views/wheel_spin.cpp
@@ -0,0 +1,61 @@
+/* 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/wheel_spin.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace Views {
+
+WheelSpin::WheelSpin() : TextView("WheelSpin") {
+ _bounds = getLineBounds(17, 24);
+}
+
+bool WheelSpin::msgFocus(const FocusMessage &msg) {
+ TextView::msgFocus(msg);
+ spin();
+ return true;
+}
+
+void WheelSpin::draw() {
+ clearSurface();
+
+ for (uint i = 0; i < g_globals->_party.size(); ++i) {
+ const Character &c = g_globals->_party[i];
+ writeString(0, i, c._name);
+ writeString(17, i, _results[i]);
+ }
+}
+
+bool WheelSpin::msgKeypress(const KeypressMessage &msg) {
+ close();
+ return true;
+}
+
+bool WheelSpin::msgAction(const ActionMessage &msg) {
+ close();
+ return true;
+}
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views/wheel_spin.h b/engines/mm/mm1/views/wheel_spin.h
new file mode 100644
index 00000000000..b43a750d597
--- /dev/null
+++ b/engines/mm/mm1/views/wheel_spin.h
@@ -0,0 +1,47 @@
+/* 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_WHEEL_SPIN_H
+#define MM1_VIEWS_WHEEL_SPIN_H
+
+#include "mm/mm1/views/text_view.h"
+#include "mm/mm1/game/wheel_spin.h"
+
+namespace MM {
+namespace MM1 {
+namespace Views {
+
+class WheelSpin : public TextView, public MM1::Game::WheelSpin {
+public:
+ WheelSpin();
+ virtual ~WheelSpin() {}
+
+ bool msgFocus(const FocusMessage &msg) override;
+ void draw() override;
+ bool msgKeypress(const KeypressMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+};
+
+} // namespace Views
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/mm1/views_enh/dialogs.h b/engines/mm/mm1/views_enh/dialogs.h
index 4dea21aceb0..816e8ae966f 100644
--- a/engines/mm/mm1/views_enh/dialogs.h
+++ b/engines/mm/mm1/views_enh/dialogs.h
@@ -46,6 +46,7 @@
#include "mm/mm1/views_enh/trade.h"
#include "mm/mm1/views_enh/trap.h"
#include "mm/mm1/views_enh/unlock.h"
+#include "mm/mm1/views_enh/wheel_spin.h"
#include "mm/mm1/views_enh/which_character.h"
#include "mm/mm1/views_enh/which_item.h"
#include "mm/mm1/views_enh/who_will_try.h"
@@ -116,6 +117,7 @@ private:
ViewsEnh::Trade _trade;
ViewsEnh::Trap _trap;
ViewsEnh::Unlock _unlock;
+ ViewsEnh::WheelSpin _wheelSpin;
ViewsEnh::WhichCharacter _whichCharacter;
ViewsEnh::WhichItem _whichItem;
ViewsEnh::WhoWillTry _whoWillTry;
diff --git a/engines/mm/mm1/views_enh/wheel_spin.cpp b/engines/mm/mm1/views_enh/wheel_spin.cpp
new file mode 100644
index 00000000000..120ba54509f
--- /dev/null
+++ b/engines/mm/mm1/views_enh/wheel_spin.cpp
@@ -0,0 +1,61 @@
+/* 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/wheel_spin.h"
+#include "mm/mm1/globals.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+WheelSpin::WheelSpin() : ScrollView("WheelSpin") {
+ setBounds(Common::Rect(0, 90, 234, 200));
+}
+
+bool WheelSpin::msgFocus(const FocusMessage &msg) {
+ TextView::msgFocus(msg);
+ spin();
+ return true;
+}
+
+void WheelSpin::draw() {
+ ScrollView::draw();
+
+ for (uint i = 0; i < g_globals->_party.size(); ++i) {
+ const Character &c = g_globals->_party[i];
+ writeLine(i, c._name, ALIGN_LEFT, 0);
+ writeLine(i, _results[i], ALIGN_LEFT, 100);
+ }
+}
+
+bool WheelSpin::msgKeypress(const KeypressMessage &msg) {
+ close();
+ return true;
+}
+
+bool WheelSpin::msgAction(const ActionMessage &msg) {
+ close();
+ return true;
+}
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/wheel_spin.h b/engines/mm/mm1/views_enh/wheel_spin.h
new file mode 100644
index 00000000000..5874ae86058
--- /dev/null
+++ b/engines/mm/mm1/views_enh/wheel_spin.h
@@ -0,0 +1,48 @@
+/* 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_WHEEL_SPIN_H
+#define MM1_VIEWS_ENH_WHEEL_SPIN_H
+
+#include "mm/mm1/views_enh/scroll_view.h"
+#include "mm/mm1/game/wheel_spin.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+class WheelSpin : public ScrollView, public MM1::Game::WheelSpin {
+public:
+ WheelSpin();
+ virtual ~WheelSpin() {}
+
+ bool msgFocus(const FocusMessage &msg) override;
+ void draw() override;
+ bool msgKeypress(const KeypressMessage &msg) override;
+ bool msgAction(const ActionMessage &msg) override;
+
+};
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
+
+#endif
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 33ac255182d..43308b91eba 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -48,6 +48,7 @@ MODULE_OBJS += \
mm1/game/spells_monsters.o \
mm1/game/use_item.o \
mm1/game/view_base.o \
+ mm1/game/wheel_spin.o \
mm1/gfx/dta.o \
mm1/gfx/gfx.o \
mm1/gfx/screen_decoder.o \
@@ -125,6 +126,7 @@ MODULE_OBJS += \
mm1/views/text_view.o \
mm1/views/trap.o \
mm1/views/unlock.o \
+ mm1/views/wheel_spin.o \
mm1/views_enh/spells/cast_spell.o \
mm1/views_enh/spells/spellbook.o \
mm1/views_enh/button_container.o \
@@ -165,6 +167,7 @@ MODULE_OBJS += \
mm1/views_enh/trade.o \
mm1/views_enh/trap.o \
mm1/views_enh/unlock.o \
+ mm1/views_enh/wheel_spin.o \
mm1/views_enh/which_character.o \
mm1/views_enh/which_item.o \
mm1/views_enh/who_will_try.o \
More information about the Scummvm-git-logs
mailing list