Initial commit

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

View File

@@ -0,0 +1,262 @@
/* 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/spells/cast_spell.h"
#include "mm/mm1/game/spells_party.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
CastSpell::CastSpell() : SpellView("CastSpell") {
_bounds = getLineBounds(20, 24);
}
bool CastSpell::msgGame(const GameMessage &msg) {
if (msg._name != "SPELL")
return false;
if (msg._value == 0) {
// Ensure current character can cast spells
if (g_globals->_currCharacter->_spellLevel != 0 &&
g_globals->_currCharacter->_sp._current != 0) {
addView();
setState(SELECT_SPELL);
}
} else {
// Spell bound to an item
addView();
setSpell(msg._value, 0, 0);
if (!canCast()) {
spellDone();
} else if (hasCharTarget()) {
setState(SELECT_CHAR);
} else {
setState(PRESS_ENTER);
}
}
return true;
}
bool CastSpell::msgFocus(const FocusMessage &msg) {
if (dynamic_cast<TextEntry *>(msg._priorView) == nullptr)
_state = SELECT_SPELL;
return true;
}
void CastSpell::setState(State state) {
_state = state;
MetaEngine::setKeybindingMode(
_state == SELECT_CHAR ?
KeybindingMode::KBMODE_PARTY_MENUS :
KeybindingMode::KBMODE_MENUS
);
draw();
}
void CastSpell::abortFunc() {
CastSpell *view = (CastSpell *)g_events->focusedView();
view->close();
}
void CastSpell::enterSpellLevelFunc(const Common::String &text) {
CastSpell *view = (CastSpell *)g_events->focusedView();
view->spellLevelEntered(atoi(text.c_str()));
}
void CastSpell::enterSpellNumberFunc(const Common::String &text) {
CastSpell *view = (CastSpell *)g_events->focusedView();
view->spellNumberEntered(atoi(text.c_str()));
}
void CastSpell::draw() {
clearSurface();
if (_state == NONE)
return;
escToGoBack(0);
writeString(7, 0, STRING["dialogs.character.cast_spell"]);
if (_state >= SELECT_NUMBER) {
writeChar(' ');
writeNumber(_spellLevel);
writeString(19, 1, STRING["dialogs.character.number"]);
}
if (_state > SELECT_NUMBER) {
writeChar(' ');
writeNumber(_spellNumber);
}
switch (_state) {
case SELECT_SPELL:
_state = NONE;
_textEntry.display(27, 20, 1, true, abortFunc, enterSpellLevelFunc);
break;
case SELECT_NUMBER:
_state = NONE;
_textEntry.display(27, 21, 1, true, abortFunc, enterSpellNumberFunc);
break;
case SELECT_CHAR:
writeString(22, 3, Common::String::format(
STRING["spells.cast_on_char"].c_str(),
(int)g_globals->_party.size()
));
break;
case PRESS_ENTER:
writeString(24, 4, STRING["spells.enter_to_cast"]);
break;
case ENDING:
clearSurface();
writeString(_spellResultX, 1, _spellResult);
delaySeconds(3);
break;
default:
break;
}
}
void CastSpell::spellLevelEntered(uint level) {
// Ensure the spell level is valid
if (level < 1 || level > 7 ||
(!g_globals->_allSpells && level > g_globals->_currCharacter->_spellLevel)) {
close();
return;
}
_spellLevel = level;
setState(SELECT_NUMBER);
}
void CastSpell::spellNumberEntered(uint num) {
if (num < 1 || num > 8 || (_spellLevel >= 5 && num >= 6)) {
close();
return;
}
_spellNumber = num;
setSpell(g_globals->_currCharacter, _spellLevel, num);
if (!canCast()) {
spellDone();
} else {
if (hasCharTarget())
setState(SELECT_CHAR);
else
setState(PRESS_ENTER);
draw();
}
}
bool CastSpell::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
} else if (msg._action == KEYBIND_SELECT) {
// Time to execute the spell
performSpell();
} else if (_state == SELECT_CHAR &&
msg._action >= KEYBIND_VIEW_PARTY1 &&
msg._action <= KEYBIND_VIEW_PARTY6) {
uint charIndex = (int)(msg._action - KEYBIND_VIEW_PARTY1);
if (charIndex < g_globals->_party.size()) {
Character *c = isInCombat() ? g_globals->_combatParty[charIndex] :
&g_globals->_party[charIndex];
performSpell(c);
}
}
return true;
}
void CastSpell::timeout() {
close();
}
void CastSpell::performSpell(Character *chr) {
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()) {
spellDone(STRING["spells.magic_doesnt_work"], 5);
} else {
// Cast the spell
switch (Game::SpellsParty::cast(_spellIndex, chr)) {
case Game::SR_FAILED:
// Spell failed
spellFailed();
break;
case Game::SR_SUCCESS_DONE:
// Display spell done
spellDone();
break;
default:
// Spell done, but don't display done message
if (isFocused())
close();
break;
}
}
}
void CastSpell::spellDone() {
Common::String msg = getSpellError();
int xp = 20 - (msg.size() / 2);
spellDone(msg, xp);
}
void CastSpell::spellDone(const Common::String &msg, int xp) {
if (isInCombat()) {
close();
GameMessage gameMsg("SPELL_RESULT", msg);
gameMsg._value = xp;
g_events->focusedView()->send(gameMsg);
} else {
Sound::sound(SOUND_2);
_spellResult = msg;
_spellResultX = xp;
setState(ENDING);
}
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,92 @@
/* 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_SPELLS_CAST_SPELL_H
#define MM1_VIEWS_SPELLS_CAST_SPELL_H
#include "mm/mm1/views/spells/spell_view.h"
#include "mm/mm1/views/text_entry.h"
#include "mm/mm1/game/spell_casting.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class CastSpell : public SpellView, public MM1::Game::SpellCasting {
enum State {
NONE, SELECT_SPELL, SELECT_NUMBER, SELECT_CHAR, PRESS_ENTER, ENDING
};
private:
State _state = SELECT_SPELL;
TextEntry _textEntry;
static void abortFunc();
static void enterSpellLevelFunc(const Common::String &text);
static void enterSpellNumberFunc(const Common::String &text);
int _spellLevel = -1;
int _spellNumber = -1;
Common::String _spellResult;
int _spellResultX = -1;
private:
/**
* Set the current state
*/
void setState(State state);
/**
* Spell level number entered
*/
void spellLevelEntered(uint level);
/**
* Spell number entered
*/
void spellNumberEntered(uint num);
/**
* Cast the spell
*/
void performSpell(Character *chr = nullptr);
/**
* Spell done or failed
*/
void spellDone();
void spellDone(const Common::String &msg, int xp);
public:
CastSpell();
virtual ~CastSpell() {
}
bool msgGame(const GameMessage &msg) override;
bool msgFocus(const FocusMessage &msg) override;
void draw() override;
bool msgAction(const ActionMessage &msg) override;
void timeout() override;
};
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,69 @@
/* 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/spells/detect_magic.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
DetectMagic::DetectMagic() : SpellView("DetectMagic") {
_bounds = getLineBounds(20, 24);
}
void DetectMagic::draw() {
clearSurface();
escToGoBack(0);
writeString(0, 0, STRING["dialogs.spells.detect_charges"]);
_textPos.x = 20;
_textPos.y = 0;
getMagicStrings();
Inventory &inv = g_globals->_currCharacter->_backpack;
for (uint i = 0; i < inv.size(); ++i) {
writeChar('A' + i);
writeChar(')');
writeString(_strings[i]);
// Move to write position for next item (if any)
if (_textPos.x < 30) {
_textPos.x = 30;
} else {
_textPos.x = 20;
_textPos.y++;
}
}
}
bool DetectMagic::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_SELECT || msg._action == KEYBIND_ESCAPE)
close();
return true;
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,61 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_SPELLS_DETECT_MAGIC_H
#define MM1_VIEWS_SPELLS_DETECT_MAGIC_H
#include "mm/mm1/views/spells/spell_view.h"
#include "mm/mm1/game/detect_magic.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class DetectMagic : public SpellView, public MM1::Game::DetectMagic {
public:
/**
* Constructor
*/
DetectMagic();
/**
* Destructor
*/
virtual ~DetectMagic() {}
/**
* Draw the view contents
*/
void draw() override;
/**
* Action handler
*/
bool msgAction(const ActionMessage &msg) override;
};
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,70 @@
/* 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/spells/duplication.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
Duplication::Duplication() : SpellView("Duplication") {
_bounds = getLineBounds(20, 24);
}
void Duplication::draw() {
clearSurface();
escToGoBack(0);
writeString(10, 0, STRING["dialogs.character.which"]);
}
bool Duplication::msgKeypress(const KeypressMessage &msg) {
Inventory &inv = g_globals->_currCharacter->_backpack;
if (msg.keycode >= Common::KEYCODE_a &&
msg.keycode < (Common::KEYCODE_a + (int)inv.size())) {
int itemIndex = msg.keycode - Common::KEYCODE_a;
if (duplicate(*g_globals->_currCharacter, inv, itemIndex))
spellDone();
else
spellFailed();
}
return true;
}
bool Duplication::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
spellFailed();
return true;
}
return false;
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,72 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_SPELLS_DUPLICATION_H
#define MM1_VIEWS_SPELLS_DUPLICATION_H
#include "mm/mm1/views/spells/spell_view.h"
#include "mm/mm1/game/duplication.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class Duplication : public SpellView, public MM1::Game::Duplication {
private:
enum Mode { SELECT_ITEM, CAST };
//Mode _mode = SELECT_ITEM;
//char _direction = '\0';
//int _squares = 0;
public:
/**
* Constructor
*/
Duplication();
/**
* Destructor
*/
virtual ~Duplication() {}
/**
* 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 Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,97 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "mm/mm1/views/spells/fly.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
Fly::Fly() : SpellView("Fly") {
_bounds = getLineBounds(21, 24);
}
bool Fly::msgFocus(const FocusMessage &msg) {
SpellView::msgFocus(msg);
_mode = SELECT_X;
_xIndex = _yIndex = 0;
return false;
}
void Fly::draw() {
clearSurface();
escToGoBack(0);
writeString(9, 0, STRING["dialogs.spells.fly_to_x"]);
writeChar((_mode == SELECT_X) ? '_' : 'A' + _xIndex);
if (_mode == SELECT_Y || _mode == CAST) {
writeString(16, 1, STRING["dialogs.spells.fly_to_y"]);
writeChar((_mode == SELECT_Y) ? '_' : '1' + _yIndex);
}
if (_mode == CAST) {
writeString(24, 3, STRING["spells.enter_to_cast"]);
}
}
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;
redraw();
}
return true;
}
bool Fly::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
fly(-1);
return true;
} else if (_mode == CAST && msg._action == KEYBIND_SELECT) {
// Spell was cast
close();
int mapIndex = _yIndex * 5 + _xIndex;
fly(mapIndex);
}
return false;
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,76 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_SPELLS_FLY_H
#define MM1_VIEWS_SPELLS_FLY_H
#include "mm/mm1/views/spells/spell_view.h"
#include "mm/mm1/game/fly.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class Fly : public SpellView, 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;
};
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,108 @@
/* 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/spells/location.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
Location::Location() : SpellView("Location") {
_bounds = getLineBounds(20, 24);
}
void Location::draw() {
Maps::Maps &maps = *g_maps;
Maps::Map &map = *maps._currentMap;
byte v;
clearSurface();
escToGoBack(0);
writeString(0, 0, STRING["dialogs.spells.location_loc"]);
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"]);
}
writeString(21, 0, STRING["dialogs.spells.location_sector"]);
writeChar(map[Maps::MAP_SECTOR1] & 0x7f);
writeChar('-');
writeChar(map[Maps::MAP_SECTOR2] & 0x7f);
writeString(21, 1, STRING["dialogs.spells.location_surface_x"]);
writeString("X=");
if (map[Maps::MAP_TYPE]) {
writeNumber(map[Maps::MAP_SURFACE_X]);
writeString(35, 1, "Y=");
writeNumber(map[Maps::MAP_SURFACE_Y]);
writeString(22, 2, STRING["dialogs.spells.location_inside_x"]);
writeString("X=");
}
writeNumber(maps._mapPos.x);
writeString(35, 2, "Y=");
writeNumber(maps._mapPos.y);
writeString(22, 3, STRING["dialogs.spells.location_facing"]);
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;
}
}
}
bool Location::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_SELECT || msg._action == KEYBIND_ESCAPE)
close();
return true;
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,60 @@
/* 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_SPELLS_LOCATION_H
#define MM1_VIEWS_SPELLS_LOCATION_H
#include "mm/mm1/views/spells/spell_view.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class Location : public SpellView {
public:
/**
* Constructor
*/
Location();
/**
* Destructor
*/
virtual ~Location() {}
/**
* Draw the view contents
*/
void draw() override;
/**
* Action handler
*/
bool msgAction(const ActionMessage &msg) override;
};
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,71 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "mm/mm1/views/spells/recharge_item.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
RechargeItem::RechargeItem() : SpellView("RechargeItem") {
_bounds = getLineBounds(20, 24);
}
void RechargeItem::draw() {
clearSurface();
escToGoBack(0);
writeString(10, 0, STRING["dialogs.character.which"]);
}
bool RechargeItem::msgKeypress(const KeypressMessage &msg) {
Inventory &inv = g_globals->_currCharacter->_backpack;
if (msg.keycode >= Common::KEYCODE_a &&
msg.keycode < (Common::KEYCODE_a + (int)inv.size())) {
int itemIndex = msg.keycode - Common::KEYCODE_a;
if (charge(inv, itemIndex)) {
spellDone();
} else {
spellFailed();
}
}
return true;
}
bool RechargeItem::msgAction(const ActionMessage &msg) {
if (msg._action == KEYBIND_ESCAPE) {
close();
return true;
}
return false;
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View 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/>.
*
*/
#ifndef MM1_VIEWS_SPELLS_RECHARGE_ITEM_H
#define MM1_VIEWS_SPELLS_RECHARGE_ITEM_H
#include "mm/mm1/views/spells/spell_view.h"
#include "mm/mm1/game/recharge_item.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class RechargeItem : public SpellView, public MM1::Game::RechargeItem {
public:
/**
* Constructor
*/
RechargeItem();
/**
* Destructor
*/
virtual ~RechargeItem() {}
/**
* 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 Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,61 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "mm/mm1/views/spells/spell_view.h"
#include "mm/mm1/globals.h"
#include "mm/mm1/sound.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
void SpellView::spellFailed() {
// Spell failed
clearSurface();
writeString(10, 2, STRING["spells.failed"]);
Sound::sound(SOUND_2);
delaySeconds(3);
}
void SpellView::spellDone() {
clearSurface();
writeString(14, 2, STRING["spells.done"]);
g_globals->_party.updateAC();
Sound::sound(SOUND_2);
delaySeconds(3);
}
void SpellView::timeout() {
close();
}
bool SpellView::msgFocus(const FocusMessage &msg) {
MetaEngine::setKeybindingMode(KeybindingMode::KBMODE_MENUS);
return true;
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View 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/>.
*
*/
#ifndef MM1_VIEWS_SPELLS_SPELL_VIEW_H
#define MM1_VIEWS_SPELLS_SPELL_VIEW_H
#include "common/str.h"
#include "mm/mm1/views/text_view.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class SpellView : public TextView {
public:
SpellView(const Common::String &name) : TextView(name) {}
SpellView(const Common::String &name, UIElement *owner) :
TextView(name, owner) {}
virtual ~SpellView() {}
/**
* Spell failed display
*/
void spellFailed();
/**
* Spell done display
*/
void spellDone();
/**
* Timeout for the failed/done display
*/
void timeout() override;
/**
* Called when the view is focused
*/
bool msgFocus(const FocusMessage &msg) override;
};
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM
#endif

