From 03f67cd6bdc84da0c42f37acd73fe568a054084f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 8 Jul 2014 12:39:12 +0200 Subject: [PATCH 01/28] moved low level widgets from CSVWorld into a separate namespace/directory --- apps/opencs/CMakeLists.txt | 18 +++++++++++------- apps/opencs/view/render/scenewidget.cpp | 6 +++--- apps/opencs/view/render/scenewidget.hpp | 4 ++-- apps/opencs/view/render/worldspacewidget.cpp | 11 ++++++----- apps/opencs/view/render/worldspacewidget.hpp | 4 ++-- .../view/{world => widget}/scenetool.cpp | 4 ++-- .../view/{world => widget}/scenetool.hpp | 6 +++--- .../view/{world => widget}/scenetoolbar.cpp | 8 ++++---- .../view/{world => widget}/scenetoolbar.hpp | 6 +++--- .../view/{world => widget}/scenetoolmode.cpp | 8 ++++---- .../view/{world => widget}/scenetoolmode.hpp | 6 +++--- apps/opencs/view/world/previewsubview.cpp | 8 ++++---- apps/opencs/view/world/scenesubview.cpp | 18 ++++++++++-------- apps/opencs/view/world/scenesubview.hpp | 13 +++++++++---- 14 files changed, 66 insertions(+), 54 deletions(-) rename apps/opencs/view/{world => widget}/scenetool.cpp (77%) rename apps/opencs/view/{world => widget}/scenetool.hpp (81%) rename apps/opencs/view/{world => widget}/scenetoolbar.cpp (66%) rename apps/opencs/view/{world => widget}/scenetoolbar.hpp (83%) rename apps/opencs/view/{world => widget}/scenetoolmode.cpp (82%) rename apps/opencs/view/{world => widget}/scenetoolmode.hpp (88%) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 288e0394c..5d8d99f27 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -59,8 +59,17 @@ opencs_hdrs_noqt (view/doc opencs_units (view/world table tablesubview scriptsubview util regionmapsubview tablebottombox creator genericcreator - cellcreator referenceablecreator referencecreator scenesubview scenetoolbar scenetool - scenetoolmode infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable + cellcreator referenceablecreator referencecreator scenesubview + infocreator scriptedit dialoguesubview previewsubview regionmap dragrecordtable + ) + +opencs_units_noqt (view/world + subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate + scripthighlighter idvalidator dialoguecreator + ) + +opencs_units (view/widget + scenetoolbar scenetool scenetoolmode ) opencs_units (view/render @@ -73,11 +82,6 @@ opencs_units_noqt (view/render lightingbright object cell ) -opencs_units_noqt (view/world - subviews enumdelegate vartypedelegate recordstatusdelegate idtypedelegate datadisplaydelegate - scripthighlighter idvalidator dialoguecreator - ) - opencs_units (view/tools reportsubview diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 76f6db385..3728dd72d 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -11,7 +11,7 @@ #include #include -#include "../world/scenetoolmode.hpp" +#include "../widget/scenetoolmode.hpp" #include "navigation.hpp" #include "lighting.hpp" @@ -54,9 +54,9 @@ namespace CSVRender timer->start (20); /// \todo make this configurable } - CSVWorld::SceneToolMode *SceneWidget::makeLightingSelector (CSVWorld::SceneToolbar *parent) + CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent) { - CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent); + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); tool->addButton (":door.png", "day"); /// \todo replace icons tool->addButton (":GMST.png", "night"); diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index f6b41942f..8b01e7185 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -16,7 +16,7 @@ namespace Ogre class RenderWindow; } -namespace CSVWorld +namespace CSVWidget { class SceneToolMode; class SceneToolbar; @@ -38,7 +38,7 @@ namespace CSVRender QPaintEngine* paintEngine() const; - CSVWorld::SceneToolMode *makeLightingSelector (CSVWorld::SceneToolbar *parent); + CSVWidget::SceneToolMode *makeLightingSelector (CSVWidget::SceneToolbar *parent); ///< \attention The created tool is not added to the toolbar (via addTool). Doing that /// is the responsibility of the calling function. diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index fee2f0a16..5b3dc57e2 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -7,8 +7,9 @@ #include -#include "../world/scenetoolmode.hpp" -#include +#include "../../model/world/universalid.hpp" + +#include "../widget/scenetoolmode.hpp" CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent) : SceneWidget (parent), mDocument(document) @@ -53,10 +54,10 @@ void CSVRender::WorldspaceWidget::selectDefaultNavigationMode() setNavigation (&m1st); } -CSVWorld::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( - CSVWorld::SceneToolbar *parent) +CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( + CSVWidget::SceneToolbar *parent) { - CSVWorld::SceneToolMode *tool = new CSVWorld::SceneToolMode (parent); + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); tool->addButton (":door.png", "1st"); /// \todo replace icons tool->addButton (":GMST.png", "free"); diff --git a/apps/opencs/view/render/worldspacewidget.hpp b/apps/opencs/view/render/worldspacewidget.hpp index 2af90b0fe..3b96779a8 100644 --- a/apps/opencs/view/render/worldspacewidget.hpp +++ b/apps/opencs/view/render/worldspacewidget.hpp @@ -13,7 +13,7 @@ namespace CSMWorld { class UniversalId; } -namespace CSVWorld +namespace CSVWidget { class SceneToolMode; class SceneToolbar; @@ -49,7 +49,7 @@ namespace CSVRender WorldspaceWidget (CSMDoc::Document& document, QWidget *parent = 0); - CSVWorld::SceneToolMode *makeNavigationSelector (CSVWorld::SceneToolbar *parent); + CSVWidget::SceneToolMode *makeNavigationSelector (CSVWidget::SceneToolbar *parent); ///< \attention The created tool is not added to the toolbar (via addTool). Doing that /// is the responsibility of the calling function. diff --git a/apps/opencs/view/world/scenetool.cpp b/apps/opencs/view/widget/scenetool.cpp similarity index 77% rename from apps/opencs/view/world/scenetool.cpp rename to apps/opencs/view/widget/scenetool.cpp index 612b4c6d3..e498fdf63 100644 --- a/apps/opencs/view/world/scenetool.cpp +++ b/apps/opencs/view/widget/scenetool.cpp @@ -3,7 +3,7 @@ #include "scenetoolbar.hpp" -CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) +CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) { setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); setIconSize (QSize (parent->getIconSize(), parent->getIconSize())); @@ -12,7 +12,7 @@ CSVWorld::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) connect (this, SIGNAL (clicked()), this, SLOT (openRequest())); } -void CSVWorld::SceneTool::openRequest() +void CSVWidget::SceneTool::openRequest() { showPanel (parentWidget()->mapToGlobal (pos())); } diff --git a/apps/opencs/view/world/scenetool.hpp b/apps/opencs/view/widget/scenetool.hpp similarity index 81% rename from apps/opencs/view/world/scenetool.hpp rename to apps/opencs/view/widget/scenetool.hpp index 07e8b58d7..312d8e00c 100644 --- a/apps/opencs/view/world/scenetool.hpp +++ b/apps/opencs/view/widget/scenetool.hpp @@ -1,9 +1,9 @@ -#ifndef CSV_WORLD_SCENETOOL_H -#define CSV_WORLD_SCENETOOL_H +#ifndef CSV_WIDGET_SCENETOOL_H +#define CSV_WIDGET_SCENETOOL_H #include -namespace CSVWorld +namespace CSVWidget { class SceneToolbar; diff --git a/apps/opencs/view/world/scenetoolbar.cpp b/apps/opencs/view/widget/scenetoolbar.cpp similarity index 66% rename from apps/opencs/view/world/scenetoolbar.cpp rename to apps/opencs/view/widget/scenetoolbar.cpp index d60240da7..59a3a1d6e 100644 --- a/apps/opencs/view/world/scenetoolbar.cpp +++ b/apps/opencs/view/widget/scenetoolbar.cpp @@ -5,7 +5,7 @@ #include "scenetool.hpp" -CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) +CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) : QWidget (parent), mButtonSize (buttonSize), mIconSize (buttonSize-6) { setFixedWidth (mButtonSize); @@ -18,17 +18,17 @@ CSVWorld::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) setLayout (mLayout); } -void CSVWorld::SceneToolbar::addTool (SceneTool *tool) +void CSVWidget::SceneToolbar::addTool (SceneTool *tool) { mLayout->addWidget (tool, 0, Qt::AlignTop); } -int CSVWorld::SceneToolbar::getButtonSize() const +int CSVWidget::SceneToolbar::getButtonSize() const { return mButtonSize; } -int CSVWorld::SceneToolbar::getIconSize() const +int CSVWidget::SceneToolbar::getIconSize() const { return mIconSize; } \ No newline at end of file diff --git a/apps/opencs/view/world/scenetoolbar.hpp b/apps/opencs/view/widget/scenetoolbar.hpp similarity index 83% rename from apps/opencs/view/world/scenetoolbar.hpp rename to apps/opencs/view/widget/scenetoolbar.hpp index 731806cc5..0ef84f488 100644 --- a/apps/opencs/view/world/scenetoolbar.hpp +++ b/apps/opencs/view/widget/scenetoolbar.hpp @@ -1,11 +1,11 @@ -#ifndef CSV_WORLD_SCENETOOLBAR_H -#define CSV_WORLD_SCENETOOLBAR_H +#ifndef CSV_WIDGET_SCENETOOLBAR_H +#define CSV_WIDGET_SCENETOOLBAR_H #include class QVBoxLayout; -namespace CSVWorld +namespace CSVWidget { class SceneTool; diff --git a/apps/opencs/view/world/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp similarity index 82% rename from apps/opencs/view/world/scenetoolmode.cpp rename to apps/opencs/view/widget/scenetoolmode.cpp index 73b01ae3a..72efae0df 100644 --- a/apps/opencs/view/world/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -7,7 +7,7 @@ #include "scenetoolbar.hpp" -CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent) +CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent) : SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()) { mPanel = new QFrame (this, Qt::Popup); @@ -19,13 +19,13 @@ CSVWorld::SceneToolMode::SceneToolMode (SceneToolbar *parent) mPanel->setLayout (mLayout); } -void CSVWorld::SceneToolMode::showPanel (const QPoint& position) +void CSVWidget::SceneToolMode::showPanel (const QPoint& position) { mPanel->move (position); mPanel->show(); } -void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::string& id) +void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); @@ -42,7 +42,7 @@ void CSVWorld::SceneToolMode::addButton (const std::string& icon, const std::str setIcon (button->icon()); } -void CSVWorld::SceneToolMode::selected() +void CSVWidget::SceneToolMode::selected() { std::map::const_iterator iter = mButtons.find (dynamic_cast (sender())); diff --git a/apps/opencs/view/world/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp similarity index 88% rename from apps/opencs/view/world/scenetoolmode.hpp rename to apps/opencs/view/widget/scenetoolmode.hpp index a156c0c95..175c53f96 100644 --- a/apps/opencs/view/world/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -1,5 +1,5 @@ -#ifndef CSV_WORLD_SCENETOOL_MODE_H -#define CSV_WORLD_SCENETOOL_MODE_H +#ifndef CSV_WIDGET_SCENETOOL_MODE_H +#define CSV_WIDGET_SCENETOOL_MODE_H #include "scenetool.hpp" @@ -7,7 +7,7 @@ class QHBoxLayout; -namespace CSVWorld +namespace CSVWidget { class SceneToolbar; diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 49e6d9361..bae0abb8b 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -5,8 +5,8 @@ #include "../render/previewwidget.hpp" -#include "scenetoolbar.hpp" -#include "scenetoolmode.hpp" +#include "../widget/scenetoolbar.hpp" +#include "../widget/scenetoolmode.hpp" CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id) @@ -28,9 +28,9 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo else mScene = new CSVRender::PreviewWidget (document.getData(), id.getId(), true, this); - SceneToolbar *toolbar = new SceneToolbar (48+6, this); + CSVWidget::SceneToolbar *toolbar = new CSVWidget::SceneToolbar (48+6, this); - SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); + CSVWidget::SceneToolMode *lightingTool = mScene->makeLightingSelector (toolbar); toolbar->addTool (lightingTool); layout->addWidget (toolbar, 0); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 36cce9ecd..0ff540ec2 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -17,9 +17,11 @@ #include "../render/pagedworldspacewidget.hpp" #include "../render/unpagedworldspacewidget.hpp" +#include "../widget/scenetoolbar.hpp" +#include "../widget/scenetoolmode.hpp" + #include "tablebottombox.hpp" #include "creator.hpp" -#include "scenetoolmode.hpp" CSVWorld::SceneSubView::SceneSubView (const CSMWorld::UniversalId& id, CSMDoc::Document& document) : SubView (id), mLayout(new QHBoxLayout), mDocument(document), mScene(NULL), mToolbar(NULL) @@ -95,18 +97,18 @@ void CSVWorld::SceneSubView::makeConnections (CSVRender::PagedWorldspaceWidget* this, SLOT (cellSelectionChanged (const CSMWorld::CellSelection&))); } -CSVWorld::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type) +CSVWidget::SceneToolbar* CSVWorld::SceneSubView::makeToolbar (CSVRender::WorldspaceWidget* widget, widgetType type) { - CSVWorld::SceneToolbar* toolbar = new SceneToolbar (48+6, this); + CSVWidget::SceneToolbar* toolbar = new CSVWidget::SceneToolbar (48+6, this); - SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar); + CSVWidget::SceneToolMode *navigationTool = widget->makeNavigationSelector (toolbar); toolbar->addTool (navigationTool); - SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); + CSVWidget::SceneToolMode *lightingTool = widget->makeLightingSelector (toolbar); toolbar->addTool (lightingTool); /* Add buttons specific to the type. For now no need for it. - * + * switch (type) { case widget_Paged: @@ -188,7 +190,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI { CSVRender::PagedWorldspaceWidget* pagedNewWidget = NULL; CSVRender::UnpagedWorldspaceWidget* unPagedNewWidget = NULL; - SceneToolbar* toolbar = NULL; + CSVWidget::SceneToolbar* toolbar = NULL; switch (mScene->getDropRequirements(CSVRender::WorldspaceWidget::getDropType(data))) { @@ -217,7 +219,7 @@ void CSVWorld::SceneSubView::handleDrop (const std::vector< CSMWorld::UniversalI } } -void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWorld::SceneToolbar* toolbar) +void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar) { assert(mLayout); diff --git a/apps/opencs/view/world/scenesubview.hpp b/apps/opencs/view/world/scenesubview.hpp index b9ecbe931..b9dcdd6a3 100644 --- a/apps/opencs/view/world/scenesubview.hpp +++ b/apps/opencs/view/world/scenesubview.hpp @@ -4,7 +4,6 @@ #include #include "../doc/subview.hpp" -#include "scenetoolbar.hpp" class QModelIndex; @@ -25,6 +24,11 @@ namespace CSVRender class UnpagedWorldspaceWidget; } +namespace CSVWidget +{ + class SceneToolbar; +} + namespace CSVWorld { class Table; @@ -39,7 +43,7 @@ namespace CSVWorld CSVRender::WorldspaceWidget *mScene; QHBoxLayout* mLayout; CSMDoc::Document& mDocument; - SceneToolbar* mToolbar; + CSVWidget::SceneToolbar* mToolbar; public: @@ -59,14 +63,15 @@ namespace CSVWorld void makeConnections(CSVRender::UnpagedWorldspaceWidget* widget); - void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, SceneToolbar* toolbar); + void replaceToolbarAndWorldspace(CSVRender::WorldspaceWidget* widget, CSVWidget::SceneToolbar* toolbar); enum widgetType { widget_Paged, widget_Unpaged }; - SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type); + + CSVWidget::SceneToolbar* makeToolbar(CSVRender::WorldspaceWidget* widget, widgetType type); private slots: From 3333f67830c0a150c27662f5455b1e72402ed2aa Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 8 Jul 2014 12:53:25 +0200 Subject: [PATCH 02/28] removed a left-over marker --- apps/opencs/model/world/resourcetable.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/opencs/model/world/resourcetable.cpp b/apps/opencs/model/world/resourcetable.cpp index 167b48436..86de0a6a6 100644 --- a/apps/opencs/model/world/resourcetable.cpp +++ b/apps/opencs/model/world/resourcetable.cpp @@ -75,8 +75,6 @@ QVariant CSMWorld::ResourceTable::headerData (int section, Qt::Orientation orien break; } - // xxx - return QVariant(); } From 930f782bc590414d5cea08defd522742ac12d3a6 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 10:09:21 +0200 Subject: [PATCH 03/28] SceneWidget::setLighting was missing an update call --- apps/opencs/view/render/scenewidget.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 3728dd72d..e93bf347e 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -347,6 +347,9 @@ namespace CSVRender mLighting = lighting; mLighting->activate (mSceneMgr, mHasDefaultAmbient ? &mDefaultAmbient : 0); + + if (mWindow) + mWindow->update(); } void SceneWidget::selectLightingMode (const std::string& mode) From dd0aa20390968d5f7a3d637a0b427d872c98190d Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 11:03:55 +0200 Subject: [PATCH 04/28] custom push button --- apps/opencs/CMakeLists.txt | 2 +- apps/opencs/view/widget/pushbutton.cpp | 29 +++++++++++++++++++++++ apps/opencs/view/widget/pushbutton.hpp | 28 ++++++++++++++++++++++ apps/opencs/view/widget/scenetoolmode.cpp | 10 ++++---- apps/opencs/view/widget/scenetoolmode.hpp | 3 ++- 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 apps/opencs/view/widget/pushbutton.cpp create mode 100644 apps/opencs/view/widget/pushbutton.hpp diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 5d8d99f27..c03cc3138 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -69,7 +69,7 @@ opencs_units_noqt (view/world ) opencs_units (view/widget - scenetoolbar scenetool scenetoolmode + scenetoolbar scenetool scenetoolmode pushbutton ) opencs_units (view/render diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp new file mode 100644 index 000000000..8b4cf65e3 --- /dev/null +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -0,0 +1,29 @@ + +#include "pushbutton.hpp" + +#include +#include + +void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event) +{ + if (event->key()!=Qt::Key_Shift) + mKeepOpen = false; + + QPushButton::keyPressEvent (event); +} + +void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) +{ + mKeepOpen = event->button()==Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier); + QPushButton::mouseReleaseEvent (event); +} + +CSVWidget::PushButton::PushButton (const QIcon& icon, const QString& text, QWidget *parent) +: QPushButton (icon, text, parent), mKeepOpen (false) +{ +} + +bool CSVWidget::PushButton::hasKeepOpen() const +{ + return mKeepOpen; +} \ No newline at end of file diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp new file mode 100644 index 000000000..aa9da4885 --- /dev/null +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -0,0 +1,28 @@ +#ifndef CSV_WIDGET_PUSHBUTTON_H +#define CSV_WIDGET_PUSHBUTTON_H + +#include + +namespace CSVWidget +{ + class PushButton : public QPushButton + { + Q_OBJECT + + bool mKeepOpen; + + protected: + + virtual void keyPressEvent (QKeyEvent *event); + + virtual void mouseReleaseEvent (QMouseEvent *event); + + public: + + PushButton (const QIcon& icon, const QString& text, QWidget *parent = 0); + + bool hasKeepOpen() const; + }; +} + +#endif diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 72efae0df..87abd8140 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -6,6 +6,7 @@ #include #include "scenetoolbar.hpp" +#include "pushbutton.hpp" CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent) : SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()) @@ -27,7 +28,7 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { - QPushButton *button = new QPushButton (QIcon (QPixmap (icon.c_str())), "", mPanel); + PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), "", mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize (QSize (mIconSize, mIconSize)); button->setFixedSize (mButtonSize, mButtonSize); @@ -44,12 +45,13 @@ void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::st void CSVWidget::SceneToolMode::selected() { - std::map::const_iterator iter = - mButtons.find (dynamic_cast (sender())); + std::map::const_iterator iter = + mButtons.find (dynamic_cast (sender())); if (iter!=mButtons.end()) { - mPanel->hide(); + if (!iter->first->hasKeepOpen()) + mPanel->hide(); setIcon (iter->first->icon()); emit modeChanged (iter->second); diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp index 175c53f96..0ad5243b3 100644 --- a/apps/opencs/view/widget/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -10,6 +10,7 @@ class QHBoxLayout; namespace CSVWidget { class SceneToolbar; + class PushButton; ///< \brief Mode selector tool class SceneToolMode : public SceneTool @@ -18,7 +19,7 @@ namespace CSVWidget QWidget *mPanel; QHBoxLayout *mLayout; - std::map mButtons; // widget, id + std::map mButtons; // widget, id int mButtonSize; int mIconSize; From 50ee815dd8e777db3cdf4d32dde0a643f16ab302 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 11:23:48 +0200 Subject: [PATCH 05/28] make buttons in mode panel act like radiobuttons --- apps/opencs/view/widget/pushbutton.cpp | 1 + apps/opencs/view/widget/scenetoolmode.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 8b4cf65e3..61afa0d9d 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -21,6 +21,7 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) CSVWidget::PushButton::PushButton (const QIcon& icon, const QString& text, QWidget *parent) : QPushButton (icon, text, parent), mKeepOpen (false) { + setCheckable (true); } bool CSVWidget::PushButton::hasKeepOpen() const diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 87abd8140..5f2eecdc3 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -40,7 +40,10 @@ void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::st connect (button, SIGNAL (clicked()), this, SLOT (selected())); if (mButtons.size()==1) + { setIcon (button->icon()); + button->setChecked (true); + } } void CSVWidget::SceneToolMode::selected() @@ -53,6 +56,10 @@ void CSVWidget::SceneToolMode::selected() if (!iter->first->hasKeepOpen()) mPanel->hide(); + for (std::map::const_iterator iter2 = mButtons.begin(); + iter2!=mButtons.end(); ++iter2) + iter2->first->setChecked (iter2==iter); + setIcon (iter->first->icon()); emit modeChanged (iter->second); } From 365b7218781d3f5df48ae89709fad588d89c8dff Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 11:32:20 +0200 Subject: [PATCH 06/28] return/enter activate the selected button --- apps/opencs/view/widget/pushbutton.cpp | 11 +++++++++++ apps/opencs/view/widget/pushbutton.hpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 61afa0d9d..8b70cb6b8 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -12,6 +12,17 @@ void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event) QPushButton::keyPressEvent (event); } +void CSVWidget::PushButton::keyReleaseEvent (QKeyEvent *event) +{ + if (event->key()==Qt::Key_Return || event->key()==Qt::Key_Enter) + { + mKeepOpen = event->modifiers() & Qt::ShiftModifier; + emit clicked(); + } + + QPushButton::keyReleaseEvent (event); +} + void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) { mKeepOpen = event->button()==Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier); diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index aa9da4885..961b3ed11 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -15,6 +15,8 @@ namespace CSVWidget virtual void keyPressEvent (QKeyEvent *event); + virtual void keyReleaseEvent (QKeyEvent *event); + virtual void mouseReleaseEvent (QMouseEvent *event); public: From 8b239df1b1cd3c5817ffa5d9942610ce4e0649b8 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 11:34:09 +0200 Subject: [PATCH 07/28] removed text argument from button constructor, because toolbar buttons will always be icon only --- apps/opencs/view/widget/pushbutton.cpp | 4 ++-- apps/opencs/view/widget/pushbutton.hpp | 2 +- apps/opencs/view/widget/scenetoolmode.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 8b70cb6b8..b010a8668 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -29,8 +29,8 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) QPushButton::mouseReleaseEvent (event); } -CSVWidget::PushButton::PushButton (const QIcon& icon, const QString& text, QWidget *parent) -: QPushButton (icon, text, parent), mKeepOpen (false) +CSVWidget::PushButton::PushButton (const QIcon& icon, QWidget *parent) +: QPushButton (icon, "", parent), mKeepOpen (false) { setCheckable (true); } diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 961b3ed11..984a77d57 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -21,7 +21,7 @@ namespace CSVWidget public: - PushButton (const QIcon& icon, const QString& text, QWidget *parent = 0); + PushButton (const QIcon& icon, QWidget *parent = 0); bool hasKeepOpen() const; }; diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 5f2eecdc3..4d76215bb 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -28,7 +28,7 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { - PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), "", mPanel); + PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize (QSize (mIconSize, mIconSize)); button->setFixedSize (mButtonSize, mButtonSize); From 44b95bbd7be6c940509decb633dd0a2fad61e1e7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 11:44:01 +0200 Subject: [PATCH 08/28] added push mode and icon-less push button constructor --- apps/opencs/view/widget/pushbutton.cpp | 10 ++++++++-- apps/opencs/view/widget/pushbutton.hpp | 6 +++++- apps/opencs/view/widget/scenetoolmode.cpp | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index b010a8668..8fb90c4d0 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -29,10 +29,16 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) QPushButton::mouseReleaseEvent (event); } -CSVWidget::PushButton::PushButton (const QIcon& icon, QWidget *parent) +CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, QWidget *parent) : QPushButton (icon, "", parent), mKeepOpen (false) { - setCheckable (true); + setCheckable (!push); +} + +CSVWidget::PushButton::PushButton (bool push, QWidget *parent) +: QPushButton (parent), mKeepOpen (false) +{ + setCheckable (!push); } bool CSVWidget::PushButton::hasKeepOpen() const diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 984a77d57..7c2a2caca 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -21,7 +21,11 @@ namespace CSVWidget public: - PushButton (const QIcon& icon, QWidget *parent = 0); + /// \param push Do not maintain a toggle state + PushButton (const QIcon& icon, bool push = false, QWidget *parent = 0); + + /// \param push Do not maintain a toggle state + PushButton (bool push = false, QWidget *parent = 0); bool hasKeepOpen() const; }; diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 4d76215bb..cbf20d7dc 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -28,7 +28,7 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { - PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), mPanel); + PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), false, mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize (QSize (mIconSize, mIconSize)); button->setFixedSize (mButtonSize, mButtonSize); From d6c0b8d0ac704917160b75b27fb9c5b53ffdc849 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 11:45:45 +0200 Subject: [PATCH 09/28] use custom button on toolbar (top level) --- apps/opencs/view/widget/scenetool.cpp | 2 +- apps/opencs/view/widget/scenetool.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/widget/scenetool.cpp b/apps/opencs/view/widget/scenetool.cpp index e498fdf63..36d1f6610 100644 --- a/apps/opencs/view/widget/scenetool.cpp +++ b/apps/opencs/view/widget/scenetool.cpp @@ -3,7 +3,7 @@ #include "scenetoolbar.hpp" -CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : QPushButton (parent) +CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, parent) { setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); setIconSize (QSize (parent->getIconSize(), parent->getIconSize())); diff --git a/apps/opencs/view/widget/scenetool.hpp b/apps/opencs/view/widget/scenetool.hpp index 312d8e00c..24099683e 100644 --- a/apps/opencs/view/widget/scenetool.hpp +++ b/apps/opencs/view/widget/scenetool.hpp @@ -1,14 +1,14 @@ #ifndef CSV_WIDGET_SCENETOOL_H #define CSV_WIDGET_SCENETOOL_H -#include +#include "pushbutton.hpp" namespace CSVWidget { class SceneToolbar; ///< \brief Tool base class - class SceneTool : public QPushButton + class SceneTool : public PushButton { Q_OBJECT From 57b9b8d8848780a7e7922365ba750cd2190770d4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 12:13:27 +0200 Subject: [PATCH 10/28] set focus when opening a toolbar panel --- apps/opencs/view/widget/scenetoolmode.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index cbf20d7dc..0d8526a30 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -24,6 +24,9 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) { mPanel->move (position); mPanel->show(); + + if (!mButtons.empty()) + mButtons.begin()->first->setFocus (Qt::OtherFocusReason); } void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) From 67ad7d5b0ecd2c179c200401290cb7a1cb0d780b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 12:20:48 +0200 Subject: [PATCH 11/28] fixed scene subview focus problem --- apps/opencs/view/world/scenesubview.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 0ff540ec2..4430d28eb 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -242,4 +242,5 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mLayout->addWidget (mScene, 1); mScene->selectDefaultNavigationMode(); + setFocusProxy (mScene); } \ No newline at end of file From 32e48edb83b63c3f3c8f2308256dfa43871de202 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 12:53:57 +0200 Subject: [PATCH 12/28] toolbar tooltip system --- apps/opencs/view/widget/pushbutton.cpp | 25 +++++++++++++++++++---- apps/opencs/view/widget/pushbutton.hpp | 11 ++++++++-- apps/opencs/view/widget/scenetool.cpp | 2 +- apps/opencs/view/widget/scenetoolmode.cpp | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 8fb90c4d0..52c78ff1c 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -4,6 +4,20 @@ #include #include +void CSVWidget::PushButton::setExtendedToolTip (const std::string& text) +{ + std::string tooltip = text; + + if (tooltip.empty()) + tooltip = "(Tool tip not implemented yet)"; + + if (!mPush) + tooltip += + "

(left click to activate,
shift-left click to activate and keep panel open)"; + + setToolTip (QString::fromUtf8 (tooltip.c_str())); +} + void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event) { if (event->key()!=Qt::Key_Shift) @@ -29,16 +43,19 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) QPushButton::mouseReleaseEvent (event); } -CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, QWidget *parent) -: QPushButton (icon, "", parent), mKeepOpen (false) +CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, const std::string& tooltip, + QWidget *parent) +: QPushButton (icon, "", parent), mKeepOpen (false), mPush (push) { setCheckable (!push); + setExtendedToolTip (tooltip); } -CSVWidget::PushButton::PushButton (bool push, QWidget *parent) -: QPushButton (parent), mKeepOpen (false) +CSVWidget::PushButton::PushButton (bool push, const std::string& tooltip, QWidget *parent) +: QPushButton (parent), mKeepOpen (false), mPush (push) { setCheckable (!push); + setExtendedToolTip (tooltip); } bool CSVWidget::PushButton::hasKeepOpen() const diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 7c2a2caca..6cd4f65ab 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -10,6 +10,11 @@ namespace CSVWidget Q_OBJECT bool mKeepOpen; + bool mPush; + + private: + + void setExtendedToolTip (const std::string& text); protected: @@ -22,10 +27,12 @@ namespace CSVWidget public: /// \param push Do not maintain a toggle state - PushButton (const QIcon& icon, bool push = false, QWidget *parent = 0); + PushButton (const QIcon& icon, bool push = false, const std::string& tooltip = "", + QWidget *parent = 0); /// \param push Do not maintain a toggle state - PushButton (bool push = false, QWidget *parent = 0); + PushButton (bool push = false, const std::string& tooltip = "", + QWidget *parent = 0); bool hasKeepOpen() const; }; diff --git a/apps/opencs/view/widget/scenetool.cpp b/apps/opencs/view/widget/scenetool.cpp index 36d1f6610..d247096b0 100644 --- a/apps/opencs/view/widget/scenetool.cpp +++ b/apps/opencs/view/widget/scenetool.cpp @@ -3,7 +3,7 @@ #include "scenetoolbar.hpp" -CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, parent) +CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, "", parent) { setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); setIconSize (QSize (parent->getIconSize(), parent->getIconSize())); diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 0d8526a30..152a7c0ce 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -31,7 +31,7 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { - PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), false, mPanel); + PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), false, "", mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize (QSize (mIconSize, mIconSize)); button->setFixedSize (mButtonSize, mButtonSize); From 61a02d8a40385840d1277d14ec08c61d4d621bda Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 13:04:30 +0200 Subject: [PATCH 13/28] replaced custom toolbutton push flag with type enum --- apps/opencs/view/widget/pushbutton.cpp | 32 ++++++++++++++++------- apps/opencs/view/widget/pushbutton.hpp | 16 +++++++++--- apps/opencs/view/widget/scenetool.cpp | 3 ++- apps/opencs/view/widget/scenetoolmode.cpp | 3 ++- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 52c78ff1c..35bed1627 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -11,9 +11,23 @@ void CSVWidget::PushButton::setExtendedToolTip (const std::string& text) if (tooltip.empty()) tooltip = "(Tool tip not implemented yet)"; - if (!mPush) - tooltip += - "

(left click to activate,
shift-left click to activate and keep panel open)"; + switch (mType) + { + case Type_TopMode: + + tooltip += + "

(left click to change mode)"; + + break; + + case Type_Mode: + + tooltip += + "

(left click to activate," + "
shift-left click to activate and keep panel open)"; + + break; + } setToolTip (QString::fromUtf8 (tooltip.c_str())); } @@ -43,18 +57,18 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) QPushButton::mouseReleaseEvent (event); } -CSVWidget::PushButton::PushButton (const QIcon& icon, bool push, const std::string& tooltip, +CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const std::string& tooltip, QWidget *parent) -: QPushButton (icon, "", parent), mKeepOpen (false), mPush (push) +: QPushButton (icon, "", parent), mKeepOpen (false), mType (type) { - setCheckable (!push); + setCheckable (type==Type_Mode); setExtendedToolTip (tooltip); } -CSVWidget::PushButton::PushButton (bool push, const std::string& tooltip, QWidget *parent) -: QPushButton (parent), mKeepOpen (false), mPush (push) +CSVWidget::PushButton::PushButton (Type type, const std::string& tooltip, QWidget *parent) +: QPushButton (parent), mKeepOpen (false), mType (type) { - setCheckable (!push); + setCheckable (type==Type_Mode); setExtendedToolTip (tooltip); } diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 6cd4f65ab..099cba358 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -9,8 +9,18 @@ namespace CSVWidget { Q_OBJECT + public: + + enum Type + { + Type_TopMode, // top level button for mode selector panel + Type_Mode // mode button + }; + + private: + bool mKeepOpen; - bool mPush; + Type mType; private: @@ -27,11 +37,11 @@ namespace CSVWidget public: /// \param push Do not maintain a toggle state - PushButton (const QIcon& icon, bool push = false, const std::string& tooltip = "", + PushButton (const QIcon& icon, Type type, const std::string& tooltip = "", QWidget *parent = 0); /// \param push Do not maintain a toggle state - PushButton (bool push = false, const std::string& tooltip = "", + PushButton (Type type, const std::string& tooltip = "", QWidget *parent = 0); bool hasKeepOpen() const; diff --git a/apps/opencs/view/widget/scenetool.cpp b/apps/opencs/view/widget/scenetool.cpp index d247096b0..e3f2dfd1c 100644 --- a/apps/opencs/view/widget/scenetool.cpp +++ b/apps/opencs/view/widget/scenetool.cpp @@ -3,7 +3,8 @@ #include "scenetoolbar.hpp" -CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) : PushButton (true, "", parent) +CSVWidget::SceneTool::SceneTool (SceneToolbar *parent) +: PushButton (PushButton::Type_TopMode, "", parent) { setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); setIconSize (QSize (parent->getIconSize(), parent->getIconSize())); diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 152a7c0ce..629cf9415 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -31,7 +31,8 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) { - PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), false, "", mPanel); + PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), PushButton::Type_Mode, + "", mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize (QSize (mIconSize, mIconSize)); button->setFixedSize (mButtonSize, mButtonSize); From 490442cf6214b7ef8c66453638f7b27cae7a1e83 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Thu, 10 Jul 2014 13:18:24 +0200 Subject: [PATCH 14/28] added lighting mode tooltips --- apps/opencs/view/render/scenewidget.cpp | 20 +++++++++++++++++--- apps/opencs/view/widget/scenetoolmode.cpp | 5 +++-- apps/opencs/view/widget/scenetoolmode.hpp | 3 ++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index e93bf347e..8f6b74765 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -58,9 +58,23 @@ namespace CSVRender { CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); - tool->addButton (":door.png", "day"); /// \todo replace icons - tool->addButton (":GMST.png", "night"); - tool->addButton (":Info.png", "bright"); + /// \todo replace icons + tool->addButton (":door.png", "day", + "Day" + "

  • Cell specific ambient in interiors
  • " + "
  • Low ambient in exteriors
  • " + "
  • Strong directional light source/lir>" + "
  • This mode closely resembles day time in-game
"); + tool->addButton (":GMST.png", "night", + "Night" + "
  • Cell specific ambient in interiors
  • " + "
  • Low ambient in exteriors
  • " + "
  • Weak directional light source
  • " + "
  • This mode closely resembles night time in-game
"); + tool->addButton (":Info.png", "bright", + "Bright" + "
  • Maximum ambient
  • " + "
  • Strong directional light source
"); connect (tool, SIGNAL (modeChanged (const std::string&)), this, SLOT (selectLightingMode (const std::string&))); diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 629cf9415..412959c7c 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -29,10 +29,11 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) mButtons.begin()->first->setFocus (Qt::OtherFocusReason); } -void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id) +void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id, + const std::string& tooltip) { PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), PushButton::Type_Mode, - "", mPanel); + tooltip, mPanel); button->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); button->setIconSize (QSize (mIconSize, mIconSize)); button->setFixedSize (mButtonSize, mButtonSize); diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp index 0ad5243b3..5f18f712f 100644 --- a/apps/opencs/view/widget/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -29,7 +29,8 @@ namespace CSVWidget virtual void showPanel (const QPoint& position); - void addButton (const std::string& icon, const std::string& id); + void addButton (const std::string& icon, const std::string& id, + const std::string& tooltip = ""); signals: From d0e1210dd7be3db928cbebae2b8511af460ef199 Mon Sep 17 00:00:00 2001 From: slothlife Date: Sun, 13 Jul 2014 01:39:42 -0500 Subject: [PATCH 15/28] Fix for Bullet debug assert After changing the vector comparison to squaredDistance, the threshold for rejecting similar vectors needed to be readjusted. --- apps/openmw/mwworld/physicssystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index 201393761..daad5b0e6 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -364,7 +364,7 @@ namespace MWWorld continue; // velocity updated, calculate nextpos again } - if(newPosition.squaredDistance(nextpos) > 0.00000001*0.00000001) + if(newPosition.squaredDistance(nextpos) > 0.0001) { // trace to where character would go if there were no obstructions tracer.doTrace(colobj, newPosition, nextpos, engine); From e855e5531837e410bb347c88d9f11b9142b69fe4 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 13 Jul 2014 10:52:33 +0200 Subject: [PATCH 16/28] added tooltip to user settings button on startup window --- apps/opencs/view/doc/startup.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/opencs/view/doc/startup.cpp b/apps/opencs/view/doc/startup.cpp index 5d59492c6..799a07e14 100644 --- a/apps/opencs/view/doc/startup.cpp +++ b/apps/opencs/view/doc/startup.cpp @@ -81,6 +81,7 @@ QWidget *CSVDoc::StartupDialogue::createTools() config->setSizePolicy (QSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed)); config->setIcon (QIcon (":startup/configure")); + config->setToolTip ("Open user settings"); layout->addWidget (config); From 26f87f5d235630d122270998ea79ef32ba33854b Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 13 Jul 2014 12:15:05 +0200 Subject: [PATCH 17/28] added navigation mode button tooltips --- apps/opencs/view/render/worldspacewidget.cpp | 31 ++++++++++++++++++-- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 5b3dc57e2..33f27c8ba 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -59,9 +59,34 @@ CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( { CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); - tool->addButton (":door.png", "1st"); /// \todo replace icons - tool->addButton (":GMST.png", "free"); - tool->addButton (":Info.png", "orbit"); + /// \todo replace icons + /// \todo consider user-defined button-mapping + tool->addButton (":door.png", "1st", + "First Person" + "
  • Mouse-Look while holding the left button
  • " + "
  • WASD movement keys
  • " + "
  • Mouse wheel moves the camera forawrd/backward
  • " + "
  • Stafing (also vertically) by holding the left mouse button and control
  • " + "
  • Camera is held upright
  • " + "
  • Hold shift to speed up movement
  • " + "
"); + tool->addButton (":GMST.png", "free", + "Free Camera" + "
  • Mouse-Look while holding the left button
  • " + "
  • Stafing (also vertically) via WASD or by holding the left mouse button and control
  • " + "
  • Mouse wheel moves the camera forawrd/backward
  • " + "
  • Roll camera with Q and E keys
  • " + "
  • Hold shift to speed up movement
  • " + "
"); + tool->addButton (":Info.png", "orbit", + "Orbiting Camera" + "
  • Always facing the centre point
  • " + "
  • Rotate around the centre point via WASD or by moving the mouse while holding the left button
  • " + "
  • Mouse wheel moves camera away or towards centre point but can not pass through it
  • " + "
  • Roll camera with Q and E keys
  • " + "
  • Stafing (also vertically) by holding the left mouse button and control (includes relocation of the centre point)
  • " + "
  • Hold shift to speed up movement
  • " + "
"); connect (tool, SIGNAL (modeChanged (const std::string&)), this, SLOT (selectNavigationMode (const std::string&))); From c2ea8f3f0a6483a55a8234c59c1377303528c38f Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Sun, 13 Jul 2014 14:21:50 +0200 Subject: [PATCH 18/28] added self-adjusting tooltips to the top-level toolbar buttons --- apps/opencs/view/render/scenewidget.cpp | 2 +- apps/opencs/view/render/worldspacewidget.cpp | 2 +- apps/opencs/view/widget/pushbutton.cpp | 21 ++++++++++++-------- apps/opencs/view/widget/pushbutton.hpp | 10 +++++++--- apps/opencs/view/widget/scenetoolmode.cpp | 20 ++++++++++++++++--- apps/opencs/view/widget/scenetoolmode.hpp | 7 +++++-- 6 files changed, 44 insertions(+), 18 deletions(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 8f6b74765..5cad25b25 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -56,7 +56,7 @@ namespace CSVRender CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent) { - CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Lighting Mode"); /// \todo replace icons tool->addButton (":door.png", "day", diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 33f27c8ba..d3413a29d 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -57,7 +57,7 @@ void CSVRender::WorldspaceWidget::selectDefaultNavigationMode() CSVWidget::SceneToolMode *CSVRender::WorldspaceWidget::makeNavigationSelector ( CSVWidget::SceneToolbar *parent) { - CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent); + CSVWidget::SceneToolMode *tool = new CSVWidget::SceneToolMode (parent, "Camera Mode"); /// \todo replace icons /// \todo consider user-defined button-mapping diff --git a/apps/opencs/view/widget/pushbutton.cpp b/apps/opencs/view/widget/pushbutton.cpp index 35bed1627..056e548fb 100644 --- a/apps/opencs/view/widget/pushbutton.cpp +++ b/apps/opencs/view/widget/pushbutton.cpp @@ -4,11 +4,11 @@ #include #include -void CSVWidget::PushButton::setExtendedToolTip (const std::string& text) +void CSVWidget::PushButton::setExtendedToolTip (const QString& text) { - std::string tooltip = text; + QString tooltip = text; - if (tooltip.empty()) + if (tooltip.isEmpty()) tooltip = "(Tool tip not implemented yet)"; switch (mType) @@ -29,7 +29,7 @@ void CSVWidget::PushButton::setExtendedToolTip (const std::string& text) break; } - setToolTip (QString::fromUtf8 (tooltip.c_str())); + setToolTip (tooltip); } void CSVWidget::PushButton::keyPressEvent (QKeyEvent *event) @@ -57,16 +57,16 @@ void CSVWidget::PushButton::mouseReleaseEvent (QMouseEvent *event) QPushButton::mouseReleaseEvent (event); } -CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const std::string& tooltip, +CSVWidget::PushButton::PushButton (const QIcon& icon, Type type, const QString& tooltip, QWidget *parent) -: QPushButton (icon, "", parent), mKeepOpen (false), mType (type) +: QPushButton (icon, "", parent), mKeepOpen (false), mType (type), mToolTip (tooltip) { setCheckable (type==Type_Mode); setExtendedToolTip (tooltip); } -CSVWidget::PushButton::PushButton (Type type, const std::string& tooltip, QWidget *parent) -: QPushButton (parent), mKeepOpen (false), mType (type) +CSVWidget::PushButton::PushButton (Type type, const QString& tooltip, QWidget *parent) +: QPushButton (parent), mKeepOpen (false), mType (type), mToolTip (tooltip) { setCheckable (type==Type_Mode); setExtendedToolTip (tooltip); @@ -75,4 +75,9 @@ CSVWidget::PushButton::PushButton (Type type, const std::string& tooltip, QWidge bool CSVWidget::PushButton::hasKeepOpen() const { return mKeepOpen; +} + +QString CSVWidget::PushButton::getBaseToolTip() const +{ + return mToolTip; } \ No newline at end of file diff --git a/apps/opencs/view/widget/pushbutton.hpp b/apps/opencs/view/widget/pushbutton.hpp index 099cba358..9b90bd0c6 100644 --- a/apps/opencs/view/widget/pushbutton.hpp +++ b/apps/opencs/view/widget/pushbutton.hpp @@ -21,10 +21,11 @@ namespace CSVWidget bool mKeepOpen; Type mType; + QString mToolTip; private: - void setExtendedToolTip (const std::string& text); + void setExtendedToolTip (const QString& text); protected: @@ -37,14 +38,17 @@ namespace CSVWidget public: /// \param push Do not maintain a toggle state - PushButton (const QIcon& icon, Type type, const std::string& tooltip = "", + PushButton (const QIcon& icon, Type type, const QString& tooltip = "", QWidget *parent = 0); /// \param push Do not maintain a toggle state - PushButton (Type type, const std::string& tooltip = "", + PushButton (Type type, const QString& tooltip = "", QWidget *parent = 0); bool hasKeepOpen() const; + + /// Return tooltip used at construction (without any button-specific modifications) + QString getBaseToolTip() const; }; } diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 412959c7c..9a97924a8 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -8,8 +8,20 @@ #include "scenetoolbar.hpp" #include "pushbutton.hpp" -CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent) -: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()) +void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode) +{ + QString toolTip = mToolTip; + + toolTip += "

Currently selected: " + activeMode->getBaseToolTip(); + + toolTip += "

(left click to change mode)"; + + setToolTip (toolTip); +} + +CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip) +: SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()), + mToolTip (toolTip) { mPanel = new QFrame (this, Qt::Popup); @@ -30,7 +42,7 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) } void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id, - const std::string& tooltip) + const QString& tooltip) { PushButton *button = new PushButton (QIcon (QPixmap (icon.c_str())), PushButton::Type_Mode, tooltip, mPanel); @@ -48,6 +60,7 @@ void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::st { setIcon (button->icon()); button->setChecked (true); + adjustToolTip (button); } } @@ -66,6 +79,7 @@ void CSVWidget::SceneToolMode::selected() iter2->first->setChecked (iter2==iter); setIcon (iter->first->icon()); + adjustToolTip (iter->first); emit modeChanged (iter->second); } } \ No newline at end of file diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp index 5f18f712f..92f031fe7 100644 --- a/apps/opencs/view/widget/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -22,15 +22,18 @@ namespace CSVWidget std::map mButtons; // widget, id int mButtonSize; int mIconSize; + QString mToolTip; + + void adjustToolTip (const PushButton *activeMode); public: - SceneToolMode (SceneToolbar *parent); + SceneToolMode (SceneToolbar *parent, const QString& toolTip); virtual void showPanel (const QPoint& position); void addButton (const std::string& icon, const std::string& id, - const std::string& tooltip = ""); + const QString& tooltip = ""); signals: From 688d413b8c3b21c5d3d7d4ba09ccfb265dae071e Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 14 Jul 2014 11:06:12 +0200 Subject: [PATCH 19/28] when scene toolbar gains focus, focus first button --- apps/opencs/view/widget/scenetoolbar.cpp | 8 ++++++++ apps/opencs/view/widget/scenetoolbar.hpp | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/apps/opencs/view/widget/scenetoolbar.cpp b/apps/opencs/view/widget/scenetoolbar.cpp index 59a3a1d6e..f06c856cb 100644 --- a/apps/opencs/view/widget/scenetoolbar.cpp +++ b/apps/opencs/view/widget/scenetoolbar.cpp @@ -5,6 +5,14 @@ #include "scenetool.hpp" +void CSVWidget::SceneToolbar::focusInEvent (QFocusEvent *event) +{ + QWidget::focusInEvent (event); + + if (mLayout->count()) + dynamic_cast (*mLayout->itemAt (0)).widget()->setFocus(); +} + CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) : QWidget (parent), mButtonSize (buttonSize), mIconSize (buttonSize-6) { diff --git a/apps/opencs/view/widget/scenetoolbar.hpp b/apps/opencs/view/widget/scenetoolbar.hpp index 0ef84f488..bd609078d 100644 --- a/apps/opencs/view/widget/scenetoolbar.hpp +++ b/apps/opencs/view/widget/scenetoolbar.hpp @@ -17,6 +17,10 @@ namespace CSVWidget int mButtonSize; int mIconSize; + protected: + + virtual void focusInEvent (QFocusEvent *event); + public: SceneToolbar (int buttonSize, QWidget *parent = 0); From 92af0938567b2acd70a9a20bdc089c4b59b9d2e7 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 14 Jul 2014 11:19:59 +0200 Subject: [PATCH 20/28] new keyboard shortcut (T): move focus from scene widget to toolbar --- apps/opencs/view/render/scenewidget.cpp | 7 ++++++- apps/opencs/view/render/scenewidget.hpp | 4 ++++ apps/opencs/view/world/previewsubview.cpp | 1 + apps/opencs/view/world/scenesubview.cpp | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index 5cad25b25..a37d1071a 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,11 @@ namespace CSVRender QTimer *timer = new QTimer (this); connect (timer, SIGNAL (timeout()), this, SLOT (update())); - timer->start (20); /// \todo make this configurable + timer->start (20); ///< \todo make this configurable + + /// \todo make shortcut configurable + QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this); + connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest())); } CSVWidget::SceneToolMode *SceneWidget::makeLightingSelector (CSVWidget::SceneToolbar *parent) diff --git a/apps/opencs/view/render/scenewidget.hpp b/apps/opencs/view/render/scenewidget.hpp index 8b01e7185..8f548f483 100644 --- a/apps/opencs/view/render/scenewidget.hpp +++ b/apps/opencs/view/render/scenewidget.hpp @@ -111,6 +111,10 @@ namespace CSVRender void update(); void selectLightingMode (const std::string& mode); + + signals: + + void focusToolbarRequest(); }; } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index bae0abb8b..599e9cb9d 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -46,6 +46,7 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo connect (mScene, SIGNAL (closeRequest()), this, SLOT (closeRequest())); connect (mScene, SIGNAL (referenceableIdChanged (const std::string&)), this, SLOT (referenceableIdChanged (const std::string&))); + connect (mScene, SIGNAL (focusToolbarRequest()), toolbar, SLOT (setFocus())); } void CSVWorld::PreviewSubView::setEditLock (bool locked) {} diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 4430d28eb..60988e1bb 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -238,6 +238,8 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mScene = widget; mToolbar = toolbar; + connect (mScene, SIGNAL (focusToolbarRequest()), mToolbar, SLOT (setFocus())); + mLayout->addWidget (mToolbar, 0); mLayout->addWidget (mScene, 1); From 17fc570e38b669bc17540d9255de77334f9de9eb Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 14 Jul 2014 13:49:55 +0200 Subject: [PATCH 21/28] new keyboard shortcut (T): move focus from toolbar to scene widget --- apps/opencs/view/render/scenewidget.cpp | 2 +- apps/opencs/view/widget/scenetoolbar.cpp | 7 ++++++- apps/opencs/view/widget/scenetoolbar.hpp | 4 ++++ apps/opencs/view/world/previewsubview.cpp | 1 + apps/opencs/view/world/scenesubview.cpp | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/render/scenewidget.cpp b/apps/opencs/view/render/scenewidget.cpp index a37d1071a..ebd3eb764 100644 --- a/apps/opencs/view/render/scenewidget.cpp +++ b/apps/opencs/view/render/scenewidget.cpp @@ -55,7 +55,7 @@ namespace CSVRender timer->start (20); ///< \todo make this configurable /// \todo make shortcut configurable - QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this); + QShortcut *focusToolbar = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut); connect (focusToolbar, SIGNAL (activated()), this, SIGNAL (focusToolbarRequest())); } diff --git a/apps/opencs/view/widget/scenetoolbar.cpp b/apps/opencs/view/widget/scenetoolbar.cpp index f06c856cb..eac9bcec3 100644 --- a/apps/opencs/view/widget/scenetoolbar.cpp +++ b/apps/opencs/view/widget/scenetoolbar.cpp @@ -2,6 +2,7 @@ #include "scenetoolbar.hpp" #include +#include #include "scenetool.hpp" @@ -24,6 +25,10 @@ CSVWidget::SceneToolbar::SceneToolbar (int buttonSize, QWidget *parent) mLayout->setContentsMargins (QMargins (0, 0, 0, 0)); setLayout (mLayout); + + /// \todo make shortcut configurable + QShortcut *focusScene = new QShortcut (Qt::Key_T, this, 0, 0, Qt::WidgetWithChildrenShortcut); + connect (focusScene, SIGNAL (activated()), this, SIGNAL (focusSceneRequest())); } void CSVWidget::SceneToolbar::addTool (SceneTool *tool) @@ -39,4 +44,4 @@ int CSVWidget::SceneToolbar::getButtonSize() const int CSVWidget::SceneToolbar::getIconSize() const { return mIconSize; -} \ No newline at end of file +} diff --git a/apps/opencs/view/widget/scenetoolbar.hpp b/apps/opencs/view/widget/scenetoolbar.hpp index bd609078d..1902ba2be 100644 --- a/apps/opencs/view/widget/scenetoolbar.hpp +++ b/apps/opencs/view/widget/scenetoolbar.hpp @@ -30,6 +30,10 @@ namespace CSVWidget int getButtonSize() const; int getIconSize() const; + + signals: + + void focusSceneRequest(); }; } diff --git a/apps/opencs/view/world/previewsubview.cpp b/apps/opencs/view/world/previewsubview.cpp index 599e9cb9d..1e106c69f 100644 --- a/apps/opencs/view/world/previewsubview.cpp +++ b/apps/opencs/view/world/previewsubview.cpp @@ -47,6 +47,7 @@ CSVWorld::PreviewSubView::PreviewSubView (const CSMWorld::UniversalId& id, CSMDo connect (mScene, SIGNAL (referenceableIdChanged (const std::string&)), this, SLOT (referenceableIdChanged (const std::string&))); connect (mScene, SIGNAL (focusToolbarRequest()), toolbar, SLOT (setFocus())); + connect (toolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus())); } void CSVWorld::PreviewSubView::setEditLock (bool locked) {} diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index 60988e1bb..dc1525b05 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -239,6 +239,7 @@ void CSVWorld::SceneSubView::replaceToolbarAndWorldspace (CSVRender::WorldspaceW mToolbar = toolbar; connect (mScene, SIGNAL (focusToolbarRequest()), mToolbar, SLOT (setFocus())); + connect (mToolbar, SIGNAL (focusSceneRequest()), mScene, SLOT (setFocus())); mLayout->addWidget (mToolbar, 0); mLayout->addWidget (mScene, 1); From 0430558c3cac7b1805d017e6c466aca5db98aab9 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Mon, 14 Jul 2014 14:17:27 +0200 Subject: [PATCH 22/28] fixed focussed button in mode tool panel when panel is opened --- apps/opencs/view/widget/scenetoolmode.cpp | 7 ++++--- apps/opencs/view/widget/scenetoolmode.hpp | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/opencs/view/widget/scenetoolmode.cpp b/apps/opencs/view/widget/scenetoolmode.cpp index 9a97924a8..caedfa3ee 100644 --- a/apps/opencs/view/widget/scenetoolmode.cpp +++ b/apps/opencs/view/widget/scenetoolmode.cpp @@ -21,7 +21,7 @@ void CSVWidget::SceneToolMode::adjustToolTip (const PushButton *activeMode) CSVWidget::SceneToolMode::SceneToolMode (SceneToolbar *parent, const QString& toolTip) : SceneTool (parent), mButtonSize (parent->getButtonSize()), mIconSize (parent->getIconSize()), - mToolTip (toolTip) + mToolTip (toolTip), mFirst (0) { mPanel = new QFrame (this, Qt::Popup); @@ -37,8 +37,8 @@ void CSVWidget::SceneToolMode::showPanel (const QPoint& position) mPanel->move (position); mPanel->show(); - if (!mButtons.empty()) - mButtons.begin()->first->setFocus (Qt::OtherFocusReason); + if (mFirst) + mFirst->setFocus (Qt::OtherFocusReason); } void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::string& id, @@ -58,6 +58,7 @@ void CSVWidget::SceneToolMode::addButton (const std::string& icon, const std::st if (mButtons.size()==1) { + mFirst = button; setIcon (button->icon()); button->setChecked (true); adjustToolTip (button); diff --git a/apps/opencs/view/widget/scenetoolmode.hpp b/apps/opencs/view/widget/scenetoolmode.hpp index 92f031fe7..9959f9835 100644 --- a/apps/opencs/view/widget/scenetoolmode.hpp +++ b/apps/opencs/view/widget/scenetoolmode.hpp @@ -23,6 +23,7 @@ namespace CSVWidget int mButtonSize; int mIconSize; QString mToolTip; + PushButton *mFirst; void adjustToolTip (const PushButton *activeMode); From 1a1f5dfc4a1ada1ebc842075129b7bef8f169c51 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Tue, 15 Jul 2014 12:46:52 +0200 Subject: [PATCH 23/28] added tooltips to dialgoue subview buttons --- apps/opencs/view/world/dialoguesubview.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/apps/opencs/view/world/dialoguesubview.cpp b/apps/opencs/view/world/dialoguesubview.cpp index ad2db8723..bcf108934 100644 --- a/apps/opencs/view/world/dialoguesubview.cpp +++ b/apps/opencs/view/world/dialoguesubview.cpp @@ -426,25 +426,32 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM QHBoxLayout *buttonsLayout = new QHBoxLayout; QToolButton* prevButton = new QToolButton(mainWidget); prevButton->setIcon(QIcon(":/go-previous.png")); + prevButton->setToolTip ("Switch to previous record"); QToolButton* nextButton = new QToolButton(mainWidget); nextButton->setIcon(QIcon(":/go-next.png")); + nextButton->setToolTip ("Switch to next record"); buttonsLayout->addWidget(prevButton, 0); buttonsLayout->addWidget(nextButton, 1); buttonsLayout->addStretch(2); QToolButton* cloneButton = new QToolButton(mainWidget); cloneButton->setIcon(QIcon(":/edit-clone.png")); + cloneButton->setToolTip ("Clone record"); QToolButton* addButton = new QToolButton(mainWidget); addButton->setIcon(QIcon(":/add.png")); + addButton->setToolTip ("Add new record"); QToolButton* deleteButton = new QToolButton(mainWidget); deleteButton->setIcon(QIcon(":/edit-delete.png")); + deleteButton->setToolTip ("Delete record"); QToolButton* revertButton = new QToolButton(mainWidget); revertButton->setIcon(QIcon(":/edit-undo.png")); + revertButton->setToolTip ("Revert record"); if (mTable->getFeatures() & CSMWorld::IdTable::Feature_Preview) { QToolButton* previewButton = new QToolButton(mainWidget); previewButton->setIcon(QIcon(":/edit-preview.png")); + previewButton->setToolTip ("Open a preview of this record"); buttonsLayout->addWidget(previewButton); connect(previewButton, SIGNAL(clicked()), this, SLOT(showPreview())); } @@ -453,6 +460,7 @@ CSVWorld::DialogueSubView::DialogueSubView (const CSMWorld::UniversalId& id, CSM { QToolButton* viewButton = new QToolButton(mainWidget); viewButton->setIcon(QIcon(":/cell.png")); + viewButton->setToolTip ("Open a scene view of the cell this record is located in"); buttonsLayout->addWidget(viewButton); connect(viewButton, SIGNAL(clicked()), this, SLOT(viewRecord())); } From d5381e1bc44f85f4be7bba8aca0c982ef34429ff Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sat, 19 Jul 2014 14:04:38 +0200 Subject: [PATCH 24/28] Dynamically resize skill widgets to fit their contents (Fixes #1610) --- apps/openmw/mwgui/statswindow.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 6c4e00ae5..b11258f1c 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -321,6 +321,11 @@ namespace MWGui skillValueWidget->_setWidgetState(state); skillValueWidget->eventMouseWheel += MyGUI::newDelegate(this, &StatsWindow::onMouseWheel); + // resize dynamically according to text size + int textWidthPlusMargin = skillValueWidget->getTextSize().width + 12; + skillValueWidget->setCoord(coord2.left + coord2.width - textWidthPlusMargin, coord2.top, textWidthPlusMargin, coord2.height); + skillNameWidget->setSize(skillNameWidget->getSize() + MyGUI::IntSize(coord2.width - textWidthPlusMargin, 0)); + mSkillWidgets.push_back(skillNameWidget); mSkillWidgets.push_back(skillValueWidget); From 0f2305ae43fc4bd0d3cbc411f659409561d4be60 Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Sun, 20 Jul 2014 13:07:47 +0200 Subject: [PATCH 25/28] Clear selected spell when window manager is cleared --- apps/openmw/mwgui/windowmanagerimp.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 865ad1dca..668211db2 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1529,6 +1529,8 @@ namespace MWGui mCompanionWindow->resetReference(); mConsole->resetReference(); + mSelectedSpell.clear(); + mGuiModes.clear(); MWBase::Environment::get().getInputManager()->changeInputMode(false); updateVisible(); From 3b67e9b329e0fd1e4a6e6c00a54033007504dd6e Mon Sep 17 00:00:00 2001 From: MiroslavR Date: Mon, 21 Jul 2014 20:56:02 +0200 Subject: [PATCH 26/28] Rework level up dialog to behave more like vanilla --- apps/openmw/mwgui/levelupdialog.cpp | 103 ++++++++++++++--------- apps/openmw/mwgui/levelupdialog.hpp | 7 +- files/mygui/openmw_levelup_dialog.layout | 2 +- 3 files changed, 69 insertions(+), 43 deletions(-) diff --git a/apps/openmw/mwgui/levelupdialog.cpp b/apps/openmw/mwgui/levelupdialog.cpp index eaa822722..bf6181d76 100644 --- a/apps/openmw/mwgui/levelupdialog.cpp +++ b/apps/openmw/mwgui/levelupdialog.cpp @@ -16,9 +16,10 @@ namespace MWGui { - + const unsigned int LevelupDialog::sMaxCoins = 3; LevelupDialog::LevelupDialog() - : WindowBase("openmw_levelup_dialog.layout") + : WindowBase("openmw_levelup_dialog.layout"), + mCoinCount(sMaxCoins) { getWidget(mOkButton, "OkButton"); getWidget(mClassImage, "ClassImage"); @@ -46,12 +47,10 @@ namespace MWGui mAttributeMultipliers.push_back(t); } - int curX = mMainWidget->getWidth()/2 - (16 + 2) * 1.5; - for (int i=0; i<3; ++i) + for (unsigned int i = 0; i < mCoinCount; ++i) { - MyGUI::ImageBox* image = mMainWidget->createWidget("ImageBox", MyGUI::IntCoord(curX,250,16,16), MyGUI::Align::Default); + MyGUI::ImageBox* image = mCoinBox->createWidget("ImageBox", MyGUI::IntCoord(0,0,16,16), MyGUI::Align::Default); image->setImageTexture ("icons\\tx_goldicon.dds"); - curX += 24+2; mCoins.push_back(image); } @@ -61,15 +60,15 @@ namespace MWGui void LevelupDialog::setAttributeValues() { MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); - MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats (player); + MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats(player); MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player); - for (int i=0; i<8; ++i) + for (int i = 0; i < 8; ++i) { - int val = creatureStats.getAttribute (i).getBase (); + int val = creatureStats.getAttribute(i).getBase(); if (std::find(mSpentAttributes.begin(), mSpentAttributes.end(), i) != mSpentAttributes.end()) { - val += pcStats.getLevelupAttributeMultiplier (i); + val += pcStats.getLevelupAttributeMultiplier(i); } if (val >= 100) @@ -80,20 +79,21 @@ namespace MWGui } - void LevelupDialog::resetCoins () + void LevelupDialog::resetCoins() { - int curX = 0; - for (int i=0; i<3; ++i) + const int coinSpacing = 10; + int curX = mCoinBox->getWidth()/2 - (coinSpacing*(mCoinCount - 1) + 16*mCoinCount)/2; + for (unsigned int i=0; idetachFromWidget(); image->attachToWidget(mCoinBox); image->setCoord(MyGUI::IntCoord(curX,0,16,16)); - curX += 24+2; + curX += 16+coinSpacing; } } - void LevelupDialog::assignCoins () + void LevelupDialog::assignCoins() { resetCoins(); for (unsigned int i=0; igetPlayerPtr(); - MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats (player); - MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player); - - mSpentAttributes.clear(); - resetCoins(); - - setAttributeValues(); + MWMechanics::CreatureStats& creatureStats = player.getClass().getCreatureStats(player); + MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats(player); const ESM::NPC *playerData = player.get()->mBase; @@ -144,70 +139,98 @@ namespace MWGui if(it->mData.mIsPlayable && it->mData.mSpecialization == 2 && it->mData.mAttribute[0] == 4 && it->mData.mAttribute[1] == 3) break; } - mClassImage->setImageTexture ("textures\\levelup\\" + it->mId + ".dds"); + mClassImage->setImageTexture("textures\\levelup\\" + it->mId + ".dds"); } else - mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds"); + mClassImage->setImageTexture("textures\\levelup\\" + cls->mId + ".dds"); int level = creatureStats.getLevel ()+1; mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + boost::lexical_cast(level)); std::string levelupdescription; - if(level>20) + if(level > 20) levelupdescription=world->getFallback()->getFallbackString("Level_Up_Default"); else levelupdescription=world->getFallback()->getFallbackString("Level_Up_Level"+boost::lexical_cast(level)); mLevelDescription->setCaption (levelupdescription); - for (int i=0; i<8; ++i) + unsigned int availableAttributes = 0; + for (int i = 0; i < 8; ++i) { MyGUI::TextBox* text = mAttributeMultipliers[i]; - int mult = pcStats.getLevelupAttributeMultiplier (i); - text->setCaption(mult <= 1 ? "" : "x" + boost::lexical_cast(mult)); + if (pcStats.getAttribute(i).getBase() < 100) + { + mAttributes[i]->setEnabled(true); + availableAttributes++; + + int mult = pcStats.getLevelupAttributeMultiplier (i); + text->setCaption(mult <= 1 ? "" : "x" + boost::lexical_cast(mult)); + } + else + { + mAttributes[i]->setEnabled(false); + + text->setCaption(""); + } + } + + mCoinCount = std::min(sMaxCoins, availableAttributes); + + for (unsigned int i = 0; i < sMaxCoins; i++) + { + if (i < mCoinCount) + mCoins[i]->attachToWidget(mCoinBox); + else + mCoins[i]->detachFromWidget(); } + mSpentAttributes.clear(); + resetCoins(); + + setAttributeValues(); + center(); } - void LevelupDialog::onOkButtonClicked (MyGUI::Widget* sender) + void LevelupDialog::onOkButtonClicked(MyGUI::Widget* sender) { - MWWorld::Ptr player = MWBase::Environment::get().getWorld ()->getPlayerPtr(); + MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWMechanics::NpcStats& pcStats = player.getClass().getNpcStats (player); - if (mSpentAttributes.size() < 3) - MWBase::Environment::get().getWindowManager ()->messageBox("#{sNotifyMessage36}"); + if (mSpentAttributes.size() < mCoinCount) + MWBase::Environment::get().getWindowManager()->messageBox("#{sNotifyMessage36}"); else { // increase attributes - for (int i=0; i<3; ++i) + for (unsigned int i = 0; i < mCoinCount; ++i) { MWMechanics::AttributeValue attribute = pcStats.getAttribute(mSpentAttributes[i]); - attribute.setBase (attribute.getBase () + pcStats.getLevelupAttributeMultiplier (mSpentAttributes[i])); + attribute.setBase(attribute.getBase() + pcStats.getLevelupAttributeMultiplier(mSpentAttributes[i])); if (attribute.getBase() >= 100) attribute.setBase(100); pcStats.setAttribute(mSpentAttributes[i], attribute); } - pcStats.levelUp (); + pcStats.levelUp(); - MWBase::Environment::get().getWindowManager()->removeGuiMode (GM_Levelup); + MWBase::Environment::get().getWindowManager()->removeGuiMode(GM_Levelup); } } - void LevelupDialog::onAttributeClicked (MyGUI::Widget *sender) + void LevelupDialog::onAttributeClicked(MyGUI::Widget *sender) { int attribute = *sender->getUserData(); std::vector::iterator found = std::find(mSpentAttributes.begin(), mSpentAttributes.end(), attribute); if (found != mSpentAttributes.end()) - mSpentAttributes.erase (found); + mSpentAttributes.erase(found); else { - if (mSpentAttributes.size() == 3) - mSpentAttributes[2] = attribute; + if (mSpentAttributes.size() == mCoinCount) + mSpentAttributes[mCoinCount - 1] = attribute; else mSpentAttributes.push_back(attribute); } diff --git a/apps/openmw/mwgui/levelupdialog.hpp b/apps/openmw/mwgui/levelupdialog.hpp index 69afbf089..5ca9c8c75 100644 --- a/apps/openmw/mwgui/levelupdialog.hpp +++ b/apps/openmw/mwgui/levelupdialog.hpp @@ -28,8 +28,11 @@ namespace MWGui std::vector mSpentAttributes; - void onOkButtonClicked (MyGUI::Widget* sender); - void onAttributeClicked (MyGUI::Widget* sender); + unsigned int mCoinCount; + static const unsigned int sMaxCoins; + + void onOkButtonClicked(MyGUI::Widget* sender); + void onAttributeClicked(MyGUI::Widget* sender); void assignCoins(); void resetCoins(); diff --git a/files/mygui/openmw_levelup_dialog.layout b/files/mygui/openmw_levelup_dialog.layout index 0b12d7a05..07e1e560b 100644 --- a/files/mygui/openmw_levelup_dialog.layout +++ b/files/mygui/openmw_levelup_dialog.layout @@ -23,7 +23,7 @@ - + From 171c61022d432508e39616d413fd5a677f8c6eff Mon Sep 17 00:00:00 2001 From: Lukasz Gromanowski Date: Mon, 21 Jul 2014 21:16:30 +0200 Subject: [PATCH 27/28] Added initialization of weapRange in AiCombat::execute(). Signed-off-by: Lukasz Gromanowski --- apps/openmw/mwmechanics/aicombat.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 2606daa88..c0a97a1b1 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -265,7 +265,7 @@ namespace MWMechanics const ESM::Weapon *weapon = NULL; MWMechanics::WeaponType weaptype; - float weapRange; + float weapRange = 1.0f; actorClass.getCreatureStats(actor).setMovementFlag(CreatureStats::Flag_Run, true); @@ -300,7 +300,7 @@ namespace MWMechanics else //is creature { weaptype = WeapType_HandToHand; //doesn't matter, should only reflect if it is melee or distant weapon - weapRange = 150; //TODO: use true attack range (the same problem in Creature::hit) + weapRange = 150.0f; //TODO: use true attack range (the same problem in Creature::hit) } float rangeAttack; From e24173f94acf12f6e48d1eb8f09a983d36b59303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20=C5=9Aciubid=C5=82o?= Date: Mon, 21 Jul 2014 23:56:38 +0100 Subject: [PATCH 28/28] Fix bug 1482: - put powers on cooldown only when they are used succedsfully --- apps/openmw/mwworld/worldimp.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 386834882..93316f876 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2316,15 +2316,10 @@ namespace MWWorld } // If this is a power, check if it was already used in the last 24h - if (!fail && spell->mData.mType == ESM::Spell::ST_Power) + if (!fail && spell->mData.mType == ESM::Spell::ST_Power && !stats.getSpells().canUsePower(spell->mId)) { - if (stats.getSpells().canUsePower(spell->mId)) - stats.getSpells().usePower(spell->mId); - else - { - message = "#{sPowerAlreadyUsed}"; - fail = true; - } + message = "#{sPowerAlreadyUsed}"; + fail = true; } // Reduce mana @@ -2357,6 +2352,10 @@ namespace MWWorld if (!selectedSpell.empty()) { const ESM::Spell* spell = getStore().get().search(selectedSpell); + + // A power can be used once per 24h + if (spell->mData.mType == ESM::Spell::ST_Power) + stats.getSpells().usePower(spell->mId); cast.cast(spell); }