mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-21 03:14:06 +00:00
store mouse bindings in WorldspaceWidget
This commit is contained in:
parent
d597bef2cd
commit
5c34a02058
2 changed files with 62 additions and 1 deletions
|
@ -18,6 +18,8 @@
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
|
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "../widget/scenetoolmode.hpp"
|
#include "../widget/scenetoolmode.hpp"
|
||||||
#include "../widget/scenetooltoggle2.hpp"
|
#include "../widget/scenetooltoggle2.hpp"
|
||||||
#include "../widget/scenetoolrun.hpp"
|
#include "../widget/scenetoolrun.hpp"
|
||||||
|
@ -26,6 +28,17 @@
|
||||||
#include "elements.hpp"
|
#include "elements.hpp"
|
||||||
#include "editmode.hpp"
|
#include "editmode.hpp"
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
static const char * const sMappingSettings[] =
|
||||||
|
{
|
||||||
|
"p-navi", "s-navi",
|
||||||
|
"p-edit", "s-edit",
|
||||||
|
"select",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidget* parent)
|
||||||
: SceneWidget (document.getData().getResourceSystem(), parent), mSceneElements(0), mRun(0), mDocument(document),
|
: SceneWidget (document.getData().getResourceSystem(), parent), mSceneElements(0), mRun(0), mDocument(document),
|
||||||
mInteractionMask (0)
|
mInteractionMask (0)
|
||||||
|
@ -59,6 +72,13 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
||||||
this, SLOT (debugProfileDataChanged (const QModelIndex&, const QModelIndex&)));
|
this, SLOT (debugProfileDataChanged (const QModelIndex&, const QModelIndex&)));
|
||||||
connect (debugProfiles, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
connect (debugProfiles, SIGNAL (rowsAboutToBeRemoved (const QModelIndex&, int, int)),
|
||||||
this, SLOT (debugProfileAboutToBeRemoved (const QModelIndex&, int, int)));
|
this, SLOT (debugProfileAboutToBeRemoved (const QModelIndex&, int, int)));
|
||||||
|
|
||||||
|
for (int i=0; sMappingSettings[i]; ++i)
|
||||||
|
{
|
||||||
|
QString key ("scene-input/");
|
||||||
|
key += sMappingSettings[i];
|
||||||
|
storeMappingSetting (key, CSMSettings::UserSettings::instance().settingValue (key));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
||||||
|
@ -256,7 +276,8 @@ unsigned int CSVRender::WorldspaceWidget::getInteractionMask() const
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::updateUserSetting (const QString& name, const QStringList& value)
|
void CSVRender::WorldspaceWidget::updateUserSetting (const QString& name, const QStringList& value)
|
||||||
{
|
{
|
||||||
|
if (!value.isEmpty() && storeMappingSetting (name, value.first()))
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
|
void CSVRender::WorldspaceWidget::addVisibilitySelectorButtons (
|
||||||
|
@ -293,6 +314,40 @@ void CSVRender::WorldspaceWidget::dragMoveEvent(QDragMoveEvent *event)
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool CSVRender::WorldspaceWidget::storeMappingSetting (const QString& key, const QString& value)
|
||||||
|
{
|
||||||
|
const QString prefix = "scene-input/";
|
||||||
|
|
||||||
|
if (key.startsWith (prefix))
|
||||||
|
{
|
||||||
|
QString key2 (key.mid (prefix.length()));
|
||||||
|
|
||||||
|
for (int i=0; sMappingSettings[i]; ++i)
|
||||||
|
if (key2==sMappingSettings[i])
|
||||||
|
{
|
||||||
|
std::cout<<"button :"<<sMappingSettings[i]<<std::endl;
|
||||||
|
Qt::MouseButton button = Qt::NoButton;
|
||||||
|
|
||||||
|
if (value.endsWith ("Left Mouse-Button"))
|
||||||
|
button = Qt::LeftButton;
|
||||||
|
else if (value.endsWith ("Right Mouse-Button"))
|
||||||
|
button = Qt::RightButton;
|
||||||
|
else if (value.endsWith ("Middle Mouse-Button"))
|
||||||
|
button = Qt::MiddleButton;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool ctrl = value.startsWith ("Ctrl-");
|
||||||
|
|
||||||
|
mButtonMapping[std::make_pair (button, ctrl)] = sMappingSettings[i];
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
|
void CSVRender::WorldspaceWidget::dropEvent (QDropEvent* event)
|
||||||
{
|
{
|
||||||
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
const CSMWorld::TableMimeData* mime = dynamic_cast<const CSMWorld::TableMimeData*> (event->mimeData());
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H
|
#ifndef OPENCS_VIEW_WORLDSPACEWIDGET_H
|
||||||
#define OPENCS_VIEW_WORLDSPACEWIDGET_H
|
#define OPENCS_VIEW_WORLDSPACEWIDGET_H
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
#include "scenewidget.hpp"
|
#include "scenewidget.hpp"
|
||||||
|
@ -31,6 +33,7 @@ namespace CSVRender
|
||||||
CSVWidget::SceneToolRun *mRun;
|
CSVWidget::SceneToolRun *mRun;
|
||||||
CSMDoc::Document& mDocument;
|
CSMDoc::Document& mDocument;
|
||||||
unsigned int mInteractionMask;
|
unsigned int mInteractionMask;
|
||||||
|
std::map<std::pair<Qt::MouseButton, bool>, std::string> mButtonMapping;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -120,6 +123,9 @@ namespace CSVRender
|
||||||
|
|
||||||
void dragMoveEvent(QDragMoveEvent *event);
|
void dragMoveEvent(QDragMoveEvent *event);
|
||||||
|
|
||||||
|
/// \return Is \a key a button mapping setting? (ignored otherwise)
|
||||||
|
bool storeMappingSetting (const QString& key, const QString& value);
|
||||||
|
|
||||||
virtual std::string getStartupInstruction() = 0;
|
virtual std::string getStartupInstruction() = 0;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in a new issue