View File

@@ -0,0 +1,129 @@
/* 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/spells/teleport.h"
#include "mm/mm1/globals.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
Teleport::Teleport() : SpellView("Teleport") {
_bounds = getLineBounds(20, 24);
}
bool Teleport::msgFocus(const FocusMessage &msg) {
SpellView::msgFocus(msg);
_mode = SELECT_DIRECTION;
return false;
}
void Teleport::draw() {
clearSurface();
escToGoBack(0);
writeString(10, 1, STRING["dialogs.spells.teleport_dir"]);
writeChar((_mode == SELECT_DIRECTION) ? '_' : _direction);
if (_mode != SELECT_DIRECTION) {
writeString(11, 2, STRING["dialogs.spells.teleport_squares"]);
writeChar((_mode == SELECT_SQUARES) ? '_' : '0' + _squares);
}
if (_mode == CAST)
writeString(23, 4, STRING["spells.enter_to_cast"]);
}
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;
if (map[Maps::MAP_FLAGS] & 2) {
spellFailed();
} 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;
}
close();
send("Game", GameMessage("UPDATE"));
}
}
} // namespace Spells
} // namespace Views
} // namespace MM1
} // namespace MM

View File

@@ -0,0 +1,83 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef MM1_VIEWS_SPELLS_TELEPORT_H
#define MM1_VIEWS_SPELLS_TELEPORT_H
#include "mm/mm1/views/spells/spell_view.h"
namespace MM {
namespace MM1 {
namespace Views {
namespace Spells {
class Teleport : public SpellView {
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 Views
} // namespace MM1
} // namespace MM
#endif