forked from teamnwah/openmw-tes3coop
clean up interfaces
This commit is contained in:
parent
2a06d72e32
commit
83e758ee50
11 changed files with 121 additions and 464 deletions
|
@ -29,6 +29,7 @@ namespace ESM
|
||||||
struct Class;
|
struct Class;
|
||||||
struct Potion;
|
struct Potion;
|
||||||
struct Spell;
|
struct Spell;
|
||||||
|
struct NPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace MWRender
|
namespace MWRender
|
||||||
|
@ -249,6 +250,11 @@ namespace MWBase
|
||||||
///< Create a new recrod (of type cell) in the ESM store.
|
///< Create a new recrod (of type cell) in the ESM store.
|
||||||
/// \return ID, pointer to created record
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0;
|
||||||
|
///< Create a new recrod (of type npc) in the ESM store.
|
||||||
|
///< \note special treatment for 'player' record
|
||||||
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
|
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
|
||||||
int mode, int number = 1) = 0;
|
int mode, int number = 1) = 0;
|
||||||
///< Run animation for a MW-reference. Calls to this function for references that are
|
///< Run animation for a MW-reference. Calls to this function for references that are
|
||||||
|
@ -296,12 +302,6 @@ namespace MWBase
|
||||||
/// 1 - only waiting \n
|
/// 1 - only waiting \n
|
||||||
/// 2 - player is underwater \n
|
/// 2 - player is underwater \n
|
||||||
/// 3 - enemies are nearby (not implemented)
|
/// 3 - enemies are nearby (not implemented)
|
||||||
|
|
||||||
/// Update player record part with given value
|
|
||||||
virtual void updatePlayer(int flag, const std::string &value) = 0;
|
|
||||||
|
|
||||||
/// Update player record part with given value
|
|
||||||
virtual void updatePlayer(int flag, bool value) = 0;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,7 +108,8 @@ namespace MWGui
|
||||||
|
|
||||||
void LevelupDialog::open()
|
void LevelupDialog::open()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayer().getPlayer();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
MWWorld::Ptr player = world->getPlayer().getPlayer();
|
||||||
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
|
MWMechanics::CreatureStats& creatureStats = MWWorld::Class::get(player).getCreatureStats (player);
|
||||||
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
MWMechanics::NpcStats& pcStats = MWWorld::Class::get(player).getNpcStats (player);
|
||||||
|
|
||||||
|
@ -119,9 +120,11 @@ namespace MWGui
|
||||||
|
|
||||||
setAttributeValues();
|
setAttributeValues();
|
||||||
|
|
||||||
|
const ESM::NPC *playerData = player.get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
// set class image
|
// set class image
|
||||||
const ESM::Class *cls =
|
const ESM::Class *cls =
|
||||||
MWBase::Environment::get().getWorld ()->getPlayer ().getClass ();
|
world->getStore().get<ESM::Class>().find(playerData->mClass);
|
||||||
|
|
||||||
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
|
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
|
||||||
|
|
||||||
|
|
|
@ -252,12 +252,12 @@ void StatsWindow::onFrame ()
|
||||||
}
|
}
|
||||||
|
|
||||||
setFactions(PCstats.getFactionRanks());
|
setFactions(PCstats.getFactionRanks());
|
||||||
|
/*
|
||||||
const ESM::BirthSign *sign =
|
const ESM::BirthSign *sign =
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().getBirthsign();
|
MWBase::Environment::get().getWorld()->getPlayer().getBirthsign();
|
||||||
|
|
||||||
setBirthSign((sign != 0) ? sign->mId : "");
|
setBirthSign((sign != 0) ? sign->mId : "");
|
||||||
|
*/
|
||||||
if (mChanged)
|
if (mChanged)
|
||||||
updateSkillArea();
|
updateSkillArea();
|
||||||
}
|
}
|
||||||
|
@ -429,11 +429,13 @@ void StatsWindow::updateSkillArea()
|
||||||
if (!mMiscSkills.empty())
|
if (!mMiscSkills.empty())
|
||||||
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
addSkills(mMiscSkills, "sSkillClassMisc", "Misc Skills", coord1, coord2);
|
||||||
|
|
||||||
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
const MWWorld::ESMStore &store = world->getStore();
|
||||||
|
const ESM::NPC *player =
|
||||||
|
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
// race tooltip
|
// race tooltip
|
||||||
const ESM::Race* playerRace =
|
const ESM::Race* playerRace = store.get<ESM::Race>().find(player->mRace);
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().getRace();
|
|
||||||
|
|
||||||
MyGUI::Widget* raceWidget;
|
MyGUI::Widget* raceWidget;
|
||||||
getWidget(raceWidget, "RaceText");
|
getWidget(raceWidget, "RaceText");
|
||||||
|
@ -445,7 +447,7 @@ void StatsWindow::updateSkillArea()
|
||||||
MyGUI::Widget* classWidget;
|
MyGUI::Widget* classWidget;
|
||||||
|
|
||||||
const ESM::Class *playerClass =
|
const ESM::Class *playerClass =
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().getClass();
|
store.get<ESM::Class>().find(player->mClass);
|
||||||
|
|
||||||
getWidget(classWidget, "ClassText");
|
getWidget(classWidget, "ClassText");
|
||||||
ToolTips::createClassToolTip(classWidget, *playerClass);
|
ToolTips::createClassToolTip(classWidget, *playerClass);
|
||||||
|
|
|
@ -37,14 +37,17 @@ namespace MWMechanics
|
||||||
creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance);
|
creatureStats.getAttribute(5).setBase (player->mNpdt52.mEndurance);
|
||||||
creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality);
|
creatureStats.getAttribute(6).setBase (player->mNpdt52.mPersonality);
|
||||||
creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck);
|
creatureStats.getAttribute(7).setBase (player->mNpdt52.mLuck);
|
||||||
|
|
||||||
|
const MWWorld::ESMStore &esmStore =
|
||||||
|
MWBase::Environment::get().getWorld()->getStore();
|
||||||
|
|
||||||
// race
|
// race
|
||||||
if (mRaceSelected)
|
if (mRaceSelected)
|
||||||
{
|
{
|
||||||
const ESM::Race *race =
|
const ESM::Race *race =
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().getRace();
|
esmStore.get<ESM::Race>().find(player->mRace);
|
||||||
|
|
||||||
bool male = MWBase::Environment::get().getWorld()->getPlayer().isMale();
|
bool male = (player->mFlags & ESM::NPC::Female) == 0;
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
{
|
{
|
||||||
|
@ -87,11 +90,11 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
// birthsign
|
// birthsign
|
||||||
const ESM::BirthSign *sign =
|
if (!mSign.empty())
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().getBirthsign();
|
|
||||||
|
|
||||||
if (sign != 0)
|
|
||||||
{
|
{
|
||||||
|
const ESM::BirthSign *sign =
|
||||||
|
esmStore.get<ESM::BirthSign>().find(mSign);
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin());
|
for (std::vector<std::string>::const_iterator iter (sign->mPowers.mList.begin());
|
||||||
iter!=sign->mPowers.mList.end(); ++iter)
|
iter!=sign->mPowers.mList.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
@ -103,7 +106,7 @@ namespace MWMechanics
|
||||||
if (mClassSelected)
|
if (mClassSelected)
|
||||||
{
|
{
|
||||||
const ESM::Class *class_ =
|
const ESM::Class *class_ =
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().getClass();
|
esmStore.get<ESM::Class>().find(player->mClass);
|
||||||
|
|
||||||
for (int i=0; i<2; ++i)
|
for (int i=0; i<2; ++i)
|
||||||
{
|
{
|
||||||
|
@ -132,7 +135,7 @@ namespace MWMechanics
|
||||||
}
|
}
|
||||||
|
|
||||||
const MWWorld::Store<ESM::Skill> &skills =
|
const MWWorld::Store<ESM::Skill> &skills =
|
||||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>();
|
esmStore.get<ESM::Skill>();
|
||||||
|
|
||||||
MWWorld::Store<ESM::Skill>::iterator iter = skills.begin();
|
MWWorld::Store<ESM::Skill>::iterator iter = skills.begin();
|
||||||
for (; iter != skills.end(); ++iter)
|
for (; iter != skills.end(); ++iter)
|
||||||
|
@ -263,13 +266,19 @@ namespace MWMechanics
|
||||||
// basic player profile; should not change anymore after the creation phase is finished.
|
// basic player profile; should not change anymore after the creation phase is finished.
|
||||||
MWBase::WindowManager *winMgr =
|
MWBase::WindowManager *winMgr =
|
||||||
MWBase::Environment::get().getWindowManager();
|
MWBase::Environment::get().getWindowManager();
|
||||||
|
|
||||||
MWWorld::Player &player =
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
MWBase::Environment::get().getWorld()->getPlayer();
|
const ESM::NPC *player =
|
||||||
|
world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
winMgr->setValue ("name", player.getName());
|
const ESM::Race *race =
|
||||||
winMgr->setValue ("race", player.getRace()->mName);
|
world->getStore().get<ESM::Race>().find(player->mRace);
|
||||||
winMgr->setValue ("class", player.getClass()->mName);
|
const ESM::Class *cls =
|
||||||
|
world->getStore().get<ESM::Class>().find(player->mClass);
|
||||||
|
|
||||||
|
winMgr->setValue ("name", player->mName);
|
||||||
|
winMgr->setValue ("race", race->mName);
|
||||||
|
winMgr->setValue ("class", cls->mName);
|
||||||
|
|
||||||
mUpdatePlayer = false;
|
mUpdatePlayer = false;
|
||||||
|
|
||||||
|
@ -278,8 +287,8 @@ namespace MWMechanics
|
||||||
|
|
||||||
for (int i=0; i<5; ++i)
|
for (int i=0; i<5; ++i)
|
||||||
{
|
{
|
||||||
minorSkills[i] = player.getClass()->mData.mSkills[i][0];
|
minorSkills[i] = cls->mData.mSkills[i][0];
|
||||||
majorSkills[i] = player.getClass()->mData.mSkills[i][1];
|
majorSkills[i] = cls->mData.mSkills[i][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
winMgr->configureSkills (majorSkills, minorSkills);
|
winMgr->configureSkills (majorSkills, minorSkills);
|
||||||
|
@ -295,14 +304,33 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::setPlayerName (const std::string& name)
|
void MechanicsManager::setPlayerName (const std::string& name)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setName (name);
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
ESM::NPC player =
|
||||||
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
player.mName = name;
|
||||||
|
|
||||||
|
world->createRecord(player);
|
||||||
|
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
void MechanicsManager::setPlayerRace (const std::string& race, bool male)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setGender (male);
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setRace (race);
|
|
||||||
|
ESM::NPC player =
|
||||||
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
|
||||||
|
player.mRace = race;
|
||||||
|
|
||||||
|
player.mFlags |= ESM::NPC::Female;
|
||||||
|
if (male) {
|
||||||
|
player.mFlags ^= ESM::NPC::Female;
|
||||||
|
}
|
||||||
|
|
||||||
|
world->createRecord(player);
|
||||||
|
|
||||||
mRaceSelected = true;
|
mRaceSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
|
@ -310,14 +338,21 @@ namespace MWMechanics
|
||||||
|
|
||||||
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
void MechanicsManager::setPlayerBirthsign (const std::string& id)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setBirthsign (id);
|
mSign = id;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MechanicsManager::setPlayerClass (const std::string& id)
|
void MechanicsManager::setPlayerClass (const std::string& id)
|
||||||
{
|
{
|
||||||
MWBase::Environment::get().getWorld()->getPlayer().setClass(id);
|
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||||
|
|
||||||
|
ESM::NPC player =
|
||||||
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
player.mClass = id;
|
||||||
|
|
||||||
|
world->createRecord(player);
|
||||||
|
|
||||||
mClassSelected = true;
|
mClassSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
mUpdatePlayer = true;
|
mUpdatePlayer = true;
|
||||||
|
@ -329,7 +364,11 @@ namespace MWMechanics
|
||||||
|
|
||||||
const ESM::Class *ptr = world->createRecord(cls);
|
const ESM::Class *ptr = world->createRecord(cls);
|
||||||
|
|
||||||
world->getPlayer().setClass(ptr->mId);
|
ESM::NPC player =
|
||||||
|
*world->getPlayer().getPlayer().get<ESM::NPC>()->mBase;
|
||||||
|
player.mClass = ptr->mId;
|
||||||
|
|
||||||
|
world->createRecord(player);
|
||||||
|
|
||||||
mClassSelected = true;
|
mClassSelected = true;
|
||||||
buildPlayer();
|
buildPlayer();
|
||||||
|
|
|
@ -29,6 +29,7 @@ namespace MWMechanics
|
||||||
bool mUpdatePlayer;
|
bool mUpdatePlayer;
|
||||||
bool mClassSelected;
|
bool mClassSelected;
|
||||||
bool mRaceSelected;
|
bool mRaceSelected;
|
||||||
|
std::string mSign;
|
||||||
Actors mActors;
|
Actors mActors;
|
||||||
|
|
||||||
void buildPlayer();
|
void buildPlayer();
|
||||||
|
|
|
@ -146,13 +146,13 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
Store<T> &get() {
|
const T *insert(const T &x) {
|
||||||
throw std::runtime_error("Storage for this type not exist (non-const)");
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
T *insert(const T &x) {
|
|
||||||
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
Store<T> &store = const_cast<Store<T> &>(get<T>());
|
||||||
|
if (store.search(x.mId) != 0) {
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << "Try to override existing record '" << x.mId << "'";
|
||||||
|
throw std::runtime_error(msg.str());
|
||||||
|
}
|
||||||
T record = x;
|
T record = x;
|
||||||
|
|
||||||
std::ostringstream id;
|
std::ostringstream id;
|
||||||
|
@ -173,10 +173,30 @@ namespace MWWorld
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) {
|
inline const ESM::Cell *ESMStore::insert<ESM::Cell>(const ESM::Cell &cell) {
|
||||||
return mCells.insert(cell);
|
return mCells.insert(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline const ESM::NPC *ESMStore::insert<ESM::NPC>(const ESM::NPC &npc) {
|
||||||
|
if (StringUtils::ciEqual(npc.mId, "player")) {
|
||||||
|
return mNpcs.insert(npc);
|
||||||
|
} else if (mNpcs.search(npc.mId) != 0) {
|
||||||
|
std::ostringstream msg;
|
||||||
|
msg << "Try to override existing record '" << npc.mId << "'";
|
||||||
|
throw std::runtime_error(msg.str());
|
||||||
|
}
|
||||||
|
ESM::NPC record = npc;
|
||||||
|
|
||||||
|
std::ostringstream id;
|
||||||
|
id << "$dynamic" << mDynamicCount++;
|
||||||
|
record.mId = id.str();
|
||||||
|
|
||||||
|
ESM::NPC *ptr = mNpcs.insert(record);
|
||||||
|
mIds[ptr->mId] = ESM::REC_NPC_;
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
inline const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const {
|
inline const Store<ESM::Activator> &ESMStore::get<ESM::Activator>() const {
|
||||||
return mActivators;
|
return mActivators;
|
||||||
|
@ -401,231 +421,6 @@ namespace MWWorld
|
||||||
inline const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const {
|
inline const Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() const {
|
||||||
return mAttributes;
|
return mAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Activator> &ESMStore::get<ESM::Activator>() {
|
|
||||||
return mActivators;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Potion> &ESMStore::get<ESM::Potion>() {
|
|
||||||
return mPotions;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Apparatus> &ESMStore::get<ESM::Apparatus>() {
|
|
||||||
return mAppas;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Armor> &ESMStore::get<ESM::Armor>() {
|
|
||||||
return mArmors;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::BodyPart> &ESMStore::get<ESM::BodyPart>() {
|
|
||||||
return mBodyParts;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Book> &ESMStore::get<ESM::Book>() {
|
|
||||||
return mBooks;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::BirthSign> &ESMStore::get<ESM::BirthSign>() {
|
|
||||||
return mBirthSigns;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Class> &ESMStore::get<ESM::Class>() {
|
|
||||||
return mClasses;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Clothing> &ESMStore::get<ESM::Clothing>() {
|
|
||||||
return mClothes;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::LoadCNTC> &ESMStore::get<ESM::LoadCNTC>() {
|
|
||||||
return mContChange;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Container> &ESMStore::get<ESM::Container>() {
|
|
||||||
return mContainers;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Creature> &ESMStore::get<ESM::Creature>() {
|
|
||||||
return mCreatures;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::LoadCREC> &ESMStore::get<ESM::LoadCREC>() {
|
|
||||||
return mCreaChange;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Dialogue> &ESMStore::get<ESM::Dialogue>() {
|
|
||||||
return mDialogs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Door> &ESMStore::get<ESM::Door>() {
|
|
||||||
return mDoors;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Enchantment> &ESMStore::get<ESM::Enchantment>() {
|
|
||||||
return mEnchants;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Faction> &ESMStore::get<ESM::Faction>() {
|
|
||||||
return mFactions;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Global> &ESMStore::get<ESM::Global>() {
|
|
||||||
return mGlobals;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Ingredient> &ESMStore::get<ESM::Ingredient>() {
|
|
||||||
return mIngreds;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::CreatureLevList> &ESMStore::get<ESM::CreatureLevList>() {
|
|
||||||
return mCreatureLists;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::ItemLevList> &ESMStore::get<ESM::ItemLevList>() {
|
|
||||||
return mItemLists;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Light> &ESMStore::get<ESM::Light>() {
|
|
||||||
return mLights;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Tool> &ESMStore::get<ESM::Tool>() {
|
|
||||||
return mLockpicks;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Miscellaneous> &ESMStore::get<ESM::Miscellaneous>() {
|
|
||||||
return mMiscItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::NPC> &ESMStore::get<ESM::NPC>() {
|
|
||||||
return mNpcs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::LoadNPCC> &ESMStore::get<ESM::LoadNPCC>() {
|
|
||||||
return mNpcChange;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Probe> &ESMStore::get<ESM::Probe>() {
|
|
||||||
return mProbes;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Race> &ESMStore::get<ESM::Race>() {
|
|
||||||
return mRaces;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Region> &ESMStore::get<ESM::Region>() {
|
|
||||||
return mRegions;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Repair> &ESMStore::get<ESM::Repair>() {
|
|
||||||
return mRepairs;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::SoundGenerator> &ESMStore::get<ESM::SoundGenerator>() {
|
|
||||||
return mSoundGens;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Sound> &ESMStore::get<ESM::Sound>() {
|
|
||||||
return mSounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Spell> &ESMStore::get<ESM::Spell>() {
|
|
||||||
return mSpells;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::StartScript> &ESMStore::get<ESM::StartScript>() {
|
|
||||||
return mStartScripts;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Static> &ESMStore::get<ESM::Static>() {
|
|
||||||
return mStatics;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Weapon> &ESMStore::get<ESM::Weapon>() {
|
|
||||||
return mWeapons;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::GameSetting> &ESMStore::get<ESM::GameSetting>() {
|
|
||||||
return mGameSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Script> &ESMStore::get<ESM::Script>() {
|
|
||||||
return mScripts;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Cell> &ESMStore::get<ESM::Cell>() {
|
|
||||||
return mCells;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Land> &ESMStore::get<ESM::Land>() {
|
|
||||||
return mLands;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::LandTexture> &ESMStore::get<ESM::LandTexture>() {
|
|
||||||
return mLandTextures;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Pathgrid> &ESMStore::get<ESM::Pathgrid>() {
|
|
||||||
return mPathgrids;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::MagicEffect> &ESMStore::get<ESM::MagicEffect>() {
|
|
||||||
return mMagicEffects;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Skill> &ESMStore::get<ESM::Skill>() {
|
|
||||||
return mSkills;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
inline Store<ESM::Attribute> &ESMStore::get<ESM::Attribute>() {
|
|
||||||
return mAttributes;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -15,9 +15,6 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
Player::Player (const ESM::NPC *player, const MWBase::World& world)
|
Player::Player (const ESM::NPC *player, const MWBase::World& world)
|
||||||
: mCellStore(0),
|
: mCellStore(0),
|
||||||
mClass(0),
|
|
||||||
mRace(0),
|
|
||||||
mSign(0),
|
|
||||||
mAutoMove(false),
|
mAutoMove(false),
|
||||||
mForwardBackward (0)
|
mForwardBackward (0)
|
||||||
{
|
{
|
||||||
|
@ -26,9 +23,6 @@ namespace MWWorld
|
||||||
|
|
||||||
float* playerPos = mPlayer.mData.getPosition().pos;
|
float* playerPos = mPlayer.mData.getPosition().pos;
|
||||||
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
playerPos[0] = playerPos[1] = playerPos[2] = 0;
|
||||||
|
|
||||||
mClass = world.getStore().get<ESM::Class>().find (player->mClass);
|
|
||||||
mRace = world.getStore().get<ESM::Race>().find(player->mRace);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setDrawState (MWMechanics::DrawState_ state)
|
void Player::setDrawState (MWMechanics::DrawState_ state)
|
||||||
|
@ -91,36 +85,4 @@ namespace MWWorld
|
||||||
MWWorld::Ptr ptr = getPlayer();
|
MWWorld::Ptr ptr = getPlayer();
|
||||||
return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState();
|
return MWWorld::Class::get(ptr).getNpcStats(ptr).getDrawState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setName(const std::string &value)
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWorld()->updatePlayer(Data_Name, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setGender(bool value)
|
|
||||||
{
|
|
||||||
MWBase::Environment::get().getWorld()->updatePlayer(Data_Male, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setRace(const std::string &value)
|
|
||||||
{
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
||||||
world->updatePlayer(Data_Race, value);
|
|
||||||
|
|
||||||
mRace = world->getStore().get<ESM::Race>().find(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setBirthsign(const std::string &value)
|
|
||||||
{
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
||||||
mSign = world->getStore().get<ESM::BirthSign>().find(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setClass(const std::string &value)
|
|
||||||
{
|
|
||||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
|
||||||
world->updatePlayer(Data_Class, value);
|
|
||||||
|
|
||||||
mClass = world->getStore().get<ESM::Class>().find(value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,25 +22,10 @@ namespace MWWorld
|
||||||
LiveCellRef<ESM::NPC> mPlayer;
|
LiveCellRef<ESM::NPC> mPlayer;
|
||||||
MWWorld::CellStore *mCellStore;
|
MWWorld::CellStore *mCellStore;
|
||||||
|
|
||||||
// cached referenced data
|
|
||||||
const ESM::Class *mClass;
|
|
||||||
const ESM::Race *mRace;
|
|
||||||
const ESM::BirthSign *mSign;
|
|
||||||
|
|
||||||
bool mAutoMove;
|
bool mAutoMove;
|
||||||
int mForwardBackward;
|
int mForwardBackward;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum {
|
|
||||||
Data_Male,
|
|
||||||
Data_Name,
|
|
||||||
Data_Race,
|
|
||||||
Data_Class,
|
|
||||||
Data_Sign,
|
|
||||||
Data_Model,
|
|
||||||
Data_Head,
|
|
||||||
Data_Hair
|
|
||||||
};
|
|
||||||
|
|
||||||
Player(const ESM::NPC *player, const MWBase::World& world);
|
Player(const ESM::NPC *player, const MWBase::World& world);
|
||||||
|
|
||||||
|
@ -55,39 +40,8 @@ namespace MWWorld
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setName (const std::string& name);
|
|
||||||
void setGender (bool male);
|
|
||||||
void setRace (const std::string& race);
|
|
||||||
void setBirthsign (const std::string& birthsign);
|
|
||||||
void setClass (const std::string &cls);
|
|
||||||
|
|
||||||
void setDrawState (MWMechanics::DrawState_ state);
|
void setDrawState (MWMechanics::DrawState_ state);
|
||||||
|
|
||||||
std::string getName() const
|
|
||||||
{
|
|
||||||
return mPlayer.mBase->mName;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isMale() const
|
|
||||||
{
|
|
||||||
return (mPlayer.mBase->mFlags & 0x1) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ESM::Race *getRace() const
|
|
||||||
{
|
|
||||||
return mRace;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ESM::BirthSign *getBirthsign() const
|
|
||||||
{
|
|
||||||
return mSign;
|
|
||||||
}
|
|
||||||
|
|
||||||
const ESM::Class *getClass() const
|
|
||||||
{
|
|
||||||
return mClass;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool getAutoMove() const
|
bool getAutoMove() const
|
||||||
{
|
{
|
||||||
return mAutoMove;
|
return mAutoMove;
|
||||||
|
|
|
@ -168,26 +168,6 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T *search(const std::string &id) {
|
|
||||||
std::string key = StringUtils::lowerCase(id);
|
|
||||||
typename Dynamic::iterator dit = mDynamic.find(key);
|
|
||||||
|
|
||||||
if (dit != mDynamic.end()) {
|
|
||||||
return &dit->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
T *find(const std::string &id) {
|
|
||||||
T *ptr = search(id);
|
|
||||||
if (ptr == 0) {
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "Object '" << id << "' not found (non-const)";
|
|
||||||
throw std::runtime_error(msg.str());
|
|
||||||
}
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
T *insert(const T &item) {
|
T *insert(const T &item) {
|
||||||
std::string id = StringUtils::lowerCase(item.mId);
|
std::string id = StringUtils::lowerCase(item.mId);
|
||||||
std::pair<typename Dynamic::iterator, bool> result =
|
std::pair<typename Dynamic::iterator, bool> result =
|
||||||
|
@ -523,43 +503,6 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ESM::Cell *search(const std::string &id) {
|
|
||||||
std::string key = StringUtils::lowerCase(id);
|
|
||||||
DynamicInt::iterator it = mDynamicInt.find(key);
|
|
||||||
if (it != mDynamicInt.end()) {
|
|
||||||
return &it->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::Cell *find(const std::string &id) {
|
|
||||||
ESM::Cell *ptr = search(id);
|
|
||||||
if (ptr == 0) {
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "Interior '" << id << "' not found (non-const)";
|
|
||||||
throw std::runtime_error(msg.str());
|
|
||||||
}
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::Cell *search(int x, int y) {
|
|
||||||
DynamicExt::iterator it = mDynamicExt.find(std::make_pair(x, y));
|
|
||||||
if (it != mDynamicExt.end()) {
|
|
||||||
return &it->second;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::Cell *find(int x, int y) {
|
|
||||||
ESM::Cell *ptr = search(x, y);
|
|
||||||
if (ptr == 0) {
|
|
||||||
std::ostringstream msg;
|
|
||||||
msg << "Exterior at (" << x << ", " << y << ") not found (non-const)";
|
|
||||||
throw std::runtime_error(msg.str());
|
|
||||||
}
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESM::Cell *insert(const ESM::Cell &cell) {
|
ESM::Cell *insert(const ESM::Cell &cell) {
|
||||||
if (search(cell) != 0) {
|
if (search(cell) != 0) {
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
|
|
|
@ -799,6 +799,11 @@ namespace MWWorld
|
||||||
return mStore.insert(record);
|
return mStore.insert(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ESM::NPC *World::createRecord(const ESM::NPC &record)
|
||||||
|
{
|
||||||
|
return mStore.insert(record);
|
||||||
|
}
|
||||||
|
|
||||||
void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
|
void World::playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName, int mode,
|
||||||
int number)
|
int number)
|
||||||
{
|
{
|
||||||
|
@ -1055,12 +1060,12 @@ namespace MWWorld
|
||||||
// door leads to exterior, use cell name (if any), otherwise translated region name
|
// door leads to exterior, use cell name (if any), otherwise translated region name
|
||||||
int x,y;
|
int x,y;
|
||||||
positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y);
|
positionToIndex (ref.mRef.mDoorDest.pos[0], ref.mRef.mDoorDest.pos[1], x, y);
|
||||||
const ESM::Cell* cell = ((const ESMStore &) mStore).get<ESM::Cell>().find(x,y);
|
const ESM::Cell* cell = mStore.get<ESM::Cell>().find(x,y);
|
||||||
if (cell->mName != "")
|
if (cell->mName != "")
|
||||||
dest = cell->mName;
|
dest = cell->mName;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest = ((const ESMStore &) mStore).get<ESM::Region>().find(cell->mRegion)->mName;
|
dest = mStore.get<ESM::Region>().find(cell->mRegion)->mName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,51 +1254,4 @@ namespace MWWorld
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::updatePlayer(int flag, const std::string &value)
|
|
||||||
{
|
|
||||||
ESM::NPC *player = mStore.get<ESM::NPC>().find("player");
|
|
||||||
|
|
||||||
switch (flag) {
|
|
||||||
case Player::Data_Name:
|
|
||||||
player->mName = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Player::Data_Class:
|
|
||||||
mStore.get<ESM::Class>().erase(player->mClass);
|
|
||||||
player->mClass = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Player::Data_Race:
|
|
||||||
player->mRace = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Player::Data_Model:
|
|
||||||
player->mModel = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Player::Data_Head:
|
|
||||||
player->mHead = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Player::Data_Hair:
|
|
||||||
player->mHair = value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void World::updatePlayer(int flag, bool value)
|
|
||||||
{
|
|
||||||
ESM::NPC *player = mStore.get<ESM::NPC>().find("player");
|
|
||||||
|
|
||||||
if (flag == Player::Data_Male) {
|
|
||||||
player->mFlags |= 0x1;
|
|
||||||
if (value) {
|
|
||||||
player->mFlags ^= 0x1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,6 +266,12 @@ namespace MWWorld
|
||||||
///< Create a new recrod (of type cell) in the ESM store.
|
///< Create a new recrod (of type cell) in the ESM store.
|
||||||
/// \return ID, pointer to created record
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
virtual const ESM::NPC *createRecord(const ESM::NPC &record);
|
||||||
|
///< Create a new recrod (of type npc) in the ESM store.
|
||||||
|
///< \note special treatment for 'player' record
|
||||||
|
/// \return ID, pointer to created record
|
||||||
|
|
||||||
|
|
||||||
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
|
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
|
||||||
int mode, int number = 1);
|
int mode, int number = 1);
|
||||||
///< Run animation for a MW-reference. Calls to this function for references that are
|
///< Run animation for a MW-reference. Calls to this function for references that are
|
||||||
|
@ -327,12 +333,6 @@ namespace MWWorld
|
||||||
/// 1 - only waiting \n
|
/// 1 - only waiting \n
|
||||||
/// 2 - player is underwater \n
|
/// 2 - player is underwater \n
|
||||||
/// 3 - enemies are nearby (not implemented)
|
/// 3 - enemies are nearby (not implemented)
|
||||||
|
|
||||||
/// Update player record part with given value
|
|
||||||
virtual void updatePlayer(int flag, const std::string &value);
|
|
||||||
|
|
||||||
/// Update player record part with given value
|
|
||||||
virtual void updatePlayer(int flag, bool value);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue