Merge remote-tracking branch 'zini/master' into animations

Conflicts:
	apps/openmw/mwworld/worldimp.cpp
pull/16/head
Chris Robinson 12 years ago
commit 15a2eeebb8

@ -368,7 +368,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
mEnvironment.setWorld( new MWWorld::World (*mOgre, mFileCollections, mMaster, mPlugins,
mResDir, mCfgMgr.getCachePath(), mNewGame, mEncoder, mFallbackMap,
mActivationDistanceOverride));
MWBase::Environment::get().getWorld()->setupPlayer(mNewGame);
MWBase::Environment::get().getWorld()->setupPlayer();
//Load translation data
mTranslationDataStorage.setEncoder(mEncoder);

@ -323,9 +323,11 @@ namespace MWBase
virtual void changeVanityModeScale(float factor) = 0;
virtual bool vanityRotateCamera(float * rot) = 0;
virtual void setupPlayer(bool newGame) = 0;
virtual void setupPlayer() = 0;
virtual void renderPlayer() = 0;
virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door) = 0;
///< if activated, should this door be opened or closed?
virtual void activateDoor(const MWWorld::Ptr& door) = 0;
///< activate (open or close) an non-teleport door

@ -375,12 +375,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell);
}
short Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
float Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>();
return ref->mBase->mData.mEnchant;
return ref->mBase->mData.mEnchant/10.f;
}
bool Armor::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -77,7 +77,7 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
};

@ -176,12 +176,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell);
}
short Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
float Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>();
return ref->mBase->mData.mEnchant;
return ref->mBase->mData.mEnchant/10.f;
}
bool Book::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -58,7 +58,7 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
};

@ -295,12 +295,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell);
}
short Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
float Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
return ref->mBase->mData.mEnchant;
return ref->mBase->mData.mEnchant/10.f;
}
bool Clothing::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -71,7 +71,7 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
};

@ -141,7 +141,7 @@ namespace MWClass
{
// animated door
boost::shared_ptr<MWWorld::Action> action(new MWWorld::ActionDoor(ptr));
if (ptr.getRefData().getLocalRotation().rot[2] == 0)
if (MWBase::Environment::get().getWorld()->getOpenOrCloseDoor(ptr))
action->setSound(openSound);
else
action->setSound(closeSound);

@ -181,4 +181,12 @@ namespace MWClass
{
return npcServices & ESM::NPC::Picks;
}
int Lockpick::getItemMaxHealth (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
return ref->mBase->mData.mUses;
}
}

@ -59,6 +59,9 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health
};
}

@ -180,4 +180,12 @@ namespace MWClass
{
return npcServices & ESM::NPC::Probes;
}
int Probe::getItemMaxHealth (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>();
return ref->mBase->mData.mUses;
}
}

@ -59,6 +59,9 @@ namespace MWClass
virtual std::string getModel(const MWWorld::Ptr &ptr) const;
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
virtual int getItemMaxHealth (const MWWorld::Ptr& ptr) const;
///< Return item max health or throw an exception, if class does not have item health
};
}

@ -428,12 +428,12 @@ namespace MWClass
return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell);
}
short Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
float Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
return ref->mBase->mData.mEnchant;
return ref->mBase->mData.mEnchant/10.f;
}
bool Weapon::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -79,7 +79,7 @@ namespace MWClass
virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
};
}

