1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 09:35:28 +00:00

Merge remote-tracking branch 'upstream/master'

Conflicts:
	apps/openmw/mwmechanics/actors.cpp
This commit is contained in:
Thomas 2014-04-28 12:27:57 -04:00
commit 885228ec02
80 changed files with 375 additions and 241 deletions

View File

@ -333,7 +333,7 @@ int load(Arguments& info)
// Is the user interested in this record type?
bool interested = true;
if (info.types.size() > 0)
if (!info.types.empty())
{
std::vector<std::string>::iterator match;
match = std::find(info.types.begin(), info.types.end(),

View File

@ -124,7 +124,7 @@ void printEffectList(ESM::EffectList effects)
{
int i = 0;
std::vector<ESM::ENAMstruct>::iterator eit;
for (eit = effects.mList.begin(); eit != effects.mList.end(); eit++)
for (eit = effects.mList.begin(); eit != effects.mList.end(); ++eit)
{
std::cout << " Effect[" << i << "]: " << magicEffectLabel(eit->mEffectID)
<< " (" << eit->mEffectID << ")" << std::endl;

View File

@ -214,13 +214,13 @@ QStringList Launcher::GraphicsPage::getAvailableOptions(const QString &key, Ogre
uint row = 0;
Ogre::ConfigOptionMap options = renderer->getConfigOptions();
for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); i++, row++)
for (Ogre::ConfigOptionMap::iterator i = options.begin (); i != options.end (); ++i, ++row)
{
Ogre::StringVector::iterator opt_it;
uint idx = 0;
for (opt_it = i->second.possibleValues.begin();
opt_it != i->second.possibleValues.end(); opt_it++, idx++)
opt_it != i->second.possibleValues.end(); ++opt_it, ++idx)
{
if (strcmp (key.toStdString().c_str(), i->first.c_str()) == 0) {
result << ((key == "FSAA") ? QString("MSAA ") : QString("")) + QString::fromStdString((*opt_it).c_str()).simplified();

4
apps/opencs/view/world/datadisplaydelegate.cpp Executable file → Normal file
View File

@ -25,7 +25,7 @@ CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
void CSVWorld::DataDisplayDelegate::buildPixmaps ()
{
if (mPixmaps.size() > 0)
if (!mPixmaps.empty())
mPixmaps.clear();
IconList::iterator it = mIcons.begin();
@ -33,7 +33,7 @@ void CSVWorld::DataDisplayDelegate::buildPixmaps ()
while (it != mIcons.end())
{
mPixmaps.push_back (std::make_pair (it->first, it->second.pixmap (mIconSize) ) );
it++;
++it;
}
}

View File

@ -298,7 +298,7 @@ void CSVWorld::Table::revertRecord()
{
std::vector<std::string> revertableIds = listRevertableSelectedIds();
if (revertableIds.size()>0)
if (!revertableIds.empty())
{
if (revertableIds.size()>1)
mDocument.getUndoStack().beginMacro (tr ("Revert multiple records"));
@ -318,7 +318,7 @@ void CSVWorld::Table::deleteRecord()
{
std::vector<std::string> deletableIds = listDeletableSelectedIds();
if (deletableIds.size()>0)
if (!deletableIds.empty())
{
if (deletableIds.size()>1)
mDocument.getUndoStack().beginMacro (tr ("Delete multiple records"));

View File

@ -5,6 +5,11 @@
#include <stdint.h>
namespace Loading
{
class Listener;
}
namespace ESM
{
class ESMReader;
@ -60,7 +65,7 @@ namespace MWBase
virtual int countSavedGameRecords() const = 0;
virtual void write (ESM::ESMWriter& writer) const = 0;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const = 0;
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
};

View File

@ -11,6 +11,11 @@
#include "../mwdialogue/topic.hpp"
#include "../mwdialogue/quest.hpp"
namespace Loading
{
class Listener;
}
namespace ESM
{
class ESMReader;
@ -80,7 +85,7 @@ namespace MWBase
virtual int countSavedGameRecords() const = 0;
virtual void write (ESM::ESMWriter& writer) const = 0;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const = 0;
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
};

View File

@ -156,8 +156,9 @@ namespace MWBase
virtual void setValue (const std::string& id, int value) = 0;
/// Set time left for the player to start drowning (update the drowning bar)
/// @param time value from [0,20]
virtual void setDrowningTimeLeft (float time) =0;
/// @param time time left to start drowning
/// @param maxTime how long we can be underwater (in total) until drowning starts
virtual void setDrowningTimeLeft (float time, float maxTime) = 0;
virtual void setPlayerClass (const ESM::Class &class_) = 0;
///< set current class of player
@ -302,7 +303,7 @@ namespace MWBase
/// Clear all savegame-specific data
virtual void clear() = 0;
virtual void write (ESM::ESMWriter& writer) = 0;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) = 0;
virtual void readRecord (ESM::ESMReader& reader, int32_t type) = 0;
};
}

View File

@ -108,7 +108,7 @@ namespace MWBase
virtual int countSavedGameRecords() const = 0;
virtual void write (ESM::ESMWriter& writer) const = 0;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& listener) const = 0;
virtual void readRecord (ESM::ESMReader& reader, int32_t type,
const std::map<int, int>& contentFileMap) = 0;

View File

@ -609,7 +609,7 @@ namespace MWDialogue
return 1; // known topics
}
void DialogueManager::write (ESM::ESMWriter& writer) const
void DialogueManager::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
ESM::DialogueState state;
@ -621,6 +621,7 @@ namespace MWDialogue
writer.startRecord (ESM::REC_DIAS);
state.save (writer);
writer.endRecord (ESM::REC_DIAS);
progress.increaseProgress();
}
void DialogueManager::readRecord (ESM::ESMReader& reader, int32_t type)

View File

@ -83,7 +83,7 @@ namespace MWDialogue
virtual int countSavedGameRecords() const;
virtual void write (ESM::ESMWriter& writer) const;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
};

View File

@ -167,7 +167,7 @@ namespace MWDialogue
return count;
}
void Journal::write (ESM::ESMWriter& writer) const
void Journal::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
for (TQuestIter iter (mQuests.begin()); iter!=mQuests.end(); ++iter)
{
@ -178,6 +178,7 @@ namespace MWDialogue
writer.startRecord (ESM::REC_QUES);
state.save (writer);
writer.endRecord (ESM::REC_QUES);
progress.increaseProgress();
for (Topic::TEntryIter iter (quest.begin()); iter!=quest.end(); ++iter)
{
@ -188,6 +189,7 @@ namespace MWDialogue
writer.startRecord (ESM::REC_JOUR);
entry.save (writer);
writer.endRecord (ESM::REC_JOUR);
progress.increaseProgress();
}
}
@ -199,6 +201,7 @@ namespace MWDialogue
writer.startRecord (ESM::REC_JOUR);
entry.save (writer);
writer.endRecord (ESM::REC_JOUR);
progress.increaseProgress();
}
for (TTopicIter iter (mTopics.begin()); iter!=mTopics.end(); ++iter)
@ -214,6 +217,7 @@ namespace MWDialogue
writer.startRecord (ESM::REC_JOUR);
entry.save (writer);
writer.endRecord (ESM::REC_JOUR);
progress.increaseProgress();
}
}
}

View File

@ -64,7 +64,7 @@ namespace MWDialogue
virtual int countSavedGameRecords() const;
virtual void write (ESM::ESMWriter& writer) const;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
};

View File

