Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

View File

@@ -0,0 +1,121 @@
/* 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 "common/scummsys.h"
#include "mm/mm1/views_enh/button_container.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
void UIButton::draw(bool pressed) {
_sprites->draw(g_events->getScreen(),
pressed ? _selectedFrame : _frameNum,
Common::Point(_bounds.left, _bounds.top));
}
ButtonContainer::ButtonContainer(const Common::String &name,
UIElement *owner) : Views::TextView(name, owner) {
}
void ButtonContainer::saveButtons() {
_savedButtons.push(_buttons);
clearButtons();
}
void ButtonContainer::clearButtons() {
_buttons.clear();
}
void ButtonContainer::restoreButtons() {
_buttons = _savedButtons.pop();
}
void ButtonContainer::addButton(const Common::Rect &bounds, KeybindingAction action,
Shared::Xeen::SpriteResource *sprites) {
_buttons.push_back(UIButton(this, bounds, action, _buttons.size() * 2, sprites, sprites != nullptr));
}
void ButtonContainer::addButton(const Common::Rect &bounds, KeybindingAction action,
int frameNum, Shared::Xeen::SpriteResource *sprites) {
_buttons.push_back(UIButton(this, bounds, action, frameNum, sprites, sprites != nullptr));
}
bool ButtonContainer::msgMouseDown(const MouseDownMessage &msg) {
_selectedAction = KEYBIND_NONE;
if (msg._button == MouseMessage::MB_LEFT) {
// Check whether any button is selected
for (uint i = 0; i < _buttons.size(); ++i) {
if (_buttons[i]._bounds.contains(msg._pos) &&
_buttons[i]._action != KEYBIND_NONE) {
_selectedAction = _buttons[i]._action;
g_events->redraw();
g_events->drawElements();
return true;
}
}
}
return false;
}
bool ButtonContainer::msgMouseUp(const MouseUpMessage &msg) {
KeybindingAction action = _selectedAction;
_selectedAction = KEYBIND_NONE;
if (msg._button == MouseMessage::MB_LEFT && action != KEYBIND_NONE) {
for (uint i = 0; i < _buttons.size(); ++i) {
if (_buttons[i]._action == action) {
if (_buttons[i]._action == action)
g_events->send(ActionMessage(action));
g_events->redraw();
g_events->drawElements();
return true;
}
}
}
return false;
}
void ButtonContainer::draw() {
TextView::draw();
for (uint btnIndex = 0; btnIndex < _buttons.size(); ++btnIndex) {
UIButton &btn = _buttons[btnIndex];
if (btn._draw && btn._sprites)
btn.draw(btn._action != KEYBIND_NONE &&
btn._action == _selectedAction);
}
}
bool ButtonContainer::doScroll(bool fadeIn) {
// TODO
return false;
}
} // namespace ViewsEnh
} // End of namespace MM1
} // End of namespace MM

View File

@@ -0,0 +1,120 @@
/* 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_BUTTON_CONTAINER_H
#define MM1_VIEWS_ENH_BUTTON_CONTAINER_H
#include "common/array.h"
#include "common/stack.h"
#include "common/rect.h"
#include "mm/shared/xeen/sprites.h"
#include "mm/mm1/views/text_view.h"
#include "mm/mm1/events.h"
#include "mm/mm1/metaengine.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class ButtonContainer;
class UIButton {
public:
Common::Rect _bounds;
Shared::Xeen::SpriteResource *_sprites;
KeybindingAction _action;
uint _frameNum, _selectedFrame;
bool _draw;
/**
* Constructor
*/
UIButton(ButtonContainer *owner, const Common::Rect &bounds,
KeybindingAction action, uint frameNum, Shared::Xeen::SpriteResource *sprites,
bool draw) :
_bounds(bounds), _action(action), _frameNum(frameNum),
_selectedFrame(frameNum | 1), _sprites(sprites), _draw(draw) {
}
/**
* Constructor
*/
UIButton() : _action(KEYBIND_NONE), _frameNum(0), _selectedFrame(0),
_sprites(nullptr), _draw(false) {
}
/**
* Set the frame
*/
void setFrame(uint frameNum) {
_frameNum = frameNum;
_selectedFrame = frameNum | 1;
}
/**
* Set the frame
*/
void setFrame(uint frameNum, uint selectedFrame) {
_frameNum = frameNum;
_selectedFrame = selectedFrame;
}
/**
* Draw the button
*/
void draw(bool pressed = false);
};
class ButtonContainer : public Views::TextView {
private:
Common::Stack< Common::Array<UIButton> > _savedButtons;
KeybindingAction _selectedAction = KEYBIND_NONE;
protected:
Common::Array<UIButton> _buttons;
bool doScroll(bool fadeIn);
public:
ButtonContainer(const Common::String &name, UIElement *owner);
/**
* Saves the current list of buttons
*/
void saveButtons();
void clearButtons();
void restoreButtons();
void addButton(const Common::Rect &bounds, KeybindingAction action,
Shared::Xeen::SpriteResource *sprites = nullptr);
void addButton(const Common::Rect &bounds, KeybindingAction action,
int frameNum, Shared::Xeen::SpriteResource *sprites = nullptr);
void draw() override;
bool msgMouseDown(const MouseDownMessage &msg) override;
bool msgMouseUp(const MouseUpMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,170 @@
/* 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/character_base.h"
#include "mm/mm1/utils/strings.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define LINE1_Y 5
#define COL1_X 30
#define COL3_X 220
#define BACKPACK_Y 103
CharacterBase::CharacterBase(const Common::String &name) : ScrollView(name) {
_escSprite.load("esc.icn");
}
void CharacterBase::printStats() {
const Character &c = *g_globals->_currCharacter;
printSummary();
writeLine(4, STRING["stats.attributes.int"], ALIGN_RIGHT, COL1_X);
writeLine(4, Common::String::format("%u", c._intelligence._base), ALIGN_LEFT, COL1_X);
writeLine(5, STRING["stats.attributes.mgt"], ALIGN_RIGHT, COL1_X);
writeLine(5, Common::String::format("%u", c._might._base), ALIGN_LEFT, COL1_X);
writeLine(6, STRING["stats.attributes.per"], ALIGN_RIGHT, COL1_X);
writeLine(6, Common::String::format("%u", c._personality._base), ALIGN_LEFT, COL1_X);
writeLine(7, STRING["stats.attributes.end"], ALIGN_RIGHT, COL1_X);
writeLine(7, Common::String::format("%u", c._endurance._base), ALIGN_LEFT, COL1_X);
writeLine(8, STRING["stats.attributes.spd"], ALIGN_RIGHT, COL1_X);
writeLine(8, Common::String::format("%u", c._speed._base), ALIGN_LEFT, COL1_X);
writeLine(9, STRING["stats.attributes.acy"], ALIGN_RIGHT, COL1_X);
writeLine(9, Common::String::format("%u", c._accuracy._base), ALIGN_LEFT, COL1_X);
writeLine(10, STRING["stats.attributes.luc"], ALIGN_RIGHT, COL1_X);
writeLine(10, Common::String::format("%u", c._luck._base), ALIGN_LEFT, COL1_X);
writeLine(4, STRING["stats.attributes.level"], ALIGN_RIGHT, 90);
writeNumber(c._level);
writeLine(4, STRING["stats.attributes.age"], ALIGN_LEFT, 120);
writeNumber(c._age);
writeLine(6, STRING["stats.attributes.sp"], ALIGN_RIGHT, 90);
writeLine(6, Common::String::format("%u", c._sp._current), ALIGN_LEFT, 90);
writeLine(6, Common::String::format("/%u", c._sp._base), ALIGN_LEFT, 120);
writeLine(6, Common::String::format("(%u)", c._spellLevel._current), ALIGN_LEFT, 160);
writeLine(8, STRING["stats.attributes.hp"], ALIGN_RIGHT, 90);
writeLine(8, Common::String::format("%u", c._hpCurrent), ALIGN_LEFT, 90);
writeLine(8, Common::String::format("/%u", c._hpMax), ALIGN_LEFT, 120);
writeLine(10, STRING["stats.attributes.ac"], ALIGN_RIGHT, 90);
writeLine(10, Common::String::format("%u", c._ac._current), ALIGN_LEFT, 90);
writeLine(4, STRING["stats.attributes.exp"], ALIGN_RIGHT, COL3_X);
writeLine(4, Common::String::format("%u", c._exp), ALIGN_LEFT, COL3_X);
writeLine(6, STRING["stats.attributes.gems"], ALIGN_RIGHT, COL3_X);
writeLine(6, Common::String::format("%u", c._gems), ALIGN_LEFT, COL3_X);
writeLine(8, STRING["stats.attributes.gold"], ALIGN_RIGHT, COL3_X);
writeLine(8, Common::String::format("%u", c._gold), ALIGN_LEFT, COL3_X);
writeLine(10, STRING["stats.attributes.food"], ALIGN_RIGHT, COL3_X);
writeLine(10, Common::String::format("%u", c._food), ALIGN_LEFT, COL3_X);
printCondition();
printInventory();
}
void CharacterBase::printSummary() {
const Character &c = *g_globals->_currCharacter;
writeString(35, LINE1_Y, c._name);
writeString(120, LINE1_Y, ": ");
writeString((c._sex == MALE) ? "M " : (c._sex == FEMALE ? "F " : "O "));
writeString((c._alignment >= GOOD && c._alignment <= EVIL) ?
STRING[Common::String::format("stats.alignments.%d", c._alignment)] :
STRING["stats.none"]
);
writeChar(' ');
if (c._race >= HUMAN && c._race <= HALF_ORC)
writeString(STRING[Common::String::format("stats.races.%d", c._race)]);
else
writeString(STRING["stats.none"]);
writeChar(' ');
if (c._class >= KNIGHT && c._class <= ROBBER)
writeString(STRING[Common::String::format("stats.classes.%d", c._class)]);
else
writeString(STRING["stats.none"]);
}
void CharacterBase::printCondition() {
const Character &c = *g_globals->_currCharacter;
writeLine(2, STRING["stats.attributes.cond"], ALIGN_RIGHT, 90);
writeLine(2, c.getConditionString(), ALIGN_LEFT, 90);
}
void CharacterBase::printInventory() {
const Character &c = *g_globals->_currCharacter;
writeString(0, BACKPACK_Y, STRING["stats.inventory"]);
for (int i = 0; i < 5; ++i)
writeChar('-');
// Print the equipped and backpack items
for (uint i = 0; i < INVENTORY_COUNT; ++i) {
// Equippied item
writeString(0, BACKPACK_Y + 9 * (i + 1), Common::String::format("%c) ", '1' + i));
if (i < c._equipped.size()) {
g_globals->_items.getItem(c._equipped[i]._id);
const Item &item = g_globals->_currItem;
writeString(item._name);
}
// Backpack item
writeString(160 - _innerBounds.left, BACKPACK_Y + 9 * (i + 1),
Common::String::format("%c) ", 'A' + i));
if (i < c._backpack.size()) {
g_globals->_items.getItem(c._backpack[i]._id);
const Item &item = g_globals->_currItem;
writeString(item._name);
}
}
}
void CharacterBase::draw() {
assert(g_globals->_currCharacter);
const Character &c = *g_globals->_currCharacter;
ScrollView::draw();
Graphics::ManagedSurface s = getSurface();
c._faceSprites.draw(&s, 0, Common::Point(_innerBounds.left, _innerBounds.top));
printStats();
}
bool CharacterBase::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
return true;
}
return false;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,64 @@
/* 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_CHARACTER_BASE_H
#define MM1_VIEWS_ENH_CHARACTER_BASE_H
#include "common/array.h"
#include "mm/mm1/views_enh/scroll_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
/**
* Base class for showing character information.
* MM1 has three character dialogs:
* 1) Character management from Create Characters
* 2) Inn that allows simply viewing characters
* 3) In-game character display
*/
class CharacterBase : public ScrollView {
private:
void printStats();
void printSummary();
void printInventory();
protected:
Shared::Xeen::SpriteResource _escSprite;
void printCondition();
public:
CharacterBase(const Common::String &name);
~CharacterBase() {}
bool msgAction(const ActionMessage &msg) override;
void draw() override;
void escToGoBack(int xp = 0) {}
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,450 @@
/* 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/character_info.h"
#include "mm/mm1/views_enh/scroll_popup.h"
#include "mm/shared/utils/strings.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define CURSOR_BLINK_FRAMES 6
#define ICONS_COUNT 18
#define REDUCED_TO_EXPANDED(IDX) ((IDX >= 13) ? IDX + 2 : IDX)
#define EXPANDED_TO_REDUCED(IDX) ((IDX >= 13) ? IDX - 2 : IDX)
const CharacterInfo::IconPos CharacterInfo::ICONS[CHAR_ICONS_COUNT] = {
{ 0, 2, 16 },
{ 2, 2, 39 },
{ 4, 2, 62 },
{ 6, 2, 85 },
{ 8, 2, 108 },
{ 10, 53, 16 },
{ 12, 53, 39 },
{ 14, 53, 62 },
{ 16, 53, 85 },
{ 18, 53, 108 },
{ 20, 104, 16 },
{ 22, 104, 39 },
{ 24, 104, 62 },
{ 30, 169, 16 },
{ 32, 169, 39 },
{ 34, 169, 62 },
{ 36, 169, 85 },
{ 38, 169, 108 },
{ 40, 277, 3 },
{ 42, 277, 35 },
{ 44, 277, 67 },
{ 46, 277, 99 }
};
bool CharacterInfo::AttributeView::msgFocus(const FocusMessage &msg) {
ScrollPopup::msgFocus(msg);
g_events->send("GameParty", GameMessage("CHAR_HIGHLIGHT", (int)true));
return true;
}
CharacterInfo::CharacterInfo() : PartyView("CharacterInfo") {
_bounds = Common::Rect(0, 0, 320, 146);
_statInfo.setReduced(true);
static const char *FIELDS[CHAR_ICONS_COUNT] = {
"might", "intelligence", "personality",
"endurance", "speed",
"accuracy", "luck", "age", "level", "ac",
"hp", "sp", "spells",
"experience", "gold", "gems", "food", "condition"
};
for (int i = 0; i < ICONS_COUNT; ++i) {
ICONS_TEXT[i] = STRING[Common::String::format(
"enhdialogs.character.stats.%s", FIELDS[i])];
}
}
bool CharacterInfo::msgFocus(const FocusMessage &msg) {
_viewIcon.load("view.icn");
// Don't reset selection after having viewed an attribute
if (dynamic_cast<ScrollPopup *>(msg._priorView) == nullptr)
_cursorCell = 0;
showCursor(true);
delayFrames(CURSOR_BLINK_FRAMES);
return PartyView::msgFocus(msg);
}
bool CharacterInfo::msgUnfocus(const UnfocusMessage &msg) {
_viewIcon.clear();
return PartyView::msgUnfocus(msg);
}
bool CharacterInfo::msgGame(const GameMessage &msg) {
if (msg._name == "USE") {
g_events->send("CharacterInventory", GameMessage("USE"));
return true;
}
return false;
}
bool CharacterInfo::msgKeypress(const KeypressMessage &msg) {
int idx;
switch (msg.keycode) {
case Common::KEYCODE_UP:
showCursor(false);
if (--_cursorCell < 0)
_cursorCell = ICONS_COUNT - 1;
showCursor(true);
break;
case Common::KEYCODE_DOWN:
showCursor(false);
if (++_cursorCell >= ICONS_COUNT)
_cursorCell = 0;
showCursor(true);
break;
case Common::KEYCODE_LEFT:
showCursor(false);
idx = REDUCED_TO_EXPANDED(_cursorCell) - 5;
if (idx == 13 || idx == 14)
idx -= 5;
if (idx < 0)
idx += 20;
_cursorCell = EXPANDED_TO_REDUCED(idx);
showCursor(true);
break;
case Common::KEYCODE_RIGHT:
showCursor(false);
idx = REDUCED_TO_EXPANDED(_cursorCell) + 5;
if (idx == 13 || idx == 14)
idx += 5;
if (idx >= 20)
idx -= 20;
_cursorCell = EXPANDED_TO_REDUCED(idx);
showCursor(true);
break;
case Common::KEYCODE_i:
addView("CharacterInventory");
break;
case Common::KEYCODE_e:
addView("Exchange");
break;
case Common::KEYCODE_q:
replaceView("QuickRef");
break;
default:
break;
}
return true;
}
bool CharacterInfo::msgAction(const ActionMessage &msg) {
switch (msg._action) {
case KEYBIND_ESCAPE:
close();
return true;
case KEYBIND_SELECT:
showAttribute(_cursorCell);
return true;
default:
return PartyView::msgAction(msg);
}
}
bool CharacterInfo::msgMouseUp(const MouseUpMessage &msg) {
// Check if a stat icon was clicked
Common::Rect r(25, 22);
for (int i = 0; i < CHAR_ICONS_COUNT; ++i) {
r.moveTo(_innerBounds.left + ICONS[i]._x,
_innerBounds.top + ICONS[i]._y);
if (r.contains(msg._pos)) {
switch (i) {
case 18:
msgKeypress(Common::KeyState(Common::KEYCODE_i));
break;
case 19:
msgKeypress(Common::KeyState(Common::KEYCODE_q));
break;
case 20:
msgKeypress(Common::KeyState(Common::KEYCODE_e));
break;
case 21:
msgAction(ActionMessage(KEYBIND_ESCAPE));
break;
default:
showAttribute(i);
break;
}
return true;
}
}
return PartyView::msgMouseUp(msg);
}
void CharacterInfo::draw() {
ScrollView::draw();
drawTitle();
drawIcons();
drawStats();
}
void CharacterInfo::drawTitle() {
const Character &c = *g_globals->_currCharacter;
Common::String msg = Common::String::format(
"%s : %s %s %s %s",
camelCase(c._name).c_str(),
STRING[Common::String::format("stats.sex.%d", (int)c._sex)].c_str(),
STRING[Common::String::format("stats.alignments.%d", (int)c._alignment)].c_str(),
STRING[Common::String::format("stats.races.%d", (int)c._race)].c_str(),
STRING[Common::String::format("stats.classes.%d", (int)c._class)].c_str()
);
writeString(0, 0, msg);
}
void CharacterInfo::drawIcons() {
Graphics::ManagedSurface s = getSurface();
for (int i = 0; i < CHAR_ICONS_COUNT; ++i) {
_viewIcon.draw(&s, ICONS[i]._frame,
Common::Point(ICONS[i]._x + _bounds.borderSize(),
ICONS[i]._y + _bounds.borderSize()));
}
// Text for buttons
writeString(277, 25, STRING["enhdialogs.character.item"]);
writeString(273, 57, STRING["enhdialogs.character.quick"]);
writeString(276, 90, STRING["enhdialogs.character.exchange"]);
writeString(278, 122, STRING["enhdialogs.misc.exit"]);
}
void CharacterInfo::drawStats() {
// Draw stat titles
for (int i = 0; i < 18; ++i) {
writeString(ICONS[i]._x + 27, ICONS[i]._y + 2, ICONS_TEXT[i]);
}
// Draw stat values
const Character &c = *g_globals->_currCharacter;
const uint CURR[16] = {
c._might._current, c._intelligence._current,
c._personality._current, c._endurance._current,
c._speed._current, c._accuracy._current,
c._luck._current, c._age, c._level._current,
c._ac._current, c._hpCurrent, c._sp._current, 0,
c._exp, c._gold, c._gems
};
const uint BASE[16] = {
c._might._base, c._intelligence._base,
c._personality._base, c._endurance._base,
c._speed._base, c._accuracy._base,
c._luck._base, c._age, c._level._base,
c._ac._current, c._hp, c._sp._base, 0,
c._exp, c._gold, c._gems
};
for (int i = 0; i < 17; ++i) {
if (i == 12)
continue;
Common::Point pt(ICONS[i]._x + 27, ICONS[i]._y + 12);
if (i < 10)
pt.x += 8 + (CURR[i] < 10 ? 8 : 0);
if (i == 16) {
// Food
Common::String str = Common::String::format("%d %s",
c._food,
STRING[c._food == 1 ? "enhdialogs.character.stats.day" :
"enhdialogs.character.stats.days"].c_str());
setTextColor(15);
writeString(pt.x, pt.y, str);
} else {
setTextColor(c.statColor(CURR[i], BASE[i]));
writeNumber(pt.x, pt.y, CURR[i]);
}
}
// Condition string
Common::String condStr = camelCase(c.getConditionString());
setTextColor(!c._condition ? 15 : 19);
uint i = condStr.findFirstOf(',');
if (i != Common::String::npos) {
// More than one condition
condStr = Common::String(condStr.c_str(), i);
setTextColor(32);
}
writeString(196, 120, condStr);
}
void CharacterInfo::showCursor(bool flag) {
const int CURSOR_X[4] = { 9, 60, 111, 176 };
const int CURSOR_Y[5] = { 23, 46, 69, 92, 115 };
if (flag == _cursorVisible)
return;
int idx = REDUCED_TO_EXPANDED(_cursorCell);
_cursorVisible = flag;
Graphics::ManagedSurface s = getSurface();
_viewIcon.draw(&s, flag ? 49 : 48,
Common::Point(CURSOR_X[idx / 5], CURSOR_Y[idx % 5]));
s.markAllDirty();
}
void CharacterInfo::timeout() {
showCursor(!_cursorVisible);
delayFrames(CURSOR_BLINK_FRAMES);
}
void CharacterInfo::charSwitched(Character *priorChar) {
PartyView::charSwitched(priorChar);
_cursorCell = 0;
redraw();
}
void CharacterInfo::showAttribute(int attrNum) {
// Switch the cursor to the selected attribute
showCursor(false);
_cursorCell = attrNum;
showCursor(true);
getSurface().markAllDirty();
g_events->getScreen()->update();
// Display the info dialog
const int STAT_POS[2][20] = {
{
61, 61, 61, 61, 61, 112, 112, 112, 112, 112,
177, 177, 177, 177, 177, 34, 34, 34, 34, 34
}, {
24, 47, 70, 93, 93, 24, 47, 70, 93, 93,
24, 47, 70, 93, 93, 24, 47, 70, 93, 93
}
};
int attrib = REDUCED_TO_EXPANDED(attrNum);
assert(attrib < 20);
if (attrib == 12) {
// Show active party spells
g_events->addView("Protect");
return;
}
Common::Rect bounds(STAT_POS[0][attrib], STAT_POS[1][attrib],
STAT_POS[0][attrib] + 143, STAT_POS[1][attrib] + 44);
_statInfo.setBounds(bounds);
_statInfo.clear();
const Character &c = *g_globals->_currCharacter;
const uint CURR[12] = {
c._might._current, c._intelligence._current,
c._personality._current, c._endurance._current,
c._speed._current, c._accuracy._current,
c._luck._current, c._age, c._level._current,
c._ac._current, c._hpCurrent, c._sp._current
};
const uint BASE[12] = {
c._might._base, c._intelligence._base,
c._personality._base, c._endurance._base,
c._speed._base, c._accuracy._base,
c._luck._base, c._age, c._level._base,
c._ac._current, c._hp, c._sp._base
};
const char *TITLES[12] = {
"might", "intelligence", "personality",
"endurance", "speed", "accuracy", "luck",
"age", "level", "ac", "hp", "sp"
};
if (attrib < 12) {
_statInfo.addLine(
STRING[Common::String::format("enhdialogs.character.long.%s",
TITLES[attrib]).c_str()],
ALIGN_MIDDLE);
int xc = (bounds.width() - FRAME_BORDER_SIZE * 2) / 2;
_statInfo.addText(STRING["enhdialogs.character.long.current"],
1, 0, ALIGN_RIGHT, xc - 8);
_statInfo.addText("/", 1, 0, ALIGN_MIDDLE);
_statInfo.addText(STRING["enhdialogs.character.long.base"],
1, 0, ALIGN_LEFT, xc + 8);
_statInfo.addText(Common::String::format("%u", CURR[attrib]),
2, 0, ALIGN_RIGHT, xc - 8);
_statInfo.addText("/", 2, 0, ALIGN_MIDDLE);
_statInfo.addText(Common::String::format("%u", BASE[attrib]),
2, 0, ALIGN_LEFT, xc + 8);
} else if (attrib == 15) {
// Experience
_statInfo.addLine(STRING["enhdialogs.character.stats.experience"], ALIGN_MIDDLE);
_statInfo.addLine(Common::String::format("%u", c._exp), ALIGN_MIDDLE);
} else if (attrib >= 16 && attrib <= 18) {
bounds.bottom -= 8;
_statInfo.setBounds(bounds);
uint value = c._gold;
Common::String title = STRING["enhdialogs.character.stats.gold"];
if (attrib == 17) {
value = c._gems;
title = STRING["enhdialogs.character.stats.gems"];
} else if (attrib == 18) {
value = c._food;
title = STRING["enhdialogs.character.stats.food"];
}
_statInfo.addLine(title, ALIGN_MIDDLE);
_statInfo.addLine(Common::String::format("%u %s",
value, STRING["enhdialogs.character.long.on_hand"].c_str()),
ALIGN_MIDDLE);
} else {
// Condition
Common::String conditionStr = c.getConditionString();
_statInfo.addLine(STRING["enhdialogs.character.stats.condition"], ALIGN_MIDDLE);
_statInfo.addLine(conditionStr, ALIGN_MIDDLE);
}
_statInfo.addView();
}
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,112 @@
/* 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_CHARACTER_INFO_H
#define MM1_VIEWS_ENH_CHARACTER_INFO_H
#include "mm/mm1/views_enh/party_view.h"
#include "mm/mm1/views_enh/scroll_popup.h"
#include "mm/shared/xeen/sprites.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define CHAR_ICONS_COUNT 22
class CharacterInfo : public PartyView {
struct IconPos {
int _frame; int _x; int _y;
};
class AttributeView : public ScrollPopup {
public:
AttributeView() : ScrollPopup("ScrollText") {}
virtual ~AttributeView() {}
bool msgFocus(const FocusMessage &msg) override;
};
private:
Shared::Xeen::SpriteResource _viewIcon;
static const IconPos ICONS[CHAR_ICONS_COUNT];
Common::String ICONS_TEXT[CHAR_ICONS_COUNT];
int _cursorCell = 0;
bool _cursorVisible = false;
AttributeView _statInfo;
private:
/**
* Draw the title text
*/
void drawTitle();
/**
* Draw the icons
*/
void drawIcons();
/**
* Draw the stats
*/
void drawStats();
/**
* Toggle display of cursor
*/
void showCursor(bool flag);
/**
* Show the details of a given attribute
*/
void showAttribute(int attrib);
protected:
void timeout() override;
/**
* Called when the selected character has been switched
*/
void charSwitched(Character *priorChar) override;
public:
CharacterInfo();
virtual ~CharacterInfo() {}
bool msgFocus(const FocusMessage &msg) override;
bool msgUnfocus(const UnfocusMessage &msg) override;
bool msgGame(const GameMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
bool msgMouseUp(const MouseUpMessage &msg) override;
void draw() override;
};
class CharacterInfoCombat : public CharacterInfo {
public:
CharacterInfoCombat() : CharacterInfo() {
_name = "CharacterViewCombat";
}
virtual ~CharacterInfoCombat() {
}
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,366 @@
/* 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/character_inventory.h"
#include "mm/mm1/views_enh/combat.h"
#include "mm/mm1/views_enh/game_messages.h"
#include "mm/mm1/views_enh/trade.h"
#include "mm/mm1/views_enh/which_item.h"
#include "mm/mm1/data/locations.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
CharacterInventory::CharacterInventory() : ItemsView("CharacterInventory") {
setup();
}
CharacterInventory::CharacterInventory(const Common::String &name) : ItemsView(name) {
setup();
}
void CharacterInventory::setup() {
_btnSprites.load("items.icn");
addButton(2, STRING["enhdialogs.items.buttons.arms"], Common::KEYCODE_a);
addButton(6, STRING["enhdialogs.items.buttons.backpack"], Common::KEYCODE_b);
addButton(8, STRING["enhdialogs.items.buttons.equip"], Common::KEYCODE_e);
addButton(10, STRING["enhdialogs.items.buttons.remove"], Common::KEYCODE_r);
addButton(12, STRING["enhdialogs.items.buttons.discard"], Common::KEYCODE_d);
addButton(6, STRING["enhdialogs.items.buttons.trade"], Common::KEYCODE_t);
addButton(14, STRING["enhdialogs.items.buttons.use"], Common::KEYCODE_u);
addButton(16, STRING["enhdialogs.misc.exit"], Common::KEYCODE_ESCAPE);
}
bool CharacterInventory::msgFocus(const FocusMessage &msg) {
ItemsView::msgFocus(msg);
assert(g_globals->_currCharacter);
bool inCombat = g_events->isInCombat();
for (int i = 2; i < ((int)getButtonCount() - 1); ++i)
setButtonEnabled(i, !inCombat);
if (dynamic_cast<WhichItem *>(msg._priorView) == nullptr &&
dynamic_cast<Trade *>(msg._priorView) == nullptr &&
dynamic_cast<GameMessages *>(msg._priorView) == nullptr) {
_mode = BACKPACK_MODE;
_selectedButton = BTN_NONE;
}
populateItems();
return true;
}
bool CharacterInventory::msgGame(const GameMessage &msg) {
if (msg._name == "ITEM" && msg._value >= 0 &&
msg._value < (int)_items.size()) {
_selectedItem = msg._value;
performAction();
return true;
} else if (msg._name == "TRADE") {
_tradeMode = msg._stringValue;
_tradeAmount = msg._value;
addView("WhichCharacter");
return true;
} else if (msg._name == "TRADE_DEST") {
if (msg._value != -1)
trade(_tradeMode, _tradeAmount, &g_globals->_party[msg._value]);
return true;
} else if (msg._name == "USE") {
// Combat use item mode
addView();
return true;
}
return ItemsView::msgGame(msg);
}
void CharacterInventory::draw() {
ItemsView::draw();
drawTitle();
}
void CharacterInventory::drawTitle() {
const Character &c = *g_globals->_currCharacter;
const Common::String fmt = STRING[(_mode == ARMS_MODE) ?
"enhdialogs.items.arms_for" :
"enhdialogs.items.backpack_for"];
const Common::String title = Common::String::format(fmt.c_str(),
c._name,
STRING[Common::String::format("stats.classes.%d", c._class)].c_str()
);
setReduced(false);
writeLine(0, title, ALIGN_MIDDLE);
}
bool CharacterInventory::msgKeypress(const KeypressMessage &msg) {
if (endDelay())
return true;
switch (msg.keycode) {
case Common::KEYCODE_a:
_mode = ARMS_MODE;
populateItems();
redraw();
return true;
case Common::KEYCODE_b:
_mode = BACKPACK_MODE;
populateItems();
redraw();
return true;
default:
break;
}
if (!g_events->isInCombat()) {
switch (msg.keycode) {
case Common::KEYCODE_e:
selectButton(BTN_EQUIP);
return true;
case Common::KEYCODE_r:
selectButton(BTN_REMOVE);
return true;
case Common::KEYCODE_d:
selectButton(BTN_DISCARD);
return true;
case Common::KEYCODE_t:
addView("Trade");
return true;
case Common::KEYCODE_u:
selectButton(BTN_USE);
return true;
default:
break;
}
}
return ItemsView::msgKeypress(msg);
}
bool CharacterInventory::msgAction(const ActionMessage &msg) {
if (endDelay())
return true;
return ItemsView::msgAction(msg);
}
void CharacterInventory::populateItems() {
_items.clear();
_selectedItem = -1;
const Character &c = *g_globals->_currCharacter;
const Inventory &inv = (_mode == ARMS_MODE) ? c._equipped : c._backpack;
for (uint i = 0; i < inv.size(); ++i)
_items.push_back(inv[i]._id);
}
bool CharacterInventory::canSwitchChar() {
// When in combat, the current character can't be changed
return !g_events->isInCombat();
}
bool CharacterInventory::canSwitchToChar(Character *dst) {
if (_selectedItem != -1) {
tradeItem(dst);
return false;
}
return true;
}
void CharacterInventory::charSwitched(Character *priorChar) {
PartyView::charSwitched(priorChar);
populateItems();
redraw();
}
void CharacterInventory::itemSelected() {
if (g_events->isInCombat() && dynamic_cast<Combat *>(g_events->priorView()) != nullptr) {
useItem();
}
}
void CharacterInventory::selectButton(SelectedButton btnMode) {
if (btnMode == BTN_EQUIP && _mode == ARMS_MODE) {
// Selecting items to equip only makes sense in BACKPACK_MODE,
// so we switch to it:
_mode = BACKPACK_MODE;
populateItems();
redraw();
draw();
}
else if (btnMode == BTN_REMOVE && _mode == BACKPACK_MODE) {
// Selecting items to unequip only makes sense in ARMS_MODE,
// so we switch to it:
_mode = ARMS_MODE;
populateItems();
redraw();
draw();
}
_selectedButton = btnMode;
if (_selectedItem != -1) {
performAction();
} else {
Common::String btn = STRING["enhdialogs.items.equip"];
if (btnMode == BTN_REMOVE)
btn = STRING["enhdialogs.items.remove"];
else if (btnMode == BTN_DISCARD)
btn = STRING["enhdialogs.items.discard"];
else if (btnMode == BTN_USE)
btn = STRING["enhdialogs.items.use"];
else if (btnMode == BTN_CHARGE)
btn = STRING["enhdialogs.items.charge"];
send("WhichItem", GameMessage("DISPLAY",
Common::String::format("%s %s", btn.c_str(),
STRING["enhdialogs.items.which_item"].c_str())
));
}
}
void CharacterInventory::performAction() {
switch (_selectedButton) {
case BTN_EQUIP:
equipItem();
break;
case BTN_REMOVE:
removeItem();
break;
case BTN_DISCARD:
discardItem();
break;
case BTN_USE:
useItem();
break;
default:
error("No button selected");
break;
}
}
void CharacterInventory::equipItem() {
Common::String errMsg;
Common::Point textPos;
if (EquipRemove::equipItem(_selectedItem, textPos, errMsg)) {
_mode = ARMS_MODE;
populateItems();
redraw();
} else {
displayMessage(errMsg);
}
}
void CharacterInventory::removeItem() {
Common::String errMsg;
Common::Point textPos;
if (EquipRemove::removeItem(_selectedItem, textPos, errMsg)) {
_mode = BACKPACK_MODE;
populateItems();
redraw();
} else {
displayMessage(errMsg);
}
}
void CharacterInventory::useItem() {
Character &c = *g_globals->_currCharacter;
Inventory &inv = (_mode == ARMS_MODE) ? c._equipped : c._backpack;
Inventory::Entry *invEntry = &inv[_selectedItem];
Common::String msg;
if (g_events->isInCombat())
msg = Game::UseItem::combatUseItem(inv, *invEntry, _mode == BACKPACK_MODE);
else
msg = Game::UseItem::nonCombatUseItem(inv, *invEntry, _mode == BACKPACK_MODE);
if (!msg.empty())
displayMessage(msg);
else
g_events->replaceView("Game", true);
}
void CharacterInventory::discardItem() {
Character &c = *g_globals->_currCharacter;
Inventory &inv = (_mode == ARMS_MODE) ? c._equipped : c._backpack;
inv.removeAt(_selectedItem);
populateItems();
redraw();
}
void CharacterInventory::tradeItem(Character *dst) {
if (dst == g_globals->_currCharacter)
return;
// Get source and dest inventories
Character &cSrc = *g_globals->_currCharacter;
Inventory &iSrc = (_mode == ARMS_MODE) ? cSrc._equipped : cSrc._backpack;
Character &cDest = *dst;
Inventory &iDest = cDest._backpack;
if (iDest.full()) {
backpackFull();
} else {
Inventory::Entry item = iSrc[_selectedItem];
iSrc.removeAt(_selectedItem);
iDest.add(item._id, item._charges);
populateItems();
redraw();
}
}
void CharacterInventory::trade(const Common::String &mode, int amount, Character *destChar) {
assert(isFocused());
Character &src = *g_globals->_currCharacter;
if (mode == "GEMS") {
src._gems -= amount;
destChar->_gems = MIN(destChar->_gems + amount, 0xffff);
} else if (mode == "GOLD") {
src._gold -= amount;
destChar->_gold += amount;
} else if (mode == "FOOD") {
src._food -= amount;
destChar->_food = MIN(destChar->_food + amount, MAX_FOOD);
}
redraw();
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,138 @@
/* 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_CHARACTER_INVENTORY_H
#define MM1_VIEWS_ENH_CHARACTER_INVENTORY_H
#include "mm/mm1/views_enh/items_view.h"
#include "mm/mm1/data/character.h"
#include "mm/mm1/game/equip_remove.h"
#include "mm/mm1/game/use_item.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class CharacterInventory : public ItemsView, public Game::EquipRemove,
public Game::UseItem {
protected:
enum SelectedButton {
BTN_NONE, BTN_EQUIP, BTN_REMOVE, BTN_DISCARD, BTN_USE, BTN_CHARGE, BTN_COPY
};
enum DisplayMode {
ARMS_MODE, BACKPACK_MODE
};
SelectedButton _selectedButton = BTN_NONE;
DisplayMode _mode = ARMS_MODE;
private:
Common::String _tradeMode;
int _tradeAmount;
/**
* Populates the list of items
*/
void populateItems();
/**
* Displays the title row
*/
void drawTitle();
/**
* Equip an item
*/
void equipItem();
/**
* Unequip an item
*/
void removeItem();
/**
* Discard an item
*/
void discardItem();
/**
* Use an item
*/
void useItem();
/**
* Trade an item to another character
*/
void tradeItem(Character *from);
/**
* Trade gems, gold, or food
*/
void trade(const Common::String &mode, int amount, Character *destChar);
protected:
/**
* Return true if the selected character can be switched
*/
bool canSwitchChar() override;
/**
* Returns true if the destination character can be switched to
*/
bool canSwitchToChar(Character *dst) override;
/**
* Called when an item is selected
*/
void itemSelected() override;
/**
* When the selected character is changed
*/
void charSwitched(Character *priorChar) override;
/**
* Handle action with selected button mode and selected item
*/
virtual void performAction();
/**
* Selects a button mode
*/
void selectButton(SelectedButton btnMode);
public:
CharacterInventory();
CharacterInventory(const Common::String &name);
virtual ~CharacterInventory() {}
void setup();
bool msgFocus(const FocusMessage &msg) override;
bool msgGame(const GameMessage &msg) override;
void draw() override;
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,179 @@
/* 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/character_manage.h"
#include "mm/mm1/utils/strings.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
CharacterManage::CharacterManage() : CharacterBase("CharacterManage") {
addButton(&_escSprite, Common::Point(20, 172), 0, Common::KEYCODE_p, true);
addButton(&_escSprite, Common::Point(90, 172), 0, Common::KEYCODE_r, true);
addButton(&_escSprite, Common::Point(160, 172), 0, Common::KEYCODE_d, true);
addButton(&_escSprite, Common::Point(230, 172), 0, KEYBIND_ESCAPE, true);
}
bool CharacterManage::msgFocus(const FocusMessage &msg) {
CharacterBase::msgFocus(msg);
_changed = false;
return true;
}
bool CharacterManage::msgUnfocus(const UnfocusMessage &msg) {
if (_changed)
g_globals->_roster.save();
CharacterBase::msgUnfocus(msg);
return true;
}
void CharacterManage::abortFunc() {
CharacterManage *view = static_cast<CharacterManage *>(g_events->focusedView());
view->setMode(DISPLAY);
}
void CharacterManage::enterFunc(const Common::String &name) {
CharacterManage *view = static_cast<CharacterManage *>(g_events->focusedView());
view->setName(name);
}
void CharacterManage::draw() {
assert(g_globals->_currCharacter);
setReduced(false);
CharacterBase::draw();
switch (_state) {
case DISPLAY:
setReduced(true);
writeString(35, 174, STRING["enhdialogs.character.portrait"]);
writeString(105, 174, STRING["enhdialogs.character.rename"]);
writeString(175, 174, STRING["enhdialogs.character.delete"]);
writeString(245, 174, STRING["enhdialogs.misc.go_back"]);
break;
case RENAME:
_state = DISPLAY;
writeString(80, 172, STRING["dialogs.view_character.name"]);
_textEntry.display(130, 180, 15, false, abortFunc, enterFunc);
break;
case DELETE:
writeString(120, 174, STRING["enhdialogs.character.are_you_sure"]);
break;
}
}
bool CharacterManage::msgKeypress(const KeypressMessage &msg) {
Character &c = *g_globals->_currCharacter;
switch (_state) {
case DISPLAY:
switch (msg.keycode) {
case Common::KEYCODE_p:
c._portrait = (c._portrait + 1) % NUM_PORTRAITS;
c.loadFaceSprites();
redraw();
break;
case Common::KEYCODE_r:
setMode(RENAME);
break;
case Common::KEYCODE_d:
setMode(DELETE);
break;
default:
break;
}
break;
case RENAME:
break;
case DELETE:
switch (msg.keycode) {
case Common::KEYCODE_y:
msgAction(ActionMessage(KEYBIND_SELECT));
break;
case Common::KEYCODE_n:
msgAction(ActionMessage(KEYBIND_ESCAPE));
break;
default:
break;
}
break;
}
return true;
}
bool CharacterManage::msgAction(const ActionMessage &msg) {
Character &c = *g_globals->_currCharacter;
if (msg._action == KEYBIND_ESCAPE) {
switch (_state) {
case DISPLAY:
close();
break;
default:
setMode(DISPLAY);
break;
}
return true;
} else if (msg._action == KEYBIND_SELECT) {
if (_state == RENAME) {
Common::strcpy_s(c._name, _newName.c_str());
c._name[15] = '\0';
setMode(DISPLAY);
return true;
} else if (_state == DELETE) {
// Removes the character and returns to View All Characters
g_globals->_roster.remove(g_globals->_currCharacter);
_changed = true;
close();
}
}
return CharacterBase::msgAction(msg);
}
void CharacterManage::setMode(ViewState state) {
_state = state;
for (int i = 0; i < 4; ++i)
setButtonEnabled(i, state == DISPLAY);
redraw();
}
void CharacterManage::setName(const Common::String &newName) {
Character &c = *g_globals->_currCharacter;
Common::strcpy_s(c._name, newName.c_str());
c._name[15] = '\0';
_changed = true;
setMode(DISPLAY);
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,71 @@
/* 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_CHARACTER_MANAGE_H
#define MM1_VIEWS_ENH_CHARACTER_MANAGE_H
#include "common/array.h"
#include "mm/mm1/views_enh/character_base.h"
#include "mm/mm1/views_enh/text_entry.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
/**
* Character management dialog
*/
class CharacterManage : public CharacterBase {
enum ViewState { DISPLAY = 0, RENAME = 1, DELETE = 2 };
private:
ViewState _state = DISPLAY;
Common::String _newName;
bool _changed = false;
TextEntry _textEntry;
static void abortFunc();
static void enterFunc(const Common::String &name);
/**
* Set the mode
*/
void setMode(ViewState state);
/**
* Set a new name
*/
void setName(const Common::String &newName);
public:
CharacterManage();
virtual ~CharacterManage() {}
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;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,67 @@
/* 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/character_select.h"
#include "mm/mm1/events.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
CharacterSelect::CharacterSelect() : PartyView("CharacterSelect") {
_bounds = Common:: Rect(225, 144, 320, 200);
}
void CharacterSelect::draw() {
ScrollView::draw();
_fontReduced = true;
writeString(0, 0, STRING["enhdialogs.character_select.title"]);
}
bool CharacterSelect::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
g_events->send(g_events->focusedView()->getName(),
GameMessage("CHAR_SELECTED", -1));
return true;
} else {
return PartyView::msgAction(msg);
}
}
bool CharacterSelect::canSwitchToChar(Character *dst) {
close();
// Signal the character that was selected
int charNum = g_globals->_party.indexOf(dst);
g_events->send(g_events->focusedView()->getName(),
GameMessage("CHAR_SELECTED", charNum));
// Return false, because we don't want the character that was
// selected to be actually switched to
return false;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,62 @@
/* 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_CHARACTER_SELECT_H
#define MM1_VIEWS_ENH_CHARACTER_SELECT_H
#include "mm/mm1/messages.h"
#include "mm/mm1/data/character.h"
#include "mm/mm1/views_enh/party_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
/**
* Dialog for choosing a character target
*/
class CharacterSelect : public PartyView {
protected:
/**
* Return true if a character should be selected by default
*/
virtual bool selectCharByDefault() const override {
return false;
}
/**
* Returns true if the destination character can be switched to
*/
bool canSwitchToChar(Character *dst) override;
public:
CharacterSelect();
virtual ~CharacterSelect() {}
void draw() override;
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,41 @@
/* 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/character_view.h"
#include "mm/mm1/utils/strings.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
CharacterView::CharacterView() : CharacterBase("CharacterView") {
addButton(&_escSprite, Common::Point(105, 172), 0, KEYBIND_ESCAPE, true);
}
void CharacterView::draw() {
CharacterBase::draw();
writeString(120, 174, STRING["dialogs.misc.go_back"]);
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_CHARACTER_VIEW_H
#define MM1_VIEWS_ENH_CHARACTER_VIEW_H
#include "common/array.h"
#include "mm/mm1/views_enh/character_base.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
/**
* Character view from the inn screen
*/
class CharacterView : public CharacterBase {
public:
CharacterView();
virtual ~CharacterView() {}
/**
* Draw the view
*/
void draw() override;
};
} // namespace Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,119 @@
/* 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(120, 172), 0, KEYBIND_ESCAPE, true);
}
void Characters::draw() {
ScrollView::draw();
Graphics::ManagedSurface s = getSurface();
Roster &roster = g_globals->_roster;
_charIndexes.clear();
// 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 charNum = 0; charNum < ROSTER_COUNT; ++charNum) {
if (!roster._towns[charNum])
continue;
const Character &c = roster[charNum];
_charIndexes.push_back(charNum);
int idx = _charIndexes.size() - 1;
// 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(135, 174, STRING["enhdialogs.misc.go_back"]);
}
bool Characters::msgMouseDown(const MouseDownMessage &msg) {
// Cycle through portraits
for (uint idx = 0; idx < _charIndexes.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)) {
g_globals->_currCharacter = &g_globals->_roster[_charIndexes[idx]];
_characterView.addView();
return true;
}
}
return ScrollView::msgMouseDown(msg);
}
bool Characters::msgKeypress(const KeypressMessage &msg) {
if (msg.keycode >= Common::KEYCODE_a &&
msg.keycode < (Common::KeyCode)(Common::KEYCODE_a + _charIndexes.size())) {
g_globals->_currCharacter = &g_globals->_roster[_charIndexes[msg.keycode - Common::KEYCODE_a]];
_characterView.addView();
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);
}
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,53 @@
/* 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/views_enh/character_manage.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:
CharacterManage _characterView;
Shared::Xeen::SpriteResource _escSprite;
Common::Array<uint> _charIndexes;
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

View File

@@ -0,0 +1,142 @@
/* 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/color_questions.h"
#include "mm/mm1/maps/map17.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define COLOR 510
#define CORRECT_ANSWERS 511
ColorQuestions::ColorQuestions() : ScrollView("ColorQuestions") {
setBounds(Common::Rect(0, 88, 234, 144));
}
bool ColorQuestions::msgFocus(const FocusMessage &msg) {
ScrollView::msgFocus(msg);
_showingResponse = false;
// Find first non-incapacitated party member
_charIndex = -1;
moveToNextChar();
return true;
}
void ColorQuestions::draw() {
// Highlight next character to answer question
g_globals->_currCharacter = &g_globals->_party[_charIndex];
g_events->send("GameParty", GameMessage("CHAR_HIGHLIGHT", (int)true));
// Draw view
ScrollView::draw();
setReduced(false);
if (!_showingResponse) {
writeString(0, 0, STRING["maps.map17.color"]);
setReduced(true);
for (int option = 0; option < 8; ++option) {
Common::String prefix = Common::String::format("%c) ", '1' + option);
writeString(20 + 105 * (option % 2), 10 + (option / 2) * 8, prefix, ALIGN_RIGHT);
writeString(STRING[Common::String::format("colors.%d", option + 1)]);
}
} else {
const Character &c = g_globals->_party[_charIndex];
Common::String result = STRING[c.hasBadCondition() ?
"maps.map17.wrong" : "maps.map17.correct"];
writeLine(1, result, ALIGN_MIDDLE);
}
}
bool ColorQuestions::msgKeypress(const KeypressMessage &msg) {
if (endDelay())
return true;
if (!_showingResponse && msg.keycode >= Common::KEYCODE_1 && msg.keycode <= Common::KEYCODE_9) {
Maps::Map17 &map = *static_cast<Maps::Map17 *>(g_maps->_currentMap);
map[COLOR] = msg.ascii - '1';
Character &c = g_globals->_party[_charIndex];
int color = c._flags[2] & 0xf;
// If a color hasn't been designated yet from talking to Gypsy,
// or it has but the wrong color is selected, eradicate them
if (!color || (color & 7) != map[COLOR]) {
c._condition = ERADICATED;
} else {
map[CORRECT_ANSWERS]++;
c._flags[4] |= CHARFLAG4_80;
}
// Show the response
_showingResponse = true;
redraw();
delaySeconds(2);
return true;
}
return false;
}
bool ColorQuestions::msgAction(const ActionMessage &msg) {
if (endDelay())
return true;
return false;
}
void ColorQuestions::timeout() {
// Move to next non-incapacitated character
_showingResponse = false;
moveToNextChar();
if (_charIndex >= (int)g_globals->_party.size()) {
// All of party questioned
close();
g_maps->_mapPos.y = 2;
g_maps->_currentMap->updateGame();
g_globals->_party.checkPartyDead();
} else {
// Prompt response for next party member
redraw();
}
}
void ColorQuestions::moveToNextChar() {
do {
++_charIndex;
} while (_charIndex < (int)g_globals->_party.size() &&
g_globals->_party[_charIndex].hasBadCondition());
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,53 @@
/* 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_COLOR_QUESTIONS_H
#define MM1_VIEWS_ENH_COLOR_QUESTIONS_H
#include "mm/mm1/views_enh/scroll_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class ColorQuestions : public ScrollView {
private:
int _charIndex = 0;
bool _showingResponse = false;
void moveToNextChar();
public:
ColorQuestions();
virtual ~ColorQuestions() {
}
bool msgFocus(const FocusMessage &msg) override;
void draw() override;
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
void timeout() override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,290 @@
/* 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_COMBAT_H
#define MM1_VIEWS_ENH_COMBAT_H
#include "mm/mm1/game/combat.h"
#include "mm/mm1/views_enh/scroll_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class Combat : public ScrollView, public Game::Combat {
private:
LineArray _monsterSpellLines;
uint _attackableCount = 0;
InfoMessage _spellResult;
bool _firstDraw = false;
// Combat options that have sub-option selection
enum SelectedOption {
OPTION_NONE, OPTION_DELAY, OPTION_EXCHANGE,
OPTION_FIGHT, OPTION_SHOOT
};
SelectedOption _option = OPTION_NONE;
/**
* Selects a combat option that requires a selection
*/
void setOption(SelectedOption option);
void writeOptions();
void writeAllOptions();
void writeAttackOptions();
void writeCastOption();
void writeShootOption();
void clearSurface() override;
void clearBottom();
void clearArea(const Common::Rect &r);
void resetBottom();
void writeBottomText(int x, int line, const Common::String &msg,
TextAlign align = ALIGN_LEFT);
Common::Rect getOptionButtonRect(uint col, uint row);
void writeOption(uint col, uint row, char c, const Common::String &msg);
/**
* Write the encounter handicap
*/
void writeHandicap();
/**
* Write out all the static content
*/
void writeStaticContent();
/**
* Write out the round number
*/
void writeRound();
/**
* Writes out the party member numbers,
* with a plus next to each if they can attack
*/
void writePartyNumbers();
/**
* Write the monsters list
*/
void writeMonsters();
/**
* Write out a monster's status
*/
void writeMonsterStatus(int monsterNum);
/**
* Write out a series of dots
*/
void writeDots();
/**
* Writes out the party members
*/
void writeParty();
/**
* Clears the party area
*/
void clearPartyArea();
/**
* Writes the result of defeating all the monsters
*/
void writeDefeat();
/**
* Highlight the round number indicator
*/
void highlightNextRound();
/**
* Write monster changes
*/
void writeMonsterEffects();
/**
* Handles a monster action
*/
void writeMonsterAction(bool flees);
/**
* Write out message from a monster casting a spell
*/
void writeMonsterSpell();
/**
* Write out monster's attack
*/
void writeMonsterAttack();
/**
* Write message for monster infiltrating the party
*/
void writeInfiltration();
/**
* Write message for monster waits for an opening
*/
void writeWaitsForOpening();
/**
* Writes the result of a spell
*/
void writeSpellResult();
/**
* Whether there's messages remaining
*/
void checkMonsterSpellDone();
/**
* Delay option
*/
void delay();
/**
* Exchange option
*/
void exchange();
/**
* Fight option
*/
void fight();
/**
* Shoot option
*/
void shoot();
/**
* Write message for characters attacking monsters
*/
void writeCharAttackDamage();
/**
* Write message for character attack having no effect
*/
void writeCharAttackNoEffect();
/**
* Get attack damage string
*/
Common::String getAttackString();
/**
* Writes out a message
*/
void writeMessage();
/**
* Writes text for delay number selection
*/
void writeDelaySelect();
/**
* Write text for exchange party member
*/
void writeExchangeSelect();
/**
* Having selected to fight, selects monster to attack
*/
void writeFightSelect();
/**
* Having selected to shoot, selects monster to attack
*/
void writeShootSelect();
protected:
/**
* Sets a new display mode
*/
void setMode(Mode newMode) override;
/**
* Does final cleanup when combat is done
*/
void combatDone() override;
public:
Combat();
virtual ~Combat() {}
void displaySpellResult(const InfoMessage &msg) override;
/**
* Disable the flags for allowing attacks for
* the current character
*/
void disableAttacks();
/**
* Called when the view is focused
*/
bool msgFocus(const FocusMessage &msg) override;
/**
* Called when the view is unfocused
*/
bool msgUnfocus(const UnfocusMessage &msg) override;
/**
* Called for game messages
*/
bool msgGame(const GameMessage &msg) override;
/**
* Draw the Combat details overlayed on
* the existing game screen
*/
void draw() override;
/**
* Handles delay timeouts
*/
void timeout() override;
/**
* Handles keypresses
*/
bool msgKeypress(const KeypressMessage &msg) override;
/**
* Handle mouse up messages
*/
bool msgMouseUp(const MouseUpMessage &msg) override;
/**
* Key binder actions
*/
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,83 @@
/* 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/confirm.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
Confirm::Confirm() : ScrollView("Confirm") {
_bounds = Common::Rect(99, 59, 237, 141);
_bounds.setBorderSize(10);
addButton(&g_globals->_confirmIcons, Common::Point(20, 44), 0, Common::KEYCODE_y);
addButton(&g_globals->_confirmIcons, Common::Point(70, 44), 2, Common::KEYCODE_n);
}
void Confirm::show(const Common::String &msg,
YNCallback callback) {
Confirm *view = static_cast<Confirm *>(g_events->findView("Confirm"));
view->_msg = msg;
view->_callback = callback;
view->addView();
}
void Confirm::draw() {
ScrollView::draw();
writeString(0, 0, _msg);
}
bool Confirm::msgKeypress(const KeypressMessage &msg) {
switch (msg.keycode) {
case Common::KEYCODE_y:
return msgAction(ActionMessage(KEYBIND_SELECT));
break;
case Common::KEYCODE_n:
return msgAction(ActionMessage(KEYBIND_ESCAPE));
break;
default:
return true;
}
}
bool Confirm::msgAction(const ActionMessage &msg) {
switch (msg._action) {
case KEYBIND_SELECT:
close();
_callback();
break;
case KEYBIND_ESCAPE:
close();
break;
default:
break;
}
return true;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_CONFIRM_H
#define MM1_VIEWS_ENH_CONFIRM_H
#include "mm/mm1/views_enh/scroll_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class Confirm : public ScrollView {
private:
Common::String _msg;
YNCallback _callback = nullptr;
public:
Confirm();
virtual ~Confirm() {}
static void show(const Common::String &msg,
YNCallback callback);
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
void draw() override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,592 @@
/* 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/create_characters.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define RIGHT_X 200
void CreateCharacters::NewCharacter::clear() {
Common::fill(_attribs1, _attribs1 + 7, 0);
Common::fill(_attribs2, _attribs2 + 7, 0);
_class = KNIGHT;
_race = HUMAN;
_alignment = GOOD;
_sex = MALE;
_name = "";
Common::fill(_classesAllowed, _classesAllowed + 7, 0);
}
void CreateCharacters::NewCharacter::reroll() {
clear();
// Generate attributes
for (int attrib = INTELLECT; attrib <= LUCK; ++attrib)
_attribs1[attrib] = g_engine->getRandomNumber(4, 17);
Common::copy(_attribs1, _attribs1 + 7, _attribs2);
// Select which classes are available
_classesAllowed[KNIGHT] = _attribs1[MIGHT] >= 12;
_classesAllowed[PALADIN] = _attribs1[MIGHT] >= 12 && _attribs1[PERSONALITY] >= 12 &&
_attribs1[ENDURANCE] >= 12;
_classesAllowed[ARCHER] = _attribs1[INTELLECT] >= 12 && _attribs1[ACCURACY] >= 12;
_classesAllowed[CLERIC] = _attribs1[PERSONALITY] >= 12;
_classesAllowed[SORCERER] = _attribs1[INTELLECT] >= 12;
_classesAllowed[ROBBER] = true;
}
void CreateCharacters::NewCharacter::loadPortrait() {
Common::Path cname(Common::String::format("char%02d.fac",
_portrait * 2 + (_sex == MALE ? 0 : 1) + 1));
_portraits.load(cname);
}
void CreateCharacters::NewCharacter::save() {
uint i = 0;
while (i < ROSTER_COUNT && g_globals->_roster._towns[i])
++i;
g_globals->_roster._towns[i] = Maps::SORPIGAL;
g_globals->_currCharacter = &g_globals->_roster[i];
Character &re = *g_globals->_currCharacter;
re.clear();
Common::strcpy_s(re._name, _name.c_str());
re._sex = _sex;
re._alignment = re._alignmentInitial = _alignment;
re._race = _race;
re._class = _class;
re._intelligence = _attribs1[INTELLECT];
re._might = _attribs1[MIGHT];
re._personality = _attribs1[PERSONALITY];
re._endurance = _attribs1[ENDURANCE];
re._speed = _attribs1[SPEED];
re._accuracy = _attribs1[ACCURACY];
re._luck = _attribs1[LUCK];
switch (_class) {
case KNIGHT:
setHP(12);
break;
case PALADIN:
case ARCHER:
setHP(10);
break;
case CLERIC:
setHP(8);
setSP(_attribs1[PERSONALITY]);
break;
case SORCERER:
setHP(6);
setSP(_attribs1[INTELLECT]);
break;
case ROBBER:
setHP(8);
re._trapCtr = 50;
break;
default:
break;
}
switch (_race) {
case HUMAN:
re._resistances._s._fear = 70;
re._resistances._s._psychic = 25;
break;
case ELF:
re._resistances._s._fear = 70;
break;
case DWARF:
re._resistances._s._poison = 25;
break;
case GNOME:
re._resistances._s._magic = 20;
break;
case HALF_ORC:
re._resistances._s._psychic = 50;
break;
}
re._food = 10;
re._backpack[0]._id = 1;
const int ALIGNMENT_VALS[3] = { 0, 0x10, 0x20 };
re._alignmentCtr = ALIGNMENT_VALS[re._alignmentInitial];
re._portrait = _portrait;
g_globals->_roster.save();
}
void CreateCharacters::NewCharacter::setHP(int hp) {
Character &re = *g_globals->_currCharacter;
if (_attribs1[ENDURANCE] >= 19)
hp += 4;
else if (_attribs1[ENDURANCE] >= 17)
hp += 3;
else if (_attribs1[ENDURANCE] >= 15)
hp += 2;
else if (_attribs1[ENDURANCE] >= 13)
hp += 1;
else if (_attribs1[ENDURANCE] < 5)
hp -= 2;
else if (_attribs1[ENDURANCE] < 8)
hp -= 1;
re._hpCurrent = re._hp = re._hpMax = hp;
int ac = 0;
if (_attribs1[SPEED] >= 19)
ac = 4;
else if (_attribs1[SPEED] >= 17)
ac = 3;
else if (_attribs1[SPEED] >= 15)
ac = 2;
if (_attribs1[SPEED] >= 13)
ac = 1;
re._ac = ac;
}
void CreateCharacters::NewCharacter::setSP(int amount) {
Character &re = *g_globals->_currCharacter;
int level = 0;
if (amount >= 19)
level = 4;
else if (amount >= 17)
level = 3;
else if (amount >= 15)
level = 2;
else if (amount >= 13)
level = 1;
re._sp._base = re._sp._current = level + 3;
re._spellLevel = 1;
}
/*------------------------------------------------------------------------*/
CreateCharacters::CreateCharacters() : ScrollView("CreateCharacters") {
_icons.load("create.icn");
addButton(&_icons, Common::Point(120, 172), 4, KEYBIND_ESCAPE, true);
addButton(&_icons, Common::Point(40, 120), 0, Common::KEYCODE_r);
addButton(&_icons, Common::Point(190, 110), 6, Common::KEYCODE_UP);
addButton(&_icons, Common::Point(190, 130), 8, Common::KEYCODE_DOWN);
addButton(&_icons, Common::Point(220, 120), 2, KEYBIND_SELECT);
setButtonEnabled(2, false);
setButtonEnabled(3, false);
setButtonEnabled(4, false);
}
bool CreateCharacters::msgFocus(const FocusMessage &msg) {
if (dynamic_cast<TextEntry *>(msg._priorView) == nullptr)
_newChar.reroll();
return true;
}
void CreateCharacters::draw() {
ScrollView::draw();
printAttributes();
if ((int)_state >= SELECT_NAME) {
Graphics::ManagedSurface s = getSurface();
_newChar._portraits.draw(&s, 0, Common::Point(10, 10));
}
writeString(135, 174, STRING["enhdialogs.misc.go_back"]);
writeString(70, 125, STRING["enhdialogs.create_characters.roll"]);
switch (_state) {
case SELECT_CLASS:
printClasses();
if (g_globals->_roster.full())
writeLine(9, STRING["dialogs.create_characters.full"], ALIGN_MIDDLE, 190);
break;
case SELECT_RACE:
printRaces();
break;
case SELECT_ALIGNMENT:
printAlignments();
break;
case SELECT_SEX:
printSexes();
break;
case SELECT_PORTRAIT:
printPortraits();
break;
case SELECT_NAME:
printSelectName();
break;
case SAVE_PROMPT:
printSummary();
break;
default:
break;
}
}
void CreateCharacters::printAttributes() {
writeLine(0, STRING["dialogs.create_characters.title"], ALIGN_MIDDLE);
writeLine(5, STRING["enhdialogs.create_characters.intellect"], ALIGN_RIGHT, 90);
writeLine(6, STRING["enhdialogs.create_characters.might"], ALIGN_RIGHT, 90);
writeLine(7, STRING["enhdialogs.create_characters.personality"], ALIGN_RIGHT, 90);
writeLine(8, STRING["enhdialogs.create_characters.endurance"], ALIGN_RIGHT, 90);
writeLine(9, STRING["enhdialogs.create_characters.speed"], ALIGN_RIGHT, 90);
writeLine(10, STRING["enhdialogs.create_characters.accuracy"], ALIGN_RIGHT, 90);
writeLine(11, STRING["enhdialogs.create_characters.luck"], ALIGN_RIGHT, 90);
for (int i = 0; i < 7; ++i, _textPos.y += 2) {
writeLine(5 + i,
Common::String::format("%u", _newChar._attribs1[i]),
ALIGN_RIGHT, 110);
}
}
void CreateCharacters::addSelection(int yStart, int num) {
Common::Rect r(170, 0, 320, 9);
r.translate(0, (yStart + num) * 9);
addButton(r, Common::KeyState((Common::KeyCode)(Common::KEYCODE_0 + num), '0' + num));
}
void CreateCharacters::printClasses() {
for (int classNum = KNIGHT; classNum <= SORCERER; ++classNum) {
setTextColor(_newChar._classesAllowed[classNum] ? 0 : 1);
writeLine(4 + classNum, Common::String::format("%d) %s",
classNum,
STRING[Common::String::format("stats.classes.%d", classNum)].c_str()
), ALIGN_LEFT, 170);
if (_newChar._classesAllowed[classNum])
addSelection(4, classNum);
}
setTextColor(0);
writeLine(10, Common::String::format("6) %s", STRING["stats.classes.6"].c_str()),
ALIGN_LEFT, 170);
addSelection(4, ROBBER);
writeLine(13, STRING["dialogs.create_characters.select_class"], ALIGN_MIDDLE, RIGHT_X);
writeLine(14, "(1-6)", ALIGN_MIDDLE, RIGHT_X);
}
void CreateCharacters::printRaces() {
writeLine(5, STRING["enhdialogs.create_characters.class"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.classes.%d", _newChar._class)]);
for (int i = 1; i <= 5; ++i) {
writeLine(6 + i, Common::String::format("%d) %s", i,
STRING[Common::String::format("stats.races.%d", i)].c_str()),
ALIGN_LEFT, 170);
addSelection(6, i);
}
writeLine(13, STRING["dialogs.create_characters.select_race"], ALIGN_MIDDLE, RIGHT_X);
writeLine(14, "(1-5)", ALIGN_MIDDLE, RIGHT_X);
}
void CreateCharacters::printAlignments() {
writeLine(5, STRING["enhdialogs.create_characters.class"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.classes.%d", _newChar._class)]);
writeLine(6, STRING["enhdialogs.create_characters.race"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.races.%d", _newChar._race)]);
for (int i = 1; i <= 3; ++i) {
writeLine(7 + i, Common::String::format("%d) %s", i,
STRING[Common::String::format("stats.alignments.%d", i)].c_str()),
ALIGN_LEFT, 170);
addSelection(7, i);
}
writeLine(13, STRING["dialogs.create_characters.select_alignment"], ALIGN_MIDDLE, RIGHT_X);
writeLine(14, "(1-3)", ALIGN_MIDDLE, RIGHT_X);
}
void CreateCharacters::printSexes() {
writeLine(5, STRING["enhdialogs.create_characters.class"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.classes.%d", _newChar._class)]);
writeLine(6, STRING["enhdialogs.create_characters.race"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.races.%d", _newChar._race)]);
writeLine(7, STRING["enhdialogs.create_characters.alignment"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.alignments.%d", _newChar._alignment)]);
writeLine(9, "1) ", ALIGN_LEFT, 170);
writeString(STRING["stats.sex.1"]);
addSelection(8, 1);
writeLine(10, "2) ", ALIGN_LEFT, 170);
writeString(STRING["stats.sex.2"]);
addSelection(8, 2);
writeLine(14, STRING["dialogs.create_characters.select_sex"], ALIGN_MIDDLE, RIGHT_X);
writeLine(15, "(1-2)", ALIGN_MIDDLE, RIGHT_X);
}
void CreateCharacters::printSelections() {
writeLine(5, STRING["enhdialogs.create_characters.class"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.classes.%d", _newChar._class)]);
writeLine(6, STRING["enhdialogs.create_characters.race"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.races.%d", _newChar._race)]);
writeLine(7, STRING["enhdialogs.create_characters.alignment"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.alignments.%d", _newChar._alignment)]);
writeLine(8, STRING["enhdialogs.create_characters.sex"], ALIGN_RIGHT, RIGHT_X);
writeString(STRING[Common::String::format("stats.sex.%d", _newChar._sex)]);
}
void CreateCharacters::printPortraits() {
printSelections();
writeLine(10, STRING["enhdialogs.create_characters.select_portrait"], ALIGN_MIDDLE, RIGHT_X);
Graphics::ManagedSurface s = getSurface();
_newChar._portraits.draw(&s, 0, Common::Point(160, 120));
writeString(250, 126, STRING["enhdialogs.create_characters.select"]);
}
void CreateCharacters::printSelectName() {
printSelections();
writeLine(10, STRING["enhdialogs.create_characters.enter_name"], ALIGN_MIDDLE, RIGHT_X);
}
void CreateCharacters::printSummary() {
printSelections();
writeLine(9, STRING["enhdialogs.create_characters.name"], ALIGN_RIGHT, RIGHT_X);
writeString(_newChar._name);
writeLine(12, STRING["dialogs.create_characters.save_character"], ALIGN_MIDDLE, RIGHT_X);
}
bool CreateCharacters::msgKeypress(const KeypressMessage &msg) {
if (msg.keycode == Common::KEYCODE_r && _state != SELECT_NAME) {
setState(SELECT_CLASS);
_newChar.reroll();
redraw();
return true;
}
switch (_state) {
case SELECT_CLASS:
if (msg.keycode >= Common::KEYCODE_1 &&
msg.keycode <= Common::KEYCODE_6) {
if (_newChar._classesAllowed[msg.keycode - Common::KEYCODE_0] &&
!g_globals->_roster.full()) {
// Selected a valid class
_newChar._class = (CharacterClass)(msg.keycode - Common::KEYCODE_0);
setState(SELECT_RACE);
redraw();
}
}
break;
case SELECT_RACE:
if (msg.keycode >= Common::KEYCODE_1 &&
msg.keycode <= Common::KEYCODE_5) {
// Selected a race
_newChar._race = (Race)(msg.keycode - Common::KEYCODE_0);
switch (_newChar._race) {
case ELF:
_newChar._attribs1[INTELLECT]++;
_newChar._attribs1[ACCURACY]++;
_newChar._attribs1[MIGHT]--;
_newChar._attribs1[ENDURANCE]--;
break;
case DWARF:
_newChar._attribs1[ENDURANCE]++;
_newChar._attribs1[LUCK]++;
_newChar._attribs1[INTELLECT]--;
_newChar._attribs1[SPEED]--;
break;
case GNOME:
_newChar._attribs1[LUCK] += 2;
_newChar._attribs1[SPEED]--;
_newChar._attribs1[ACCURACY]--;
break;
case HALF_ORC:
_newChar._attribs1[MIGHT]++;
_newChar._attribs1[ENDURANCE]++;
_newChar._attribs1[INTELLECT]--;
_newChar._attribs1[PERSONALITY]--;
_newChar._attribs1[LUCK]--;
break;
default:
break;
}
setState(SELECT_ALIGNMENT);
redraw();
}
break;
case SELECT_ALIGNMENT:
if (msg.keycode >= Common::KEYCODE_1 &&
msg.keycode <= Common::KEYCODE_3) {
// Selected a valid alignment
_newChar._alignment = (Alignment)(msg.keycode - Common::KEYCODE_0);
setState(SELECT_SEX);
redraw();
}
break;
case SELECT_SEX:
if (msg.keycode >= Common::KEYCODE_1 &&
msg.keycode <= Common::KEYCODE_2) {
// Selected a valid sex
_newChar._sex = (Sex)(msg.keycode - Common::KEYCODE_0);
_newChar.loadPortrait();
setState(SELECT_PORTRAIT);
redraw();
}
break;
case SELECT_PORTRAIT:
switch (msg.keycode) {
case Common::KEYCODE_UP:
_newChar._portrait = (_newChar._portrait == 0) ?
NUM_PORTRAITS - 1 : _newChar._portrait - 1;
_newChar.loadPortrait();
redraw();
break;
case Common::KEYCODE_DOWN:
_newChar._portrait = (_newChar._portrait + 1) % NUM_PORTRAITS;
_newChar.loadPortrait();
redraw();
break;
case Common::KEYCODE_s:
msgAction(ActionMessage(KEYBIND_SELECT));
break;
default:
break;
}
return true;
case SAVE_PROMPT:
if (msg.keycode == Common::KEYCODE_y)
_newChar.save();
setState(SELECT_CLASS);
redraw();
break;
case SELECT_NAME:
break;
}
return true;
}
bool CreateCharacters::msgAction(const ActionMessage &msg) {
switch (msg._action) {
case KEYBIND_ESCAPE:
if (_state == SELECT_CLASS) {
close();
} else {
setState(SELECT_CLASS);
_newChar.reroll();
redraw();
}
return true;
case KEYBIND_SELECT:
switch (_state) {
case SELECT_CLASS:
// Re-roll attributes
_newChar.reroll();
redraw();
break;
case SELECT_PORTRAIT:
setState(SELECT_NAME);
break;
case SAVE_PROMPT:
_newChar.save();
setState(SELECT_CLASS);
_newChar.reroll();
redraw();
break;
default:
break;
}
return true;
default:
break;
}
return false;
}
void CreateCharacters::abortFunc() {
CreateCharacters *view = static_cast<CreateCharacters *>(g_events->focusedView());
view->setState(SELECT_CLASS);
}
void CreateCharacters::enterFunc(const Common::String &name) {
CreateCharacters *view = static_cast<CreateCharacters *>(g_events->focusedView());
view->_newChar._name = name;
view->setState(SAVE_PROMPT);
}
void CreateCharacters::setState(State state) {
_state = state;
setButtonEnabled(2, _state == SELECT_PORTRAIT);
setButtonEnabled(3, _state == SELECT_PORTRAIT);
setButtonEnabled(4, _state == SELECT_PORTRAIT);
removeButtons(5, -1);
if (_state == SELECT_CLASS) {
_newChar.reroll();
} else if (_state == SAVE_PROMPT) {
addButton(&g_globals->_confirmIcons, Common::Point(185, 122), 0,
Common::KeyState(Common::KEYCODE_y, 'y'));
addButton(&g_globals->_confirmIcons, Common::Point(215, 122), 2,
Common::KeyState(Common::KEYCODE_n, 'n'));
}
if (_state == SELECT_NAME) {
draw();
_textEntry.display(160, 110, 15, false, abortFunc, enterFunc);
} else {
redraw();
}
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,144 @@
/* 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_CREATE_CHARACTERS_H
#define MM1_VIEWS_ENH_CREATE_CHARACTERS_H
#include "mm/mm1/data/roster.h"
#include "mm/mm1/views_enh/scroll_view.h"
#include "mm/mm1/views_enh/text_entry.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class CreateCharacters : public ScrollView {
enum State {
SELECT_CLASS, SELECT_RACE, SELECT_ALIGNMENT,
SELECT_SEX, SELECT_PORTRAIT, SELECT_NAME, SAVE_PROMPT
};
enum Attribute {
INTELLECT, MIGHT, PERSONALITY, ENDURANCE, SPEED,
ACCURACY, LUCK
};
struct NewCharacter {
private:
void setHP(int hp);
void setSP(int sp);
public:
Shared::Xeen::SpriteResource _portraits;
uint8 _attribs1[LUCK + 1] = { 0 };
uint8 _attribs2[LUCK + 1] = { 0 };
CharacterClass _class = KNIGHT;
Race _race = HUMAN;
Alignment _alignment = GOOD;
Sex _sex = MALE;
Common::String _name;
int _portrait = 0;
bool _classesAllowed[7] = { false };
void clear();
void reroll();
void save();
void loadPortrait();
};
private:
TextEntry _textEntry;
static void abortFunc();
static void enterFunc(const Common::String &name);
Shared::Xeen::SpriteResource _icons;
State _state = SELECT_CLASS;
NewCharacter _newChar;
//int _portraitNum = 0;
/**
* Displays the new character attributes
*/
void printAttributes();
/**
* Add a selection entry
*/
void addSelection(int yStart, int num);
/**
* Display the available classes
*/
void printClasses();
/**
* Display the races
*/
void printRaces();
/**
* Display the alignments
*/
void printAlignments();
/**
* Display the sexes
*/
void printSexes();
/**
* Display the selected summaries
*/
void printSelections();
/**
* Display the portrait selection
*/
void printPortraits();
/**
* Display the name entry
*/
void printSelectName();
/**
* Display the selection summary
*/
void printSummary();
/**
* Sets a new state
*/
void setState(State state);
public:
CreateCharacters();
virtual ~CreateCharacters() {}
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

View File

@@ -0,0 +1,68 @@
/* 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/dead.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
bool Dead::msgFocus(const FocusMessage &msg) {
TextView::msgFocus(msg);
Sound::sound2(SOUND_4);
g_globals->_party.clear();
g_globals->_roster.load();
g_globals->_activeSpells.clear();
// Play the Xeen death sound
g_engine->_sound->playSound("xeenlaff.voc");
return true;
}
void Dead::draw() {
ScrollView::draw();
setReduced(false);
writeLine(4, STRING["dialogs.dead.1"], ALIGN_MIDDLE);
writeLine(6, STRING["dialogs.dead.2"], ALIGN_MIDDLE);
writeLine(8, STRING["dialogs.dead.3"], ALIGN_MIDDLE);
writeLine(10, STRING["dialogs.dead.4"], ALIGN_MIDDLE);
writeLine(12, STRING["dialogs.dead.5"], ALIGN_MIDDLE);
writeLine(14, STRING["dialogs.dead.6"], ALIGN_MIDDLE);
}
bool Dead::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_SELECT) {
replaceView("MainMenu");
return true;
}
return false;
}
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,45 @@
/* 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_DEAD_H
#define MM1_VIEWS_ENH_DEAD_H
#include "mm/mm1/views_enh/scroll_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class Dead : public ScrollView {
public:
Dead() : ScrollView("Dead") {}
virtual ~Dead() {}
bool msgFocus(const FocusMessage &msg) override;
void draw() override;
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,31 @@
/* 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/dialogs.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace Views {
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,191 @@
/* 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_DIALOGS_H
#define MM1_VIEWS_ENH_DIALOGS_H
#include "mm/mm1/events.h"
#include "mm/mm1/views/bash.h"
#include "mm/mm1/views_enh/character_info.h"
#include "mm/mm1/views_enh/character_inventory.h"
#include "mm/mm1/views_enh/character_select.h"
#include "mm/mm1/views_enh/characters.h"
#include "mm/mm1/views_enh/color_questions.h"
#include "mm/mm1/views_enh/combat.h"
#include "mm/mm1/views_enh/confirm.h"
#include "mm/mm1/views_enh/create_characters.h"
#include "mm/mm1/views_enh/dead.h"
#include "mm/mm1/views_enh/encounter.h"
#include "mm/mm1/views_enh/exchange.h"
#include "mm/mm1/views_enh/game.h"
#include "mm/mm1/views_enh/game_messages.h"
#include "mm/mm1/views_enh/main_menu.h"
#include "mm/mm1/views_enh/map_popup.h"
#include "mm/mm1/views_enh/protect.h"
#include "mm/mm1/views_enh/quick_ref.h"
#include "mm/mm1/views_enh/rest.h"
#include "mm/mm1/views_enh/search.h"
#include "mm/mm1/views_enh/title.h"
#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"
#include "mm/mm1/views_enh/won_game.h"
#include "mm/mm1/views_enh/interactions/access_code.h"
#include "mm/mm1/views_enh/interactions/alamar.h"
#include "mm/mm1/views_enh/interactions/alien.h"
#include "mm/mm1/views_enh/interactions/arenko.h"
#include "mm/mm1/views_enh/interactions/arrested.h"
#include "mm/mm1/views_enh/interactions/chess.h"
#include "mm/mm1/views_enh/interactions/dog_statue.h"
#include "mm/mm1/views_enh/interactions/ghost.h"
#include "mm/mm1/views_enh/interactions/giant.h"
#include "mm/mm1/views_enh/interactions/gypsy.h"
#include "mm/mm1/views_enh/interactions/hacker.h"
#include "mm/mm1/views_enh/interactions/ice_princess.h"
#include "mm/mm1/views_enh/interactions/inspectron.h"
#include "mm/mm1/views_enh/interactions/keeper.h"
#include "mm/mm1/views_enh/interactions/leprechaun.h"
#include "mm/mm1/views_enh/interactions/lion.h"
#include "mm/mm1/views_enh/interactions/lord_archer.h"
#include "mm/mm1/views_enh/interactions/lord_ironfist.h"
#include "mm/mm1/views_enh/interactions/orango.h"
#include "mm/mm1/views_enh/interactions/prisoners.h"
#include "mm/mm1/views_enh/interactions/resistances.h"
#include "mm/mm1/views_enh/interactions/ruby.h"
#include "mm/mm1/views_enh/interactions/scummvm.h"
#include "mm/mm1/views_enh/interactions/statue.h"
#include "mm/mm1/views_enh/interactions/trivia.h"
#include "mm/mm1/views_enh/interactions/volcano_god.h"
#include "mm/mm1/views_enh/locations/blacksmith_items.h"
#include "mm/mm1/views_enh/locations/blacksmith.h"
#include "mm/mm1/views_enh/locations/inn.h"
#include "mm/mm1/views_enh/locations/market.h"
#include "mm/mm1/views_enh/locations/tavern.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"
#include "mm/mm1/views_enh/spells/detect_magic.h"
#include "mm/mm1/views_enh/spells/duplication.h"
#include "mm/mm1/views_enh/spells/fly.h"
#include "mm/mm1/views_enh/spells/location.h"
#include "mm/mm1/views_enh/spells/recharge_item.h"
#include "mm/mm1/views_enh/spells/teleport.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
struct Dialogs : public ViewsBase {
private:
ViewsEnh::Interactions::AccessCode _accessCode;
ViewsEnh::Interactions::Alamar _alamar;
ViewsEnh::Interactions::Alien _alien;
ViewsEnh::Interactions::Arenko _arenko;
ViewsEnh::Interactions::Arrested _arrested;
ViewsEnh::Interactions::Chess _chess;
ViewsEnh::Interactions::DogStatue _dogStatue;
ViewsEnh::Interactions::Ghost _ghost;
ViewsEnh::Interactions::Giant _giant;
ViewsEnh::Interactions::Gypsy _gypsy;
ViewsEnh::Interactions::Hacker _hacker;
ViewsEnh::Interactions::IcePrincess _icePrincess;
ViewsEnh::Interactions::Inspectron _inspectron;
ViewsEnh::Interactions::Keeper _keeper;
ViewsEnh::Interactions::Leprechaun _leprechaun;
ViewsEnh::Interactions::Lion _lion;
ViewsEnh::Interactions::LordArcher _lordArcher;
ViewsEnh::Interactions::LordIronfist _lordIronfist;
ViewsEnh::Interactions::Orango _orango;
ViewsEnh::Interactions::Resistances _resistances;
ViewsEnh::Interactions::Ruby _ruby;
ViewsEnh::Interactions::ScummVM _scummVM;
ViewsEnh::Interactions::Statue _statue;
ViewsEnh::Interactions::Trivia _trivia;
ViewsEnh::Interactions::VolcanoGod _volcanoGod;
ViewsEnh::Interactions::ChildPrisoner _childPrisoner;
ViewsEnh::Interactions::CloakedPrisoner _cloakedPrisoner;
ViewsEnh::Interactions::DemonPrisoner _demonPrisoner;
ViewsEnh::Interactions::MaidenPrisoner _maidenPrisoner;
ViewsEnh::Interactions::ManPrisoner _manPrisoner;
ViewsEnh::Interactions::MutatedPrisoner _mutatedPrisoner;
ViewsEnh::Interactions::VirginPrisoner _virginPrisoner;
ViewsEnh::Locations::Blacksmith _blacksmith;
ViewsEnh::Locations::BlacksmithItems _blacksmithItems;
ViewsEnh::Locations::Inn _inn;
ViewsEnh::Locations::Market _market;
ViewsEnh::Locations::Tavern _tavern;
ViewsEnh::Locations::Temple _temple;
ViewsEnh::Locations::Training _training;
ViewsEnh::Spells::CastSpell _castSpell;
ViewsEnh::Spells::Spellbook _spellbook;
ViewsEnh::Spells::DetectMagic _detectMagic;
ViewsEnh::Spells::Duplication _duplicateItem;
ViewsEnh::Spells::Fly _fly;
ViewsEnh::Spells::Location _location;
ViewsEnh::Spells::RechargeItem _rechargeItem;
ViewsEnh::Spells::Teleport _teleport;
ViewsEnh::CharacterInfo _characterInfo;
ViewsEnh::CharacterInfoCombat _characterInfoCombat;
ViewsEnh::CharacterInventory _characterInventory;
ViewsEnh::CharacterSelect _characterSelect;
ViewsEnh::Characters _characters;
ViewsEnh::ColorQuestions _colorQuestions;
ViewsEnh::Combat _combat;
ViewsEnh::Confirm _confirm;
ViewsEnh::CreateCharacters _createCharacters;
ViewsEnh::Dead _dead;
ViewsEnh::Encounter _encounter;
ViewsEnh::Exchange _exchange;
ViewsEnh::Game _game;
ViewsEnh::GameMessages _gameMessages;
ViewsEnh::MainMenu _mainMenu;
ViewsEnh::MapPopup _mapPopup;
ViewsEnh::Protect _protect;
ViewsEnh::QuickRef _quickRef;
ViewsEnh::Rest _rest;
ViewsEnh::Search _search;
ViewsEnh::Title _title;
ViewsEnh::Trade _trade;
ViewsEnh::Trap _trap;
ViewsEnh::Unlock _unlock;
ViewsEnh::WheelSpin _wheelSpin;
ViewsEnh::WhichCharacter _whichCharacter;
ViewsEnh::WhichItem _whichItem;
ViewsEnh::WhoWillTry _whoWillTry;
ViewsEnh::WonGame _wonGame;
Views::Bash _bash;
public:
Dialogs() {}
~Dialogs() override {}
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,448 @@
/* 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/encounter.h"
#include "mm/mm1/views_enh/scroll_text.h"
#include "mm/mm1/game/encounter.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
Encounter::Encounter() : YesNo("Encounter") {
setDisplayArea(false);
_btnSprites.load("combat.icn");
}
bool Encounter::msgFocus(const FocusMessage &msg) {
setMode(ALERT);
return true;
}
void Encounter::setDisplayArea(bool largeArea) {
if (largeArea)
setBounds(Common::Rect(0, 0, 234, 144));
else
setBounds(Common::Rect(0, 144, 234, 200));
}
void Encounter::draw() {
Game::Encounter &enc = g_globals->_encounters;
setDisplayArea(false);
setReduced(false);
if (_mode != ALERT) {
YesNo::draw();
}
switch (_mode) {
case ALERT: {
setDisplayArea(true);
Graphics::ManagedSurface s = getSurface();
Common::Point pt((_innerBounds.left + _innerBounds.right) / 2,
(_innerBounds.top + _innerBounds.bottom) / 2);
ScrollText view("EncounterMsg", nullptr);
view.setBounds(Common::Rect(pt.x - 50, pt.y - 9, pt.x + 50, pt.y + 18));
view.draw();
writeLine(7, STRING["dialogs.encounter.title"], ALIGN_MIDDLE);
delaySeconds(2);
break;
}
case SURPRISED_BY_MONSTERS:
writeLine(0, STRING["dialogs.encounter.surprised"], ALIGN_MIDDLE);
enc._encounterType = Game::FORCE_SURPRISED;
delaySeconds(2);
break;
case SURPRISED_MONSTERS:
writeLine(0, STRING["dialogs.encounter.surprise"], ALIGN_MIDDLE);
writeLine(2, STRING["dialogs.encounter.approach"], ALIGN_MIDDLE);
break;
case ENCOUNTER_OPTIONS: {
// Write the encounter options
setReduced(false);
writeString(0, 5, STRING["enhdialogs.encounter.options"]);
setReduced(true);
writeString(88, 5, STRING["enhdialogs.encounter.attack"]);
writeString(164, 5, STRING["enhdialogs.encounter.retreat"]);
writeString(88, 25, STRING["enhdialogs.encounter.bribe"]);
writeString(164, 25, STRING["enhdialogs.encounter.surrender"]);
break;
}
case NOWHERE_TO_RUN:
writeLine(0, STRING["dialogs.encounter.nowhere_to_run"], ALIGN_MIDDLE);
delaySeconds(2);
break;
case SURROUNDED:
writeLine(0, STRING["dialogs.encounter.surround"], ALIGN_MIDDLE);
delaySeconds(2);
break;
case SURRENDER_FAILED:
writeLine(0, STRING["dialogs.encounter.surrender_failed"], ALIGN_MIDDLE);
delaySeconds(2);
break;
case NO_RESPONSE:
writeLine(0, STRING["dialogs.encounter.no_response"], ALIGN_MIDDLE);
delaySeconds(2);
break;
case BRIBE:
enc._bribeFleeCtr++;
enc._bribeAlignmentCtr++;
writeLine(0, Common::String::format(
STRING["dialogs.encounter.give_up"].c_str(),
_bribeTypeStr.c_str()), ALIGN_MIDDLE);
break;
case NOT_ENOUGH:
writeLine(0, STRING["dialogs.encounter.not_enough"], ALIGN_MIDDLE);
delaySeconds(2);
break;
case COMBAT:
writeLine(0, STRING["dialogs.encounter.combat"], ALIGN_MIDDLE);
delaySeconds(2);
break;
default:
break;
}
if (_mode != ALERT) {
// Display the monster
setDisplayArea(true);
drawGraphic(enc._monsterImgNum);
// Write the monster list
// Draw an empty scroll for the background
ScrollText view("MonstersList", nullptr);
view.setBounds(Common::Rect(168, 10, 310, 140));
view.draw();
setReduced(true);
setBounds(Common::Rect(168, 10, 310, 140));
for (uint i = 0; i < enc._monsterList.size(); ++i) {
writeString(12, i * 8,
Common::String::format("%c)", 'A' + i), ALIGN_RIGHT);
writeString(18, i * 8, enc._monsterList[i]._name.c_str());
}
}
if (_mode == NO_RESPONSE || _mode == SURROUNDED ||
_mode == NOT_ENOUGH || _mode == COMBAT ||
_mode == NOWHERE_TO_RUN || _mode == SURRENDER_FAILED ||
_mode == SURPRISED_BY_MONSTERS) {
if (enc._alignmentsChanged) {
setDisplayArea(false);
writeLine(3, STRING["dialogs.encounter.alignment_slips"], ALIGN_MIDDLE);
Sound::sound(SOUND_2);
}
setMode(BATTLE);
}
setDisplayArea(false);
}
void Encounter::timeout() {
const Game::Encounter &enc = g_globals->_encounters;
const Maps::Map &map = *g_maps->_currentMap;
switch (_mode) {
case ALERT:
// Finished displaying initial encounter alert
if (enc._encounterType == Game::FORCE_SURPRISED) {
setMode(SURPRISED_BY_MONSTERS);
} else if (enc._encounterType == Game::NORMAL_SURPRISED ||
/* ENCOUNTER_OPTIONS */
g_engine->getRandomNumber(100) > map[Maps::MAP_21]) {
// Potentially surprised. Check for guard dog spell
if (g_globals->_activeSpells._s.guard_dog ||
g_engine->getRandomNumber(100) > map[Maps::MAP_20])
setMode(ENCOUNTER_OPTIONS);
else
setMode(SURPRISED_BY_MONSTERS);
} else {
setMode(SURPRISED_MONSTERS);
}
break;
case BATTLE:
// Switch to combat view
close();
send("Combat", GameMessage("COMBAT"));
break;
default:
break;
}
redraw();
}
bool Encounter::msgKeypress(const KeypressMessage &msg) {
const Maps::Map &map = *g_maps->_currentMap;
switch (_mode) {
case SURPRISED_MONSTERS:
if (msg.keycode == Common::KEYCODE_y) {
setMode(ENCOUNTER_OPTIONS);
redraw();
} else if (msg.keycode == Common::KEYCODE_n) {
encounterEnded();
}
break;
case ENCOUNTER_OPTIONS:
switch (msg.keycode) {
case Common::KEYCODE_a:
attack();
break;
case Common::KEYCODE_b:
bribe();
break;
case Common::KEYCODE_r:
retreat();
break;
case Common::KEYCODE_s:
surrender();
break;
default:
break;
}
break;
case BRIBE:
if (msg.keycode == Common::KEYCODE_y) {
if (getRandomNumber(100) > map[Maps::MAP_BRIBE_THRESHOLD]) {
setMode(NOT_ENOUGH);
redraw();
} else {
switch (_bribeType) {
case BRIBE_GOLD:
g_globals->_party.clearPartyGold();
break;
case BRIBE_GEMS:
g_globals->_party.clearPartyGems();
break;
case BRIBE_FOOD:
g_globals->_party.clearPartyFood();
break;
}
encounterEnded();
}
} else if (msg.keycode == Common::KEYCODE_n) {
setMode(ENCOUNTER_OPTIONS);
redraw();
}
break;
default:
break;
}
return true;
}
void Encounter::encounterEnded() {
close();
g_events->send("Game", GameMessage("UPDATE"));
}
void Encounter::attack() {
const Game::Encounter &enc = g_globals->_encounters;
if (!enc.checkSurroundParty() || !enc.checkSurroundParty() ||
!enc.checkSurroundParty()) {
increaseAlignments();
}
setMode(COMBAT);
redraw();
}
void Encounter::bribe() {
const Game::Encounter &enc = g_globals->_encounters;
if (enc.checkSurroundParty()) {
if (!enc._bribeAlignmentCtr)
decreaseAlignments();
setMode(NO_RESPONSE);
redraw();
} else if (getRandomNumber(7) == 5 && !enc._bribeFleeCtr) {
// Rare chance to abort combat immediately
encounterEnded();
} else {
setMode(BRIBE);
int val = getRandomNumber(100);
if (val < 6) {
_bribeType = BRIBE_GEMS;
_bribeTypeStr = STRING["dialogs.encounter.gems"];
} else if (val < 16) {
_bribeType = BRIBE_FOOD;
_bribeTypeStr = STRING["dialogs.encounter.food"];
} else {
_bribeType = BRIBE_GOLD;
_bribeTypeStr = STRING["dialogs.encounter.gold"];
}
redraw();
}
}
void Encounter::retreat() {
const Maps::Map &map = *g_maps->_currentMap;
const Game::Encounter &enc = g_globals->_encounters;
int val = getRandomNumber(110);
if (val >= 100) {
// 9% chance of simply fleeing
flee();
} else if (val > map[Maps::MAP_FLEE_THRESHOLD]) {
// Nowhere to run depending on the map
setMode(NOWHERE_TO_RUN);
redraw();
} else if (enc._monsterList.size() < g_globals->_party.size() || !enc.checkSurroundParty()) {
// Only allow fleeing if the number of monsters
// are less than the size of the party
flee();
} else {
setMode(SURROUNDED);
redraw();
}
}
void Encounter::surrender() {
const Game::Encounter &enc = g_globals->_encounters;
const Maps::Map &map = *g_maps->_currentMap;
if (getRandomNumber(100) > map[Maps::MAP_SURRENDER_THRESHOLD] ||
getRandomNumber(100) > enc._fleeThreshold) {
setMode(SURRENDER_FAILED);
redraw();
} else {
g_maps->_mapPos.x = map[Maps::MAP_SURRENDER_X];
g_maps->_mapPos.y = map[Maps::MAP_SURRENDER_Y];
g_maps->visitedTile();
// Randomly remove food, gems, or gold from the party
int val = getRandomNumber(200);
if (val < 51) {
} else if (val < 151) {
g_globals->_party.clearPartyGold();
} else if (val < 161) {
g_globals->_party.clearPartyGems();
} else if (val < 171) {
g_globals->_party.clearPartyFood();
} else if (val < 191) {
g_globals->_party.clearPartyFood();
g_globals->_party.clearPartyGold();
} else if (val < 200) {
g_globals->_party.clearPartyGold();
g_globals->_party.clearPartyGems();
} else {
g_globals->_party.clearPartyGems();
g_globals->_party.clearPartyFood();
g_globals->_party.clearPartyGold();
}
encounterEnded();
}
}
void Encounter::flee() {
const Maps::Map &map = *g_maps->_currentMap;
g_maps->_mapPos.x = map[Maps::MAP_FLEE_X];
g_maps->_mapPos.y = map[Maps::MAP_FLEE_Y];
encounterEnded();
}
void Encounter::decreaseAlignments() {
Game::Encounter &enc = g_globals->_encounters;
for (uint i = 0; i < g_globals->_party.size(); ++i) {
Character &c = g_globals->_party[i];
g_globals->_currCharacter = &c;
if (c._alignmentCtr) {
--c._alignmentCtr;
if (c._alignmentCtr == 0)
enc.changeCharAlignment(GOOD);
else if (c._alignmentCtr == 16)
enc.changeCharAlignment(NEUTRAL);
}
}
}
void Encounter::increaseAlignments() {
Game::Encounter &enc = g_globals->_encounters;
for (uint i = 0; i < g_globals->_party.size(); ++i) {
Character &c = g_globals->_party[i];
g_globals->_currCharacter = &c;
if (c._alignmentCtr != 32) {
++c._alignmentCtr;
if (c._alignmentCtr == 32)
enc.changeCharAlignment(EVIL);
else if (c._alignmentCtr == 16)
enc.changeCharAlignment(NEUTRAL);
}
}
}
void Encounter::setMode(Mode newMode) {
if (_mode == SURPRISED_MONSTERS || _mode == BRIBE)
closeYesNo();
_mode = newMode;
if (_mode == SURPRISED_MONSTERS || _mode == BRIBE)
openYesNo();
clearButtons();
if (_mode == ENCOUNTER_OPTIONS) {
addButton(&_btnSprites, Common::Point(60, 0), 0, Common::KEYCODE_a);
addButton(&_btnSprites, Common::Point(136, 0), 8, Common::KEYCODE_r);
addButton(&_btnSprites, Common::Point(60, 20), 2, Common::KEYCODE_b);
addButton(&_btnSprites, Common::Point(136, 20), 12, Common::KEYCODE_s);
}
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,128 @@
/* 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_ENCOUNTER_H
#define MM1_VIEWS_ENH_ENCOUNTER_H
#include "mm/mm1/views_enh/yes_no.h"
#include "mm/shared/xeen/sprites.h"
#include "mm/mm1/events.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class Encounter : public YesNo {
private:
enum Mode {
ALERT, SURPRISED_BY_MONSTERS, SURPRISED_MONSTERS,
ENCOUNTER_OPTIONS, NOWHERE_TO_RUN, SURROUNDED,
SURRENDER_FAILED, NO_RESPONSE, BRIBE, NOT_ENOUGH,
COMBAT, BATTLE
};
Mode _mode = ALERT;
enum BribeType { BRIBE_GOLD, BRIBE_GEMS, BRIBE_FOOD };
BribeType _bribeType = BRIBE_GOLD;
Common::String _bribeTypeStr;
Shared::Xeen::SpriteResource _btnSprites;
/**
* Set display mode
*/
void setMode(Mode newMode);
/**
* Sets the display area
*/
void setDisplayArea(bool largeArea);
/**
* Handles the end of the encounter
*/
void encounterEnded();
/**
* Initiates the combat
*/
void attack();
/**
* Try and bribe the enemies
*/
void bribe();
/**
* Try and retreat
*/
void retreat();
/**
* Try and surrender
*/
void surrender();
/**
* Ends an encounter
*/
void flee();
/**
* Decreases the alignment counter, gradually turning
* EVIL to NEUTRAL to GOOD
*/
void decreaseAlignments();
/**
* Increases the alignment counter, gradually turning
* GOOD to NEUTRAL to EVIL
*/
void increaseAlignments();
public:
Encounter();
virtual ~Encounter() {}
/**
* Called when the view is focused
*/
bool msgFocus(const FocusMessage &msg) override;
/**
* Draw the encounter details overlayed on
* the existing game screen
*/
void draw() override;
/**
* Handles delay timeouts
*/
void timeout() override;
/**
* Handles keypresses
*/
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,72 @@
/* 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/exchange.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
Exchange::Exchange() : PartyView("Exchange") {
_bounds = Common::Rect(50, 112, 266, 148);
addButton(&g_globals->_escSprites, Common::Point(165, 0), 0, KEYBIND_ESCAPE);
}
bool Exchange::msgFocus(const FocusMessage &msg) {
PartyView::msgFocus(msg);
_srcCharacter = g_globals->_party.indexOf(g_globals->_currCharacter);
assert(_srcCharacter != -1);
return true;
}
void Exchange::draw() {
PartyView::draw();
writeString(10, 5, STRING["enhdialogs.exchange"]);
}
bool Exchange::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
return true;
}
return PartyView::msgAction(msg);
}
void Exchange::charSwitched(Character *priorChar) {
PartyView::charSwitched(priorChar);
int charNum = g_globals->_party.indexOf(g_globals->_currCharacter);
if (charNum != _srcCharacter) {
// Swap the two characters
SWAP(g_globals->_party[charNum], g_globals->_party[_srcCharacter]);
}
close();
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,54 @@
/* 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_EXCHANGE_H
#define MM1_VIEWS_ENH_EXCHANGE_H
#include "mm/mm1/views_enh/party_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class Exchange : public PartyView {
private:
int _srcCharacter = -1;
protected:
/**
* Called when the selected character has been switched
*/
void charSwitched(Character *priorChar) override;
public:
Exchange();
virtual ~Exchange() {}
bool msgFocus(const FocusMessage &msg) override;
void draw() override;
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,125 @@
/* 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 "common/file.h"
#include "mm/mm1/views_enh/game.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/metaengine.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
Game::Game() : TextView("Game"),
_view(this),
_commands(this),
_party(this) {
_view.setBounds(Common::Rect(8, 15, 224, 130));
}
bool Game::msgFocus(const FocusMessage &msg) {
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_NORMAL);
return TextView::msgFocus(msg);
}
bool Game::msgUnfocus(const UnfocusMessage &msg) {
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
return true;
}
void Game::draw() {
Graphics::ManagedSurface s = getSurface();
s.blitFrom(g_globals->_gameBackground);
UIElement::draw();
}
bool Game::msgKeypress(const KeypressMessage &msg) {
switch (msg.keycode) {
case Common::KEYCODE_F5:
if (g_engine->canSaveGameStateCurrently())
g_engine->saveGameDialog();
break;
case Common::KEYCODE_F7:
if (g_engine->canLoadGameStateCurrently())
g_engine->loadGameDialog();
break;
default:
break;
}
return true;
}
bool Game::msgAction(const ActionMessage &msg) {
switch (msg._action) {
case KEYBIND_BASH:
send("Bash", GameMessage("SHOW"));
break;
case KEYBIND_MAP:
if (g_maps->_currentMap->mappingAllowed())
addView("MapPopup");
else
send(InfoMessage(STRING["enhdialogs.map.disabled"]));
return true;
case KEYBIND_MENU:
g_engine->openMainMenuDialog();
return true;
case KEYBIND_PROTECT:
addView("Protect");
return true;
case KEYBIND_QUICKREF:
addView("QuickRef");
return true;
case KEYBIND_REST:
addView("Rest");
return true;
case KEYBIND_SEARCH:
send("Search", GameMessage("SHOW"));
break;
case KEYBIND_SPELL:
addView("CastSpell");
return true;
case KEYBIND_UNLOCK:
send("Unlock", GameMessage("SHOW"));
break;
//case KEYBIND_ORDER:
// Enhanced mode uses Exchange button from Char Info view
default:
break;
}
return TextView::msgAction(msg);
}
bool Game::msgGame(const GameMessage &msg) {
if (msg._name == "DISPLAY") {
replaceView(this);
return true;
}
return TextView::msgGame(msg);
}
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,57 @@
/* 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_GAME_H
#define MM1_VIEWS_ENH_GAME_H
#include "graphics/managed_surface.h"
#include "mm/mm1/events.h"
#include "mm/mm1/views_enh/game_view.h"
#include "mm/mm1/views_enh/game_commands.h"
#include "mm/mm1/views_enh/game_messages.h"
#include "mm/mm1/views_enh/game_party.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class Game : public Views::TextView {
private:
ViewsEnh::GameView _view;
GameCommands _commands;
GameParty _party;
public:
Game();
virtual ~Game() {}
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;
bool msgGame(const GameMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,81 @@
/* 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/game_commands.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
GameCommands::GameCommands(UIElement *owner) :
ButtonContainer("GameCommands", owner),
_minimap(this) {
Shared::Xeen::SpriteResource *spr = &g_globals->_mainIcons;
_iconSprites.load("cast.icn");
addButton(Common::Rect(235, 75, 259, 95), KEYBIND_SPELL, 2, spr);
addButton(Common::Rect(260, 75, 284, 95), KEYBIND_PROTECT, 10, spr);
addButton(Common::Rect(286, 75, 310, 95), KEYBIND_REST, 4, spr);
addButton(Common::Rect(235, 96, 259, 116), KEYBIND_BASH, 6, spr);
addButton(Common::Rect(260, 96, 284, 116), KEYBIND_SEARCH, 2, &_iconSprites);
addButton(Common::Rect(286, 96, 310, 116), KEYBIND_UNLOCK, 14, spr);
addButton(Common::Rect(235, 117, 259, 137), KEYBIND_MAP, 12, spr);
addButton(Common::Rect(260, 117, 284, 137), KEYBIND_QUICKREF, 16, spr);
addButton(Common::Rect(109, 137, 122, 147), KEYBIND_MENU, 18, spr);
addButton(Common::Rect(235, 148, 259, 168), KEYBIND_TURN_LEFT, 20, spr);
addButton(Common::Rect(260, 148, 284, 168), KEYBIND_FORWARDS, 22, spr);
addButton(Common::Rect(286, 148, 310, 168), KEYBIND_TURN_RIGHT, 24, spr);
addButton(Common::Rect(235, 169, 259, 189), KEYBIND_STRAFE_LEFT, 26, spr);
addButton(Common::Rect(260, 169, 284, 189), KEYBIND_BACKWARDS, 28, spr);
addButton(Common::Rect(286, 169, 310, 189), KEYBIND_STRAFE_RIGHT, 30, spr);
addButton(_minimap.getBounds(), KEYBIND_MINIMAP);
}
bool GameCommands::msgAction(const ActionMessage & msg) {
switch (msg._action) {
case KEYBIND_MINIMAP:
_minimap.toggleMinimap();
return true;
default:
// Other button actions are handled by outer Game view
break;
}
return false;
}
void GameCommands::Minimap::toggleMinimap() {
g_globals->_minimapOn = !g_globals->_minimapOn;
}
void GameCommands::Minimap::draw() {
if (g_globals->_minimapOn && g_maps->_currentMap->mappingAllowed())
Map::draw();
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,58 @@
/* 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_GAME_COMMANDS_H
#define MM1_VIEWS_ENH_GAME_COMMANDS_H
#include "mm/mm1/views_enh/button_container.h"
#include "mm/mm1/views_enh/map.h"
#include "mm/shared/xeen/sprites.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class GameCommands : public ButtonContainer {
class Minimap : public Map {
public:
Minimap(UIElement *owner) : Map(owner) {
_bounds = Common::Rect(236, 11, 308, 69);
}
void toggleMinimap();
void draw() override;
};
private:
Minimap _minimap;
Shared::Xeen::SpriteResource _iconSprites;
public:
GameCommands(UIElement *owner);
virtual ~GameCommands() {}
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,179 @@
/* 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 "common/util.h"
#include "mm/shared/utils/strings.h"
#include "mm/mm1/views_enh/game_messages.h"
#include "mm/mm1/events.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
GameMessages::YesNo::YesNo() :
ScrollView("MessagesYesNo", g_events) {
_bounds = Common::Rect(234, 144, 320, 200);
addButton(&g_globals->_confirmIcons, Common::Point(0, 0), 0,
Common::KeyState(Common::KEYCODE_y, 'y'));
addButton(&g_globals->_confirmIcons, Common::Point(26, 0), 2,
Common::KeyState(Common::KEYCODE_n, 'n'));
}
bool GameMessages::YesNo::msgKeypress(const KeypressMessage &msg) {
// Pass on any Y/N button presses to the messages area
return send("GameMessages", msg);
}
/*------------------------------------------------------------------------*/
GameMessages::GameMessages() : ScrollText("GameMessages") {
setBounds(Common::Rect(0, 144, 234, 200));
}
void GameMessages::draw() {
ScrollText::draw();
if (_callback && !isDelayActive()) {
_yesNo.resetSelectedButton();
_yesNo.draw();
}
}
bool GameMessages::msgFocus(const FocusMessage &msg) {
MetaEngine::setKeybindingMode(_callback || _keyCallback ?
KeybindingMode::KBMODE_MENUS :
KeybindingMode::KBMODE_NORMAL);
return true;
}
bool GameMessages::msgInfo(const InfoMessage &msg) {
// Do a first draw to show 3d view at new position
g_events->redraw();
g_events->draw();
_callback = msg._callback;
_nCallback = msg._nCallback;
_keyCallback = msg._keyCallback;
_fontReduced = msg._fontReduced;
// Add the view
addView(this);
if (msg._largeMessage)
setBounds(Common::Rect(0, 90, 234, 200));
else
setBounds(Common::Rect(0, 144, 234, 200));
// Process the lines
clear();
for (const auto &line : msg._lines)
addText(line._text, -1, 0, (line.x > 0) ? ALIGN_MIDDLE : line._align, 0);
if (msg._delaySeconds)
delaySeconds(msg._delaySeconds);
return true;
}
bool GameMessages::msgKeypress(const KeypressMessage &msg) {
if (_keyCallback) {
_keyCallback(msg);
} else if (_callback) {
if (msg.keycode == Common::KEYCODE_n) {
close();
if (_nCallback)
_nCallback();
} else if (msg.keycode == Common::KEYCODE_y) {
close();
_callback();
}
} else {
// Displayed message, any keypress closes the window
// and passes control to the game
close();
if (msg.keycode != Common::KEYCODE_SPACE)
send("Game", msg);
}
return true;
}
bool GameMessages::msgAction(const ActionMessage &msg) {
if (_callback || _keyCallback) {
switch (msg._action) {
case KEYBIND_ESCAPE:
if (_keyCallback) {
_keyCallback(Common::KeyState(Common::KEYCODE_ESCAPE));
} else {
close();
if (_nCallback)
_nCallback();
}
return true;
case KEYBIND_SELECT:
if (_keyCallback) {
_keyCallback(Common::KeyState(Common::KEYCODE_RETURN));
} else {
close();
_callback();
}
return true;
default:
break;
}
} else {
// Single turn message display
close();
if (msg._action != KEYBIND_SELECT)
return send("Game", msg);
}
return false;
}
bool GameMessages::msgMouseDown(const MouseDownMessage &msg) {
// If yes/no prompting, also pass events to buttons view
if (_callback)
return send("MessagesYesNo", msg);
return msgAction(KeybindingAction(KEYBIND_SELECT));
}
bool GameMessages::msgMouseUp(const MouseUpMessage &msg) {
// If yes/no prompting, also pass events to buttons view
if (_callback)
return send("MessagesYesNo", msg);
return false;
}
void GameMessages::timeout() {
close();
if (_callback)
_callback();
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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/>.
*
*/
#ifndef MM1_VIEWS_ENH_GAME_MESSAGES_H
#define MM1_VIEWS_ENH_GAME_MESSAGES_H
#include "mm/mm1/messages.h"
#include "mm/mm1/views_enh/scroll_text.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class GameMessages : public ScrollText {
class YesNo : public ScrollView {
public:
YesNo();
bool msgKeypress(const KeypressMessage &msg) override;
};
private:
YNCallback _callback = nullptr;
YNCallback _nCallback = nullptr;
KeyCallback _keyCallback = nullptr;
YesNo _yesNo;
public:
GameMessages();
virtual ~GameMessages() {}
void draw() override;
bool msgFocus(const FocusMessage &msg) override;
bool msgInfo(const InfoMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
bool msgMouseDown(const MouseDownMessage &msg) override;
bool msgMouseUp(const MouseUpMessage &msg) override;
void timeout() override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,164 @@
/* 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/game.h"
#include "mm/mm1/events.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#if 0
static const byte CONDITION_COLORS[17] = {
9, 9, 9, 9, 9, 9, 9, 9, 32, 32, 32, 32, 6, 6, 6, 6, 15
};
#endif
static const byte FACE_CONDITION_FRAMES[17] = {
2, 2, 2, 1, 1, 4, 4, 4, 3, 2, 4, 3, 3, 5, 6, 7, 0
};
static const byte CHAR_FACES_X[6] = { 10, 45, 81, 117, 153, 189 };
static const byte HP_BARS_X[6] = { 13, 50, 86, 122, 158, 194 };
GameParty::GameParty(UIElement *owner) : TextView("GameParty", owner),
_restoreSprites("restorex.icn"),
_hpSprites("hpbars.icn"),
_dseFace("dse.fac") {
setBounds(Common::Rect(0, 144, 234, 200));
}
void GameParty::draw() {
Graphics::ManagedSurface s = getSurface();
// Draw Xeen background
s.blitFrom(g_globals->_gameBackground, Common::Rect(0, 144, 320, 200),
Common::Point(0, 0));
_restoreSprites.draw(&s, 0, Common::Point(8, 5));
// Handle drawing the party faces
bool inCombat = g_events->isInCombat();
// Draw character frames
for (uint idx = 0; idx < g_globals->_party.size(); ++idx) {
Character &c = inCombat ? *g_globals->_combatParty[idx] : g_globals->_party[idx];
ConditionEnum charCondition = c.worstCondition();
int charFrame = FACE_CONDITION_FRAMES[charCondition];
Shared::Xeen::SpriteResource *sprites = (charFrame > 4) ? &_dseFace : &c._faceSprites;
assert(sprites);
if (charFrame > 4)
charFrame -= 5;
sprites->draw(&s, charFrame, Common::Point(CHAR_FACES_X[idx], 6));
}
for (uint idx = 0; idx < g_globals->_party.size(); ++idx) {
const Character &c = inCombat ? *g_globals->_combatParty[idx] : g_globals->_party[idx];
// Draw the Hp bar
int maxHp = c._hpMax;
int frame;
if (c._hpCurrent < 1)
frame = 4;
else if (c._hpCurrent > maxHp)
frame = 3;
else if (c._hpCurrent == maxHp)
frame = 0;
else if (c._hpCurrent < (maxHp / 4))
frame = 2;
else
frame = 1;
_hpSprites.draw(&s, frame, Common::Point(HP_BARS_X[idx], 38));
// Also draw the highlight if character is selected
if (_highlightOn && g_globals->_currCharacter == &c)
g_globals->_globalSprites.draw(&s, 8, Common::Point(CHAR_FACES_X[idx] - 1, 5));
}
// Sprite drawing doesn't automatically mark the drawn areas,
// so manually flag the entire area as dirty
s.markAllDirty();
}
bool GameParty::msgGame(const GameMessage &msg) {
if (msg._name == "CHAR_HIGHLIGHT") {
_highlightOn = msg._value != 0;
draw();
return true;
}
return false;
}
bool GameParty::msgMouseDown(const MouseDownMessage &msg) {
for (uint i = 0; i < g_globals->_party.size(); ++i) {
const Common::Rect r(CHAR_FACES_X[i], 150, CHAR_FACES_X[i] + 30, 180);
if (r.contains(msg._pos)) {
msgAction(ActionMessage((KeybindingAction)(KEYBIND_VIEW_PARTY1 + i)));
return true;
}
}
return false;
}
void GameParty::highlightChar(uint charNum) {
g_globals->_currCharacter = &g_globals->_party[charNum];
_highlightOn = true;
draw();
}
bool GameParty::msgAction(const ActionMessage &msg) {
if (msg._action >= KEYBIND_VIEW_PARTY1 &&
msg._action <= KEYBIND_VIEW_PARTY6) {
uint charNum = msg._action - KEYBIND_VIEW_PARTY1;
if (charNum < g_globals->_party.size()) {
if (dynamic_cast<ViewsEnh::Game *>(g_events->focusedView()) != nullptr) {
// Open character info dialog
highlightChar(charNum);
addView("CharacterInfo");
} else {
// Another view is focused
// Try passing the selected char to it to handle
if (!send(g_events->focusedView()->getName(), msg)) {
// Wasn't handled directly, so switch selected character,
// and try calling the given view again with an UPDATE message
highlightChar(charNum);
send(g_events->focusedView()->getName(), GameMessage("UPDATE"));
}
}
return true;
}
}
return false;
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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/>.
*
*/
#ifndef MM1_VIEWS_ENH_GAME_PARTY_H
#define MM1_VIEWS_ENH_GAME_PARTY_H
#include "mm/mm1/views_enh/text_view.h"
#include "mm/shared/xeen/sprites.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
/**
* Handles displaying the party portraits
*/
class GameParty : public TextView {
private:
Shared::Xeen::SpriteResource _restoreSprites;
Shared::Xeen::SpriteResource _hpSprites;
Shared::Xeen::SpriteResource _dseFace;
bool _highlightOn = false;
void highlightChar(uint charNum);
public:
GameParty(UIElement *owner);
virtual ~GameParty() {}
/**
* Draw the view
*/
void draw() override;
bool msgGame(const GameMessage &msg) override;
bool msgMouseDown(const MouseDownMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,214 @@
/* 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/game_view.h"
#include "mm/mm1/views_enh/scroll_text.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define TICKS_PER_FRAME 4
namespace Animations {
ViewAnimation::ViewAnimation(const char *prefix, uint count, uint frameCount) :
_sound(*g_engine->_sound), _frameCount(frameCount) {
_backgrounds.resize(count);
for (uint i = 0; i < _backgrounds.size(); ++i) {
Common::Path 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));
}
void ViewAnimation::leave() {
_sound.stopSound();
_sound.stopSong();
}
/*------------------------------------------------------------------------*/
class Blacksmith : public ViewAnimation {
public:
Blacksmith() : ViewAnimation("blck", 2, 13) {
}
~Blacksmith() override {
}
void enter() override {
_sound.playVoice("whaddayo.voc");
_sound.playSong("smith.m");
}
};
class Market : public ViewAnimation {
public:
Market() : ViewAnimation("gild", 4, 32) {}
~Market() override {}
void enter() override {
_sound.playVoice("hello.voc");
_sound.playSong("guild.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");
}
};
class Temple : public ViewAnimation {
public:
Temple() : ViewAnimation("tmpl", 4, 26) {
}
~Temple() override {
}
void enter() override {
_sound.playVoice("maywe2.voc");
_sound.playSong("temple.m");
}
};
class Training : public ViewAnimation {
public:
Training() : ViewAnimation("trng", 2, 16) {
}
~Training() override {
}
void enter() override {
_sound.playVoice("training.voc");
_sound.playSong("grounds.m");
}
};
} // namespace Animations
/*------------------------------------------------------------------------*/
bool GameView::msgGame(const GameMessage &msg) {
if (msg._name == "LOCATION") {
showLocation(msg._value);
} else if (msg._name == "LOCATION_DRAW") {
UIElement *view = g_events->findView("Game");
view->draw();
} else {
return Views::GameView::msgGame(msg);
}
return true;
}
void GameView::showLocation(int locationId) {
if (locationId == -1) {
_anim->leave();
delete _anim;
_anim = nullptr;
} else {
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 (_anim == nullptr) {
Views::GameView::draw();
} else {
Graphics::ManagedSurface s = getSurface();
_anim->draw(s);
}
}
bool GameView::tick() {
if (_anim != nullptr) {
if (++_timerCtr >= TICKS_PER_FRAME) {
_timerCtr = 0;
_anim->tick();
}
redraw();
}
return true;
}
void GameView::drawDialogMessage() {
Common::String msg = _dialogMessage;
msg.trim();
msg.setChar(toupper(msg[0]), 0); // Capitalize
ScrollText view("GameViewMessage", nullptr);
view.setBounds(Common::Rect(9 * 8, 8 * 8, 23 * 8, 11 * 8));
view.addLine(msg, MM1::ALIGN_MIDDLE);
view.draw();
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,85 @@
/* 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_GAME_VIEW_H
#define MM1_VIEWS_ENH_GAME_VIEW_H
#include "mm/mm1/views/game_view.h"
#include "mm/shared/xeen/sprites.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Animations {
class ViewAnimation {
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() {}
virtual void enter() {}
void tick();
void draw(Graphics::ManagedSurface &s);
virtual void leave();
};
} // namespace Animations
class GameView : public Views::GameView {
private:
Animations::ViewAnimation *_anim = nullptr;
uint _timerCtr = 0;
/**
* Start location animation
*/
void showLocation(int locationId);
protected:
/**
* Draws the dialog message
*/
void drawDialogMessage() override;
public:
GameView(UIElement *owner) : Views::GameView(owner) {}
virtual ~GameView() {
delete _anim;
}
void draw() override;
bool msgGame(const GameMessage &msg) override;
bool tick() override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,44 @@
/* 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/interactions/access_code.h"
#include "mm/mm1/maps/map08.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
AccessCode::AccessCode() : InteractionQuery("AccessCode", 8) {
_title = STRING["maps.emap08.access_code"];
addText(STRING["maps.map08.enter_code"]);
}
void AccessCode::answerEntered() {
MM1::Maps::Map08 &map = *static_cast<MM1::Maps::Map08 *>(g_maps->_currentMap);
map.codeEntered(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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_INTERACTIONS_ACCESS_CODE_H
#define MM1_VIEWS_ENH_INTERACTIONS_ACCESS_CODE_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class AccessCode : public InteractionQuery {
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
AccessCode();
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#include "mm/mm1/views_enh/interactions/alamar.h"
#include "mm/mm1/maps/map49.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
#define VAL1 952
#define HAS_EYE 154
Alamar::Alamar() : Interaction("Alamar", 22) {
}
bool Alamar::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
clearButtons();
MM1::Maps::Map49 &map = *static_cast<MM1::Maps::Map49 *>(g_maps->_currentMap);
_succeeded = false;
for (uint i = 0; i < g_globals->_party.size() && !_succeeded; ++i)
_succeeded = (g_globals->_party[i]._flags[13] & CHARFLAG13_ALAMAR) != 0;
map[HAS_EYE] = g_globals->_party.hasItem(EYE_OF_GOROS_ID) ? 1 : 0;
if (!_succeeded && !map[HAS_EYE]) {
for (uint i = 0; i < g_globals->_party.size() && !_succeeded; ++i)
g_globals->_party[i]._quest = 255;
}
_title = STRING["maps.emap49.king_alamar"];
if (_succeeded) {
addText(Common::String::format("%s%s",
STRING["maps.map49.alamar1"].c_str(),
STRING["maps.map49.alamar3"].c_str()
));
} else if (map[HAS_EYE]) {
_title = STRING["maps.emap49.sheltem"];
addText(Common::String::format("%s%s",
STRING["maps.map49.alamar1"].c_str(),
STRING["maps.map49.alamar4"].c_str()
));
for (int i = 0; i < 6; ++i)
Sound::sound(SOUND_2);
} else {
addText(Common::String::format("%s%s",
STRING["maps.map49.alamar1"].c_str(),
STRING["maps.map49.alamar2"].c_str()
));
}
return true;
}
void Alamar::viewAction() {
MM1::Maps::Map49 &map = *static_cast<MM1::Maps::Map49 *>(g_maps->_currentMap);
close();
if (map[HAS_EYE]) {
map[VAL1]++;
map.updateGame();
} else {
g_maps->_mapPos.x = 8;
map.updateGame();
}
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,52 @@
/* 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_INTERACTIONS_ALAMAR_H
#define MM1_VIEWS_ENH_INTERACTIONS_ALAMAR_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Alamar : public Interaction {
private:
bool _succeeded = false;
protected:
void viewAction() override;
public:
Alamar();
virtual ~Alamar() {}
bool msgFocus(const FocusMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,67 @@
/* 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/interactions/alien.h"
#include "mm/mm1/maps/map31.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Alien::Alien() : Interaction("Alien", 37) {
_title = STRING["maps.emap31.alien_title"];
addText(STRING["maps.emap31.alien"]);
addButton(STRING["maps.emap31.option_a"], 'A');
addButton(STRING["maps.emap31.option_b"], 'B');
addButton(STRING["maps.emap31.option_c"], 'C');
}
bool Alien::msgKeypress(const KeypressMessage &msg) {
MM1::Maps::Map31 &map = *static_cast<MM1::Maps::Map31 *>(
g_maps->_currentMap);
switch (msg.keycode) {
case Common::KEYCODE_a:
close();
map.hostile();
break;
case Common::KEYCODE_b:
close();
map.neutral();
break;
case Common::KEYCODE_c:
close();
map.friendly();
break;
default:
break;
}
return true;
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,44 @@
/* 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_INTERACTIONS_ALIEN_H
#define MM1_VIEWS_ENH_INTERACTIONS_ALIEN_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Alien : public Interaction {
public:
Alien();
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -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/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<Maps::Map28 *>(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

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#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

View File

@@ -0,0 +1,82 @@
/* 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/interactions/arrested.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Arrested::Arrested() : Interaction("Arrested", 26), Game::Arrested() {
_title = STRING["maps.emap04.town_guards"];
}
bool Arrested::msgFocus(const FocusMessage &msg) {
addText(STRING["maps.emap04.guards"]);
clearButtons();
addButton(STRING["maps.emap04.attack"], 'A');
addButton(STRING["maps.emap04.bribe"], 'B');
addButton(STRING["maps.emap04.run"], 'R');
addButton(STRING["maps.emap04.surrender"], 'S');
return true;
}
bool Arrested::msgKeypress(const KeypressMessage &msg) {
switch (msg.keycode) {
case Common::KEYCODE_a:
attack();
break;
case Common::KEYCODE_b:
bribe();
break;
case Common::KEYCODE_r:
run();
break;
case Common::KEYCODE_s:
surrender();
break;
default:
return Interaction::msgKeypress(msg);
}
return true;
}
void Arrested::surrender(int numYears) {
Game::Arrested::surrender(numYears);
// Display sentence
Common::String str = Common::String::format(
STRING["maps.emap04.sentence"].c_str(), numYears);
SoundMessage msg(str);
msg._delaySeconds = 3;
send(msg);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,53 @@
/* 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_INTERACTIONS_ARRESTED_H
#define MM1_VIEWS_ENH_INTERACTIONS_ARRESTED_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/game/arrested.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Arrested : public Interaction, public MM1::Game::Arrested {
protected:
void surrender(int numYears = 2);
public:
Arrested();
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,44 @@
/* 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/interactions/chess.h"
#include "mm/mm1/maps/map29.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Chess::Chess() : InteractionQuery("Chess", 23, 13) {
_title = STRING["maps.emap29.og_title"];
addText(STRING["maps.map29.og"]);
}
void Chess::answerEntered() {
MM1::Maps::Map29 &map = *static_cast<MM1::Maps::Map29 *>(g_maps->_currentMap);
map.chessAnswer(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,49 @@
/* 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_INTERACTIONS_CHESS_H
#define MM1_VIEWS_ENH_INTERACTIONS_CHESS_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Chess : public InteractionQuery {
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
Chess();
virtual ~Chess() {}
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -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/views_enh/interactions/dog_statue.h"
#include "mm/mm1/maps/map42.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
DogStatue::DogStatue() : Interaction("DogStatue") {
_title = STRING["maps.emap42.title"];
}
bool DogStatue::msgFocus(const FocusMessage &msg) {
Sound::sound(SOUND_2);
_completedQuests = false;
for (uint i = 0; i < g_globals->_party.size(); ++i) {
if ((g_globals->_party[i]._flags[0] &
(CHARFLAG0_COURIER3 | CHARFLAG0_FOUND_CHEST | CHARFLAG0_40)) ==
(CHARFLAG0_COURIER3 | CHARFLAG0_FOUND_CHEST | CHARFLAG0_40)) {
_completedQuests = true;
break;
}
}
clearButtons();
if (_completedQuests) {
addText(Common::String::format("%s%s",
STRING["maps.map42.statue1"].c_str(),
STRING["maps.map42.statue2"].c_str()
));
} else {
addText(Common::String::format("%s%s",
STRING["maps.map42.statue1"].c_str(),
STRING["maps.map42.statue3"].c_str()
));
addButton(STRING["maps.yes"], 'Y');
addButton(STRING["maps.no"], 'N');
}
return TextView::msgFocus(msg);
}
bool DogStatue::msgKeypress(const KeypressMessage &msg) {
MM1::Maps::Map42 &map = *static_cast<MM1::Maps::Map42 *>(g_maps->_currentMap);
if (_completedQuests) {
close();
map.dogSuccess();
} else if (msg.keycode == Common::KEYCODE_y || msg.keycode == Common::KEYCODE_n) {
close();
if (msg.keycode == Common::KEYCODE_y)
map.dogDesecrate();
}
return true;
}
void DogStatue::viewAction() {
MM1::Maps::Map42 &map = *static_cast<MM1::Maps::Map42 *>(g_maps->_currentMap);
close();
if (_completedQuests)
map.dogSuccess();
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,54 @@
/* 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_INTERACTIONS_DOG_STATUE_H
#define MM1_VIEWS_ENH_INTERACTIONS_DOG_STATUE_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class DogStatue : public Interaction {
private:
bool _completedQuests = false;
protected:
/**
* Handles any action/press
*/
void viewAction() override;
public:
DogStatue();
virtual ~DogStatue() {}
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,78 @@
/* 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/interactions/ghost.h"
#include "mm/mm1/maps/map37.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Ghost::Ghost() : Interaction("Ghost", 33) {
_title = STRING["maps.emap37.okrim"];
}
bool Ghost::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
addText(STRING["maps.map37.okrim1"]);
clearButtons();
addButton(STRING["maps.accept"], 'Y');
addButton(STRING["maps.decline"], 'N');
return true;
}
bool Ghost::msgKeypress(const KeypressMessage &msg) {
if (!_buttons.empty()) {
MM1::Maps::Map37 &map = *static_cast<MM1::Maps::Map37 *>(g_maps->_currentMap);
if (msg.keycode == Common::KEYCODE_y) {
g_globals->_party[0]._condition = ERADICATED;
close();
return true;
} else if (msg.keycode == Common::KEYCODE_n) {
map[MM1::Maps::MAP_29] = 32;
map[MM1::Maps::MAP_47] = 8;
addText(STRING["maps.map37.okrim2"]);
clearButtons();
return true;
}
}
return true;
}
void Ghost::viewAction() {
if (_buttons.empty()) {
close();
}
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,58 @@
/* 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_INTERACTIONS_GHOST_H
#define MM1_VIEWS_ENH_INTERACTIONS_GHOST_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Ghost : public Interaction {
protected:
/**
* Handles any action/press
*/
void viewAction() override;
public:
Ghost();
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
/**
* Handle keypresses
*/
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,68 @@
/* 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/interactions/giant.h"
#include "mm/mm1/maps/map30.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Giant::Giant() : Interaction("Giant", 8) {
_title = STRING["maps.emap30.giant_title"];
_animated = false;
}
bool Giant::msgFocus(const FocusMessage &msg) {
PartyView::msgFocus(msg);
_charSelected = false;
addText(STRING["maps.map30.giant"]);
return true;
}
void Giant::charSwitched(Character *priorChar) {
Interaction::charSwitched(priorChar);
if (_charSelected)
return;
_charSelected = true;
MM1::Maps::Map30 &map = *static_cast<MM1::Maps::Map30 *>(g_maps->_currentMap);
Common::String line = map.worthiness();
addText(line);
Sound::sound(SOUND_2);
delaySeconds(5);
redraw();
}
void Giant::timeout() {
close();
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,65 @@
/* 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_INTERACTIONS_GIANT_H
#define MM1_VIEWS_ENH_INTERACTIONS_GIANT_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Giant : public Interaction {
private:
bool _charSelected = false;
protected:
/**
* Called when the selected character has been switched
*/
void charSwitched(Character *priorChar) override;
/**
* Only allow a character to be selected once
*/
bool canSwitchToChar(Character *dst) override {
return !_charSelected;
}
public:
Giant();
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
void timeout() override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,72 @@
/* 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/interactions/gypsy.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Gypsy::Gypsy() : Interaction("Gypsy", 9) {
_title = STRING["maps.emap23.gypsy_title"];
}
bool Gypsy::msgFocus(const FocusMessage &msg) {
PartyView::msgFocus(msg);
_charSelected = false;
addText(STRING["maps.map23.gypsy"]);
return true;
}
void Gypsy::viewAction() {
// When already showing Gypsy, any click/key will close view
if (_charSelected)
close();
}
void Gypsy::charSwitched(Character *priorChar) {
Interaction::charSwitched(priorChar);
Character &c = *g_globals->_currCharacter;
if (!(c._flags[4] & CHARFLAG4_ASSIGNED)) {
c._flags[4] = CHARFLAG4_ASSIGNED |
(getRandomNumber(8) - 1);
}
Common::String line = Common::String::format(
STRING["maps.map23.your_sign_is"].c_str(),
STRING[Common::String::format("colors.%d",
c._flags[4] & CHARFLAG4_SIGN)].c_str()
);
addText(line);
_charSelected = true;
redraw();
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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/>.
*
*/
#ifndef MM1_VIEWS_ENH_INTERACTIONS_GYPSY_H
#define MM1_VIEWS_ENH_INTERACTIONS_GYPSY_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Gypsy : public Interaction {
private:
bool _charSelected = false;
protected:
/**
* Handles any action/press
*/
void viewAction() override;
/**
* Called when the selected character has been switched
*/
void charSwitched(Character *priorChar) override;
public:
Gypsy();
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,110 @@
/* 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/interactions/hacker.h"
#include "mm/mm1/maps/map36.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Hacker::Hacker() : Interaction("Hacker", 35) {
_title = STRING["maps.emap36.hacker_title"];
}
bool Hacker::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
return true;
}
bool Hacker::msgGame(const GameMessage &msg) {
if (msg._name != "DISPLAY")
return false;
g_globals->_currCharacter = &g_globals->_party[0];
_mode = g_globals->_currCharacter->_quest ? ACTIVE_QUEST : CAN_ACCEPT;
if (_mode == CAN_ACCEPT)
Sound::sound(SOUND_2);
addView();
clearButtons();
if (_mode == CAN_ACCEPT) {
addText(STRING["maps.map36.hacker2"]);
addButton(STRING["maps.accept"], 'Y');
addButton(STRING["maps.decline"], 'N');
} else {
// There's an active quest, so check for completion
MM1::Maps::Map36 &map = *static_cast<MM1::Maps::Map36 *>(g_maps->_currentMap);
int questNum = g_globals->_party[0]._quest;
Common::String line;
if (questNum >= 8 && questNum <= 14)
line = map.checkQuestComplete();
else
line = STRING["maps.map36.hacker4"];
g_maps->_mapPos.y++;
map.redrawGame();
addText(line);
}
return true;
}
bool Hacker::msgKeypress(const KeypressMessage &msg) {
MM1::Maps::Map36 &map = *static_cast<MM1::Maps::Map36 *>(g_maps->_currentMap);
if (_mode == CAN_ACCEPT) {
if (msg.keycode == Common::KEYCODE_y) {
map.acceptQuest();
_mode = ACCEPTED_QUEST;
clearButtons();
Common::String line = Common::String::format("%s %s",
STRING["maps.map36.hacker3"].c_str(),
STRING[Common::String::format(
"maps.map36.ingredients.%d",
g_globals->_party[0]._quest - 15)].c_str()
);
addText(line);
redraw();
return true;
} else if (msg.keycode == Common::KEYCODE_n) {
close();
return true;
}
}
return false;
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,52 @@
/* 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_INTERACTIONS_HACKER_H
#define MM1_VIEWS_ENH_INTERACTIONS_HACKER_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Hacker : public Interaction {
private:
enum Mode { CAN_ACCEPT, ACTIVE_QUEST, ACCEPTED_QUEST };
Mode _mode = CAN_ACCEPT;
public:
Hacker();
virtual ~Hacker() {}
bool msgGame(const GameMessage &msg) override;
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,44 @@
/* 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/interactions/ice_princess.h"
#include "mm/mm1/maps/map19.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
IcePrincess::IcePrincess() : InteractionQuery("IcePrincess", 10, 19) {
_title = STRING["maps.emap19.title"];
addText(STRING["maps.emap19.ice_princess"]);
}
void IcePrincess::answerEntered() {
MM1::Maps::Map19 &map = *static_cast<MM1::Maps::Map19 *>(g_maps->_currentMap);
map.riddleAnswer(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_INTERACTIONS_ICE_PRINCESS_H
#define MM1_VIEWS_ENH_INTERACTIONS_ICE_PRINCESS_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class IcePrincess : public InteractionQuery {
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
IcePrincess();
virtual ~IcePrincess() {}
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,107 @@
/* 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/interactions/inspectron.h"
#include "mm/mm1/maps/map35.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Inspectron::Inspectron() : Interaction("Inspectron", 18) {
_title = STRING["maps.emap35.inspectron_title"];
}
bool Inspectron::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
return true;
}
bool Inspectron::msgGame(const GameMessage &msg) {
if (msg._name != "DISPLAY")
return false;
g_globals->_currCharacter = &g_globals->_party[0];
_mode = g_globals->_currCharacter->_quest ? ACTIVE_QUEST : CAN_ACCEPT;
if (_mode == CAN_ACCEPT)
Sound::sound(SOUND_2);
addView();
clearButtons();
if (_mode == CAN_ACCEPT) {
addText(STRING["maps.map35.inspectron2"]);
addButton(STRING["maps.accept"], 'Y');
addButton(STRING["maps.decline"], 'N');
} else {
// There's an active quest, so check for completion
MM1::Maps::Map35 &map = *static_cast<MM1::Maps::Map35 *>(g_maps->_currentMap);
int questNum = g_globals->_party[0]._quest;
Common::String line;
if (questNum >= 8 && questNum <= 14)
line = map.checkQuestComplete();
else
line = STRING["maps.map35.inspectron4"];
g_maps->_mapPos.y++;
map.redrawGame();
addText(line);
}
return true;
}
bool Inspectron::msgKeypress(const KeypressMessage &msg) {
MM1::Maps::Map35 &map = *static_cast<MM1::Maps::Map35 *>(g_maps->_currentMap);
if (_mode == CAN_ACCEPT) {
if (msg.keycode == Common::KEYCODE_y) {
map.acceptQuest();
_mode = ACCEPTED_QUEST;
clearButtons();
addText(STRING[Common::String::format(
"maps.map35.quests.%d",
g_globals->_party[0]._quest - 8
)]);
redraw();
return true;
} else if (msg.keycode == Common::KEYCODE_n) {
close();
return true;
}
}
return false;
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,52 @@
/* 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_INTERACTIONS_INSPECTRON_H
#define MM1_VIEWS_ENH_INTERACTIONS_INSPECTRON_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Inspectron : public Interaction {
private:
enum Mode { CAN_ACCEPT, ACTIVE_QUEST, ACCEPTED_QUEST };
Mode _mode = CAN_ACCEPT;
public:
Inspectron();
virtual ~Inspectron() {}
bool msgGame(const GameMessage &msg) override;
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,179 @@
/* 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/interactions/interaction.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 Interactions {
#define BTN_SIZE 10
Interaction::Interaction(const Common::String &name, int portrait) : PartyView(name) {
_bounds = Common::Rect(8, 8, 224, 140);
if (portrait != -1) {
_frame.load("frame.fac");
_portrait.load(Common::Path(Common::String::format("face%02d.fac", portrait)));
}
}
void Interaction::addText(const Common::String &str) {
setReduced(false);
_lines = splitLines(searchAndReplace(str, "\n", " "));
}
bool Interaction::msgGame(const GameMessage &msg) {
if (msg._name == "DISPLAY") {
addView(this);
return true;
}
return PartyView::msgGame(msg);
}
bool Interaction::msgUnfocus(const UnfocusMessage &msg) {
PartyView::msgUnfocus(msg);
return true;
}
void Interaction::draw() {
PartyView::draw();
Graphics::ManagedSurface s = getSurface();
if (!_frame.empty()) {
_frame.draw(&s, 0, Common::Point(8, 8));
_portrait.draw(&s, _portraitFrameNum, Common::Point(15, 14));
}
setReduced(false);
if (!_title.empty()) {
size_t strWidth = getStringWidth(_title);
writeString(125 - strWidth / 2, 20, _title);
}
// Write any text lines
for (uint i = 0; i < _lines.size(); ++i) {
writeString(0, (6 + i) * 9 - 5, _lines[i], ALIGN_MIDDLE);
}
// Write out any buttons
if (!_buttons.empty()) {
_textPos = Common::Point(0, (6 + _lines.size()) * 9);
setReduced(true);
// Create a blank button
Graphics::ManagedSurface btnSmall(BTN_SIZE, BTN_SIZE);
btnSmall.blitFrom(g_globals->_blankButton, Common::Rect(0, 0, 20, 20),
Common::Rect(0, 0, BTN_SIZE, BTN_SIZE));
for (uint i = 0; i < _buttons.size(); ++i, _textPos.x += 10) {
InteractionButton &btn = _buttons[i];
int itemWidth = BTN_SIZE + 5 + getStringWidth(_buttons[i]._text);
if ((_textPos.x + itemWidth) > _innerBounds.width()) {
_textPos.x = 0;
_textPos.y += BTN_SIZE + 2;
}
Common::Point pt = _textPos;
// Display button and write character in the middle
s.blitFrom(btnSmall, Common::Point(pt.x + _bounds.borderSize(),
pt.y + _bounds.borderSize()));
writeString(pt.x + (BTN_SIZE / 2) + 1, pt.y,
Common::String::format("%c", _buttons[i]._c), ALIGN_MIDDLE);
// Write text to the right of the button
writeString(pt.x + BTN_SIZE + 5, pt.y, _buttons[i]._text);
// Set up bounds for the area covered by the button & text
btn._bounds = Common::Rect(pt.x, pt.y,
pt.x + BTN_SIZE + 5 + itemWidth, pt.y + BTN_SIZE);
btn._bounds.translate(_innerBounds.left, _innerBounds.top);
}
}
}
bool Interaction::tick() {
if (_animated && ++_tickCtr >= 10) {
_tickCtr = 0;
_portraitFrameNum = g_engine->getRandomNumber(0, 2);
redraw();
}
return PartyView::tick();
}
void Interaction::leave() {
if (g_events->focusedView() == this)
close();
g_maps->turnAround();
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 (!PartyView::msgAction(msg)) {
viewAction();
}
return true;
}
bool Interaction::msgMouseDown(const MouseDownMessage &msg) {
if (!PartyView::msgMouseDown(msg)) {
// Check if a button was pressed
for (uint i = 0; i < _buttons.size(); ++i) {
const auto &btn = _buttons[i];
if (_buttons[i]._bounds.contains(msg._pos)) {
msgKeypress(KeypressMessage(Common::KeyState(
(Common::KeyCode)(Common::KEYCODE_a + btn._c - 'A'), btn._c
)));
return true;
}
}
// Fall back on treating click as a standard acknowledgement
viewAction();
}
return true;
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,149 @@
/* 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_INTERACTIONS_INTERACTION_H
#define MM1_VIEWS_ENH_INTERACTIONS_INTERACTION_H
#include "mm/mm1/views_enh/party_view.h"
#include "mm/shared/xeen/sprites.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Interaction : public PartyView {
struct InteractionButton {
Common::String _text;
char _c = '\0';
Common::Rect _bounds;
InteractionButton() {}
InteractionButton(const Common::String &text, char c) :
_text(text), _c(toupper(c)) {}
};
private:
Shared::Xeen::SpriteResource _frame;
Shared::Xeen::SpriteResource _portrait;
int _tickCtr = 0;
int _portraitFrameNum = 0;
protected:
Common::String _title;
Common::StringArray _lines;
Common::Array<InteractionButton> _buttons;
bool _animated = true;
int _portraitNum = 0;
protected:
bool selectCharByDefault() const override {
return false;
}
/**
* Handles any action/press
*/
virtual void viewAction() {}
/**
* Adds text for display
*/
void addText(const Common::String &str);
/**
* Clear the buttons
*/
void clearButtons() {
_buttons.clear();
}
/**
* Adds a button
*/
void addButton(const Common::String &str, char c) {
_buttons.push_back(InteractionButton(str, c));
}
/**
* Write out a line
*/
void writeLine(int lineNum, const Common::String &str,
TextAlign align = ALIGN_LEFT, int xp = 0) {
PartyView::writeLine(6 + lineNum, str, align, xp);
}
/**
* Write out a line
*/
void writeLine(int lineNum, int value,
TextAlign align = ALIGN_LEFT, int xp = 0) {
PartyView::writeLine(6 + lineNum,
Common::String::format("%d", value), align, xp);
}
public:
Interaction(const Common::String &name, int portrait = -1);
/**
* Handles game messages
*/
bool msgGame(const GameMessage &msg) override;
/**
* Unfocuses the view
*/
bool msgUnfocus(const UnfocusMessage &msg) override;
/**
* Draw the location
*/
void draw() override;
/**
* Tick handler
*/
bool tick() override;
/**
* 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
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,74 @@
/* 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/interactions/interaction_query.h"
#include "mm/mm1/views_enh/text_entry.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
InteractionQuery::InteractionQuery(const Common::String &name,
int maxChars, int portrait) : Interaction(name, portrait),
_maxChars(maxChars) {
}
void InteractionQuery::abortFunc() {
auto *view = static_cast<InteractionQuery *>(g_events->focusedView());
view->answerEntry("");
}
void InteractionQuery::enterFunc(const Common::String &answer) {
auto *view = static_cast<InteractionQuery *>(g_events->focusedView());
view->answerEntry(answer);
}
bool InteractionQuery::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
_showEntry = dynamic_cast<TextEntry *>(msg._priorView) == nullptr;
return true;
}
void InteractionQuery::draw() {
Interaction::draw();
if (!_showEntry)
return;
assert(_buttons.empty());
int xp = 30; // (_innerBounds.width() / 2) - (_maxChars * 8 / 2);
int yp = (8 + _lines.size()) * 9 - 5;
_textEntry.display(xp, yp, _maxChars, false, abortFunc, enterFunc);
}
void InteractionQuery::answerEntry(const Common::String &answer) {
close();
_answer = answer;
answerEntered();
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,67 @@
/* 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_INTERACTIONS_INTERACTION_QUERY_H
#define MM1_VIEWS_ENH_INTERACTIONS_INTERACTION_QUERY_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/views_enh/text_entry.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class InteractionQuery : public Interaction {
private:
TextEntry _textEntry;
static void abortFunc();
static void enterFunc(const Common::String &answer);
int _maxChars = 0;
protected:
bool _showEntry = false;
Common::String _answer;
/**
* Answer entered
*/
virtual void answerEntered() = 0;
public:
InteractionQuery(const Common::String &name,
int maxChars, int portrait = -1);
bool msgFocus(const FocusMessage &msg) override;
void draw() override;
/**
* Passed the entered text
*/
void answerEntry(const Common::String &answer);
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,88 @@
/* 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/interactions/keeper.h"
#include "mm/mm1/maps/map54.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Keeper::Keeper() : Interaction("Keeper", 10) {
_title = STRING["maps.emap54.keeper"];
_animated = false;
}
bool Keeper::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
_pageNum = 0;
addText(STRING["maps.map54.keeper1"]);
return true;
}
void Keeper::viewAction() {
MM1::Maps::Map54 &map = *static_cast<MM1::Maps::Map54 *>(g_maps->_currentMap);
switch (++_pageNum) {
case 1:
addText(STRING["maps.emap54.keeper2"]);
redraw();
break;
case 2: {
uint32 perfTotal;
_isWorthy = map.isWorthy(perfTotal);
addText(Common::String::format(
STRING["maps.emap54.keeper3"].c_str(), perfTotal));
redraw();
break;
}
case 3:
addText(STRING[_isWorthy ? "maps.emap54.keeper5" :
"maps.emap54.keeper4"].c_str());
redraw();
break;
case 4:
if (!_isWorthy) {
leave();
} else {
addText(STRING["maps.map54.keeper6"]);
redraw();
}
break;
default:
leave();
break;
}
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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_INTERACTIONS_KEEPER_H
#define MM1_VIEWS_ENH_INTERACTIONS_KEEPER_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Keeper : public Interaction {
private:
int _pageNum = 0;
bool _isWorthy = false;
protected:
/**
* Handles any action/press
*/
void viewAction() override;
public:
Keeper();
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,62 @@
/* 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/interactions/leprechaun.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Leprechaun::Leprechaun() : Interaction("Leprechaun", 15) {
_title = STRING["maps.emap00.leprechaun_title"];
addText(STRING["maps.emap00.leprechaun"]);
addButton(STRING["stats.towns.1"], '1');
addButton(STRING["stats.towns.2"], '2');
addButton(STRING["stats.towns.3"], '3');
addButton(STRING["stats.towns.4"], '4');
addButton(STRING["stats.towns.5"], '5');
}
bool Leprechaun::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
return true;
}
bool Leprechaun::msgKeypress(const KeypressMessage &msg) {
if (msg.keycode >= Common::KEYCODE_1 && msg.keycode <= Common::KEYCODE_5) {
teleportToTown(msg.ascii);
return true;
} else if (msg.keycode == Common::KEYCODE_6) {
g_maps->turnRight();
g_maps->_mapPos = Common::Point(8, 3);
g_maps->changeMap(0x4242, 1);
}
return false;
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,46 @@
/* 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_INTERACTIONS_LEPRECHAUN_H
#define MM1_VIEWS_ENH_INTERACTIONS_LEPRECHAUN_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/game/leprechaun.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Leprechaun : public Interaction, MM1::Game::Leprechaun {
public:
Leprechaun();
virtual ~Leprechaun() {}
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,44 @@
/* 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/interactions/lion.h"
#include "mm/mm1/maps/map32.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Lion::Lion() : InteractionQuery("Lion", 10) {
_title = STRING["maps.emap32.statue_title"];
addText(STRING["maps.emap32.statue"]);
}
void Lion::answerEntered() {
MM1::Maps::Map32 &map = *static_cast<MM1::Maps::Map32 *>(g_maps->_currentMap);
map.passwordEntered(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_INTERACTIONS_LION_H
#define MM1_VIEWS_ENH_INTERACTIONS_LION_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Lion : public InteractionQuery {
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
Lion();
virtual ~Lion() {}
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,57 @@
/* 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/interactions/lord_archer.h"
#include "mm/mm1/maps/map40.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
LordArcher::LordArcher() : Interaction("LordArcher", 33) {
_title = STRING["maps.emap40.title"];
addText(STRING["maps.emap40.archer"]);
addButton(STRING["maps.yes"], 'Y');
addButton(STRING["maps.no"], 'N');
}
bool LordArcher::msgKeypress(const KeypressMessage &msg) {
if (msg.keycode == Common::KEYCODE_y || msg.keycode == Common::KEYCODE_n) {
MM1::Maps::Map40 &map = *static_cast<MM1::Maps::Map40 *>(g_maps->_currentMap);
close();
if (msg.keycode == Common::KEYCODE_y) {
map.archerSubmit();
} else {
map.archerResist();
}
}
return true;
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,45 @@
/* 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_INTERACTIONS_LORD_ARCHER_H
#define MM1_VIEWS_ENH_INTERACTIONS_LORD_ARCHER_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class LordArcher : public Interaction {
public:
LordArcher();
virtual ~LordArcher() {}
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -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/interactions/lord_ironfist.h"
#include "mm/mm1/maps/map43.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
LordIronfist::LordIronfist() : Interaction("LordIronfist", 18) {
_title = STRING["maps.emap43.title"];
}
bool LordIronfist::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
clearButtons();
if (_mode == ACCEPTING) {
_mode = ACCEPTED_QUEST;
addText(STRING[Common::String::format(
"maps.map43.quests.%d",
g_globals->_party[0]._quest
)]);
} else {
const Character &c = g_globals->_party[0];
_mode = c._quest ? ACTIVE_QUEST : CAN_ACCEPT;
if (_mode == CAN_ACCEPT) {
Sound::sound(SOUND_2);
addText(Common::String::format("%s%s",
STRING["maps.map43.ironfist1"].c_str(),
STRING["maps.map43.ironfist2"].c_str()
));
addButton(STRING["maps.accept"], 'Y');
addButton(STRING["maps.decline"], 'N');
} else {
// There's an active quest, so check for completion
MM1::Maps::Map43 &map = *static_cast<MM1::Maps::Map43 *>(g_maps->_currentMap);
int questNum = g_globals->_party[0]._quest;
Common::String line;
if (questNum < 8)
line = map.checkQuestComplete();
else
line = STRING["maps.map43.ironfist4"];
g_maps->_mapPos.x++;
addText(Common::String::format("%s%s",
STRING["maps.map43.ironfist1"].c_str(),
line.c_str()
));
}
}
return true;
}
bool LordIronfist::msgKeypress(const KeypressMessage &msg) {
MM1::Maps::Map43 &map = *static_cast<MM1::Maps::Map43 *>(g_maps->_currentMap);
if (_mode == CAN_ACCEPT) {
if (msg.keycode == Common::KEYCODE_y) {
// Accept the quest
close();
map.acceptQuest();
// Reshow the view to display what the quest is
_mode = ACCEPTING;
addView();
} else if (msg.keycode == Common::KEYCODE_n) {
close();
}
} else {
close();
}
return true;
}
void LordIronfist::viewAction() {
if (_mode != CAN_ACCEPT)
close();
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,54 @@
/* 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_INTERACTIONS_LORD_IRONFIST_H
#define MM1_VIEWS_ENH_INTERACTIONS_LORD_IRONFIST_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class LordIronfist : public Interaction {
private:
enum Mode { CAN_ACCEPT, ACCEPTING, ACTIVE_QUEST, ACCEPTED_QUEST };
Mode _mode = CAN_ACCEPT;
protected:
void viewAction() override;
public:
LordIronfist();
virtual ~LordIronfist() {}
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,45 @@
/* 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/interactions/orango.h"
#include "mm/mm1/maps/map48.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Orango::Orango() : InteractionQuery("Orango", 15, 13) {
_title = STRING["maps.emap48.title"];
addText(STRING["maps.emap48.orango1"]);
}
void Orango::answerEntered() {
MM1::Maps::Map48 &map = *static_cast<MM1::Maps::Map48 *>(g_maps->_currentMap);
map.orangoAnswer(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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_INTERACTIONS_ORANGO_H
#define MM1_VIEWS_ENH_INTERACTIONS_ORANGO_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Orango : public InteractionQuery {
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
Orango();
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,188 @@
/* 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/interactions/prisoners.h"
#include "mm/mm1/maps/map11.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Prisoner::Prisoner(const Common::String &name, int portrait, const Common::String &line1,
byte flag, Alignment freeAlignment, Alignment leaveAlignment) :
Interaction(name, portrait), _line(line1), _flag(flag),
_freeAlignment(freeAlignment), _leaveAlignment(leaveAlignment) {
_title = STRING["maps.eprisoners.title"];
}
bool Prisoner::msgFocus(const FocusMessage &msg) {
Interaction::msgFocus(msg);
addText(_line);
clearButtons();
addButton(STRING["maps.eprisoners.options1"], '1');
addButton(STRING["maps.eprisoners.options2"], '2');
addButton(STRING["maps.eprisoners.options3"], '3');
// Since the prisoner options are 1 to 3, disable party bindings
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
return true;
}
bool Prisoner::msgKeypress(const KeypressMessage &msg) {
if (endDelay())
return true;
if (msg.keycode < Common::KEYCODE_1 || msg.keycode > Common::KEYCODE_3)
return true;
Common::String line;
int align;
switch (msg.keycode) {
case Common::KEYCODE_1:
line = STRING["maps.prisoners.flees"];
align = _freeAlignment;
g_maps->clearSpecial();
flee();
break;
case Common::KEYCODE_2:
line = STRING["maps.prisoners.cowers"];
align = _leaveAlignment;
break;
default:
align = NEUTRAL;
break;
}
for (uint i = 0; i < g_globals->_party.size(); ++i) {
Character &c = g_globals->_party[i];
if (!(c._flags[1] & _flag)) {
c._flags[1] |= _flag;
if (align == c._alignment)
c._worthiness += 32;
}
}
if (align != NEUTRAL) {
clearButtons();
addText(line);
redraw();
delaySeconds(3);
Sound::sound(SOUND_2);
} else {
close();
}
return true;
}
void Prisoner::timeout() {
close();
}
/*------------------------------------------------------------------------*/
ChildPrisoner::ChildPrisoner() :
Prisoner("ChildPrisoner", 34, STRING["maps.prisoners.child"],
CHARFLAG1_4, GOOD, EVIL) {
}
ManPrisoner::ManPrisoner() :
Prisoner("ManPrisoner", 23, STRING["maps.prisoners.man"],
CHARFLAG1_20, EVIL, GOOD) {
}
CloakedPrisoner::CloakedPrisoner() :
Prisoner("CloakedPrisoner", 16, STRING["maps.prisoners.cloaked"],
CHARFLAG1_40, EVIL, GOOD) {
_animated = false;
}
DemonPrisoner::DemonPrisoner() :
Prisoner("DemonPrisoner", 41, STRING["maps.prisoners.demon"],
CHARFLAG1_10, EVIL, GOOD) {
}
MutatedPrisoner::MutatedPrisoner() :
Prisoner("MutatedPrisoner", 1, STRING["maps.prisoners.mutated"],
CHARFLAG1_2, GOOD, EVIL) {
}
MaidenPrisoner::MaidenPrisoner() :
Prisoner("MaidenPrisoner", 2, STRING["maps.prisoners.maiden"],
CHARFLAG1_8, GOOD, EVIL) {
}
void MaidenPrisoner::flee() {
MM1::Maps::Map &map = *g_maps->_currentMap;
map._walls[48] &= 0x7f;
}
/*------------------------------------------------------------------------*/
VirginPrisoner::VirginPrisoner() : Interaction("VirginPrisoner", 2) {
addText(STRING["maps.emap11.virgin"]);
addButton(STRING["maps.emap11.virgin_a"], 'A');
addButton(STRING["maps.emap11.virgin_b"], 'B');
addButton(STRING["maps.emap11.virgin_c"], 'C');
}
bool VirginPrisoner::msgKeypress(const KeypressMessage &msg) {
switch (msg.keycode) {
case Common::KEYCODE_a:
g_events->close();
g_events->send(SoundMessage(STRING["maps.map11.tip1"]));
break;
case Common::KEYCODE_b:
g_events->close();
static_cast<MM1::Maps::Map11 *>(g_maps->_currentMap)->challenge();
break;
case Common::KEYCODE_c:
g_events->close();
break;
default:
return Interaction::msgKeypress(msg);
}
return true;
}
bool VirginPrisoner::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
g_events->close();
return true;
} else {
return Interaction::msgAction(msg);
}
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,115 @@
/* 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_INTERACTIONS_PRISONERS_H
#define MM1_VIEWS_ENH_INTERACTIONS_PRISONERS_H
#include "mm/mm1/views_enh/interactions/interaction.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Prisoner : public Interaction {
private:
Common::String _line;
byte _flag;
Alignment _freeAlignment;
Alignment _leaveAlignment;
protected:
virtual void flee() {}
/**
* Return true if the selected character can be switched
*/
bool canSwitchChar() override {
return false;
}
public:
Prisoner(const Common::String &name, int portrait, const Common::String &line1,
byte flag, Alignment freeAlignment, Alignment leaveAlignment);
virtual ~Prisoner() {}
bool msgFocus(const FocusMessage &msg) override;
bool msgKeypress(const KeypressMessage &msg) override;
void timeout() override;
};
class ChildPrisoner : public Prisoner {
public:
ChildPrisoner();
virtual ~ChildPrisoner() {}
};
class ManPrisoner : public Prisoner {
public:
ManPrisoner();
virtual ~ManPrisoner() {}
};
class CloakedPrisoner : public Prisoner {
public:
CloakedPrisoner();
virtual ~CloakedPrisoner() {
}
};
class DemonPrisoner : public Prisoner {
public:
DemonPrisoner();
virtual ~DemonPrisoner() {
}
};
class MutatedPrisoner : public Prisoner {
public:
MutatedPrisoner();
virtual ~MutatedPrisoner() {
}
};
class MaidenPrisoner : public Prisoner {
protected:
void flee() override;
public:
MaidenPrisoner();
virtual ~MaidenPrisoner() {
}
};
class VirginPrisoner : public Interaction {
public:
VirginPrisoner();
virtual ~VirginPrisoner() {
}
bool msgKeypress(const KeypressMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,84 @@
/* 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/interactions/resistances.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Resistances::Resistances() : Interaction("Resistances", 4) {
_title = STRING["maps.emap02.resistances"];
}
bool Resistances::msgFocus(const FocusMessage &msg) {
PartyView::msgFocus(msg);
addText(STRING["maps.map02.morango"]);
return true;
}
void Resistances::draw() {
Interaction::draw();
if (_lines.empty()) {
const Character &c = *g_globals->_currCharacter;
setReduced(true);
writeLine(0, STRING["maps.emap02.magic"], ALIGN_LEFT, 0);
writeLine(0, c._resistances._s._magic, ALIGN_RIGHT, 45);
writeLine(0, STRING["maps.emap02.fire"], ALIGN_LEFT, 50);
writeLine(0, c._resistances._s._fire, ALIGN_RIGHT, 90);
writeLine(0, STRING["maps.emap02.cold"], ALIGN_LEFT, 95);
writeLine(0, c._resistances._s._cold, ALIGN_RIGHT, 145);
writeLine(0, STRING["maps.emap02.electricity"], ALIGN_LEFT, 150);
writeLine(0, c._resistances._s._electricity, ALIGN_RIGHT, 195);
writeLine(1, STRING["maps.emap02.acid"], ALIGN_LEFT, 0);
writeLine(1, c._resistances._s._acid, ALIGN_RIGHT, 45);
writeLine(1, STRING["maps.emap02.fear"], ALIGN_LEFT, 50);
writeLine(1, c._resistances._s._fear, ALIGN_RIGHT, 90);
writeLine(1, STRING["maps.emap02.poison"], ALIGN_LEFT, 95);
writeLine(1, c._resistances._s._poison, ALIGN_RIGHT, 145);
writeLine(1, STRING["maps.emap02.sleep"], ALIGN_LEFT, 150);
writeLine(1, c._resistances._s._psychic, ALIGN_RIGHT, 195);
}
}
void Resistances::viewAction() {
// When already showing resistances, any click/key will close view
if (_lines.empty())
close();
}
void Resistances::charSwitched(Character *priorChar) {
Interaction::charSwitched(priorChar);
_lines.clear();
redraw();
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,63 @@
/* 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_INTERACTIONS_RESISTANCES_H
#define MM1_VIEWS_ENH_INTERACTIONS_RESISTANCES_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Resistances : public Interaction {
protected:
/**
* Handles any action/press
*/
void viewAction() override;
/**
* Called when the selected character has been switched
*/
void charSwitched(Character *priorChar) override;
public:
Resistances();
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
/**
* Draw the location
*/
void draw() override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,44 @@
/* 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/interactions/ruby.h"
#include "mm/mm1/maps/map39.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Ruby::Ruby() : InteractionQuery("Ruby", 12) {
_title = STRING["maps.emap39.title"];
addText(STRING["maps.emap39.ruby1"]);
}
void Ruby::answerEntered() {
MM1::Maps::Map39 &map = *static_cast<MM1::Maps::Map39 *>(g_maps->_currentMap);
map.riddleAnswered(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_INTERACTIONS_RUBY_H
#define MM1_VIEWS_ENH_INTERACTIONS_RUBY_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Ruby : public InteractionQuery {
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
Ruby();
virtual ~Ruby() {}
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#include "mm/mm1/views_enh/interactions/scummvm.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
ScummVM::ScummVM() : Interaction("ScummVM", 38) {
_title = STRING["maps.map55.title"];
addText(STRING["maps.map55.message"]);
}
void ScummVM::viewAction() {
for (uint i = 0; i < g_globals->_party.size(); ++i) {
Character &c = g_globals->_party[i];
c._gold += 10000;
c._gems = MIN((int)c._gems + 1000, 0xffff);
}
g_maps->_mapPos = Common::Point(8, 3);
g_maps->changeMap(0x604, 1);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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_INTERACTIONS_SCUMMVM_H
#define MM1_VIEWS_ENH_INTERACTIONS_SCUMMVM_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class ScummVM : public Interaction {
protected:
/**
* Handles any action/press
*/
void viewAction() override;
public:
ScummVM();
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,76 @@
/* 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/interactions/statue.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Statue::Statue() : Interaction("Statue", 33) {
_title = STRING["dialogs.statues.statue"];
_animated = false;
}
bool Statue::msgGame(const GameMessage &msg) {
if (msg._name == "STATUE") {
_pageNum = 0;
_statueNum = msg._value;
addView(this);
return true;
}
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
} // namespace MM

View File

@@ -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/>.
*
*/
#ifndef MM1_VIEWS_ENH_INTERACTIONS_STATUE_H
#define MM1_VIEWS_ENH_INTERACTIONS_STATUE_H
#include "mm/mm1/views_enh/interactions/interaction.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Statue : public Interaction {
private:
int _statueNum = 0;
int _pageNum = 0;
protected:
/**
* Handles any action/press
*/
void viewAction() override;
public:
Statue();
/**
* Handles game message
*/
bool msgGame(const GameMessage &msg) override;
/**
* Handles focus
*/
bool msgFocus(const FocusMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,67 @@
/* 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/interactions/trivia.h"
#include "mm/mm1/maps/map21.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
Trivia::Trivia() : InteractionQuery("Trivia", 14) {
_title = STRING["maps.emap21.title"];
}
bool Trivia::msgGame(const GameMessage &msg) {
if (msg._name == "TRIVIA") {
_question = STRING[Common::String::format(
"maps.map21.questions.%d", msg._value)];
_correctAnswer = STRING[Common::String::format(
"maps.map21.answers.%d", msg._value)];
addText(_question);
open();
return true;
}
return false;
}
void Trivia::answerEntered() {
if (_answer.equalsIgnoreCase(_correctAnswer)) {
send(InfoMessage(STRING["maps.map21.correct"]));
g_globals->_party[0]._gems += 50;
Sound::sound(SOUND_3);
} else {
g_maps->_mapPos.x = 15;
g_maps->_currentMap->updateGame();
send(InfoMessage(STRING["maps.map21.incorrect"]));
}
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,54 @@
/* 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_INTERACTIONS_TRIVIA_H
#define MM1_VIEWS_ENH_INTERACTIONS_TRIVIA_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class Trivia : public InteractionQuery {
private:
Common::String _question, _correctAnswer;
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
Trivia();
virtual ~Trivia() {}
bool msgGame(const GameMessage &msg) override;
};
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,117 @@
/* 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/interactions/volcano_god.h"
#include "mm/mm1/maps/map11.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
VolcanoGod::VolcanoGod() : InteractionQuery("VolcanoGod", 8, 10) {
_title = STRING["maps.emap11.volcano_god"];
}
bool VolcanoGod::msgFocus(const FocusMessage &msg) {
InteractionQuery::msgFocus(msg);
_showEntry = false;
setMode(CHOOSE_OPTION);
return true;
}
bool VolcanoGod::msgKeypress(const KeypressMessage &msg) {
switch (msg.keycode) {
case Common::KEYCODE_a:
challenge();
break;
case Common::KEYCODE_b:
riddle();
break;
case Common::KEYCODE_c:
clue();
break;
default:
return InteractionQuery::msgKeypress(msg);
}
return true;
}
bool VolcanoGod::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
g_events->close();
return true;
} else {
return InteractionQuery::msgAction(msg);
}
}
void VolcanoGod::setMode(Mode newMode) {
clearButtons();
_mode = newMode;
switch (_mode) {
case CHOOSE_OPTION:
addText(STRING["maps.emap11.god_text"]);
addButton(STRING["maps.emap11.god_a"], 'A');
addButton(STRING["maps.emap11.god_b"], 'B');
addButton(STRING["maps.emap11.god_c"], 'C');
break;
case ENTER_RESPONSE:
addText(STRING["maps.emap11.question"]);
_showEntry = true;
break;
}
redraw();
}
void VolcanoGod::challenge() {
MM1::Maps::Map11 &map = *static_cast<MM1::Maps::Map11 *>(g_maps->_currentMap);
close();
map.challenge();
}
void VolcanoGod::riddle() {
Sound::sound(SOUND_2);
setMode(ENTER_RESPONSE);
redraw();
}
void VolcanoGod::clue() {
MM1::Maps::Map11 &map = *static_cast<MM1::Maps::Map11 *>(g_maps->_currentMap);
close();
map.clue();
}
void VolcanoGod::answerEntered() {
MM1::Maps::Map11 &map = *static_cast<MM1::Maps::Map11 *>(g_maps->_currentMap);
map.riddleAnswer(_answer);
}
} // namespace Interactions
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,65 @@
/* 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_INTERACTIONS_VOLCANO_GOD_H
#define MM1_VIEWS_ENH_INTERACTIONS_VOLCANO_GOD_H
#include "mm/mm1/views_enh/interactions/interaction_query.h"
#include "mm/mm1/data/character.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
namespace Interactions {
class VolcanoGod : public InteractionQuery {
private:
enum Mode {
CHOOSE_OPTION, ENTER_RESPONSE
};
Mode _mode = CHOOSE_OPTION;
void setMode(Mode newMode);
void challenge();
void riddle();
void clue();
protected:
/**
* Answer entered
*/
void answerEntered() override;
public:
VolcanoGod();
virtual ~VolcanoGod() {
}
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

View File

@@ -0,0 +1,180 @@
/* 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/items_view.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
#define BUTTON_WIDTH 35
#define EXIT_X 275
ItemsView::ItemsView(const Common::String &name) : PartyView(name),
_buttonsArea(Common::Rect(0, 101, 320, 146)) {
_bounds = Common::Rect(0, 0, 320, 146);
}
void ItemsView::addButton(int frame, const Common::String &text,
Common::KeyCode keycode) {
Common::Point pt(_btnText.size() * BUTTON_WIDTH + 5, 101);
if (keycode == Common::KEYCODE_ESCAPE) {
pt.x = EXIT_X;
PartyView::addButton(&g_globals->_escSprites, pt, 0, KEYBIND_ESCAPE);
} else {
PartyView::addButton(&_btnSprites, pt, frame, keycode);
}
_btnText.push_back(text);
}
bool ItemsView::msgFocus(const FocusMessage &msg) {
PartyView::msgFocus(msg);
// Disable the normal '1' to '6' character selection keybindings,
// since we're using them in this dialog for item selection
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
_selectedItem = -1;
return true;
}
void ItemsView::draw() {
// Draw the outer frame and buttons
PartyView::draw();
// Draw the frame surrounding the buttons area
const Common::Rect r = _bounds;
_bounds = _buttonsArea;
frame();
_bounds = r;
// Draw button text
setReduced(true);
for (uint i = 0; i < _btnText.size(); ++i) {
if (isButtonEnabled(i)) {
Common::Point pt(i * BUTTON_WIDTH + 5, 123);
if (i == (_btnText.size() - 1))
pt.x = EXIT_X;
writeString(pt.x + 12, pt.y, _btnText[i], ALIGN_MIDDLE);
}
}
// List the items
for (int i = 0; i < (int)_items.size(); ++i) {
g_globals->_items.getItem(_items[i]);
const Item &item = g_globals->_currItem;
const Common::String line = Common::String::format(
"%d) %s", i + 1,
item._name.c_str()
);
setTextColor(i == _selectedItem ? 15 : getLineColor());
writeLine(2 + i, line, ALIGN_LEFT, 10);
if (_costMode != NO_COST) {
int cost = (_costMode == SHOW_COST) ? item._cost : item.getSellCost();
writeLine(2 + i, Common::String::format("%d", cost),
ALIGN_RIGHT);
}
}
if (_items.size() == 0)
writeLine(2, STRING["enhdialogs.misc.no_items"], ALIGN_LEFT, 10);
setTextColor(0);
}
bool ItemsView::msgKeypress(const KeypressMessage &msg) {
if (endDelay())
return true;
if (msg.keycode >= Common::KEYCODE_1 &&
msg.keycode <= (int)(Common::KEYCODE_0 + _items.size())) {
_selectedItem = msg.keycode - Common::KEYCODE_1;
draw();
itemSelected();
return true;
}
return PartyView::msgKeypress(msg);
}
bool ItemsView::msgMouseDown(const MouseDownMessage &msg) {
if (msg._pos.x >= (_innerBounds.left + 10) &&
msg._pos.x < _innerBounds.right) {
int y = msg._pos.y - (_innerBounds.top + 2 * 9);
if (y >= 0) {
int lineNum = y / 9;
if (lineNum < (int)_items.size()) {
_selectedItem = lineNum;
draw();
itemSelected();
return true;
}
}
}
return PartyView::msgMouseDown(msg);
}
bool ItemsView::msgAction(const ActionMessage &msg) {
if (endDelay())
return true;
if (msg._action == KEYBIND_ESCAPE) {
close();
return true;
} else {
return PartyView::msgAction(msg);
}
}
void ItemsView::timeout() {
redraw();
}
void ItemsView::backpackFull() {
displayMessage(STRING["dialogs.misc.backpack_full"]);
}
void ItemsView::notEnoughGold() {
displayMessage(STRING["dialogs.misc.not_enough_gold"]);
}
void ItemsView::displayMessage(const Common::String &msg) {
SoundMessage infoMsg(msg, ALIGN_MIDDLE);
infoMsg._delaySeconds = 3;
infoMsg._callback = []() {
ItemsView *view = static_cast<ItemsView *>(g_events->focusedView());
view->timeout();
};
send(infoMsg);
}
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM

View File

@@ -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 <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_ENH_ITEMS_VIEW_H
#define MM1_VIEWS_ENH_ITEMS_VIEW_H
#include "mm/mm1/views_enh/party_view.h"
namespace MM {
namespace MM1 {
namespace ViewsEnh {
class ItemsView : public PartyView {
protected:
enum CostMode { SHOW_COST, SHOW_VALUE, NO_COST };
int _selectedItem = -1;
CostMode _costMode = NO_COST;
Common::Array<int> _items;
const Common::Rect _buttonsArea;
Shared::Xeen::SpriteResource _btnSprites;
Common::StringArray _btnText;
/**
* Add a button to the buttons bar
*/
void addButton(int frame, const Common::String &text,
Common::KeyCode keycode);
/**
* Display a message that the inventory is full
*/
void backpackFull();
/**
* Display a message the character doesn't have enough gold
*/
void notEnoughGold();
/**
* Display an arbitrary message
*/
void displayMessage(const Common::String &msg);
/**
* Get the text color for a line
*/
virtual int getLineColor() const {
return 0;
}
/**
* Called when an item is selected
*/
virtual void itemSelected() = 0;
/**
* Clear the buttons list
*/
void clearButtons() {
_btnText.clear();
PartyView::clearButtons();
}
public:
ItemsView(const Common::String &name);
virtual ~ItemsView() {}
bool msgFocus(const FocusMessage &msg) override;
void draw() override;
bool msgKeypress(const KeypressMessage &msg) override;
bool msgMouseDown(const MouseDownMessage &msg) override;
bool msgAction(const ActionMessage &msg) override;
void timeout() override;
};
} // namespace ViewsEnh
} // namespace MM1
} // namespace MM
#endif

Some files were not shown because too many files have changed in this diff Show More