From 73e0229decda14962fcef1ac3006332d4c188e44 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 9 Apr 2023 17:35:18 -0700 Subject: [PATCH] MM: MM1: Added separate view for the druid Arenko --- devtools/create_mm/files/mm1/strings_en.yml | 6 ++ engines/mm/mm1/game/arenko.cpp | 50 ++++++++++ engines/mm/mm1/game/arenko.h | 42 ++++++++ engines/mm/mm1/maps/map28.cpp | 38 +------ engines/mm/mm1/views/dialogs.h | 2 + engines/mm/mm1/views/maps/arenko.cpp | 98 +++++++++++++++++++ engines/mm/mm1/views/maps/arenko.h | 51 ++++++++++ engines/mm/mm1/views_enh/dialogs.h | 2 + .../mm/mm1/views_enh/interactions/arenko.cpp | 97 ++++++++++++++++++ .../mm/mm1/views_enh/interactions/arenko.h | 50 ++++++++++ engines/mm/module.mk | 3 + 11 files changed, 402 insertions(+), 37 deletions(-) create mode 100644 engines/mm/mm1/game/arenko.cpp create mode 100644 engines/mm/mm1/game/arenko.h create mode 100644 engines/mm/mm1/views/maps/arenko.cpp create mode 100644 engines/mm/mm1/views/maps/arenko.h create mode 100644 engines/mm/mm1/views_enh/interactions/arenko.cpp create mode 100644 engines/mm/mm1/views_enh/interactions/arenko.h diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml index da359808b12..a80896de089 100644 --- a/devtools/create_mm/files/mm1/strings_en.yml +++ b/devtools/create_mm/files/mm1/strings_en.yml @@ -1394,6 +1394,12 @@ maps: cursed: "Cursed" keep_climbing: "Keep climbing." sign: "Roadsign: Algary S.9" + emap28: + arenko_title: "Arenko" + well_done: "Well done! What is your pleasure?" + gold: "Gold" + gems: "Gems" + item: "Item" map29: algary: "Algary, enter (Y/N)?" diff --git a/engines/mm/mm1/game/arenko.cpp b/engines/mm/mm1/game/arenko.cpp new file mode 100644 index 00000000000..3bb664ca698 --- /dev/null +++ b/engines/mm/mm1/game/arenko.cpp @@ -0,0 +1,50 @@ +/* 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 . + * + */ + +#include "mm/mm1/game/arenko.h" +#include "mm/mm1/globals.h" + + +namespace MM { +namespace MM1 { +namespace Game { + +void Arenko::giveGold() { + g_globals->_treasure.setGold((getRandomNumber(8) + 8) * 256); + g_maps->clearSpecial(); + g_events->addAction(KEYBIND_SEARCH); +} + +void Arenko::giveGems() { + g_globals->_treasure.setGems(getRandomNumber(50) + 200); + g_maps->clearSpecial(); + g_events->addAction(KEYBIND_SEARCH); +} + +void Arenko::giveItem() { + g_globals->_treasure._items[2] = getRandomNumber(22) + 196; + g_maps->clearSpecial(); + g_events->addAction(KEYBIND_SEARCH); +} + +} // namespace Game +} // namespace MM1 +} // namespace MM diff --git a/engines/mm/mm1/game/arenko.h b/engines/mm/mm1/game/arenko.h new file mode 100644 index 00000000000..e73bddb7e09 --- /dev/null +++ b/engines/mm/mm1/game/arenko.h @@ -0,0 +1,42 @@ +/* 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 . + * + */ + +#ifndef MM1_GAME_ARENKO_H +#define MM1_GAME_ARENKO_H + +#include "mm/mm1/game/game_logic.h" + +namespace MM { +namespace MM1 { +namespace Game { + +class Arenko : public GameLogic { +public: + void giveGold(); + void giveGems(); + void giveItem(); +}; + +} // namespace Game +} // namespace MM1 +} // namespace MM + +#endif diff --git a/engines/mm/mm1/maps/map28.cpp b/engines/mm/mm1/maps/map28.cpp index 1416af8dacc..a0bc36cadf7 100644 --- a/engines/mm/mm1/maps/map28.cpp +++ b/engines/mm/mm1/maps/map28.cpp @@ -135,43 +135,7 @@ void Map28::special() { } void Map28::special00() { - if (!_data[VAL1]) { - send(SoundMessage(STRING["maps.map28.arenko"])); - _data[VAL2] = 1; - } else if (_data[VAL1] < 19) { - send(SoundMessage(STRING["maps.map28.keep_climbing"])); - } else { - send(SoundMessage( - STRING["maps.map28.well_done"], - [](const Common::KeyState &ks) { - switch (ks.keycode) { - case Common::KEYCODE_a: - g_events->close(); - g_globals->_treasure.setGold((g_events->getRandomNumber(8) + 8) * 256); - g_maps->clearSpecial(); - g_events->addAction(KEYBIND_SEARCH); - break; - - case Common::KEYCODE_b: - g_events->close(); - g_globals->_treasure.setGems(g_events->getRandomNumber(50) + 200); - g_maps->clearSpecial(); - g_events->addAction(KEYBIND_SEARCH); - break; - - case Common::KEYCODE_c: - g_events->close(); - g_globals->_treasure._items[2] = g_events->getRandomNumber(22) + 196; - g_maps->clearSpecial(); - g_events->addAction(KEYBIND_SEARCH); - break; - - default: - break; - } - } - )); - } + g_events->addView("Arenko"); } void Map28::special01() { diff --git a/engines/mm/mm1/views/dialogs.h b/engines/mm/mm1/views/dialogs.h index d5afba41807..787afdf0aa4 100644 --- a/engines/mm/mm1/views/dialogs.h +++ b/engines/mm/mm1/views/dialogs.h @@ -56,6 +56,7 @@ #include "mm/mm1/views/maps/access_code.h" #include "mm/mm1/views/maps/alamar.h" #include "mm/mm1/views/maps/alien.h" +#include "mm/mm1/views/maps/arenko.h" #include "mm/mm1/views/maps/arrested.h" #include "mm/mm1/views/maps/chess.h" #include "mm/mm1/views/maps/dog_statue.h" @@ -123,6 +124,7 @@ private: Views::Maps::AccessCode _accessCode; Views::Maps::Alamar _alamar; Views::Maps::Alien _alien; + Views::Maps::Arenko _arenko; Views::Maps::Arrested _arrested; Views::Maps::Chess _chess; Views::Maps::ChildPrisoner _childPrisoner; diff --git a/engines/mm/mm1/views/maps/arenko.cpp b/engines/mm/mm1/views/maps/arenko.cpp new file mode 100644 index 00000000000..021e0c7b2ee --- /dev/null +++ b/engines/mm/mm1/views/maps/arenko.cpp @@ -0,0 +1,98 @@ +/* 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 . + * + */ + +#include "mm/mm1/views/maps/arenko.h" +#include "mm/mm1/maps/map28.h" +#include "mm/mm1/globals.h" + +#define VAL1 63 +#define VAL2 64 + +namespace MM { +namespace MM1 { +namespace Views { +namespace Maps { + +Arenko::Arenko() : TextView("Arenko") { + _bounds = getLineBounds(20, 24); +} + +bool Arenko::msgFocus(const FocusMessage &msg) { + MM1::Maps::Map28 &map = *static_cast(g_maps->_currentMap); + + if (!map[VAL1]) { + _line = STRING["maps.map28.arenko"]; + map[VAL2] = 1; + + } else if (map[VAL1] < 19) { + _line = STRING["maps.map28.keep_climbing"]; + + } else { + _line = STRING["maps.map28.well_done"]; + } + + return true; +} + +void Arenko::draw() { + clearSurface(); + writeString(0, 1, _line); +} + +bool Arenko::msgKeypress(const KeypressMessage &msg) { + MM1::Maps::Map28 &map = *static_cast(g_maps->_currentMap); + + if (map[VAL1] == 19) { + switch (msg.keycode) { + case Common::KEYCODE_a: + close(); + giveGold(); + return true; + case Common::KEYCODE_b: + close(); + giveGems(); + return true; + case Common::KEYCODE_c: + close(); + giveItem(); + return true; + default: + break; + } + } else { + close(); + } + + return true; +} + +bool Arenko::msgAction(const ActionMessage &msg) { + MM1::Maps::Map28 &map = *static_cast(g_maps->_currentMap); + if (map[VAL1] != 19) + close(); + + return true; +} + +} // namespace Maps +} // namespace Views +} // namespace MM1 +} // namespace MM diff --git a/engines/mm/mm1/views/maps/arenko.h b/engines/mm/mm1/views/maps/arenko.h new file mode 100644 index 00000000000..d37ac9b0149 --- /dev/null +++ b/engines/mm/mm1/views/maps/arenko.h @@ -0,0 +1,51 @@ +/* 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 . + * + */ + +#ifndef MM1_VIEWS_MAPS_ARENKO_H +#define MM1_VIEWS_MAPS_ARENKO_H + +#include "mm/mm1/views/text_view.h" +#include "mm/mm1/game/arenko.h" + +namespace MM { +namespace MM1 { +namespace Views { +namespace Maps { + +class Arenko : public TextView, public MM1::Game::Arenko { +private: + Common::String _line; +public: + Arenko(); + virtual ~Arenko() {} + + bool msgFocus(const FocusMessage &msg) override; + void draw() override; + bool msgKeypress(const KeypressMessage &msg) override; + bool msgAction(const ActionMessage &msg) override; +}; + +} // namespace Maps +} // 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 e873f8b43bb..27df486f91a 100644 --- a/engines/mm/mm1/views_enh/dialogs.h +++ b/engines/mm/mm1/views_enh/dialogs.h @@ -54,6 +54,7 @@ #include "mm/mm1/views_enh/who_will_try.h" #include "mm/mm1/views_enh/won_game.h" #include "mm/mm1/views_enh/interactions/access_code.h" +#include "mm/mm1/views_enh/interactions/arenko.h" #include "mm/mm1/views_enh/interactions/arrested.h" #include "mm/mm1/views_enh/interactions/gypsy.h" #include "mm/mm1/views_enh/interactions/ice_princess.h" @@ -79,6 +80,7 @@ namespace ViewsEnh { struct Dialogs { private: ViewsEnh::Interactions::AccessCode _accessCode; + ViewsEnh::Interactions::Arenko _arenko; ViewsEnh::Interactions::Arrested _arrested; ViewsEnh::Interactions::Gypsy _gypsy; ViewsEnh::Interactions::IcePrincess _icePrincess; diff --git a/engines/mm/mm1/views_enh/interactions/arenko.cpp b/engines/mm/mm1/views_enh/interactions/arenko.cpp new file mode 100644 index 00000000000..d6108e6a319 --- /dev/null +++ b/engines/mm/mm1/views_enh/interactions/arenko.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 . + * + */ + +#include "mm/mm1/views_enh/interactions/arenko.h" +#include "mm/mm1/maps/map28.h" +#include "mm/mm1/globals.h" + +#define VAL1 63 +#define VAL2 64 + +namespace MM { +namespace MM1 { +namespace ViewsEnh { +namespace Interactions { + +Arenko::Arenko() : Interaction("Arenko", 9) { + _title = STRING["maps.emap28.arenko_title"]; +} + +bool Arenko::msgFocus(const FocusMessage &msg) { + Maps::Map28 &map = *static_cast(g_maps->_currentMap); + clearButtons(); + + if (!map[VAL1]) { + addText(STRING["maps.map28.arenko"]); + map[VAL2] = 1; + + } else if (map[VAL1] < 19) { + addText(STRING["maps.map28.keep_climbing"]); + + } else { + addText(STRING["maps.map28.well_done"]); + addButton(STRING["maps.emap28.gold"], 'A'); + addButton(STRING["maps.emap28.gems"], 'B'); + addButton(STRING["maps.emap28.item"], 'C'); + } + + return true; +} + +void Arenko::viewAction() { + if (_buttons.empty()) { + close(); + } +} + +bool Arenko::msgKeypress(const KeypressMessage &msg) { + if (!_buttons.empty()) { + switch (msg.keycode) { + case Common::KEYCODE_a: + close(); + giveGold(); + return true; + case Common::KEYCODE_b: + close(); + giveGems(); + return true; + case Common::KEYCODE_c: + close(); + giveItem(); + return true; + default: + break; + } + } + + return Interaction::msgKeypress(msg); +} + +bool Arenko::msgAction(const ActionMessage &msg) { + if (_buttons.empty()) + return Interaction::msgAction(msg); + return true; +} + +} // namespace Interactions +} // namespace ViewsEnh +} // namespace MM1 +} // namespace MM diff --git a/engines/mm/mm1/views_enh/interactions/arenko.h b/engines/mm/mm1/views_enh/interactions/arenko.h new file mode 100644 index 00000000000..bd61d170c73 --- /dev/null +++ b/engines/mm/mm1/views_enh/interactions/arenko.h @@ -0,0 +1,50 @@ +/* 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 . + * + */ + +#ifndef MM1_VIEWS_ENH_INTERACTIONS_ARENKO_H +#define MM1_VIEWS_ENH_INTERACTIONS_ARENKO_H + +#include "mm/mm1/views_enh/interactions/interaction.h" +#include "mm/mm1/game/arenko.h" + +namespace MM { +namespace MM1 { +namespace ViewsEnh { +namespace Interactions { + +class Arenko : public Interaction, public MM1::Game::Arenko { +protected: + void viewAction() override; + +public: + Arenko(); + + bool msgFocus(const FocusMessage &msg) override; + bool msgKeypress(const KeypressMessage &msg) override; + bool msgAction(const ActionMessage &msg) override; +}; + +} // namespace Interactions +} // namespace ViewsEnh +} // namespace MM1 +} // namespace MM + +#endif diff --git a/engines/mm/module.mk b/engines/mm/module.mk index d7810096baa..cd6c3c00d34 100644 --- a/engines/mm/module.mk +++ b/engines/mm/module.mk @@ -36,6 +36,7 @@ MODULE_OBJS += \ mm1/data/text_parser.o \ mm1/data/trap.o \ mm1/data/treasure.o \ + mm1/game/arenko.o \ mm1/game/arrested.o \ mm1/game/game_logic.o \ mm1/game/combat.o \ @@ -71,6 +72,7 @@ MODULE_OBJS += \ mm1/views/maps/alamar.o \ mm1/views/maps/alien.o \ mm1/views/maps/answer_entry.o \ + mm1/views/maps/arenko.o \ mm1/views/maps/arrested.o \ mm1/views/maps/chess.o \ mm1/views/maps/dog_statue.o \ @@ -177,6 +179,7 @@ MODULE_OBJS += \ mm1/views_enh/won_game.o \ mm1/views_enh/yes_no.o \ mm1/views_enh/interactions/access_code.o \ + mm1/views_enh/interactions/arenko.o \ mm1/views_enh/interactions/arrested.o \ mm1/views_enh/interactions/gypsy.o \ mm1/views_enh/interactions/ice_princess.o \