@ -188,12 +188,13 @@ namespace MWGui
break;
case GM_ClassCreate:
MWBase::Environment::get().getWindowManager()->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
mCreateClassDialog = new CreateClassDialog();
if (!mCreateClassDialog)
{
mCreateClassDialog = new CreateClassDialog();
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
}
mCreateClassDialog->setNextButtonShow(mCreationStage >= CSE_ClassChosen);
mCreateClassDialog->eventDone += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogDone);
mCreateClassDialog->eventBack += MyGUI::newDelegate(this, &CharacterCreation::onCreateClassDialogBack);
mCreateClassDialog->setVisible(true);
if (mCreationStage < CSE_RaceChosen)
mCreationStage = CSE_RaceChosen;
@ -531,8 +532,8 @@ namespace MWGui
mPlayerClass = klass;
MWBase::Environment::get().getWindowManager()->setPlayerClass(klass);
MWBase::Environment::get().getWindowManager()->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
// Do not delete dialog, so that choices are rembered in case we want to go back and adjust them later
mCreateClassDialog->setVisible(false);
}
updatePlayerHealth();
@ -554,8 +555,8 @@ namespace MWGui
void CharacterCreation::onCreateClassDialogBack()
{
MWBase::Environment::get().getWindowManager()->removeDialog(mCreateClassDialog);
mCreateClassDialog = 0;
// Do not delete dialog, so that choices are rembered in case we want to go back and adjust them later
mCreateClassDialog->setVisible(false);
MWBase::Environment::get().getWindowManager()->popGuiMode();
MWBase::Environment::get().getWindowManager()->pushGuiMode(GM_Class);

View File

@ -10,7 +10,7 @@ namespace MWGui
{
}
void CompanionItemModel::copyItem (const ItemStack& item, size_t count)
void CompanionItemModel::copyItem (const ItemStack& item, size_t count, bool setNewOwner=false)
{
if (mActor.getClass().isNpc())
{
@ -18,7 +18,7 @@ namespace MWGui
stats.modifyProfit(MWWorld::Class::get(item.mBase).getValue(item.mBase) * count);
}
InventoryItemModel::copyItem(item, count);
InventoryItemModel::copyItem(item, count, setNewOwner);
}
void CompanionItemModel::removeItem (const ItemStack& item, size_t count)

View File

@ -13,7 +13,7 @@ namespace MWGui
public:
CompanionItemModel (const MWWorld::Ptr& actor);
virtual void copyItem (const ItemStack& item, size_t count);
virtual void copyItem (const ItemStack& item, size_t count, bool setNewOwner);
virtual void removeItem (const ItemStack& item, size_t count);
};

View File

@ -13,6 +13,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwmechanics/pickpocket.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "countdialog.hpp"
#include "tradewindow.hpp"
@ -84,8 +85,7 @@ namespace MWGui
// otherwise, do the transfer
if (targetModel != mSourceModel)
{
targetModel->copyItem(mItem, mDraggedCount);
mSourceModel->removeItem(mItem, mDraggedCount);
mSourceModel->moveItem(mItem, mDraggedCount, targetModel);
}
mSourceModel->update();
@ -292,8 +292,7 @@ namespace MWGui
if (!onTakeItem(item, item.mCount))
break;
playerModel->copyItem(item, item.mCount);
mModel->removeItem(item, item.mCount);
mModel->moveItem(item, item.mCount, playerModel);
}
MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Container);
@ -341,7 +340,11 @@ namespace MWGui
}
else
{
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, count);
// Looting a dead corpse is considered OK
if (mPtr.getClass().isActor() && mPtr.getClass().getCreatureStats(mPtr).isDead())
return true;
else
MWBase::Environment::get().getMechanicsManager()->itemTaken(player, item.mBase, count);
}
return true;
}

View File

@ -71,7 +71,7 @@ ItemModel::ModelIndex ContainerItemModel::getIndex (ItemStack item)
return -1;
}
void ContainerItemModel::copyItem (const ItemStack& item, size_t count)
void ContainerItemModel::copyItem (const ItemStack& item, size_t count, bool setNewOwner)
{
const MWWorld::Ptr& source = mItemSources[mItemSources.size()-1];
if (item.mBase.getContainerStore() == &source.getClass().getContainerStore(source))

View File

@ -21,7 +21,7 @@ namespace MWGui
virtual ModelIndex getIndex (ItemStack item);
virtual size_t getItemCount();
virtual void copyItem (const ItemStack& item, size_t count);
virtual void copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
virtual void removeItem (const ItemStack& item, size_t count);
virtual void update();

View File

@ -203,9 +203,9 @@ namespace MWGui
}
}
void HUD::setDrowningTimeLeft(float time)
void HUD::setDrowningTimeLeft(float time, float maxTime)
{
size_t progress = time/20.0*200.0;
size_t progress = time/maxTime*200.0;
mDrowning->setProgressPosition(progress);
bool isDrowning = (progress == 0);
@ -625,7 +625,7 @@ namespace MWGui
if (mIsDrowning)
{
float intensity = (cos(mDrowningFlashTheta) + 1.0f) / 2.0f;
mDrowningFlash->setColour(MyGUI::Colour(intensity, intensity, intensity));
mDrowningFlash->setColour(MyGUI::Colour(intensity, 0, 0));
}
}

View File

@ -22,8 +22,9 @@ namespace MWGui
void setBatchCount(unsigned int count);
/// Set time left for the player to start drowning
/// @param time value from [0,20]
void setDrowningTimeLeft(float time);
/// @param time time left to start drowning
/// @param maxTime how long we can be underwater (in total) until drowning starts
void setDrowningTimeLeft(float time, float maxTime);
void setDrowningBarVisible(bool visible);
void setHmsVisible(bool visible);

View File

@ -4,6 +4,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwmechanics/creaturestats.hpp"
namespace MWGui
{
@ -38,11 +40,11 @@ ItemModel::ModelIndex InventoryItemModel::getIndex (ItemStack item)
return -1;
}
void InventoryItemModel::copyItem (const ItemStack& item, size_t count)
void InventoryItemModel::copyItem (const ItemStack& item, size_t count, bool setNewOwner)
{
if (item.mBase.getContainerStore() == &mActor.getClass().getContainerStore(mActor))
throw std::runtime_error("Item to copy needs to be from a different container!");
mActor.getClass().getContainerStore(mActor).add(item.mBase, count, mActor);
mActor.getClass().getContainerStore(mActor).add(item.mBase, count, mActor, setNewOwner);
}
@ -57,6 +59,18 @@ void InventoryItemModel::removeItem (const ItemStack& item, size_t count)
throw std::runtime_error("Not enough items in the stack to remove");
}
void InventoryItemModel::moveItem(const ItemStack &item, size_t count, ItemModel *otherModel)
{
bool setNewOwner = false;
// Are you dead? Then you wont need that anymore
if (mActor.getClass().isActor() && mActor.getClass().getCreatureStats(mActor).isDead())
setNewOwner = true;
otherModel->copyItem(item, count, setNewOwner);
removeItem(item, count);
}
void InventoryItemModel::update()
{
MWWorld::ContainerStore& store = MWWorld::Class::get(mActor).getContainerStore(mActor);

View File

@ -15,9 +15,12 @@ namespace MWGui
virtual ModelIndex getIndex (ItemStack item);
virtual size_t getItemCount();
virtual void copyItem (const ItemStack& item, size_t count);
virtual void copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
virtual void removeItem (const ItemStack& item, size_t count);
/// Move items from this model to \a otherModel.
virtual void moveItem (const ItemStack& item, size_t count, ItemModel* otherModel);
virtual void update();
protected:

View File

@ -71,16 +71,22 @@ namespace MWGui
{
}
void ItemModel::moveItem(const ItemStack &item, size_t count, ItemModel *otherModel)
{
otherModel->copyItem(item, count);
removeItem(item, count);
}
ProxyItemModel::~ProxyItemModel()
{
delete mSourceModel;
}
void ProxyItemModel::copyItem (const ItemStack& item, size_t count)
void ProxyItemModel::copyItem (const ItemStack& item, size_t count, bool setNewOwner)
{
// no need to use mapToSource since itemIndex refers to an index in the sourceModel
mSourceModel->copyItem (item, count);
mSourceModel->copyItem (item, count, setNewOwner);
}
void ProxyItemModel::removeItem (const ItemStack& item, size_t count)

View File

@ -55,7 +55,11 @@ namespace MWGui
virtual void update() = 0;
virtual void copyItem (const ItemStack& item, size_t count) = 0;
/// Move items from this model to \a otherModel.
virtual void moveItem (const ItemStack& item, size_t count, ItemModel* otherModel);
/// @param setNewOwner Set the copied item's owner to the actor we are copying to, or keep the original owner?
virtual void copyItem (const ItemStack& item, size_t count, bool setNewOwner=false) = 0;
virtual void removeItem (const ItemStack& item, size_t count) = 0;
private:
@ -69,7 +73,7 @@ namespace MWGui
{
public:
virtual ~ProxyItemModel();
virtual void copyItem (const ItemStack& item, size_t count);
virtual void copyItem (const ItemStack& item, size_t count, bool setNewOwner=false);
virtual void removeItem (const ItemStack& item, size_t count);
virtual ModelIndex getIndex (ItemStack item);

View File

@ -160,7 +160,6 @@ namespace MWGui
void LoadingScreen::setProgress (size_t value)
{
assert(value < mProgressBar->getScrollRange());
if (value - mProgress < mProgressBar->getScrollRange()/100.f)
return;
mProgress = value;
@ -174,7 +173,6 @@ namespace MWGui
mProgressBar->setScrollPosition(0);
size_t value = mProgress + increase;
mProgress = value;
assert(mProgress < mProgressBar->getScrollRange());
mProgressBar->setTrackSize(value / (float)(mProgressBar->getScrollRange()) * mProgressBar->getLineSize());
draw();
}

View File

@ -25,7 +25,7 @@ namespace MWGui
virtual void setProgressRange (size_t range);
virtual void setProgress (size_t value);
virtual void increaseProgress (size_t increase);
virtual void increaseProgress (size_t increase=1);
virtual void setVisible(bool visible);

View File

@ -595,7 +595,7 @@ namespace MWGui
MyGUI::Gui::getInstance().destroyWidget(mGlobalMapOverlay->getChildAt(0));
}
void MapWindow::write(ESM::ESMWriter &writer)
void MapWindow::write(ESM::ESMWriter &writer, Loading::Listener& progress)
{
ESM::GlobalMap map;
mGlobalMapRender->write(map);
@ -605,6 +605,7 @@ namespace MWGui
writer.startRecord(ESM::REC_GMAP);
map.save(writer);
writer.endRecord(ESM::REC_GMAP);
progress.increaseProgress();
}
void MapWindow::readRecord(ESM::ESMReader &reader, int32_t type)

View File

@ -108,7 +108,7 @@ namespace MWGui
/// Clear all savegame-specific data
void clear();
void write (ESM::ESMWriter& writer);
void write (ESM::ESMWriter& writer, Loading::Listener& progress);
void readRecord (ESM::ESMReader& reader, int32_t type);
private:

View File

@ -120,14 +120,11 @@ namespace MWGui
if (i == sourceModel->getItemCount())
throw std::runtime_error("The borrowed item disappeared");
// reset owner before copying
// reset owner while copying, but only for items bought by the player
bool setNewOwner = (mMerchant.isEmpty());
const ItemStack& item = sourceModel->getItem(i);
std::string owner = item.mBase.getCellRef().mOwner;
if (mMerchant.isEmpty()) // only for items bought by player
item.mBase.getCellRef().mOwner = "";
// copy the borrowed items to our model
copyItem(item, it->mCount);
item.mBase.getCellRef().mOwner = owner;
copyItem(item, it->mCount, setNewOwner);
// then remove them from the source model
sourceModel->removeItem(item, it->mCount);
}

