mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-07 03:54:40 +00:00
added foundation for esm record class hierarchy
This commit is contained in:
parent
b584215680
commit
a70c3876a2
@ -2,33 +2,33 @@ project(OpenMW)
|
||||
|
||||
# local files
|
||||
|
||||
set(GAME
|
||||
set(GAME
|
||||
main.cpp
|
||||
engine.cpp)
|
||||
set(GAME_HEADER
|
||||
set(GAME_HEADER
|
||||
engine.hpp)
|
||||
source_group(game FILES ${GAME} ${GAME_HEADER})
|
||||
|
||||
set(GAMEREND
|
||||
set(GAMEREND
|
||||
mwrender/mwscene.cpp
|
||||
mwrender/cellimp.cpp
|
||||
mwrender/interior.cpp
|
||||
mwrender/sky.cpp)
|
||||
set(GAMEREND_HEADER
|
||||
set(GAMEREND_HEADER
|
||||
mwrender/cell.hpp
|
||||
mwrender/cellimp.hpp
|
||||
mwrender/mwscene.hpp
|
||||
mwrender/interior.hpp
|
||||
mwrender/playerpos.hpp
|
||||
mwrender/sky.hpp)
|
||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||
source_group(apps\\openmw\\mwrender FILES ${GAMEREND} ${GAMEREND_HEADER})
|
||||
|
||||
set(GAMEINPUT
|
||||
mwinput/inputmanager.cpp
|
||||
)
|
||||
set(GAMEINPUT_HEADER
|
||||
set(GAMEINPUT_HEADER
|
||||
mwinput/inputmanager.hpp)
|
||||
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
||||
source_group(apps\\openmw\\mwinput FILES ${GAMEINPUT} ${GAMEINPUT_HEADER})
|
||||
|
||||
set(GAMEGUI_HEADER
|
||||
mwgui/mw_layouts.hpp
|
||||
@ -54,7 +54,7 @@ set(GAMESCRIPT
|
||||
mwscript/extensions.cpp
|
||||
mwscript/globalscripts.cpp
|
||||
)
|
||||
set(GAMESCRIPT_HEADER
|
||||
set(GAMESCRIPT_HEADER
|
||||
mwscript/locals.hpp
|
||||
mwscript/scriptmanager.hpp
|
||||
mwscript/compilercontext.hpp
|
||||
@ -68,35 +68,41 @@ set(GAMESCRIPT_HEADER
|
||||
mwscript/extensions.hpp
|
||||
mwscript/globalscripts.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||
source_group(apps\\openmw\\mwscript FILES ${GAMESCRIPT} ${GAMESCRIPT_HEADER})
|
||||
|
||||
set(GAMESOUND
|
||||
mwsound/soundmanager.cpp)
|
||||
set(GAMESOUND_HEADER
|
||||
set(GAMESOUND_HEADER
|
||||
mwsound/soundmanager.hpp)
|
||||
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
|
||||
source_group(apps\\openmw\\mwsound FILES ${GAMESOUND} ${GAMESOUND_HEADER})
|
||||
|
||||
set(GAMEWORLD
|
||||
mwworld/world.cpp
|
||||
mwworld/globals.cpp
|
||||
mwworld/class.cpp
|
||||
mwworld/classes.cpp
|
||||
mwworld/activator.cpp
|
||||
)
|
||||
set(GAMEWORLD_HEADER
|
||||
set(GAMEWORLD_HEADER
|
||||
mwworld/refdata.hpp
|
||||
mwworld/world.hpp
|
||||
mwworld/ptr.hpp
|
||||
mwworld/environment.hpp
|
||||
mwworld/globals.hpp
|
||||
mwworld/class.hpp
|
||||
mwworld/classes.hpp
|
||||
mwworld/activator.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||
source_group(apps\\openmw\\mwworld FILES ${GAMEWORLD} ${GAMEWORLD_HEADER})
|
||||
|
||||
set(GAMEMECHANICS
|
||||
mwmechanics/mechanicsmanager.cpp)
|
||||
set(GAMEMECHANICS_HEADER
|
||||
set(GAMEMECHANICS_HEADER
|
||||
mwmechanics/mechanicsmanager.hpp
|
||||
mwmechanics/stat.hpp
|
||||
mwmechanics/creaturestats.hpp
|
||||
)
|
||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||
source_group(apps\\openmw\\mwmechanics FILES ${GAMEMECHANICS} ${GAMEMECHANICS_HEADER})
|
||||
|
||||
set(OPENMW_CPP ${GAME} ${GAMEREND} ${GAMEINPUT} ${GAMESCRIPT} ${GAMESOUND} ${GAMEGUI} ${GAMEWORLD}
|
||||
${GAMEMECHANICS}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "mwworld/world.hpp"
|
||||
#include "mwworld/ptr.hpp"
|
||||
#include "mwworld/environment.hpp"
|
||||
#include "mwworld/classes.hpp"
|
||||
|
||||
#include "mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
@ -78,6 +79,7 @@ OMW::Engine::Engine()
|
||||
, mScriptManager (0)
|
||||
, mScriptContext (0)
|
||||
{
|
||||
MWWorld::registerClasses();
|
||||
}
|
||||
|
||||
OMW::Engine::~Engine()
|
||||
|
14
apps/openmw/mwworld/activator.cpp
Normal file
14
apps/openmw/mwworld/activator.cpp
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
#include "activator.hpp"
|
||||
|
||||
#include <components/esm/loadacti.hpp>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void Activator::registerSelf()
|
||||
{
|
||||
boost::shared_ptr<Class> instance (new Activator);
|
||||
|
||||
registerClass (typeid (ESM::Activator).name(), instance);
|
||||
}
|
||||
}
|
17
apps/openmw/mwworld/activator.hpp
Normal file
17
apps/openmw/mwworld/activator.hpp
Normal file
@ -0,0 +1,17 @@
|
||||
#ifndef GAME_MWWORLD_ACTIVATOR_H
|
||||
#define GAME_MWWORLD_ACTIVATOR_H
|
||||
|
||||
#include "class.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class Activator : public Class
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
static void registerSelf();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
28
apps/openmw/mwworld/class.cpp
Normal file
28
apps/openmw/mwworld/class.cpp
Normal file
@ -0,0 +1,28 @@
|
||||
|
||||
#include "class.hpp"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> > Class::sClasses;
|
||||
|
||||
Class::Class() {}
|
||||
|
||||
Class::~Class() {}
|
||||
|
||||
const Class& Class::get (const std::string& key)
|
||||
{
|
||||
std::map<std::string, boost::shared_ptr<Class> >::const_iterator iter = sClasses.find (key);
|
||||
|
||||
if (iter==sClasses.end())
|
||||
throw std::logic_error ("unknown class key: " + key);
|
||||
|
||||
return *iter->second;
|
||||
}
|
||||
|
||||
void Class::registerClass (const std::string& key, boost::shared_ptr<Class> instance)
|
||||
{
|
||||
sClasses.insert (std::make_pair (key, instance));
|
||||
}
|
||||
}
|
37
apps/openmw/mwworld/class.hpp
Normal file
37
apps/openmw/mwworld/class.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
#ifndef GAME_MWWORLD_CLASS_H
|
||||
#define GAME_MWWORLD_CLASS_H
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
/// \brief Base class for referenceable esm records
|
||||
class Class
|
||||
{
|
||||
static std::map<std::string, boost::shared_ptr<Class> > sClasses;
|
||||
|
||||
// not implemented
|
||||
Class (const Class&);
|
||||
Class& operator= (const Class&);
|
||||
|
||||
protected:
|
||||
|
||||
Class();
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Class();
|
||||
|
||||
|
||||
|
||||
static const Class& get (const std::string& key);
|
||||
///< If there is no class for this \a key, an exception is thrown.
|
||||
|
||||
static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
12
apps/openmw/mwworld/classes.cpp
Normal file
12
apps/openmw/mwworld/classes.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
#include "classes.hpp"
|
||||
|
||||
#include "activator.hpp"
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void registerClasses()
|
||||
{
|
||||
Activator::registerSelf();
|
||||
}
|
||||
}
|
10
apps/openmw/mwworld/classes.hpp
Normal file
10
apps/openmw/mwworld/classes.hpp
Normal file
@ -0,0 +1,10 @@
|
||||
#ifndef GAME_MWWORLD_CLASSES_H
|
||||
#define GAME_MWWORLD_CLASSES_H
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
void registerClasses();
|
||||
///< register all known classes
|
||||
}
|
||||
|
||||
#endif
|
@ -27,6 +27,7 @@ namespace MWWorld
|
||||
ESM::CellRef *mCellRef;
|
||||
RefData *mRefData;
|
||||
CellStore *mCell;
|
||||
std::string mTypeName;
|
||||
|
||||
public:
|
||||
|
||||
@ -43,6 +44,11 @@ namespace MWWorld
|
||||
return mPtr.type();
|
||||
}
|
||||
|
||||
const std::string& getTypeName() const
|
||||
{
|
||||
return mTypeName;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
|
||||
{
|
||||
@ -50,6 +56,7 @@ namespace MWWorld
|
||||
mCellRef = &liveCellRef->ref;
|
||||
mRefData = &liveCellRef->mData;
|
||||
mCell = cell;
|
||||
mTypeName = typeid (T).name();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
|
Loading…
Reference in New Issue
Block a user