Skip to content

Commit

Permalink
Merge branch '0.7.1' into 0.7.1-urm
Browse files Browse the repository at this point in the history
  • Loading branch information
uramer committed Mar 14, 2020
2 parents 41dcb9f + 43e7df6 commit a6579d1
Show file tree
Hide file tree
Showing 56 changed files with 543 additions and 246 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Bug #3977: Non-ASCII characters in object ID's are not supported
Bug #4009: Launcher does not show data files on the first run after installing
Bug #4077: Enchanted items are not recharged if they are not in the player's inventory
Bug #4141: PCSkipEquip isn't set to 1 when reading books/scrolls
Bug #4202: Open .omwaddon files without needing toopen openmw-cs first
Bug #4240: Ash storm origin coordinates and hand shielding animation behavior are incorrect
Bug #4262: Rain settings are hardcoded
Expand All @@ -36,6 +37,8 @@
Bug #4411: Reloading a saved game while falling prevents damage in some cases
Bug #4449: Value returned by GetWindSpeed is incorrect
Bug #4456: AiActivate should not be cancelled after target activation
Bug #4493: If the setup doesn't find what it is expecting, it fails silently and displays the requester again instead of letting the user know what wasn't found.
Bug #4523: "player->ModCurrentFatigue -0.001" in global script does not cause the running player to fall
Bug #4540: Rain delay when exiting water
Bug #4594: Actors without AI packages don't use Hello dialogue
Bug #4598: Script parser does not support non-ASCII characters
Expand Down Expand Up @@ -200,7 +203,8 @@
Bug #5264: "Damage Fatigue" Magic Effect Can Bring Fatigue below 0
Bug #5269: Editor: Cell lighting in resaved cleaned content files is corrupted
Bug #5278: Console command Show doesn't fall back to global variable after local var not found
Feature #1415: Infinite fall failsafe
Bug #5300: NPCs don't switch from torch to shield when starting combat
Bug #5308: World map copying makes save loading much slower
Feature #1774: Handle AvoidNode
Feature #2229: Improve pathfinding AI
Feature #3025: Analogue gamepad movement controls
Expand All @@ -224,6 +228,7 @@
Feature #4730: Native animated containers support
Feature #4784: Launcher: Duplicate Content Lists
Feature #4812: Support NiSwitchNode
Feature #4831: Item search in the player's inventory
Feature #4836: Daytime node switch
Feature #4840: Editor: Transient terrain change support
Feature #4859: Make water reflections more configurable
Expand Down Expand Up @@ -253,9 +258,11 @@
Feature #5146: Safe Dispose corpse
Feature #5147: Show spell magicka cost in spell buying window
Feature #5170: Editor: Land shape editing, land selection
Feature #5172: Editor: Delete instances/references with keypress in scene window
Feature #5193: Weapon sheathing
Feature #5219: Impelement TestCells console command
Feature #5224: Handle NiKeyframeController for NiTriShape
Feature #5304: Morrowind-style bump-mapping
Task #4686: Upgrade media decoder to a more current FFmpeg API
Task #4695: Optimize Distant Terrain memory consumption
Task #4789: Optimize cell transitions
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG_PR.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ New Editor Features:
- "Faction Ranks" table for "Faction" records (#4209)
- Changes to height editing can be cancelled without changes to data (press esc to cancel) (#4840)
- Land heightmap/shape editing and vertex selection (#5170)
- Deleting instances with a keypress (#5172)

Bug Fixes:
- The Mouse Wheel can now be used for key bindings (#2679)
Expand Down
1 change: 1 addition & 0 deletions apps/opencs/model/prefs/state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ void CSMPrefs::State::declare()
declareShortcut ("scene-select-secondary", "Secondary Select",
QKeySequence(Qt::ControlModifier | (int)Qt::MiddleButton));
declareModifier ("scene-speed-modifier", "Speed Modifier", Qt::Key_Shift);
declareShortcut ("scene-delete", "Delete Instance", QKeySequence(Qt::Key_Delete));
declareShortcut ("scene-load-cam-cell", "Load Camera Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_5));
declareShortcut ("scene-load-cam-eastcell", "Load East Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_6));
declareShortcut ("scene-load-cam-northcell", "Load North Cell", QKeySequence(Qt::KeypadModifier | Qt::Key_8));
Expand Down
5 changes: 3 additions & 2 deletions apps/opencs/model/world/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ CSMWorld::Data::Data (ToUTF8::FromType encoding, bool fsStrict, const Files::Pat

Shader::ShaderManager::DefineMap defines = mResourceSystem->getSceneManager()->getShaderManager().getGlobalDefines();
Shader::ShaderManager::DefineMap shadowDefines = SceneUtil::ShadowManager::getShadowsDisabledDefines();
defines["forcePPL"] = "0";
defines["clamp"] = "1";
defines["forcePPL"] = "0"; // Don't force per-pixel lighting
defines["clamp"] = "1"; // Clamp lighting
defines["preLightEnv"] = "0"; // Apply environment maps after lighting like Morrowind
for (const auto& define : shadowDefines)
defines[define.first] = define.second;
mResourceSystem->getSceneManager()->getShaderManager().setGlobalDefines(defines);
Expand Down
22 changes: 22 additions & 0 deletions apps/opencs/view/render/instancemode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../../model/world/idtree.hpp"
#include "../../model/world/commands.hpp"
#include "../../model/world/commandmacro.hpp"
#include "../../model/prefs/shortcut.hpp"

#include "../widget/scenetoolbar.hpp"
#include "../widget/scenetoolmode.hpp"
Expand Down Expand Up @@ -96,6 +97,9 @@ CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidg
{
connect(this, SIGNAL(requestFocus(const std::string&)),
worldspaceWidget, SIGNAL(requestFocus(const std::string&)));

CSMPrefs::Shortcut* deleteShortcut = new CSMPrefs::Shortcut("scene-delete", worldspaceWidget);
connect(deleteShortcut, SIGNAL(activated(bool)), this, SLOT(deleteSelectedInstances(bool)));
}

void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar)
Expand Down Expand Up @@ -659,3 +663,21 @@ void CSVRender::InstanceMode::subModeChanged (const std::string& id)
getWorldspaceWidget().abortDrag();
getWorldspaceWidget().setSubMode (getSubModeFromId (id), SceneUtil::Mask_EditorReference);
}

void CSVRender::InstanceMode::deleteSelectedInstances(bool active)
{
std::vector<osg::ref_ptr<TagBase> > selection = getWorldspaceWidget().getSelection (SceneUtil::Mask_EditorReference);
if (selection.empty()) return;

CSMDoc::Document& document = getWorldspaceWidget().getDocument();
CSMWorld::IdTable& referencesTable = dynamic_cast<CSMWorld::IdTable&> (
*document.getData().getTableModel (CSMWorld::UniversalId::Type_References));
QUndoStack& undoStack = document.getUndoStack();

CSMWorld::CommandMacro macro (undoStack, "Delete Instances");
for(osg::ref_ptr<TagBase> tag: selection)
if (CSVRender::ObjectTag *objectTag = dynamic_cast<CSVRender::ObjectTag *> (tag.get()))
macro.push(new CSMWorld::DeleteCommand(referencesTable, objectTag->mObject->getReferenceId()));

getWorldspaceWidget().clearSelection (SceneUtil::Mask_EditorReference);
}
1 change: 1 addition & 0 deletions apps/opencs/view/render/instancemode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ namespace CSVRender
private slots:

void subModeChanged (const std::string& id);
void deleteSelectedInstances(bool active);
};
}

Expand Down
4 changes: 4 additions & 0 deletions apps/openmw/mwbase/world.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ namespace MWBase

virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) = 0;

virtual bool castRay(const osg::Vec3f& from, const osg::Vec3f& to, int mask, const MWWorld::ConstPtr& ignore) = 0;

virtual void setActorCollisionMode(const MWWorld::Ptr& ptr, bool internal, bool external) = 0;
virtual bool isActorCollisionEnabled(const MWWorld::Ptr& ptr) = 0;

Expand Down Expand Up @@ -825,6 +827,8 @@ namespace MWBase
virtual osg::Vec3f getPathfindingHalfExtents(const MWWorld::ConstPtr& actor) const = 0;

virtual bool hasCollisionWithDoor(const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const = 0;

virtual bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, const MWWorld::ConstPtr& ignore) const = 0;
};
}

Expand Down
9 changes: 9 additions & 0 deletions apps/openmw/mwgui/companionwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ CompanionWindow::CompanionWindow(DragAndDrop *dragAndDrop, MessageBoxManager* ma
getWidget(mCloseButton, "CloseButton");
getWidget(mProfitLabel, "ProfitLabel");
getWidget(mEncumbranceBar, "EncumbranceBar");
getWidget(mFilterEdit, "FilterEdit");
getWidget(mItemView, "ItemView");
mItemView->eventBackgroundClicked += MyGUI::newDelegate(this, &CompanionWindow::onBackgroundSelected);
mItemView->eventItemClicked += MyGUI::newDelegate(this, &CompanionWindow::onItemSelected);
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &CompanionWindow::onNameFilterChanged);

mCloseButton->eventMouseButtonClick += MyGUI::newDelegate(this, &CompanionWindow::onCloseButtonClicked);

Expand Down Expand Up @@ -92,6 +94,12 @@ void CompanionWindow::onItemSelected(int index)
dragItem (nullptr, count);
}