View File

@ -78,13 +78,13 @@ namespace MWGui
}
void TradeWindow::startTrade(const MWWorld::Ptr& actor)
{
{
mPtr = actor;
mCurrentBalance = 0;
mCurrentMerchantOffer = 0;
checkTradeTime();
checkTradeTime();
std::vector<MWWorld::Ptr> itemSources;
MWBase::Environment::get().getWorld()->getContainersOwnedBy(actor, itemSources);
@ -245,7 +245,7 @@ namespace MWGui
// were there any items traded at all?
std::vector<ItemStack> playerBought = playerItemModel->getItemsBorrowedToUs();
std::vector<ItemStack> merchantBought = mTradeModel->getItemsBorrowedToUs();
if (!playerBought.size() && !merchantBought.size())
if (playerBought.empty() && merchantBought.empty())
{
// user notification
MWBase::Environment::get().getWindowManager()->
@ -476,7 +476,7 @@ namespace MWGui
}
// Relates to NPC gold reset delay
void TradeWindow::checkTradeTime()
void TradeWindow::checkTradeTime()
{
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
@ -488,14 +488,14 @@ namespace MWGui
}
}
void TradeWindow::updateTradeTime()
void TradeWindow::updateTradeTime()
{
MWWorld::ContainerStore store = mPtr.getClass().getContainerStore(mPtr);
MWMechanics::CreatureStats &sellerStats = mPtr.getClass().getCreatureStats(mPtr);
double delay = boost::lexical_cast<double>(MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fBarterGoldResetDelay")->getInt());
// If trade timestamp is within reset delay don't set
if ( ! (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() &&
if ( ! (MWBase::Environment::get().getWorld()->getTimeStamp() >= sellerStats.getTradeTime() &&
MWBase::Environment::get().getWorld()->getTimeStamp() < sellerStats.getTradeTime() + delay) )
{
sellerStats.setTradeTime(MWBase::Environment::get().getWorld()->getTimeStamp());

View File

@ -625,9 +625,9 @@ namespace MWGui
mStatsWindow->setValue (id, value);
}
void WindowManager::setDrowningTimeLeft (float time)
void WindowManager::setDrowningTimeLeft (float time, float maxTime)
{
mHud->setDrowningTimeLeft(time);
mHud->setDrowningTimeLeft(time, maxTime);
}
void WindowManager::setPlayerClass (const ESM::Class &class_)
@ -1407,9 +1407,9 @@ namespace MWGui
mMap->clear();
}
void WindowManager::write(ESM::ESMWriter &writer)
void WindowManager::write(ESM::ESMWriter &writer, Loading::Listener& progress)
{
mMap->write(writer);
mMap->write(writer, progress);
}
void WindowManager::readRecord(ESM::ESMReader &reader, int32_t type)

View File

@ -166,8 +166,9 @@ namespace MWGui
virtual void setValue (const std::string& id, int value);
/// Set time left for the player to start drowning (update the drowning bar)
/// @param time value from [0,20]
virtual void setDrowningTimeLeft (float time);
/// @param time time left to start drowning
/// @param maxTime how long we can be underwater (in total) until drowning starts
virtual void setDrowningTimeLeft (float time, float maxTime);
virtual void setPlayerClass (const ESM::Class &class_); ///< set current class of player
virtual void configureSkills (const SkillList& major, const SkillList& minor); ///< configure skill groups, each set contains the skill ID for that group.
@ -290,7 +291,7 @@ namespace MWGui
/// Clear all savegame-specific data
virtual void clear();
virtual void write (ESM::ESMWriter& writer);
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress);
virtual void readRecord (ESM::ESMReader& reader, int32_t type);
private:

View File

@ -206,7 +206,7 @@ namespace MWMechanics
if (effectIt->mKey.mId == effectId)
effectIt = it->second.mEffects.erase(effectIt);
else
effectIt++;
++effectIt;
}
}
mSpellsChanged = true;
@ -224,7 +224,7 @@ namespace MWMechanics
&& it->second.mCasterHandle == actorHandle)
effectIt = it->second.mEffects.erase(effectIt);
else
effectIt++;
++effectIt;
}
}
mSpellsChanged = true;

View File

