Initial commit
This commit is contained in:
61
engines/ultima/shared/actions/action.cpp
Normal file
61
engines/ultima/shared/actions/action.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/shared/actions/action.h"
|
||||
#include "ultima/shared/early/game.h"
|
||||
#include "ultima/shared/maps/map.h"
|
||||
#include "ultima/shared/gfx/visual_item.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
namespace Actions {
|
||||
|
||||
Action::Action(TreeItem *parent) : TreeItem() {
|
||||
assert(parent);
|
||||
addUnder(parent);
|
||||
}
|
||||
|
||||
Game *Action::getGame() {
|
||||
return static_cast<Game *>(TreeItem::getGame());
|
||||
}
|
||||
|
||||
Maps::Map *Action::getMap() {
|
||||
return static_cast<Maps::Map *>(getGame()->getMap());
|
||||
}
|
||||
|
||||
void Action::addInfoMsg(const Common::String &text, bool newLine, bool replaceLine) {
|
||||
CInfoMsg msg(text, newLine, replaceLine);
|
||||
msg.execute(getView());
|
||||
}
|
||||
|
||||
void Action::playFX(uint effectId) {
|
||||
getGame()->playFX(effectId);
|
||||
}
|
||||
|
||||
void Action::endOfTurn() {
|
||||
getGame()->endOfTurn();
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
|
||||
85
engines/ultima/shared/actions/action.h
Normal file
85
engines/ultima/shared/actions/action.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* 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_SHARED_ACTIONS_ACTION_H
|
||||
#define ULTIMA_SHARED_ACTIONS_ACTION_H
|
||||
|
||||
#include "ultima/shared/core/tree_item.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
|
||||
class Game;
|
||||
|
||||
namespace Maps {
|
||||
class Map;
|
||||
}
|
||||
|
||||
namespace Actions {
|
||||
|
||||
/**
|
||||
* Base class for implementing the various actions the player can do, such as moving, climbing, entering, etc.
|
||||
*/
|
||||
class Action : public TreeItem {
|
||||
protected:
|
||||
/**
|
||||
* Signals the end of the turn
|
||||
*/
|
||||
void endOfTurn();
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Action(TreeItem *parent);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Action() override {}
|
||||
|
||||
/**
|
||||
* Jumps up through the parents to find the root game
|
||||
*/
|
||||
Game *getGame();
|
||||
|
||||
/**
|
||||
* Return the game's map
|
||||
*/
|
||||
Maps::Map *getMap();
|
||||
|
||||
/**
|
||||
* Adds a text string to the info area
|
||||
* @param text Text to add
|
||||
* @param newLine Whether to apply a newline at the end
|
||||
*/
|
||||
void addInfoMsg(const Common::String &text, bool newLine = true, bool replaceLine = false);
|
||||
|
||||
/**
|
||||
* Play a sound effect
|
||||
*/
|
||||
void playFX(uint effectId);
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
40
engines/ultima/shared/actions/huh.cpp
Normal file
40
engines/ultima/shared/actions/huh.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* 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/shared/actions/huh.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Huh, Action)
|
||||
ON_MESSAGE(HuhMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Huh::HuhMsg(CHuhMsg *msg) {
|
||||
addInfoMsg(_text);
|
||||
endOfTurn();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
55
engines/ultima/shared/actions/huh.h
Normal file
55
engines/ultima/shared/actions/huh.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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_SHARED_ACTIONS_HUH_H
|
||||
#define ULTIMA_SHARED_ACTIONS_HUH_H
|
||||
|
||||
#include "ultima/shared/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
namespace Actions {
|
||||
|
||||
class Huh : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool HuhMsg(CHuhMsg *msg);
|
||||
private:
|
||||
const char *&_text;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Huh(TreeItem *parent, const char *&text) : Action(parent), _text(text) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Huh() override {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
40
engines/ultima/shared/actions/pass.cpp
Normal file
40
engines/ultima/shared/actions/pass.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/* 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/shared/actions/pass.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Pass, Action)
|
||||
ON_MESSAGE(PassMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Pass::PassMsg(CPassMsg *msg) {
|
||||
addInfoMsg(_text);
|
||||
endOfTurn();
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
55
engines/ultima/shared/actions/pass.h
Normal file
55
engines/ultima/shared/actions/pass.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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_SHARED_ACTIONS_PASS_H
|
||||
#define ULTIMA_SHARED_ACTIONS_PASS_H
|
||||
|
||||
#include "ultima/shared/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Shared {
|
||||
namespace Actions {
|
||||
|
||||
class Pass : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool PassMsg(CPassMsg *msg);
|
||||
private:
|
||||
const char *&_text;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Pass(TreeItem *parent, const char *&text) : Action(parent), _text(text) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Pass() override {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user