@ -57,8 +57,9 @@ namespace MWGui
void EnchantingDialog::updateLabels()
{
mEnchantmentPoints->setCaption(boost::lexical_cast<std::string>(mEnchanting.getEnchantCost())
+ " / " + boost::lexical_cast<std::string>(mEnchanting.getMaxEnchantValue()));
std::stringstream enchantCost;
enchantCost << std::setprecision(1) << std::fixed << mEnchanting.getEnchantCost();
mEnchantmentPoints->setCaption(enchantCost.str() + " / " + boost::lexical_cast<std::string>(mEnchanting.getMaxEnchantValue()));
mCharge->setCaption(boost::lexical_cast<std::string>(mEnchanting.getGemCharge()));

@ -918,14 +918,16 @@ namespace MWGui
const ESM::Enchantment* ench = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>()
.find(MWWorld::Class::get(item).getEnchantment(item));
int chargePercent = item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100;
int chargePercent = (item.getCellRef().mEnchantmentCharge == -1) ? 100
: (item.getCellRef().mEnchantmentCharge / static_cast<float>(ench->mData.mCharge) * 100);
mHud->setSelectedEnchantItem(item, chargePercent);
mSpellWindow->setTitle(MWWorld::Class::get(item).getName(item));
}
void WindowManager::setSelectedWeapon(const MWWorld::Ptr& item)
{
int durabilityPercent = item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100;
int durabilityPercent = (item.getCellRef().mCharge == -1) ? 100
: (item.getCellRef().mCharge / static_cast<float>(MWWorld::Class::get(item).getItemMaxHealth(item)) * 100);
mHud->setSelectedWeapon(item, durabilityPercent);
mInventoryWindow->setTitle(MWWorld::Class::get(item).getName(item));
}
@ -1110,6 +1112,13 @@ namespace MWGui
{
mLoadingScreen->loadingDone ();
}
bool WindowManager::getRestEnabled()
{
//Enable rest dialogue if character creation finished
if(mRestAllowed==false && MWBase::Environment::get().getWorld()->getGlobalVariable ("chargenstate").mFloat==-1)
mRestAllowed=true;
return mRestAllowed;
}
bool WindowManager::getPlayerSleeping ()
{

@ -220,7 +220,7 @@ namespace MWGui
virtual void loadingDone();
virtual void enableRest() { mRestAllowed = true; }
virtual bool getRestEnabled() { return mRestAllowed; }
virtual bool getRestEnabled();
virtual bool getPlayerSleeping();
virtual void wakeUpPlayer();

@ -679,7 +679,8 @@ namespace MWInput
void InputManager::quickKey (int index)
{
mWindows.activateQuickKey (index);
if (!mWindows.isGuiMode())
mWindows.activateQuickKey (index);
}
void InputManager::showQuickKeysMenu()

@ -134,7 +134,7 @@ namespace MWMechanics
}
}
int Enchanting::getEnchantCost() const
float Enchanting::getEnchantCost() const
{
const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
float cost = 0;
@ -193,7 +193,7 @@ namespace MWMechanics
return soul->mData.mSoul;
}
int Enchanting::getMaxEnchantValue() const
float Enchanting::getMaxEnchantValue() const
{
if (itemEmpty())
return 0;

@ -35,9 +35,9 @@ namespace MWMechanics
bool create(); //Return true if created, false if failed.
void nextEnchantType(); //Set enchant type to next possible type (for mOldItemPtr object)
int getEnchantType() const;
int getEnchantCost() const;
float getEnchantCost() const;
int getEnchantPrice() const;
int getMaxEnchantValue() const;
float getMaxEnchantValue() const;
int getGemCharge() const;
float getEnchantChance() const;
bool soulEmpty() const; //Return true if empty

@ -54,9 +54,10 @@ namespace MWRender
TerrainMaterial::Profile::~Profile()
{
if (mMaterial)
sh::Factory::getInstance().destroyMaterialInstance(mMaterial->getName());
}
Ogre::MaterialPtr TerrainMaterial::Profile::generate(const Ogre::Terrain* terrain)
{
const Ogre::String& matName = terrain->getMaterialName();

@ -132,7 +132,7 @@ namespace MWWorld
return 0;
}
short Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
float Class::getEnchantmentPoints (const MWWorld::Ptr& ptr) const
{
throw std::runtime_error ("class does not support enchanting");
}

@ -231,7 +231,7 @@ namespace MWWorld
///< @return the enchantment ID if the object is enchanted, otherwise an empty string
/// (default implementation: return empty string)
virtual short getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
///< @return the number of enchantment points available for possible enchanting
virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;

@ -162,7 +162,8 @@ namespace MWWorld
ToUTF8::Utf8Encoder* encoder, const std::map<std::string,std::string>& fallbackMap, int mActivationDistanceOverride)
: mPlayer (0), mLocalScripts (mStore), mGlobalVariables (0),
mSky (true), mCells (mStore, mEsm),
mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride),mFallback(fallbackMap)
mNumFacing(0), mActivationDistanceOverride (mActivationDistanceOverride),
mFallback(fallbackMap), mNewGame(newGame)
{
mPhysics = new PhysicsSystem(renderer);
mPhysEngine = mPhysics->getEngine();
@ -213,7 +214,7 @@ namespace MWWorld
// global variables
mGlobalVariables = new Globals (mStore);
if (newGame)
if (mNewGame)
{
// set new game mark
mGlobalVariables->setInt ("chargenstate", 1);
@ -1490,14 +1491,14 @@ namespace MWWorld
return mRendering->vanityRotateCamera(rot);
}
void World::setupPlayer(bool newGame)
void World::setupPlayer()
{
const ESM::NPC *player = mStore.get<ESM::NPC>().find("player");
mPlayer = new MWWorld::Player(player, *this);
Ptr ptr = mPlayer->getPlayer();
mRendering->setupPlayer(ptr);
if(newGame)
if (mNewGame)
{
MWWorld::Class::get(ptr).getContainerStore(ptr).fill(player->mInventory, "", mStore);
MWWorld::Class::get(ptr).getInventoryStore(ptr).autoEquip(ptr);
@ -1508,6 +1509,8 @@ namespace MWWorld
{
mRendering->renderPlayer(mPlayer->getPlayer());
mPhysics->addActor(mPlayer->getPlayer());
if (mNewGame)
toggleCollisionMode();
}
void World::setupExternalRendering (MWRender::ExternalRendering& rendering)
@ -1566,4 +1569,11 @@ namespace MWWorld
mDoorStates[door] = 0; // close
}
}
bool World::getOpenOrCloseDoor(const Ptr &door)
{
if (mDoorStates.find(door) != mDoorStates.end())
return !mDoorStates[door]; // if currently opening or closing, then do the opposite
return door.getRefData().getLocalRotation().rot[2] == 0;
}
}

