mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 18:35:04 +02:00
Merge pull request #9658 from Atlante45/feat/capture-entity-clicks
Add entity clicks capture capabilities
This commit is contained in:
commit
ab09cc4339
6 changed files with 29 additions and 3 deletions
|
@ -3111,7 +3111,10 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
|||
|
||||
if (!_aboutToQuit) {
|
||||
getOverlays().mousePressEvent(&mappedEvent);
|
||||
getEntities()->mousePressEvent(&mappedEvent);
|
||||
|
||||
if (!_controllerScriptingInterface->areEntityClicksCaptured()) {
|
||||
getEntities()->mousePressEvent(&mappedEvent);
|
||||
}
|
||||
}
|
||||
|
||||
_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 {
|
||||
return _capturedJoysticks.contains(joystickIndex);
|
||||
}
|
||||
|
|
|
@ -84,6 +84,7 @@ public:
|
|||
bool isKeyCaptured(QKeyEvent* event) const;
|
||||
bool isKeyCaptured(const KeyEvent& event) const;
|
||||
bool isJoystickCaptured(int joystickIndex) const;
|
||||
bool areEntityClicksCaptured() const;
|
||||
|
||||
void updateInputControllers();
|
||||
|
||||
|
@ -95,6 +96,9 @@ public slots:
|
|||
virtual void captureJoystick(int joystickIndex);
|
||||
virtual void releaseJoystick(int joystickIndex);
|
||||
|
||||
virtual void captureEntityClickEvents();
|
||||
virtual void releaseEntityClickEvents();
|
||||
|
||||
virtual glm::vec2 getViewportDimensions() const;
|
||||
virtual QVariant getRecommendedOverlayRect() const;
|
||||
|
||||
|
@ -128,6 +132,7 @@ private:
|
|||
|
||||
QMultiMap<int,KeyEvent> _capturedKeys;
|
||||
QSet<int> _capturedJoysticks;
|
||||
bool _captureEntityClicks;
|
||||
|
||||
using InputKey = controller::InputController::Key;
|
||||
using InputControllerMap = std::map<InputKey, controller::InputController::Pointer>;
|
||||
|
|
|
@ -404,7 +404,7 @@ Grabber.prototype.pressEvent = 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -462,6 +462,11 @@ var toolBar = (function () {
|
|||
|
||||
that.setActive = function (active) {
|
||||
Settings.setValue(EDIT_SETTING, active);
|
||||
if (active) {
|
||||
Controller.captureEntityClickEvents();
|
||||
} else {
|
||||
Controller.releaseEntityClickEvents();
|
||||
}
|
||||
if (active === isActive) {
|
||||
return;
|
||||
}
|
||||
|
@ -965,6 +970,7 @@ function cleanupModelMenus() {
|
|||
}
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
toolBar.setActive(false);
|
||||
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_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
|
||||
EDIT_SETTING = "io.highfidelity.isEditting";
|
||||
isInEditMode = function isInEditMode() {
|
||||
return Settings.getValue(EDIT_SETTING) === "false" ? false : !!Settings.getValue(EDIT_SETTING);
|
||||
return Settings.getValue(EDIT_SETTING);
|
||||
};
|
||||
|
||||
if (!Function.prototype.bind) {
|
||||
|
|
Loading…
Reference in a new issue