Initial commit
This commit is contained in:
212
engines/mm/mm1/views_enh/spells/cast_spell.cpp
Normal file
212
engines/mm/mm1/views_enh/spells/cast_spell.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/* 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/spells/cast_spell.h"
|
||||
#include "mm/mm1/game/spells_party.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
CastSpell::CastSpell() : PartyView("CastSpell") {
|
||||
_bounds = Common::Rect(225, 0, 320, 146);
|
||||
|
||||
_icons.load("cast.icn");
|
||||
addButton(&_icons, Common::Point(0, 100), 0,
|
||||
Common::KeyState(Common::KEYCODE_c, 'c'));
|
||||
addButton(&_icons, Common::Point(28, 100), 2,
|
||||
Common::KeyState(Common::KEYCODE_n, 'n'));
|
||||
addButton(&_icons, Common::Point(56, 100), 4, KEYBIND_ESCAPE);
|
||||
}
|
||||
|
||||
bool CastSpell::msgFocus(const FocusMessage &msg) {
|
||||
if (!isInCombat())
|
||||
(void)PartyView::msgFocus(msg);
|
||||
|
||||
updateSelectedSpell();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CastSpell::msgUnfocus(const UnfocusMessage &msg) {
|
||||
if (!isInCombat())
|
||||
(void)PartyView::msgUnfocus(msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CastSpell::draw() {
|
||||
if (!isInCombat()) {
|
||||
PartyView::draw();
|
||||
} else {
|
||||
ScrollView::draw();
|
||||
}
|
||||
_fontReduced = false;
|
||||
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
writeString(0, 0, STRING["enhdialogs.cast_spell.title"], ALIGN_MIDDLE);
|
||||
writeString(0, 20, c._name, ALIGN_MIDDLE);
|
||||
writeString(0, 40, STRING["enhdialogs.cast_spell.spell_ready"]);
|
||||
|
||||
setTextColor(37);
|
||||
|
||||
int spellNum = c.spellNumber();
|
||||
Common::String spellName = STRING["enhdialogs.cast_spell.none"];
|
||||
if (spellNum >= 0 && spellNum < 47) {
|
||||
spellName = STRING[Common::String::format("spells.cleric.%d", spellNum)];
|
||||
} else if (spellNum >= 47) {
|
||||
spellName = STRING[Common::String::format("spells.wizard.%d", spellNum - 47)];
|
||||
}
|
||||
writeString(0, 60, spellName, ALIGN_MIDDLE);
|
||||
|
||||
_fontReduced = true;
|
||||
setTextColor(0);
|
||||
writeString(0, 80, STRING["enhdialogs.cast_spell.cost"]);
|
||||
writeString(0, 90, STRING["enhdialogs.cast_spell.cur_sp"]);
|
||||
writeString(0, 80, Common::String::format("%d/%d",
|
||||
_requiredSp, _requiredGems), ALIGN_RIGHT);
|
||||
writeString(0, 90, Common::String::format("%d", c._sp._current), ALIGN_RIGHT);
|
||||
|
||||
writeString(0, 122, STRING["enhdialogs.cast_spell.cast"]);
|
||||
writeString(30, 122, STRING["enhdialogs.cast_spell.new"]);
|
||||
writeString(60, 122, STRING["enhdialogs.cast_spell.esc"]);
|
||||
|
||||
_fontReduced = false;
|
||||
}
|
||||
|
||||
bool CastSpell::msgKeypress(const KeypressMessage &msg) {
|
||||
if (msg.keycode == Common::KEYCODE_c) {
|
||||
// Cast a spell
|
||||
if (_spellIndex != -1) {
|
||||
if (!canCast()) {
|
||||
close();
|
||||
spellError();
|
||||
} else if (hasCharTarget()) {
|
||||
addView("CharacterSelect");
|
||||
} else {
|
||||
close();
|
||||
castSpell();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
} else if (msg.keycode == Common::KEYCODE_n) {
|
||||
// Select a new spell
|
||||
addView("Spellbook");
|
||||
return true;
|
||||
} else if (!isInCombat()) {
|
||||
return PartyView::msgKeypress(msg);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CastSpell::msgAction(const ActionMessage &msg) {
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
close();
|
||||
return true;
|
||||
|
||||
} else if (!isInCombat()) {
|
||||
return PartyView::msgAction(msg);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CastSpell::msgGame(const GameMessage &msg) {
|
||||
if (msg._name == "UPDATE") {
|
||||
updateSelectedSpell();
|
||||
draw();
|
||||
return true;
|
||||
} else if (msg._name == "CHAR_SELECTED" && msg._value != -1) {
|
||||
close();
|
||||
castSpell(&g_globals->_party[msg._value]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CastSpell::updateSelectedSpell() {
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
int spellNum = c.spellNumber();
|
||||
if (spellNum == -1) {
|
||||
_requiredSp = _requiredGems = 0;
|
||||
_spellIndex = -1;
|
||||
|
||||
} else {
|
||||
int lvl, num;
|
||||
getSpellLevelNum(spellNum, lvl, num);
|
||||
assert(getSpellIndex(&c, lvl, num) == spellNum);
|
||||
|
||||
setSpell(&c, lvl, num);
|
||||
}
|
||||
}
|
||||
|
||||
void CastSpell::charSwitched(Character *priorChar) {
|
||||
PartyView::charSwitched(priorChar);
|
||||
updateSelectedSpell();
|
||||
}
|
||||
|
||||
void CastSpell::castSpell(Character *target) {
|
||||
if (_spellIndex == -1)
|
||||
return;
|
||||
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
c._sp._current = MAX((int)c._sp._current - _requiredSp, 0);
|
||||
c._gems = MAX((int)c._gems - _requiredGems, 0);
|
||||
|
||||
if (!isMagicAllowed()) {
|
||||
g_events->send(InfoMessage(STRING["spells.magic_doesnt_work"]));
|
||||
|
||||
} else {
|
||||
// Cast the spell
|
||||
Game::SpellResult result = Game::SpellsParty::cast(_spellIndex, target);
|
||||
|
||||
switch (result) {
|
||||
case Game::SR_FAILED:
|
||||
g_events->send(InfoMessage(STRING["spells.failed"]));
|
||||
break;
|
||||
|
||||
case Game::SR_SUCCESS_DONE:
|
||||
g_events->send(InfoMessage(STRING["spells.done"]));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Spell done, but don't display done message
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CastSpell::spellError() {
|
||||
g_events->drawElements();
|
||||
|
||||
Common::String msg = getSpellError();
|
||||
send(SoundMessage(msg, ALIGN_MIDDLE));
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
86
engines/mm/mm1/views_enh/spells/cast_spell.h
Normal file
86
engines/mm/mm1/views_enh/spells/cast_spell.h
Normal file
@@ -0,0 +1,86 @@
|
||||
/* 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_CAST_SPELL_H
|
||||
#define MM1_VIEWS_ENH_CAST_SPELL_H
|
||||
|
||||
#include "mm/mm1/messages.h"
|
||||
#include "mm/mm1/game/spell_casting.h"
|
||||
#include "mm/mm1/views_enh/party_view.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Dialog for casting a spell
|
||||
*/
|
||||
class CastSpell : public PartyView, public MM1::Game::SpellCasting {
|
||||
private:
|
||||
Shared::Xeen::SpriteResource _icons;
|
||||
|
||||
/**
|
||||
* Updates the data for the displayed spell
|
||||
*/
|
||||
void updateSelectedSpell();
|
||||
|
||||
/**
|
||||
* Casts the selected spell
|
||||
*/
|
||||
void castSpell(Character *target = nullptr);
|
||||
|
||||
/**
|
||||
* Handles spell errors
|
||||
*/
|
||||
void spellError();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Return true if the selected character can be switched
|
||||
*/
|
||||
bool canSwitchChar() override {
|
||||
return !isInCombat();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the selected character has been switched
|
||||
*/
|
||||
void charSwitched(Character *priorChar) override;
|
||||
|
||||
public:
|
||||
CastSpell();
|
||||
virtual ~CastSpell() {}
|
||||
|
||||
void draw() override;
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgUnfocus(const UnfocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
74
engines/mm/mm1/views_enh/spells/detect_magic.cpp
Normal file
74
engines/mm/mm1/views_enh/spells/detect_magic.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_enh/spells/detect_magic.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
#define TEXT_X1 160
|
||||
#define TEXT_X2 195
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
DetectMagic::DetectMagic() : ScrollView("DetectMagic") {
|
||||
setBounds(Common::Rect(30, 30, 210, 120));
|
||||
addButton(&g_globals->_escSprites, Common::Point(0, 64), 0, KEYBIND_ESCAPE, true);
|
||||
}
|
||||
|
||||
void DetectMagic::draw() {
|
||||
ScrollView::draw();
|
||||
|
||||
setReduced(true);
|
||||
writeString(0, 0, STRING["dialogs.spells.detect_charges"], ALIGN_RIGHT);
|
||||
|
||||
getMagicStrings();
|
||||
|
||||
Inventory &inv = g_globals->_currCharacter->_backpack;
|
||||
for (uint i = 0; i < inv.size(); ++i) {
|
||||
// Write item name
|
||||
writeString(0, (i + 1) * 8, Common::String::format("%c) ", 'A' + i));
|
||||
g_globals->_items.getItem(inv[i]._id);
|
||||
writeString(g_globals->_currItem._name);
|
||||
|
||||
// Write out the detect status
|
||||
writeString(0, (i + 1) * 8, _strings[i], ALIGN_RIGHT);
|
||||
}
|
||||
|
||||
if (inv.empty())
|
||||
writeLine(1, STRING["enhdialogs.misc.no_items"]);
|
||||
|
||||
writeString(15, 66, STRING["enhdialogs.misc.go_back"]);
|
||||
setReduced(false);
|
||||
}
|
||||
|
||||
bool DetectMagic::msgAction(const ActionMessage &msg) {
|
||||
if (msg._action == KEYBIND_SELECT || msg._action == KEYBIND_ESCAPE)
|
||||
g_events->replaceView("Game", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
48
engines/mm/mm1/views_enh/spells/detect_magic.h
Normal file
48
engines/mm/mm1/views_enh/spells/detect_magic.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MM1_VIEWS_ENH_SPELLS_DETECT_MAGIC_H
|
||||
#define MM1_VIEWS_ENH_SPELLS_DETECT_MAGIC_H
|
||||
|
||||
#include "mm/mm1/views_enh/scroll_view.h"
|
||||
#include "mm/mm1/game/detect_magic.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
class DetectMagic : public ScrollView, public MM1::Game::DetectMagic {
|
||||
public:
|
||||
DetectMagic();
|
||||
virtual ~DetectMagic() {
|
||||
}
|
||||
|
||||
void draw() override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
66
engines/mm/mm1/views_enh/spells/duplication.cpp
Normal file
66
engines/mm/mm1/views_enh/spells/duplication.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/* 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/spells/duplication.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
Duplication::Duplication() : CharacterInventory("Duplication") {
|
||||
clearButtons();
|
||||
|
||||
addButton(2, STRING["enhdialogs.items.buttons.arms"], Common::KEYCODE_a);
|
||||
addButton(6, STRING["enhdialogs.items.buttons.backpack"], Common::KEYCODE_b);
|
||||
addButton(14, STRING["enhdialogs.items.buttons.copy"], Common::KEYCODE_c);
|
||||
addButton(16, STRING["enhdialogs.misc.exit"], Common::KEYCODE_ESCAPE);
|
||||
}
|
||||
|
||||
bool Duplication::msgKeypress(const KeypressMessage &msg) {
|
||||
if (msg.keycode == Common::KEYCODE_a || msg.keycode == Common::KEYCODE_b ||
|
||||
(msg.keycode >= Common::KEYCODE_1 && msg.keycode <= Common::KEYCODE_6)) {
|
||||
// Keys we can allow the base view to handle
|
||||
CharacterInventory::msgKeypress(msg);
|
||||
|
||||
} else if (msg.keycode == Common::KEYCODE_c || msg.keycode == Common::KEYCODE_d) {
|
||||
selectButton(BTN_COPY);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Duplication::performAction() {
|
||||
assert(_selectedButton == BTN_COPY);
|
||||
Inventory &inv = _mode == ARMS_MODE ? g_globals->_currCharacter->_equipped :
|
||||
g_globals->_currCharacter->_backpack;
|
||||
|
||||
bool result = duplicate(*g_globals->_currCharacter, inv, _selectedItem);
|
||||
close();
|
||||
|
||||
g_events->send(InfoMessage(STRING[result ? "spells.done" : "spells.failed"]));
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
59
engines/mm/mm1/views_enh/spells/duplication.h
Normal file
59
engines/mm/mm1/views_enh/spells/duplication.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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_SPELLS_DUPLICATE_ITEM_H
|
||||
#define MM1_VIEWS_ENH_SPELLS_DUPLICATE_ITEM_H
|
||||
|
||||
#include "mm/mm1/views_enh/character_inventory.h"
|
||||
#include "mm/mm1/game/duplication.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
class Duplication : public CharacterInventory, public MM1::Game::Duplication {
|
||||
protected:
|
||||
/**
|
||||
* Handle action with selected button mode and selected item
|
||||
*/
|
||||
void performAction() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Duplication();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~Duplication() {}
|
||||
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
110
engines/mm/mm1/views_enh/spells/fly.cpp
Normal file
110
engines/mm/mm1/views_enh/spells/fly.cpp
Normal file
@@ -0,0 +1,110 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/spells/fly.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
#define TEXT_X1 160
|
||||
#define TEXT_X2 195
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
#define TEXT_X 120
|
||||
|
||||
Fly::Fly() : ScrollView("Fly") {
|
||||
setBounds(Common::Rect(0, 144, 234, 200));
|
||||
addButton(&g_globals->_escSprites, Common::Point(5, 28), 0, KEYBIND_ESCAPE, true);
|
||||
}
|
||||
|
||||
bool Fly::msgFocus(const FocusMessage &msg) {
|
||||
ScrollView::msgFocus(msg);
|
||||
|
||||
_mode = SELECT_X;
|
||||
_xIndex = _yIndex = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Fly::draw() {
|
||||
ScrollView::draw();
|
||||
|
||||
setReduced(true);
|
||||
writeString(20, 30, STRING["enhdialogs.misc.go_back"]);
|
||||
|
||||
writeLine(0, STRING["dialogs.spells.fly_to_x"], ALIGN_RIGHT, TEXT_X);
|
||||
writeChar((_mode == SELECT_X) ? '_' : 'A' + _xIndex);
|
||||
|
||||
if (_mode == SELECT_Y || _mode == CAST) {
|
||||
writeLine(1, STRING["dialogs.spells.fly_to_y"], ALIGN_RIGHT, TEXT_X);
|
||||
writeChar((_mode == SELECT_Y) ? '_' : '1' + _yIndex);
|
||||
}
|
||||
|
||||
setReduced(false);
|
||||
}
|
||||
|
||||
bool Fly::msgKeypress(const KeypressMessage &msg) {
|
||||
if (_mode == SELECT_X && msg.keycode >= Common::KEYCODE_a
|
||||
&& msg.keycode <= Common::KEYCODE_d) {
|
||||
// X map selected
|
||||
_mode = SELECT_Y;
|
||||
_xIndex = msg.keycode - Common::KEYCODE_a;
|
||||
redraw();
|
||||
|
||||
} else if (_mode == SELECT_Y && msg.keycode >= Common::KEYCODE_1
|
||||
&& msg.keycode <= Common::KEYCODE_4) {
|
||||
// Y map selected
|
||||
_mode = CAST;
|
||||
_yIndex = msg.keycode - Common::KEYCODE_1;
|
||||
|
||||
delaySeconds(1);
|
||||
redraw();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Fly::msgAction(const ActionMessage &msg) {
|
||||
if (endDelay())
|
||||
return true;
|
||||
|
||||
if (msg._action == KEYBIND_ESCAPE) {
|
||||
cancelDelay();
|
||||
g_events->replaceView("Game", true);
|
||||
fly(-1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Fly::timeout() {
|
||||
// Spell was cast
|
||||
g_events->replaceView("Game", true);
|
||||
int mapIndex = _yIndex * 5 + _xIndex;
|
||||
fly(mapIndex);
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
81
engines/mm/mm1/views_enh/spells/fly.h
Normal file
81
engines/mm/mm1/views_enh/spells/fly.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_ENH_SPELLS_FLY_H
|
||||
#define MM1_VIEWS_ENH_SPELLS_FLY_H
|
||||
|
||||
#include "mm/mm1/views_enh/scroll_view.h"
|
||||
#include "mm/mm1/game/fly.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
class Fly : public ScrollView, public MM1::Game::Fly {
|
||||
private:
|
||||
enum Mode { SELECT_X, SELECT_Y, CAST };
|
||||
Mode _mode = SELECT_X;
|
||||
int _xIndex = 0, _yIndex = 0;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Fly();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~Fly() {}
|
||||
|
||||
/**
|
||||
* Show the view
|
||||
*/
|
||||
bool msgFocus(const FocusMessage &) override;
|
||||
|
||||
/**
|
||||
* Draw the view contents
|
||||
*/
|
||||
void draw() override;
|
||||
|
||||
/**
|
||||
* Keypress handler
|
||||
*/
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
|
||||
/**
|
||||
* Action handler
|
||||
*/
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
|
||||
/**
|
||||
* Timeout handler
|
||||
*/
|
||||
void timeout() override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
117
engines/mm/mm1/views_enh/spells/location.cpp
Normal file
117
engines/mm/mm1/views_enh/spells/location.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mm/mm1/views_enh/spells/location.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
#define TEXT_X1 160
|
||||
#define TEXT_X2 195
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
Location::Location() : ScrollView("Location") {
|
||||
setBounds(Common::Rect(0, 144, 234, 200));
|
||||
addButton(&g_globals->_escSprites, Common::Point(5, 28), 0, KEYBIND_ESCAPE, true);
|
||||
}
|
||||
|
||||
void Location::draw() {
|
||||
Maps::Maps &maps = *g_maps;
|
||||
Maps::Map &map = *maps._currentMap;
|
||||
byte v;
|
||||
|
||||
ScrollView::draw();
|
||||
|
||||
setReduced(true);
|
||||
writeString(20, 30, STRING["enhdialogs.misc.go_back"]);
|
||||
|
||||
writeLine(0, STRING["dialogs.spells.location_loc"], ALIGN_LEFT, 0);
|
||||
|
||||
v = map[Maps::MAP_TYPE];
|
||||
if (v == 0xff) {
|
||||
writeString(STRING["dialogs.spells.location_unknown"]);
|
||||
} else {
|
||||
if (v == 0) {
|
||||
writeString(STRING["dialogs.spells.location_outdoors"]);
|
||||
} else if (!(v & 0x80)) {
|
||||
writeChar('0' + map[37]);
|
||||
writeString(STRING["dialogs.spells.location_under"]);
|
||||
} else if (v == 0xfe) {
|
||||
writeString(STRING["dialogs.spells.location_town"]);
|
||||
} else {
|
||||
writeString(STRING["dialogs.spells.location_castle"]);
|
||||
}
|
||||
|
||||
writeLine(0, STRING["dialogs.spells.location_sector"], ALIGN_LEFT, 111);
|
||||
writeChar(map[Maps::MAP_SECTOR1] & 0x7f);
|
||||
writeChar('-');
|
||||
writeChar(map[Maps::MAP_SECTOR2] & 0x7f);
|
||||
|
||||
writeLine(1, STRING["dialogs.spells.location_surface_x"], ALIGN_RIGHT, TEXT_X1);
|
||||
writeString("X=");
|
||||
|
||||
if (map[Maps::MAP_TYPE]) {
|
||||
writeNumber(map[Maps::MAP_SURFACE_X]);
|
||||
writeLine(1, "Y=", ALIGN_LEFT, TEXT_X2);
|
||||
writeNumber(map[Maps::MAP_SURFACE_Y]);
|
||||
|
||||
writeLine(2, STRING["dialogs.spells.location_inside_x"], ALIGN_RIGHT, TEXT_X1);
|
||||
writeString("X=");
|
||||
}
|
||||
|
||||
writeNumber(maps._mapPos.x);
|
||||
_textPos.x = TEXT_X2;
|
||||
writeString("Y=");
|
||||
writeNumber(maps._mapPos.y);
|
||||
|
||||
writeLine(3, STRING["dialogs.spells.location_facing"], ALIGN_RIGHT, TEXT_X1);
|
||||
switch (maps._forwardMask) {
|
||||
case Maps::DIRMASK_N:
|
||||
writeChar('N');
|
||||
break;
|
||||
case Maps::DIRMASK_S:
|
||||
writeChar('S');
|
||||
break;
|
||||
case Maps::DIRMASK_E:
|
||||
writeChar('E');
|
||||
break;
|
||||
default:
|
||||
writeChar('W');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
setReduced(false);
|
||||
}
|
||||
|
||||
bool Location::msgAction(const ActionMessage &msg) {
|
||||
if (msg._action == KEYBIND_SELECT || msg._action == KEYBIND_ESCAPE)
|
||||
g_events->replaceView("Game", true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
47
engines/mm/mm1/views_enh/spells/location.h
Normal file
47
engines/mm/mm1/views_enh/spells/location.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_SPELLS_LOCATION_H
|
||||
#define MM1_VIEWS_ENH_SPELLS_LOCATION_H
|
||||
|
||||
#include "mm/mm1/views_enh/scroll_view.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
class Location : public ScrollView {
|
||||
public:
|
||||
Location();
|
||||
virtual ~Location() {
|
||||
}
|
||||
|
||||
void draw() override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
66
engines/mm/mm1/views_enh/spells/recharge_item.cpp
Normal file
66
engines/mm/mm1/views_enh/spells/recharge_item.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/* 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/spells/recharge_item.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
RechargeItem::RechargeItem() : CharacterInventory("RechargeItem") {
|
||||
clearButtons();
|
||||
|
||||
addButton(2, STRING["enhdialogs.items.buttons.arms"], Common::KEYCODE_a);
|
||||
addButton(6, STRING["enhdialogs.items.buttons.backpack"], Common::KEYCODE_b);
|
||||
addButton(14, STRING["enhdialogs.items.buttons.charge"], Common::KEYCODE_c);
|
||||
addButton(16, STRING["enhdialogs.misc.exit"], Common::KEYCODE_ESCAPE);
|
||||
}
|
||||
|
||||
bool RechargeItem::msgKeypress(const KeypressMessage &msg) {
|
||||
if (msg.keycode == Common::KEYCODE_a || msg.keycode == Common::KEYCODE_b ||
|
||||
(msg.keycode >= Common::KEYCODE_1 && msg.keycode <= Common::KEYCODE_6)) {
|
||||
// Keys we can allow the base view to handle
|
||||
CharacterInventory::msgKeypress(msg);
|
||||
|
||||
} else if (msg.keycode == Common::KEYCODE_c) {
|
||||
selectButton(BTN_CHARGE);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RechargeItem::performAction() {
|
||||
assert(_selectedButton == BTN_CHARGE);
|
||||
Inventory &inv = _mode == ARMS_MODE ? g_globals->_currCharacter->_equipped :
|
||||
g_globals->_currCharacter->_backpack;
|
||||
|
||||
bool result = charge(inv, _selectedItem);
|
||||
close();
|
||||
|
||||
g_events->send(InfoMessage(STRING[result ? "spells.done" : "spells.failed"]));
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
59
engines/mm/mm1/views_enh/spells/recharge_item.h
Normal file
59
engines/mm/mm1/views_enh/spells/recharge_item.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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_SPELLS_RECHARGE_ITEM_H
|
||||
#define MM1_VIEWS_ENH_SPELLS_RECHARGE_ITEM_H
|
||||
|
||||
#include "mm/mm1/views_enh/character_inventory.h"
|
||||
#include "mm/mm1/game/recharge_item.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
class RechargeItem : public CharacterInventory, public MM1::Game::RechargeItem {
|
||||
protected:
|
||||
/**
|
||||
* Handle action with selected button mode and selected item
|
||||
*/
|
||||
void performAction() override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
RechargeItem();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~RechargeItem() {}
|
||||
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
250
engines/mm/mm1/views_enh/spells/spellbook.cpp
Normal file
250
engines/mm/mm1/views_enh/spells/spellbook.cpp
Normal file
@@ -0,0 +1,250 @@
|
||||
/* 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/spells/spellbook.h"
|
||||
#include "mm/mm1/game/spells_party.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
Spellbook::Spellbook() : PartyView("Spellbook") {
|
||||
_bounds = Common::Rect(27, 6, 208, 142);
|
||||
addButtons();
|
||||
}
|
||||
|
||||
void Spellbook::addButtons() {
|
||||
_scrollSprites.load("scroll.icn");
|
||||
addButton(&g_globals->_mainIcons, Common::Point(187, 26), 0, Common::KEYCODE_UP);
|
||||
addButton(&g_globals->_mainIcons, Common::Point(187, 111), 2, Common::KEYCODE_DOWN);
|
||||
addButton(&_scrollSprites, Common::Point(100, 109), 5, KEYBIND_SELECT);
|
||||
|
||||
addButton(Common::Rect(5, 14, 152, 22), Common::KEYCODE_1);
|
||||
addButton(Common::Rect(5, 23, 152, 31), Common::KEYCODE_2);
|
||||
addButton(Common::Rect(5, 32, 152, 40), Common::KEYCODE_3);
|
||||
addButton(Common::Rect(5, 41, 152, 49), Common::KEYCODE_4);
|
||||
addButton(Common::Rect(5, 50, 152, 58), Common::KEYCODE_5);
|
||||
addButton(Common::Rect(5, 59, 152, 67), Common::KEYCODE_6);
|
||||
addButton(Common::Rect(5, 68, 152, 76), Common::KEYCODE_7);
|
||||
addButton(Common::Rect(5, 77, 152, 85), Common::KEYCODE_8);
|
||||
addButton(Common::Rect(5, 86, 152, 94), Common::KEYCODE_9);
|
||||
addButton(Common::Rect(5, 95, 152, 103), Common::KEYCODE_0);
|
||||
|
||||
addButton(Common::Rect(139, 109, 163, 119), KEYBIND_ESCAPE);
|
||||
addButton(Common::Rect(152, 21, 163, 59), Common::KEYCODE_PAGEUP);
|
||||
addButton(Common::Rect(152, 60, 163, 98), Common::KEYCODE_PAGEDOWN);
|
||||
addButton(Common::Rect(97, 109, 163, 119), KEYBIND_SELECT);
|
||||
}
|
||||
|
||||
bool Spellbook::msgFocus(const FocusMessage &msg) {
|
||||
if (!isInCombat())
|
||||
PartyView::msgFocus(msg);
|
||||
|
||||
// In this view we don't want 1 to 6 mapping to char selection
|
||||
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
|
||||
updateChar();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Spellbook::msgUnfocus(const UnfocusMessage &msg) {
|
||||
if (!isInCombat())
|
||||
PartyView::msgUnfocus(msg);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Spellbook::canSwitchChar() {
|
||||
return !g_events->isInCombat();
|
||||
}
|
||||
|
||||
void Spellbook::draw() {
|
||||
if (isInCombat()) {
|
||||
ScrollView::draw();
|
||||
} else {
|
||||
PartyView::draw();
|
||||
}
|
||||
|
||||
Graphics::ManagedSurface s = getSurface();
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
|
||||
// Draw the scrolling area frame
|
||||
_scrollSprites.draw(&s, 4, Common::Point(14, 20));
|
||||
_scrollSprites.draw(&s, 0, Common::Point(162, 20));
|
||||
_scrollSprites.draw(&s, 2, Common::Point(162, 105));
|
||||
|
||||
// Title line
|
||||
_fontReduced = true;
|
||||
Common::String title = Common::String::format("%s %s",
|
||||
STRING["enhdialogs.spellbook.title"].c_str(),
|
||||
c._name
|
||||
);
|
||||
writeString(0, 0, title, ALIGN_MIDDLE);
|
||||
|
||||
// Write current spell points
|
||||
Common::String sp = Common::String::format("%s - %d",
|
||||
STRING["enhdialogs.spellbook.spell_points"].c_str(), c._sp._current);
|
||||
writeString(7, 111, sp);
|
||||
|
||||
// Iterate over the lines
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
// Left gutter row number
|
||||
setTextColor(0);
|
||||
const int yp = 15 + 9 * i;
|
||||
writeString(0, yp, Common::String::format("%c", (i == 9) ? '0' : '1' + i));
|
||||
|
||||
const int spellIndex = _topIndex + i;
|
||||
|
||||
if (_count == 0) {
|
||||
if (i == 0) {
|
||||
setTextColor(37);
|
||||
writeString(12, yp, STRING["enhdialogs.spellbook.non_caster"]);
|
||||
}
|
||||
} else if (spellIndex < _count) {
|
||||
// Spell requirements
|
||||
int lvl, num;
|
||||
getSpellLevelNum(CATEGORY_SPELLS_COUNT * (_isWizard ? 1 : 0) + spellIndex, lvl, num);
|
||||
setSpell(g_globals->_currCharacter, lvl, num);
|
||||
|
||||
setTextColor((spellIndex == _selectedIndex) ? 15 :
|
||||
(canCast() ? 37 : 1));
|
||||
|
||||
// Spell name and requirements
|
||||
Common::String spellName = STRING[Common::String::format(
|
||||
"spells.%s.%d",
|
||||
_isWizard ? "wizard" : "cleric",
|
||||
spellIndex
|
||||
)];
|
||||
writeString(12, yp, spellName);
|
||||
writeString(152, yp, Common::String::format("%d/%d",
|
||||
_requiredSp, _requiredGems), ALIGN_RIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Spellbook::msgKeypress(const KeypressMessage &msg) {
|
||||
if (msg.keycode >= Common::KEYCODE_0 && msg.keycode <= Common::KEYCODE_9) {
|
||||
int newIndex = _topIndex + (msg.keycode == Common::KEYCODE_0 ?
|
||||
9 : msg.keycode - Common::KEYCODE_1);
|
||||
if (newIndex < _count) {
|
||||
_selectedIndex = newIndex;
|
||||
redraw();
|
||||
}
|
||||
} else if (msg.keycode == Common::KEYCODE_PAGEUP) {
|
||||
if (_topIndex > 0) {
|
||||
_topIndex = MAX(_topIndex - 10, 0);
|
||||
redraw();
|
||||
}
|
||||
} else if (msg.keycode == Common::KEYCODE_PAGEDOWN) {
|
||||
int newTopIndex = _topIndex + 10;
|
||||
if (newTopIndex < _count) {
|
||||
_topIndex = newTopIndex;
|
||||
redraw();
|
||||
}
|
||||
} else if (msg.keycode == Common::KEYCODE_UP) {
|
||||
if (_topIndex > 0) {
|
||||
--_topIndex;
|
||||
redraw();
|
||||
}
|
||||
} else if (msg.keycode == Common::KEYCODE_DOWN) {
|
||||
if ((_topIndex + 10) < _count) {
|
||||
++_topIndex;
|
||||
redraw();
|
||||
}
|
||||
} else if (msg.keycode == Common::KEYCODE_s) {
|
||||
// Alternate alias for Select button
|
||||
msgAction(ActionMessage(KEYBIND_SELECT));
|
||||
|
||||
} else if (!isInCombat()) {
|
||||
return PartyView::msgKeypress(msg);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Spellbook::msgAction(const ActionMessage &msg) {
|
||||
switch (msg._action) {
|
||||
case KEYBIND_ESCAPE:
|
||||
close();
|
||||
return true;
|
||||
|
||||
case KEYBIND_SELECT:
|
||||
spellSelected();
|
||||
close();
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Spellbook::msgGame(const GameMessage &msg) {
|
||||
if (msg._name == "UPDATE") {
|
||||
updateChar();
|
||||
return true;
|
||||
} else if (!isInCombat()) {
|
||||
return PartyView::msgGame(msg);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Spellbook::updateChar() {
|
||||
// Refresh the cast spell side dialog for new character
|
||||
send("CastSpell", GameMessage("UPDATE"));
|
||||
|
||||
// Update the highlighted char in the party display
|
||||
g_events->send(GameMessage("CHAR_HIGHLIGHT", (int)true));
|
||||
|
||||
// Update fields
|
||||
const Character &c = *g_globals->_currCharacter;
|
||||
_isWizard = c._class == SORCERER || c._class == ARCHER;
|
||||
|
||||
_selectedIndex = (g_events->isInCombat() ? c._combatSpell : c._nonCombatSpell) % CATEGORY_SPELLS_COUNT;
|
||||
if (_selectedIndex == -1)
|
||||
_selectedIndex = 0;
|
||||
_topIndex = (_selectedIndex / 10) * 10;
|
||||
|
||||
if (c._spellLevel._current == 0) {
|
||||
_count = 0;
|
||||
} else {
|
||||
_count = (c._spellLevel._current < 5) ?
|
||||
c._spellLevel * 8 - 1 : 31 + (c._spellLevel - 4) * 5;
|
||||
}
|
||||
|
||||
// And finally, update the display
|
||||
redraw();
|
||||
}
|
||||
|
||||
void Spellbook::spellSelected() {
|
||||
Character &c = *g_globals->_currCharacter;
|
||||
int spellIndex = (_isWizard ? CATEGORY_SPELLS_COUNT : 0) + _selectedIndex;
|
||||
|
||||
// Set the selected spell for the character
|
||||
c.setSpellNumber(spellIndex);
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
80
engines/mm/mm1/views_enh/spells/spellbook.h
Normal file
80
engines/mm/mm1/views_enh/spells/spellbook.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* 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_SPELLBOOK_H
|
||||
#define MM1_VIEWS_ENH_SPELLBOOK_H
|
||||
|
||||
#include "mm/mm1/messages.h"
|
||||
#include "mm/mm1/game/spell_casting.h"
|
||||
#include "mm/mm1/views_enh/party_view.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Dialog for selecting a spell to cast
|
||||
*/
|
||||
class Spellbook : public PartyView, public MM1::Game::SpellCasting {
|
||||
private:
|
||||
Shared::Xeen::SpriteResource _scrollSprites;
|
||||
bool _isWizard = false;
|
||||
int _topIndex = 0, _count = 0;
|
||||
int _selectedIndex = -1;
|
||||
|
||||
/**
|
||||
* Loads buttons for the dialog
|
||||
*/
|
||||
void addButtons();
|
||||
|
||||
/**
|
||||
* Called when character is changed
|
||||
*/
|
||||
void updateChar();
|
||||
|
||||
/**
|
||||
* Performs the selected spell
|
||||
*/
|
||||
void spellSelected();
|
||||
|
||||
protected:
|
||||
bool canSwitchChar() override;
|
||||
|
||||
public:
|
||||
Spellbook();
|
||||
virtual ~Spellbook() {
|
||||
}
|
||||
|
||||
void draw() override;
|
||||
bool msgFocus(const FocusMessage &msg) override;
|
||||
bool msgUnfocus(const UnfocusMessage &msg) override;
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
bool msgGame(const GameMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
136
engines/mm/mm1/views_enh/spells/teleport.cpp
Normal file
136
engines/mm/mm1/views_enh/spells/teleport.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
/* 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/spells/teleport.h"
|
||||
#include "mm/mm1/globals.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
#define TEXT_X 120
|
||||
|
||||
Teleport::Teleport() : ScrollView("Teleport") {
|
||||
setBounds(Common::Rect(0, 144, 234, 200));
|
||||
addButton(&g_globals->_escSprites, Common::Point(5, 28), 0, KEYBIND_ESCAPE, true);
|
||||
}
|
||||
|
||||
bool Teleport::msgFocus(const FocusMessage &msg) {
|
||||
ScrollView::msgFocus(msg);
|
||||
|
||||
_mode = SELECT_DIRECTION;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Teleport::draw() {
|
||||
ScrollView::draw();
|
||||
|
||||
setReduced(true);
|
||||
writeString(20, 30, STRING["enhdialogs.misc.go_back"]);
|
||||
|
||||
writeLine(0, STRING["dialogs.spells.teleport_dir"], ALIGN_RIGHT, TEXT_X);
|
||||
writeChar((_mode == SELECT_DIRECTION) ? '_' : _direction);
|
||||
|
||||
if (_mode == SELECT_SQUARES || _mode == CAST) {
|
||||
writeLine(1, STRING["dialogs.spells.teleport_squares"], ALIGN_RIGHT, TEXT_X);
|
||||
writeChar((_mode == SELECT_SQUARES) ? '_' : '0' + _squares);
|
||||
}
|
||||
|
||||
if (_mode == CAST)
|
||||
writeString(0, 30, STRING["spells.enter_to_cast"], ALIGN_RIGHT);
|
||||
|
||||
setReduced(false);
|
||||
}
|
||||
|
||||
bool Teleport::msgKeypress(const KeypressMessage &msg) {
|
||||
if (_mode == SELECT_DIRECTION && (
|
||||
msg.keycode == Common::KEYCODE_n ||
|
||||
msg.keycode == Common::KEYCODE_s ||
|
||||
msg.keycode == Common::KEYCODE_e ||
|
||||
msg.keycode == Common::KEYCODE_w)) {
|
||||
_direction = toupper(msg.ascii);
|
||||
_mode = SELECT_SQUARES;
|
||||
redraw();
|
||||
|
||||
} else if (_mode == SELECT_SQUARES && (
|
||||
msg.keycode >= Common::KEYCODE_0 &&
|
||||
msg.keycode <= Common::KEYCODE_9)) {
|
||||
_squares = msg.keycode - Common::KEYCODE_0;
|
||||
_mode = CAST;
|
||||
redraw();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Teleport::msgAction(const ActionMessage &msg) {
|
||||
switch (msg._action) {
|
||||
case KEYBIND_ESCAPE:
|
||||
close();
|
||||
return true;
|
||||
|
||||
case KEYBIND_SELECT:
|
||||
if (_mode == CAST)
|
||||
teleport();
|
||||
return true;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Teleport::teleport() {
|
||||
Maps::Maps &maps = *g_maps;
|
||||
Maps::Map &map = *maps._currentMap;
|
||||
|
||||
close();
|
||||
if (map[Maps::MAP_FLAGS] & 2) {
|
||||
g_events->send(SoundMessage(STRING["spells.failed"]));
|
||||
|
||||
} else {
|
||||
switch (_direction) {
|
||||
case 'N':
|
||||
maps.step(Common::Point(0, _squares));
|
||||
break;
|
||||
case 'S':
|
||||
maps.step(Common::Point(0, -_squares));
|
||||
break;
|
||||
case 'E':
|
||||
maps.step(Common::Point(_squares, 0));
|
||||
break;
|
||||
case 'W':
|
||||
maps.step(Common::Point(-_squares, 0));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
send("Game", GameMessage("UPDATE"));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
82
engines/mm/mm1/views_enh/spells/teleport.h
Normal file
82
engines/mm/mm1/views_enh/spells/teleport.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MM1_VIEWS_ENH_SPELLS_TELEPORT_H
|
||||
#define MM1_VIEWS_ENH_SPELLS_TELEPORT_H
|
||||
|
||||
#include "mm/mm1/views_enh/scroll_view.h"
|
||||
|
||||
namespace MM {
|
||||
namespace MM1 {
|
||||
namespace ViewsEnh {
|
||||
namespace Spells {
|
||||
|
||||
class Teleport : public ScrollView {
|
||||
private:
|
||||
enum Mode { SELECT_DIRECTION, SELECT_SQUARES, CAST };
|
||||
Mode _mode = SELECT_DIRECTION;
|
||||
char _direction = '\0';
|
||||
int _squares = 0;
|
||||
|
||||
/**
|
||||
* Handle the teleporting
|
||||
*/
|
||||
void teleport();
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Teleport();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~Teleport() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the view
|
||||
*/
|
||||
bool msgFocus(const FocusMessage &) override;
|
||||
|
||||
/**
|
||||
* Draw the view contents
|
||||
*/
|
||||
void draw() override;
|
||||
|
||||
/**
|
||||
* Keypress handler
|
||||
*/
|
||||
bool msgKeypress(const KeypressMessage &msg) override;
|
||||
|
||||
/**
|
||||
* Action handler
|
||||
*/
|
||||
bool msgAction(const ActionMessage &msg) override;
|
||||
};
|
||||
|
||||
} // namespace Spells
|
||||
} // namespace ViewsEnh
|
||||
} // namespace MM1
|
||||
} // namespace MM
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user