2020-12-18 22:21:10 +00:00
|
|
|
#ifndef GAME_MWBASE_LUAMANAGER_H
|
|
|
|
#define GAME_MWBASE_LUAMANAGER_H
|
|
|
|
|
2022-07-30 17:10:36 +00:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2021-06-26 21:10:24 +00:00
|
|
|
#include <variant>
|
2022-07-30 17:10:36 +00:00
|
|
|
|
2020-12-18 22:21:10 +00:00
|
|
|
#include <SDL_events.h>
|
|
|
|
|
2022-02-21 19:49:00 +00:00
|
|
|
#include <components/sdlutil/events.hpp>
|
|
|
|
|
2020-12-18 22:21:10 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Ptr;
|
|
|
|
}
|
|
|
|
|
2021-01-29 01:38:09 +00:00
|
|
|
namespace Loading
|
|
|
|
{
|
|
|
|
class Listener;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
2021-04-23 00:49:12 +00:00
|
|
|
struct LuaScripts;
|
2021-01-29 01:38:09 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 22:21:10 +00:00
|
|
|
namespace MWBase
|
|
|
|
{
|
|
|
|
|
|
|
|
class LuaManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~LuaManager() = default;
|
|
|
|
|
|
|
|
virtual void newGameStarted() = 0;
|
2021-09-25 08:46:47 +00:00
|
|
|
virtual void gameLoaded() = 0;
|
2021-04-21 02:11:11 +00:00
|
|
|
virtual void objectAddedToScene(const MWWorld::Ptr& ptr) = 0;
|
|
|
|
virtual void objectRemovedFromScene(const MWWorld::Ptr& ptr) = 0;
|
2022-05-12 16:03:50 +00:00
|
|
|
virtual void itemConsumed(const MWWorld::Ptr& consumable, const MWWorld::Ptr& actor) = 0;
|
2022-02-01 23:42:56 +00:00
|
|
|
virtual void objectActivated(const MWWorld::Ptr& object, const MWWorld::Ptr& actor) = 0;
|
2021-04-21 02:11:11 +00:00
|
|
|
// TODO: notify LuaManager about other events
|
|
|
|
// virtual void objectOnHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object,
|
|
|
|
// const MWWorld::Ptr &attacker, const osg::Vec3f &hitPosition, bool successful) = 0;
|
2020-12-18 22:21:10 +00:00
|
|
|
|
2021-06-26 21:10:24 +00:00
|
|
|
struct InputEvent
|
|
|
|
{
|
2022-02-21 19:49:00 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
KeyPressed,
|
|
|
|
KeyReleased,
|
|
|
|
ControllerPressed,
|
|
|
|
ControllerReleased,
|
|
|
|
Action,
|
|
|
|
TouchPressed,
|
|
|
|
TouchReleased,
|
|
|
|
TouchMoved,
|
|
|
|
} mType;
|
|
|
|
std::variant<SDL_Keysym, int, SDLUtil::TouchEvent> mValue;
|
2021-06-26 21:10:24 +00:00
|
|
|
};
|
|
|
|
virtual void inputEvent(const InputEvent& event) = 0;
|
|
|
|
|
2021-04-23 00:49:12 +00:00
|
|
|
struct ActorControls
|
|
|
|
{
|
2021-07-12 09:01:32 +00:00
|
|
|
bool mDisableAI = false;
|
2021-08-02 23:40:44 +00:00
|
|
|
bool mChanged = false;
|
2021-07-12 09:01:32 +00:00
|
|
|
|
|
|
|
bool mJump = false;
|
|
|
|
bool mRun = false;
|
2022-12-05 22:31:23 +00:00
|
|
|
bool mSneak = false;
|
2021-07-12 09:01:32 +00:00
|
|
|
float mMovement = 0;
|
|
|
|
float mSideMovement = 0;
|
2022-02-01 18:47:20 +00:00
|
|
|
float mPitchChange = 0;
|
|
|
|
float mYawChange = 0;
|
|
|
|
int mUse = 0;
|
2020-12-18 22:21:10 +00:00
|
|
|
};
|
|
|
|
|
2021-04-18 20:09:01 +00:00
|
|
|
virtual ActorControls* getActorControls(const MWWorld::Ptr&) const = 0;
|
2020-12-18 22:21:10 +00:00
|
|
|
|
|
|
|
virtual void clear() = 0;
|
|
|
|
virtual void setupPlayer(const MWWorld::Ptr&) = 0;
|
2021-01-29 01:38:09 +00:00
|
|
|
|
|
|
|
// Saving
|
2022-10-05 21:45:17 +00:00
|
|
|
int countSavedGameRecords() const { return 1; }
|
2021-01-29 01:38:09 +00:00
|
|
|
virtual void write(ESM::ESMWriter& writer, Loading::Listener& progress) = 0;
|
|
|
|
virtual void saveLocalScripts(const MWWorld::Ptr& ptr, ESM::LuaScripts& data) = 0;
|
|
|
|
|
|
|
|
// Loading from a save
|
|
|
|
virtual void readRecord(ESM::ESMReader& reader, uint32_t type) = 0;
|
|
|
|
virtual void loadLocalScripts(const MWWorld::Ptr& ptr, const ESM::LuaScripts& data) = 0;
|
|
|
|
|
|
|
|
// Should be called before loading. The map is used to fix refnums if the order of content files was changed.
|
|
|
|
virtual void setContentFileMapping(const std::map<int, int>&) = 0;
|
2021-04-12 01:15:17 +00:00
|
|
|
|
|
|
|
// Drops script cache and reloads all scripts. Calls `onSave` and `onLoad` for every script.
|
|
|
|
virtual void reloadAllScripts() = 0;
|
2022-04-09 21:07:57 +00:00
|
|
|
|
|
|
|
virtual void handleConsoleCommand(
|
|
|
|
const std::string& consoleMode, const std::string& command, const MWWorld::Ptr& selectedPtr)
|
|
|
|
= 0;
|
2022-11-26 20:25:18 +00:00
|
|
|
|
|
|
|
virtual std::string formatResourceUsageStats() const = 0;
|
2020-12-18 22:21:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // GAME_MWBASE_LUAMANAGER_H
|