diff --git a/apps/launcher/maindialog.cpp b/apps/launcher/maindialog.cpp
index 4012a1fbd..a6ac3d78d 100644
--- a/apps/launcher/maindialog.cpp
+++ b/apps/launcher/maindialog.cpp
@@ -443,6 +443,32 @@ bool Launcher::MainDialog::setupGameSettings()
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
QString globalPath = QString::fromStdString(mCfgMgr.getGlobalPath().string());
+ // Load the user config file first, separately
+ // So we can write it properly, uncontaminated
+ QString path = userPath + QLatin1String("openmw.cfg");
+ QFile file(path);
+
+ qDebug() << "Loading config file:" << qPrintable(path);
+
+ if (file.exists()) {
+ if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ QMessageBox msgBox;
+ msgBox.setWindowTitle(tr("Error opening OpenMW configuration file"));
+ msgBox.setIcon(QMessageBox::Critical);
+ msgBox.setStandardButtons(QMessageBox::Ok);
+ msgBox.setText(QObject::tr("
Could not open %0 for reading
\
+ Please make sure you have the right permissions \
+ and try again.
").arg(file.fileName()));
+ msgBox.exec();
+ return false;
+ }
+ QTextStream stream(&file);
+ stream.setCodec(QTextCodec::codecForName("UTF-8"));
+
+ mGameSettings.readUserFile(stream);
+ }
+
+ // Now the rest
QStringList paths;
paths.append(userPath + QString("openmw.cfg"));
paths.append(QString("openmw.cfg"));
diff --git a/apps/launcher/settings/gamesettings.cpp b/apps/launcher/settings/gamesettings.cpp
index 41113c35a..e7e5cf1ea 100644
--- a/apps/launcher/settings/gamesettings.cpp
+++ b/apps/launcher/settings/gamesettings.cpp
@@ -90,6 +90,16 @@ QStringList Launcher::GameSettings::values(const QString &key, const QStringList
}
bool Launcher::GameSettings::readFile(QTextStream &stream)
+{
+ return readFile(stream, mSettings);
+}
+
+bool Launcher::GameSettings::readUserFile(QTextStream &stream)
+{
+ return readFile(stream, mUserSettings);
+}
+
+bool Launcher::GameSettings::readFile(QTextStream &stream, QMap &settings)
{
QMap cache;
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
@@ -107,10 +117,10 @@ bool Launcher::GameSettings::readFile(QTextStream &stream)
// Don't remove existing data entries
if (key != QLatin1String("data"))
- mSettings.remove(key);
+ settings.remove(key);
QStringList values = cache.values(key);
- values.append(mSettings.values(key));
+ values.append(settings.values(key));
if (!values.contains(value)) {
cache.insertMulti(key, value);
@@ -118,23 +128,24 @@ bool Launcher::GameSettings::readFile(QTextStream &stream)
}
}
- if (mSettings.isEmpty()) {
- mSettings = cache; // This is the first time we read a file
+ if (settings.isEmpty()) {
+ settings = cache; // This is the first time we read a file
validatePaths();
return true;
}
// Merge the changed keys with those which didn't
- mSettings.unite(cache);
+ settings.unite(cache);
validatePaths();
return true;
}
+
bool Launcher::GameSettings::writeFile(QTextStream &stream)
{
// Iterate in reverse order to preserve insertion order
- QMapIterator i(mSettings);
+ QMapIterator i(mUserSettings);
i.toBack();
while (i.hasPrevious()) {
@@ -162,7 +173,7 @@ bool Launcher::GameSettings::writeFile(QTextStream &stream)
}
- QStringList content = mSettings.values(QString("content"));
+ QStringList content = mUserSettings.values(QString("content"));
for (int i = content.count(); i--;) {
stream << "content=" << content.at(i) << "\n";
}
@@ -172,14 +183,14 @@ bool Launcher::GameSettings::writeFile(QTextStream &stream)
bool Launcher::GameSettings::hasMaster()
{
- bool result = false;
- QStringList content = mSettings.values(QString("content"));
- for (int i = 0; i < content.count(); ++i) {
- if (content.at(i).contains(".omwgame") || content.at(i).contains(".esm")) {
- result = true;
- break;
+ bool result = false;
+ QStringList content = mSettings.values(QString("content"));
+ for (int i = 0; i < content.count(); ++i) {
+ if (content.at(i).contains(".omwgame") || content.at(i).contains(".esm")) {
+ result = true;
+ break;
+ }
}
- }
- return result;
+ return result;
}
diff --git a/apps/launcher/settings/gamesettings.hpp b/apps/launcher/settings/gamesettings.hpp
index 60236200a..df8215074 100644
--- a/apps/launcher/settings/gamesettings.hpp
+++ b/apps/launcher/settings/gamesettings.hpp
@@ -31,6 +31,7 @@ namespace Launcher
inline void setValue(const QString &key, const QString &value)
{
mSettings.insert(key, value);
+ mUserSettings.insert(key, value);
}
inline void setMultiValue(const QString &key, const QString &value)
@@ -38,11 +39,16 @@ namespace Launcher
QStringList values = mSettings.values(key);
if (!values.contains(value))
mSettings.insertMulti(key, value);
+
+ values = mUserSettings.values(key);
+ if (!values.contains(value))
+ mUserSettings.insertMulti(key, value);
}
inline void remove(const QString &key)
{
mSettings.remove(key);
+ mUserSettings.remove(key);
}
inline QStringList getDataDirs() { return mDataDirs; }
@@ -52,7 +58,11 @@ namespace Launcher
bool hasMaster();
QStringList values(const QString &key, const QStringList &defaultValues = QStringList());
+
bool readFile(QTextStream &stream);
+ bool readFile(QTextStream &stream, QMap &settings);
+ bool readUserFile(QTextStream &stream);
+
bool writeFile(QTextStream &stream);
private:
@@ -60,6 +70,7 @@ namespace Launcher
void validatePaths();
QMap mSettings;
+ QMap mUserSettings;
QStringList mDataDirs;
QString mDataLocal;
diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt
index 90fdd11ba..5a062575c 100644
--- a/apps/openmw/CMakeLists.txt
+++ b/apps/openmw/CMakeLists.txt
@@ -19,7 +19,7 @@ source_group(game FILES ${GAME} ${GAME_HEADER})
add_openmw_dir (mwrender
renderingmanager debugging sky camera animation npcanimation creatureanimation activatoranimation
actors objects renderinginterface localmap occlusionquery water shadows
- compositors characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
+ characterpreview externalrendering globalmap videoplayer ripplesimulation refraction
terrainstorage
)
diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp
index 0dcc5b36d..51281e213 100644
--- a/apps/openmw/main.cpp
+++ b/apps/openmw/main.cpp
@@ -3,8 +3,7 @@
#include
-#include
-#include
+#include
#include "engine.hpp"
#if defined(_WIN32) && !defined(_CONSOLE)
@@ -283,7 +282,7 @@ int main(int argc, char**argv)
catch (std::exception &e)
{
#if OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_APPLE
- if (isatty(fileno(stdin)))
+ if (isatty(fileno(stdin)) || !SDL_WasInit(SDL_INIT_VIDEO))
std::cerr << "\nERROR: " << e.what() << std::endl;
else
#endif
diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp
index 8141af712..961d3d958 100644
--- a/apps/openmw/mwbase/world.hpp
+++ b/apps/openmw/mwbase/world.hpp
@@ -80,7 +80,6 @@ namespace MWBase
Render_CollisionDebug,
Render_Wireframe,
Render_Pathgrid,
- Render_Compositors,
Render_BoundingBoxes
};
diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp
index 697b75579..53c62273d 100644
--- a/apps/openmw/mwclass/apparatus.cpp
+++ b/apps/openmw/mwclass/apparatus.cpp
@@ -124,7 +124,7 @@ namespace MWClass
std::string text;
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp
index f3f36542a..5b2b7caa3 100644
--- a/apps/openmw/mwclass/armor.cpp
+++ b/apps/openmw/mwclass/armor.cpp
@@ -172,7 +172,7 @@ namespace MWClass
if (ptr.getCellRef().mCharge == -1)
return ref->mBase->mData.mValue;
else
- return ref->mBase->mData.mValue * (ptr.getCellRef().mCharge / getItemMaxHealth(ptr));
+ return ref->mBase->mData.mValue * (static_cast(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
}
void Armor::registerSelf()
@@ -248,7 +248,7 @@ namespace MWClass
+ MWGui::ToolTips::toString(ref->mBase->mData.mHealth);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight) + " (" + typeText + ")";
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp
index b22cbc31f..1da920970 100644
--- a/apps/openmw/mwclass/book.cpp
+++ b/apps/openmw/mwclass/book.cpp
@@ -136,7 +136,7 @@ namespace MWClass
std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp
index 8941f3627..c162bbe9d 100644
--- a/apps/openmw/mwclass/clothing.cpp
+++ b/apps/openmw/mwclass/clothing.cpp
@@ -191,7 +191,7 @@ namespace MWClass
std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp
index 983480782..2e7f00dd3 100644
--- a/apps/openmw/mwclass/creature.cpp
+++ b/apps/openmw/mwclass/creature.cpp
@@ -199,7 +199,7 @@ namespace MWClass
else
{
MWMechanics::DynamicStat fatigue(getCreatureStats(ptr).getFatigue());
- fatigue.setCurrent(fatigue.getCurrent() - damage);
+ fatigue.setCurrent(fatigue.getCurrent() - damage, true);
getCreatureStats(ptr).setFatigue(fatigue);
}
}
diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp
index 06d9d5d23..4296d4e1b 100644
--- a/apps/openmw/mwclass/ingredient.cpp
+++ b/apps/openmw/mwclass/ingredient.cpp
@@ -145,7 +145,7 @@ namespace MWClass
std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp
index a031d2556..6a6133cb9 100644
--- a/apps/openmw/mwclass/light.cpp
+++ b/apps/openmw/mwclass/light.cpp
@@ -183,7 +183,7 @@ namespace MWClass
std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp
index 73b47d6af..e1dc5b2e1 100644
--- a/apps/openmw/mwclass/lockpick.cpp
+++ b/apps/openmw/mwclass/lockpick.cpp
@@ -89,7 +89,7 @@ namespace MWClass
if (ptr.getCellRef().mCharge == -1)
return ref->mBase->mData.mValue;
else
- return ref->mBase->mData.mValue * (ptr.getCellRef().mCharge / getItemMaxHealth(ptr));
+ return ref->mBase->mData.mValue * (static_cast(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
}
void Lockpick::registerSelf()
@@ -141,7 +141,7 @@ namespace MWClass
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp
index 5e9801c49..e8b9bfaf2 100644
--- a/apps/openmw/mwclass/npc.cpp
+++ b/apps/openmw/mwclass/npc.cpp
@@ -669,7 +669,7 @@ namespace MWClass
else
{
MWMechanics::DynamicStat fatigue(getCreatureStats(ptr).getFatigue());
- fatigue.setCurrent(fatigue.getCurrent() - damage);
+ fatigue.setCurrent(fatigue.getCurrent() - damage, true);
getCreatureStats(ptr).setFatigue(fatigue);
}
}
diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp
index 883473eb3..e276c58aa 100644
--- a/apps/openmw/mwclass/potion.cpp
+++ b/apps/openmw/mwclass/potion.cpp
@@ -128,7 +128,7 @@ namespace MWClass
std::string text;
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
info.effects = MWGui::Widgets::MWEffectList::effectListFromESM(&ref->mBase->mEffects);
diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp
index 845c2a0d0..b54464acd 100644
--- a/apps/openmw/mwclass/probe.cpp
+++ b/apps/openmw/mwclass/probe.cpp
@@ -88,7 +88,7 @@ namespace MWClass
if (ptr.getCellRef().mCharge == -1)
return ref->mBase->mData.mValue;
else
- return ref->mBase->mData.mValue * (ptr.getCellRef().mCharge / getItemMaxHealth(ptr));
+ return ref->mBase->mData.mValue * (static_cast(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
}
void Probe::registerSelf()
@@ -140,7 +140,7 @@ namespace MWClass
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp
index dbfa9f0f6..ce2b4ff10 100644
--- a/apps/openmw/mwclass/repair.cpp
+++ b/apps/openmw/mwclass/repair.cpp
@@ -79,7 +79,7 @@ namespace MWClass
if (ptr.getCellRef().mCharge == -1)
return ref->mBase->mData.mValue;
else
- return ref->mBase->mData.mValue * (ptr.getCellRef().mCharge / getItemMaxHealth(ptr));
+ return ref->mBase->mData.mValue * (static_cast(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
}
void Repair::registerSelf()
@@ -144,7 +144,7 @@ namespace MWClass
text += "\n#{sUses}: " + MWGui::ToolTips::toString(remainingUses);
text += "\n#{sQuality}: " + MWGui::ToolTips::toString(ref->mBase->mData.mQuality);
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
if (MWBase::Environment::get().getWindowManager()->getFullHelp()) {
text += MWGui::ToolTips::getMiscString(ref->mRef.mOwner, "Owner");
diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp
index b1bf2b0b7..a09e83380 100644
--- a/apps/openmw/mwclass/weapon.cpp
+++ b/apps/openmw/mwclass/weapon.cpp
@@ -157,7 +157,7 @@ namespace MWClass
if (ptr.getCellRef().mCharge == -1)
return ref->mBase->mData.mValue;
else
- return ref->mBase->mData.mValue * (ptr.getCellRef().mCharge / getItemMaxHealth(ptr));
+ return ref->mBase->mData.mValue * (static_cast(ptr.getCellRef().mCharge) / getItemMaxHealth(ptr));
}
void Weapon::registerSelf()
@@ -346,7 +346,7 @@ namespace MWClass
}
text += "\n#{sWeight}: " + MWGui::ToolTips::toString(ref->mBase->mData.mWeight);
- text += MWGui::ToolTips::getValueString(ref->mBase->mData.mValue, "#{sValue}");
+ text += MWGui::ToolTips::getValueString(getValue(ptr), "#{sValue}");
info.enchant = ref->mBase->mEnchant;
diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp
index 52493bf76..3951cedcb 100644
--- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp
+++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp
@@ -413,10 +413,6 @@ namespace MWDialogue
void DialogueManager::goodbyeSelected()
{
- // Do not close the dialogue window if the player has to answer a question
- if (mIsInChoice)
- return;
-
MWBase::Environment::get().getWindowManager()->removeGuiMode(MWGui::GM_Dialogue);
// Apply disposition change to NPC's base disposition
@@ -474,6 +470,8 @@ namespace MWDialogue
void DialogueManager::goodbye()
{
+ mIsInChoice = true;
+
MWGui::DialogueWindow* win = MWBase::Environment::get().getWindowManager()->getDialogueWindow();
win->goodbye();
diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp
index 71995f97f..914302d84 100644
--- a/apps/openmw/mwgui/dialogue.cpp
+++ b/apps/openmw/mwgui/dialogue.cpp
@@ -302,6 +302,8 @@ namespace MWGui
void DialogueWindow::onByeClicked(MyGUI::Widget* _sender)
{
+ if (!mEnabled || MWBase::Environment::get().getDialogueManager()->isInChoice())
+ return;
MWBase::Environment::get().getDialogueManager()->goodbyeSelected();
}
diff --git a/apps/openmw/mwgui/hud.cpp b/apps/openmw/mwgui/hud.cpp
index f0843834d..a78b1a6d1 100644
--- a/apps/openmw/mwgui/hud.cpp
+++ b/apps/openmw/mwgui/hud.cpp
@@ -174,38 +174,32 @@ namespace MWGui
void HUD::setValue(const std::string& id, const MWMechanics::DynamicStat& value)
{
- static const char *ids[] =
- {
- "HBar", "MBar", "FBar", 0
- };
+ int current = std::max(0, static_cast(value.getCurrent()));
+ int modified = static_cast(value.getModified());
- for (int i=0; ids[i]; ++i)
- if (ids[i]==id)
- {
- MyGUI::Widget* w;
- std::string valStr = boost::lexical_cast(value.getCurrent()) + "/" + boost::lexical_cast(value.getModified());
- switch (i)
- {
- case 0:
- mHealth->setProgressRange (value.getModified());
- mHealth->setProgressPosition (value.getCurrent());
- getWidget(w, "HealthFrame");
- w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
- break;
- case 1:
- mMagicka->setProgressRange (value.getModified());
- mMagicka->setProgressPosition (value.getCurrent());
- getWidget(w, "MagickaFrame");
- w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
- break;
- case 2:
- mStamina->setProgressRange (value.getModified());
- mStamina->setProgressPosition (value.getCurrent());
- getWidget(w, "FatigueFrame");
- w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
- break;
- }
- }
+ MyGUI::Widget* w;
+ std::string valStr = boost::lexical_cast(current) + "/" + boost::lexical_cast(modified);
+ if (id == "HBar")
+ {
+ mHealth->setProgressRange(modified);
+ mHealth->setProgressPosition(current);
+ getWidget(w, "HealthFrame");
+ w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
+ }
+ else if (id == "MBar")
+ {
+ mMagicka->setProgressRange (modified);
+ mMagicka->setProgressPosition (current);
+ getWidget(w, "MagickaFrame");
+ w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
+ }
+ else if (id == "FBar")
+ {
+ mStamina->setProgressRange (modified);
+ mStamina->setProgressPosition (current);
+ getWidget(w, "FatigueFrame");
+ w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
+ }
}
void HUD::setDrowningTimeLeft(float time)
diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp
index 4bd383c2f..868b58209 100644
--- a/apps/openmw/mwgui/loadingscreen.cpp
+++ b/apps/openmw/mwgui/loadingscreen.cpp
@@ -1,8 +1,6 @@
#include "loadingscreen.hpp"
#include
-#include
-#include
#include
@@ -199,28 +197,7 @@ namespace MWGui
MWBase::Environment::get().getInputManager()->update(0, true);
- Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain(mWindow->getViewport(0));
-
- bool hasCompositor = chain->getCompositor ("gbufferFinalizer");
-
-
- if (!hasCompositor)
- {
- mWindow->getViewport(0)->setClearEveryFrame(false);
- }
- else
- {
- if (!mFirstLoad)
- {
- mBackgroundMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName(chain->getCompositor ("gbufferFinalizer")->getTextureInstance ("no_mrt_output", 0)->getName());
- mRectangle->setVisible(true);
- }
-
- for (unsigned int i = 0; igetNumCompositors(); ++i)
- {
- Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), false);
- }
- }
+ mWindow->getViewport(0)->setClearEveryFrame(false);
// First, swap buffers from last draw, then, queue an update of the
// window contents, but don't swap buffers (which would have
@@ -231,15 +208,8 @@ namespace MWGui
mWindow->update(false);
- if (!hasCompositor)
- mWindow->getViewport(0)->setClearEveryFrame(true);
- else
- {
- for (unsigned int i = 0; igetNumCompositors(); ++i)
- {
- Ogre::CompositorManager::getSingleton().setCompositorEnabled(mWindow->getViewport(0), chain->getCompositor(i)->getCompositor()->getName(), true);
- }
- }
+ mWindow->getViewport(0)->setClearEveryFrame(true);
+
mRectangle->setVisible(false);
diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp
index 136328f57..ab6096b7e 100644
--- a/apps/openmw/mwgui/statswindow.cpp
+++ b/apps/openmw/mwgui/statswindow.cpp
@@ -134,38 +134,28 @@ namespace MWGui
void StatsWindow::setValue (const std::string& id, const MWMechanics::DynamicStat& value)
{
- static const char *ids[] =
- {
- "HBar", "MBar", "FBar",
- 0
- };
+ int current = std::max(0, static_cast(value.getCurrent()));
+ int modified = static_cast(value.getModified());
- for (int i=0; ids[i]; ++i)
- {
- if (ids[i]==id)
- {
- std::string id (ids[i]);
- setBar (id, id + "T", static_cast(value.getCurrent()), static_cast(value.getModified()));
+ setBar (id, id + "T", current, modified);
- // health, magicka, fatigue tooltip
- MyGUI::Widget* w;
- std::string valStr = boost::lexical_cast(int(value.getCurrent())) + "/" + boost::lexical_cast(int(value.getModified()));
- if (i==0)
- {
- getWidget(w, "Health");
- w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
- }
- else if (i==1)
- {
- getWidget(w, "Magicka");
- w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
- }
- else if (i==2)
- {
- getWidget(w, "Fatigue");
- w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
- }
- }
+ // health, magicka, fatigue tooltip
+ MyGUI::Widget* w;
+ std::string valStr = boost::lexical_cast(current) + "/" + boost::lexical_cast(modified);
+ if (id == "HBar")
+ {
+ getWidget(w, "Health");
+ w->setUserString("Caption_HealthDescription", "#{sHealthDesc}\n" + valStr);
+ }
+ else if (id == "MBar")
+ {
+ getWidget(w, "Magicka");
+ w->setUserString("Caption_HealthDescription", "#{sIntDesc}\n" + valStr);
+ }
+ else if (id == "FBar")
+ {
+ getWidget(w, "Fatigue");
+ w->setUserString("Caption_HealthDescription", "#{sFatDesc}\n" + valStr);
}
}
diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp
index 78986a052..afa020082 100644
--- a/apps/openmw/mwgui/windowmanagerimp.cpp
+++ b/apps/openmw/mwgui/windowmanagerimp.cpp
@@ -112,9 +112,6 @@ namespace MWGui
, mPlayerMinorSkills()
, mPlayerMajorSkills()
, mPlayerSkillValues()
- , mPlayerHealth()
- , mPlayerMagicka()
- , mPlayerFatigue()
, mGui(NULL)
, mGuiModes()
, mCursorManager(NULL)
@@ -590,32 +587,8 @@ namespace MWGui
mStatsWindow->setValue (id, value);
mHud->setValue (id, value);
mCharGen->setValue(id, value);
- if (id == "HBar")
- {
- mPlayerHealth = value;
- }
- else if (id == "MBar")
- {
- mPlayerMagicka = value;
- }
- else if (id == "FBar")
- {
- mPlayerFatigue = value;
- }
}
- #if 0
- MWMechanics::DynamicStat WindowManager::getValue(const std::string& id)
- {
- if(id == "HBar")
- return mPlayerHealth;
- else if (id == "MBar")
- return mPlayerMagicka;
- else if (id == "FBar")
- return mPlayerFatigue;
- }
- #endif
-
void WindowManager::setValue (const std::string& id, const std::string& value)
{
mStatsWindow->setValue (id, value);
diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp
index 4f1960295..743160aa8 100644
--- a/apps/openmw/mwgui/windowmanagerimp.hpp
+++ b/apps/openmw/mwgui/windowmanagerimp.hpp
@@ -346,8 +346,6 @@ namespace MWGui
std::map > mPlayerAttributes;
SkillList mPlayerMajorSkills, mPlayerMinorSkills;
std::map > mPlayerSkillValues;
- MWMechanics::DynamicStat mPlayerHealth, mPlayerMagicka, mPlayerFatigue;
-
MyGUI::Gui *mGui; // Gui
std::vector mGuiModes;
diff --git a/apps/openmw/mwmechanics/stat.hpp b/apps/openmw/mwmechanics/stat.hpp
index 65d47c9c0..cb6c09014 100644
--- a/apps/openmw/mwmechanics/stat.hpp
+++ b/apps/openmw/mwmechanics/stat.hpp
@@ -162,14 +162,26 @@ namespace MWMechanics
setCurrent (getCurrent()+diff);
}
- void setCurrent (const T& value)
+ void setCurrent (const T& value, bool allowDecreaseBelowZero = false)
{
- mCurrent = value;
+ if (value > mCurrent)
+ {
+ // increase
+ mCurrent = value;
- if (mCurrent<0)
+ if (mCurrent > getModified())
+ mCurrent = getModified();
+ }
+ else if (value > 0 || allowDecreaseBelowZero)
+ {
+ // allowed decrease
+ mCurrent = value;
+ }
+ else if (mCurrent > 0)
+ {
+ // capped decrease
mCurrent = 0;
- else if (mCurrent>getModified())
- mCurrent = getModified();
+ }
}
void setModifier (const T& modifier)
diff --git a/apps/openmw/mwrender/compositors.cpp b/apps/openmw/mwrender/compositors.cpp
deleted file mode 100644
index b1c98a306..000000000
--- a/apps/openmw/mwrender/compositors.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-#include "compositors.hpp"
-
-#include
-#include
-#include
-#include
-
-using namespace MWRender;
-
-Compositors::Compositors(Ogre::Viewport* vp) :
- mViewport(vp)
- , mEnabled(true)
-{
-}
-
-Compositors::~Compositors()
-{
- Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
-}
-
-void Compositors::setEnabled (const bool enabled)
-{
- for (CompositorMap::iterator it=mCompositors.begin();
- it != mCompositors.end(); ++it)
- {
- Ogre::CompositorManager::getSingleton().setCompositorEnabled(mViewport, it->first, enabled && it->second.first);
- }
- mEnabled = enabled;
-}
-
-void Compositors::recreate()
-{
- Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
-
- CompositorMap temp = mCompositors;
- mCompositors.clear();
-
- for (CompositorMap::iterator it=temp.begin();
- it != temp.end(); ++it)
- {
- addCompositor(it->first, it->second.second);
- setCompositorEnabled(it->first, mEnabled && it->second.first);
- }
-}
-
-void Compositors::addCompositor (const std::string& name, const int priority)
-{
- int id = 0;
-
- for (CompositorMap::iterator it=mCompositors.begin();
- it != mCompositors.end(); ++it)
- {
- if (it->second.second > priority)
- break;
- ++id;
- }
- Ogre::CompositorManager::getSingleton().addCompositor (mViewport, name, id);
-
- mCompositors[name] = std::make_pair(false, priority);
-}
-
-void Compositors::setCompositorEnabled (const std::string& name, const bool enabled)
-{
- mCompositors[name].first = enabled;
- Ogre::CompositorManager::getSingleton().setCompositorEnabled (mViewport, name, enabled && mEnabled);
-}
-
-void Compositors::removeAll()
-{
- Ogre::CompositorManager::getSingleton().removeCompositorChain(mViewport);
-
- mCompositors.clear();
-}
-
-bool Compositors::anyCompositorEnabled()
-{
- for (CompositorMap::iterator it=mCompositors.begin();
- it != mCompositors.end(); ++it)
- {
- if (it->second.first && mEnabled)
- return true;
- }
- return false;
-}
-
-void Compositors::countTrianglesBatches(unsigned int &triangles, unsigned int &batches)
-{
- triangles = 0;
- batches = 0;
-
- Ogre::CompositorInstance* c = NULL;
- Ogre::CompositorChain* chain = Ogre::CompositorManager::getSingleton().getCompositorChain (mViewport);
- // accumulate tris & batches from all compositors with all their render targets
- for (unsigned int i=0; i < chain->getNumCompositors(); ++i)
- {
- if (chain->getCompositor(i)->getEnabled())
- {
- c = chain->getCompositor(i);
- for (unsigned int j = 0; j < c->getTechnique()->getNumTargetPasses(); ++j)
- {
- std::string textureName = c->getTechnique()->getTargetPass(j)->getOutputName();
- Ogre::RenderTarget* rt = c->getRenderTarget(textureName);
- triangles += rt->getTriangleCount();
- batches += rt->getBatchCount();
- }
- }
- }
-}
diff --git a/apps/openmw/mwrender/compositors.hpp b/apps/openmw/mwrender/compositors.hpp
deleted file mode 100644
index e5dd7503c..000000000
--- a/apps/openmw/mwrender/compositors.hpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef GAME_MWRENDER_COMPOSITORS_H
-#define GAME_MWRENDER_COMPOSITORS_H
-
-#include