Initial commit
This commit is contained in:
96
engines/mm/mm1/views/locations/blacksmith.cpp
Normal file
96
engines/mm/mm1/views/locations/blacksmith.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
/* 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/locations/blacksmith.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
Blacksmith::Blacksmith() : Location("Blacksmith") {
|
||||
}
|
||||
|
||||
bool Blacksmith::msgFocus(const FocusMessage &msg) {
|
||||
send("View", GameMessage("LOCATION", LOC_BLACKSMITH));
|
||||
changeCharacter(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Blacksmith::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(22, 1, STRING["dialogs.blacksmith.a"]);
|
||||
writeString(22, 2, STRING["dialogs.blacksmith.b"]);
|
||||
writeString(22, 3, STRING["dialogs.blacksmith.c"]);
|
||||
writeString(22, 4, STRING["dialogs.blacksmith.d"]);
|
||||
}
|
||||
|
||||
bool Blacksmith::msgKeypress(const KeypressMessage &msg) {
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_1:
|
||||
case Common::KEYCODE_2:
|
||||
case Common::KEYCODE_3:
|
||||
case Common::KEYCODE_4:
|
||||
case Common::KEYCODE_5:
|
||||
case Common::KEYCODE_6:
|
||||
changeCharacter(msg.keycode - Common::KEYCODE_1);
|
||||
break;
|
||||
case Common::KEYCODE_a:
|
||||
_buyWeapons.addView();
|
||||
break;
|
||||
case Common::KEYCODE_b:
|
||||
_buyArmor.addView();
|
||||
break;
|
||||
case Common::KEYCODE_c:
|
||||
_buyMisc.addView();
|
||||
break;
|
||||
case Common::KEYCODE_d:
|
||||
_sellItem.addView();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Blacksmith::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
57
engines/mm/mm1/views/locations/blacksmith.h
Normal file
57
engines/mm/mm1/views/locations/blacksmith.h
Normal 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_LOCATIONS_BLACKSMITH_H
|
||||
#define MM1_VIEWS_LOCATIONS_BLACKSMITH_H
|
||||
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
#include "mm/mm1/views/locations/blacksmith_buy_weapons.h"
|
||||
#include "mm/mm1/views/locations/blacksmith_buy_armor.h"
|
||||
#include "mm/mm1/views/locations/blacksmith_buy_misc.h"
|
||||
#include "mm/mm1/views/locations/blacksmith_sell_item.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Blacksmith : public Location {
|
||||
private:
|
||||
BlacksmithBuyWeapons _buyWeapons;
|
||||
BlacksmithBuyArmor _buyArmor;
|
||||
BlacksmithBuyMisc _buyMisc;
|
||||
BlacksmithSellItem _sellItem;
|
||||
public:
|
||||
Blacksmith();
|
||||
virtual ~Blacksmith() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
57
engines/mm/mm1/views/locations/blacksmith_buy_armor.cpp
Normal file
57
engines/mm/mm1/views/locations/blacksmith_buy_armor.cpp
Normal 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/locations/blacksmith_buy_armor.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
BlacksmithBuyArmor::BlacksmithBuyArmor() :
|
||||
BlacksmithSubview("BlacksmithBuyArmor") {
|
||||
_modeString = STRING["dialogs.location.buy"];
|
||||
}
|
||||
|
||||
bool BlacksmithBuyArmor::msgFocus(const FocusMessage &msg) {
|
||||
int townNum = g_maps->_currentMap->dataByte(Maps::MAP_ID);
|
||||
if (townNum < 1 || townNum >= 6)
|
||||
townNum = 1;
|
||||
_items = ARMOR[townNum - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlacksmithBuyArmor::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(23, 0, STRING["dialogs.blacksmith.armor"]);
|
||||
drawItems();
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
47
engines/mm/mm1/views/locations/blacksmith_buy_armor.h
Normal file
47
engines/mm/mm1/views/locations/blacksmith_buy_armor.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_LOCATIONS_BLACKSMITH_BUY_ARMOR_H
|
||||
#define MM1_VIEWS_LOCATIONS_BLACKSMITH_BUY_ARMOR_H
|
||||
|
||||
#include "mm/mm1/views/locations/blacksmith_subview.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class BlacksmithBuyArmor : public BlacksmithSubview, public BuyArmorData {
|
||||
public:
|
||||
BlacksmithBuyArmor();
|
||||
virtual ~BlacksmithBuyArmor() {}
|
||||
|
||||
void draw() override;
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
57
engines/mm/mm1/views/locations/blacksmith_buy_misc.cpp
Normal file
57
engines/mm/mm1/views/locations/blacksmith_buy_misc.cpp
Normal 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/locations/blacksmith_buy_misc.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
BlacksmithBuyMisc::BlacksmithBuyMisc() :
|
||||
BlacksmithSubview("BlacksmithBuyMisc") {
|
||||
_modeString = STRING["dialogs.location.buy"];
|
||||
}
|
||||
|
||||
bool BlacksmithBuyMisc::msgFocus(const FocusMessage &msg) {
|
||||
int townNum = g_maps->_currentMap->dataByte(Maps::MAP_ID);
|
||||
if (townNum < 1 || townNum >= 6)
|
||||
townNum = 1;
|
||||
_items = MISC[townNum - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlacksmithBuyMisc::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(23, 0, STRING["dialogs.blacksmith.misc"]);
|
||||
drawItems();
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
47
engines/mm/mm1/views/locations/blacksmith_buy_misc.h
Normal file
47
engines/mm/mm1/views/locations/blacksmith_buy_misc.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_LOCATIONS_BLACKSMITH_BUY_MISC_H
|
||||
#define MM1_VIEWS_LOCATIONS_BLACKSMITH_BUY_MISC_H
|
||||
|
||||
#include "mm/mm1/views/locations/blacksmith_subview.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class BlacksmithBuyMisc : public BlacksmithSubview,
|
||||
public BuyMiscData {
|
||||
public:
|
||||
BlacksmithBuyMisc();
|
||||
virtual ~BlacksmithBuyMisc() {}
|
||||
|
||||
void draw() override;
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
57
engines/mm/mm1/views/locations/blacksmith_buy_weapons.cpp
Normal file
57
engines/mm/mm1/views/locations/blacksmith_buy_weapons.cpp
Normal 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/locations/blacksmith_buy_weapons.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
BlacksmithBuyWeapons::BlacksmithBuyWeapons() :
|
||||
BlacksmithSubview("BlacksmithBuyWeapons") {
|
||||
_modeString = STRING["dialogs.location.buy"];
|
||||
}
|
||||
|
||||
bool BlacksmithBuyWeapons::msgFocus(const FocusMessage &msg) {
|
||||
int townNum = g_maps->_currentMap->dataByte(Maps::MAP_ID);
|
||||
if (townNum < 1 || townNum >= 6)
|
||||
townNum = 1;
|
||||
_items = WEAPONS[townNum - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BlacksmithBuyWeapons::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(23, 0, STRING["dialogs.blacksmith.weapons"]);
|
||||
drawItems();
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
47
engines/mm/mm1/views/locations/blacksmith_buy_weapons.h
Normal file
47
engines/mm/mm1/views/locations/blacksmith_buy_weapons.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_LOCATIONS_BLACKSMITH_BUY_WEAPONS_H
|
||||
#define MM1_VIEWS_LOCATIONS_BLACKSMITH_BUY_WEAPONS_H
|
||||
|
||||
#include "mm/mm1/views/locations/blacksmith_subview.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class BlacksmithBuyWeapons : public BlacksmithSubview, public BuyWeaponData {
|
||||
public:
|
||||
BlacksmithBuyWeapons();
|
||||
virtual ~BlacksmithBuyWeapons() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
74
engines/mm/mm1/views/locations/blacksmith_sell_item.cpp
Normal file
74
engines/mm/mm1/views/locations/blacksmith_sell_item.cpp
Normal 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/locations/blacksmith_sell_item.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
BlacksmithSellItem::BlacksmithSellItem() :
|
||||
BlacksmithSubview("BlacksmithSellItem") {
|
||||
_modeString = STRING["dialogs.location.sell"];
|
||||
}
|
||||
|
||||
void BlacksmithSellItem::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(22, 0, STRING["dialogs.blacksmith.backpack"]);
|
||||
drawItems();
|
||||
}
|
||||
|
||||
void BlacksmithSellItem::drawItems() {
|
||||
const Inventory &inv = g_globals->_currCharacter->_backpack;
|
||||
|
||||
for (uint idx = 0; idx < INVENTORY_COUNT; ++idx) {
|
||||
writeChar(17, 1 + idx, 'A' + idx);
|
||||
writeString(") ");
|
||||
|
||||
if (idx < inv.size()) {
|
||||
g_globals->_items.getItem(inv[idx]._id);
|
||||
writeString(g_globals->_currItem._name);
|
||||
_textPos.x = 35;
|
||||
writeNumber(g_globals->_currItem.getSellCost());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void BlacksmithSellItem::selectItem(uint index) {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
Inventory &inv = c._backpack;
|
||||
assert(index < inv.size());
|
||||
g_globals->_items.getItem(inv[index]._id);
|
||||
|
||||
c._gold += g_globals->_currItem.getSellCost();
|
||||
inv.removeAt(index);
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
53
engines/mm/mm1/views/locations/blacksmith_sell_item.h
Normal file
53
engines/mm/mm1/views/locations/blacksmith_sell_item.h
Normal 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_LOCATIONS_BLACKSMITH_SELL_ITEM_H
|
||||
#define MM1_VIEWS_LOCATIONS_BLACKSMITH_SELL_ITEM_H
|
||||
|
||||
#include "mm/mm1/views/locations/blacksmith_subview.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class BlacksmithSellItem : public BlacksmithSubview {
|
||||
private:
|
||||
void drawItems();
|
||||
protected:
|
||||
/**
|
||||
* Selects an item from the list
|
||||
*/
|
||||
void selectItem(uint index) override;
|
||||
|
||||
public:
|
||||
BlacksmithSellItem();
|
||||
virtual ~BlacksmithSellItem() {}
|
||||
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
105
engines/mm/mm1/views/locations/blacksmith_subview.cpp
Normal file
105
engines/mm/mm1/views/locations/blacksmith_subview.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
/* 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/locations/blacksmith_subview.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
void BlacksmithSubview::drawItems() {
|
||||
for (int idx = 0; idx < INVENTORY_COUNT; ++idx) {
|
||||
writeChar(17, 1 + idx, 'A' + idx);
|
||||
writeString(") ");
|
||||
|
||||
g_globals->_items.getItem(_items[idx]);
|
||||
drawIsAllowed();
|
||||
writeString(g_globals->_currItem._name);
|
||||
_textPos.x = 35;
|
||||
writeNumber(g_globals->_currItem._cost);
|
||||
}
|
||||
}
|
||||
|
||||
void BlacksmithSubview::drawIsAllowed() {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
|
||||
if (c._class != NONE && c._class <= ROBBER) {
|
||||
if (!(BLACKSMITH_CLASS_USAGE[c._class - 1] &
|
||||
g_globals->_currItem._disablements))
|
||||
return;
|
||||
}
|
||||
|
||||
_textPos.x--;
|
||||
writeChar('-');
|
||||
}
|
||||
|
||||
bool BlacksmithSubview::msgKeypress(const KeypressMessage &msg) {
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_a:
|
||||
case Common::KEYCODE_b:
|
||||
case Common::KEYCODE_c:
|
||||
case Common::KEYCODE_d:
|
||||
case Common::KEYCODE_e:
|
||||
case Common::KEYCODE_f:
|
||||
selectItem(msg.keycode - Common::KEYCODE_a);
|
||||
draw();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BlacksmithSubview::msgAction(const ActionMessage &msg) {
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
close();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BlacksmithSubview::selectItem(uint index) {
|
||||
switch (g_globals->_currCharacter->buyItem(
|
||||
_items[index])) {
|
||||
case Character::BUY_BACKPACK_FULL:
|
||||
backpackFull();
|
||||
break;
|
||||
case Character::BUY_NOT_ENOUGH_GOLD:
|
||||
notEnoughGold();
|
||||
break;
|
||||
default:
|
||||
// Purchased successfully
|
||||
displayMessage(15, STRING["dialogs.blacksmith.thankyou"]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
64
engines/mm/mm1/views/locations/blacksmith_subview.h
Normal file
64
engines/mm/mm1/views/locations/blacksmith_subview.h
Normal 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_LOCATIONS_BLACKSMITH_SUBVIEW_H
|
||||
#define MM1_VIEWS_LOCATIONS_BLACKSMITH_SUBVIEW_H
|
||||
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class BlacksmithSubview : public Location, public BlacksmithData {
|
||||
protected:
|
||||
const byte *_items = nullptr;
|
||||
private:
|
||||
/**
|
||||
* For an item draws the character if the item is
|
||||
* not allowed for the character's class
|
||||
*/
|
||||
void drawIsAllowed();
|
||||
protected:
|
||||
/**
|
||||
* Draws a list of items
|
||||
*/
|
||||
void drawItems();
|
||||
|
||||
/**
|
||||
* Selects an item from the list
|
||||
*/
|
||||
virtual void selectItem(uint index);
|
||||
public:
|
||||
BlacksmithSubview(const Common::String &name) : Location(name) {}
|
||||
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
167
engines/mm/mm1/views/locations/inn.cpp
Normal file
167
engines/mm/mm1/views/locations/inn.cpp
Normal file
@@ -0,0 +1,167 @@
|
||||
/* 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/locations/inn.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
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() {
|
||||
drawTextBorder();
|
||||
|
||||
writeString(10, 0, Common::String::format(
|
||||
STRING["dialogs.inn.title"].c_str(),
|
||||
'0' + g_globals->_startingTown));
|
||||
writeString(STRING[Common::String::format(
|
||||
"stats.towns.%d", g_globals->_startingTown)]);
|
||||
escToGoBack();
|
||||
|
||||
if (_charNums.empty()) {
|
||||
writeString(8, 5, STRING["dialogs.misc.no_characters"]);
|
||||
} else {
|
||||
writeString(10, 3, STRING["dialogs.misc.some_characters"]);
|
||||
|
||||
for (uint idx = 0; idx < _charNums.size(); ++idx) {
|
||||
uint charNum = _charNums[idx];
|
||||
Character &re = g_globals->_roster[charNum];
|
||||
|
||||
_textPos = (idx < 9) ? Common::Point(2, 6 + idx) :
|
||||
Common::Point(20, 6 + idx - 9);
|
||||
|
||||
// Write character
|
||||
writeChar(_partyChars.contains(charNum) ? '@' : ' ');
|
||||
writeChar('A' + idx);
|
||||
writeChar(')');
|
||||
writeString(re._name);
|
||||
}
|
||||
|
||||
Common::String range = Common::String::format("'A'-'%c' ",
|
||||
'A' + _charNums.size() - 1);
|
||||
writeString(13, 19, range);
|
||||
writeString(STRING["dialogs.inn.to_view"]);
|
||||
writeString(6, 20, STRING["dialogs.inn.ctrl"]);
|
||||
writeString(range);
|
||||
writeString(STRING["dialogs.inn.add_remove"]);
|
||||
|
||||
if (!_partyChars.empty())
|
||||
writeString(13, 22, STRING["dialogs.inn.exit"]);
|
||||
if (_partyChars.size() == 6)
|
||||
writeString(10, 16, STRING["dialogs.inn.full"]);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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 Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
62
engines/mm/mm1/views/locations/inn.h
Normal file
62
engines/mm/mm1/views/locations/inn.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_LOCATIONS_INN_H
|
||||
#define MM1_VIEWS_LOCATIONS_INN_H
|
||||
|
||||
#include "mm/mm1/views/text_view.h"
|
||||
#include "mm/mm1/views/character_view.h"
|
||||
#include "mm/mm1/data/int_array.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Inn : public TextView {
|
||||
private:
|
||||
CharacterView _characterView;
|
||||
Common::Array<uint> _charNums;
|
||||
IntArray _partyChars;
|
||||
|
||||
/**
|
||||
* Exit the Inn
|
||||
*/
|
||||
void exitInn();
|
||||
|
||||
public:
|
||||
Inn() : TextView("Inn") {
|
||||
}
|
||||
virtual ~Inn() {
|
||||
}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
void draw() override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
109
engines/mm/mm1/views/locations/location.cpp
Normal file
109
engines/mm/mm1/views/locations/location.cpp
Normal file
@@ -0,0 +1,109 @@
|
||||
/* 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/locations/location.h"
|
||||
#include "mm/mm1/maps/maps.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
#define DISPLAY_SECONDS 5
|
||||
|
||||
Location::Location(const Common::String &name) : TextView(name) {
|
||||
_bounds = getLineBounds(17, 24);
|
||||
_modeString = STRING["dialogs.location.gather"];
|
||||
}
|
||||
|
||||
bool Location::msgGame(const GameMessage &msg) {
|
||||
if (msg._name == "DISPLAY") {
|
||||
addView();
|
||||
return true;
|
||||
}
|
||||
|
||||
return TextView::msgGame(msg);
|
||||
}
|
||||
|
||||
void Location::draw() {
|
||||
clearSurface();
|
||||
writeString(0, 0, g_globals->_currCharacter->_name);
|
||||
newLine();
|
||||
writeString(STRING["dialogs.location.gold"]);
|
||||
writeNumber(g_globals->_currCharacter->_gold);
|
||||
newLine();
|
||||
newLine();
|
||||
writeString(_modeString);
|
||||
writeString(0, 6, STRING["dialogs.misc.go_back"]);
|
||||
}
|
||||
|
||||
void Location::displayMessage(int x, const Common::String &msg) {
|
||||
clearLines(3, 7);
|
||||
writeString(x, 5, msg);
|
||||
delaySeconds(DISPLAY_SECONDS);
|
||||
}
|
||||
|
||||
void Location::newLine() {
|
||||
_textPos.x = 0;
|
||||
if (++_textPos.y >= 24)
|
||||
_textPos.y = 0;
|
||||
}
|
||||
|
||||
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"]);
|
||||
}
|
||||
|
||||
void Location::changeCharacter(uint index) {
|
||||
if (index >= g_globals->_party.size())
|
||||
return;
|
||||
|
||||
g_globals->_currCharacter = &g_globals->_party[index];
|
||||
redraw();
|
||||
}
|
||||
|
||||
void Location::leave() {
|
||||
g_maps->turnAround();
|
||||
close();
|
||||
g_events->redraw();
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
95
engines/mm/mm1/views/locations/location.h
Normal file
95
engines/mm/mm1/views/locations/location.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/* 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_LOCATIONS_BUSINESS_H
|
||||
#define MM1_VIEWS_LOCATIONS_BUSINESS_H
|
||||
|
||||
#include "mm/mm1/views/text_view.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Location : public TextView {
|
||||
protected:
|
||||
Common::String _modeString;
|
||||
protected:
|
||||
/**
|
||||
* Clears the bottom part of the window and
|
||||
* displays a message
|
||||
*/
|
||||
void displayMessage(int x, const Common::String &msg);
|
||||
void displayMessage(const Common::String &msg) {
|
||||
displayMessage(0, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move text position to the next line
|
||||
*/
|
||||
void newLine();
|
||||
|
||||
/**
|
||||
* Leave the business
|
||||
*/
|
||||
void leave();
|
||||
|
||||
/**
|
||||
* Subtract gold from current character
|
||||
*/
|
||||
bool subtractGold(uint amount);
|
||||
|
||||
/**
|
||||
* Displays not enough gold
|
||||
*/
|
||||
void notEnoughGold();
|
||||
|
||||
/**
|
||||
* Displays backpack is full
|
||||
*/
|
||||
void backpackFull();
|
||||
|
||||
/**
|
||||
* Change character
|
||||
*/
|
||||
virtual void changeCharacter(uint index);
|
||||
|
||||
public:
|
||||
Location(const Common::String &name);
|
||||
virtual ~Location() {}
|
||||
|
||||
/**
|
||||
* Game message handler
|
||||
*/
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
|
||||
/**
|
||||
* Draws the initial display for the business
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
125
engines/mm/mm1/views/locations/market.cpp
Normal file
125
engines/mm/mm1/views/locations/market.cpp
Normal 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 "mm/mm1/views/locations/market.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
Market::Market() : Location("Market") {
|
||||
_bounds = getLineBounds(21, 24);
|
||||
}
|
||||
|
||||
bool Market::msgFocus(const FocusMessage &msg) {
|
||||
send("View", GameMessage("LOCATION", LOC_MARKET));
|
||||
|
||||
Maps::Map &map = *g_maps->_currentMap;
|
||||
_foodCost = FOOD_COST[map[Maps::MAP_ID] - 1];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Market::msgKeypress(const KeypressMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_n:
|
||||
msgAction(ActionMessage(KEYBIND_ESCAPE));
|
||||
break;
|
||||
case Common::KEYCODE_y:
|
||||
buyFood();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Market::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg._action) {
|
||||
case KEYBIND_ESCAPE:
|
||||
leave();
|
||||
return true;
|
||||
case KEYBIND_SELECT:
|
||||
buyFood();
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Market::draw() {
|
||||
clearSurface();
|
||||
|
||||
writeString(0, 0, STRING["dialogs.market.special"]);
|
||||
writeNumber(_foodCost);
|
||||
writeString(STRING["dialogs.market.gp"]);
|
||||
writeString(10, 2, STRING["dialogs.market.will_you_pay"]);
|
||||
}
|
||||
|
||||
void Market::buyFood() {
|
||||
int foodPurchased = 0;
|
||||
for (uint i = 0; i < g_globals->_party.size(); ++i) {
|
||||
if (buyFood(&g_globals->_party[i]))
|
||||
++foodPurchased;
|
||||
}
|
||||
|
||||
clearSurface();
|
||||
writeString(10, 2, foodPurchased ?
|
||||
STRING["dialogs.market.thankyou"] :
|
||||
STRING["dialogs.market.no_gold"]
|
||||
);
|
||||
|
||||
delaySeconds(3);
|
||||
}
|
||||
|
||||
bool Market::buyFood(Character *c) {
|
||||
int tempGold = (int)c->_gold - _foodCost;
|
||||
if (tempGold < 0)
|
||||
return false;
|
||||
|
||||
c->_gold = tempGold;
|
||||
c->_food = MAX_FOOD;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Market::timeout() {
|
||||
leave();
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
67
engines/mm/mm1/views/locations/market.h
Normal file
67
engines/mm/mm1/views/locations/market.h
Normal 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_LOCATIONS_MARKET_H
|
||||
#define MM1_VIEWS_LOCATIONS_MARKET_H
|
||||
|
||||
#include "mm/mm1/data/character.h"
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Market : public Location, public MarketData {
|
||||
private:
|
||||
int _foodCost = 0;
|
||||
private:
|
||||
/**
|
||||
* Buys food
|
||||
*/
|
||||
void buyFood();
|
||||
|
||||
/**
|
||||
* Has a single character buy food
|
||||
*/
|
||||
bool buyFood(Character *c);
|
||||
public:
|
||||
Market();
|
||||
virtual ~Market() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void draw() override;
|
||||
|
||||
/**
|
||||
* Leaves market after displaying result message
|
||||
*/
|
||||
void timeout() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
106
engines/mm/mm1/views/locations/statue.cpp
Normal file
106
engines/mm/mm1/views/locations/statue.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
/* 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/locations/statue.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
#define PAGE1_SECONDS 10
|
||||
|
||||
Statue::Statue() : Location("Statue") {
|
||||
}
|
||||
|
||||
bool Statue::msgGame(const GameMessage &msg) {
|
||||
if (msg._name == "STATUE") {
|
||||
_pageNum = 0;
|
||||
_statueNum = msg._value;
|
||||
addView(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Statue::msgKeypress(const KeypressMessage &msg) {
|
||||
if (!endDelay())
|
||||
leave();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Statue::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Statue::draw() {
|
||||
switch (_pageNum) {
|
||||
case 0:
|
||||
_bounds = getLineBounds(20, 24);
|
||||
clearSurface();
|
||||
|
||||
writeString(0, 1, STRING["dialogs.statues.stone"]);
|
||||
writeString(STRING[Common::String::format(
|
||||
"dialogs.statues.names.%d", _statueNum)]);
|
||||
newLine();
|
||||
writeString(STRING["dialogs.statues.plaque"]);
|
||||
|
||||
++_pageNum;
|
||||
delaySeconds(PAGE1_SECONDS);
|
||||
redraw();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
_bounds = getLineBounds(17, 24);
|
||||
clearSurface();
|
||||
|
||||
writeString(0, 0, STRING[Common::String::format(
|
||||
"dialogs.statues.messages.%d", _statueNum)]);
|
||||
|
||||
Sound::sound(SOUND_2);
|
||||
++_pageNum;
|
||||
redraw();
|
||||
break;
|
||||
|
||||
default:
|
||||
leave();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
51
engines/mm/mm1/views/locations/statue.h
Normal file
51
engines/mm/mm1/views/locations/statue.h
Normal 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_LOCATIONS_STATUE_H
|
||||
#define MM1_VIEWS_LOCATIONS_STATUE_H
|
||||
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Statue : public Location {
|
||||
private:
|
||||
int _statueNum = 0;
|
||||
int _pageNum = 0;
|
||||
public:
|
||||
Statue();
|
||||
virtual ~Statue() {}
|
||||
|
||||
void draw() override;
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
148
engines/mm/mm1/views/locations/tavern.cpp
Normal file
148
engines/mm/mm1/views/locations/tavern.cpp
Normal file
@@ -0,0 +1,148 @@
|
||||
/* 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/locations/tavern.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
Tavern::Tavern() : Location("Tavern") {
|
||||
}
|
||||
|
||||
bool Tavern::msgFocus(const FocusMessage &msg) {
|
||||
send("View", GameMessage("LOCATION", LOC_TAVERN));
|
||||
g_globals->_currCharacter = &g_globals->_party[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tavern::msgKeypress(const KeypressMessage &msg) {
|
||||
// If timed message display, end the waiting
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_a:
|
||||
haveADrink();
|
||||
break;
|
||||
case Common::KEYCODE_b:
|
||||
tipBartender();
|
||||
break;
|
||||
case Common::KEYCODE_c:
|
||||
listenForRumors();
|
||||
break;
|
||||
case Common::KEYCODE_g:
|
||||
g_globals->_currCharacter->gatherGold();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_1:
|
||||
case Common::KEYCODE_2:
|
||||
case Common::KEYCODE_3:
|
||||
case Common::KEYCODE_4:
|
||||
case Common::KEYCODE_5:
|
||||
case Common::KEYCODE_6:
|
||||
changeCharacter(msg.keycode - Common::KEYCODE_1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tavern::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Tavern::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(20, 1, STRING["dialogs.tavern.drink"]);
|
||||
writeString(20, 2, STRING["dialogs.tavern.tip"]);
|
||||
writeString(20, 3, STRING["dialogs.tavern.listen"]);
|
||||
}
|
||||
|
||||
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(13, 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 Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
64
engines/mm/mm1/views/locations/tavern.h
Normal file
64
engines/mm/mm1/views/locations/tavern.h
Normal 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_LOCATIONS_TAVERN_H
|
||||
#define MM1_VIEWS_LOCATIONS_TAVERN_H
|
||||
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Tavern : public Location {
|
||||
private:
|
||||
/**
|
||||
* Have a drink
|
||||
*/
|
||||
void haveADrink();
|
||||
|
||||
/**
|
||||
* Tip the bartender
|
||||
*/
|
||||
void tipBartender();
|
||||
|
||||
/**
|
||||
* Listen for rumors
|
||||
*/
|
||||
void listenForRumors();
|
||||
|
||||
public:
|
||||
Tavern();
|
||||
virtual ~Tavern() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
237
engines/mm/mm1/views/locations/temple.cpp
Normal file
237
engines/mm/mm1/views/locations/temple.cpp
Normal file
@@ -0,0 +1,237 @@
|
||||
/* 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/locations/temple.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/mm1.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
Temple::Temple() : Location("Temple") {
|
||||
}
|
||||
|
||||
bool Temple::msgFocus(const FocusMessage &msg) {
|
||||
send("View", GameMessage("LOCATION", LOC_TEMPLE));
|
||||
changeCharacter(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Temple::msgKeypress(const KeypressMessage &msg) {
|
||||
// If a delay is active, end it
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_a:
|
||||
restoreHealth();
|
||||
break;
|
||||
case Common::KEYCODE_b:
|
||||
uncurseItems();
|
||||
break;
|
||||
case Common::KEYCODE_c:
|
||||
restoreAlignment();
|
||||
break;
|
||||
case Common::KEYCODE_d:
|
||||
donate();
|
||||
break;
|
||||
case Common::KEYCODE_g:
|
||||
g_globals->_currCharacter->gatherGold();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_1:
|
||||
case Common::KEYCODE_2:
|
||||
case Common::KEYCODE_3:
|
||||
case Common::KEYCODE_4:
|
||||
case Common::KEYCODE_5:
|
||||
case Common::KEYCODE_6:
|
||||
changeCharacter(msg.keycode - Common::KEYCODE_1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Temple::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Temple::changeCharacter(uint index) {
|
||||
Maps::Map &map = *g_maps->_currentMap;
|
||||
int i;
|
||||
|
||||
if (index >= g_globals->_party.size())
|
||||
return;
|
||||
Location::changeCharacter(index);
|
||||
|
||||
_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::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(21, 0, STRING["dialogs.temple.service_cost"]);
|
||||
|
||||
writeString(18, 2, STRING["dialogs.temple.a"]);
|
||||
_textPos.x = 36;
|
||||
if (_healCost)
|
||||
writeNumber(_healCost);
|
||||
else
|
||||
writeString("----");
|
||||
|
||||
writeString(18, 3, STRING["dialogs.temple.b"]);
|
||||
_textPos.x = 36;
|
||||
if (_uncurseCost)
|
||||
writeNumber(_uncurseCost);
|
||||
else
|
||||
writeString("----");
|
||||
|
||||
writeString(18, 4, STRING["dialogs.temple.c"]);
|
||||
_textPos.x = 36;
|
||||
if (_alignmentCost)
|
||||
writeNumber(_alignmentCost);
|
||||
else
|
||||
writeString("----");
|
||||
|
||||
writeString(18, 5, STRING["dialogs.temple.d"]);
|
||||
_textPos.x = 36;
|
||||
writeNumber(_donateCost);
|
||||
}
|
||||
|
||||
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 Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
65
engines/mm/mm1/views/locations/temple.h
Normal file
65
engines/mm/mm1/views/locations/temple.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_LOCATIONS_TEMPLE_H
|
||||
#define MM1_VIEWS_LOCATIONS_TEMPLE_H
|
||||
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Temple : public Location, public TempleData {
|
||||
private:
|
||||
bool _isEradicated = false;
|
||||
int _healCost = 0, _uncurseCost = 0;
|
||||
int _alignmentCost = 0, _donateCost = 0;
|
||||
private:
|
||||
void restoreHealth();
|
||||
void uncurseItems();
|
||||
void restoreAlignment();
|
||||
void donate();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Change character
|
||||
*/
|
||||
void changeCharacter(uint index) override;
|
||||
|
||||
public:
|
||||
Temple();
|
||||
virtual ~Temple() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
198
engines/mm/mm1/views/locations/training.cpp
Normal file
198
engines/mm/mm1/views/locations/training.cpp
Normal file
@@ -0,0 +1,198 @@
|
||||
/* 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/locations/training.h"
|
||||
#include "mm/mm1/events.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
#include "mm/mm1/sound.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
Training::Training() : Location("Training") {
|
||||
}
|
||||
|
||||
bool Training::msgFocus(const FocusMessage &msg) {
|
||||
send("View", GameMessage("LOCATION", LOC_TRAINING));
|
||||
changeCharacter(0);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Training::changeCharacter(uint index) {
|
||||
Location::changeCharacter(index);
|
||||
checkCharacter();
|
||||
}
|
||||
|
||||
void Training::timeout() {
|
||||
checkCharacter();
|
||||
Location::timeout();
|
||||
}
|
||||
|
||||
void Training::checkCharacter() {
|
||||
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::draw() {
|
||||
Location::draw();
|
||||
|
||||
writeString(18, 1, STRING["dialogs.training.for_level"]);
|
||||
writeNumber(_currLevel + 1);
|
||||
|
||||
if (_currLevel >= MAX_LEVEL) {
|
||||
writeString(24, 3, STRING["dialogs.training.no_way"]);
|
||||
|
||||
} else if (_remainingExp > 0) {
|
||||
writeString(21, 3, Common::String::format(
|
||||
STRING["dialogs.training.need"].c_str(), _remainingExp));
|
||||
writeString(20, 5, STRING["dialogs.training.xp"]);
|
||||
|
||||
} else {
|
||||
writeString(21, 3, Common::String::format(
|
||||
STRING["dialogs.training.cost"].c_str(), _cost));
|
||||
writeString(18, 5, STRING["dialogs.training.cost"]);
|
||||
}
|
||||
}
|
||||
|
||||
bool Training::msgKeypress(const KeypressMessage &msg) {
|
||||
// If a delay is active, end it
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
switch (msg.keycode) {
|
||||
case Common::KEYCODE_a:
|
||||
if (_canTrain)
|
||||
train();
|
||||
break;
|
||||
case Common::KEYCODE_g:
|
||||
g_globals->_currCharacter->gatherGold();
|
||||
redraw();
|
||||
break;
|
||||
case Common::KEYCODE_1:
|
||||
case Common::KEYCODE_2:
|
||||
case Common::KEYCODE_3:
|
||||
case Common::KEYCODE_4:
|
||||
case Common::KEYCODE_5:
|
||||
case Common::KEYCODE_6:
|
||||
changeCharacter(msg.keycode - Common::KEYCODE_1);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Training::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
leave();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Training::train() {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
|
||||
if (c._condition) {
|
||||
Sound::sound(SOUND_3);
|
||||
clearSurface();
|
||||
writeString(8, 5, STRING["dialogs.training.condition"]);
|
||||
delaySeconds(3);
|
||||
|
||||
} else if (!_canAfford) {
|
||||
notEnoughGold();
|
||||
|
||||
} else {
|
||||
// Do the actual training
|
||||
c._gold -= _cost;
|
||||
Character::LevelIncrease lvl = c.increaseLevel();
|
||||
Sound::sound(SOUND_2);
|
||||
|
||||
clearSurface();
|
||||
writeString(0, 3, STRING["dialogs.training.congrats"]);
|
||||
writeNumber(c._level._base);
|
||||
|
||||
writeString(7, 5, Common::String::format(
|
||||
STRING["dialogs.training.hp"].c_str(), lvl._numHP));
|
||||
|
||||
if (lvl._numSpells != 0)
|
||||
writeString(7, 6, STRING["dialogs.training.new_spells"]);
|
||||
|
||||
Sound::sound(SOUND_2);
|
||||
delaySeconds(10);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
81
engines/mm/mm1/views/locations/training.h
Normal file
81
engines/mm/mm1/views/locations/training.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MM1_VIEWS_LOCATIONS_TRAINING_H
|
||||
#define MM1_VIEWS_LOCATIONS_TRAINING_H
|
||||
|
||||
#include "mm/mm1/data/character.h"
|
||||
#include "mm/mm1/views/locations/location.h"
|
||||
#include "mm/mm1/data/locations.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace Views {
|
||||
namespace Locations {
|
||||
|
||||
class Training : public Location, public TrainingData {
|
||||
private:
|
||||
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();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Change character
|
||||
*/
|
||||
void changeCharacter(uint index) override;
|
||||
|
||||
/**
|
||||
* Called when an active timeout countdown expired
|
||||
*/
|
||||
void timeout() override;
|
||||
|
||||
public:
|
||||
Training();
|
||||
virtual ~Training() {}
|
||||
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // namespace Locations
|
||||
} // namespace Views
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user