mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
Add entity clicks capture capabilities
This commit is contained in:
parent
f4ff5cf746
commit
512bb4765f
6 changed files with 29 additions and 3 deletions
|
@ -3111,7 +3111,10 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
|
|
||||||
if (!_aboutToQuit) {
|
if (!_aboutToQuit) {
|
||||||
getOverlays().mousePressEvent(&mappedEvent);
|
getOverlays().mousePressEvent(&mappedEvent);
|
||||||
getEntities()->mousePressEvent(&mappedEvent);
|
|
||||||
|
if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
|
||||||
|
getEntities()->mousePressEvent(&mappedEvent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts
|
_controllerScriptingInterface->emitMousePressEvent(&mappedEvent); // send events to any registered scripts
|
||||||
|
|
|
@ -60,6 +60,18 @@ void ControllerScriptingInterface::releaseKeyEvents(const KeyEvent& event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ControllerScriptingInterface::areEntityClicksCaptured() const {
|
||||||
|
return _captureEntityClicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerScriptingInterface::captureEntityClickEvents() {
|
||||||
|
_captureEntityClicks = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControllerScriptingInterface::releaseEntityClickEvents() {
|
||||||
|
_captureEntityClicks = false;
|
||||||
|
}
|
||||||
|
|
||||||
bool ControllerScriptingInterface::isJoystickCaptured(int joystickIndex) const {
|
bool ControllerScriptingInterface::isJoystickCaptured(int joystickIndex) const {
|
||||||
return _capturedJoysticks.contains(joystickIndex);
|
return _capturedJoysticks.contains(joystickIndex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,6 +84,7 @@ public:
|
||||||
bool isKeyCaptured(QKeyEvent* event) const;
|
bool isKeyCaptured(QKeyEvent* event) const;
|
||||||
bool isKeyCaptured(const KeyEvent& event) const;
|
bool isKeyCaptured(const KeyEvent& event) const;
|
||||||
bool isJoystickCaptured(int joystickIndex) const;
|
bool isJoystickCaptured(int joystickIndex) const;
|
||||||
|
bool areEntityClicksCaptured() const;
|
||||||
|
|
||||||
void updateInputControllers();
|
void updateInputControllers();
|
||||||
|
|
||||||
|
@ -95,6 +96,9 @@ public slots:
|
||||||
virtual void captureJoystick(int joystickIndex);
|
virtual void captureJoystick(int joystickIndex);
|
||||||
virtual void releaseJoystick(int joystickIndex);
|
virtual void releaseJoystick(int joystickIndex);
|
||||||
|
|
||||||
|
virtual void captureEntityClickEvents();
|
||||||
|
virtual void releaseEntityClickEvents();
|
||||||
|
|
||||||
virtual glm::vec2 getViewportDimensions() const;
|
virtual glm::vec2 getViewportDimensions() const;
|
||||||
virtual QVariant getRecommendedOverlayRect() const;
|
virtual QVariant getRecommendedOverlayRect() const;
|
||||||
|
|
||||||
|
@ -128,6 +132,7 @@ private:
|
||||||
|
|
||||||
QMultiMap<int,KeyEvent> _capturedKeys;
|
QMultiMap<int,KeyEvent> _capturedKeys;
|
||||||
QSet<int> _capturedJoysticks;
|
QSet<int> _capturedJoysticks;
|
||||||
|
bool _captureEntityClicks;
|
||||||
|
|
||||||
using InputKey = controller::InputController::Key;
|
using InputKey = controller::InputController::Key;
|
||||||
using InputControllerMap = std::map<InputKey, controller::InputController::Pointer>;
|
using InputControllerMap = std::map<InputKey, controller::InputController::Pointer>;
|
||||||
|
|
|
@ -404,7 +404,7 @@ Grabber.prototype.pressEvent = function(event) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Grabber.prototype.releaseEvent = function(event) {
|
Grabber.prototype.releaseEvent = function(event) {
|
||||||
if (event.isLeftButton!==true ||event.isRightButton===true || event.isMiddleButton===true) {
|
if (event.isLeftButton!==true ||event.isRightButton===true || event.isMiddleButton===true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -462,6 +462,11 @@ var toolBar = (function () {
|
||||||
|
|
||||||
that.setActive = function (active) {
|
that.setActive = function (active) {
|
||||||
Settings.setValue(EDIT_SETTING, active);
|
Settings.setValue(EDIT_SETTING, active);
|
||||||
|
if (active) {
|
||||||
|
Controller.captureEntityClickEvents();
|
||||||
|
} else {
|
||||||
|
Controller.releaseEntityClickEvents();
|
||||||
|
}
|
||||||
if (active === isActive) {
|
if (active === isActive) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -965,6 +970,7 @@ function cleanupModelMenus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Script.scriptEnding.connect(function () {
|
Script.scriptEnding.connect(function () {
|
||||||
|
toolBar.setActive(false);
|
||||||
Settings.setValue(SETTING_AUTO_FOCUS_ON_SELECT, Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT));
|
Settings.setValue(SETTING_AUTO_FOCUS_ON_SELECT, Menu.isOptionChecked(MENU_AUTO_FOCUS_ON_SELECT));
|
||||||
Settings.setValue(SETTING_EASE_ON_FOCUS, Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
Settings.setValue(SETTING_EASE_ON_FOCUS, Menu.isOptionChecked(MENU_EASE_ON_FOCUS));
|
||||||
Settings.setValue(SETTING_SHOW_LIGHTS_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE));
|
Settings.setValue(SETTING_SHOW_LIGHTS_IN_EDIT_MODE, Menu.isOptionChecked(MENU_SHOW_LIGHTS_IN_EDIT_MODE));
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// note: this constant is currently duplicated in edit.js
|
// note: this constant is currently duplicated in edit.js
|
||||||
EDIT_SETTING = "io.highfidelity.isEditting";
|
EDIT_SETTING = "io.highfidelity.isEditting";
|
||||||
isInEditMode = function isInEditMode() {
|
isInEditMode = function isInEditMode() {
|
||||||
return Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING);
|
return Settings.getValue(EDIT_SETTING);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!Function.prototype.bind) {
|
if (!Function.prototype.bind) {
|
||||||
|
|
Loading…
Reference in a new issue