From afe624bd07822ca9ee9fd6ba120c9036b4ffe743 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sat, 26 Apr 2014 08:12:57 -0400 Subject: [PATCH 01/14] Cleaned up update in Actors.cpp Removed unnecessary for loops --- apps/openmw/mwmechanics/actors.cpp | 35 +++++++++--------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index ca37b152c..267170214 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -852,39 +852,29 @@ namespace MWMechanics // Note, the new hit object for this frame may be set by CharacterController::update -> Animation::runAnimation // (below) iter->first.getClass().getCreatureStats(iter->first).setLastHitObject(std::string()); - } - // AI and magic effects update - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) - { + // AI and magic effects update if (!iter->first.getClass().getCreatureStats(iter->first).isDead()) { updateActor(iter->first, duration); if(iter->first.getTypeName() == typeid(ESM::NPC).name()) updateNpc(iter->first, duration, paused); } - } - // Looping magic VFX update - // Note: we need to do this before any of the animations are updated. - // Reaching the text keys may trigger Hit / Spellcast (and as such, particles), - // so updating VFX immediately after that would just remove the particle effects instantly. - // There needs to be a magic effect update in between. - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) + // Looping magic VFX update + // Note: we need to do this before any of the animations are updated. + // Reaching the text keys may trigger Hit / Spellcast (and as such, particles), + // so updating VFX immediately after that would just remove the particle effects instantly. + // There needs to be a magic effect update in between. iter->second->updateContinuousVfx(); - // Animation/movement update - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) - { + // Animation/movement update if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( ESM::MagicEffect::Paralyze).mMagnitude > 0) iter->second->skipAnim(); iter->second->update(duration); - } - // Kill dead actors - for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++) - { + // Kill dead actors const MWWorld::Class &cls = MWWorld::Class::get(iter->first); CreatureStats &stats = cls.getCreatureStats(iter->first); @@ -912,13 +902,8 @@ namespace MWMechanics continue; } - // Make sure spell effects with CasterLinked flag are removed - // TODO: would be nice not to do this all the time... - for(PtrControllerMap::iterator iter2(mActors.begin());iter2 != mActors.end();++iter2) - { - MWMechanics::ActiveSpells& spells = iter2->first.getClass().getCreatureStats(iter2->first).getActiveSpells(); - spells.purge(iter->first.getRefData().getHandle()); - } + MWMechanics::ActiveSpells& spells = iter2->first.getClass().getCreatureStats(iter2->first).getActiveSpells(); + spells.purge(iter->first.getRefData().getHandle()); // FIXME: see http://bugs.openmw.org/issues/869 MWBase::Environment::get().getWorld()->enableActorCollision(iter->first, false); From 48b2c0073b1dceecb940eed8e54ff061833bc773 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sat, 26 Apr 2014 08:29:28 -0400 Subject: [PATCH 02/14] fix, sorry for being sloppy.. --- apps/openmw/mwmechanics/actors.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 267170214..a08cd9c33 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -845,7 +845,7 @@ namespace MWMechanics { if(!paused) { - // Reset data from previous frame + // Update actors from previous frame for (PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { // Reset last hit object, which is only valid for one frame @@ -902,7 +902,7 @@ namespace MWMechanics continue; } - MWMechanics::ActiveSpells& spells = iter2->first.getClass().getCreatureStats(iter2->first).getActiveSpells(); + MWMechanics::ActiveSpells& spells = iter->first.getClass().getCreatureStats(iter->first).getActiveSpells(); spells.purge(iter->first.getRefData().getHandle()); // FIXME: see http://bugs.openmw.org/issues/869 From f0c5d1a7e1eba636e3b0baa9ead6d00e70b059b3 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sat, 26 Apr 2014 10:03:56 -0400 Subject: [PATCH 03/14] Revert "Checks the state of the passed sneak variable" This reverts commit 4a4c08946c5b75701a5eb9b3e878c0727380909d. --- apps/openmw/mwworld/player.cpp | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index 8588547d2..f4ca5ee27 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -134,25 +134,17 @@ namespace MWWorld ptr.getClass().getCreatureStats(ptr).setMovementFlag(MWMechanics::CreatureStats::Flag_Sneak, sneak); - if (sneak == true) - { - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); - // Find all the actors who might be able to see the player - std::vector neighbors; - MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos), - esmStore.get().find("fSneakUseDist")->getInt(), neighbors); - for (std::vector::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) - MWBase::Environment::get().getWindowManager()->setSneakVisibility(true); - } + // Find all the actors who might be able to see the player + std::vector neighbors; + MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos), + esmStore.get().find("fSneakUseDist")->getInt(), neighbors); + for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) + if ( MWBase::Environment::get().getMechanicsManager()->awarenessCheck(ptr, *it) ) + MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak); + if (!neighbors.size()) + MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak); } void Player::yaw(float yaw) From b28dfa94cd5b92f47d9adef8ee06d7a1908cc7a1 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sat, 26 Apr 2014 10:07:56 -0400 Subject: [PATCH 04/14] Revert 4a4c089..f0c5d1a This rolls back to commit 4a4c08946c5b75701a5eb9b3e878c0727380909d. --- apps/openmw/mwmechanics/actors.cpp | 37 +++++++++++++++++++++--------- apps/openmw/mwworld/player.cpp | 28 ++++++++++++++-------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index a08cd9c33..ca37b152c 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -845,36 +845,46 @@ namespace MWMechanics { if(!paused) { - // Update actors from previous frame + // Reset data from previous frame for (PtrControllerMap::iterator iter(mActors.begin()); iter != mActors.end(); ++iter) { // Reset last hit object, which is only valid for one frame // Note, the new hit object for this frame may be set by CharacterController::update -> Animation::runAnimation // (below) iter->first.getClass().getCreatureStats(iter->first).setLastHitObject(std::string()); + } - // AI and magic effects update + // AI and magic effects update + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) + { if (!iter->first.getClass().getCreatureStats(iter->first).isDead()) { updateActor(iter->first, duration); if(iter->first.getTypeName() == typeid(ESM::NPC).name()) updateNpc(iter->first, duration, paused); } + } - // Looping magic VFX update - // Note: we need to do this before any of the animations are updated. - // Reaching the text keys may trigger Hit / Spellcast (and as such, particles), - // so updating VFX immediately after that would just remove the particle effects instantly. - // There needs to be a magic effect update in between. + // Looping magic VFX update + // Note: we need to do this before any of the animations are updated. + // Reaching the text keys may trigger Hit / Spellcast (and as such, particles), + // so updating VFX immediately after that would just remove the particle effects instantly. + // There needs to be a magic effect update in between. + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) iter->second->updateContinuousVfx(); - // Animation/movement update + // Animation/movement update + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter) + { if (iter->first.getClass().getCreatureStats(iter->first).getMagicEffects().get( ESM::MagicEffect::Paralyze).mMagnitude > 0) iter->second->skipAnim(); iter->second->update(duration); + } - // Kill dead actors + // Kill dead actors + for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++) + { const MWWorld::Class &cls = MWWorld::Class::get(iter->first); CreatureStats &stats = cls.getCreatureStats(iter->first); @@ -902,8 +912,13 @@ namespace MWMechanics continue; } - MWMechanics::ActiveSpells& spells = iter->first.getClass().getCreatureStats(iter->first).getActiveSpells(); - spells.purge(iter->first.getRefData().getHandle()); + // Make sure spell effects with CasterLinked flag are removed + // TODO: would be nice not to do this all the time... + for(PtrControllerMap::iterator iter2(mActors.begin());iter2 != mActors.end();++iter2) + { + MWMechanics::ActiveSpells& spells = iter2->first.getClass().getCreatureStats(iter2->first).getActiveSpells(); + spells.purge(iter->first.getRefData().getHandle()); + } // FIXME: see http://bugs.openmw.org/issues/869 MWBase::Environment::get().getWorld()->enableActorCollision(iter->first, false); diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index f4ca5ee27..8588547d2 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -134,17 +134,25 @@ namespace MWWorld ptr.getClass().getCreatureStats(ptr).setMovementFlag(MWMechanics::CreatureStats::Flag_Sneak, sneak); - const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); + if (sneak == true) + { + const MWWorld::ESMStore& esmStore = MWBase::Environment::get().getWorld()->getStore(); - // Find all the actors who might be able to see the player - std::vector neighbors; - MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos), - esmStore.get().find("fSneakUseDist")->getInt(), neighbors); - for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) - if ( MWBase::Environment::get().getMechanicsManager()->awarenessCheck(ptr, *it) ) - MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak); - if (!neighbors.size()) - MWBase::Environment::get().getWindowManager()->setSneakVisibility(sneak); + // Find all the actors who might be able to see the player + std::vector neighbors; + MWBase::Environment::get().getMechanicsManager()->getActorsInRange( Ogre::Vector3(ptr.getRefData().getPosition().pos), + esmStore.get().find("fSneakUseDist")->getInt(), neighbors); + for (std::vector::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) + MWBase::Environment::get().getWindowManager()->setSneakVisibility(true); + } } void Player::yaw(float yaw) From ab33e78b6799c8875d262048651787ee83a8f044 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 26 Apr 2014 09:40:58 -0500 Subject: [PATCH 05/14] Added RangeView class files --- apps/opencs/CMakeLists.txt | 1 + apps/opencs/view/settings/booleanview.hpp | 2 +- apps/opencs/view/settings/rangeview.cpp | 91 +++++++++++++++++++++++ apps/opencs/view/settings/rangeview.hpp | 44 +++++++++++ 4 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 apps/opencs/view/settings/rangeview.cpp create mode 100644 apps/opencs/view/settings/rangeview.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 8ab44243d..680c8f8b7 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -95,6 +95,7 @@ opencs_units (view/settings booleanview textview listview + rangeview resizeablestackedwidget ) diff --git a/apps/opencs/view/settings/booleanview.hpp b/apps/opencs/view/settings/booleanview.hpp index 52f9e05f1..55ef0bb08 100644 --- a/apps/opencs/view/settings/booleanview.hpp +++ b/apps/opencs/view/settings/booleanview.hpp @@ -1,5 +1,5 @@ #ifndef CSVSETTINGS_BOOLEANVIEW_HPP -#define CSVSETTINGS_BOOELANVIEW_HPP +#define CSVSETTINGS_BOOLEANVIEW_HPP #include #include diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp new file mode 100644 index 000000000..411e12775 --- /dev/null +++ b/apps/opencs/view/settings/rangeview.cpp @@ -0,0 +1,91 @@ +#include +#include + +#include +#include +#include + +#include + +#include "rangeview.hpp" +#include "../../model/settings/setting.hpp" + +CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, + Page *parent) + : View (setting, parent) +{ + foreach (const QString &value, setting->declaredValues()) + { + QAbstractButton *button = 0; + + if (isMultiValue()) + button = new QCheckBox (value, this); + else + button = new QRadioButton (value, this); + + connect (button, SIGNAL (clicked (bool)), + this, SLOT (slotToggled (bool))); + + button->setObjectName (value); + + addWidget (button); + + mButtons[value] = button; + } +} + +void CSVSettings::RangeView::slotToggled (bool state) +{ + //test only for true to avoid multiple selection updates with radiobuttons + if (!isMultiValue() && !state) + return; + + QStringList values; + + foreach (QString key, mButtons.keys()) + { + if (mButtons.value(key)->isChecked()) + values.append (key); + } + setSelectedValues (values, false); + + View::updateView(); +} + +void CSVSettings::RangeView::updateView (bool signalUpdate) const +{ + + QStringList values = selectedValues(); + + foreach (const QString &buttonName, mButtons.keys()) + { + QAbstractButton *button = mButtons[buttonName]; + + //if the value is not found in the list, the widget is checked false + bool buttonValue = values.contains(buttonName); + + //skip if the butotn value will not change + if (button->isChecked() == buttonValue) + continue; + + //disable autoexclusive if it's enabled and we're setting + //the button value to false + bool switchExclusive = (!buttonValue && button->autoExclusive()); + + if (switchExclusive) + button->setAutoExclusive (false); + + button->setChecked (buttonValue); + + if (switchExclusive) + button->setAutoExclusive(true); + } + View::updateView (signalUpdate); +} + +CSVSettings::RangeView *CSVSettings::RangeViewFactory::createView + (CSMSettings::Setting *setting, + Page *parent) +{ + return new RangeView (setting, parent); +} diff --git a/apps/opencs/view/settings/rangeview.hpp b/apps/opencs/view/settings/rangeview.hpp new file mode 100644 index 000000000..1df0c7bd6 --- /dev/null +++ b/apps/opencs/view/settings/rangeview.hpp @@ -0,0 +1,44 @@ +#ifndef CSVSETTINGS_RANGEVIEW_HPP +#define CSVSETTINGS_RANGEVIEW_HPP + +#include +#include + +#include "view.hpp" +#include "../../model/settings/support.hpp" + +class QStringListModel; + +namespace CSVSettings +{ + class RangeView : public View + { + Q_OBJECT + + QMap mButtons; + + public: + explicit RangeView (CSMSettings::Setting *setting, + Page *parent); + + protected: + void updateView (bool signalUpdate = true) const; + + private slots: + void slotToggled (bool state); + }; + + class RangeViewFactory : public QObject, public IViewFactory + { + Q_OBJECT + + public: + explicit RangeViewFactory (QWidget *parent = 0) + : QObject (parent) + {} + + RangeView *createView (CSMSettings::Setting *setting, + Page *parent); + }; +} +#endif // CSVSETTINGS_RANGEVIEW_HPP From 1fb2c8d87bf505ccf003415e2fafcefb218e4688 Mon Sep 17 00:00:00 2001 From: cc9cii Date: Sat, 26 Apr 2014 19:47:47 +1000 Subject: [PATCH 06/14] NPC turning is less hacky but still not perfect. NPC's should walk away after a period of non-action by the player (vanilla behaviour) - not yet implemented. --- apps/openmw/mwmechanics/aiwander.cpp | 41 +++++++++++++++++----------- apps/openmw/mwmechanics/aiwander.hpp | 1 + 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index ad94be0eb..2d1fbdd78 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -1,6 +1,7 @@ #include "aiwander.hpp" #include +#include #include "../mwbase/world.hpp" #include "../mwbase/environment.hpp" @@ -211,7 +212,7 @@ namespace MWMechanics // Reduce the turning animation glitch by using a *HUGE* value of // epsilon... TODO: a proper fix might be in either the physics or the // animation subsystem - if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(12))) + if (zTurn(actor, Ogre::Degree(mTargetAngle), Ogre::Degree(5))) mRotate = false; } @@ -333,18 +334,7 @@ namespace MWMechanics if(mChooseAction) { mPlayedIdle = 0; - unsigned short idleRoll = 0; - - for(unsigned int counter = 0; counter < mIdle.size(); counter++) - { - unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter]; - unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier)); - if(randSelect < idleChance && randSelect > idleRoll) - { - mPlayedIdle = counter+2; - idleRoll = randSelect; - } - } + getRandomIdle(); // NOTE: sets mPlayedIdle with a random selection if(!mPlayedIdle && mDistance) { @@ -395,6 +385,8 @@ namespace MWMechanics mMoveNow = false; mWalking = false; mObstacleCheck.clear(); + mIdleNow = true; + getRandomIdle(); } if(!mRotate) @@ -402,11 +394,11 @@ namespace MWMechanics Ogre::Vector3 dir = playerPos - actorPos; float length = dir.length(); - // FIXME: horrible hack float faceAngle = Ogre::Radian(Ogre::Math::ACos(dir.y / length) * ((Ogre::Math::ASin(dir.x / length).valueRadians()>0)?1.0:-1.0)).valueDegrees(); + float actorAngle = actor.getRefData().getBaseNode()->getOrientation().getRoll().valueDegrees(); // an attempt at reducing the turning animation glitch - if(abs(faceAngle) > 10) + if(abs(abs(faceAngle) - abs(actorAngle)) >= 5) // TODO: is there a better way? { mTargetAngle = faceAngle; mRotate = true; @@ -432,7 +424,8 @@ namespace MWMechanics } // Check if idle animation finished - if(!checkIdle(actor, mPlayedIdle)) + // FIXME: don't stay forever + if(!checkIdle(actor, mPlayedIdle) && playerDistSqr > helloDistance*helloDistance) { mPlayedIdle = 0; mIdleNow = false; @@ -586,5 +579,21 @@ namespace MWMechanics else return false; } + + void AiWander::getRandomIdle() + { + unsigned short idleRoll = 0; + + for(unsigned int counter = 0; counter < mIdle.size(); counter++) + { + unsigned short idleChance = mIdleChanceMultiplier * mIdle[counter]; + unsigned short randSelect = (int)(rand() / ((double)RAND_MAX + 1) * int(100 / mIdleChanceMultiplier)); + if(randSelect < idleChance && randSelect > idleRoll) + { + mPlayedIdle = counter+2; + idleRoll = randSelect; + } + } + } } diff --git a/apps/openmw/mwmechanics/aiwander.hpp b/apps/openmw/mwmechanics/aiwander.hpp index fe14abeb6..35ecc83e0 100644 --- a/apps/openmw/mwmechanics/aiwander.hpp +++ b/apps/openmw/mwmechanics/aiwander.hpp @@ -26,6 +26,7 @@ namespace MWMechanics void stopWalking(const MWWorld::Ptr& actor); void playIdle(const MWWorld::Ptr& actor, unsigned short idleSelect); bool checkIdle(const MWWorld::Ptr& actor, unsigned short idleSelect); + void getRandomIdle(); int mDistance; // how far the actor can wander from the spawn point int mDuration; From 0d711e51b00463308d455510d8668322fec81099 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 26 Apr 2014 21:32:36 -0500 Subject: [PATCH 07/14] Converted SettingType enums to indicate widget type. --- apps/opencs/model/settings/setting.cpp | 17 ++++++------ apps/opencs/model/settings/support.hpp | 29 +++++++++++++++------ apps/opencs/model/settings/usersettings.cpp | 18 ++++++------- apps/opencs/view/settings/page.cpp | 2 ++ apps/opencs/view/settings/rangeview.cpp | 4 +++ apps/opencs/view/settings/settingwindow.cpp | 12 +++++---- 6 files changed, 51 insertions(+), 31 deletions(-) diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index 6c7e78087..ca682b454 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -12,15 +12,14 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, { buildDefaultSetting(); - int vType = static_cast (typ); + int settingType = static_cast (typ); - if ((vType % 2) == 0) - setProperty (Property_IsMultiValue, - QVariant(true).toString()); - else - vType--; + //even-numbered setting types are multi-valued + if ((settingType % 2) == 0) + setProperty (Property_IsMultiValue, QVariant(true).toString()); - setProperty (Property_ViewType, QVariant (vType / 2).toString()); + //view type is related to setting type by an order of magnitude + setProperty (Property_ViewType, QVariant (settingType / 10).toString()); setProperty (Property_Page, pageName); setProperty (Property_Name, settingName); setProperty (Property_DeclaredValues, values); @@ -267,9 +266,9 @@ void CSMSettings::Setting::setProperty (SettingProperty prop, QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting) { - stream << setting.properties(); + // stream << setting.properties(); - stream << setting.proxies(); + // stream << setting.proxies(); return stream; } diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index abc86a0cb..ce808587f 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -47,14 +47,27 @@ namespace CSMSettings enum SettingType { - Type_MultiBool = 0, - Type_SingleBool = 1, - Type_MultiList = 2, - Type_SingleList = 3, - Type_MultiRange = 4, - Type_SingleRange = 5, - Type_MultiText = 6, - Type_SingleText = 7 + /* + * 0 - 9 - Boolean widgets + * 10-19 - List widgets + * 21-29 - Range widgets + * 31-39 - Text widgets + * + * Each range corresponds to a View_Type enum by a factor of 10. + * + * Even-numbered values are single-value widgets + * Odd-numbered values are multi-valued widgets + */ + + Type_CheckBox = 0, + Type_RadioButton = 1, + Type_ListView = 10, + Type_ComboBox = 11, + Type_SpinBox = 21, + Type_Slider = 23, + Type_Dial = 24, + Type_TextArea = 30, + Type_LineEdit = 31 }; enum MergeMethod diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 808fbfc70..2f8e8098d 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -47,8 +47,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() { QString section = "Window Size"; { - Setting *width = createSetting (Type_SingleText, section, "Width"); - Setting *height = createSetting (Type_SingleText, section, "Height"); + Setting *width = createSetting (Type_LineEdit, section, "Width"); + Setting *height = createSetting (Type_LineEdit, section, "Height"); width->setWidgetWidth (5); height->setWidgetWidth (5); @@ -65,7 +65,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() /* *Create the proxy setting for predefined values */ - Setting *preDefined = createSetting (Type_SingleList, section, + Setting *preDefined = createSetting (Type_ComboBox, section, "Pre-Defined", QStringList() << "640 x 480" @@ -94,11 +94,11 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() QStringList values = QStringList() << defaultValue << "Icon Only" << "Text Only"; - Setting *rsd = createSetting (Type_SingleBool, + Setting *rsd = createSetting (Type_RadioButton, section, "Record Status Display", values); - Setting *ritd = createSetting (Type_SingleBool, + Setting *ritd = createSetting (Type_RadioButton, section, "Referenceable ID Type Display", values); @@ -110,24 +110,24 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() { //create three setting objects, specifying the basic widget type, //the setting view name, the page name, and the default value - Setting *masterBoolean = createSetting (Type_SingleBool, section, + Setting *masterBoolean = createSetting (Type_RadioButton, section, "Master Proxy", QStringList() << "Profile One" << "Profile Two" << "Profile Three" << "Profile Four" ); - Setting *slaveBoolean = createSetting (Type_MultiBool, section, + Setting *slaveBoolean = createSetting (Type_CheckBox, section, "Proxy Checkboxes", QStringList() << "One" << "Two" << "Three" << "Four" << "Five" ); - Setting *slaveSingleText = createSetting (Type_SingleText, section, + Setting *slaveSingleText = createSetting (Type_LineEdit, section, "Proxy TextBox 1" ); - Setting *slaveMultiText = createSetting (Type_SingleText, section, + Setting *slaveMultiText = createSetting (Type_LineEdit, section, "ProxyTextBox 2" ); diff --git a/apps/opencs/view/settings/page.cpp b/apps/opencs/view/settings/page.cpp index a5711c8f8..e67445873 100644 --- a/apps/opencs/view/settings/page.cpp +++ b/apps/opencs/view/settings/page.cpp @@ -3,6 +3,7 @@ #include "booleanview.hpp" #include "textview.hpp" #include "listview.hpp" +#include "rangeview.hpp" #include "../../model/settings/usersettings.hpp" #include "../../model/settings/connector.hpp" @@ -85,4 +86,5 @@ void CSVSettings::Page::buildFactories() mViewFactories[ViewType_Boolean] = new BooleanViewFactory (this); mViewFactories[ViewType_Text] = new TextViewFactory (this); mViewFactories[ViewType_List] = new ListViewFactory (this); + mViewFactories[ViewType_Range] = new RangeViewFactory (this); } diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 411e12775..12b71d28f 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -10,6 +10,9 @@ #include "rangeview.hpp" #include "../../model/settings/setting.hpp" + +#include + CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, Page *parent) : View (setting, parent) @@ -87,5 +90,6 @@ CSVSettings::RangeView *CSVSettings::RangeViewFactory::createView (CSMSettings::Setting *setting, Page *parent) { + qDebug() << "adding a new range view"; return new RangeView (setting, parent); } diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 9283bbf51..8eccee646 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -14,16 +14,18 @@ CSVSettings::SettingWindow::SettingWindow(QWidget *parent) void CSVSettings::SettingWindow::createPages() { + qDebug () << "getting page map"; CSMSettings::SettingPageMap pageMap = mModel->settingPageMap(); QList connectedSettings; - + qDebug () << "iterating map"; foreach (const QString &pageName, pageMap.keys()) - { + { + qDebug() << "iterating page: " << pageName; QList pageSettings = pageMap.value (pageName); - + qDebug () << "appending page: " << pageName << "; settings = " << pageSettings.size(); mPages.append (new Page (pageName, pageSettings, this)); - + qDebug() << "iterating page " << pageName << " settings"; for (int i = 0; i < pageSettings.size(); i++) { CSMSettings::Setting *setting = pageSettings.at(i); @@ -32,7 +34,7 @@ void CSVSettings::SettingWindow::createPages() connectedSettings.append (setting); } } - + qDebug() << "making connections"; if (!connectedSettings.isEmpty()) createConnections(connectedSettings); } From 985af15a12f2645c1fe47f25c67e460d2f4d39da Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 26 Apr 2014 21:43:42 -0500 Subject: [PATCH 08/14] removed qdebug references --- apps/opencs/view/settings/rangeview.cpp | 1 - apps/opencs/view/settings/settingwindow.cpp | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 12b71d28f..2bb5863bc 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -90,6 +90,5 @@ CSVSettings::RangeView *CSVSettings::RangeViewFactory::createView (CSMSettings::Setting *setting, Page *parent) { - qDebug() << "adding a new range view"; return new RangeView (setting, parent); } diff --git a/apps/opencs/view/settings/settingwindow.cpp b/apps/opencs/view/settings/settingwindow.cpp index 8eccee646..7bd0b228e 100644 --- a/apps/opencs/view/settings/settingwindow.cpp +++ b/apps/opencs/view/settings/settingwindow.cpp @@ -14,18 +14,16 @@ CSVSettings::SettingWindow::SettingWindow(QWidget *parent) void CSVSettings::SettingWindow::createPages() { - qDebug () << "getting page map"; CSMSettings::SettingPageMap pageMap = mModel->settingPageMap(); QList connectedSettings; - qDebug () << "iterating map"; + foreach (const QString &pageName, pageMap.keys()) { - qDebug() << "iterating page: " << pageName; QList pageSettings = pageMap.value (pageName); - qDebug () << "appending page: " << pageName << "; settings = " << pageSettings.size(); + mPages.append (new Page (pageName, pageSettings, this)); - qDebug() << "iterating page " << pageName << " settings"; + for (int i = 0; i < pageSettings.size(); i++) { CSMSettings::Setting *setting = pageSettings.at(i); @@ -34,7 +32,7 @@ void CSVSettings::SettingWindow::createPages() connectedSettings.append (setting); } } - qDebug() << "making connections"; + if (!connectedSettings.isEmpty()) createConnections(connectedSettings); } From ce106d3becb8b1b7739f21011578d86a76f61c7b Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sun, 27 Apr 2014 09:34:33 -0400 Subject: [PATCH 09/14] Revert "NPCs detect crime exclusively" This reverts commit 54d9615d85ae856ad4fdd2c130ac9cb0cd847c72. Conflicts: apps/openmw/mwmechanics/mechanicsmanagerimp.cpp --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 2b1fdd365..26c629fb8 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -843,7 +843,10 @@ namespace MWMechanics // Find an actor who witnessed the crime for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { +<<<<<<< HEAD +======= if (*it == ptr) continue; // not the player +>>>>>>> parent of 54d9615... NPCs detect crime exclusively // Was the crime seen? if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || From b9bd4bc1265a4f4c531b1456f9a4fcf21076cd55 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sun, 27 Apr 2014 09:34:59 -0400 Subject: [PATCH 10/14] broken --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 26c629fb8..88d07cfa6 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -844,6 +844,8 @@ namespace MWMechanics for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { <<<<<<< HEAD + if ( *it == ptr + && it->getClass().isNpc()) continue; // not the player and is an NPC ======= if (*it == ptr) continue; // not the player >>>>>>> parent of 54d9615... NPCs detect crime exclusively @@ -862,7 +864,8 @@ namespace MWMechanics // Tell everyone, including yourself for (std::vector::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) { - if (*it1 == ptr) continue; // not the player + if ( *it == ptr + && it->getClass().isNpc()) continue; // not the player and is an NPC // TODO: Add more messages if (type == OT_Theft) From 0409e18a0e7a903a00bc4c4b0951ee7532ec0317 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sun, 27 Apr 2014 09:35:49 -0400 Subject: [PATCH 11/14] revert --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 88d07cfa6..2b1fdd365 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -843,12 +843,7 @@ namespace MWMechanics // Find an actor who witnessed the crime for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { -<<<<<<< HEAD - if ( *it == ptr - && it->getClass().isNpc()) continue; // not the player and is an NPC -======= if (*it == ptr) continue; // not the player ->>>>>>> parent of 54d9615... NPCs detect crime exclusively // Was the crime seen? if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || @@ -864,8 +859,7 @@ namespace MWMechanics // Tell everyone, including yourself for (std::vector::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) { - if ( *it == ptr - && it->getClass().isNpc()) continue; // not the player and is an NPC + if (*it1 == ptr) continue; // not the player // TODO: Add more messages if (type == OT_Theft) From 7599b26d309bba10a22adab0abd051674a31eb5a Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sun, 27 Apr 2014 09:37:43 -0400 Subject: [PATCH 12/14] Fixed: creatures won't witness crimes and potential crash. --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 2b1fdd365..03beed5a5 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -843,7 +843,8 @@ namespace MWMechanics // Find an actor who witnessed the crime for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { - if (*it == ptr) continue; // not the player + if ( *it == ptr + && it->getClass().isNpc()) continue; // not the player and is an NPC // Was the crime seen? if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || @@ -859,7 +860,8 @@ namespace MWMechanics // Tell everyone, including yourself for (std::vector::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) { - if (*it1 == ptr) continue; // not the player + if ( *it == ptr + && it->getClass().isNpc()) continue; // not the player and is an NPC // TODO: Add more messages if (type == OT_Theft) From 52bb7c3f69914084eacd1affa8470017286a4b1d Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sun, 27 Apr 2014 09:55:38 -0400 Subject: [PATCH 13/14] fixed logic. ! --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 03beed5a5..8b8788741 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -844,7 +844,7 @@ namespace MWMechanics for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { if ( *it == ptr - && it->getClass().isNpc()) continue; // not the player and is an NPC + && !it->getClass().isNpc()) continue; // not the player and is an NPC // Was the crime seen? if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || @@ -861,7 +861,7 @@ namespace MWMechanics for (std::vector::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) { if ( *it == ptr - && it->getClass().isNpc()) continue; // not the player and is an NPC + && !it->getClass().isNpc()) continue; // not the player and is an NPC // TODO: Add more messages if (type == OT_Theft) From edbc319c424d6fd29b00338608f6e52fc2f7b644 Mon Sep 17 00:00:00 2001 From: Jeffrey Haines Date: Sun, 27 Apr 2014 10:05:34 -0400 Subject: [PATCH 14/14] fixed logic. || --- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 8b8788741..eca0c2289 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -844,7 +844,7 @@ namespace MWMechanics for (std::vector::iterator it = neighbors.begin(); it != neighbors.end(); ++it) { if ( *it == ptr - && !it->getClass().isNpc()) continue; // not the player and is an NPC + || !it->getClass().isNpc()) continue; // not the player and is an NPC // Was the crime seen? if ( ( MWBase::Environment::get().getWorld()->getLOS(ptr, *it) && awarenessCheck(ptr, *it) ) || @@ -861,7 +861,7 @@ namespace MWMechanics for (std::vector::iterator it1 = neighbors.begin(); it1 != neighbors.end(); ++it1) { if ( *it == ptr - && !it->getClass().isNpc()) continue; // not the player and is an NPC + || !it->getClass().isNpc()) continue; // not the player and is an NPC // TODO: Add more messages if (type == OT_Theft)