mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
Merge remote-tracking branch 'scrawl/next' into next
This commit is contained in:
commit
a5dbc7ce61
@ -49,6 +49,67 @@ namespace
|
||||
{
|
||||
return new CustomData (*this);
|
||||
}
|
||||
|
||||
void autoCalculateAttributes (const ESM::NPC* npc, MWMechanics::CreatureStats& creatureStats)
|
||||
{
|
||||
// race bonus
|
||||
const ESM::Race *race =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Race>().find(npc->mRace);
|
||||
|
||||
bool male = (npc->mFlags & ESM::NPC::Female) == 0;
|
||||
|
||||
int level = creatureStats.getLevel();
|
||||
|
||||
for (int i=0; i<ESM::Attribute::Length; ++i)
|
||||
{
|
||||
const ESM::Race::MaleFemale& attribute = race->mData.mAttributeValues[i];
|
||||
creatureStats.getAttribute(i).setBase (male ? attribute.mMale : attribute.mFemale);
|
||||
}
|
||||
|
||||
// class bonus
|
||||
const ESM::Class *class_ =
|
||||
MWBase::Environment::get().getWorld()->getStore().get<ESM::Class>().find(npc->mClass);
|
||||
|
||||
for (int i=0; i<2; ++i)
|
||||
{
|
||||
int attribute = class_->mData.mAttribute[i];
|
||||
if (attribute>=0 && attribute<8)
|
||||
{
|
||||
creatureStats.getAttribute(attribute).setBase (
|
||||
creatureStats.getAttribute(attribute).getBase() + 10);
|
||||
}
|
||||
}
|
||||
|
||||
// skill bonus
|
||||
for (int attribute=0; attribute<ESM::Attribute::Length; ++attribute)
|
||||
{
|
||||
float modifierSum = 0;
|
||||
|
||||
for (int j=0; j<ESM::Skill::Length; ++j)
|
||||
{
|
||||
const ESM::Skill* skill = MWBase::Environment::get().getWorld()->getStore().get<ESM::Skill>().find(j);
|
||||
|
||||
if (skill->mData.mAttribute != attribute)
|
||||
continue;
|
||||
|
||||
// is this a minor or major skill?
|
||||
float add=0.2;
|
||||
for (int k=0; k<5; ++k)
|
||||
{
|
||||
if (class_->mData.mSkills[k][0] == j)
|
||||
add=0.5;
|
||||
}
|
||||
for (int k=0; k<5; ++k)
|
||||
{
|
||||
if (class_->mData.mSkills[k][1] == j)
|
||||
add=1.0;
|
||||
}
|
||||
modifierSum += add;
|
||||
}
|
||||
creatureStats.getAttribute(attribute).setBase ( std::min(creatureStats.getAttribute(attribute).getBase()
|
||||
+ static_cast<int>((level-1) * modifierSum+0.5), 100) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace MWClass
|
||||
@ -126,15 +187,14 @@ namespace MWClass
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i=0; i<8; ++i)
|
||||
data->mCreatureStats.getAttribute (i).set (10);
|
||||
|
||||
for (int i=0; i<3; ++i)
|
||||
data->mCreatureStats.setDynamic (i, 10);
|
||||
|
||||
data->mCreatureStats.setLevel(ref->mBase->mNpdt12.mLevel);
|
||||
data->mNpcStats.setBaseDisposition(ref->mBase->mNpdt12.mDisposition);
|
||||
data->mNpcStats.setReputation(ref->mBase->mNpdt12.mReputation);
|
||||
|
||||
autoCalculateAttributes(ref->mBase, data->mCreatureStats);
|
||||
}
|
||||
|
||||
data->mCreatureStats.setAiSetting (0, ref->mBase->mAiData.mHello);
|
||||
|
@ -426,6 +426,7 @@ namespace MWDialogue
|
||||
|
||||
void DialogueManager::questionAnswered (const std::string& answer)
|
||||
{
|
||||
|
||||
if (mChoiceMap.find(answer) != mChoiceMap.end())
|
||||
{
|
||||
mChoice = mChoiceMap[answer];
|
||||
@ -442,6 +443,10 @@ namespace MWDialogue
|
||||
std::string text = info->mResponse;
|
||||
parseText (text);
|
||||
|
||||
mChoiceMap.clear();
|
||||
mChoice = -1;
|
||||
mIsInChoice = false;
|
||||
|
||||
MWScript::InterpreterContext interpreterContext(&mActor.getRefData().getLocals(),mActor);
|
||||
MWBase::Environment::get().getWindowManager()->getDialogueWindow()->addText (Interpreter::fixDefinesDialog(text, interpreterContext));
|
||||
MWBase::Environment::get().getJournal()->addTopic (mLastTopic, info->mId);
|
||||
@ -449,9 +454,6 @@ namespace MWDialogue
|
||||
mLastDialogue = *info;
|
||||
}
|
||||
}
|
||||
mChoiceMap.clear();
|
||||
mChoice = -1;
|
||||
mIsInChoice = false;
|
||||
}
|
||||
|
||||
updateTopics();
|
||||
|
@ -73,6 +73,11 @@ bool MWDialogue::Filter::testActor (const ESM::DialInfo& info) const
|
||||
if (iter->second < info.mData.mRank)
|
||||
return false;
|
||||
}
|
||||
else if (info.mData.mRank != -1)
|
||||
{
|
||||
// if there is a rank condition, but the NPC is not in a faction, always fail
|
||||
return false;
|
||||
}
|
||||
|
||||
// Gender
|
||||
if (!isCreature)
|
||||
|
@ -18,17 +18,17 @@ namespace MWGui
|
||||
|
||||
void ReferenceInterface::checkReferenceAvailable()
|
||||
{
|
||||
if (mPtr.isEmpty())
|
||||
return;
|
||||
|
||||
MWWorld::Ptr::CellStore* playerCell = MWBase::Environment::get().getWorld()->getPlayer().getPlayer().getCell();
|
||||
|
||||
// check if player has changed cell, or count of the reference has become 0
|
||||
if ((playerCell != mCurrentPlayerCell && mCurrentPlayerCell != NULL)
|
||||
|| mPtr.getRefData().getCount() == 0)
|
||||
|| (!mPtr.isEmpty() && mPtr.getRefData().getCount() == 0))
|
||||
{
|
||||
mPtr = MWWorld::Ptr();
|
||||
onReferenceUnavailable();
|
||||
if (!mPtr.isEmpty())
|
||||
{
|
||||
mPtr = MWWorld::Ptr();
|
||||
onReferenceUnavailable();
|
||||
}
|
||||
}
|
||||
|
||||
mCurrentPlayerCell = playerCell;
|
||||
|
@ -21,13 +21,15 @@ namespace MWRender
|
||||
|
||||
CharacterPreview::CharacterPreview(MWWorld::Ptr character, int sizeX, int sizeY, const std::string& name,
|
||||
Ogre::Vector3 position, Ogre::Vector3 lookAt)
|
||||
: mSizeX(sizeX)
|
||||
, mSizeY(sizeY)
|
||||
, mName(name)
|
||||
|
||||
: mSceneMgr (0)
|
||||
, mPosition(position)
|
||||
, mLookAt(lookAt)
|
||||
, mCharacter(character)
|
||||
, mAnimation(NULL)
|
||||
, mName(name)
|
||||
, mSizeX(sizeX)
|
||||
, mSizeY(sizeY)
|
||||
{
|
||||
|
||||
}
|
||||
@ -88,16 +90,20 @@ namespace MWRender
|
||||
|
||||
CharacterPreview::~CharacterPreview ()
|
||||
{
|
||||
//Ogre::TextureManager::getSingleton().remove(mName);
|
||||
mSceneMgr->destroyCamera (mName);
|
||||
delete mAnimation;
|
||||
Ogre::Root::getSingleton().destroySceneManager(mSceneMgr);
|
||||
if (mSceneMgr)
|
||||
{
|
||||
//Ogre::TextureManager::getSingleton().remove(mName);
|
||||
mSceneMgr->destroyAllCameras();
|
||||
delete mAnimation;
|
||||
Ogre::Root::getSingleton().destroySceneManager(mSceneMgr);
|
||||
}
|
||||
}
|
||||
|
||||
void CharacterPreview::rebuild()
|
||||
{
|
||||
assert(mAnimation);
|
||||
delete mAnimation;
|
||||
mAnimation = 0;
|
||||
|
||||
mAnimation = new NpcAnimation(mCharacter, mNode, MWWorld::Class::get(mCharacter).getInventoryStore(mCharacter),
|
||||
0, (renderHeadOnly() ? NpcAnimation::VM_HeadOnly : NpcAnimation::VM_Normal));
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include "../mwbase/inputmanager.hpp" // FIXME
|
||||
#include "../mwbase/windowmanager.hpp" // FIXME
|
||||
|
||||
#include "../mwmechanics/creaturestats.hpp"
|
||||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/player.hpp"
|
||||
|
||||
@ -315,13 +317,15 @@ void RenderingManager::update (float duration, bool paused)
|
||||
{
|
||||
MWBase::World *world = MWBase::Environment::get().getWorld();
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
|
||||
int blind = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::Blind)).mMagnitude;
|
||||
mRendering.getFader()->setFactor(1.f-(blind / 100.f));
|
||||
|
||||
setAmbientMode();
|
||||
|
||||
// player position
|
||||
MWWorld::RefData &data =
|
||||
MWBase::Environment::get()
|
||||
.getWorld()
|
||||
->getPlayer()
|
||||
.getPlayer()
|
||||
.getRefData();
|
||||
MWWorld::RefData &data = player.getRefData();
|
||||
float *_playerPos = data.getPosition().pos;
|
||||
Ogre::Vector3 playerPos(_playerPos[0], _playerPos[1], _playerPos[2]);
|
||||
|
||||
@ -597,8 +601,15 @@ void RenderingManager::setSunColour(const Ogre::ColourValue& colour)
|
||||
|
||||
void RenderingManager::setAmbientColour(const Ogre::ColourValue& colour)
|
||||
{
|
||||
mRendering.getScene()->setAmbientLight(colour);
|
||||
mTerrainManager->setAmbient(colour);
|
||||
mAmbientColor = colour;
|
||||
|
||||
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
|
||||
int nightEye = MWWorld::Class::get(player).getCreatureStats(player).getMagicEffects().get(MWMechanics::EffectKey(ESM::MagicEffect::NightEye)).mMagnitude;
|
||||
Ogre::ColourValue final = colour;
|
||||
final += Ogre::ColourValue(0.7,0.7,0.7,0) * std::min(1.f, (nightEye/100.f));
|
||||
|
||||
mRendering.getScene()->setAmbientLight(final);
|
||||
mTerrainManager->setAmbient(final);
|
||||
}
|
||||
|
||||
void RenderingManager::sunEnable(bool real)
|
||||
|
@ -475,7 +475,7 @@ namespace MWWorld
|
||||
cell.mData.mX = x, cell.mData.mY = y;
|
||||
|
||||
std::pair<int, int> key(x, y);
|
||||
std::map<std::pair<int, int>, ESM::Cell>::const_iterator it = mExt.find(key);
|
||||
DynamicExt::const_iterator it = mExt.find(key);
|
||||
if (it != mExt.end()) {
|
||||
return &(it->second);
|
||||
}
|
||||
@ -493,7 +493,7 @@ namespace MWWorld
|
||||
cell.mData.mX = x, cell.mData.mY = y;
|
||||
|
||||
std::pair<int, int> key(x, y);
|
||||
std::map<std::pair<int, int>, ESM::Cell>::const_iterator it = mExt.find(key);
|
||||
DynamicExt::const_iterator it = mExt.find(key);
|
||||
if (it != mExt.end()) {
|
||||
return &(it->second);
|
||||
}
|
||||
@ -534,7 +534,7 @@ namespace MWWorld
|
||||
|
||||
void setUp() {
|
||||
//typedef std::vector<ESM::Cell>::iterator Iterator;
|
||||
typedef std::map<std::pair<int, int>, ESM::Cell>::iterator ExtIterator;
|
||||
typedef DynamicExt::iterator ExtIterator;
|
||||
typedef std::map<std::string, ESM::Cell>::iterator IntIterator;
|
||||
|
||||
//std::sort(mInt.begin(), mInt.end(), RecordCmp());
|
||||
|
@ -260,13 +260,24 @@ void NIFMeshLoader::createSubMesh(Ogre::Mesh *mesh, const Nif::NiTriShape *shape
|
||||
|
||||
// Texture UV coordinates
|
||||
size_t numUVs = data->uvlist.size();
|
||||
for(size_t i = 0;i < numUVs;i++)
|
||||
if (numUVs)
|
||||
{
|
||||
vbuf = hwBufMgr->createVertexBuffer(Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2),
|
||||
srcVerts.size(), Ogre::HardwareBuffer::HBU_STATIC);
|
||||
vbuf->writeData(0, vbuf->getSizeInBytes(), &data->uvlist[i][0], true);
|
||||
size_t elemSize = Ogre::VertexElement::getTypeSize(Ogre::VET_FLOAT2);
|
||||
|
||||
for(size_t i = 0; i < numUVs; i++)
|
||||
decl->addElement(nextBuf, elemSize*i, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, i);
|
||||
|
||||
vbuf = hwBufMgr->createVertexBuffer(decl->getVertexSize(nextBuf), srcVerts.size(),
|
||||
Ogre::HardwareBuffer::HBU_STATIC);
|
||||
|
||||
std::vector<Ogre::Vector2> allUVs;
|
||||
allUVs.reserve(srcVerts.size()*numUVs);
|
||||
for (size_t vert = 0; vert<srcVerts.size(); ++vert)
|
||||
for(size_t i = 0; i < numUVs; i++)
|
||||
allUVs.push_back(data->uvlist[i][vert]);
|
||||
|
||||
vbuf->writeData(0, elemSize*srcVerts.size()*numUVs, &allUVs[0], true);
|
||||
|
||||
decl->addElement(nextBuf, 0, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, i);
|
||||
bind->setBinding(nextBuf++, vbuf);
|
||||
}
|
||||
|
||||
|
@ -559,6 +559,8 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
|
||||
assert(mgr);
|
||||
|
||||
mSceneMgr = mgr;
|
||||
mShaderRenderManager = NULL;
|
||||
mRenderManager = NULL;
|
||||
|
||||
using namespace MyGUI;
|
||||
|
||||
@ -574,7 +576,10 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
|
||||
|
||||
// Set up OGRE platform (bypassing OgrePlatform). We might make this more generic later.
|
||||
mLogManager = new LogManager();
|
||||
mRenderManager = new MyGUI::ShaderBasedRenderManager();
|
||||
if (!Ogre::Root::getSingleton().getRenderSystem()->getCapabilities()->hasCapability(Ogre::RSC_FIXED_FUNCTION))
|
||||
mShaderRenderManager = new MyGUI::ShaderBasedRenderManager();
|
||||
else
|
||||
mRenderManager = new MyGUI::OgreRenderManager();
|
||||
mDataManager = new MyGUI::FixedOgreDataManager();
|
||||
|
||||
LogManager::getInstance().setSTDOutputEnabled(logging);
|
||||
@ -582,7 +587,10 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
|
||||
if (!theLogFile.empty())
|
||||
LogManager::getInstance().createDefaultSource(theLogFile);
|
||||
|
||||
mRenderManager->initialise(wnd, mgr);
|
||||
if (mShaderRenderManager)
|
||||
mShaderRenderManager->initialise(wnd, mgr);
|
||||
else
|
||||
mRenderManager->initialise(wnd, mgr);
|
||||
mDataManager->initialise("General");
|
||||
|
||||
// Create GUI
|
||||
@ -592,8 +600,16 @@ void MyGUIManager::setup(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool
|
||||
|
||||
void MyGUIManager::updateWindow (Ogre::RenderWindow *wnd)
|
||||
{
|
||||
mRenderManager->setRenderWindow (wnd);
|
||||
mRenderManager->setActiveViewport(0);
|
||||
if (mShaderRenderManager)
|
||||
{
|
||||
mShaderRenderManager->setRenderWindow (wnd);
|
||||
mShaderRenderManager->setActiveViewport(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
mRenderManager->setRenderWindow (wnd);
|
||||
mRenderManager->setActiveViewport(0);
|
||||
}
|
||||
}
|
||||
|
||||
void MyGUIManager::shutdown()
|
||||
@ -606,6 +622,12 @@ void MyGUIManager::shutdown()
|
||||
delete mRenderManager;
|
||||
mRenderManager = NULL;
|
||||
}
|
||||
if(mShaderRenderManager)
|
||||
{
|
||||
mShaderRenderManager->shutdown();
|
||||
delete mShaderRenderManager;
|
||||
mShaderRenderManager = NULL;
|
||||
}
|
||||
if(mDataManager)
|
||||
{
|
||||
mDataManager->shutdown();
|
||||
|
@ -8,6 +8,7 @@ namespace MyGUI
|
||||
class Gui;
|
||||
class LogManager;
|
||||
class OgreDataManager;
|
||||
class OgreRenderManager;
|
||||
class ShaderBasedRenderManager;
|
||||
}
|
||||
|
||||
@ -25,12 +26,12 @@ namespace GUI
|
||||
MyGUI::Gui *mGui;
|
||||
MyGUI::LogManager* mLogManager;
|
||||
MyGUI::OgreDataManager* mDataManager;
|
||||
MyGUI::ShaderBasedRenderManager* mRenderManager;
|
||||
MyGUI::OgreRenderManager* mRenderManager;
|
||||
MyGUI::ShaderBasedRenderManager* mShaderRenderManager;
|
||||
Ogre::SceneManager* mSceneMgr;
|
||||
|
||||
|
||||
public:
|
||||
MyGUIManager() : mLogManager(NULL), mDataManager(NULL), mRenderManager(NULL), mGui(NULL) {}
|
||||
MyGUIManager(Ogre::RenderWindow *wnd, Ogre::SceneManager *mgr, bool logging=false, const std::string& logDir = std::string(""))
|
||||
{
|
||||
setup(wnd,mgr,logging, logDir);
|
||||
|
@ -19,6 +19,7 @@ Fader::Fader(Ogre::SceneManager* sceneMgr)
|
||||
, mTargetAlpha(0.f)
|
||||
, mCurrentAlpha(0.f)
|
||||
, mStartAlpha(0.f)
|
||||
, mFactor(1.f)
|
||||
{
|
||||
// Create the fading material
|
||||
MaterialPtr material = MaterialManager::getSingleton().create("FadeInOutMaterial", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
|
||||
@ -62,19 +63,20 @@ void Fader::update(float dt)
|
||||
mCurrentAlpha += dt/mTargetTime * (mTargetAlpha-mStartAlpha);
|
||||
if (mCurrentAlpha > mTargetAlpha) mCurrentAlpha = mTargetAlpha;
|
||||
}
|
||||
|
||||
applyAlpha();
|
||||
|
||||
|
||||
mRemainingTime -= dt;
|
||||
}
|
||||
|
||||
if (mCurrentAlpha == 0.f) mRectangle->setVisible(false);
|
||||
if (1.f-((1.f-mCurrentAlpha) * mFactor) == 0.f)
|
||||
mRectangle->setVisible(false);
|
||||
else
|
||||
applyAlpha();
|
||||
}
|
||||
|
||||
void Fader::applyAlpha()
|
||||
{
|
||||
mRectangle->setVisible(true);
|
||||
mFadeTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, mCurrentAlpha);
|
||||
mFadeTextureUnit->setAlphaOperation(LBX_SOURCE1, LBS_MANUAL, LBS_CURRENT, 1.f-((1.f-mCurrentAlpha) * mFactor));
|
||||
}
|
||||
|
||||
void Fader::fadeIn(float time)
|
||||
|
@ -29,6 +29,8 @@ namespace Render
|
||||
void fadeOut(const float time);
|
||||
void fadeTo(const int percent, const float time);
|
||||
|
||||
void setFactor (float factor) { mFactor = factor; }
|
||||
|
||||
private:
|
||||
enum FadingMode
|
||||
{
|
||||
@ -49,6 +51,8 @@ namespace Render
|
||||
float mCurrentAlpha;
|
||||
float mStartAlpha;
|
||||
|
||||
float mFactor;
|
||||
|
||||
Ogre::SceneManager* mSceneMgr;
|
||||
};
|
||||
}}
|
||||
|
@ -136,6 +136,9 @@ Bug #700: "On the rocks" mod does not load its UV coordinates correctly.
|
||||
Bug #702: Some race mods don't work
|
||||
Bug #711: Crash during character creation
|
||||
Bug #715: Growing Tauryon
|
||||
Bug #725: Auto calculate stats
|
||||
Bug #728: Failure to open container and talk dialogue
|
||||
Bug #731: Crash with Mush-Mere's "background" topic
|
||||
Feature #55/657: Item Repairing
|
||||
Feature #62/87: Enchanting
|
||||
Feature #99: Pathfinding
|
||||
|
Loading…
x
Reference in New Issue
Block a user