void CompanionWindow::onNameFilterChanged(MyGUI::EditBox* _sender)
{
mSortModel->setNameFilter(_sender->getCaption());
mItemView->update();
}

void CompanionWindow::dragItem(MyGUI::Widget* sender, int count)
{
mDragAndDrop->startDrag(mSelectedItem, mSortModel, mModel, mItemView, count);
Expand All @@ -113,6 +121,7 @@ void CompanionWindow::setPtr(const MWWorld::Ptr& npc)

mModel = new CompanionItemModel(npc);
mSortModel = new SortFilterItemModel(mModel);
mFilterEdit->setCaption(std::string());
mItemView->setModel(mSortModel);
mItemView->resetScrollBars();

Expand Down
2 changes: 2 additions & 0 deletions apps/openmw/mwgui/companionwindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,13 @@ namespace MWGui
DragAndDrop* mDragAndDrop;

MyGUI::Button* mCloseButton;
MyGUI::EditBox* mFilterEdit;
MyGUI::TextBox* mProfitLabel;
Widgets::MWDynamicStat* mEncumbranceBar;
MessageBoxManager* mMessageBoxManager;

void onItemSelected(int index);
void onNameFilterChanged(MyGUI::EditBox* _sender);
void onBackgroundSelected();
void dragItem(MyGUI::Widget* sender, int count);

Expand Down
70 changes: 39 additions & 31 deletions apps/openmw/mwgui/inventorywindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <MyGUI_RenderManager.h>
#include <MyGUI_InputManager.h>
#include <MyGUI_Button.h>
#include <MyGUI_EditBox.h>

#include <osg/Texture2D>

Expand Down Expand Up @@ -35,12 +36,10 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/scriptmanager.hpp"

#include "../mwworld/inventorystore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/actionequip.hpp"
#include "../mwscript/interpretercontext.hpp"

#include "../mwmechanics/actorutil.hpp"
#include "../mwmechanics/creaturestats.hpp"
Expand Down Expand Up @@ -104,6 +103,7 @@ namespace MWGui
getWidget(mLeftPane, "LeftPane");
getWidget(mRightPane, "RightPane");
getWidget(mArmorRating, "ArmorRating");
getWidget(mFilterEdit, "FilterEdit");

mAvatarImage->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onAvatarClicked);
mAvatarImage->setRenderItemTexture(mPreviewTexture.get());
Expand All @@ -118,6 +118,7 @@ namespace MWGui
mFilterApparel->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
mFilterMagic->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
mFilterMisc->eventMouseButtonClick += MyGUI::newDelegate(this, &InventoryWindow::onFilterChanged);
mFilterEdit->eventEditTextChange += MyGUI::newDelegate(this, &InventoryWindow::onNameFilterChanged);

