From c1901069be63ecd09b6c5d34d3e56807c3c05bb2 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 15 Jan 2016 12:07:25 +0100 Subject: [PATCH 01/30] added instance mode sub-modes --- apps/opencs/view/render/instancemode.cpp | 43 +++++++++++++++++++++++- apps/opencs/view/render/instancemode.hpp | 10 ++++++ apps/opencs/view/world/scenesubview.cpp | 2 +- 3 files changed, 53 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index b6430036b..449d9d7a6 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -9,6 +9,9 @@ #include "../../model/world/idtree.hpp" #include "../../model/world/commands.hpp" +#include "../widget/scenetoolbar.hpp" +#include "../widget/scenetoolmode.hpp" + #include "elements.hpp" #include "object.hpp" #include "worldspacewidget.hpp" @@ -16,9 +19,47 @@ CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent) : EditMode (worldspaceWidget, QIcon (":placeholder"), Element_Reference, "Instance editing", - parent) + parent), mSubMode (0) +{ +} + +void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar) +{ + if (!mSubMode) + { + mSubMode = new CSVWidget::SceneToolMode (toolbar, "Edit Sub-Mode"); + mSubMode->addButton (":placeholder", "move", + "Move selected instances" + "" + "Not implemented yet"); + mSubMode->addButton (":placeholder", "rotate", + "Rotate selected instances" + "" + "Not implemented yet"); + mSubMode->addButton (":placeholder", "scale", + "Scale selected instances" + "" + "Not implemented yet"); + } + + EditMode::activate (toolbar); + + toolbar->addTool (mSubMode); +} + +void CSVRender::InstanceMode::deactivate (CSVWidget::SceneToolbar *toolbar) { + toolbar->removeTool (mSubMode); + delete mSubMode; + mSubMode = 0; + EditMode::deactivate (toolbar); } void CSVRender::InstanceMode::primaryEditPressed (osg::ref_ptr tag) diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index 7649c241c..1eec62874 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -3,16 +3,26 @@ #include "editmode.hpp" +namespace CSVWidget +{ + class SceneToolMode; +} + namespace CSVRender { class InstanceMode : public EditMode { Q_OBJECT + CSVWidget::SceneToolMode *mSubMode; public: InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent = 0); + virtual void activate (CSVWidget::SceneToolbar *toolbar); + + virtual void deactivate (CSVWidget::SceneToolbar *toolbar); + virtual void primaryEditPressed (osg::ref_ptr tag); virtual void secondaryEditPressed (osg::ref_ptr tag); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 44fe94d84..7014b1486 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -122,7 +122,7 @@ CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::Worldsp CSVWidget::SceneToolRun *runTool = widget->makeRunTool (toolbar); toolbar->addTool (runTool); - toolbar->addTool (widget->makeEditModeSelector (toolbar)); + toolbar->addTool (widget->makeEditModeSelector (toolbar), runTool); return toolbar; } From 19b39de351d9329a10dc42e2906e919018100661 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Tue, 19 Jan 2016 11:15:36 +0100 Subject: [PATCH 02/30] use trusty --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0910ac546..10b47ee7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ os: - linux # - osx language: cpp +sudo: required +dist: trusty branches: only: - master From 0305ae369327ad39a354a5b7f91abaed424b0287 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Jan 2016 12:17:13 +0100 Subject: [PATCH 03/30] added selection mode UI --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/view/render/instancemode.cpp | 23 +++++++++++++--- apps/opencs/view/render/instancemode.hpp | 3 +++ .../view/render/instanceselectionmode.cpp | 27 +++++++++++++++++++ .../view/render/instanceselectionmode.hpp | 19 +++++++++++++ 5 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 apps/opencs/view/render/instanceselectionmode.cpp create mode 100644 apps/opencs/view/render/instanceselectionmode.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 0e9a49432..ae4bbd66c 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -85,7 +85,7 @@ opencs_units (view/widget opencs_units (view/render scenewidget worldspacewidget pagedworldspacewidget unpagedworldspacewidget - previewwidget editmode instancemode + previewwidget editmode instancemode instanceselectionmode ) opencs_units_noqt (view/render diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index 449d9d7a6..53ebc7052 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -16,10 +16,11 @@ #include "object.hpp" #include "worldspacewidget.hpp" #include "pagedworldspacewidget.hpp" +#include "instanceselectionmode.hpp" CSVRender::InstanceMode::InstanceMode (WorldspaceWidget *worldspaceWidget, QWidget *parent) : EditMode (worldspaceWidget, QIcon (":placeholder"), Element_Reference, "Instance editing", - parent), mSubMode (0) + parent), mSubMode (0), mSelectionMode (0) { } @@ -48,16 +49,30 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar) "Not implemented yet"); } + if (!mSelectionMode) + mSelectionMode = new InstanceSelectionMode (toolbar); + EditMode::activate (toolbar); toolbar->addTool (mSubMode); + toolbar->addTool (mSelectionMode); } void CSVRender::InstanceMode::deactivate (CSVWidget::SceneToolbar *toolbar) { - toolbar->removeTool (mSubMode); - delete mSubMode; - mSubMode = 0; + if (mSelectionMode) + { + toolbar->removeTool (mSelectionMode); + delete mSelectionMode; + mSelectionMode = 0; + } + + if (mSubMode) + { + toolbar->removeTool (mSubMode); + delete mSubMode; + mSubMode = 0; + } EditMode::deactivate (toolbar); } diff --git a/apps/opencs/view/render/instancemode.hpp b/apps/opencs/view/render/instancemode.hpp index 1eec62874..78836878a 100644 --- a/apps/opencs/view/render/instancemode.hpp +++ b/apps/opencs/view/render/instancemode.hpp @@ -10,10 +10,13 @@ namespace CSVWidget namespace CSVRender { + class InstanceSelectionMode; + class InstanceMode : public EditMode { Q_OBJECT CSVWidget::SceneToolMode *mSubMode; + InstanceSelectionMode *mSelectionMode; public: diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp new file mode 100644 index 000000000..9fd825999 --- /dev/null +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -0,0 +1,27 @@ + +#include "instanceselectionmode.hpp" + +CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent) +: CSVWidget::SceneToolMode (parent, "Selection Mode") +{ + addButton (":placeholder", "cube-centre", + "Centred cube" + "
  • Drag with primary (make instances the selection) or secondary (invert selection state) select button from the centre of the selection cube outwards
  • " + "
  • The selection cube is aligned to the word space axis
  • " + "
  • If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect
  • " + "
" + "Not implemented yet"); + addButton (":placeholder", "cube-corner", + "Cube corner to corner" + "
  • Drag with primary (make instances the selection) or secondary (invert selection state) select button from one corner of the selection cube to the opposite corner
  • " + "
  • The selection cube is aligned to the word space axis
  • " + "
  • If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect
  • " + "
" + "Not implemented yet"); + addButton (":placeholder", "sphere", + "Centred sphere" + "
  • Drag with primary (make instances the selection) or secondary (invert selection state) select button from the centre of the selection sphere outwards
  • " + "
  • If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect
  • " + "
" + "Not implemented yet"); +} diff --git a/apps/opencs/view/render/instanceselectionmode.hpp b/apps/opencs/view/render/instanceselectionmode.hpp new file mode 100644 index 000000000..e823de213 --- /dev/null +++ b/apps/opencs/view/render/instanceselectionmode.hpp @@ -0,0 +1,19 @@ +#ifndef CSV_RENDER_INSTANCE_SELECTION_MODE_H +#define CSV_RENDER_INSTANCE_SELECTION_MODE_H + +#include "../widget/scenetoolmode.hpp" + +namespace CSVRender +{ + class InstanceSelectionMode : public CSVWidget::SceneToolMode + { + Q_OBJECT + + public: + + InstanceSelectionMode (CSVWidget::SceneToolbar *parent); + + }; +} + +#endif From eee972a1a4414a065e55153fe88413f7e6229cfc Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Jan 2016 12:47:11 +0100 Subject: [PATCH 04/30] added scene tool mode context menu feature --- apps/opencs/view/widget/scenetoolmode.cpp | 17 +++++++++++++++++ apps/opencs/view/widget/scenetoolmode.hpp | 11 +++++++++++ 2 files changed, 28 insertions(+) diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index a93bb0556..efb508f9d 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -3,10 +3,24 @@ #include #include #include +#include +#include #include "scenetoolbar.hpp" #include "modebutton.hpp" +void CSVWidget::SceneToolMode::contextMenuEvent (QContextMenuEvent *event) +{ + QMenu menu (this); + if (createContextMenu (&menu)) + menu.exec (event->globalPos()); +} + +bool CSVWidget::SceneToolMode::createContextMenu (QMenu *menu) +{ + return false; +} + void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode) { QString toolTip = mToolTip; @@ -15,6 +29,9 @@ void CSVWidget::SceneToolMode::adjustToolTip (const ModeButton *activeMode) toolTip += "