@ -194,21 +194,11 @@ namespace MWMechanics
+(actorpos.pos[1] - playerpos.pos[1])*(actorpos.pos[1] - playerpos.pos[1])
+(actorpos.pos[2] - playerpos.pos[2])*(actorpos.pos[2] - playerpos.pos[2]));
float fight = ptr.getClass().getCreatureStats(ptr).getAiSetting(CreatureStats::AI_Fight).getModified();
float disp = 100; //creatures don't have disposition, so set it to 100 by default
if(ptr.getTypeName() == typeid(ESM::NPC).name())
{
disp = MWBase::Environment::get().getMechanicsManager()->getDerivedDisposition(ptr);
}
if( (fight == 100 )
|| (fight >= 95 && d <= 3000)
|| (fight >= 90 && d <= 2000)
|| (fight >= 80 && d <= 1000)
|| (fight >= 80 && disp <= 40)
|| (fight >= 70 && disp <= 35 && d <= 1000)
|| (fight >= 60 && disp <= 30 && d <= 1000)
|| (fight >= 50 && disp == 0)
|| (fight >= 40 && disp <= 10 && d <= 500)
)
{
bool LOS = MWBase::Environment::get().getWorld()->getLOS(ptr,player)
@ -1039,8 +1029,7 @@ namespace MWMechanics
{
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
CreatureStats &stats = cls.getCreatureStats(iter->first);
if(stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow && !stats.isDead())
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdFollow)
{
MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage());
if(package->getFollowedActor() == actor.getCellRef().mRefID)
@ -1061,8 +1050,7 @@ namespace MWMechanics
{
const MWWorld::Class &cls = MWWorld::Class::get(*iter);
CreatureStats &stats = cls.getCreatureStats(*iter);
if(stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat && !stats.isDead())
if(!stats.isDead() && stats.getAiSequence().getTypeId() == AiPackage::TypeIdCombat)
{
MWMechanics::AiCombat* package = static_cast<MWMechanics::AiCombat*>(stats.getAiSequence().getActivePackage());
if(package->getTargetId() == actor.getCellRef().mRefID)

View File

@ -38,7 +38,7 @@ MWMechanics::AiSequence& MWMechanics::AiSequence::operator= (const AiSequence& s
copy (sequence);
mDone = sequence.mDone;
}
return *this;
}
@ -51,7 +51,7 @@ int MWMechanics::AiSequence::getTypeId() const
{
if (mPackages.empty())
return -1;
return mPackages.front()->getTypeId();
}
@ -102,7 +102,7 @@ void MWMechanics::AiSequence::execute (const MWWorld::Ptr& actor,float duration)
}
else
{
mDone = false;
mDone = false;
}
}
}
@ -118,7 +118,7 @@ void MWMechanics::AiSequence::clear()
void MWMechanics::AiSequence::stack (const AiPackage& package)
{
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); it++)
for(std::list<AiPackage *>::iterator it = mPackages.begin(); it != mPackages.end(); ++it)
{
if(mPackages.front()->getPriority() <= package.getPriority())
{

View File

@ -298,13 +298,15 @@ namespace MWMechanics
if(stats.getTimeToStartDrowning() != mWatchedStats.getTimeToStartDrowning())
{
const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>()
.find("fHoldBreathTime")->getFloat();
mWatchedStats.setTimeToStartDrowning(stats.getTimeToStartDrowning());
if(stats.getTimeToStartDrowning() >= 20.0f)
if(stats.getTimeToStartDrowning() >= fHoldBreathTime)
winMgr->setDrowningBarVisibility(false);
else
{
winMgr->setDrowningBarVisibility(true);
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning());
winMgr->setDrowningTimeLeft(stats.getTimeToStartDrowning(), fHoldBreathTime);
}
}
@ -338,6 +340,8 @@ namespace MWMechanics
MWWorld::ContainerStoreIterator enchantItem = inv.getSelectedEnchantItem();
if (enchantItem != inv.end())
winMgr->setSelectedEnchantItem(*enchantItem);
else if (winMgr->getSelectedSpell() == "")
winMgr->unsetSelectedSpell();
}
if (mUpdatePlayer)

View File

@ -296,7 +296,7 @@ namespace MWMechanics
// add this edge to openset, lowest cost goes to the front
// TODO: if this causes performance problems a hash table may help
std::list<int>::iterator it = openset.begin();
for(it = openset.begin(); it!= openset.end(); it++)
for(it = openset.begin(); it!= openset.end(); ++it)
{
if(fScore[*it] > fScore[dest])
break;

View File

@ -401,10 +401,10 @@ namespace MWMechanics
if (!exploded)
MWBase::Environment::get().getWorld()->explodeSpell(mHitPosition, mTarget, effects, caster, mId, mSourceName);
if (reflectedEffects.mList.size())
if (!reflectedEffects.mList.empty())
inflict(caster, target, reflectedEffects, range, true);
if (appliedLastingEffects.size())
if (!appliedLastingEffects.empty())
target.getClass().getCreatureStats(target).getActiveSpells().addSpell(mId, mStack, appliedLastingEffects,
mSourceName, caster.getRefData().getHandle());

View File

@ -129,7 +129,7 @@ namespace MWMechanics
if (spell->mData.mType == ESM::Spell::ST_Disease)
mSpells.erase(iter++);
else
iter++;
++iter;
}
}
@ -143,7 +143,7 @@ namespace MWMechanics
if (spell->mData.mType == ESM::Spell::ST_Blight)
mSpells.erase(iter++);
else
iter++;
++iter;
}
}
@ -157,7 +157,7 @@ namespace MWMechanics
if (Misc::StringUtils::ciEqual(spell->mId, "corprus"))
mSpells.erase(iter++);
else
iter++;
++iter;
}
}
@ -171,7 +171,7 @@ namespace MWMechanics
if (spell->mData.mType == ESM::Spell::ST_Curse)
mSpells.erase(iter++);
else
iter++;
++iter;
}
}

View File

@ -411,7 +411,7 @@ Ogre::Node *Animation::getNode(const std::string &name)
NifOgre::TextKeyMap::const_iterator Animation::findGroupStart(const NifOgre::TextKeyMap &keys, const std::string &groupname)
{
NifOgre::TextKeyMap::const_iterator iter(keys.begin());
for(;iter != keys.end();iter++)
for(;iter != keys.end();++iter)
{
if(iter->second.compare(0, groupname.size(), groupname) == 0 &&
iter->second.compare(groupname.size(), 2, ": ") == 0)
@ -424,7 +424,7 @@ NifOgre::TextKeyMap::const_iterator Animation::findGroupStart(const NifOgre::Tex
bool Animation::hasAnimation(const std::string &anim)
{
AnimSourceList::const_iterator iter(mAnimSources.begin());
for(;iter != mAnimSources.end();iter++)
for(;iter != mAnimSources.end();++iter)
{
const NifOgre::TextKeyMap &keys = (*iter)->mTextKeys;
if(findGroupStart(keys, anim) != keys.end())
@ -465,7 +465,7 @@ float Animation::calcAnimVelocity(const NifOgre::TextKeyMap &keys, NifOgre::Node
stoptime = keyiter->first;
break;
}
keyiter++;
++keyiter;
}
if(stoptime > starttime)
@ -585,13 +585,13 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
std::string starttag = groupname+": "+start;
NifOgre::TextKeyMap::const_iterator startkey(groupstart);
while(startkey != keys.end() && startkey->second != starttag)
startkey++;
++startkey;
if(startkey == keys.end() && start == "loop start")
{
starttag = groupname+": start";
startkey = groupstart;
while(startkey != keys.end() && startkey->second != starttag)
startkey++;
++startkey;
}
if(startkey == keys.end())
return false;
@ -603,7 +603,7 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
// The Scrib's idle3 animation has "Idle3: Stop." instead of "Idle3: Stop".
// Why, just why? :(
&& (stopkey->second.size() < stoptag.size() || stopkey->second.substr(0,stoptag.size()) != stoptag))
stopkey++;
++stopkey;
if(stopkey == keys.end())
return false;
@ -627,7 +627,7 @@ bool Animation::reset(AnimState &state, const NifOgre::TextKeyMap &keys, const s
state.mLoopStartTime = key->first;
else if(key->second == loopstoptag)
state.mLoopStopTime = key->first;
key++;
++key;
}
}
@ -776,7 +776,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
/* Look in reverse; last-inserted source has priority. */
AnimSourceList::reverse_iterator iter(mAnimSources.rbegin());
for(;iter != mAnimSources.rend();iter++)
for(;iter != mAnimSources.rend();++iter)
{
const NifOgre::TextKeyMap &textkeys = (*iter)->mTextKeys;
AnimState state;
@ -795,7 +795,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
while(textkey != textkeys.end() && textkey->first <= state.mTime)
{
handleTextKey(state, groupname, textkey);
textkey++;
++textkey;
}
if(state.mTime >= state.mLoopStopTime && state.mLoopCount > 0)
@ -810,7 +810,7 @@ void Animation::play(const std::string &groupname, int priority, int groups, boo
while(textkey != textkeys.end() && textkey->first <= state.mTime)
{
handleTextKey(state, groupname, textkey);
textkey++;
++textkey;
}
}
@ -965,7 +965,7 @@ Ogre::Vector3 Animation::runAnimation(float duration)
while(textkey != textkeys.end() && textkey->first <= state.mTime)
{
handleTextKey(state, stateiter->first, textkey);
textkey++;
++textkey;
}
if(state.mTime >= state.mLoopStopTime && state.mLoopCount > 0)
@ -979,7 +979,7 @@ Ogre::Vector3 Animation::runAnimation(float duration)
while(textkey != textkeys.end() && textkey->first <= state.mTime)
{
handleTextKey(state, stateiter->first, textkey);
textkey++;
++textkey;
}
if(state.mTime >= state.mLoopStopTime)

View File

@ -106,7 +106,7 @@ ManualObject *Debugging::createPathgridPoints(const ESM::Pathgrid *pathgrid)
uint32 startIndex = 0;
for(ESM::Pathgrid::PointList::const_iterator it = pathgrid->mPoints.begin();
it != pathgrid->mPoints.end();
it++, startIndex += 6)
++it, startIndex += 6)
{
Vector3 pointPos(it->mX, it->mY, it->mZ);

View File

@ -240,25 +240,25 @@ Ogre::AxisAlignedBox Objects::getDimensions(MWWorld::CellStore* cell)
void Objects::enableLights()
{
PtrAnimationMap::const_iterator it = mObjects.begin();
for(;it != mObjects.end();it++)
for(;it != mObjects.end();++it)
it->second->enableLights(true);
}
void Objects::disableLights()
{
PtrAnimationMap::const_iterator it = mObjects.begin();
for(;it != mObjects.end();it++)
for(;it != mObjects.end();++it)
it->second->enableLights(false);
}
void Objects::update(float dt, Ogre::Camera* camera)
{
PtrAnimationMap::const_iterator it = mObjects.begin();
for(;it != mObjects.end();it++)
for(;it != mObjects.end();++it)
it->second->runAnimation(dt);
it = mObjects.begin();
for(;it != mObjects.end();it++)
for(;it != mObjects.end();++it)
it->second->preRender(camera);
}

View File

@ -6,14 +6,9 @@
#include <cstdio>
#include <cmath>
#include <OgreRoot.h>
#include <OgreHardwarePixelBuffer.h>
#include <OgreRenderWindow.h>
#include <OgreTextureManager.h>
#include <OgreTechnique.h>
#include <OgreRectangle2D.h>
#include <OgreMaterialManager.h>
#include <OgreSceneNode.h>
#include <OgreStringConverter.h>
#include <boost/thread.hpp>
@ -21,9 +16,6 @@
#include "../mwbase/soundmanager.hpp"
#include "../mwsound/sound_decoder.hpp"
#include "../mwsound/sound.hpp"
#include "../mwbase/inputmanager.hpp"
#include "renderconst.hpp"
#ifdef _WIN32
#include <BaseTsd.h>

View File

@ -97,7 +97,7 @@ namespace MWScript
return mScripts.size();
}
void GlobalScripts::write (ESM::ESMWriter& writer) const
void GlobalScripts::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
for (std::map<std::string, std::pair<bool, Locals> >::const_iterator iter (mScripts.begin());
iter!=mScripts.end(); ++iter)
@ -113,6 +113,7 @@ namespace MWScript
writer.startRecord (ESM::REC_GSCR);
script.save (writer);
writer.endRecord (ESM::REC_GSCR);
progress.increaseProgress();
}
}