mFilterAll->setStateSelected(true);

Expand Down Expand Up @@ -147,6 +148,8 @@ namespace MWGui
else
mSortModel = new SortFilterItemModel(mTradeModel);

mSortModel->setNameFilter(mFilterEdit->getCaption());

mItemView->setModel(mSortModel);

mFilterAll->setStateSelected(true);
Expand Down Expand Up @@ -402,6 +405,11 @@ namespace MWGui

void InventoryWindow::onOpen()
{
// Reset the filter focus when opening the window
MyGUI::Widget* focus = MyGUI::InputManager::getInstance().getKeyFocusWidget();
if (focus == mFilterEdit)
MWBase::Environment::get().getWindowManager()->setKeyFocusWidget(nullptr);

if (!mPtr.isEmpty())
{
updateEncumbranceBar();
Expand Down Expand Up @@ -479,6 +487,12 @@ namespace MWGui
width*mScaleFactor/float(mPreview->getTextureWidth()), height*mScaleFactor/float(mPreview->getTextureHeight())));
}

void InventoryWindow::onNameFilterChanged(MyGUI::EditBox* _sender)
{
mSortModel->setNameFilter(_sender->getCaption());
mItemView->update();
}

void InventoryWindow::onFilterChanged(MyGUI::Widget* _sender)
{
if (_sender == mFilterAll)
Expand All @@ -491,7 +505,6 @@ namespace MWGui
mSortModel->setCategory(SortFilterItemModel::Category_Magic);
else if (_sender == mFilterMisc)
mSortModel->setCategory(SortFilterItemModel::Category_Misc);

mFilterAll->setStateSelected(false);
mFilterWeapon->setStateSelected(false);
mFilterApparel->setStateSelected(false);
Expand Down Expand Up @@ -521,6 +534,16 @@ namespace MWGui
void InventoryWindow::useItem(const MWWorld::Ptr &ptr, bool force)
{
const std::string& script = ptr.getClass().getScript(ptr);
if (!script.empty())
{
// Don't try to equip the item if PCSkipEquip is set to 1
if (ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 1)
{
ptr.getRefData().getLocals().setVarByInt(script, "onpcequip", 1);
return;
}
ptr.getRefData().getLocals().setVarByInt(script, "onpcequip", 0);
}

MWWorld::Ptr player = MWMechanics::getPlayer();

Expand All @@ -540,43 +563,28 @@ namespace MWGui

if (canEquip.first == 0)
{
/// If PCSkipEquip is set, set OnPCEquip to 1 and don't message anything
if (!script.empty() && ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 1)
ptr.getRefData().getLocals().setVarByInt(script, "onpcequip", 1);
else
MWBase::Environment::get().getWindowManager()->messageBox(canEquip.second);
MWBase::Environment::get().getWindowManager()->messageBox(canEquip.second);
updateItemView();
return;
}
}
}

