[Scummvm-git-logs] scummvm master -> 1892b7a13592673d89eb3908fddfc8a20d03244e
dreammaster
noreply at scummvm.org
Fri Mar 3 06:26:59 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
1fc0852e76 MM: MM1: Add exit button to Inn
1892b7a135 MM: MM1: Added View All Characters view
Commit: 1fc0852e76093fd1600cf3bd4fe96d86c41b2db1
https://github.com/scummvm/scummvm/commit/1fc0852e76093fd1600cf3bd4fe96d86c41b2db1
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-02T22:26:48-08:00
Commit Message:
MM: MM1: Add exit button to Inn
Changed paths:
devtools/create_mm/files/mm1/strings_en.yml
engines/mm/mm1/views_enh/locations/inn.cpp
engines/mm/mm1/views_enh/locations/inn.h
engines/mm/mm1/views_enh/scroll_view.cpp
engines/mm/mm1/views_enh/scroll_view.h
diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 794c867a830..192a5226c8c 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -519,6 +519,7 @@ enhdialogs:
inn:
left_click: "Left click potraits to add/remove"
right_click: "Right click to view"
+ exit: "Exit Inn"
esc: "ESC to go back"
tavern:
title: "Tavern"
diff --git a/engines/mm/mm1/views_enh/locations/inn.cpp b/engines/mm/mm1/views_enh/locations/inn.cpp
index 20dca590e5b..99a1a466246 100644
--- a/engines/mm/mm1/views_enh/locations/inn.cpp
+++ b/engines/mm/mm1/views_enh/locations/inn.cpp
@@ -31,6 +31,9 @@ namespace Locations {
Inn::Inn() : ScrollView("Inn") {
_bounds.setBorderSize(10);
+ _escSprite.load("esc.icn");
+ addButton(&_escSprite, Common::Point(100, 162), 0, KEYBIND_SELECT);
+ setButtonEnabled(0, false);
}
bool Inn::msgFocus(const FocusMessage &msg) {
@@ -109,11 +112,11 @@ void Inn::draw() {
if (_partyChars.size() == 6)
writeString(0, 130, STRING["dialogs.inn.full"], ALIGN_MIDDLE);
- writeString(0, 145, STRING["enhdialogs.inn.left_click"], ALIGN_MIDDLE);
- writeString(0, 155, STRING["enhdialogs.inn.right_click"], ALIGN_MIDDLE);
+ writeString(0, 142, STRING["enhdialogs.inn.left_click"], ALIGN_MIDDLE);
+ writeString(0, 152, STRING["enhdialogs.inn.right_click"], ALIGN_MIDDLE);
if (!_partyChars.empty())
- writeString(0, 170, STRING["dialogs.inn.exit"], ALIGN_MIDDLE);
+ writeString(155, 168, STRING["enhdialogs.inn.exit"], ALIGN_MIDDLE);
}
}
@@ -131,12 +134,13 @@ bool Inn::msgMouseDown(const MouseDownMessage &msg) {
else
_partyChars.push_back(charNum);
+ setButtonEnabled(0, !_partyChars.empty());
redraw();
break;
}
}
- return true;
+ return ScrollView::msgMouseDown(msg);
}
bool Inn::msgKeypress(const KeypressMessage &msg) {
@@ -151,6 +155,7 @@ bool Inn::msgKeypress(const KeypressMessage &msg) {
else
_partyChars.push_back(charNum);
+ setButtonEnabled(0, !_partyChars.empty());
redraw();
} else if (msg.flags == 0) {
diff --git a/engines/mm/mm1/views_enh/locations/inn.h b/engines/mm/mm1/views_enh/locations/inn.h
index dd9214d7c2f..9414fbadad8 100644
--- a/engines/mm/mm1/views_enh/locations/inn.h
+++ b/engines/mm/mm1/views_enh/locations/inn.h
@@ -33,6 +33,7 @@ namespace Locations {
class Inn : public ScrollView {
private:
+ Shared::Xeen::SpriteResource _escSprite;
Common::Array<uint> _charNums;
IntArray _partyChars;
diff --git a/engines/mm/mm1/views_enh/scroll_view.cpp b/engines/mm/mm1/views_enh/scroll_view.cpp
index dc00d63a4dc..7503cbadfb7 100644
--- a/engines/mm/mm1/views_enh/scroll_view.cpp
+++ b/engines/mm/mm1/views_enh/scroll_view.cpp
@@ -41,23 +41,27 @@ ScrollView::ScrollView(const Common::String &name,
_bounds.setBorderSize(FRAME_BORDER_SIZE);
}
-void ScrollView::addButton(Shared::Xeen::SpriteResource *sprites,
+int ScrollView::addButton(Shared::Xeen::SpriteResource *sprites,
const Common::Point &pos, int frame,
const Common::KeyState &key) {
_buttons.push_back(Button(sprites, pos, frame, key));
+ return _buttons.size() - 1;
}
-void ScrollView::addButton(Shared::Xeen::SpriteResource *sprites,
+int ScrollView::addButton(Shared::Xeen::SpriteResource *sprites,
const Common::Point &pos, int frame, KeybindingAction action) {
_buttons.push_back(Button(sprites, pos, frame, action));
+ return _buttons.size() - 1;
}
-void ScrollView::addButton(const Common::Rect &r, const Common::KeyState &key) {
+int ScrollView::addButton(const Common::Rect &r, const Common::KeyState &key) {
_buttons.push_back(Button(r, key));
+ return _buttons.size() - 1;
}
-void ScrollView::addButton(const Common::Rect &r, KeybindingAction action) {
+int ScrollView::addButton(const Common::Rect &r, KeybindingAction action) {
_buttons.push_back(Button(r, action));
+ return _buttons.size() - 1;
}
void ScrollView::resetSelectedButton() {
@@ -73,7 +77,7 @@ void ScrollView::draw() {
Graphics::ManagedSurface s = getSurface();
for (uint i = 0; i < _buttons.size(); ++i) {
const Button &btn = _buttons[i];
- if (btn._frame != -1) {
+ if (btn._enabled && btn._frame != -1) {
btn._sprites->draw(&s,
btn._frame + (_selectedButton == (int)i ? 1 : 0),
Common::Point(btn._bounds.left + _bounds.borderSize(),
@@ -202,7 +206,7 @@ int ScrollView::getButtonAt(const Common::Point &pos) {
Common::Rect r = _buttons[i]._bounds;
r.translate(_innerBounds.left, _innerBounds.top);
- if (r.contains(pos))
+ if (_buttons[i]._enabled && r.contains(pos))
return i;
}
diff --git a/engines/mm/mm1/views_enh/scroll_view.h b/engines/mm/mm1/views_enh/scroll_view.h
index f70f0e6f7e7..089f7726566 100644
--- a/engines/mm/mm1/views_enh/scroll_view.h
+++ b/engines/mm/mm1/views_enh/scroll_view.h
@@ -39,6 +39,7 @@ class ScrollView : public TextView {
int _frame = -1;
Common::KeyState _key;
KeybindingAction _action = KEYBIND_NONE;
+ bool _enabled = true;
Button(Shared::Xeen::SpriteResource *sprites,
const Common::Point &pos, int frame,
@@ -99,25 +100,32 @@ public:
/**
* Add a button for display
*/
- void addButton(Shared::Xeen::SpriteResource *sprites,
+ int addButton(Shared::Xeen::SpriteResource *sprites,
const Common::Point &pos, int frame,
const Common::KeyState &key);
/**
* Add a button for display
*/
- void addButton(Shared::Xeen::SpriteResource *sprites,
+ int addButton(Shared::Xeen::SpriteResource *sprites,
const Common::Point &pos, int frame, KeybindingAction action);
/**
* Add a button for display
*/
- void addButton(const Common::Rect &r, const Common::KeyState &key);
+ int addButton(const Common::Rect &r, const Common::KeyState &key);
/**
* Add a button for display
*/
- void addButton(const Common::Rect &r, KeybindingAction action);
+ int addButton(const Common::Rect &r, KeybindingAction action);
+
+ /**
+ * Set a button's enablement
+ */
+ void setButtonEnabled(int buttonNum, bool enabled) {
+ _buttons[buttonNum]._enabled = enabled;
+ }
/**
* Reset selected button
Commit: 1892b7a13592673d89eb3908fddfc8a20d03244e
https://github.com/scummvm/scummvm/commit/1892b7a13592673d89eb3908fddfc8a20d03244e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-03-02T22:26:48-08:00
Commit Message:
MM: MM1: Added View All Characters view
Changed paths:
A engines/mm/mm1/views_enh/characters.cpp
A engines/mm/mm1/views_enh/characters.h
devtools/create_mm/files/mm1/strings_en.yml
engines/mm/mm1/views/characters.cpp
engines/mm/mm1/views_enh/dialogs.h
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 192a5226c8c..e156f4d8da4 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -482,6 +482,13 @@ enhdialogs:
good: "Good"
character_select:
title: "Select target"
+ characters:
+ left_click: "Left click portraits to view"
+ inn:
+ left_click: "Left click potraits to add/remove"
+ right_click: "Right click to view"
+ exit: "Exit Inn"
+ esc: "ESC to go back"
location:
store: "store"
options: "options"
@@ -516,11 +523,6 @@ enhdialogs:
select: "Select"
exit: "Exit"
non_caster: "Not a spell caster..."
- inn:
- left_click: "Left click potraits to add/remove"
- right_click: "Right click to view"
- exit: "Exit Inn"
- esc: "ESC to go back"
tavern:
title: "Tavern"
drink: "\x01""37Drink"
diff --git a/engines/mm/mm1/views/characters.cpp b/engines/mm/mm1/views/characters.cpp
index 93b0ce69694..89e0d4dfb48 100644
--- a/engines/mm/mm1/views/characters.cpp
+++ b/engines/mm/mm1/views/characters.cpp
@@ -42,7 +42,7 @@ void Characters::draw() {
}
// Loop to print characters
- for (int charNum = 0; charNum < 18; ++charNum) {
+ for (int charNum = 0; charNum < ROSTER_COUNT; ++charNum) {
if (roster._towns[charNum]) {
const Character &re = roster[charNum];
Common::String charName = re._name;
diff --git a/engines/mm/mm1/views_enh/characters.cpp b/engines/mm/mm1/views_enh/characters.cpp
new file mode 100644
index 00000000000..27796f49d38
--- /dev/null
+++ b/engines/mm/mm1/views_enh/characters.cpp
@@ -0,0 +1,118 @@
+/* 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/characters.h"
+#include "mm/mm1/globals.h"
+#include "mm/mm1/mm1.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+Characters::Characters() : ScrollView("Characters") {
+ _bounds.setBorderSize(10);
+ _escSprite.load("esc.icn");
+ addButton(&_escSprite, Common::Point(90, 162), 0, KEYBIND_ESCAPE);
+}
+
+void Characters::draw() {
+ ScrollView::draw();
+ Graphics::ManagedSurface s = getSurface();
+ Roster &roster = g_globals->_roster;
+
+ // Write title
+ setReduced(false);
+ writeString(0, 0, STRING["dialogs.view_characters.title"], ALIGN_MIDDLE);
+
+ if (g_globals->_roster.empty()) {
+ writeString(0, 40, STRING["dialogs.misc.no_characters"], ALIGN_MIDDLE);
+
+ } else {
+ // Write out the roster
+ setReduced(true);
+
+ for (uint idx = 0; idx < ROSTER_COUNT; ++idx) {
+ if (!roster._towns[idx])
+ continue;
+ Character &c = roster[idx];
+
+ // Build up character portrait and/or frame
+ Graphics::ManagedSurface portrait;
+ portrait.create(30, 30);
+ c._faceSprites.draw(&portrait, 0, Common::Point(0, 0));
+
+ Common::Point pt(_innerBounds.left + _innerBounds.width() / 3
+ * (idx % 3), 20 + 20 * (idx / 3));
+ s.blitFrom(portrait, Common::Rect(0, 0, 30, 30),
+ Common::Rect(pt.x + 2, pt.y + 2, pt.x + 17, pt.y + 17));
+
+ writeString(pt.x - _innerBounds.left + 22, pt.y - _innerBounds.top + 5, c._name);
+ }
+
+ setReduced(false);
+ writeString(0, 152, STRING["enhdialogs.characters.left_click"], ALIGN_MIDDLE);
+ }
+
+ writeString(120, 168, STRING["dialogs.misc.go_back"]);
+}
+
+bool Characters::msgMouseDown(const MouseDownMessage &msg) {
+ // Cycle through portraits
+ for (uint idx = 0; idx < _charNums.size(); ++idx) {
+ Common::Point pt(_innerBounds.left + _innerBounds.width() / 3
+ * (idx % 3), 20 + 20 * (idx / 3));
+
+ if (Common::Rect(pt.x, pt.y, pt.x + 19, pt.y + 19).contains(msg._pos)) {
+ showCharacter(idx);
+ break;
+ }
+ }
+
+ return ScrollView::msgMouseDown(msg);
+}
+
+bool Characters::msgKeypress(const KeypressMessage &msg) {
+ if (msg.keycode >= Common::KEYCODE_a &&
+ msg.keycode < (Common::KeyCode)(Common::KEYCODE_a + _charNums.size())) {
+ showCharacter(msg.keycode - Common::KEYCODE_a);
+ return true;
+ }
+
+ return false;
+}
+
+bool Characters::msgAction(const ActionMessage &msg) {
+ switch (msg._action) {
+ case KEYBIND_ESCAPE:
+ replaceView("MainMenu");
+ return true;
+ default:
+ return ScrollView::msgAction(msg);
+ }
+}
+
+void Characters::showCharacter(uint charIndex) {
+ warning("TODO: Show character %d", charIndex);
+}
+
+} // namespace ViewsEnh
+} // namespace MM1
+} // namespace MM
diff --git a/engines/mm/mm1/views_enh/characters.h b/engines/mm/mm1/views_enh/characters.h
new file mode 100644
index 00000000000..5c2f640bd9e
--- /dev/null
+++ b/engines/mm/mm1/views_enh/characters.h
@@ -0,0 +1,56 @@
+/* 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_Characters_H
+#define MM1_VIEWS_ENH_LOCATIONS_Characters_H
+
+#include "mm/mm1/views_enh/locations/location.h"
+#include "mm/mm1/data/character.h"
+#include "mm/mm1/data/int_array.h"
+
+namespace MM {
+namespace MM1 {
+namespace ViewsEnh {
+
+class Characters : public ScrollView {
+private:
+ Shared::Xeen::SpriteResource _escSprite;
+ Common::Array<uint> _charNums;
+
+ /**
+ * Show a character
+ */
+ void showCharacter(uint charIndex);
+
+public:
+ Characters();
+
+ void draw() override;
+ bool msgMouseDown(const MouseDownMessage &msg) 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/mm1/views_enh/dialogs.h b/engines/mm/mm1/views_enh/dialogs.h
index 599b478ed4e..950f90f7920 100644
--- a/engines/mm/mm1/views_enh/dialogs.h
+++ b/engines/mm/mm1/views_enh/dialogs.h
@@ -29,6 +29,7 @@
#include "mm/mm1/views/title.h"
#include "mm/mm1/views_enh/character_info.h"
#include "mm/mm1/views_enh/character_select.h"
+#include "mm/mm1/views_enh/characters.h"
#include "mm/mm1/views_enh/game.h"
#include "mm/mm1/views_enh/game_messages.h"
#include "mm/mm1/views_enh/main_menu.h"
@@ -49,10 +50,10 @@ namespace ViewsEnh {
struct Dialogs {
private:
- Views::Characters _characters;
Views::CreateCharacters _createCharacters;
Views::Protect _protect;
Views::Title _title;
+ ViewsEnh::Characters _characters;
ViewsEnh::Interactions::Statue _statue;
ViewsEnh::Locations::Inn _inn;
ViewsEnh::Locations::Market _market;
diff --git a/engines/mm/module.mk b/engines/mm/module.mk
index 0c4ef2650ec..d14aaa5d4b6 100644
--- a/engines/mm/module.mk
+++ b/engines/mm/module.mk
@@ -127,6 +127,7 @@ MODULE_OBJS += \
mm1/views_enh/button_container.o \
mm1/views_enh/character_info.o \
mm1/views_enh/character_select.o \
+ mm1/views_enh/characters.o \
mm1/views_enh/dialogs.o \
mm1/views_enh/game.o \
mm1/views_enh/game_commands.o \
More information about the Scummvm-git-logs
mailing list