View File

@ -14,6 +14,11 @@ namespace ESM
class ESMReader;
}
namespace Loading
{
class Listener;
}
namespace MWWorld
{
struct ESMStore;
@ -46,7 +51,7 @@ namespace MWScript
int countSavedGameRecords() const;
void write (ESM::ESMWriter& writer) const;
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord (ESM::ESMReader& reader, int32_t type);
///< Records for variables that do not exist are dropped silently.

View File

@ -442,7 +442,7 @@ namespace MWSound
{
snditer->first->setFadeout(duration);
}
snditer++;
++snditer;
}
}

View File

@ -196,26 +196,36 @@ void MWState::StateManager::saveGame (const std::string& description, const Slot
writer.addMaster (*iter, 0); // not using the size information anyway -> use value of 0
writer.setFormat (ESM::Header::CurrentFormat);
writer.setRecordCount (
1 // saved game header
+MWBase::Environment::get().getJournal()->countSavedGameRecords()
+MWBase::Environment::get().getWorld()->countSavedGameRecords()
+MWBase::Environment::get().getScriptManager()->getGlobalScripts().countSavedGameRecords()
+MWBase::Environment::get().getDialogueManager()->countSavedGameRecords()
+1 // global map
);
int recordCount = 1 // saved game header
+MWBase::Environment::get().getJournal()->countSavedGameRecords()
+MWBase::Environment::get().getWorld()->countSavedGameRecords()
+MWBase::Environment::get().getScriptManager()->getGlobalScripts().countSavedGameRecords()
+MWBase::Environment::get().getDialogueManager()->countSavedGameRecords()
+1; // global map
writer.setRecordCount (recordCount);
writer.save (stream);
Loading::Listener& listener = *MWBase::Environment::get().getWindowManager()->getLoadingScreen();
listener.setProgressRange(recordCount);
listener.setLabel("#{sNotifyMessage4}");
Loading::ScopedLoad load(&listener);
writer.startRecord (ESM::REC_SAVE);
slot->mProfile.save (writer);
writer.endRecord (ESM::REC_SAVE);
listener.increaseProgress();
MWBase::Environment::get().getJournal()->write (writer);
MWBase::Environment::get().getDialogueManager()->write (writer);
MWBase::Environment::get().getWorld()->write (writer);
MWBase::Environment::get().getScriptManager()->getGlobalScripts().write (writer);
MWBase::Environment::get().getWindowManager()->write(writer);
MWBase::Environment::get().getJournal()->write (writer, listener);
MWBase::Environment::get().getDialogueManager()->write (writer, listener);
MWBase::Environment::get().getWorld()->write (writer, listener);
MWBase::Environment::get().getScriptManager()->getGlobalScripts().write (writer, listener);
MWBase::Environment::get().getWindowManager()->write(writer, listener);
// Ensure we have written the number of records that was estimated
if (writer.getRecordCount() != recordCount+1) // 1 extra for TES3 record
std::cerr << "Warning: number of written savegame records does not match. Estimated: " << recordCount+1 << ", written: " << writer.getRecordCount() << std::endl;
writer.close();
@ -261,6 +271,13 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
std::map<int, int> contentFileMap = buildContentFileIndexMap (reader);
Loading::Listener& listener = *MWBase::Environment::get().getWindowManager()->getLoadingScreen();
listener.setProgressRange(reader.getRecordCount());
listener.setLabel("#{sLoadingMessage14}");
Loading::ScopedLoad load(&listener);
while (reader.hasMoreRecs())
{
ESM::NAME n = reader.getRecName();
@ -318,6 +335,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl
/// \todo log error
reader.skipRecord();
}
listener.increaseProgress();
}
mCharacterManager.setCurrentCharacter(character);

View File

@ -3,7 +3,6 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
@ -24,7 +23,12 @@ namespace MWWorld
void ActionRead::executeImp (const MWWorld::Ptr& actor) {
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()) { //Ensure we're not in combat
//Ensure we're not in combat
if(MWBase::Environment::get().getWorld()->getPlayer().isInCombat()
// Reading in combat is still allowed if the scroll/book is not in the player inventory yet
// (since otherwise, there would be no way to pick it up)
&& getTarget().getContainerStore() == &actor.getClass().getContainerStore(actor)
) {
MWBase::Environment::get().getWindowManager()->messageBox("#{sInventoryMessage4}");
return;
}

View File

@ -20,7 +20,7 @@ namespace MWWorld
//find any NPC that is following the actor and teleport him too
std::list<MWWorld::Ptr> followers = MWBase::Environment::get().getMechanicsManager()->getActorsFollowing(actor);
for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();it++)
for(std::list<MWWorld::Ptr>::iterator it = followers.begin();it != followers.end();++it)
{
std::cout << "teleporting someone!" << (*it).getCellRef().mRefID;
executeImp(*it);

View File

@ -277,17 +277,23 @@ int MWWorld::Cells::countSavedGameRecords() const
return count;
}
void MWWorld::Cells::write (ESM::ESMWriter& writer) const
void MWWorld::Cells::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
for (std::map<std::pair<int, int>, CellStore>::iterator iter (mExteriors.begin());
iter!=mExteriors.end(); ++iter)
if (iter->second.hasState())
{
writeCell (writer, iter->second);
progress.increaseProgress(); // Assumes that each cell writes one record
}
for (std::map<std::string, CellStore>::iterator iter (mInteriors.begin());
iter!=mInteriors.end(); ++iter)
if (iter->second.hasState())
{
writeCell (writer, iter->second);
progress.increaseProgress(); // Assumes that each cell writes one record
}
}
bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, int32_t type,

