diff --git a/apps/opencs/view/world/pathgridcreator.cpp b/apps/opencs/view/world/pathgridcreator.cpp index a305b1249..7d2f46b91 100644 --- a/apps/opencs/view/world/pathgridcreator.cpp +++ b/apps/opencs/view/world/pathgridcreator.cpp @@ -1,29 +1,113 @@ #include "pathgridcreator.hpp" +#include + +#include "../../model/doc/document.hpp" + +#include "../../model/world/columns.hpp" #include "../../model/world/data.hpp" +#include "../../model/world/idcompletionmanager.hpp" +#include "../../model/world/idtable.hpp" + +#include "../widget/droplineedit.hpp" +#include "idvalidator.hpp" + +std::string CSVWorld::PathgridCreator::getId() const +{ + return mCell->text().toUtf8().constData(); +} + +CSMWorld::IdTable& CSVWorld::PathgridCreator::getPathgridsTable() const +{ + return dynamic_cast ( + *getData().getTableModel(getCollectionId()) + ); +} CSVWorld::PathgridCreator::PathgridCreator( CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, + CSMWorld::IdCompletionManager& completionManager, bool relaxedIdRules ) : GenericCreator(data, undoStack, id, relaxedIdRules) -{} +{ + setManualEditing(false); + + QLabel *label = new QLabel("Cell ID", this); + insertBeforeButtons(label, false); + + // Add cell ID input with auto-completion. + CSMWorld::ColumnBase::Display displayType = CSMWorld::ColumnBase::Display_Cell; + mCell = new CSVWidget::DropLineEdit(displayType, this); + mCell->setCompleter(completionManager.getCompleter(displayType).get()); + mCell->setValidator(new IdValidator(relaxedIdRules, this)); + insertBeforeButtons(mCell, true); + + connect(mCell, SIGNAL (textChanged(const QString&)), this, SLOT (cellChanged())); + connect(mCell, SIGNAL (returnPressed()), this, SLOT (inputReturnPressed())); +} + +void CSVWorld::PathgridCreator::cloneMode( + const std::string& originId, + const CSMWorld::UniversalId::Type type) +{ + CSVWorld::GenericCreator::cloneMode(originId, type); + + // Look up cloned record in pathgrids table and set cell ID text. + CSMWorld::IdTable& table = getPathgridsTable(); + int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_Id); + mCell->setText(table.data(table.getModelIndex(originId, column)).toString()); +} std::string CSVWorld::PathgridCreator::getErrors() const { - std::string pathgridId = getId(); + std::string cellId = getId(); // Check user input for any errors. + // The last two checks, cell with existing pathgrid and non-existent cell, + // shouldn't be needed but we absolutely want to make sure they never happen. std::string errors; - if (pathgridId.empty()) + if (cellId.empty()) + { + errors = "No cell ID selected"; + } + else if (getData().getPathgrids().searchId(cellId) > -1) { - errors = "No Pathgrid ID entered"; + errors = "Pathgrid for selected cell ID already exists"; } - else if (getData().getPathgrids().searchId(pathgridId) > -1) + else if (getData().getCells().searchId(cellId) == -1) { - errors = "Pathgrid with this ID already exists"; + errors = "Cell with selected cell ID does not exist"; } return errors; } + +void CSVWorld::PathgridCreator::focus() +{ + mCell->setFocus(); +} + +void CSVWorld::PathgridCreator::reset() +{ + CSVWorld::GenericCreator::reset(); + mCell->setText(""); +} + +void CSVWorld::PathgridCreator::cellChanged() +{ + update(); +} + +CSVWorld::Creator *CSVWorld::PathgridCreatorFactory::makeCreator( + CSMDoc::Document& document, + const CSMWorld::UniversalId& id) const +{ + return new PathgridCreator( + document.getData(), + document.getUndoStack(), + id, + document.getIdCompletionManager() + ); +} diff --git a/apps/opencs/view/world/pathgridcreator.hpp b/apps/opencs/view/world/pathgridcreator.hpp index 10f64a0a7..c2ae20fc0 100644 --- a/apps/opencs/view/world/pathgridcreator.hpp +++ b/apps/opencs/view/world/pathgridcreator.hpp @@ -3,6 +3,24 @@ #include "genericcreator.hpp" +namespace CSMDoc +{ + class Document; +} + +namespace CSMWorld +{ + class Data; + class IdCompletionManager; + class IdTable; + class UniversalId; +} + +namespace CSVWidget +{ + class DropLineEdit; +} + namespace CSVWorld { /// \brief Record creator for pathgrids. @@ -10,16 +28,55 @@ namespace CSVWorld { Q_OBJECT + CSVWidget::DropLineEdit *mCell; + + private: + + /// \return Cell ID entered by user. + virtual std::string getId() const; + + /// \return reference to table containing pathgrids. + CSMWorld::IdTable& getPathgridsTable() const; + public: PathgridCreator( CSMWorld::Data& data, QUndoStack& undoStack, const CSMWorld::UniversalId& id, + CSMWorld::IdCompletionManager& completionManager, bool relaxedIdRules = false); + /// \brief Set cell ID input widget to ID of record to be cloned. + /// \param originId Cell ID to be cloned. + /// \param type Type of record to be cloned. + virtual void cloneMode( + const std::string& originId, + const CSMWorld::UniversalId::Type type); + /// \return Error description for current user input. virtual std::string getErrors() const; + + /// \brief Set focus to cell ID input widget. + virtual void focus(); + + /// \brief Clear cell ID input widget. + virtual void reset(); + + private slots: + + /// \brief Check user input for errors. + void cellChanged(); + }; + + /// \brief Creator factory for pathgrid record creator. + class PathgridCreatorFactory : public CreatorFactoryBase + { + public: + + virtual Creator *makeCreator( + CSMDoc::Document& document, + const CSMWorld::UniversalId& id) const; }; } diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index 32661ed93..93e105106 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -76,7 +76,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) new CSVDoc::SubViewFactoryWithCreator); manager.add (CSMWorld::UniversalId::Type_Pathgrids, - new CSVDoc::SubViewFactoryWithCreator >); + new CSVDoc::SubViewFactoryWithCreator); manager.add (CSMWorld::UniversalId::Type_Globals, new CSVDoc::SubViewFactoryWithCreator >); @@ -174,7 +174,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) new CSVDoc::SubViewFactoryWithCreator (false)); manager.add (CSMWorld::UniversalId::Type_Pathgrid, - new CSVDoc::SubViewFactoryWithCreator > (false)); + new CSVDoc::SubViewFactoryWithCreator (false)); manager.add (CSMWorld::UniversalId::Type_DebugProfile, new CSVDoc::SubViewFactoryWithCreator > (false)); diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 8c663474f..51e0bdcce 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -546,7 +546,7 @@ namespace MWClass bool Creature::hasToolTip(const MWWorld::ConstPtr& ptr) const { - if (!ptr.getRefData().getCustomData()) + if (!ptr.getRefData().getCustomData() || MWBase::Environment::get().getWindowManager()->isGuiMode()) return true; const CreatureCustomData& customData = ptr.getRefData().getCustomData()->asCreatureCustomData(); diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index 11f7466b9..d85991c2a 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1055,7 +1055,7 @@ namespace MWClass bool Npc::hasToolTip(const MWWorld::ConstPtr& ptr) const { - if (!ptr.getRefData().getCustomData()) + if (!ptr.getRefData().getCustomData() || MWBase::Environment::get().getWindowManager()->isGuiMode()) return true; const NpcCustomData& customData = ptr.getRefData().getCustomData()->asNpcCustomData(); diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index b3cc19a64..44ee6cac1 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -414,11 +414,11 @@ namespace MWGui const MyGUI::IntPoint padding(8, 8); - const int maximumWidth = 500; - const int imageCaptionHPadding = (caption != "" ? 8 : 0); const int imageCaptionVPadding = (caption != "" ? 4 : 0); + const int maximumWidth = MyGUI::RenderManager::getInstance().getViewSize().width - imageCaptionHPadding * 2; + std::string realImage = MWBase::Environment::get().getWindowManager()->correctIconPath(image); MyGUI::EditBox* captionWidget = mDynamicToolTipBox->createWidget("NormalText", MyGUI::IntCoord(0, 0, 300, 300), MyGUI::Align::Left | MyGUI::Align::Top, "ToolTipCaption"); diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 0b96e0d96..f1778bde0 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -367,9 +367,11 @@ void CharacterController::refreshMovementAnims(const WeaponInfo* weap, Character { if(force || movement != mMovementState) { - mIdleState = CharState_None; mMovementState = movement; + if (movement != CharState_None) + mIdleState = CharState_None; + std::string movementAnimName; MWRender::Animation::BlendMask movemask = MWRender::Animation::BlendMask_All; const StateInfo *movestate = std::find_if(sMovementList, sMovementListEnd, FindCharState(mMovementState)); @@ -1842,7 +1844,7 @@ void CharacterController::update(float duration) if (onground) cls.getCreatureStats(mPtr).land(); - if(movestate != CharState_None) + if(movestate != CharState_None && movestate != CharState_TurnLeft && movestate != CharState_TurnRight) clearAnimQueue(); if(mAnimQueue.empty() || inwater || sneak) diff --git a/apps/openmw/mwmechanics/stat.cpp b/apps/openmw/mwmechanics/stat.cpp index cf1f228c0..41c5bac5a 100644 --- a/apps/openmw/mwmechanics/stat.cpp +++ b/apps/openmw/mwmechanics/stat.cpp @@ -189,7 +189,7 @@ namespace MWMechanics void AttributeValue::setBase(int base) { - mBase = std::max(0, base); + mBase = base; } void AttributeValue::setModifier(int mod) diff --git a/apps/openmw/mwmechanics/trading.cpp b/apps/openmw/mwmechanics/trading.cpp index 469b454df..08e4d097a 100644 --- a/apps/openmw/mwmechanics/trading.cpp +++ b/apps/openmw/mwmechanics/trading.cpp @@ -52,7 +52,7 @@ namespace MWMechanics float f1 = 0.2f * merchantStats.getAttribute(ESM::Attribute::Personality).getModified(); float dispositionTerm = gmst.find("fDispositionMod")->getFloat() * (clampedDisposition - 50); - float pcTerm = (dispositionTerm - 50 + a1 + b1 + c1) * playerStats.getFatigueTerm(); + float pcTerm = (dispositionTerm + a1 + b1 + c1) * playerStats.getFatigueTerm(); float npcTerm = (d1 + e1 + f1) * merchantStats.getFatigueTerm(); float x = gmst.find("fBargainOfferMulti")->getFloat() * d + gmst.find("fBargainOfferBase")->getFloat() diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 7b9fecc93..52275c5a0 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -126,7 +126,7 @@ namespace MWScript runtime.pop(); MWMechanics::AttributeValue attribute = ptr.getClass().getCreatureStats(ptr).getAttribute(mIndex); - attribute.setBase (value - (attribute.getModified() - attribute.getBase())); + attribute.setBase (value); ptr.getClass().getCreatureStats(ptr).setAttribute(mIndex, attribute); } }; @@ -151,7 +151,18 @@ namespace MWScript .getCreatureStats(ptr) .getAttribute(mIndex); - attribute.setBase (std::min(100, attribute.getBase() + value)); + if (value == 0) + return; + + if (((attribute.getBase() <= 0) && (value < 0)) + || ((attribute.getBase() >= 100) && (value > 0))) + return; + + if (value < 0) + attribute.setBase(std::max(0, attribute.getBase() + value)); + else + attribute.setBase(std::min(100, attribute.getBase() + value)); + ptr.getClass().getCreatureStats(ptr).setAttribute(mIndex, attribute); } }; @@ -353,12 +364,7 @@ namespace MWScript MWMechanics::NpcStats& stats = ptr.getClass().getNpcStats (ptr); - int newLevel = value - (stats.getSkill(mIndex).getModified() - stats.getSkill(mIndex).getBase()); - - if (newLevel<0) - newLevel = 0; - - stats.getSkill (mIndex).setBase (newLevel); + stats.getSkill (mIndex).setBase (value); } }; @@ -378,10 +384,21 @@ namespace MWScript Interpreter::Type_Integer value = runtime[0].mInteger; runtime.pop(); - MWMechanics::NpcStats& stats = ptr.getClass().getNpcStats(ptr); + MWMechanics::SkillValue &skill = ptr.getClass() + .getNpcStats(ptr) + .getSkill(mIndex); + + if (value == 0) + return; + + if (((skill.getBase() <= 0) && (value < 0)) + || ((skill.getBase() >= 100) && (value > 0))) + return; - stats.getSkill(mIndex). - setBase (std::min(100, stats.getSkill(mIndex).getBase() + value)); + if (value < 0) + skill.setBase(std::max(0, skill.getBase() + value)); + else + skill.setBase(std::min(100, skill.getBase() + value)); } }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c01490481..99e28f374 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1059,7 +1059,7 @@ namespace MWWorld facedObject = getFacedObject(activationDistance, true); if (!facedObject.isEmpty() && !facedObject.getClass().allowTelekinesis(facedObject) - && mDistanceToFacedObject > getMaxActivationDistance()) + && mDistanceToFacedObject > getMaxActivationDistance() && !MWBase::Environment::get().getWindowManager()->isGuiMode()) return 0; } return facedObject; diff --git a/appveyor.yml b/appveyor.yml index e959792f5..d8f2bfc35 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -48,6 +48,9 @@ cache: clone_folder: C:\projects\openmw +install: + - set PATH=C:\Program Files\Git\mingw64\bin;%PATH% + before_build: - cmd: sh %APPVEYOR_BUILD_FOLDER%\CI\before_script.msvc.sh -u -p %PLATFORM% -v %msvc% diff --git a/components/resource/stats.hpp b/components/resource/stats.hpp index bd3890d9b..55b016602 100644 --- a/components/resource/stats.hpp +++ b/components/resource/stats.hpp @@ -47,7 +47,6 @@ namespace Resource float _statsHeight; std::string _font; - float _leftPos; float _characterSize; int _resourceStatsChildNum;