(left click to change mode)"; + if (createContextMenu (0)) + toolTip += "
(right click to access context menu)"; + setToolTip (toolTip); } diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp index 6828a2269..43cd4a7d7 100644 --- a/apps/opencs/view/widget/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -6,6 +6,7 @@ #include class QHBoxLayout; +class QMenu; namespace CSVWidget { @@ -29,6 +30,16 @@ namespace CSVWidget void adjustToolTip (const ModeButton *activeMode); + virtual void contextMenuEvent (QContextMenuEvent *event); + + /// Add context menu items to \a menu. Default-implementation: return false + /// + /// \attention menu can be a 0-pointer + /// + /// \return Have there been any menu items to be added (if menu is 0 and there + /// items to be added, the function must return true anyway. + virtual bool createContextMenu (QMenu *menu); + public: SceneToolMode (SceneToolbar *parent, const QString& toolTip); From ecbcd6b1717718d1ccaa3e18d7ad930eb2244f61 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Jan 2016 12:52:30 +0100 Subject: [PATCH 05/30] allow mode buttons to setup the context menu --- apps/opencs/view/widget/modebutton.cpp | 5 +++++ apps/opencs/view/widget/modebutton.hpp | 10 ++++++++++ apps/opencs/view/widget/scenetoolmode.cpp | 3 +++ apps/opencs/view/widget/scenetoolmode.hpp | 3 ++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/widget/modebutton.cpp b/apps/opencs/view/widget/modebutton.cpp index 7c62f6bb1..88f050247 100644 --- a/apps/opencs/view/widget/modebutton.cpp +++ b/apps/opencs/view/widget/modebutton.cpp @@ -7,3 +7,8 @@ CSVWidget::ModeButton::ModeButton (const QIcon& icon, const QString& tooltip, QW void CSVWidget::ModeButton::activate (SceneToolbar *toolbar) {} void CSVWidget::ModeButton::deactivate (SceneToolbar *toolbar) {} + +bool CSVWidget::ModeButton::createContextMenu (QMenu *menu) +{ + return false; +} diff --git a/apps/opencs/view/widget/modebutton.hpp b/apps/opencs/view/widget/modebutton.hpp index ac14afc95..1615ff298 100644 --- a/apps/opencs/view/widget/modebutton.hpp +++ b/apps/opencs/view/widget/modebutton.hpp @@ -3,6 +3,8 @@ #include "pushbutton.hpp" +class QMenu; + namespace CSVWidget { class SceneToolbar; @@ -22,6 +24,14 @@ namespace CSVWidget /// Default-Implementation: do nothing virtual void deactivate (SceneToolbar *toolbar); + + /// Add context menu items to \a menu. Default-implementation: return false + /// + /// \attention menu can be a 0-pointer + /// + /// \return Have there been any menu items to be added (if menu is 0 and there + /// items to be added, the function must return true anyway. + virtual bool createContextMenu (QMenu *menu); }; } diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index efb508f9d..125f4ac79 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -18,6 +18,9 @@ void CSVWidget::SceneToolMode::contextMenuEvent (QContextMenuEvent *event) bool CSVWidget::SceneToolMode::createContextMenu (QMenu *menu) { + if (mCurrent) + return mCurrent->createContextMenu (menu); + return false; } diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp index 43cd4a7d7..3aa8e6799 100644 --- a/apps/opencs/view/widget/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -32,7 +32,8 @@ namespace CSVWidget virtual void contextMenuEvent (QContextMenuEvent *event); - /// Add context menu items to \a menu. Default-implementation: return false + /// Add context menu items to \a menu. Default-implementation: Pass on request to + /// current mode button or return false, if there is no current mode button. /// /// \attention menu can be a 0-pointer /// From 45e6974266f6df4c9185bf2b225309d19d969078 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 19 Jan 2016 14:25:20 +0100 Subject: [PATCH 06/30] added select all and clear selection features --- apps/opencs/view/render/instancemode.cpp | 3 +- .../view/render/instanceselectionmode.cpp | 37 ++++++++++++++++++- .../view/render/instanceselectionmode.hpp | 23 +++++++++++- .../view/render/pagedworldspacewidget.cpp | 9 +++++ .../view/render/pagedworldspacewidget.hpp | 3 ++ .../view/render/unpagedworldspacewidget.cpp | 6 +++ .../view/render/unpagedworldspacewidget.hpp | 3 ++ apps/opencs/view/render/worldspacewidget.hpp | 3 ++ 8 files changed, 82 insertions(+), 5 deletions(-) diff --git a/apps/opencs/view/render/instancemode.cpp b/apps/opencs/view/render/instancemode.cpp index ff49e0286..4b6b2e41f 100644 --- a/apps/opencs/view/render/instancemode.cpp +++ b/apps/opencs/view/render/instancemode.cpp @@ -9,7 +9,6 @@ #include "../../model/world/idtree.hpp" #include "../../model/world/commands.hpp" - #include "../widget/scenetoolbar.hpp" #include "../widget/scenetoolmode.hpp" @@ -52,7 +51,7 @@ void CSVRender::InstanceMode::activate (CSVWidget::SceneToolbar *toolbar) } if (!mSelectionMode) - mSelectionMode = new InstanceSelectionMode (toolbar); + mSelectionMode = new InstanceSelectionMode (toolbar, getWorldspaceWidget()); EditMode::activate (toolbar); diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp index 9fd825999..794a150d2 100644 --- a/apps/opencs/view/render/instanceselectionmode.cpp +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -1,8 +1,25 @@ #include "instanceselectionmode.hpp" -CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent) -: CSVWidget::SceneToolMode (parent, "Selection Mode") +#include +#include + +#include "worldspacewidget.hpp" + +bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu) +{ + if (menu) + { + menu->addAction (mSelectAll); + menu->addAction (mDeselectAll); + } + + return true; +} + +CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar *parent, + WorldspaceWidget& worldspaceWidget) +: CSVWidget::SceneToolMode (parent, "Selection Mode"), mWorldspaceWidget (worldspaceWidget) { addButton (":placeholder", "cube-centre", "Centred cube" @@ -24,4 +41,20 @@ CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar "

  • If context selection mode is enabled, a drag with primary/secondary edit not starting on an instance will have the same effect
  • " "" "Not implemented yet"); + + mSelectAll = new QAction ("Select all Instances", this); + mDeselectAll = new QAction ("Clear selection", this); + + connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll())); + connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection())); +} + +void CSVRender::InstanceSelectionMode::selectAll() +{ + mWorldspaceWidget.selectAll (Mask_Reference); +} + +void CSVRender::InstanceSelectionMode::clearSelection() +{ + mWorldspaceWidget.clearSelection (Mask_Reference); } diff --git a/apps/opencs/view/render/instanceselectionmode.hpp b/apps/opencs/view/render/instanceselectionmode.hpp index e823de213..6b3a4e37d 100644 --- a/apps/opencs/view/render/instanceselectionmode.hpp +++ b/apps/opencs/view/render/instanceselectionmode.hpp @@ -3,16 +3,37 @@ #include "../widget/scenetoolmode.hpp" +class QAction; + namespace CSVRender { + class WorldspaceWidget; + class InstanceSelectionMode : public CSVWidget::SceneToolMode { Q_OBJECT + WorldspaceWidget& mWorldspaceWidget; + QAction *mSelectAll; + QAction *mDeselectAll; + + /// Add context menu items to \a menu. + /// + /// \attention menu can be a 0-pointer + /// + /// \return Have there been any menu items to be added (if menu is 0 and there + /// items to be added, the function must return true anyway. + virtual bool createContextMenu (QMenu *menu); + public: - InstanceSelectionMode (CSVWidget::SceneToolbar *parent); + InstanceSelectionMode (CSVWidget::SceneToolbar *parent, WorldspaceWidget& worldspaceWidget); + + private slots: + + void selectAll(); + void clearSelection(); }; } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index 1880beab8..ccb3efb1d 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -509,6 +509,15 @@ void CSVRender::PagedWorldspaceWidget::clearSelection (int elementMask) flagAsModified(); } +void CSVRender::PagedWorldspaceWidget::selectAll (int elementMask) +{ + for (std::map::iterator iter = mCells.begin(); + iter!=mCells.end(); ++iter) + iter->second->setSelection (elementMask, Cell::Selection_All); + + flagAsModified(); +} + std::string CSVRender::PagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const { const int cellSize = 8192; diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 647341d1f..3f9e605af 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -98,6 +98,9 @@ namespace CSVRender /// \param elementMask Elements to be affected by the clear operation virtual void clearSelection (int elementMask); + /// \param elementMask Elements to be affected by the select operation + virtual void selectAll (int elementMask); + virtual std::string getCellId (const osg::Vec3f& point) const; protected: diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index dad37c946..48180f866 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -108,6 +108,12 @@ void CSVRender::UnpagedWorldspaceWidget::clearSelection (int elementMask) flagAsModified(); } +void CSVRender::UnpagedWorldspaceWidget::selectAll (int elementMask) +{ + mCell->setSelection (elementMask, Cell::Selection_All); + flagAsModified(); +} + std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const { return mCellId; diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index 70a20c216..8971f22a8 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -46,6 +46,9 @@ namespace CSVRender /// \param elementMask Elements to be affected by the clear operation virtual void clearSelection (int elementMask); + /// \param elementMask Elements to be affected by the select operation + virtual void selectAll (int elementMask); + virtual std::string getCellId (const osg::Vec3f& point) const; private: diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 7a77edad4..13e66b7f0 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -127,6 +127,9 @@ namespace CSVRender /// \param elementMask Elements to be affected by the clear operation virtual void clearSelection (int elementMask) = 0; + /// \param elementMask Elements to be affected by the select operation + virtual void selectAll (int elementMask) = 0; + /// Return the next intersection point with scene elements matched by /// \a interactionMask based on \a localPos and the camera vector. /// If there is no such point, instead a point "in front" of \a localPos will be From f0971ee8ad2f1e4d0a67a9aa6d5c6916c25ec91b Mon Sep 17 00:00:00 2001 From: scrawl Date: Wed, 20 Jan 2016 04:07:07 +0100 Subject: [PATCH 07/30] Implement Fixme script instruction --- apps/openmw/mwscript/docs/vmformat.txt | 4 +++- apps/openmw/mwscript/transformationextensions.cpp | 14 ++++++++++++++ apps/openmw/mwworld/worldimp.cpp | 3 ++- components/compiler/extensions0.cpp | 1 + components/compiler/opcodes.hpp | 2 ++ 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwscript/docs/vmformat.txt b/apps/openmw/mwscript/docs/vmformat.txt index 42c204ecb..93219c649 100644 --- a/apps/openmw/mwscript/docs/vmformat.txt +++ b/apps/openmw/mwscript/docs/vmformat.txt @@ -447,5 +447,7 @@ op 0x20002fe: RemoveFromLevItem op 0x20002ff: SetFactionReaction op 0x2000300: EnableLevelupMenu op 0x2000301: ToggleScripts +op 0x2000302: Fixme +op 0x2000303: Fixme, explicit -opcodes 0x2000302-0x3ffffff unused +opcodes 0x2000304-0x3ffffff unused diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index 60847e745..64c126de1 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -734,6 +734,18 @@ namespace MWScript } }; + template + class OpFixme : public Interpreter::Opcode0 + { + public: + + virtual void execute (Interpreter::Runtime& runtime) + { + MWWorld::Ptr ptr = R()(runtime); + MWBase::Environment::get().getWorld()->fixPosition(ptr); + } + }; + void installOpcodes (Interpreter::Interpreter& interpreter) { interpreter.installSegment5(Compiler::Transformation::opcodeSetScale,new OpSetScale); @@ -774,6 +786,8 @@ namespace MWScript interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingAngle, new OpGetStartingAngle); interpreter.installSegment5(Compiler::Transformation::opcodeGetStartingAngleExplicit, new OpGetStartingAngle); interpreter.installSegment5(Compiler::Transformation::opcodeResetActors, new OpResetActors); + interpreter.installSegment5(Compiler::Transformation::opcodeFixme, new OpFixme); + interpreter.installSegment5(Compiler::Transformation::opcodeFixmeExplicit, new OpFixme); } } } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c566a32b5..014c6b200 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1311,7 +1311,8 @@ namespace MWWorld actor.getRefData().setPosition(pos); osg::Vec3f traced = mPhysics->traceDown(actor, dist*1.1f); - moveObject(actor, actor.getCell(), traced.x(), traced.y(), traced.z()); + if (traced != pos.asVec3()) + moveObject(actor, actor.getCell(), traced.x(), traced.y(), traced.z()); } void World::rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust) diff --git a/components/compiler/extensions0.cpp b/components/compiler/extensions0.cpp index 8c76cdbb8..6916945f9 100644 --- a/components/compiler/extensions0.cpp +++ b/components/compiler/extensions0.cpp @@ -541,6 +541,7 @@ namespace Compiler extensions.registerInstruction("moveworld","cf",opcodeMoveWorld,opcodeMoveWorldExplicit); extensions.registerFunction("getstartingangle",'f',"c",opcodeGetStartingAngle,opcodeGetStartingAngleExplicit); extensions.registerInstruction("resetactors","",opcodeResetActors); + extensions.registerInstruction("fixme","",opcodeFixme, opcodeFixmeExplicit); extensions.registerInstruction("ra","",opcodeResetActors); } } diff --git a/components/compiler/opcodes.hpp b/components/compiler/opcodes.hpp index e7d51d934..feed5513e 100644 --- a/components/compiler/opcodes.hpp +++ b/components/compiler/opcodes.hpp @@ -498,6 +498,8 @@ namespace Compiler const int opcodeMoveWorld = 0x2000208; const int opcodeMoveWorldExplicit = 0x2000209; const int opcodeResetActors = 0x20002f4; + const int opcodeFixme = 0x2000302; + const int opcodeFixmeExplicit = 0x2000303; } namespace User From 339fbe23a7c0f1d89e683f6fa41728a7b5c3d428 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 20 Jan 2016 14:03:51 +0100 Subject: [PATCH 08/30] remove precise cruft --- CI/before_install.linux.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/CI/before_install.linux.sh b/CI/before_install.linux.sh index 6e288aa14..1c02bc8d9 100755 --- a/CI/before_install.linux.sh +++ b/CI/before_install.linux.sh @@ -1,22 +1,17 @@ #!/bin/sh if [ "${ANALYZE}" ]; then - if [ $(lsb_release -sc) = "precise" ]; then - echo "yes" | sudo apt-add-repository ppa:ubuntu-toolchain-r/test - fi echo "yes" | sudo add-apt-repository "deb http://llvm.org/apt/`lsb_release -sc`/ llvm-toolchain-`lsb_release -sc`-3.6 main" wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - fi echo "yes" | sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu `lsb_release -sc` main universe restricted multiverse" echo "yes" | sudo apt-add-repository ppa:openmw/openmw -echo "yes" | sudo apt-add-repository ppa:boost-latest/ppa sudo apt-get update -qq sudo apt-get install -qq libgtest-dev google-mock -sudo apt-get install -qq libboost-filesystem1.55-dev libboost-program-options1.55-dev libboost-system1.55-dev libboost-thread1.55-dev -sudo apt-get install -qq ffmpeg libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev +sudo apt-get install -qq libboost-filesystem-dev libboost-program-options-dev libboost-system-dev libboost-thread-dev +sudo apt-get install -qq libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev sudo apt-get install -qq libbullet-dev libopenscenegraph-dev libmygui-dev libsdl2-dev libunshield-dev libtinyxml-dev libopenal-dev libqt4-dev -sudo apt-get install -qq cmake-data #workaround for broken osgqt cmake script in ubuntu 12.04 if [ "${ANALYZE}" ]; then sudo apt-get install -qq clang-3.6; fi sudo mkdir /usr/src/gtest/build cd /usr/src/gtest/build From b8d19eb9cd09324b456c23a3f968a51d03432596 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Wed, 20 Jan 2016 14:30:33 +0100 Subject: [PATCH 09/30] make use of 2 dedicated cores while assuming both are blocked on I/O --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 10b47ee7d..3a76944fb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -40,7 +40,7 @@ before_script: - if [ "${TRAVIS_OS_NAME}" = "osx" ]; then ./CI/before_script.osx.sh; fi script: - cd ./build - - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE}make -j2; fi + - if [ "$COVERITY_SCAN_BRANCH" != 1 ]; then ${ANALYZE}make -j3; fi - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "osx" ]; then make package; fi - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then ./openmw_test_suite; fi - if [ "$COVERITY_SCAN_BRANCH" != 1 ] && [ "${TRAVIS_OS_NAME}" = "linux" ]; then cd .. && ./CI/check_tabs.sh; fi From 10609ca5d1d9e6abaa76978a06b830eaaa217530 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Thu, 21 Jan 2016 09:22:42 +0100 Subject: [PATCH 10/30] how much memory in our vm? --- CI/before_script.linux.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/CI/before_script.linux.sh b/CI/before_script.linux.sh index 71ddd2040..17667ad28 100755 --- a/CI/before_script.linux.sh +++ b/CI/before_script.linux.sh @@ -1,5 +1,6 @@ #!/bin/sh +free -m mkdir build cd build export CODE_COVERAGE=1 From 89512af808d78cf21e2e6553d155d1d341c4e54d Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 21 Jan 2016 14:33:26 +0100 Subject: [PATCH 11/30] Increase number of jobs for coverity scan build to 2, enable OpenMW-CS build As of the recent travis migration we should have enough memory to not run out... hopefully. --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3a76944fb..e314d8e7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,8 +20,8 @@ addons: name: "OpenMW/openmw" description: "" notification_email: scrawl@baseoftrash.de - build_command_prepend: "cmake . -DBUILD_UNITTESTS=FALSE -DBUILD_OPENCS=FALSE" - build_command: "make" + build_command_prepend: "cmake . -DBUILD_UNITTESTS=FALSE" + build_command: "make -j2" branch_pattern: coverity_scan matrix: include: From b0431833a1c8c077d2858faa62b96d9564efc3be Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 21 Jan 2016 16:08:04 +0100 Subject: [PATCH 12/30] Fix some defects reported by Coverity CI --- apps/opencs/model/doc/messages.cpp | 2 +- apps/opencs/model/doc/messages.hpp | 3 --- apps/opencs/model/doc/operationholder.cpp | 4 +++- apps/opencs/model/tools/reportmodel.cpp | 2 +- apps/opencs/model/tools/reportmodel.hpp | 2 +- apps/opencs/model/world/commands.cpp | 2 +- apps/opencs/view/render/worldspacewidget.cpp | 5 +++-- apps/opencs/view/world/table.cpp | 2 +- apps/opencs/view/world/tablebottombox.cpp | 2 +- apps/openmw/mwmechanics/mechanicsmanagerimp.cpp | 2 +- apps/openmw/mwworld/worldimp.cpp | 4 +++- 11 files changed, 16 insertions(+), 14 deletions(-) diff --git a/apps/opencs/model/doc/messages.cpp b/apps/opencs/model/doc/messages.cpp index 86e96a88d..76bbb6f22 100644 --- a/apps/opencs/model/doc/messages.cpp +++ b/apps/opencs/model/doc/messages.cpp @@ -1,6 +1,6 @@ #include "messages.hpp" -CSMDoc::Message::Message() {} +CSMDoc::Message::Message() : mSeverity(Severity_Default){} CSMDoc::Message::Message (const CSMWorld::UniversalId& id, const std::string& message, const std::string& hint, Severity severity) diff --git a/apps/opencs/model/doc/messages.hpp b/apps/opencs/model/doc/messages.hpp index 429feae4e..4041e1a67 100644 --- a/apps/opencs/model/doc/messages.hpp +++ b/apps/opencs/model/doc/messages.hpp @@ -39,9 +39,6 @@ namespace CSMDoc { public: - // \deprecated Use CSMDoc::Message directly instead. - typedef CSMDoc::Message Message; - typedef std::vector Collection; typedef Collection::const_iterator Iterator; diff --git a/apps/opencs/model/doc/operationholder.cpp b/apps/opencs/model/doc/operationholder.cpp index 5fcf24fe4..ccbed6c8b 100644 --- a/apps/opencs/model/doc/operationholder.cpp +++ b/apps/opencs/model/doc/operationholder.cpp @@ -2,7 +2,9 @@ #include "operation.hpp" -CSMDoc::OperationHolder::OperationHolder (Operation *operation) : mRunning (false) +CSMDoc::OperationHolder::OperationHolder (Operation *operation) + : mOperation(NULL) + , mRunning (false) { if (operation) setOperation (operation); diff --git a/apps/opencs/model/tools/reportmodel.cpp b/apps/opencs/model/tools/reportmodel.cpp index 77a14de84..49de1d651 100644 --- a/apps/opencs/model/tools/reportmodel.cpp +++ b/apps/opencs/model/tools/reportmodel.cpp @@ -182,7 +182,7 @@ int CSMTools::ReportModel::countErrors() const { int count = 0; - for (std::vector::const_iterator iter (mRows.begin()); + for (std::vector::const_iterator iter (mRows.begin()); iter!=mRows.end(); ++iter) if (iter->mSeverity==CSMDoc::Message::Severity_Error || iter->mSeverity==CSMDoc::Message::Severity_SeriousError) diff --git a/apps/opencs/model/tools/reportmodel.hpp b/apps/opencs/model/tools/reportmodel.hpp index 5704970f5..61b4e6307 100644 --- a/apps/opencs/model/tools/reportmodel.hpp +++ b/apps/opencs/model/tools/reportmodel.hpp @@ -16,7 +16,7 @@ namespace CSMTools { Q_OBJECT - std::vector mRows; + std::vector mRows; // Fixed columns enum Columns diff --git a/apps/opencs/model/world/commands.cpp b/apps/opencs/model/world/commands.cpp index d510cd103..097e83f7c 100644 --- a/apps/opencs/model/world/commands.cpp +++ b/apps/opencs/model/world/commands.cpp @@ -14,7 +14,7 @@ CSMWorld::ModifyCommand::ModifyCommand (QAbstractItemModel& model, const QModelIndex& index, const QVariant& new_, QUndoCommand* parent) -: QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_), mHasRecordState(false) + : QUndoCommand (parent), mModel (&model), mIndex (index), mNew (new_), mHasRecordState(false), mOldRecordState(CSMWorld::RecordBase::State_BaseOnly) { if (QAbstractProxyModel *proxy = dynamic_cast (&model)) { diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 184477d6b..af90af50c 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -33,8 +33,9 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) : SceneWidget (document.getData().getResourceSystem(), parent), mSceneElements(0), mRun(0), mDocument(document), - mInteractionMask (0), mEditMode (0), mLocked (false), mDragging (false), - mToolTipPos (-1, -1) + mInteractionMask (0), mEditMode (0), mLocked (false), mDragging (false), mDragX(0), mDragY(0), mDragFactor(0), + mDragWheelFactor(0), mDragShiftFactor(0), + mToolTipPos (-1, -1), mShowToolTips(false), mToolTipDelay(0) { setAcceptDrops(true); diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 95dfa1034..26746e8c9 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -231,7 +231,7 @@ void CSVWorld::Table::mouseDoubleClickEvent (QMouseEvent *event) CSVWorld::Table::Table (const CSMWorld::UniversalId& id, bool createAndDelete, bool sorting, CSMDoc::Document& document) : DragRecordTable(document), mCreateAction (0), - mCloneAction(0),mRecordStatusDisplay (0) + mCloneAction(0), mRecordStatusDisplay (0), mJumpToAddedRecord(false), mUnselectAfterJump(false) { mModel = &dynamic_cast (*mDocument.getData().getTableModel (id)); diff --git a/apps/opencs/view/world/tablebottombox.cpp b/apps/opencs/view/world/tablebottombox.cpp index eed522227..5a25bbc53 100644 --- a/apps/opencs/view/world/tablebottombox.cpp +++ b/apps/opencs/view/world/tablebottombox.cpp @@ -76,7 +76,7 @@ CSVWorld::TableBottomBox::TableBottomBox (const CreatorFactoryBase& creatorFacto CSMDoc::Document& document, const CSMWorld::UniversalId& id, QWidget *parent) -: QWidget (parent), mShowStatusBar (false), mEditMode(EditMode_None), mHasPosition(false) +: QWidget (parent), mShowStatusBar (false), mEditMode(EditMode_None), mHasPosition(false), mRow(0), mColumn(0) { for (int i=0; i<4; ++i) mStatusCount[i] = 0; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index b8dc90cf7..84da270eb 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -1556,7 +1556,7 @@ namespace MWMechanics (target == getPlayer() && MWBase::Environment::get().getWorld()->getGlobalInt("pcknownwerewolf"))) { - const ESM::GameSetting * iWerewolfFightMod = MWBase::Environment::get().getWorld()->getStore().get().search("iWerewolfFightMod"); + const ESM::GameSetting * iWerewolfFightMod = MWBase::Environment::get().getWorld()->getStore().get().find("iWerewolfFightMod"); fight += iWerewolfFightMod->getInt(); } } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 014c6b200..afb5be9d3 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -433,7 +433,7 @@ namespace MWWorld // Werewolf (BM) gmst["fWereWolfRunMult"] = ESM::Variant(1.f); gmst["fWereWolfSilverWeaponDamageMult"] = ESM::Variant(1.f); - + gmst["iWerewolfFightMod"] = ESM::Variant(1); std::map globals; // vanilla Morrowind does not define dayspassed. @@ -1745,6 +1745,8 @@ namespace MWWorld { cellid.mWorldspace = ref.mRef.getDestCell(); cellid.mPaged = false; + cellid.mIndex.mX = 0; + cellid.mIndex.mY = 0; } else { From ffcb6ec3819a3b3c0b66829bc2341c090254f737 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 21 Jan 2016 23:38:23 +0100 Subject: [PATCH 13/30] Change the default near clip distance to 1 (Fixes #3155) --- files/settings-default.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/settings-default.cfg b/files/settings-default.cfg index 6a2495e26..e4a8387b4 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -14,7 +14,7 @@ [Camera] # Near clipping plane (>0.0, e.g. 0.01 to 18.0). -near clip = 5.0 +near clip = 1 # Cull objects smaller than one pixel. small feature culling = true From 07a4c0bf739ced2b2975e9c6507584d6fc4afc8e Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Sat, 23 Jan 2016 01:20:31 +0100 Subject: [PATCH 14/30] version bump to 0.38 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f353cd76e..9cfb0440d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ OpenMW is a recreation of the engine for the popular role-playing game Morrowind OpenMW also comes with OpenMW-CS, a replacement for Morrowind's TES Construction Set. -* Version: 0.37.0 +* Version: 0.38.0 * License: GPL (see docs/license/GPL3.txt for more information) * Website: http://www.openmw.org * IRC: #openmw on irc.freenode.net From b93b97575eafe176d405d047040fa13b4ddd80e4 Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Sun, 24 Jan 2016 11:54:53 -0500 Subject: [PATCH 15/30] Improve start script creation (Fixes #3024) Improved start script creation by updating input to be a drop target and adding auto-completion. --- apps/opencs/view/world/startscriptcreator.cpp | 132 ++++++++++++++++-- apps/opencs/view/world/startscriptcreator.hpp | 68 ++++++++- apps/opencs/view/world/subviews.cpp | 7 +- 3 files changed, 185 insertions(+), 22 deletions(-) diff --git a/apps/opencs/view/world/startscriptcreator.cpp b/apps/opencs/view/world/startscriptcreator.cpp index 69b1b3ff1..57ac34b8f 100644 --- a/apps/opencs/view/world/startscriptcreator.cpp +++ b/apps/opencs/view/world/startscriptcreator.cpp @@ -1,20 +1,130 @@ #include "startscriptcreator.hpp" -CSVWorld::StartScriptCreator::StartScriptCreator(CSMWorld::Data &data, QUndoStack &undoStack, const CSMWorld::UniversalId &id, bool relaxedIdRules): - GenericCreator (data, undoStack, id, true) -{} +#include + +#include "../../model/doc/document.hpp" + +#include "../../model/world/columns.hpp" +#include "../../model/world/commands.hpp" +#include "../../model/world/data.hpp" +#include "../../model/world/idcompletionmanager.hpp" +#include "../../model/world/idtable.hpp" + +#include "../widget/droplineedit.hpp" + +std::string CSVWorld::StartScriptCreator::getId() const +{ + return mScript->text().toUtf8().constData(); +} + +CSMWorld::IdTable& CSVWorld::StartScriptCreator::getStartScriptsTable() const +{ + return dynamic_cast ( + *getData().getTableModel(getCollectionId()) + ); +} + +void CSVWorld::StartScriptCreator::configureCreateCommand(CSMWorld::CreateCommand& command) const +{ + CSMWorld::IdTable& table = getStartScriptsTable(); + int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_Id); + + // Set script ID to be added to start scripts table. + command.addValue(column, mScript->text()); +} + +CSVWorld::StartScriptCreator::StartScriptCreator( + CSMWorld::Data &data, + QUndoStack &undoStack, + const CSMWorld::UniversalId &id, + CSMWorld::IdCompletionManager& completionManager +) : GenericCreator(data, undoStack, id, true) +{ + setManualEditing(false); + + // Add script ID input label. + QLabel *label = new QLabel("Script ID", this); + insertBeforeButtons(label, false); + + // Add script ID input with auto-completion. + CSMWorld::ColumnBase::Display displayType = CSMWorld::ColumnBase::Display_Script; + mScript = new CSVWidget::DropLineEdit(displayType, this); + mScript->setCompleter(completionManager.getCompleter(displayType).get()); + insertBeforeButtons(mScript, true); + + connect(mScript, SIGNAL (textChanged(const QString&)), this, SLOT (scriptChanged())); +} + +void CSVWorld::StartScriptCreator::cloneMode( + const std::string& originId, + const CSMWorld::UniversalId::Type type) +{ + CSVWorld::GenericCreator::cloneMode(originId, type); + + // Look up cloned record in start scripts table and set script ID text. + CSMWorld::IdTable& table = getStartScriptsTable(); + int column = table.findColumnIndex(CSMWorld::Columns::ColumnId_Id); + mScript->setText(table.data(table.getModelIndex(originId, column)).toString()); +} std::string CSVWorld::StartScriptCreator::getErrors() const { - std::string errors; + std::string scriptId = getId(); - errors = getIdValidatorResult(); - if (errors.length() > 0) - return errors; - else if (getData().getScripts().searchId(getId()) == -1) - errors = "Script ID not found"; - else if (getData().getStartScripts().searchId(getId()) > -1 ) - errors = "Script with this ID already registered as Start Script"; + // Check user input for any errors. + std::string errors; + if (scriptId.empty()) + { + if (!errors.empty()) + { + errors += "
    "; + } + errors += "No Script ID entered"; + } + else if (getData().getScripts().searchId(scriptId) == -1) + { + if (!errors.empty()) + { + errors += "
    "; + } + errors += "Script ID not found"; + } + else if (getData().getStartScripts().searchId(scriptId) > -1) + { + if (!errors.empty()) + { + errors += "
    "; + } + errors += "Script with this ID already registered as Start Script"; + } return errors; } + +void CSVWorld::StartScriptCreator::focus() +{ + mScript->setFocus(); +} + +void CSVWorld::StartScriptCreator::reset() +{ + CSVWorld::GenericCreator::reset(); + mScript->setText(""); +} + +void CSVWorld::StartScriptCreator::scriptChanged() +{ + update(); +} + +CSVWorld::Creator *CSVWorld::StartScriptCreatorFactory::makeCreator( + CSMDoc::Document& document, + const CSMWorld::UniversalId& id) const +{ + return new StartScriptCreator( + document.getData(), + document.getUndoStack(), + id, + document.getIdCompletionManager() + ); +} diff --git a/apps/opencs/view/world/startscriptcreator.hpp b/apps/opencs/view/world/startscriptcreator.hpp index 07fe8ff3d..745dce819 100644 --- a/apps/opencs/view/world/startscriptcreator.hpp +++ b/apps/opencs/view/world/startscriptcreator.hpp @@ -3,23 +3,77 @@ #include "genericcreator.hpp" -namespace CSVWorld { +namespace CSMWorld +{ + class IdCompletionManager; + class IdTable; +} + +namespace CSVWidget +{ + class DropLineEdit; +} +namespace CSVWorld +{ + /// \brief Record creator for start scripts. class StartScriptCreator : public GenericCreator { Q_OBJECT + CSVWidget::DropLineEdit *mScript; + + private: + + /// \return script ID entered by user. + virtual std::string getId() const; + + /// \return reference to table containing start scripts. + CSMWorld::IdTable& getStartScriptsTable() const; + + /// \brief Add user input to command for creating start script. + /// \param command Creation command to configure. + virtual void configureCreateCommand(CSMWorld::CreateCommand& command) const; + public: - StartScriptCreator(CSMWorld::Data& data, QUndoStack& undoStack, - const CSMWorld::UniversalId& id, bool relaxedIdRules = false); + StartScriptCreator( + CSMWorld::Data& data, + QUndoStack& undoStack, + const CSMWorld::UniversalId& id, + CSMWorld::IdCompletionManager& completionManager); + + /// \brief Set script ID input widget to ID of record to be cloned. + /// \param originId Script 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 Formatted error descriptions for current user input. virtual std::string getErrors() const; - ///< Return formatted error descriptions for the current state of the creator. if an empty - /// string is returned, there is no error. - }; -} + /// \brief Set focus to script ID input widget. + virtual void focus(); + + /// \brief Clear script ID input widget. + virtual void reset(); + private slots: + + /// \brief Check user input for any errors. + void scriptChanged(); + }; + /// \brief Creator factory for start script record creator. + class StartScriptCreatorFactory : public CreatorFactoryBase + { + public: + + virtual Creator *makeCreator( + CSMDoc::Document& document, + const CSMWorld::UniversalId& id) const; + }; +} #endif // STARTSCRIPTCREATOR_HPP diff --git a/apps/opencs/view/world/subviews.cpp b/apps/opencs/view/world/subviews.cpp index 88375caaf..650f344ed 100644 --- a/apps/opencs/view/world/subviews.cpp +++ b/apps/opencs/view/world/subviews.cpp @@ -52,7 +52,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) new CSVDoc::SubViewFactoryWithCreator >); manager.add (CSMWorld::UniversalId::Type_StartScripts, - new CSVDoc::SubViewFactoryWithCreator >); + new CSVDoc::SubViewFactoryWithCreator); manager.add (CSMWorld::UniversalId::Type_Cells, new CSVDoc::SubViewFactoryWithCreator >); @@ -136,8 +136,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) CreatorFactory > (false)); manager.add (CSMWorld::UniversalId::Type_StartScript, - new CSVDoc::SubViewFactoryWithCreator > (false)); + new CSVDoc::SubViewFactoryWithCreator(false)); manager.add (CSMWorld::UniversalId::Type_Skill, new CSVDoc::SubViewFactoryWithCreator (false)); @@ -177,7 +176,7 @@ void CSVWorld::addSubViewFactories (CSVDoc::SubViewFactoryManager& manager) manager.add (CSMWorld::UniversalId::Type_MetaData, new CSVDoc::SubViewFactory); - + //preview manager.add (CSMWorld::UniversalId::Type_Preview, new CSVDoc::SubViewFactory); } From fbca094dda2a23860a74561dd994de8b0dab33aa Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Sun, 24 Jan 2016 20:15:27 -0500 Subject: [PATCH 16/30] Fix input validation in StartScriptCreator --- apps/opencs/view/world/startscriptcreator.cpp | 18 +++--------------- apps/opencs/view/world/startscriptcreator.hpp | 2 +- 2 files changed, 4 insertions(+), 16 deletions(-) diff --git a/apps/opencs/view/world/startscriptcreator.cpp b/apps/opencs/view/world/startscriptcreator.cpp index 57ac34b8f..7495da035 100644 --- a/apps/opencs/view/world/startscriptcreator.cpp +++ b/apps/opencs/view/world/startscriptcreator.cpp @@ -75,27 +75,15 @@ std::string CSVWorld::StartScriptCreator::getErrors() const std::string errors; if (scriptId.empty()) { - if (!errors.empty()) - { - errors += "
    "; - } - errors += "No Script ID entered"; + errors = "No Script ID entered"; } else if (getData().getScripts().searchId(scriptId) == -1) { - if (!errors.empty()) - { - errors += "
    "; - } - errors += "Script ID not found"; + errors = "Script ID not found"; } else if (getData().getStartScripts().searchId(scriptId) > -1) { - if (!errors.empty()) - { - errors += "
    "; - } - errors += "Script with this ID already registered as Start Script"; + errors = "Script with this ID already registered as Start Script"; } return errors; diff --git a/apps/opencs/view/world/startscriptcreator.hpp b/apps/opencs/view/world/startscriptcreator.hpp index 745dce819..473e2fd5f 100644 --- a/apps/opencs/view/world/startscriptcreator.hpp +++ b/apps/opencs/view/world/startscriptcreator.hpp @@ -50,7 +50,7 @@ namespace CSVWorld const std::string& originId, const CSMWorld::UniversalId::Type type); - /// \return Formatted error descriptions for current user input. + /// \return Error description for current user input. virtual std::string getErrors() const; /// \brief Set focus to script ID input widget. From 0659687bfbdf859414313aed33d9da7cef80efec Mon Sep 17 00:00:00 2001 From: Tobias Kortkamp Date: Mon, 25 Jan 2016 14:13:16 +0100 Subject: [PATCH 17/30] Some fixes for building on FreeBSD --- apps/essimporter/converter.hpp | 2 +- apps/essimporter/convertinventory.cpp | 1 + apps/openmw/crashcatcher.cpp | 2 +- apps/openmw/mwmechanics/spells.cpp | 2 +- apps/openmw/mwmechanics/spells.hpp | 2 +- apps/openmw/mwworld/projectilemanager.hpp | 1 + apps/openmw/mwworld/refdata.hpp | 1 + apps/openmw/mwworld/worldimp.cpp | 4 ++++ components/esm/spellstate.cpp | 6 +++--- components/esm/spellstate.hpp | 2 +- components/resource/bulletshape.cpp | 1 + components/sceneutil/lightcontroller.cpp | 1 + components/sceneutil/lightutil.cpp | 1 + 13 files changed, 18 insertions(+), 8 deletions(-) diff --git a/apps/essimporter/converter.hpp b/apps/essimporter/converter.hpp index f364e166c..81b2bec14 100644 --- a/apps/essimporter/converter.hpp +++ b/apps/essimporter/converter.hpp @@ -121,7 +121,7 @@ public: { mContext->mPlayer.mObject.mCreatureStats.mLevel = npc.mNpdt52.mLevel; mContext->mPlayerBase = npc; - std::map empty; + std::map empty; // FIXME: player start spells and birthsign spells aren't listed here, // need to fix openmw to account for this for (std::vector::const_iterator it = npc.mSpells.mList.begin(); it != npc.mSpells.mList.end(); ++it) diff --git a/apps/essimporter/convertinventory.cpp b/apps/essimporter/convertinventory.cpp index f476fe1ee..0799c8d11 100644 --- a/apps/essimporter/convertinventory.cpp +++ b/apps/essimporter/convertinventory.cpp @@ -1,6 +1,7 @@ #include "convertinventory.hpp" #include +#include namespace ESSImport { diff --git a/apps/openmw/crashcatcher.cpp b/apps/openmw/crashcatcher.cpp index 0b4ff6304..cafd0e08a 100644 --- a/apps/openmw/crashcatcher.cpp +++ b/apps/openmw/crashcatcher.cpp @@ -24,7 +24,7 @@ #ifndef PR_SET_PTRACER #define PR_SET_PTRACER 0x59616d61 #endif -#elif defined (__APPLE__) +#elif defined (__APPLE__) || defined (__FreeBSD__) #include #endif diff --git a/apps/openmw/mwmechanics/spells.cpp b/apps/openmw/mwmechanics/spells.cpp index a88b6b263..2f87d0446 100644 --- a/apps/openmw/mwmechanics/spells.cpp +++ b/apps/openmw/mwmechanics/spells.cpp @@ -44,7 +44,7 @@ namespace MWMechanics { if (mSpells.find (spell)==mSpells.end()) { - std::map random; + std::map random; // Determine the random magnitudes (unless this is a castable spell, in which case // they will be determined when the spell is cast) diff --git a/apps/openmw/mwmechanics/spells.hpp b/apps/openmw/mwmechanics/spells.hpp index 1b1993d5e..a46988c4c 100644 --- a/apps/openmw/mwmechanics/spells.hpp +++ b/apps/openmw/mwmechanics/spells.hpp @@ -33,7 +33,7 @@ namespace MWMechanics typedef const ESM::Spell* SpellKey; - typedef std::map > TContainer; // ID, + typedef std::map > TContainer; // ID, typedef TContainer::const_iterator TIterator; struct CorprusStats diff --git a/apps/openmw/mwworld/projectilemanager.hpp b/apps/openmw/mwworld/projectilemanager.hpp index 74d4c1dc5..02ac6cb55 100644 --- a/apps/openmw/mwworld/projectilemanager.hpp +++ b/apps/openmw/mwworld/projectilemanager.hpp @@ -3,6 +3,7 @@ #include +#include #include #include diff --git a/apps/openmw/mwworld/refdata.hpp b/apps/openmw/mwworld/refdata.hpp index 28d2dad4c..d87ffdb70 100644 --- a/apps/openmw/mwworld/refdata.hpp +++ b/apps/openmw/mwworld/refdata.hpp @@ -5,6 +5,7 @@ #include "../mwscript/locals.hpp" +#include #include namespace SceneUtil diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index afb5be9d3..37743bceb 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -108,7 +108,11 @@ namespace MWWorld } private: +#ifdef HAVE_UNORDERED_MAP + typedef std::unordered_map LoadersContainer; +#else typedef std::tr1::unordered_map LoadersContainer; +#endif LoadersContainer mLoaders; }; diff --git a/components/esm/spellstate.cpp b/components/esm/spellstate.cpp index 3ed3329b4..8845842e9 100644 --- a/components/esm/spellstate.cpp +++ b/components/esm/spellstate.cpp @@ -12,7 +12,7 @@ namespace ESM { std::string id = esm.getHString(); - std::map random; + std::map random; while (esm.isNextSub("INDX")) { int index; @@ -73,8 +73,8 @@ namespace ESM { esm.writeHNString("SPEL", it->first); - const std::map& random = it->second; - for (std::map::const_iterator rIt = random.begin(); rIt != random.end(); ++rIt) + const std::map& random = it->second; + for (std::map::const_iterator rIt = random.begin(); rIt != random.end(); ++rIt) { esm.writeHNT("INDX", rIt->first); esm.writeHNT("RAND", rIt->second); diff --git a/components/esm/spellstate.hpp b/components/esm/spellstate.hpp index 028e6a387..503c3aea9 100644 --- a/components/esm/spellstate.hpp +++ b/components/esm/spellstate.hpp @@ -28,7 +28,7 @@ namespace ESM float mMagnitude; }; - typedef std::map > TContainer; + typedef std::map > TContainer; TContainer mSpells; std::map > mPermanentSpellEffects; diff --git a/components/resource/bulletshape.cpp b/components/resource/bulletshape.cpp index 968dbe6c6..0cbc63a22 100644 --- a/components/resource/bulletshape.cpp +++ b/components/resource/bulletshape.cpp @@ -1,6 +1,7 @@ #include "bulletshape.hpp" #include +#include #include #include diff --git a/components/sceneutil/lightcontroller.cpp b/components/sceneutil/lightcontroller.cpp index e3ea93843..47575e2e6 100644 --- a/components/sceneutil/lightcontroller.cpp +++ b/components/sceneutil/lightcontroller.cpp @@ -2,6 +2,7 @@ #include +#include #include #include diff --git a/components/sceneutil/lightutil.cpp b/components/sceneutil/lightutil.cpp index 6499c54b1..979d41181 100644 --- a/components/sceneutil/lightutil.cpp +++ b/components/sceneutil/lightutil.cpp @@ -1,5 +1,6 @@ #include "lightutil.hpp" +#include #include #include #include From c1f0aa7260059007262aa1f4d21555fb1827c10b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 25 Jan 2016 14:55:02 +0100 Subject: [PATCH 18/30] added delete selection item to selection mode button menu --- apps/opencs/view/render/cell.cpp | 13 ++++++++++ apps/opencs/view/render/cell.hpp | 4 +++ .../view/render/instanceselectionmode.cpp | 26 +++++++++++++++++++ .../view/render/instanceselectionmode.hpp | 3 +++ apps/opencs/view/render/object.cpp | 5 ++++ apps/opencs/view/render/object.hpp | 2 ++ .../view/render/pagedworldspacewidget.cpp | 17 ++++++++++++ .../view/render/pagedworldspacewidget.hpp | 3 +++ .../view/render/unpagedworldspacewidget.cpp | 6 +++++ .../view/render/unpagedworldspacewidget.hpp | 3 +++ apps/opencs/view/render/worldspacewidget.hpp | 3 +++ 11 files changed, 85 insertions(+) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 40981164d..4372018fb 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -276,3 +276,16 @@ bool CSVRender::Cell::isDeleted() const { return mDeleted; } + +std::vector > CSVRender::Cell::getSelection (unsigned int elementMask) const +{ + std::vector > result; + + if (elementMask & Mask_Reference) + for (std::map::const_iterator iter (mObjects.begin()); + iter!=mObjects.end(); ++iter) + if (iter->second->getSelected()) + result.push_back (iter->second->getTag()); + + return result; +} diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 59f4cafee..3e51bb334 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -31,6 +31,8 @@ namespace CSMWorld namespace CSVRender { + class TagBase; + class Cell { CSMWorld::Data& mData; @@ -99,6 +101,8 @@ namespace CSVRender CSMWorld::CellCoordinates getCoordinates() const; bool isDeleted() const; + + std::vector > getSelection (unsigned int elementMask) const; }; } diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp index 794a150d2..754123d2d 100644 --- a/apps/opencs/view/render/instanceselectionmode.cpp +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -4,7 +4,11 @@ #include #include +#include "../../model/world/idtable.hpp" +#include "../../model/world/commands.hpp" + #include "worldspacewidget.hpp" +#include "object.hpp" bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu) { @@ -12,6 +16,7 @@ bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu) { menu->addAction (mSelectAll); menu->addAction (mDeselectAll); + menu->addAction (mDeleteSelection); } return true; @@ -44,9 +49,11 @@ CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar mSelectAll = new QAction ("Select all Instances", this); mDeselectAll = new QAction ("Clear selection", this); + mDeleteSelection = new QAction ("Delete selection", this); connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll())); connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection())); + connect (mDeleteSelection, SIGNAL (triggered ()), this, SLOT (deleteSelection())); } void CSVRender::InstanceSelectionMode::selectAll() @@ -58,3 +65,22 @@ void CSVRender::InstanceSelectionMode::clearSelection() { mWorldspaceWidget.clearSelection (Mask_Reference); } + +void CSVRender::InstanceSelectionMode::deleteSelection() +{ + std::vector > selection = + mWorldspaceWidget.getSelection (Mask_Reference); + + CSMWorld::IdTable& referencesTable = + dynamic_cast (*mWorldspaceWidget.getDocument().getData(). + getTableModel (CSMWorld::UniversalId::Type_References)); + + for (std::vector >::iterator iter (selection.begin()); + iter!=selection.end(); ++iter) + { + CSMWorld::DeleteCommand *command = new CSMWorld::DeleteCommand (referencesTable, + static_cast (iter->get())->mObject->getReferenceId()); + + mWorldspaceWidget.getDocument().getUndoStack().push (command); + } +} diff --git a/apps/opencs/view/render/instanceselectionmode.hpp b/apps/opencs/view/render/instanceselectionmode.hpp index 6b3a4e37d..07b774543 100644 --- a/apps/opencs/view/render/instanceselectionmode.hpp +++ b/apps/opencs/view/render/instanceselectionmode.hpp @@ -16,6 +16,7 @@ namespace CSVRender WorldspaceWidget& mWorldspaceWidget; QAction *mSelectAll; QAction *mDeselectAll; + QAction *mDeleteSelection; /// Add context menu items to \a menu. /// @@ -34,6 +35,8 @@ namespace CSVRender void selectAll(); void clearSelection(); + + void deleteSelection(); }; } diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 1821da059..dcf217a36 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -284,3 +284,8 @@ std::string CSVRender::Object::getReferenceableId() const { return mReferenceableId; } + +osg::ref_ptr CSVRender::Object::getTag() const +{ + return static_cast (mBaseNode->getUserData()); +} diff --git a/apps/opencs/view/render/object.hpp b/apps/opencs/view/render/object.hpp index e7638e7a9..4a89fe201 100644 --- a/apps/opencs/view/render/object.hpp +++ b/apps/opencs/view/render/object.hpp @@ -114,6 +114,8 @@ namespace CSVRender std::string getReferenceId() const; std::string getReferenceableId() const; + + osg::ref_ptr getTag() const; }; } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index ccb3efb1d..ef5c4e868 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -529,6 +529,23 @@ std::string CSVRender::PagedWorldspaceWidget::getCellId (const osg::Vec3f& point return cellCoordinates.getId (mWorldspace); } +std::vector > CSVRender::PagedWorldspaceWidget::getSelection ( + unsigned int elementMask) const +{ + std::vector > result; + + for (std::map::const_iterator iter = mCells.begin(); + iter!=mCells.end(); ++iter) + { + std::vector > cellResult = + iter->second->getSelection (elementMask); + + result.insert (result.end(), cellResult.begin(), cellResult.end()); + } + + return result; +} + CSVWidget::SceneToolToggle *CSVRender::PagedWorldspaceWidget::makeControlVisibilitySelector ( CSVWidget::SceneToolbar *parent) { diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index 3f9e605af..bd4233a64 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -103,6 +103,9 @@ namespace CSVRender virtual std::string getCellId (const osg::Vec3f& point) const; + virtual std::vector > getSelection (unsigned int elementMask) + const; + protected: virtual void addVisibilitySelectorButtons (CSVWidget::SceneToolToggle2 *tool); diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index 48180f866..a026a2473 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -119,6 +119,12 @@ std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& poi return mCellId; } +std::vector > CSVRender::UnpagedWorldspaceWidget::getSelection ( + unsigned int elementMask) const +{ + return mCell->getSelection (elementMask); +} + void CSVRender::UnpagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft, const QModelIndex& bottomRight) { diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index 8971f22a8..3aea8dee4 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -51,6 +51,9 @@ namespace CSVRender virtual std::string getCellId (const osg::Vec3f& point) const; + virtual std::vector > getSelection (unsigned int elementMask) + const; + private: virtual void referenceableDataChanged (const QModelIndex& topLeft, diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 13e66b7f0..cd031fcba 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -143,6 +143,9 @@ namespace CSVRender virtual std::string getCellId (const osg::Vec3f& point) const = 0; + virtual std::vector > getSelection (unsigned int elementMask) + const = 0; + protected: /// Visual elements in a scene From 790367b980ef6980b62abb30b61890100c7aca60 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 25 Jan 2016 16:12:20 +0100 Subject: [PATCH 19/30] fixed object removal via setting state to delete --- apps/opencs/view/render/cell.cpp | 36 ++++++++++++++++++++++---------- apps/opencs/view/render/cell.hpp | 4 ++++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 4372018fb..758498de1 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -22,11 +22,18 @@ bool CSVRender::Cell::removeObject (const std::string& id) if (iter==mObjects.end()) return false; - delete iter->second; - mObjects.erase (iter); + removeObject (iter); return true; } +std::map::iterator CSVRender::Cell::removeObject ( + std::map::iterator iter) +{ + delete iter->second; + mObjects.erase (iter++); + return iter; +} + bool CSVRender::Cell::addObjects (int start, int end) { bool modified = false; @@ -161,8 +168,8 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft, // perform update and remove where needed bool modified = false; - for (std::map::iterator iter (mObjects.begin()); - iter!=mObjects.end(); ++iter) + std::map::iterator iter = mObjects.begin(); + while (iter!=mObjects.end()) { if (iter->second->referenceDataChanged (topLeft, bottomRight)) modified = true; @@ -171,23 +178,30 @@ bool CSVRender::Cell::referenceDataChanged (const QModelIndex& topLeft, if (iter2!=ids.end()) { - if (iter2->second) + bool deleted = iter2->second; + ids.erase (iter2); + + if (deleted) { - removeObject (iter->first); + iter = removeObject (iter); modified = true; + continue; } - - ids.erase (iter2); } + + ++iter; } // add new objects for (std::map::iterator iter (ids.begin()); iter!=ids.end(); ++iter) { - mObjects.insert (std::make_pair ( - iter->first, new Object (mData, mCellNode, iter->first, false))); + if (!iter->second) + { + mObjects.insert (std::make_pair ( + iter->first, new Object (mData, mCellNode, iter->first, false))); - modified = true; + modified = true; + } } return modified; diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 3e51bb334..9f062b439 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -49,6 +49,10 @@ namespace CSVRender /// \return Was the object deleted? bool removeObject (const std::string& id); + // Remove object and return iterator to next object. + std::map::iterator removeObject ( + std::map::iterator iter); + /// Add objects from reference table that are within this cell. /// /// \return Have any objects been added? From 39e1b06101ab6947fec43470fa0225060a9cc80b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 25 Jan 2016 16:18:55 +0100 Subject: [PATCH 20/30] fixed deletion of objects that are selected (was leaving a node behind) --- apps/opencs/view/render/object.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index dcf217a36..b980b658a 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -187,6 +187,7 @@ CSVRender::Object::~Object() clear(); mParentNode->removeChild(mBaseNode); + mParentNode->removeChild(mOutline); } void CSVRender::Object::setSelected(bool selected) From b393d34ebb84f056a20aaa495c5b9509d2334837 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 25 Jan 2016 16:39:20 +0100 Subject: [PATCH 21/30] updated credits file --- AUTHORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.md b/AUTHORS.md index bfbd14a5b..83a625406 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -113,6 +113,7 @@ Programmers Stefan Galowicz (bogglez) Stanislav Bobrov (Jiub) Sylvain Thesnieres (Garvek) + t6 terrorfisch Thomas Luppi (Digmaster) Tom Mason (wheybags) From 48f53e23bfaba6ea8aa32536aeb5386e5e03a4c3 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 25 Jan 2016 16:59:31 +0100 Subject: [PATCH 22/30] Allow alternate mesh formats for marker_error --- components/resource/scenemanager.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index 1d1c5a365..e14282649 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -201,10 +201,22 @@ namespace Resource } catch (std::exception& e) { - std::cerr << "Failed to load '" << name << "': " << e.what() << ", using marker_error.nif instead" << std::endl; - Files::IStreamPtr file = mVFS->get("meshes/marker_error.nif"); - normalized = "meshes/marker_error.nif"; - loaded = load(file, normalized, mTextureManager, mNifFileManager); + static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 }; + + for (unsigned int i=0; iexists(normalized)) + { + std::cerr << "Failed to load '" << name << "': " << e.what() << ", using marker_error." << sMeshTypes[i] << " instead" << std::endl; + Files::IStreamPtr file = mVFS->get(normalized); + loaded = load(file, normalized, mTextureManager, mNifFileManager); + break; + } + } + + if (!loaded) + throw; } osgDB::Registry::instance()->getOrCreateSharedStateManager()->share(loaded.get()); From fc6fe9acfb3f70d65c97fc45d9d3b0a8b1b16236 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 25 Jan 2016 18:52:20 +0100 Subject: [PATCH 23/30] Do not crash ModVertexAlphaVisitor when there are no vertex colors --- apps/openmw/mwrender/sky.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index efe797336..692e3655a 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -374,8 +374,13 @@ public: } else if (mMeshType == 2) { - osg::Vec4Array* origColors = static_cast(geom->getColorArray()); - alpha = ((*origColors)[i].x() == 1.f) ? 1.f : 0.f; + if (geom->getColorArray()) + { + osg::Vec4Array* origColors = static_cast(geom->getColorArray()); + alpha = ((*origColors)[i].x() == 1.f) ? 1.f : 0.f; + } + else + alpha = 1.f; } (*colors)[i] = osg::Vec4f(0.f, 0.f, 0.f, alpha); From aec8c3846103da0d65ca772d859c501f2d6d9c57 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 25 Jan 2016 21:03:33 +0100 Subject: [PATCH 24/30] Move observer_ptr include where it belongs --- apps/openmw/mwrender/sky.cpp | 1 + apps/openmw/mwworld/projectilemanager.hpp | 1 - components/sceneutil/lightcontroller.cpp | 1 - components/sceneutil/lightmanager.hpp | 1 + components/sceneutil/lightutil.cpp | 1 - 5 files changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index 692e3655a..513fc74a3 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/apps/openmw/mwworld/projectilemanager.hpp b/apps/openmw/mwworld/projectilemanager.hpp index 02ac6cb55..74d4c1dc5 100644 --- a/apps/openmw/mwworld/projectilemanager.hpp +++ b/apps/openmw/mwworld/projectilemanager.hpp @@ -3,7 +3,6 @@ #include -#include #include #include diff --git a/components/sceneutil/lightcontroller.cpp b/components/sceneutil/lightcontroller.cpp index 47575e2e6..e3ea93843 100644 --- a/components/sceneutil/lightcontroller.cpp +++ b/components/sceneutil/lightcontroller.cpp @@ -2,7 +2,6 @@ #include -#include #include #include diff --git a/components/sceneutil/lightmanager.hpp b/components/sceneutil/lightmanager.hpp index 07b3b4a62..0d8610ead 100644 --- a/components/sceneutil/lightmanager.hpp +++ b/components/sceneutil/lightmanager.hpp @@ -5,6 +5,7 @@ #include #include +#include namespace SceneUtil { diff --git a/components/sceneutil/lightutil.cpp b/components/sceneutil/lightutil.cpp index 979d41181..6499c54b1 100644 --- a/components/sceneutil/lightutil.cpp +++ b/components/sceneutil/lightutil.cpp @@ -1,6 +1,5 @@ #include "lightutil.hpp" -#include #include #include #include From d9290b0ee0fa25c6655a4b054f979ea6ed186f07 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 25 Jan 2016 21:13:38 +0100 Subject: [PATCH 25/30] Array fix --- components/resource/scenemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/resource/scenemanager.cpp b/components/resource/scenemanager.cpp index e14282649..43ece41f3 100644 --- a/components/resource/scenemanager.cpp +++ b/components/resource/scenemanager.cpp @@ -201,7 +201,7 @@ namespace Resource } catch (std::exception& e) { - static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2", 0 }; + static const char * const sMeshTypes[] = { "nif", "osg", "osgt", "osgb", "osgx", "osg2" }; for (unsigned int i=0; i Date: Tue, 26 Jan 2016 10:51:47 +0100 Subject: [PATCH 26/30] minor improvements to wording of instance selection menu items --- apps/opencs/view/render/instanceselectionmode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp index 754123d2d..2fd91c8e2 100644 --- a/apps/opencs/view/render/instanceselectionmode.cpp +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -47,9 +47,9 @@ CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar "" "Not implemented yet"); - mSelectAll = new QAction ("Select all Instances", this); + mSelectAll = new QAction ("Select all instances", this); mDeselectAll = new QAction ("Clear selection", this); - mDeleteSelection = new QAction ("Delete selection", this); + mDeleteSelection = new QAction ("Delete selected instances", this); connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll())); connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection())); From 1d0ef97bf6bc566fa817e51179467a854c925365 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 26 Jan 2016 11:31:37 +0100 Subject: [PATCH 27/30] added select all of same ID item to selection mode button menu --- apps/opencs/view/render/cell.cpp | 22 +++++++++++++++++++ apps/opencs/view/render/cell.hpp | 4 ++++ .../view/render/instanceselectionmode.cpp | 9 +++++++- .../view/render/instanceselectionmode.hpp | 3 +++ .../view/render/pagedworldspacewidget.cpp | 9 ++++++++ .../view/render/pagedworldspacewidget.hpp | 6 +++++ .../view/render/unpagedworldspacewidget.cpp | 6 +++++ .../view/render/unpagedworldspacewidget.hpp | 6 +++++ apps/opencs/view/render/worldspacewidget.hpp | 6 +++++ 9 files changed, 70 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index 758498de1..bd85c8a14 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -263,6 +263,28 @@ void CSVRender::Cell::setSelection (int elementMask, Selection mode) } } +void CSVRender::Cell::selectAllWithSameParentId (int elementMask) +{ + std::set ids; + + for (std::map::const_iterator iter (mObjects.begin()); + iter!=mObjects.end(); ++iter) + { + if (iter->second->getSelected()) + ids.insert (iter->second->getReferenceableId()); + } + + for (std::map::const_iterator iter (mObjects.begin()); + iter!=mObjects.end(); ++iter) + { + if (!iter->second->getSelected() && + ids.find (iter->second->getReferenceableId())!=ids.end()) + { + iter->second->setSelected (true); + } + } +} + void CSVRender::Cell::setCellArrows (int mask) { for (int i=0; i<4; ++i) diff --git a/apps/opencs/view/render/cell.hpp b/apps/opencs/view/render/cell.hpp index 9f062b439..85b9bf21b 100644 --- a/apps/opencs/view/render/cell.hpp +++ b/apps/opencs/view/render/cell.hpp @@ -99,6 +99,10 @@ namespace CSVRender void setSelection (int elementMask, Selection mode); + // Select everything that references the same ID as at least one of the elements + // already selected + void selectAllWithSameParentId (int elementMask); + void setCellArrows (int mask); /// Returns 0, 0 in case of an unpaged cell. diff --git a/apps/opencs/view/render/instanceselectionmode.cpp b/apps/opencs/view/render/instanceselectionmode.cpp index 2fd91c8e2..5c3aaa8d1 100644 --- a/apps/opencs/view/render/instanceselectionmode.cpp +++ b/apps/opencs/view/render/instanceselectionmode.cpp @@ -16,6 +16,7 @@ bool CSVRender::InstanceSelectionMode::createContextMenu (QMenu *menu) { menu->addAction (mSelectAll); menu->addAction (mDeselectAll); + menu->addAction (mSelectSame); menu->addAction (mDeleteSelection); } @@ -50,10 +51,11 @@ CSVRender::InstanceSelectionMode::InstanceSelectionMode (CSVWidget::SceneToolbar mSelectAll = new QAction ("Select all instances", this); mDeselectAll = new QAction ("Clear selection", this); mDeleteSelection = new QAction ("Delete selected instances", this); - + mSelectSame = new QAction ("Extend selection to instances with same object ID", this); connect (mSelectAll, SIGNAL (triggered ()), this, SLOT (selectAll())); connect (mDeselectAll, SIGNAL (triggered ()), this, SLOT (clearSelection())); connect (mDeleteSelection, SIGNAL (triggered ()), this, SLOT (deleteSelection())); + connect (mSelectSame, SIGNAL (triggered ()), this, SLOT (selectSame())); } void CSVRender::InstanceSelectionMode::selectAll() @@ -84,3 +86,8 @@ void CSVRender::InstanceSelectionMode::deleteSelection() mWorldspaceWidget.getDocument().getUndoStack().push (command); } } + +void CSVRender::InstanceSelectionMode::selectSame() +{ + mWorldspaceWidget.selectAllWithSameParentId (Mask_Reference); +} diff --git a/apps/opencs/view/render/instanceselectionmode.hpp b/apps/opencs/view/render/instanceselectionmode.hpp index 07b774543..cac2ca8c2 100644 --- a/apps/opencs/view/render/instanceselectionmode.hpp +++ b/apps/opencs/view/render/instanceselectionmode.hpp @@ -17,6 +17,7 @@ namespace CSVRender QAction *mSelectAll; QAction *mDeselectAll; QAction *mDeleteSelection; + QAction *mSelectSame; /// Add context menu items to \a menu. /// @@ -37,6 +38,8 @@ namespace CSVRender void clearSelection(); void deleteSelection(); + + void selectSame(); }; } diff --git a/apps/opencs/view/render/pagedworldspacewidget.cpp b/apps/opencs/view/render/pagedworldspacewidget.cpp index ef5c4e868..d71446d0b 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.cpp +++ b/apps/opencs/view/render/pagedworldspacewidget.cpp @@ -518,6 +518,15 @@ void CSVRender::PagedWorldspaceWidget::selectAll (int elementMask) flagAsModified(); } +void CSVRender::PagedWorldspaceWidget::selectAllWithSameParentId (int elementMask) +{ + for (std::map::iterator iter = mCells.begin(); + iter!=mCells.end(); ++iter) + iter->second->selectAllWithSameParentId (elementMask); + + flagAsModified(); +} + std::string CSVRender::PagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const { const int cellSize = 8192; diff --git a/apps/opencs/view/render/pagedworldspacewidget.hpp b/apps/opencs/view/render/pagedworldspacewidget.hpp index bd4233a64..419a2a46a 100644 --- a/apps/opencs/view/render/pagedworldspacewidget.hpp +++ b/apps/opencs/view/render/pagedworldspacewidget.hpp @@ -101,6 +101,12 @@ namespace CSVRender /// \param elementMask Elements to be affected by the select operation virtual void selectAll (int elementMask); + // Select everything that references the same ID as at least one of the elements + // already selected + // + /// \param elementMask Elements to be affected by the select operation + virtual void selectAllWithSameParentId (int elementMask); + virtual std::string getCellId (const osg::Vec3f& point) const; virtual std::vector > getSelection (unsigned int elementMask) diff --git a/apps/opencs/view/render/unpagedworldspacewidget.cpp b/apps/opencs/view/render/unpagedworldspacewidget.cpp index a026a2473..8d65c3694 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.cpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.cpp @@ -114,6 +114,12 @@ void CSVRender::UnpagedWorldspaceWidget::selectAll (int elementMask) flagAsModified(); } +void CSVRender::UnpagedWorldspaceWidget::selectAllWithSameParentId (int elementMask) +{ + mCell->selectAllWithSameParentId (elementMask); + flagAsModified(); +} + std::string CSVRender::UnpagedWorldspaceWidget::getCellId (const osg::Vec3f& point) const { return mCellId; diff --git a/apps/opencs/view/render/unpagedworldspacewidget.hpp b/apps/opencs/view/render/unpagedworldspacewidget.hpp index 3aea8dee4..a4c517948 100644 --- a/apps/opencs/view/render/unpagedworldspacewidget.hpp +++ b/apps/opencs/view/render/unpagedworldspacewidget.hpp @@ -49,6 +49,12 @@ namespace CSVRender /// \param elementMask Elements to be affected by the select operation virtual void selectAll (int elementMask); + // Select everything that references the same ID as at least one of the elements + // already selected + // + /// \param elementMask Elements to be affected by the select operation + virtual void selectAllWithSameParentId (int elementMask); + virtual std::string getCellId (const osg::Vec3f& point) const; virtual std::vector > getSelection (unsigned int elementMask) diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index cd031fcba..ac6426b42 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -130,6 +130,12 @@ namespace CSVRender /// \param elementMask Elements to be affected by the select operation virtual void selectAll (int elementMask) = 0; + // Select everything that references the same ID as at least one of the elements + // already selected + // + /// \param elementMask Elements to be affected by the select operation + virtual void selectAllWithSameParentId (int elementMask) = 0; + /// Return the next intersection point with scene elements matched by /// \a interactionMask based on \a localPos and the camera vector. /// If there is no such point, instead a point "in front" of \a localPos will be From 4caf44f06156e91920d4e931a617ea8c93693245 Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Tue, 26 Jan 2016 07:48:55 -0500 Subject: [PATCH 28/30] Remove unused code in apps/opencs/view/world/table files --- apps/opencs/view/world/table.cpp | 7 ------- apps/opencs/view/world/table.hpp | 2 -- 2 files changed, 9 deletions(-) diff --git a/apps/opencs/view/world/table.cpp b/apps/opencs/view/world/table.cpp index 26746e8c9..45e50dba7 100644 --- a/apps/opencs/view/world/table.cpp +++ b/apps/opencs/view/world/table.cpp @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -12,7 +11,6 @@ #include "../../model/doc/document.hpp" -#include "../../model/world/data.hpp" #include "../../model/world/commands.hpp" #include "../../model/world/infotableproxymodel.hpp" #include "../../model/world/idtableproxymodel.hpp" @@ -20,13 +18,10 @@ #include "../../model/world/idtable.hpp" #include "../../model/world/record.hpp" #include "../../model/world/columns.hpp" -#include "../../model/world/tablemimedata.hpp" -#include "../../model/world/tablemimedata.hpp" #include "../../model/world/commanddispatcher.hpp" #include "../../model/prefs/state.hpp" -#include "recordstatusdelegate.hpp" #include "tableeditidaction.hpp" #include "util.hpp" @@ -339,8 +334,6 @@ CSVWorld::Table::Table (const CSMWorld::UniversalId& id, connect (mProxyModel, SIGNAL (rowsRemoved (const QModelIndex&, int, int)), this, SLOT (tableSizeUpdate())); - //connect (mProxyModel, SIGNAL (rowsInserted (const QModelIndex&, int, int)), - // this, SLOT (rowsInsertedEvent(const QModelIndex&, int, int))); connect (mProxyModel, SIGNAL (rowAdded (const std::string &)), this, SLOT (rowAdded (const std::string &))); diff --git a/apps/opencs/view/world/table.hpp b/apps/opencs/view/world/table.hpp index 53249f66f..768ff185d 100644 --- a/apps/opencs/view/world/table.hpp +++ b/apps/opencs/view/world/table.hpp @@ -11,7 +11,6 @@ #include "../../model/world/universalid.hpp" #include "dragrecordtable.hpp" -class QUndoStack; class QAction; namespace CSMDoc @@ -21,7 +20,6 @@ namespace CSMDoc namespace CSMWorld { - class Data; class IdTableProxyModel; class IdTableBase; class CommandDispatcher; From d43315fe4e4869fc026587a1cd468a4bf485dfde Mon Sep 17 00:00:00 2001 From: Rob Cutmore Date: Thu, 28 Jan 2016 06:28:31 -0500 Subject: [PATCH 29/30] Add script editor line wrapping (Feature #2926) Adds line wrapping for script editor and associated entry in settings window. No line wrapping remains the default. --- apps/opencs/model/prefs/state.cpp | 2 ++ apps/opencs/view/world/scriptedit.cpp | 51 +++++++++++++++++++-------- apps/opencs/view/world/scriptedit.hpp | 10 +++++- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/apps/opencs/model/prefs/state.cpp b/apps/opencs/model/prefs/state.cpp index 859fabd11..fd777b133 100644 --- a/apps/opencs/model/prefs/state.cpp +++ b/apps/opencs/model/prefs/state.cpp @@ -133,6 +133,8 @@ void CSMPrefs::State::declare() declareBool ("show-linenum", "Show Line Numbers", true). setTooltip ("Show line numbers to the left of the script editor window." "The current row and column numbers of the text cursor are shown at the bottom."); + declareBool ("wrap-lines", "Wrap Lines", false). + setTooltip ("Wrap lines longer than width of script editor."); declareBool ("mono-font", "Use monospace font", true); EnumValue warningsNormal ("Normal", "Report warnings as warning"); declareEnum ("warnings", "Warning Mode", warningsNormal). diff --git a/apps/opencs/view/world/scriptedit.cpp b/apps/opencs/view/world/scriptedit.cpp index 9f1abcf97..d0146445a 100644 --- a/apps/opencs/view/world/scriptedit.cpp +++ b/apps/opencs/view/world/scriptedit.cpp @@ -38,20 +38,20 @@ bool CSVWorld::ScriptEdit::event (QEvent *event) return QPlainTextEdit::event (event); } -CSVWorld::ScriptEdit::ScriptEdit (const CSMDoc::Document& document, ScriptHighlighter::Mode mode, - QWidget* parent) - : QPlainTextEdit (parent), - mChangeLocked (0), +CSVWorld::ScriptEdit::ScriptEdit( + const CSMDoc::Document& document, + ScriptHighlighter::Mode mode, + QWidget* parent +) : QPlainTextEdit(parent), + mChangeLocked(0), mShowLineNum(false), mLineNumberArea(0), mDefaultFont(font()), mMonoFont(QFont("Monospace")), - mDocument (document), + mDocument(document), mWhiteListQoutes("^[a-z|_]{1}[a-z|0-9|_]{0,}$", Qt::CaseInsensitive) - { -// setAcceptRichText (false); - setLineWrapMode (QPlainTextEdit::NoWrap); + wrapLines(false); setTabStopWidth (4); setUndoRedoEnabled (false); // we use OpenCS-wide undo/redo instead @@ -194,14 +194,37 @@ bool CSVWorld::ScriptEdit::stringNeedsQuote (const std::string& id) const return !(string.contains(mWhiteListQoutes)); } -void CSVWorld::ScriptEdit::settingChanged (const CSMPrefs::Setting *setting) +void CSVWorld::ScriptEdit::wrapLines(bool wrap) +{ + if (wrap) + { + setLineWrapMode(QPlainTextEdit::WidgetWidth); + } + else + { + setLineWrapMode(QPlainTextEdit::NoWrap); + } +} + +void CSVWorld::ScriptEdit::settingChanged(const CSMPrefs::Setting *setting) { - if (mHighlighter->settingChanged (setting)) + // Determine which setting was changed. + if (mHighlighter->settingChanged(setting)) + { updateHighlighting(); - else if (*setting=="Scripts/mono-font") - setFont (setting->isTrue() ? mMonoFont : mDefaultFont); - else if (*setting=="Scripts/show-linenum") - showLineNum (setting->isTrue()); + } + else if (*setting == "Scripts/mono-font") + { + setFont(setting->isTrue() ? mMonoFont : mDefaultFont); + } + else if (*setting == "Scripts/show-linenum") + { + showLineNum(setting->isTrue()); + } + else if (*setting == "Scripts/wrap-lines") + { + wrapLines(setting->isTrue()); + } } void CSVWorld::ScriptEdit::idListChanged() diff --git a/apps/opencs/view/world/scriptedit.hpp b/apps/opencs/view/world/scriptedit.hpp index 941a6295d..1f03f050a 100644 --- a/apps/opencs/view/world/scriptedit.hpp +++ b/apps/opencs/view/world/scriptedit.hpp @@ -22,6 +22,7 @@ namespace CSVWorld { class LineNumberArea; + /// \brief Editor for scripts. class ScriptEdit : public QPlainTextEdit { Q_OBJECT @@ -77,6 +78,7 @@ namespace CSVWorld virtual void resizeEvent(QResizeEvent *e); private: + QVector mAllowedTypes; const CSMDoc::Document& mDocument; const QRegExp mWhiteListQoutes; @@ -89,9 +91,15 @@ namespace CSVWorld bool stringNeedsQuote(const std::string& id) const; + /// \brief Turn line wrapping in script editor on or off. + /// \param wrap Whether or not to wrap lines. + void wrapLines(bool wrap); + private slots: - void settingChanged (const CSMPrefs::Setting *setting); + /// \brief Update editor when related setting is changed. + /// \param setting Setting that was changed. + void settingChanged(const CSMPrefs::Setting *setting); void idListChanged(); From 776c715ccd419f1e77a8445e2ddd31692efcc942 Mon Sep 17 00:00:00 2001 From: "Alexander \"Ace\" Olofsson" Date: Fri, 29 Jan 2016 17:00:18 +0100 Subject: [PATCH 30/30] Move NoTraverseCallback to mwrender/util.hpp --- apps/openmw/mwrender/renderingmanager.cpp | 10 +--------- apps/openmw/mwrender/util.hpp | 11 ++++++++++- apps/openmw/mwrender/water.cpp | 11 +---------- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 61ce626fd..c8d0925b0 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -42,6 +42,7 @@ #include "camera.hpp" #include "water.hpp" #include "terrainstorage.hpp" +#include "util.hpp" namespace MWRender { @@ -504,15 +505,6 @@ namespace MWRender mutable bool mDone; }; - - class NoTraverseCallback : public osg::NodeCallback - { - public: - virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) - { - } - }; - void RenderingManager::screenshot(osg::Image *image, int w, int h) { osg::ref_ptr rttCamera (new osg::Camera); diff --git a/apps/openmw/mwrender/util.hpp b/apps/openmw/mwrender/util.hpp index d078f0d98..815e34596 100644 --- a/apps/openmw/mwrender/util.hpp +++ b/apps/openmw/mwrender/util.hpp @@ -1,6 +1,7 @@ #ifndef OPENMW_MWRENDER_UTIL_H #define OPENMW_MWRENDER_UTIL_H +#include #include #include @@ -16,9 +17,17 @@ namespace Resource namespace MWRender { - void overrideTexture(const std::string& texture, Resource::ResourceSystem* resourceSystem, osg::ref_ptr node); + // Node callback to entirely skip the traversal. + class NoTraverseCallback : public osg::NodeCallback + { + public: + virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) + { + // no traverse() + } + }; } #endif diff --git a/apps/openmw/mwrender/water.cpp b/apps/openmw/mwrender/water.cpp index 1b19246f5..b2bef7122 100644 --- a/apps/openmw/mwrender/water.cpp +++ b/apps/openmw/mwrender/water.cpp @@ -41,6 +41,7 @@ #include "vismask.hpp" #include "ripplesimulation.hpp" #include "renderbin.hpp" +#include "util.hpp" namespace { @@ -210,16 +211,6 @@ private: osg::Plane mPlane; }; -// Node callback to entirely skip the traversal. -class NoTraverseCallback : public osg::NodeCallback -{ -public: - virtual void operator()(osg::Node* node, osg::NodeVisitor* nv) - { - // no traverse() - } -}; - /// Moves water mesh away from the camera slightly if the camera gets too close on the Z axis. /// The offset works around graphics artifacts that occured with the GL_DEPTH_CLAMP when the camera gets extremely close to the mesh (seen on NVIDIA at least). /// Must be added as a Cull callback.