Merge remote-tracking branch 'scrawl/master'

This commit is contained in:
Marc Zinnschlag 2013-04-29 18:08:25 +02:00
commit 93868c8bca
25 changed files with 67 additions and 29 deletions

View file

@ -326,6 +326,8 @@ namespace MWBase
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

View file

@ -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

View file

@ -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;
};

View file

@ -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

View file

@ -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;
};

View file

@ -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

View file

@ -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;
};

View file

@ -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);

View file

@ -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;
}
}

View file

@ -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
};
}

View file

@ -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;
}
}

View file

@ -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
};
}

View file

@ -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

View file

@ -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;
};
}

View file

@ -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()));

View file

@ -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));
}

View file

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

View file

@ -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;

View file

@ -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

View file

@ -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();

View file

@ -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");
}

View file

@ -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;

View file

@ -1551,4 +1551,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;
}
}

View file

@ -115,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,
@ -274,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.
@ -376,6 +376,8 @@ namespace MWWorld
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

View file

@ -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