View File

@ -15,6 +15,11 @@ namespace ESM
struct Cell;
}
namespace Loading
{
class Listener;
}
namespace MWWorld
{
class ESMStore;
@ -69,7 +74,7 @@ namespace MWWorld
int countSavedGameRecords() const;
void write (ESM::ESMWriter& writer) const;
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord (ESM::ESMReader& reader, int32_t type,
const std::map<int, int>& contentFileMap);

View File

@ -433,7 +433,6 @@ namespace MWWorld
while(mCell->getNextRef(esm[index], ref, deleted))
{
// Don't load reference if it was moved to a different cell.
std::string lowerCase = Misc::StringUtils::lowerCase(ref.mRefID);
ESM::MovedCellRefTracker::const_iterator iter =
std::find(mCell->mMovedRefs.begin(), mCell->mMovedRefs.end(), ref.mRefNum);
if (iter != mCell->mMovedRefs.end()) {

View File

@ -187,11 +187,38 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add(const std::string &
MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr, int count, const Ptr& actorPtr, bool setOwner)
{
MWWorld::ContainerStoreIterator it = addImp(itemPtr, count);
Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
MWWorld::ContainerStoreIterator it = end();
if (setOwner && actorPtr.getClass().isActor())
{
// HACK: Set owner on the original item, then reset it after we have copied it
// If we set the owner on the copied item, it would not stack correctly...
std::string oldOwner = itemPtr.getCellRef().mOwner;
if (actorPtr == player)
{
// No point in setting owner to the player - NPCs will not respect this anyway
// Additionally, setting it to "player" would make those items not stack with items that don't have an owner
itemPtr.getCellRef().mOwner = "";
}
else
itemPtr.getCellRef().mOwner = actorPtr.getCellRef().mRefID;
it = addImp(itemPtr, count);
itemPtr.getCellRef().mOwner = oldOwner;
}
else
{
it = addImp(itemPtr, count);
}
// The copy of the original item we just made
MWWorld::Ptr item = *it;
// we may have copied an item from the world, so reset a few things first
item.getRefData().setBaseNode(NULL);
item.getRefData().setBaseNode(NULL); // Especially important, otherwise scripts on the item could think that it's actually in a cell
item.getCellRef().mPos.rot[0] = 0;
item.getCellRef().mPos.rot[1] = 0;
item.getCellRef().mPos.rot[2] = 0;
@ -199,16 +226,11 @@ MWWorld::ContainerStoreIterator MWWorld::ContainerStore::add (const Ptr& itemPtr
item.getCellRef().mPos.pos[1] = 0;
item.getCellRef().mPos.pos[2] = 0;
if (setOwner && actorPtr.getClass().isActor())
item.getCellRef().mOwner = actorPtr.getCellRef().mRefID;
std::string script = MWWorld::Class::get(item).getScript(item);
if(script != "")
{
CellStore *cell;
Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr();
if(&(MWWorld::Class::get (player).getContainerStore (player)) == this)
{
cell = 0; // Items in player's inventory have cell set to 0, so their scripts will never be removed

View File

@ -153,17 +153,17 @@ void ESMStore::setUp()
+mWeapons.getDynamicSize();
}
void ESMStore::write (ESM::ESMWriter& writer) const
void ESMStore::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
mPotions.write (writer);
mArmors.write (writer);
mBooks.write (writer);
mClasses.write (writer);
mClothes.write (writer);
mEnchants.write (writer);
mSpells.write (writer);
mWeapons.write (writer);
mNpcs.write (writer);
mPotions.write (writer, progress);
mArmors.write (writer, progress);
mBooks.write (writer, progress);
mClasses.write (writer, progress);
mClothes.write (writer, progress);
mEnchants.write (writer, progress);
mSpells.write (writer, progress);
mWeapons.write (writer, progress);
mNpcs.write (writer, progress);
}
bool ESMStore::readRecord (ESM::ESMReader& reader, int32_t type)

View File

@ -212,7 +212,7 @@ namespace MWWorld
int countSavedGameRecords() const;
void write (ESM::ESMWriter& writer) const;
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord (ESM::ESMReader& reader, int32_t type);
///< \return Known type?

View File

@ -77,7 +77,7 @@ namespace MWWorld
return mVariables.size();
}
void Globals::write (ESM::ESMWriter& writer) const
void Globals::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
for (Collection::const_iterator iter (mVariables.begin()); iter!=mVariables.end(); ++iter)
{
@ -85,6 +85,7 @@ namespace MWWorld
writer.writeHNString ("NAME", iter->first);
iter->second.write (writer, ESM::Variant::Format_Global);
writer.endRecord (ESM::REC_GLOB);
progress.increaseProgress();
}
}

View File

@ -16,6 +16,11 @@ namespace ESM
class ESMReader;
}
namespace Loading
{
class Listener;
}
namespace MWWorld
{
class ESMStore;
@ -46,7 +51,7 @@ namespace MWWorld
int countSavedGameRecords() const;
void write (ESM::ESMWriter& writer) const;
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord (ESM::ESMReader& reader, int32_t type);
///< Records for variables that do not exist are dropped silently.

View File

@ -671,7 +671,7 @@ namespace MWWorld
void PhysicsSystem::queueObjectMovement(const Ptr &ptr, const Ogre::Vector3 &movement)
{
PtrVelocityList::iterator iter = mMovementQueue.begin();
for(;iter != mMovementQueue.end();iter++)
for(;iter != mMovementQueue.end();++iter)
{
if(iter->first == ptr)
{
@ -692,7 +692,7 @@ namespace MWWorld
{
const MWBase::World *world = MWBase::Environment::get().getWorld();
PtrVelocityList::iterator iter = mMovementQueue.begin();
for(;iter != mMovementQueue.end();iter++)
for(;iter != mMovementQueue.end();++iter)
{
float waterlevel = -std::numeric_limits<float>::max();
const ESM::Cell *cell = iter->first.getCell()->getCell();

View File

@ -141,17 +141,17 @@ namespace MWWorld
// Find all the actors who might be able to see the player
std::vector<MWWorld::Ptr> neighbors;
MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos),
MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos),
esmStore.get<ESM::GameSetting>().find("fSneakUseDist")->getInt(), neighbors);
for (std::vector<MWWorld::Ptr>::iterator it = neighbors.begin(); it != neighbors.end(); ++it)
{
if ( MWBase::Environment::get().getMechanicsManager()->awarenessCheck(ptr, *it) )
{
{
MWBase::Environment::get().getWindowManager()->setSneakVisibility(false);
break;
}
}
if (neighbors.size() == 0)
if (neighbors.empty())
MWBase::Environment::get().getWindowManager()->setSneakVisibility(true);
}
}
@ -215,7 +215,7 @@ namespace MWWorld
mTeleported = false;
}
void Player::write (ESM::ESMWriter& writer) const
void Player::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
ESM::Player player;
@ -245,6 +245,8 @@ namespace MWWorld
writer.startRecord (ESM::REC_PLAY);
player.save (writer);
writer.endRecord (ESM::REC_PLAY);
progress.increaseProgress();
}
bool Player::readRecord (ESM::ESMReader& reader, int32_t type)

View File

@ -21,6 +21,11 @@ namespace MWBase
class Ptr;
}
namespace Loading
{
class Listener;
}
namespace MWWorld
{
class CellStore;
@ -95,7 +100,7 @@ namespace MWWorld
void clear();
void write (ESM::ESMWriter& writer) const;
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
bool readRecord (ESM::ESMReader& reader, int32_t type);

View File

@ -8,6 +8,8 @@
#include <components/esm/esmwriter.hpp>
#include <components/loadinglistener/loadinglistener.hpp>
#include "recordcmp.hpp"
namespace MWWorld
@ -313,7 +315,7 @@ namespace MWWorld
return erase(item.mId);
}
void write (ESM::ESMWriter& writer) const
void write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
for (typename Dynamic::const_iterator iter (mDynamic.begin()); iter!=mDynamic.end();
++iter)
@ -322,6 +324,7 @@ namespace MWWorld
writer.writeHNString ("NAME", iter->second.mId);
iter->second.save (writer);
writer.endRecord (T::sRecordId);
progress.increaseProgress();
}
}

