Initial commit
This commit is contained in:
47
engines/ultima/ultima1/actions/action.cpp
Normal file
47
engines/ultima/ultima1/actions/action.cpp
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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/shared/gfx/visual_item.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
Ultima1Game *Action::getGame() {
|
||||
return static_cast<Ultima1Game *>(TreeItem::getGame());
|
||||
}
|
||||
|
||||
Maps::Ultima1Map *Action::getMap() {
|
||||
return static_cast<Maps::Ultima1Map *>(getGame()->getMap());
|
||||
}
|
||||
|
||||
GameResources *Action::getRes() {
|
||||
return getGame()->_res;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
70
engines/ultima/ultima1/actions/action.h
Normal file
70
engines/ultima/ultima1/actions/action.h
Normal 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_ACTION_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_ACTION_H
|
||||
|
||||
#include "ultima/shared/actions/action.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
class GameResources;
|
||||
namespace Maps {
|
||||
class Ultima1Map;
|
||||
}
|
||||
|
||||
namespace Actions {
|
||||
|
||||
class Action : public Shared::Actions::Action {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Action(TreeItem *parent) : Shared::Actions::Action(parent) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Action() override {}
|
||||
|
||||
/**
|
||||
* Jumps up through the parents to find the root game
|
||||
*/
|
||||
Ultima1Game *getGame();
|
||||
|
||||
/**
|
||||
* Return the game's map
|
||||
*/
|
||||
Maps::Ultima1Map *getMap();
|
||||
|
||||
/**
|
||||
* Gets the data resources for the game
|
||||
*/
|
||||
GameResources *getRes();
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
135
engines/ultima/ultima1/actions/attack.cpp
Normal file
135
engines/ultima/ultima1/actions/attack.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/* 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 "ultima/ultima1/actions/attack.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(AttackFire, Action)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool AttackFire::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
Shared::Maps::Direction dir = Shared::Maps::MapWidget::directionFromKey(msg->_keyState.keycode);
|
||||
|
||||
if (dir == Shared::Maps::DIR_NONE) {
|
||||
addInfoMsg(game->_res->NOTHING);
|
||||
playFX(1);
|
||||
game->endOfTurn();
|
||||
} else {
|
||||
addInfoMsg(game->_res->DIRECTION_NAMES[(int)dir - 1]);
|
||||
doAttack(dir);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
BEGIN_MESSAGE_MAP(Attack, AttackFire)
|
||||
ON_MESSAGE(AttackMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Attack::AttackMsg(CAttackMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(getMap());
|
||||
const Shared::Character &c = *game->_party;
|
||||
const Shared::Weapon &weapon = *c._weapons[c._equippedWeapon];
|
||||
|
||||
addInfoMsg(Common::String::format("%s %s", game->_res->ACTION_NAMES[0], weapon._shortName.c_str()), false);
|
||||
|
||||
if (weapon._distance == 0) {
|
||||
addInfoMsg("?");
|
||||
game->playFX(1);
|
||||
game->endOfTurn();
|
||||
} else if (map->_mapType == Maps::MAP_DUNGEON) {
|
||||
// In the dungeons, attacks always are straight ahead
|
||||
addInfoMsg("");
|
||||
doAttack(Shared::Maps::DIR_UP);
|
||||
} else if (msg->_direction == Shared::Maps::DIR_NONE) {
|
||||
// Prompt user for direction
|
||||
addInfoMsg(": ", false);
|
||||
Shared::CInfoGetKeypress keyMsg(this);
|
||||
keyMsg.execute(getGame());
|
||||
} else {
|
||||
addInfoMsg(": ", false);
|
||||
addInfoMsg(game->_res->DIRECTION_NAMES[(int)msg->_direction - 1]);
|
||||
|
||||
getMap()->attack(msg->_direction, 7);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Attack::doAttack(Shared::Maps::Direction dir) {
|
||||
getMap()->attack(dir, 7);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
BEGIN_MESSAGE_MAP(Fire, AttackFire)
|
||||
ON_MESSAGE(FireMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Fire::FireMsg(CFireMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(getMap());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[5], false);
|
||||
|
||||
if (map->_mapType != Maps::MAP_OVERWORLD) {
|
||||
// Not on the overworld
|
||||
addInfoMsg("?");
|
||||
playFX(1);
|
||||
endOfTurn();
|
||||
} else {
|
||||
Widgets::Transport *transport = dynamic_cast<Widgets::Transport *>(getMap()->getPlayerWidget());
|
||||
if (transport && !transport->getWeaponsName().empty()) {
|
||||
// Prompt user for direction
|
||||
addInfoMsg(Common::String::format(" %s: ", transport->getWeaponsName().c_str()), false);
|
||||
Shared::CInfoGetKeypress keyMsg(this);
|
||||
keyMsg.execute(getGame());
|
||||
} else {
|
||||
// Not in a transport that has weapons
|
||||
addInfoMsg(game->_res->WHAT);
|
||||
playFX(1);
|
||||
endOfTurn();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Fire::doAttack(Shared::Maps::Direction dir) {
|
||||
getMap()->attack(dir, 8);
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
102
engines/ultima/ultima1/actions/attack.h
Normal file
102
engines/ultima/ultima1/actions/attack.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* 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 ULTIMA_ULTIMA1_ACTIONS_ATTACK_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_ATTACK_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/maps/map_widget.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CCharacterInputMsg;
|
||||
using Shared::CAttackMsg;
|
||||
using Shared::CFireMsg;
|
||||
|
||||
/**
|
||||
* Common base class for attack and fire actions
|
||||
*/
|
||||
class AttackFire : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
protected:
|
||||
/**
|
||||
* Do the attack in a given direction
|
||||
*/
|
||||
virtual void doAttack(Shared::Maps::Direction dir) = 0;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
AttackFire(TreeItem *parent) : Action(parent) {}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Attack action
|
||||
*/
|
||||
class Attack : public AttackFire {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool AttackMsg(CAttackMsg *msg);
|
||||
protected:
|
||||
/**
|
||||
* Do the attack in a given direction
|
||||
*/
|
||||
void doAttack(Shared::Maps::Direction dir) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Attack(TreeItem *parent) : AttackFire(parent) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fire action
|
||||
*/
|
||||
class Fire : public AttackFire {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool FireMsg(CFireMsg *msg);
|
||||
protected:
|
||||
/**
|
||||
* Do the attack in a given direction
|
||||
*/
|
||||
void doAttack(Shared::Maps::Direction dir) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Fire(TreeItem *parent) : AttackFire(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
45
engines/ultima/ultima1/actions/cast.cpp
Normal file
45
engines/ultima/ultima1/actions/cast.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/cast.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/core/character.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Cast, Action)
|
||||
ON_MESSAGE(CastMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Cast::CastMsg(CCastMsg &msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[17], false);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/cast.h
Normal file
50
engines/ultima/ultima1/actions/cast.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_CAST_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_CAST_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CCastMsg;
|
||||
|
||||
class Cast : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CastMsg(CCastMsg &msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Cast(TreeItem *parent);
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
58
engines/ultima/ultima1/actions/map_action.h
Normal file
58
engines/ultima/ultima1/actions/map_action.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_MAP_ACTION_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_MAP_ACTION_H
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
#define MAP_ACTION(NAME, ACTION_NUM, MAP_METHOD) \
|
||||
using Shared::C##NAME##Msg; \
|
||||
class NAME : public Action { DECLARE_MESSAGE_MAP; bool NAME##Msg(C##NAME##Msg *msg) { \
|
||||
addInfoMsg(getRes()->ACTION_NAMES[ACTION_NUM], false); \
|
||||
getMap()->MAP_METHOD(); \
|
||||
return true; } \
|
||||
public: \
|
||||
CLASSDEF; \
|
||||
NAME(TreeItem *parent) : Action(parent) {} \
|
||||
}; \
|
||||
BEGIN_MESSAGE_MAP(NAME, Action) ON_MESSAGE(NAME##Msg) END_MESSAGE_MAP()
|
||||
|
||||
#define MAP_ACTION_END_TURN(NAME, ACTION_NUM, MAP_METHOD) \
|
||||
using Shared::C##NAME##Msg; \
|
||||
class NAME : public Action { DECLARE_MESSAGE_MAP; bool NAME##Msg(C##NAME##Msg *msg) { \
|
||||
addInfoMsg(getRes()->ACTION_NAMES[ACTION_NUM], false); \
|
||||
getMap()->MAP_METHOD(); \
|
||||
endOfTurn(); \
|
||||
return true; } \
|
||||
public: \
|
||||
CLASSDEF; \
|
||||
NAME(TreeItem *parent) : Action(parent) {} \
|
||||
}; \
|
||||
BEGIN_MESSAGE_MAP(NAME, Action) ON_MESSAGE(NAME##Msg) END_MESSAGE_MAP()
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
181
engines/ultima/ultima1/actions/move.cpp
Normal file
181
engines/ultima/ultima1/actions/move.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/* 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 "ultima/ultima1/actions/move.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Move, Action)
|
||||
ON_MESSAGE(MoveMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Move::MoveMsg(CMoveMsg *msg) {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
if (map->_mapType == Maps::MAP_DUNGEON) {
|
||||
switch (msg->_direction) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
dungeonTurnLeft();
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
dungeonTurnRight();
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
dungeonTurnAround();
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
dungeonMoveForward();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Shared::Maps::MapWidget *player = map->getPlayerWidget();
|
||||
assert(player);
|
||||
|
||||
// Figure out the new position
|
||||
Point delta;
|
||||
switch (msg->_direction) {
|
||||
case Shared::Maps::DIR_WEST:
|
||||
delta = Point(-1, 0);
|
||||
break;
|
||||
case Shared::Maps::DIR_EAST:
|
||||
delta = Point(1, 0);
|
||||
break;
|
||||
case Shared::Maps::DIR_NORTH:
|
||||
delta = Point(0, -1);
|
||||
break;
|
||||
case Shared::Maps::DIR_SOUTH:
|
||||
delta = Point(0, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if the player's widget type can move to the new position
|
||||
Point newPos = map->getDeltaPosition(delta);
|
||||
if (player->canMoveTo(newPos) == Shared::Maps::MapWidget::YES) {
|
||||
// Shift the viewport
|
||||
map->shiftViewport(delta);
|
||||
|
||||
// Move to the new position
|
||||
player->moveTo(newPos);
|
||||
addInfoMsg(getRes()->DIRECTION_NAMES[msg->_direction - 1]);
|
||||
} else {
|
||||
// Nope, so show a blocked message
|
||||
addInfoMsg(getRes()->BLOCKED);
|
||||
playFX(1);
|
||||
}
|
||||
}
|
||||
|
||||
endOfTurn();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Move::dungeonTurnLeft() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
switch (map->getDirection()) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
map->setDirection(Shared::Maps::DIR_DOWN);
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
map->setDirection(Shared::Maps::DIR_UP);
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
map->setDirection(Shared::Maps::DIR_RIGHT);
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
map->setDirection(Shared::Maps::DIR_LEFT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_LEFT - 1]);
|
||||
}
|
||||
|
||||
void Move::dungeonTurnRight() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
switch (map->getDirection()) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
map->setDirection(Shared::Maps::DIR_UP);
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
map->setDirection(Shared::Maps::DIR_DOWN);
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
map->setDirection(Shared::Maps::DIR_LEFT);
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
map->setDirection(Shared::Maps::DIR_RIGHT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_RIGHT - 1]);
|
||||
}
|
||||
|
||||
void Move::dungeonTurnAround() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
switch (map->getDirection()) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
map->setDirection(Shared::Maps::DIR_RIGHT);
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
map->setDirection(Shared::Maps::DIR_LEFT);
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
map->setDirection(Shared::Maps::DIR_UP);
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
map->setDirection(Shared::Maps::DIR_DOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_DOWN - 1]);
|
||||
}
|
||||
|
||||
void Move::dungeonMoveForward() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
Point delta = map->getDirectionDelta();
|
||||
Shared::Maps::MapWidget *player = map->getPlayerWidget();
|
||||
assert(player);
|
||||
|
||||
if (player->canMoveTo(map->getPosition() + delta) != Shared::Maps::MapWidget::NO) {
|
||||
map->setPosition(map->getPosition() + delta);
|
||||
} else {
|
||||
playFX(0);
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_UP - 1]);
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
75
engines/ultima/ultima1/actions/move.h
Normal file
75
engines/ultima/ultima1/actions/move.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* 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 ULTIMA_ULTIMA1_ACTIONS_MOVE_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_MOVE_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CMoveMsg;
|
||||
|
||||
class Move : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool MoveMsg(CMoveMsg *msg);
|
||||
private:
|
||||
/**
|
||||
* Turn left
|
||||
*/
|
||||
void dungeonTurnLeft();
|
||||
|
||||
/**
|
||||
* Turn right
|
||||
*/
|
||||
void dungeonTurnRight();
|
||||
|
||||
/**
|
||||
* Turn around
|
||||
*/
|
||||
void dungeonTurnAround();
|
||||
|
||||
/**
|
||||
* Move forwards
|
||||
*/
|
||||
void dungeonMoveForward();
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Move(Shared::TreeItem *parent) : Action(parent) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Move() override {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
46
engines/ultima/ultima1/actions/quit.cpp
Normal file
46
engines/ultima/ultima1/actions/quit.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/quit.h"
|
||||
#include "ultima/ultima1/u1dialogs/stats.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Quit, Action)
|
||||
ON_MESSAGE(QuitMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Quit::QuitMsg(CQuitMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[16]);
|
||||
g_vm->saveGameDialog();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/quit.h
Normal file
50
engines/ultima/ultima1/actions/quit.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_QUIT_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_QUIT_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CQuitMsg;
|
||||
|
||||
class Quit : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool QuitMsg(CQuitMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Quit(TreeItem *parent) : Action(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
47
engines/ultima/ultima1/actions/ready.cpp
Normal file
47
engines/ultima/ultima1/actions/ready.cpp
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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/ready.h"
|
||||
#include "ultima/ultima1/u1dialogs/ready.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Ready, Action)
|
||||
ON_MESSAGE(ReadyMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Ready::ReadyMsg(CReadyMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[17], false);
|
||||
|
||||
U1Dialogs::Ready *dialog = new U1Dialogs::Ready(game);
|
||||
dialog->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/ready.h
Normal file
50
engines/ultima/ultima1/actions/ready.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_READY_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_READY_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CReadyMsg;
|
||||
|
||||
class Ready : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ReadyMsg(CReadyMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ready(TreeItem *parent) : Action(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
47
engines/ultima/ultima1/actions/stats.cpp
Normal file
47
engines/ultima/ultima1/actions/stats.cpp
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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/stats.h"
|
||||
#include "ultima/ultima1/u1dialogs/stats.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Stats, Action)
|
||||
ON_MESSAGE(StatsMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Stats::StatsMsg(CStatsMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[25]);
|
||||
|
||||
U1Dialogs::Stats *dialog = new U1Dialogs::Stats(game);
|
||||
dialog->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/stats.h
Normal file
50
engines/ultima/ultima1/actions/stats.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_STATS_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_STATS_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CStatsMsg;
|
||||
|
||||
class Stats : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool StatsMsg(CStatsMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Stats(TreeItem *parent) : Action(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user