Initial commit
This commit is contained in:
88
engines/mm/mm1/views_enh/locations/blacksmith.cpp
Normal file
88
engines/mm/mm1/views_enh/locations/blacksmith.cpp
Normal 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/locations/blacksmith.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Blacksmith::Blacksmith() : Location("Blacksmith", LOC_BLACKSMITH) {
|
||||
addButton(&g_globals->_escSprites, Common::Point(24, 100), 0, KEYBIND_ESCAPE);
|
||||
}
|
||||
|
||||
void Blacksmith::draw() {
|
||||
Location::draw();
|
||||
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
setReduced(false);
|
||||
writeLine(0, STRING["enhdialogs.location.store"], ALIGN_MIDDLE);
|
||||
writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
|
||||
writeLine(3, c._name, ALIGN_MIDDLE);
|
||||
|
||||
writeLine(5, STRING["enhdialogs.blacksmith.browse"], ALIGN_LEFT, 10);
|
||||
|
||||
writeLine(10, STRING["enhdialogs.location.gold"]);
|
||||
writeLine(10, Common::String::format("%d",
|
||||
g_globals->_currCharacter->_gold), ALIGN_RIGHT);
|
||||
|
||||
setReduced(true);
|
||||
writeString(27, 122, STRING["enhdialogs.location.esc"]);
|
||||
}
|
||||
|
||||
bool Blacksmith::msgKeypress(const KeypressMessage &msg) {
|
||||
// If a delay is active, end it
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_b:
|
||||
addView("BlackSmithItems");
|
||||
break;
|
||||
default:
|
||||
return Location::msgKeypress(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Blacksmith::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return Location::msgAction(msg);
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
47
engines/mm/mm1/views_enh/locations/blacksmith.h
Normal file
47
engines/mm/mm1/views_enh/locations/blacksmith.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MM1_VIEWS_ENH_LOCATIONS_BLACKSMITH_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_BLACKSMITH_H
|
||||
|
||||
#include "mm/mm1/views_enh/locations/location.h"
|
||||
#include "mm/mm1/data/character.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Blacksmith : public Location {
|
||||
public:
|
||||
Blacksmith();
|
||||
|
||||
void draw() override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
243
engines/mm/mm1/views_enh/locations/blacksmith_items.cpp
Normal file
243
engines/mm/mm1/views_enh/locations/blacksmith_items.cpp
Normal file
@@ -0,0 +1,243 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/locations/blacksmith_items.h"
|
||||
#include "mm/mm1/views_enh/locations/blacksmith.h"
|
||||
#include "mm/mm1/views_enh/confirm.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
BlacksmithItems::BlacksmithItems() : ItemsView("BlacksmithItems") {
|
||||
_btnSprites.load("buy.icn");
|
||||
addButton(0, STRING["enhdialogs.blacksmith.buttons.weapons"], Common::KEYCODE_w);
|
||||
addButton(2, STRING["enhdialogs.blacksmith.buttons.armor"], Common::KEYCODE_a);
|
||||
addButton(6, STRING["enhdialogs.blacksmith.buttons.misc"], Common::KEYCODE_m);
|
||||
addButton(10, STRING["enhdialogs.blacksmith.buttons.sell"], Common::KEYCODE_s);
|
||||
addButton(12, STRING["enhdialogs.misc.exit"], Common::KEYCODE_ESCAPE);
|
||||
}
|
||||
|
||||
bool BlacksmithItems::msgFocus(const FocusMessage &msg) {
|
||||
ItemsView::msgFocus(msg);
|
||||
|
||||
// When first opened, default to showing weapons to buy
|
||||
if (dynamic_cast<Blacksmith *>(msg._priorView) != nullptr) {
|
||||
_mode = WEAPONS_MODE;
|
||||
populateItems();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlacksmithItems::draw() {
|
||||
ItemsView::draw();
|
||||
drawTitle();
|
||||
}
|
||||
|
||||
void BlacksmithItems::drawTitle() {
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
Common::String areaName = STRING["enhdialogs.blacksmith.areas.weapons"];
|
||||
if (_mode == ARMOR_MODE)
|
||||
areaName = STRING["enhdialogs.blacksmith.areas.armor"];
|
||||
if (_mode == MISC_MODE)
|
||||
areaName = STRING["enhdialogs.blacksmith.areas.misc"];
|
||||
|
||||
if (_mode == SELL_MODE) {
|
||||
// Show sell mode title
|
||||
Common::String title = Common::String::format(
|
||||
STRING["enhdialogs.items.backpack_for"].c_str(),
|
||||
c._name,
|
||||
STRING[Common::String::format("stats.classes.%d", c._class)].c_str()
|
||||
);
|
||||
|
||||
setReduced(false);
|
||||
writeLine(0, title, ALIGN_MIDDLE);
|
||||
|
||||
} else {
|
||||
// Show title with "Available <Area>", "Gold", and "Cost"
|
||||
setReduced(false);
|
||||
Common::String title = Common::String::format("%s %s",
|
||||
STRING["enhdialogs.blacksmith.available"].c_str(),
|
||||
areaName.c_str());
|
||||
writeString(0, 0, title);
|
||||
|
||||
Common::String gold = Common::String::format("%s - %d",
|
||||
STRING["enhdialogs.blacksmith.gold"].c_str(),
|
||||
c._gold);
|
||||
writeString(160, 0, gold);
|
||||
|
||||
writeString(0, 0, STRING["enhdialogs.blacksmith.cost"], ALIGN_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
bool BlacksmithItems::msgKeypress(const KeypressMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_w:
|
||||
_mode = WEAPONS_MODE;
|
||||
populateItems();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_a:
|
||||
_mode = ARMOR_MODE;
|
||||
populateItems();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_m:
|
||||
_mode = MISC_MODE;
|
||||
populateItems();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_s:
|
||||
_mode = SELL_MODE;
|
||||
populateItems();
|
||||
redraw();
|
||||
break;
|
||||
|
||||
default:
|
||||
return ItemsView::msgKeypress(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BlacksmithItems::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
return ItemsView::msgAction(msg);
|
||||
}
|
||||
|
||||
void BlacksmithItems::populateItems() {
|
||||
_costMode = (_mode == SELL_MODE) ? SHOW_VALUE : SHOW_COST;
|
||||
_items.clear();
|
||||
|
||||
if (_mode != SELL_MODE) {
|
||||
// Populate the list of items that can be purchased
|
||||
// from the blacksmith in that category
|
||||
int townNum = g_maps->_currentMap->dataByte(Maps::MAP_ID);
|
||||
if (townNum < 1 || townNum >= 6)
|
||||
townNum = 1;
|
||||
|
||||
const byte *ITEMS = WEAPONS[townNum - 1];
|
||||
if (_mode == ARMOR_MODE)
|
||||
ITEMS = ARMOR[townNum - 1];
|
||||
if (_mode == MISC_MODE)
|
||||
ITEMS = MISC[townNum - 1];
|
||||
|
||||
for (int i = 0; i < 6; ++i)
|
||||
_items.push_back(ITEMS[i]);
|
||||
} else {
|
||||
// Sell mode, so list the player's inventory
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
for (uint i = 0; i < c._backpack.size(); ++i)
|
||||
_items.push_back(c._backpack[i]._id);
|
||||
}
|
||||
}
|
||||
|
||||
void BlacksmithItems::itemSelected() {
|
||||
Common::String buySell, gold;
|
||||
g_globals->_items.getItem(_items[_selectedItem]);
|
||||
const Item &item = g_globals->_currItem;
|
||||
_buySellItem = _selectedItem;
|
||||
|
||||
if (_mode != SELL_MODE) {
|
||||
buySell = STRING["enhdialogs.blacksmith.buy"];
|
||||
gold = Common::String::format(
|
||||
STRING["enhdialogs.blacksmith.for_gold"].c_str(),
|
||||
item._cost);
|
||||
} else {
|
||||
buySell = STRING["enhdialogs.blacksmith.sell"];
|
||||
gold = Common::String::format(
|
||||
STRING["enhdialogs.blacksmith.for_gold"].c_str(),
|
||||
item.getSellCost());
|
||||
}
|
||||
|
||||
Common::String msg = Common::String::format(
|
||||
"%s \x02""15%s\x02""00 %s?",
|
||||
buySell.c_str(), item._name.c_str(), gold.c_str());
|
||||
Confirm::show(msg, []() {
|
||||
BlacksmithItems *view = static_cast<BlacksmithItems *>(
|
||||
g_events->focusedView());
|
||||
view->itemConfirmed();
|
||||
});
|
||||
}
|
||||
|
||||
void BlacksmithItems::charSwitched(Character *priorChar) {
|
||||
ItemsView::charSwitched(priorChar);
|
||||
populateItems();
|
||||
redraw();
|
||||
}
|
||||
|
||||
void BlacksmithItems::itemConfirmed() {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
Inventory &inv = c._backpack;
|
||||
|
||||
if (_mode == SELL_MODE) {
|
||||
// Give the character the item value, and remove from inventory
|
||||
c._gold += g_globals->_currItem.getSellCost();
|
||||
inv.removeAt(_buySellItem);
|
||||
populateItems();
|
||||
|
||||
} else {
|
||||
auto buyResult = c.buyItem(_items[_buySellItem]);
|
||||
|
||||
switch (buyResult) {
|
||||
case Character::BUY_BACKPACK_FULL:
|
||||
backpackFull();
|
||||
break;
|
||||
case Character::BUY_NOT_ENOUGH_GOLD:
|
||||
notEnoughGold();
|
||||
break;
|
||||
default:
|
||||
displayMessage(STRING["dialogs.blacksmith.thankyou"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int BlacksmithItems::getLineColor() const {
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
const Item &item = g_globals->_currItem;
|
||||
|
||||
if (_mode == SELL_MODE) {
|
||||
return 0;
|
||||
} else {
|
||||
if (c._class != NONE && c._class <= ROBBER) {
|
||||
if (!(BLACKSMITH_CLASS_USAGE[c._class - 1] & item._disablements))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
90
engines/mm/mm1/views_enh/locations/blacksmith_items.h
Normal file
90
engines/mm/mm1/views_enh/locations/blacksmith_items.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* 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_BLACKSMITH_ITEMS_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_BLACKSMITH_ITEMS_H
|
||||
|
||||
#include "mm/mm1/views_enh/items_view.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class BlacksmithItems : public ItemsView,
|
||||
public BlacksmithData, public BuyWeaponData,
|
||||
public BuyArmorData, public BuyMiscData {
|
||||
private:
|
||||
enum BlacksmithMode {
|
||||
WEAPONS_MODE = 0, ARMOR_MODE = 1, MISC_MODE = 2,
|
||||
SELL_MODE = 3
|
||||
};
|
||||
BlacksmithMode _mode = WEAPONS_MODE;
|
||||
int _buySellItem = -1;
|
||||
|
||||
/**
|
||||
* Populates the list of items
|
||||
*/
|
||||
void populateItems();
|
||||
|
||||
/**
|
||||
* Displays the title row
|
||||
*/
|
||||
void drawTitle();
|
||||
|
||||
/**
|
||||
* Called if the buy/sell action has been confirmed
|
||||
*/
|
||||
void itemConfirmed();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Get the text color for a line
|
||||
*/
|
||||
int getLineColor() const override;
|
||||
|
||||
/**
|
||||
* Called when an item is selected
|
||||
*/
|
||||
void itemSelected() override;
|
||||
|
||||
/**
|
||||
* When the selected character is changed
|
||||
*/
|
||||
void charSwitched(Character *priorChar) override;
|
||||
|
||||
public:
|
||||
BlacksmithItems();
|
||||
virtual ~BlacksmithItems() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
228
engines/mm/mm1/views_enh/locations/inn.cpp
Normal file
228
engines/mm/mm1/views_enh/locations/inn.cpp
Normal file
@@ -0,0 +1,228 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/locations/inn.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Inn::Inn() : ScrollView("Inn") {
|
||||
_bounds.setBorderSize(10);
|
||||
_escSprite.load("esc.icn");
|
||||
|
||||
addButton(&_escSprite, Common::Point(119, 166), 0, KEYBIND_ESCAPE, true);
|
||||
addButton(&_escSprite, Common::Point(85, 166), 0, KEYBIND_SELECT, true);
|
||||
setButtonEnabled(1, false);
|
||||
}
|
||||
|
||||
bool Inn::msgFocus(const FocusMessage &msg) {
|
||||
if (g_maps->_currentMap)
|
||||
// Update the starting town
|
||||
g_globals->_startingTown = (Maps::TownId)g_maps->_currentMap->dataByte(Maps::MAP_ID);
|
||||
|
||||
// Save the roster
|
||||
g_globals->_roster.update(_partyChars);
|
||||
g_globals->_roster.save();
|
||||
|
||||
// Get a list of characters in the town
|
||||
_charNums.clear();
|
||||
for (uint i = 0; i < ROSTER_COUNT; ++i) {
|
||||
if (g_globals->_roster._towns[i] == g_globals->_startingTown)
|
||||
_charNums.push_back(i);
|
||||
}
|
||||
|
||||
// Build up a list of characters in the party
|
||||
// (for if we're opening the inn from in-game)
|
||||
_partyChars.clear();
|
||||
for (uint i = 0; i < g_globals->_party.size(); ++i) {
|
||||
for (uint j = 0; j < ROSTER_COUNT; ++j) {
|
||||
if (g_globals->_roster[j] == g_globals->_party[i]) {
|
||||
_partyChars.push_back(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Inn::draw() {
|
||||
setButtonEnabled(1, !_partyChars.empty());
|
||||
if (!_partyChars.empty()) {
|
||||
setButtonPos(0, Common::Point(155, 166));
|
||||
} else {
|
||||
setButtonPos(0, Common::Point(119, 166));
|
||||
}
|
||||
|
||||
ScrollView::draw();
|
||||
Graphics::ManagedSurface s = getSurface();
|
||||
|
||||
// Write title
|
||||
Common::String title = Common::String::format(
|
||||
STRING["dialogs.inn.title"].c_str(),
|
||||
'0' + g_globals->_startingTown);
|
||||
title += STRING[Common::String::format(
|
||||
"stats.towns.%d", g_globals->_startingTown)];
|
||||
setReduced(false);
|
||||
writeString(0, 0, title, ALIGN_MIDDLE);
|
||||
|
||||
if (_charNums.empty()) {
|
||||
writeString(0, 40, STRING["dialogs.misc.no_characters"], ALIGN_MIDDLE);
|
||||
|
||||
} else {
|
||||
// Write out the roster
|
||||
setReduced(true);
|
||||
|
||||
for (uint idx = 0; idx < _charNums.size(); ++idx) {
|
||||
uint charNum = _charNums[idx];
|
||||
const Character &c = g_globals->_roster[charNum];
|
||||
bool isInParty = _partyChars.contains(charNum);
|
||||
|
||||
// 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));
|
||||
|
||||
if (isInParty)
|
||||
s.frameRect(Common::Rect(pt.x, pt.y, pt.x + 19, pt.y + 19), 37);
|
||||
|
||||
writeString(pt.x - _innerBounds.left + 22, pt.y - _innerBounds.top + 5, c._name);
|
||||
}
|
||||
|
||||
setReduced(false);
|
||||
if (_partyChars.size() == 6)
|
||||
writeString(0, 130, STRING["dialogs.inn.full"], ALIGN_MIDDLE);
|
||||
|
||||
writeString(0, 142, STRING["enhdialogs.inn.left_click"], ALIGN_MIDDLE);
|
||||
writeString(0, 152, STRING["enhdialogs.inn.right_click"], ALIGN_MIDDLE);
|
||||
}
|
||||
|
||||
if (!_partyChars.empty()) {
|
||||
writeString(100, 168, STRING["enhdialogs.inn.exit"]);
|
||||
writeString(170, 168, STRING["enhdialogs.misc.go_back"]);
|
||||
} else {
|
||||
writeString(134, 168, STRING["enhdialogs.misc.go_back"]);
|
||||
}
|
||||
}
|
||||
|
||||
bool Inn::msgMouseDown(const MouseDownMessage &msg) {
|
||||
// Cycle through portraits
|
||||
for (uint idx = 0; idx < _charNums.size(); ++idx) {
|
||||
Common::Point pt(_innerBounds.left + _innerBounds.width() / 3
|
||||
* (idx % 3), 20 + 20 * (idx / 3));
|
||||
|
||||
if (Common::Rect(pt.x, pt.y, pt.x + 19, pt.y + 19).contains(msg._pos)) {
|
||||
int charNum = _charNums[idx];
|
||||
|
||||
if (msg._button == MouseMessage::MB_LEFT) {
|
||||
// Toggle in party
|
||||
if (_partyChars.contains(charNum))
|
||||
_partyChars.remove(charNum);
|
||||
else
|
||||
_partyChars.push_back(charNum);
|
||||
|
||||
setButtonEnabled(0, !_partyChars.empty());
|
||||
redraw();
|
||||
} else {
|
||||
g_globals->_currCharacter = &g_globals->_roster[charNum];
|
||||
_characterView.addView();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ScrollView::msgMouseDown(msg);
|
||||
}
|
||||
|
||||
bool Inn::msgKeypress(const KeypressMessage &msg) {
|
||||
if (msg.keycode >= Common::KEYCODE_a &&
|
||||
msg.keycode < (Common::KeyCode)(Common::KEYCODE_a + _charNums.size())) {
|
||||
int charNum = _charNums[msg.keycode - Common::KEYCODE_a];
|
||||
|
||||
if (msg.flags & Common::KBD_CTRL) {
|
||||
// Toggle in party
|
||||
if (_partyChars.contains(charNum))
|
||||
_partyChars.remove(charNum);
|
||||
else
|
||||
_partyChars.push_back(charNum);
|
||||
|
||||
setButtonEnabled(0, !_partyChars.empty());
|
||||
redraw();
|
||||
|
||||
} else {
|
||||
// View character
|
||||
g_globals->_currCharacter = &g_globals->_roster[charNum];
|
||||
_characterView.addView();
|
||||
}
|
||||
return true;
|
||||
|
||||
} else if (msg.keycode == Common::KEYCODE_x) {
|
||||
exitInn();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Inn::msgAction(const ActionMessage &msg) {
|
||||
switch (msg._action) {
|
||||
case KEYBIND_ESCAPE:
|
||||
replaceView("MainMenu");
|
||||
return true;
|
||||
case KEYBIND_SELECT:
|
||||
exitInn();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Inn::exitInn() {
|
||||
if (_partyChars.empty())
|
||||
return;
|
||||
|
||||
// Load party from selected characters
|
||||
g_globals->_party.clear();
|
||||
for (uint i = 0; i < _partyChars.size(); ++i)
|
||||
g_globals->_party.push_back(
|
||||
g_globals->_roster[_partyChars[i]]);
|
||||
g_globals->_currCharacter = &g_globals->_party.front();
|
||||
|
||||
// Load the given town
|
||||
g_globals->_maps.loadTown(g_globals->_startingTown);
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
61
engines/mm/mm1/views_enh/locations/inn.h
Normal file
61
engines/mm/mm1/views_enh/locations/inn.h
Normal 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_LOCATIONS_INN_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_INN_H
|
||||
|
||||
#include "mm/mm1/views_enh/scroll_view.h"
|
||||
#include "mm/mm1/views_enh/character_view.h"
|
||||
#include "mm/mm1/data/character.h"
|
||||
#include "mm/mm1/data/int_array.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Inn : public ScrollView {
|
||||
private:
|
||||
CharacterView _characterView;
|
||||
Shared::Xeen::SpriteResource _escSprite;
|
||||
Common::Array<uint> _charNums;
|
||||
IntArray _partyChars;
|
||||
|
||||
/**
|
||||
* Exit the Inn
|
||||
*/
|
||||
void exitInn();
|
||||
public:
|
||||
Inn();
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
bool msgMouseDown(const MouseDownMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
111
engines/mm/mm1/views_enh/locations/location.cpp
Normal file
111
engines/mm/mm1/views_enh/locations/location.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/locations/location.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
#include "mm/shared/utils/strings.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Location::Location(const Common::String &name, int locationId) :
|
||||
PartyView(name), _locationId(locationId) {
|
||||
_bounds = Common::Rect(232, 0, 320, 146);
|
||||
_escSprite.load("esc.icn");
|
||||
}
|
||||
|
||||
bool Location::msgGame(const GameMessage &msg) {
|
||||
if (msg._name == "DISPLAY") {
|
||||
send("View", GameMessage("LOCATION", _locationId));
|
||||
addView();
|
||||
return true;
|
||||
} else {
|
||||
return PartyView::msgGame(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void Location::leave() {
|
||||
if (g_events->focusedView() == this)
|
||||
close();
|
||||
|
||||
send("View", GameMessage("LOCATION", -1));
|
||||
|
||||
g_maps->turnAround();
|
||||
g_events->redraw();
|
||||
}
|
||||
|
||||
void Location::displayMessage(const Common::String &msg) {
|
||||
InfoMessage infoMsg(0, 0, msg, ALIGN_MIDDLE);
|
||||
infoMsg._delaySeconds = 3;
|
||||
infoMsg._callback = []() {
|
||||
Location *loc = dynamic_cast<Location *>(g_events->focusedView());
|
||||
assert(loc);
|
||||
loc->messageShown();
|
||||
};
|
||||
|
||||
g_events->send(infoMsg);
|
||||
}
|
||||
|
||||
bool Location::subtractGold(uint amount) {
|
||||
if (g_globals->_currCharacter->_gold < amount) {
|
||||
notEnoughGold();
|
||||
return false;
|
||||
} else {
|
||||
g_globals->_currCharacter->_gold -= amount;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Location::notEnoughGold() {
|
||||
Sound::sound(SOUND_2);
|
||||
displayMessage(STRING["dialogs.misc.not_enough_gold"]);
|
||||
}
|
||||
|
||||
void Location::backpackFull() {
|
||||
Sound::sound(SOUND_2);
|
||||
displayMessage(STRING["dialogs.misc.backpack_full"]);
|
||||
}
|
||||
|
||||
bool Location::msgUnfocus(const UnfocusMessage &msg) {
|
||||
(void)PartyView::msgUnfocus(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Location::draw() {
|
||||
send("View", GameMessage("LOCATION_DRAW"));
|
||||
PartyView::draw();
|
||||
}
|
||||
|
||||
bool Location::tick() {
|
||||
// Locations have animated game backgrounds, so pass on tick
|
||||
// to the game view to let it update
|
||||
g_events->findView("View")->tick();
|
||||
redraw();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
104
engines/mm/mm1/views_enh/locations/location.h
Normal file
104
engines/mm/mm1/views_enh/locations/location.h
Normal file
@@ -0,0 +1,104 @@
|
||||
/* 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_LOCATION_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_LOCATION_H
|
||||
|
||||
#include "mm/mm1/views_enh/party_view.h"
|
||||
#include "mm/shared/xeen/sprites.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Location : public PartyView {
|
||||
protected:
|
||||
Shared::Xeen::SpriteResource _escSprite;
|
||||
int _locationId = -1;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called when an active timeout countdown expired
|
||||
*/
|
||||
void timeout() override {
|
||||
leave();
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract gold from current character
|
||||
*/
|
||||
bool subtractGold(uint amount);
|
||||
|
||||
/**
|
||||
* Display a message
|
||||
*/
|
||||
void displayMessage(const Common::String &msg);
|
||||
|
||||
/**
|
||||
* Displays not enough gold
|
||||
*/
|
||||
void notEnoughGold();
|
||||
|
||||
/**
|
||||
* Displays backpack is full
|
||||
*/
|
||||
void backpackFull();
|
||||
|
||||
public:
|
||||
Location(const Common::String &name, int locationId);
|
||||
|
||||
/**
|
||||
* Game message handler
|
||||
*/
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
|
||||
/**
|
||||
* Called when a message is finished being shown
|
||||
*/
|
||||
virtual void messageShown() {
|
||||
leave();
|
||||
}
|
||||
|
||||
/**
|
||||
* Leave the location, turning around
|
||||
*/
|
||||
void leave();
|
||||
|
||||
bool msgUnfocus(const UnfocusMessage &msg) override;
|
||||
|
||||
/**
|
||||
* Draw the location
|
||||
*/
|
||||
void draw() override;
|
||||
|
||||
/**
|
||||
* Tick handler
|
||||
*/
|
||||
bool tick() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
142
engines/mm/mm1/views_enh/locations/market.cpp
Normal file
142
engines/mm/mm1/views_enh/locations/market.cpp
Normal 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/locations/market.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/shared/utils/strings.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Market::Market() : Location("Market", LOC_MARKET) {
|
||||
addButton(&g_globals->_confirmIcons,
|
||||
Common::Point(_innerBounds.width() / 2 - 24,
|
||||
_innerBounds.height() - 22), 0, Common::KEYCODE_y);
|
||||
addButton(&g_globals->_confirmIcons,
|
||||
Common::Point(_innerBounds.width() / 2 + 4,
|
||||
_innerBounds.height() - 22), 2, Common::KEYCODE_n);
|
||||
}
|
||||
|
||||
bool Market::msgFocus(const FocusMessage &msg) {
|
||||
Location::msgFocus(msg);
|
||||
|
||||
Maps::Map &map = *g_maps->_currentMap;
|
||||
_foodCost = FOOD_COST[map[Maps::MAP_ID] - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Market::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeLine(0, STRING["enhdialogs.market.title"],ALIGN_MIDDLE);
|
||||
writeLine(1, STRING["enhdialogs.location.options"], ALIGN_MIDDLE);
|
||||
|
||||
writeLine(6, STRING["enhdialogs.market.buy_food"], ALIGN_MIDDLE);
|
||||
writeLine(7, Common::String::format("%d %s",
|
||||
_foodCost, STRING["dialogs.market.gp"].c_str()),
|
||||
ALIGN_MIDDLE);
|
||||
writeLine(10, STRING["enhdialogs.location.gold"], ALIGN_LEFT);
|
||||
|
||||
uint gold = g_globals->_party.getPartyGold();
|
||||
writeLine(10, Common::String::format("%d", gold), ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
bool Market::msgKeypress(const KeypressMessage &msg) {
|
||||
if (isDelayActive()) {
|
||||
// Any keypress after purchase made closes
|
||||
leave();
|
||||
return true;
|
||||
} else {
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_y:
|
||||
buyFood();
|
||||
return true;
|
||||
case Common::KEYCODE_n:
|
||||
leave();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Market::msgAction(const ActionMessage &msg) {
|
||||
if (msg._action == KEYBIND_SELECT) {
|
||||
buyFood();
|
||||
return true;
|
||||
} else if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
} else {
|
||||
return Location::msgAction(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Market::buyFood() {
|
||||
int numPurchases = 0;
|
||||
|
||||
for (uint i = 0; i < g_globals->_party.size(); ++i) {
|
||||
if (buyFood(&g_globals->_party[i]))
|
||||
++numPurchases;
|
||||
}
|
||||
|
||||
displayMessage(numPurchases ?
|
||||
STRING["enhdialogs.market.thankyou"] :
|
||||
STRING["enhdialogs.market.no_gold"]
|
||||
);
|
||||
}
|
||||
|
||||
bool Market::buyFood(Character *c) {
|
||||
if (c->_food == MAX_FOOD)
|
||||
return true;
|
||||
|
||||
int tempGold = (int)c->_gold - _foodCost;
|
||||
if (tempGold >= 0) {
|
||||
// Reduce character's gold
|
||||
c->_gold = tempGold;
|
||||
} else {
|
||||
// Fall back on any one in the party with gold
|
||||
uint i;
|
||||
for (i = 0; i < g_globals->_party.size(); ++i) {
|
||||
if (g_globals->_party[i]._gold >= _foodCost) {
|
||||
g_globals->_party[i]._gold -= _foodCost;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == g_globals->_party.size())
|
||||
return false;
|
||||
}
|
||||
|
||||
// Food purchased
|
||||
c->_food = MAX_FOOD;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
62
engines/mm/mm1/views_enh/locations/market.h
Normal file
62
engines/mm/mm1/views_enh/locations/market.h
Normal 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_LOCATIONS_MARKET_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_MARKET_H
|
||||
|
||||
#include "mm/mm1/views_enh/locations/location.h"
|
||||
#include "mm/mm1/data/character.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Market : public Location, public MarketData {
|
||||
private:
|
||||
uint _foodCost = 0;
|
||||
private:
|
||||
/**
|
||||
* Buys food for party
|
||||
*/
|
||||
void buyFood();
|
||||
|
||||
/**
|
||||
* Has a single character buy food
|
||||
*/
|
||||
bool buyFood(Character *c);
|
||||
|
||||
public:
|
||||
Market();
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
168
engines/mm/mm1/views_enh/locations/tavern.cpp
Normal file
168
engines/mm/mm1/views_enh/locations/tavern.cpp
Normal file
@@ -0,0 +1,168 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/locations/tavern.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Tavern::Tavern() : Location("Tavern", LOC_TAVERN) {
|
||||
addButton(&_escSprite, Common::Point(24, 100), 0, KEYBIND_ESCAPE);
|
||||
}
|
||||
|
||||
void Tavern::draw() {
|
||||
Location::draw();
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
setReduced(false);
|
||||
writeLine(0, STRING["enhdialogs.tavern.title"], ALIGN_MIDDLE);
|
||||
writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
|
||||
writeLine(3, c._name, ALIGN_MIDDLE);
|
||||
|
||||
writeLine(5, STRING["enhdialogs.tavern.drink"], ALIGN_LEFT, 10);
|
||||
writeLine(6, STRING["enhdialogs.tavern.gather"], ALIGN_LEFT, 10);
|
||||
writeLine(7, STRING["enhdialogs.tavern.tip"], ALIGN_LEFT, 10);
|
||||
writeLine(8, STRING["enhdialogs.tavern.rumor"], ALIGN_LEFT, 10);
|
||||
|
||||
writeLine(10, STRING["enhdialogs.location.gold"]);
|
||||
writeLine(10, Common::String::format("%d",
|
||||
g_globals->_currCharacter->_gold), ALIGN_RIGHT);
|
||||
|
||||
setReduced(true);
|
||||
writeString(27, 122, STRING["enhdialogs.location.esc"]);
|
||||
}
|
||||
|
||||
bool Tavern::msgGame(const GameMessage &msg) {
|
||||
Location::msgGame(msg);
|
||||
/*
|
||||
if (msg._name == "UPDATE")
|
||||
checkCharacter();
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tavern::msgKeypress(const KeypressMessage &msg) {
|
||||
// If a delay is active, end it
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_d:
|
||||
haveADrink();
|
||||
break;
|
||||
case Common::KEYCODE_g:
|
||||
g_globals->_currCharacter->gatherGold();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_t:
|
||||
tipBartender();
|
||||
break;
|
||||
case Common::KEYCODE_r:
|
||||
listenForRumors();
|
||||
break;
|
||||
default:
|
||||
return Location::msgKeypress(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tavern::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return Location::msgAction(msg);
|
||||
}
|
||||
|
||||
void Tavern::messageShown() {
|
||||
redraw();
|
||||
}
|
||||
|
||||
|
||||
void Tavern::haveADrink() {
|
||||
if (g_globals->_currCharacter->_condition) {
|
||||
Sound::sound(SOUND_2);
|
||||
displayMessage(STRING["dialogs.tavern.terrible"]);
|
||||
|
||||
} else if (subtractGold(1)) {
|
||||
if (++g_globals->_currCharacter->_numDrinks < 3 ||
|
||||
g_engine->getRandomNumber(10) <
|
||||
g_globals->_currCharacter->_endurance) {
|
||||
displayMessage(STRING["dialogs.tavern.great_stuff"]);
|
||||
|
||||
} else {
|
||||
if (!(g_globals->_currCharacter->_condition & BAD_CONDITION))
|
||||
g_globals->_currCharacter->_condition |= POISONED;
|
||||
|
||||
Sound::sound(SOUND_2);
|
||||
displayMessage(STRING["dialogs.tavern.you_feel_sick"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tavern::tipBartender() {
|
||||
if (g_globals->_currCharacter->_condition) {
|
||||
displayMessage(STRING["dialogs.tavern.go_see_clerics"]);
|
||||
|
||||
} else if (subtractGold(1)) {
|
||||
if (g_globals->_currCharacter->_numDrinks == 0) {
|
||||
displayMessage(STRING["dialogs.tavern.have_a_drink"]);
|
||||
|
||||
} else if (g_engine->getRandomNumber(3) != 3) {
|
||||
displayMessage(STRING["dialogs.tavern.have_another_round"]);
|
||||
|
||||
} else {
|
||||
int townNum = g_maps->_currentMap->dataByte(Maps::MAP_ID);
|
||||
displayMessage(STRING[Common::String::format(
|
||||
"dialogs.tavern.tips.%d_%d",
|
||||
townNum, g_globals->_currCharacter->_numDrinks
|
||||
)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Tavern::listenForRumors() {
|
||||
Common::String msg = STRING["dialogs.tavern.rumors.none"];
|
||||
if (!g_globals->_heardRumor) {
|
||||
g_globals->_heardRumor = true;
|
||||
msg = STRING[Common::String::format(
|
||||
"dialogs.tavern.rumors.%d",
|
||||
g_engine->getRandomNumber(16))];
|
||||
}
|
||||
|
||||
displayMessage(msg);
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
65
engines/mm/mm1/views_enh/locations/tavern.h
Normal file
65
engines/mm/mm1/views_enh/locations/tavern.h
Normal 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_LOCATIONS_TAVERN_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_TAVERN_H
|
||||
|
||||
#include "mm/mm1/views_enh/locations/location.h"
|
||||
#include "mm/mm1/data/character.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Tavern : public Location {
|
||||
private:
|
||||
/**
|
||||
* Have a drink
|
||||
*/
|
||||
void haveADrink();
|
||||
|
||||
/**
|
||||
* Tip the bartender
|
||||
*/
|
||||
void tipBartender();
|
||||
|
||||
/**
|
||||
* Listen for rumors
|
||||
*/
|
||||
void listenForRumors();
|
||||
|
||||
public:
|
||||
Tavern();
|
||||
|
||||
void draw() override;
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void messageShown() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
230
engines/mm/mm1/views_enh/locations/temple.cpp
Normal file
230
engines/mm/mm1/views_enh/locations/temple.cpp
Normal file
@@ -0,0 +1,230 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/locations/temple.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
#include "mm/shared/utils/strings.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Temple::Temple() : Location("Temple", LOC_TEMPLE) {
|
||||
addButton(&_escSprite, Common::Point(24, 100), 0, KEYBIND_ESCAPE);
|
||||
}
|
||||
|
||||
bool Temple::msgFocus(const FocusMessage &msg) {
|
||||
Location::msgFocus(msg);
|
||||
updateCosts();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Temple::draw() {
|
||||
Location::draw();
|
||||
|
||||
setReduced(false);
|
||||
writeLine(0, STRING["enhdialogs.temple.title"], ALIGN_MIDDLE);
|
||||
writeLine(1, STRING["enhdialogs.location.options_for"], ALIGN_MIDDLE);
|
||||
writeLine(3, camelCase(g_globals->_currCharacter->_name), ALIGN_MIDDLE);
|
||||
|
||||
setReduced(true);
|
||||
writeLine(5, STRING["enhdialogs.temple.heal"]);
|
||||
writeLine(6, STRING["enhdialogs.temple.uncurse"]);
|
||||
writeLine(7, STRING["enhdialogs.temple.realign"]);
|
||||
writeLine(8, STRING["enhdialogs.temple.donate"]);
|
||||
|
||||
writeLine(5, _healCost ?
|
||||
Common::String::format("%d", _healCost).c_str() : "----",
|
||||
ALIGN_RIGHT);
|
||||
writeLine(6, _uncurseCost ?
|
||||
Common::String::format("%d", _uncurseCost).c_str() : "----",
|
||||
ALIGN_RIGHT);
|
||||
writeLine(7, _alignmentCost ?
|
||||
Common::String::format("%d", _alignmentCost).c_str() : "----",
|
||||
ALIGN_RIGHT);
|
||||
writeLine(8, Common::String::format("%d", _donateCost).c_str(),
|
||||
ALIGN_RIGHT);
|
||||
|
||||
setReduced(false);
|
||||
writeLine(10, STRING["enhdialogs.location.gold"]);
|
||||
writeLine(10, Common::String::format("%d",
|
||||
g_globals->_currCharacter->_gold), ALIGN_RIGHT);
|
||||
|
||||
setReduced(true);
|
||||
writeString(27, 122, STRING["enhdialogs.location.esc"]);
|
||||
}
|
||||
|
||||
bool Temple::msgKeypress(const KeypressMessage &msg) {
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_h:
|
||||
restoreHealth();
|
||||
break;
|
||||
case Common::KEYCODE_u:
|
||||
uncurseItems();
|
||||
break;
|
||||
case Common::KEYCODE_r:
|
||||
restoreAlignment();
|
||||
break;
|
||||
case Common::KEYCODE_d:
|
||||
donate();
|
||||
break;
|
||||
case Common::KEYCODE_g:
|
||||
g_globals->_currCharacter->gatherGold();
|
||||
redraw();
|
||||
break;
|
||||
default:
|
||||
return Location::msgKeypress(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Temple::msgAction(const ActionMessage &msg) {
|
||||
switch (msg._action) {
|
||||
case KEYBIND_ESCAPE:
|
||||
leave();
|
||||
return true;
|
||||
default:
|
||||
return Location::msgAction(msg);
|
||||
}
|
||||
}
|
||||
|
||||
bool Temple::msgGame(const GameMessage &msg) {
|
||||
Location::msgGame(msg);
|
||||
if (msg._name == "UPDATE")
|
||||
updateCosts();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Temple::updateCosts() {
|
||||
Maps::Map &map = *g_maps->_currentMap;
|
||||
int i;
|
||||
_isEradicated = false;
|
||||
|
||||
int townNum = map[Maps::MAP_ID];
|
||||
if (townNum < 1 || townNum >= 6)
|
||||
townNum = 1;
|
||||
--townNum;
|
||||
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
|
||||
_healCost = 0;
|
||||
if (c._condition == ERADICATED) {
|
||||
_healCost = HEAL_COST1[townNum];
|
||||
_isEradicated = true;
|
||||
} else if (c._condition & BAD_CONDITION) {
|
||||
_healCost = HEAL_COST2[townNum];
|
||||
} else if (c._condition || c._hp < c._hpMax) {
|
||||
_healCost = HEAL_COST3[townNum];
|
||||
}
|
||||
|
||||
_uncurseCost = UNCURSE_COST[townNum];
|
||||
for (i = 0; i < INVENTORY_COUNT; ++i) {
|
||||
if (c._equipped[i]) {
|
||||
if (g_globals->_items.getItem(c._equipped[i])->_constBonus_id == EQUIP_CURSED)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == INVENTORY_COUNT)
|
||||
_uncurseCost = 0;
|
||||
|
||||
_alignmentCost = ALIGNMENT_COST[townNum];
|
||||
if (c._alignment == c._alignmentInitial)
|
||||
_alignmentCost = 0;
|
||||
|
||||
_donateCost = DONATE_COST[townNum];
|
||||
}
|
||||
|
||||
void Temple::restoreHealth() {
|
||||
if (subtractGold(_healCost)) {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
c._condition = FINE;
|
||||
c._hpCurrent = c._hp;
|
||||
|
||||
if (_isEradicated) {
|
||||
c._age += 10;
|
||||
--c._endurance;
|
||||
}
|
||||
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void Temple::uncurseItems() {
|
||||
if (subtractGold(_uncurseCost)) {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
for (int i = 0; i < INVENTORY_COUNT; ++i) {
|
||||
if (c._equipped[i]) {
|
||||
g_globals->_items.getItem(c._equipped[i]);
|
||||
if (g_globals->_currItem._constBonus_id == EQUIP_CURSED) {
|
||||
c._equipped.removeAt(i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void Temple::restoreAlignment() {
|
||||
if (subtractGold(_alignmentCost)) {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
c._alignment = c._alignmentInitial;
|
||||
c._alignmentCtr = ALIGNMENT_VALS[c._alignment];
|
||||
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
void Temple::donate() {
|
||||
if (subtractGold(_donateCost)) {
|
||||
Maps::Map &map = *g_maps->_currentMap;
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
|
||||
int townNum = map[Maps::MAP_ID];
|
||||
if (townNum < 1 || townNum >= 6)
|
||||
townNum = 1;
|
||||
--townNum;
|
||||
|
||||
c._worthiness |= DONATE_VALS[townNum];
|
||||
draw();
|
||||
|
||||
if (g_engine->getRandomNumber(15) == 10) {
|
||||
for (int i = 0; i < 13; ++i)
|
||||
g_globals->_activeSpells._arr[i] = 75;
|
||||
|
||||
Sound::sound(SOUND_3);
|
||||
displayMessage(STRING["dialogs.temple.protected"]);
|
||||
} else {
|
||||
displayMessage(STRING["dialogs.temple.thankyou"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
61
engines/mm/mm1/views_enh/locations/temple.h
Normal file
61
engines/mm/mm1/views_enh/locations/temple.h
Normal 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_LOCATIONS_TEMPLE_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_TEMPLE_H
|
||||
|
||||
#include "mm/mm1/views_enh/locations/location.h"
|
||||
#include "mm/mm1/data/character.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Temple : public Location, public TempleData {
|
||||
private:
|
||||
bool _isEradicated = false;
|
||||
int _healCost = 0, _uncurseCost = 0;
|
||||
int _alignmentCost = 0, _donateCost = 0;
|
||||
private:
|
||||
void updateCosts();
|
||||
void restoreHealth();
|
||||
void uncurseItems();
|
||||
void restoreAlignment();
|
||||
void donate();
|
||||
|
||||
public:
|
||||
Temple();
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
208
engines/mm/mm1/views_enh/locations/training.cpp
Normal file
208
engines/mm/mm1/views_enh/locations/training.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/locations/training.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
#include "mm/shared/utils/strings.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
Training::Training() : Location("Training", LOC_TRAINING) {
|
||||
_trainSprite.load("train.icn");
|
||||
addButton(&_trainSprite, Common::Point(5, 100), 2, Common::KEYCODE_t);
|
||||
addButton(&_escSprite, Common::Point(40, 100), 0, KEYBIND_ESCAPE);
|
||||
}
|
||||
|
||||
bool Training::msgFocus(const FocusMessage &msg) {
|
||||
Location::msgFocus(msg);
|
||||
checkCharacter();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Training::draw() {
|
||||
Location::draw();
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
setReduced(false);
|
||||
writeLine(0, STRING["enhdialogs.training.title"], ALIGN_MIDDLE);
|
||||
writeLine(1, STRING["enhdialogs.location.options"], ALIGN_MIDDLE);
|
||||
|
||||
if (_currLevel >= MAX_LEVEL) {
|
||||
writeLine(3, c._name, ALIGN_MIDDLE);
|
||||
writeLine(5, STRING["dialogs.training.no_way"], ALIGN_MIDDLE);
|
||||
|
||||
} else if (_remainingExp > 0) {
|
||||
writeLine(3, Common::String::format(
|
||||
STRING["enhdialogs.training.needs"].c_str(),
|
||||
c._name, _remainingExp, _currLevel + 1), ALIGN_MIDDLE);
|
||||
|
||||
} else {
|
||||
writeLine(3, Common::String::format(
|
||||
STRING["enhdialogs.training.eligible"].c_str(),
|
||||
c._name, _currLevel + 1), ALIGN_MIDDLE);
|
||||
}
|
||||
|
||||
writeLine(10, STRING["enhdialogs.location.gold"]);
|
||||
writeLine(10, Common::String::format("%d", c._gold), ALIGN_RIGHT);
|
||||
|
||||
setReduced(true);
|
||||
writeString(5, 122, STRING["enhdialogs.training.train"]);
|
||||
writeString(43, 122, STRING["enhdialogs.training.esc"]);
|
||||
}
|
||||
|
||||
bool Training::msgGame(const GameMessage &msg) {
|
||||
Location::msgGame(msg);
|
||||
if (msg._name == "UPDATE")
|
||||
checkCharacter();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Training::msgKeypress(const KeypressMessage &msg) {
|
||||
// If a delay is active, end it
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_t:
|
||||
if (_canTrain)
|
||||
train();
|
||||
break;
|
||||
case Common::KEYCODE_g:
|
||||
g_globals->_currCharacter->gatherGold();
|
||||
redraw();
|
||||
break;
|
||||
default:
|
||||
return Location::msgKeypress(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Training::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return Location::msgAction(msg);
|
||||
}
|
||||
|
||||
void Training::checkCharacter() {
|
||||
assert(g_globals->_currCharacter);
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
|
||||
_currLevel = c._level._base;
|
||||
if (_currLevel >= MAX_LEVEL) {
|
||||
_canTrain = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize fields
|
||||
_expTotal = 0;
|
||||
_remainingExp = 0;
|
||||
_expAmount = 0;
|
||||
_cost = _cost2 = 0;
|
||||
_canTrain = false;
|
||||
_canAfford = false;
|
||||
_class = c._class;
|
||||
|
||||
if (_class == KNIGHT || _class == CLERIC || _class == ROBBER) {
|
||||
_expTotal = 1500;
|
||||
_expAmount = 150000;
|
||||
|
||||
if (_currLevel != 0) {
|
||||
_cost = _currLevel >= 8 ? 3000 :
|
||||
TRAINING_COSTS1[_currLevel - 1];
|
||||
}
|
||||
} else {
|
||||
_expTotal = 2000;
|
||||
_expAmount = 200000;
|
||||
_cost = _currLevel >= 8 ? 4000 :
|
||||
TRAINING_COSTS2[_currLevel - 1];
|
||||
}
|
||||
|
||||
for (int level = _currLevel - 1, ctr = 0; level > 0; --level) {
|
||||
_expTotal *= 16;
|
||||
|
||||
if (++ctr >= 7) {
|
||||
while (--level > 0)
|
||||
_expTotal += _expAmount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_remainingExp = _expTotal - c._exp;
|
||||
_canTrain = _remainingExp <= 0;
|
||||
_canAfford = (int)c._gold >= _cost;
|
||||
}
|
||||
|
||||
void Training::train() {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
|
||||
if (c._condition) {
|
||||
// Having a condition prevents characters from training
|
||||
Sound::sound(SOUND_3);
|
||||
displayMessage(STRING["dialogs.training.condition"]);
|
||||
|
||||
} else if (!_canAfford) {
|
||||
// Can't afford training
|
||||
notEnoughGold();
|
||||
|
||||
} else {
|
||||
// Do the actual training
|
||||
c._gold -= _cost;
|
||||
Character::LevelIncrease lvl = c.increaseLevel();
|
||||
Sound::sound(SOUND_2);
|
||||
|
||||
Common::String msg = Common::String::format("%s%d",
|
||||
STRING["dialogs.training.congrats"].c_str(),
|
||||
c._level._base);
|
||||
|
||||
msg = Common::String::format(STRING["dialogs.training.hp"].c_str(),
|
||||
lvl._numHP);
|
||||
|
||||
if (lvl._numSpells != 0) {
|
||||
msg += ". ";
|
||||
msg += STRING["dialogs.training.new_spells"];
|
||||
}
|
||||
|
||||
displayMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void Training::messageShown() {
|
||||
checkCharacter();
|
||||
redraw();
|
||||
}
|
||||
|
||||
} // namespace Location
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
72
engines/mm/mm1/views_enh/locations/training.h
Normal file
72
engines/mm/mm1/views_enh/locations/training.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MM1_VIEWS_ENH_LOCATIONS_TRAINING_H
|
||||
#define MM1_VIEWS_ENH_LOCATIONS_TRAINING_H
|
||||
|
||||
#include "mm/mm1/views_enh/locations/location.h"
|
||||
#include "mm/mm1/data/character.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Locations {
|
||||
|
||||
class Training : public Location, public TrainingData {
|
||||
private:
|
||||
Shared::Xeen::SpriteResource _trainSprite;
|
||||
int _currLevel = 0;
|
||||
CharacterClass _class = KNIGHT;
|
||||
int _expTotal = 0;
|
||||
int _remainingExp = 0;
|
||||
int _expAmount = 0;
|
||||
int _cost = 0, _cost2;
|
||||
bool _canTrain = false;
|
||||
bool _canAfford = false;
|
||||
private:
|
||||
/**
|
||||
* Checks whether a character can train
|
||||
*/
|
||||
void checkCharacter();
|
||||
|
||||
/**
|
||||
* Validates if training is allowed, then trains.
|
||||
*/
|
||||
void train();
|
||||
|
||||
public:
|
||||
Training();
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void messageShown() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user