View File

@ -686,7 +686,7 @@ bool WeatherManager::isDark() const
return exterior && (mHour < mSunriseTime || mHour > mNightStart - 1);
}
void WeatherManager::write(ESM::ESMWriter& writer)
void WeatherManager::write(ESM::ESMWriter& writer, Loading::Listener& progress)
{
ESM::WeatherState state;
state.mHour = mHour;
@ -701,6 +701,7 @@ void WeatherManager::write(ESM::ESMWriter& writer)
writer.startRecord(ESM::REC_WTHR);
state.save(writer);
writer.endRecord(ESM::REC_WTHR);
progress.increaseProgress();
}
bool WeatherManager::readRecord(ESM::ESMReader& reader, int32_t type)

View File

@ -18,6 +18,11 @@ namespace MWRender
class RenderingManager;
}
namespace Loading
{
class Listener;
}
namespace MWWorld
{
class Fallback;
@ -158,7 +163,7 @@ namespace MWWorld
/// @see World::isDark
bool isDark() const;
void write(ESM::ESMWriter& writer);
void write(ESM::ESMWriter& writer, Loading::Listener& progress);
bool readRecord(ESM::ESMReader& reader, int32_t type);

View File

@ -268,19 +268,20 @@ namespace MWWorld
int World::countSavedGameRecords() const
{
return
mStore.countSavedGameRecords()
mCells.countSavedGameRecords()
+mStore.countSavedGameRecords()
+mGlobalVariables.countSavedGameRecords()
+1 // player record
+mCells.countSavedGameRecords();
+1; // weather record
}
void World::write (ESM::ESMWriter& writer) const
void World::write (ESM::ESMWriter& writer, Loading::Listener& progress) const
{
mStore.write (writer);
mGlobalVariables.write (writer);
mCells.write (writer);
mPlayer->write (writer);
mWeatherManager->write (writer);
mCells.write (writer, progress);
mStore.write (writer, progress);
mGlobalVariables.write (writer, progress);
mPlayer->write (writer, progress);
mWeatherManager->write (writer, progress);
}
void World::readRecord (ESM::ESMReader& reader, int32_t type,

View File

@ -194,7 +194,7 @@ namespace MWWorld
virtual int countSavedGameRecords() const;
virtual void write (ESM::ESMWriter& writer) const;
virtual void write (ESM::ESMWriter& writer, Loading::Listener& progress) const;
virtual void readRecord (ESM::ESMReader& reader, int32_t type,
const std::map<int, int>& contentFileMap);

View File

@ -31,6 +31,7 @@ public:
*************************************************************************/
int getVer() const { return mHeader.mData.version; }
int getRecordCount() const { return mHeader.mData.records; }
float getFVer() const { if(mHeader.mData.version == VER_12) return 1.2; else return 1.3; }
const std::string getAuthor() const { return mHeader.mData.author.toString(); }
const std::string getDesc() const { return mHeader.mData.desc.toString(); }

View File

@ -29,7 +29,12 @@ class ESMWriter
void setEncoder(ToUTF8::Utf8Encoder *encoding);
void setAuthor(const std::string& author);
void setDescription(const std::string& desc);
// Set the record count for writing it in the file header
void setRecordCount (int count);
// Counts how many records we have actually written.
// It is a good idea to compare this with the value you wrote into the header (setRecordCount)
// It should be the record count you set + 1 (1 additional record for the TES3 header)
int getRecordCount() { return mRecordCount; }
void setFormat (int format);
void clearMaster();

View File

@ -28,7 +28,7 @@ namespace ESM
int type; // 0=esp, 1=esm, 32=ess (unused)
NAME32 author; // Author's name
NAME256 desc; // File description
int records; // Number of records? Not used.
int records; // Number of records
};
// Defines another files (esm or esp) that this file depends upon.
@ -52,4 +52,4 @@ namespace ESM
}
#endif
#endif

View File

@ -17,7 +17,7 @@ namespace Loading
virtual void setProgressRange (size_t range) = 0;
virtual void setProgress (size_t value) = 0;
virtual void increaseProgress (size_t increase) = 0;
virtual void increaseProgress (size_t increase = 1) = 0;
/// Indicate the scene is now ready to be shown
virtual void removeWallpaper() = 0;

View File