@ -85,6 +85,8 @@ namespace MWWorld
float mFaced2Distance;
int mNumFacing;
bool mNewGame;
std::map<MWWorld::Ptr, int> mDoorStates;
///< only holds doors that are currently moving. 0 means closing, 1 opening
@ -113,6 +115,9 @@ namespace MWWorld
void addContainerScripts(const Ptr& reference, Ptr::CellStore* cell);
void PCDropped (const Ptr& item);
virtual void processDoors(float duration);
///< Run physics simulation and modify \a world accordingly.
public:
World (OEngine::Render::OgreRenderer& renderer,
@ -272,9 +277,6 @@ namespace MWWorld
virtual void doPhysics(const PtrMovementList &actors, float duration);
///< Run physics simulation and modify \a world accordingly.
virtual void processDoors(float duration);
///< Run physics simulation and modify \a world accordingly.
virtual bool toggleCollisionMode();
///< Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
@ -371,9 +373,11 @@ namespace MWWorld
virtual bool vanityRotateCamera(float * rot);
virtual void setupPlayer(bool newGame);
virtual void setupPlayer();
virtual void renderPlayer();
virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door);
///< if activated, should this door be opened or closed?
virtual void activateDoor(const MWWorld::Ptr& door);
///< activate (open or close) an non-teleport door

@ -313,21 +313,26 @@ public:
void destroyInstance( Archive* arch) { delete arch; }
};
class DirArchiveFactory : public FileSystemArchiveFactory
class DirArchiveFactory : public ArchiveFactory
{
public:
const String& getType() const
{
static String name = "Dir";
return name;
}
const String& getType() const
{
static String name = "Dir";
return name;
}
Archive *createInstance( const String& name )
{
return new DirArchive(name);
}
Archive *createInstance( const String& name )
{
return new DirArchive(name);
}
void destroyInstance( Archive* arch) { delete arch; }
virtual Archive* createInstance(const String& name, bool readOnly)
{
return new DirArchive(name);
}
void destroyInstance( Archive* arch) { delete arch; }
};

@ -48,7 +48,7 @@ struct Weapon
short mType;
short mHealth;
float mSpeed, mReach;
short mEnchant; // Enchantment points
short mEnchant; // Enchantment points. The real value is mEnchant/10.f
unsigned char mChop[2], mSlash[2], mThrust[2]; // Min and max
int mFlags;
}; // 32 bytes

Loading…
Cancel
Save