// If the item has a script, set its OnPcEquip to 1
if (!script.empty()
// Another morrowind oddity: when an item has skipped equipping and pcskipequip is reset to 0 afterwards,
// the next time it is equipped will work normally, but will not set onpcequip
&& (ptr != mSkippedToEquip || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 1))
ptr.getRefData().getLocals().setVarByInt(script, "onpcequip", 1);

// Give the script a chance to run once before we do anything else
// this is important when setting pcskipequip as a reaction to onpcequip being set (bk_treasuryreport does this)
if (!force && !script.empty() && MWBase::Environment::get().getWorld()->getScriptsEnabled())
// If the item has a script, set OnPCEquip or PCSkipEquip to 1
if (!script.empty())
{
MWScript::InterpreterContext interpreterContext (&ptr.getRefData().getLocals(), ptr);
MWBase::Environment::get().getScriptManager()->run (script, interpreterContext);
// Ingredients, books and repair hammers must not have OnPCEquip set to 1 here
const std::string& type = ptr.getTypeName();
bool isBook = type == typeid(ESM::Book).name();
if (!isBook && type != typeid(ESM::Ingredient).name() && type != typeid(ESM::Repair).name())
ptr.getRefData().getLocals().setVarByInt(script, "onpcequip", 1);
// Books must have PCSkipEquip set to 1 instead
else if (isBook)
ptr.getRefData().getLocals().setVarByInt(script, "pcskipequip", 1);
}

mSkippedToEquip = MWWorld::Ptr();
if (ptr.getRefData().getCount()) // make sure the item is still there, the script might have removed it
{
if (script.empty() || ptr.getRefData().getLocals().getIntVar(script, "pcskipequip") == 0)
{
std::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr, force);
action->execute(player);
}
else
mSkippedToEquip = ptr;
}
std::shared_ptr<MWWorld::Action> action = ptr.getClass().use(ptr, force);
action->execute(player);

if (isVisible())
{
Expand Down
5 changes: 3 additions & 2 deletions apps/openmw/mwgui/inventorywindow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ namespace MWGui
MyGUI::Button* mFilterApparel;
MyGUI::Button* mFilterMagic;
MyGUI::Button* mFilterMisc;

MWWorld::Ptr mSkippedToEquip;
MyGUI::EditBox* mFilterEdit;

GuiMode mGuiMode;

Expand Down Expand Up @@ -121,6 +121,7 @@ namespace MWGui

void onWindowResize(MyGUI::Window* _sender);
void onFilterChanged(MyGUI::Widget* _sender);
void onNameFilterChanged(MyGUI::EditBox* _sender);
void onAvatarClicked(MyGUI::Widget* _sender);
void onPinToggled();

Expand Down
3 changes: 0 additions & 3 deletions apps/openmw/mwgui/keyboardnavigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ namespace MWGui

bool shouldAcceptKeyFocus(MyGUI::Widget* w)
{
if (w && w->getUserString("IgnoreTabKey") == "y")
return false;

return w && !w->castType<MyGUI::Window>(false) && w->getInheritedEnabled() && w->getInheritedVisible() && w->getVisible() && w->getEnabled();
}

Expand Down
9 changes: 9 additions & 0 deletions apps/openmw/mwgui/sortfilteritemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ namespace MWGui
return false;
}

std::string compare = Misc::StringUtils::lowerCase(item.mBase.getClass().getName(item.mBase));
if(compare.find(mNameFilter) == std::string::npos)
return false;

return true;
}

Expand Down Expand Up @@ -277,6 +281,11 @@ namespace MWGui
mFilter = filter;
}

void SortFilterItemModel::setNameFilter (const std::string& filter)
{
mNameFilter = Misc::StringUtils::lowerCase(filter);
}

void SortFilterItemModel::update()
{
mSourceModel->update();
Expand Down
Loading

0 comments on commit a6579d1

Please sign in to comment.