@ -4,7 +4,6 @@ set(SDIR ${CMAKE_CURRENT_SOURCE_DIR})
set(DDIR ${OpenMW_BINARY_DIR}/resources/mygui)
set(MYGUI_FILES
bigbars.png
black.png
core.skin
core.xml
@ -81,7 +80,6 @@ set(MYGUI_FILES
openmw_companion_window.layout
openmw_savegame_dialog.layout
openmw_recharge_dialog.layout
smallbars.png
DejaVuLGCSansMono.ttf
markers.png
../launcher/images/openmw.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 387 B

View File

@ -13,7 +13,7 @@
<Property key="MultiLine" value="true"/>
</Widget>
<Widget type="HBox" position="0 89 272 24" align="Right Bottom">
<Widget type="HBox" position="0 89 284 24" align="Right Bottom">
<Widget type="Widget">
<UserString key="HStretch" value="true"/>
</Widget>

View File

@ -42,7 +42,7 @@
<Property key="TextShadow" value="true"/>
<Property key="TextShadowColour" value="0 0 0"/>
</Widget>
<Widget type="ProgressBar" skin="MW_Progress_Loading" position="12 36 196 8" align="Center Top" name="Drowning">
<Widget type="ProgressBar" skin="MW_Progress_LightBlue" position="12 36 196 8" align="Center Top" name="Drowning">
<Property key="NeedMouse" value="false"/>
</Widget>
<Widget type="Widget" skin="MW_Progress_Drowning" position="14 38 192 4" align="Center Top" name="Flash"/>

View File

@ -19,24 +19,28 @@
</Skin>
<!-- Progress bar track, various colors -->
<Skin name="MW_BarTrack_Red" size="4 8" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 4 8" align="Stretch">
<State name="normal" offset="0 0 4 8"/>
<Skin name="MW_BarTrack_Red" size="4 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0.8274 0.2431 0.129"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>
<Skin name="MW_BarTrack_Green" size="4 8" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 4 8" align="Stretch">
<State name="normal" offset="0 16 4 8"/>
<Skin name="MW_BarTrack_Green" size="4 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0 0.6823 0.2745"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>
<Skin name="MW_BarTrack_Blue" size="4 8" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 4 8" align="Stretch">
<State name="normal" offset="0 8 4 8"/>
<Skin name="MW_BarTrack_Blue" size="4 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0.2470 0.3176 0.7411"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>
<Skin name="MW_BarTrack_Yellow" size="4 8" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 4 8" align="Stretch">
<State name="normal" offset="0 32 4 8"/>
<Skin name="MW_BarTrack_Yellow" size="4 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="1 1 0"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>

View File

@ -4,13 +4,13 @@
<!-- The entire screen -->
<Widget type="Widget" layer="LoadingScreen" position="0 0 300 300" name="_Main">
<Widget type="Widget" skin="HUD_Box" position="0 200 300 60" align="Bottom HCenter">
<Widget type="Widget" skin="HUD_Box" position="0 245 300 48" align="Bottom HCenter">
<Widget type="TextBox" skin="SandText" position="20 12 260 20" name="LoadingText">
<Widget type="TextBox" skin="SandText" position="20 8 260 18" name="LoadingText">
<Property key="TextAlign" value="Center"/>
</Widget>
<Widget type="ScrollBar" skin="MW_ProgressScroll_Loading" position="20 36 260 8" name="ProgressBar">
<Widget type="ScrollBar" skin="MW_ProgressScroll_Loading" position="20 30 260 6" name="ProgressBar">
</Widget>
</Widget>

View File

@ -2,36 +2,50 @@
<MyGUI type="Skin">
<!-- Progress bar track, various colors -->
<Skin name="MW_BigTrack_Red" size="2 14" texture="bigbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 14" align="Stretch">
<State name="normal" offset="0 0 2 14"/>
<Skin name="MW_Track_Red" size="16 16" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0.8274 0.2431 0.129"/>
<BasisSkin type="MainSkin" offset="0 0 16 16" align="Stretch">
<State name="normal" offset="0 0 16 16"/>
</BasisSkin>
</Skin>
<Skin name="MW_BigTrack_Blue" size="2 14" texture="bigbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 14" align="Stretch">
<State name="normal" offset="0 14 2 14"/>
<Skin name="MW_Track_Blue" size="2 14" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0.2470 0.3176 0.7411"/>
<BasisSkin type="MainSkin" offset="0 0 16 16" align="Stretch">
<State name="normal" offset="0 0 16 16"/>
</BasisSkin>
</Skin>
<Skin name="MW_BigTrack_Green" size="2 14" texture="bigbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 14" align="Stretch">
<State name="normal" offset="0 28 2 14"/>
<Skin name="MW_Track_Green" size="2 14" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0 0.6823 0.2745"/>
<BasisSkin type="MainSkin" offset="0 0 16 16" align="Stretch">
<State name="normal" offset="0 0 16 16"/>
</BasisSkin>
</Skin>
<Skin name="MW_BigTrack_Progress_Red_Small" size="2 6" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 6" align="Stretch">
<State name="normal" offset="0 0 2 8"/>
<!-- Lighter variants (only uses top half of the gradient) -->
<Skin name="MW_BigTrack_Progress_Red_Small" size="16 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="1 0 0"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>
<Skin name="MW_BigTrack_Progress_Blue_Small" size="2 6" texture="smallbars.png" >
<BasisSkin type="MainSkin" offset="0 0 2 6" align="Stretch">
<State name="normal" offset="0 26 2 6"/>
<Skin name="MW_BigTrack_Progress_Blue_Small" size="16 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0.3 0.3 1"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>
<Skin name="MW_BigTrack_Progress_Green_Small" size="16 8" texture="textures\menu_bar_gray.dds" >
<Property key="Colour" value="0.298 0.784 0.780"/>
<BasisSkin type="MainSkin" offset="0 0 16 8" align="Stretch">
<State name="normal" offset="0 0 16 8"/>
</BasisSkin>
</Skin>
<Skin name="ProgressText" size="16 16">
<Property key="FontName" value="Default"/>
<Property key="TextAlign" value="Center"/>
<Property key="TextAlign" value="Top HCenter"/>
<Property key="TextColour" value="0.75 0.6 0.35"/>
<Property key="TextShadow" value="true"/>
<BasisSkin type="SimpleText" offset="0 0 16 16" align="Stretch"/>
</Skin>
@ -39,7 +53,7 @@
<!-- Main energy bar widget definitions. There's one for each color.-->
<Skin name="MW_Progress_Red" size="64 12">
<Property key="TrackSkin" value="MW_BigTrack_Red"/>
<Property key="TrackSkin" value="MW_Track_Red"/>
<Property key="TrackWidth" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
@ -47,7 +61,7 @@
</Skin>
<Skin name="MW_Progress_Green" size="64 12">
<Property key="TrackSkin" value="MW_BigTrack_Green"/>
<Property key="TrackSkin" value="MW_Track_Green"/>
<Property key="TrackWidth" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
@ -55,15 +69,15 @@
</Skin>
<Skin name="MW_Progress_Blue" size="64 12">
<Property key="TrackSkin" value="MW_BigTrack_Blue"/>
<Property key="TrackSkin" value="MW_Track_Blue"/>
<Property key="TrackWidth" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 12" align="Stretch"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 8" align="Stretch" name="Client"/>
</Skin>
<Skin name="MW_Progress_Loading" size="64 6">
<Property key="TrackSkin" value="MW_BigTrack_Progress_Blue_Small"/>
<Skin name="MW_Progress_LightBlue" size="64 6">
<Property key="TrackSkin" value="MW_BigTrack_Progress_Blue_Small"/>
<Property key="TrackWidth" value="1"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 6" align="Stretch"/>
@ -82,7 +96,7 @@
<Property key="MoveToClick" value="false"/>
<Child type="Widget" skin="BlackBG" offset="2 2 60 2" align="Stretch" name="Client"/>
<Child type="Button" skin="MW_BigTrack_Progress_Blue_Small" offset="0 0 1 6" align="Left VStretch" name="Track"/>
<Child type="Button" skin="MW_BigTrack_Progress_Green_Small" offset="0 0 1 6" align="Left VStretch" name="Track"/>
<Child type="Widget" skin="MW_Box" offset="0 0 64 6" align="Stretch"/>
</Skin>

View File

@ -3,10 +3,10 @@
<MyGUI type="Layout">
<Widget type="Window" skin="MW_Window_NoCaption" layer="Windows" position="0 0 400 426" name="_Main">
<Property key="MinSize" value="400 496"/>
<Property key="MaxSize" value="400 496"/>
<Property key="MinSize" value="400 446"/>
<Property key="MaxSize" value="400 446"/>
<Widget type="TabControl" skin="TabControl" position="8 8 368 410" align="Left Top" name="SettingsTab">
<Widget type="TabControl" skin="TabControl" position="8 8 368 360" align="Left Top" name="SettingsTab">
<Property key="ButtonAutoWidth" value="true"/>
<Widget type="TabItem" skin="" position="4 28 360 312">

View File

@ -147,29 +147,29 @@
<Skin name="MW_ChargeBar" size="204 18">
<Child type="ProgressBar" skin="MW_Progress_Red" offset="0 0 204 18" align="Right Top Stretch" name="Bar"/>
<Child type="TextBox" skin="SandTextC" offset="0 0 204 18" align="Right Top Stretch" name="BarText"/>
<Child type="TextBox" skin="ProgressText" offset="0 0 204 18" align="Right Top Stretch" name="BarText"/>
</Skin>
<Skin name="MW_ChargeBar_Blue" size="204 18">
<Child type="ProgressBar" skin="MW_Progress_Blue" offset="0 0 204 18" align="Right Top Stretch" name="Bar"/>
<Child type="TextBox" skin="SandTextC" offset="0 0 204 18" align="Right Top Stretch" name="BarText"/>
<Child type="TextBox" skin="ProgressText" offset="0 2 204 18" align="Right Top Stretch" name="BarText"/>
</Skin>
<Skin name="MW_DynamicStat_Red" size="204 18">
<Child type="TextBox" skin="SandText" offset="0 0 100 18" align="Left Top" name="Text"/>
<Child type="ProgressBar" skin="MW_Progress_Red" offset="74 0 130 18" align="Right Top" name="Bar"/>
<Child type="TextBox" skin="SandTextC" offset="74 0 130 18" align="Right Top" name="BarText"/>
<Child type="TextBox" skin="ProgressText" offset="74 0 130 18" align="Right Top" name="BarText"/>
</Skin>
<Skin name="MW_DynamicStat_Blue" size="204 18">
<Child type="TextBox" skin="SandText" offset="0 0 100 18" align="Left Top" name="Text"/>
<Child type="ProgressBar" skin="MW_Progress_Blue" offset="74 0 130 18" align="Right Top" name="Bar"/>
<Child type="TextBox" skin="SandTextC" offset="74 0 130 18" align="Right Top" name="BarText"/>
<Child type="TextBox" skin="ProgressText" offset="74 0 130 18" align="Right Top" name="BarText"/>
</Skin>
<Skin name="MW_DynamicStat_Green" size="204 18">
<Child type="TextBox" skin="SandText" offset="0 0 100 18" align="Left Top" name="Text"/>
<Child type="ProgressBar" skin="MW_Progress_Green" offset="74 0 130 18" align="Right Top" name="Bar"/>
<Child type="TextBox" skin="SandTextC" offset="74 0 130 18" align="Right Top" name="BarText"/>
<Child type="TextBox" skin="ProgressText" offset="74 0 130 18" align="Right Top" name="BarText"/>
</Skin>
</MyGUI>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB