mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 01:48:59 +02:00
Added mouse sensivity UI. Reworked advanced movements. TODO: properties interface complitely broken in Tablet mode
This commit is contained in:
parent
4adfe94ed5
commit
617b49fe14
7 changed files with 49 additions and 103 deletions
|
@ -149,17 +149,17 @@ FocusScope {
|
|||
}
|
||||
|
||||
function isModalWindow(window) {
|
||||
return window.modality !== Qt.NonModal;
|
||||
return true;//window.modality !== (typeof Qt !== 'undefined' ? Qt.NonModal : 0);
|
||||
}
|
||||
|
||||
function getTopLevelWindows(predicate) {
|
||||
return findMatchingChildren(desktop, function(child) {
|
||||
return (isTopLevelWindow(child) && (!predicate || predicate(child)));
|
||||
return d.findMatchingChildren(desktop, function(child) {
|
||||
return (d.isTopLevelWindow(child) && (!predicate || predicate(child)));
|
||||
});
|
||||
}
|
||||
|
||||
function getDesktopWindow(item) {
|
||||
return findParentMatching(item, isTopLevelWindow)
|
||||
return d.findParentMatching(item, d.isTopLevelWindow)
|
||||
}
|
||||
|
||||
function fixupZOrder(windows, basis, topWindow) {
|
||||
|
@ -205,23 +205,23 @@ FocusScope {
|
|||
function raiseWindow(targetWindow) {
|
||||
var predicate;
|
||||
var zBasis;
|
||||
if (isModalWindow(targetWindow)) {
|
||||
predicate = isModalWindow;
|
||||
if (d.isModalWindow(targetWindow)) {
|
||||
predicate = d.isModalWindow;
|
||||
zBasis = zLevels.modal
|
||||
} else if (isAlwaysOnTopWindow(targetWindow)) {
|
||||
} else if (d.isAlwaysOnTopWindow(targetWindow)) {
|
||||
predicate = function(window) {
|
||||
return (isAlwaysOnTopWindow(window) && !isModalWindow(window));
|
||||
return (d.isAlwaysOnTopWindow(window) && !d.isModalWindow(window));
|
||||
}
|
||||
zBasis = zLevels.top
|
||||
} else {
|
||||
predicate = function(window) {
|
||||
return (!isAlwaysOnTopWindow(window) && !isModalWindow(window));
|
||||
return (!d.isAlwaysOnTopWindow(window) && !d.isModalWindow(window));
|
||||
}
|
||||
zBasis = zLevels.normal
|
||||
}
|
||||
|
||||
var windows = getTopLevelWindows(predicate);
|
||||
fixupZOrder(windows, zBasis, targetWindow);
|
||||
var windows = d.getTopLevelWindows(predicate);
|
||||
d.fixupZOrder(windows, zBasis, targetWindow);
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -264,7 +264,7 @@ FocusScope {
|
|||
}
|
||||
|
||||
function getRepositionChildren(predicate) {
|
||||
return findMatchingChildren(desktop, function(child) {
|
||||
return d.findMatchingChildren(desktop, function(child) {
|
||||
return (child.shouldReposition === true && (!predicate || predicate(child)));
|
||||
});
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ PreferencesDialog {
|
|||
id: root
|
||||
objectName: "GeneralPreferencesDialog"
|
||||
title: "General Settings"
|
||||
showCategories: ["User Interface", "HMD", "Snapshots", "Privacy"]
|
||||
showCategories: ["User Interface", "HMD", "Snapshots", "Privacy", "Mouse Sensivity"]
|
||||
property var settings: Settings {
|
||||
category: root.objectName
|
||||
property alias x: root.x
|
||||
|
|
|
@ -32,6 +32,6 @@ StackView {
|
|||
TabletPreferencesDialog {
|
||||
id: root
|
||||
objectName: "TabletGeneralPreferences"
|
||||
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Game Controller", "Sixense Controllers", "Perception Neuron", "Kinect", "Leap Motion"]
|
||||
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Game Controller", "Sixense Controllers", "Perception Neuron", "Kinect", "Leap Motion", "Mouse Sensivity"]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ Item {
|
|||
|
||||
Text {
|
||||
id: debugZ
|
||||
visible: DebugQML
|
||||
visible: (typeof DebugQML !== 'undefined') ? DebugQML : false
|
||||
color: "red"
|
||||
text: (window ? "Z: " + window.z : "") + " " + qmlFile
|
||||
y: window ? window.height + 4 : 0
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <OffscreenUi.h>
|
||||
#include <Preferences.h>
|
||||
#include <QRandomGenerator>
|
||||
#include <MessagesClient.h>
|
||||
#include <display-plugins/CompositorHelper.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
@ -55,7 +56,20 @@ void setupPreferences() {
|
|||
auto preference = new AvatarPreference(AVATAR_BASICS, "Appearance", getter, setter);
|
||||
preferences->addPreference(preference);
|
||||
}
|
||||
// UI
|
||||
|
||||
static const QString MOUSE_SENSIVITY { "Mouse Sensivity" };
|
||||
{
|
||||
auto getterY = []()->float { return 1.0; };
|
||||
auto setterY = [](float value) { };
|
||||
preferences->addPreference(new SliderPreference(MOUSE_SENSIVITY, "Y Input", getterY, setterY));
|
||||
auto getterX = []()->float { return 1.0; };
|
||||
auto setterX = [](float value) { };
|
||||
preferences->addPreference(new SliderPreference(MOUSE_SENSIVITY, "X Input", getterX, setterX));
|
||||
auto getterSW = []()->float { return 1.0; };
|
||||
auto setterSW = [](float value) { };
|
||||
preferences->addPreference(new SliderPreference(MOUSE_SENSIVITY, "Scroll Wheel", getterSW, setterSW));
|
||||
}
|
||||
// Graphics quality
|
||||
static const QString GRAPHICS_QUALITY { "Graphics Quality" };
|
||||
{
|
||||
auto getter = []()->float { return DependencyManager::get<LODManager>()->getLODLevel(); };
|
||||
|
@ -219,69 +233,22 @@ void setupPreferences() {
|
|||
//TODO: Update with advanced movement logic, test that it works
|
||||
{
|
||||
|
||||
using namespace controller;
|
||||
auto controllerScriptingInterface = DependencyManager::get<ScriptingInterface>().data();
|
||||
static QString advMovementsMappingName = QString("Hifi-AdvancedMovement-Dev-%1").arg(QRandomGenerator().generateDouble());
|
||||
static bool advMovementsIsDisabled = false;
|
||||
static bool inFlipTurn = false;
|
||||
|
||||
//code need to be revise so it should make correct iteration thru controller interface
|
||||
/*
|
||||
if (!advMovementsIsDisabled) {
|
||||
MappingBuilderProxy* basicMapping = static_cast<MappingBuilderProxy*>
|
||||
(controllerScriptingInterface->newMapping(advMovementsMappingName));
|
||||
const auto standard = controllerScriptingInterface->getStandard();
|
||||
const auto hardware = controllerScriptingInterface->getHardware();
|
||||
qDebug() << "hardware" << hardware;
|
||||
RouteBuilderProxy* fromMapping = static_cast<RouteBuilderProxy*>
|
||||
(basicMapping->fromQml(QJSValue(standard.value("LY").toFloat())));
|
||||
for(QMap<QString, QVariant>::const_iterator i = standard.find("LY"); i != standard.end(); ++i) {
|
||||
auto stick = controllerScriptingInterface->getValue(standard.value("LS").toInt());
|
||||
const float value = i.value().toFloat();
|
||||
if(value == 1.0f && hardware.contains("OculusTouch")) {
|
||||
//rotate180
|
||||
myAvatar->setWorldOrientation(Quat().multiply(myAvatar->getWorldOrientation(),
|
||||
Quat().angleAxis(180.0, glm::vec3(0,1,0))));
|
||||
|
||||
} else if (hardware.contains("Vive")) {
|
||||
if (value > 0.75f && inFlipTurn == false) {
|
||||
inFlipTurn = true;
|
||||
//rotate180();
|
||||
QTimer::singleShot(1000, []() { inFlipTurn = false; } );
|
||||
}
|
||||
}
|
||||
}
|
||||
for(QMap<QString, QVariant>::const_iterator i = standard.find("RY"); i != standard.end(); ++i) {
|
||||
auto stick = controllerScriptingInterface->getValue(standard.value("RS").toInt());
|
||||
const float value = i.value().toFloat();
|
||||
if(value == 1.0f && hardware.contains("OculusTouch")) {
|
||||
//rotate180
|
||||
myAvatar->setWorldOrientation(Quat().multiply(myAvatar->getWorldOrientation(),
|
||||
Quat().angleAxis(180.0, glm::vec3(0,1,0))));
|
||||
} else if (hardware.contains("Vive")) {
|
||||
if (value > 0.75f && inFlipTurn == false) {
|
||||
inFlipTurn = true;
|
||||
//rotate180
|
||||
myAvatar->setWorldOrientation(Quat().multiply(myAvatar->getWorldOrientation(),
|
||||
Quat().angleAxis(180.0, glm::vec3(0,1,0))));
|
||||
|
||||
QTimer::singleShot(1000, []() { inFlipTurn = false; } );
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
static const QString movementsControlChannel = QStringLiteral("Hifi-Advanced-Movement-Disabler");
|
||||
auto getter = [=]()->bool { return myAvatar->useAdvancedMovementControls(); };
|
||||
auto setter = [=](bool value) {
|
||||
auto controllerScriptingInterface = DependencyManager::get<ScriptingInterface>().data();
|
||||
auto messagesClient = DependencyManager::get<MessagesClient>().data();
|
||||
myAvatar->setUseAdvancedMovementControls(value);
|
||||
qDebug() << "vladest movement" << value;
|
||||
if (value) {
|
||||
controllerScriptingInterface->enableMapping(advMovementsMappingName);
|
||||
messagesClient->sendMessage(movementsControlChannel, QStringLiteral("enable_mappings"), true);
|
||||
} else {
|
||||
controllerScriptingInterface->disableMapping(advMovementsMappingName);
|
||||
messagesClient->sendMessage(movementsControlChannel, QStringLiteral("disable_mappings"), true);
|
||||
}
|
||||
|
||||
};
|
||||
preferences->addPreference(new CheckPreference(MOVEMENT, "Advanced movement for hand controllers", getter, setter));
|
||||
preferences->addPreference(new CheckPreference(MOVEMENT,
|
||||
QStringLiteral("Advanced movement for hand controllers"),
|
||||
getter, setter));
|
||||
}
|
||||
|
||||
{
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include "ui/Snapshot.h"
|
||||
#include "SoundCache.h"
|
||||
#include "raypick/PointerScriptingInterface.h"
|
||||
#include <display-plugins/CompositorHelper.h>
|
||||
|
||||
static int MAX_WINDOW_SIZE = 4096;
|
||||
static const float METERS_TO_INCHES = 39.3701f;
|
||||
|
@ -256,6 +257,8 @@ void Web3DOverlay::setupQmlSurface() {
|
|||
_webSurface->getSurfaceContext()->setContextProperty("Pointers", DependencyManager::get<PointerScriptingInterface>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Web3DOverlay", this);
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Window", DependencyManager::get<WindowScriptingInterface>().data());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("Reticle", qApp->getApplicationCompositor().getReticleInterface());
|
||||
_webSurface->getSurfaceContext()->setContextProperty("desktop", DependencyManager::get<OffscreenUi>()->getDesktop());
|
||||
|
||||
// Override min fps for tablet UI, for silky smooth scrolling
|
||||
setMaxFPS(90);
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
var mappingName, basicMapping, isChecked;
|
||||
|
||||
var TURN_RATE = 1000;
|
||||
var MENU_ITEM_NAME = "Advanced Movement For Hand Controllers";
|
||||
var isDisabled = false;
|
||||
var previousSetting = MyAvatar.useAdvancedMovementControls;
|
||||
if (previousSetting === false) {
|
||||
|
@ -29,15 +28,6 @@ if (previousSetting === true) {
|
|||
isChecked = true;
|
||||
}
|
||||
|
||||
function addAdvancedMovementItemToSettingsMenu() {
|
||||
Menu.addMenuItem({
|
||||
menuName: "Settings",
|
||||
menuItemName: MENU_ITEM_NAME,
|
||||
isCheckable: true,
|
||||
isChecked: previousSetting
|
||||
});
|
||||
}
|
||||
|
||||
function rotate180() {
|
||||
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.angleAxis(180, {
|
||||
x: 0,
|
||||
|
@ -100,30 +90,11 @@ function disableMappings() {
|
|||
}
|
||||
|
||||
function scriptEnding() {
|
||||
Menu.removeMenuItem("Settings", MENU_ITEM_NAME);
|
||||
disableMappings();
|
||||
}
|
||||
|
||||
|
||||
function menuItemEvent(menuItem) {
|
||||
if (menuItem == MENU_ITEM_NAME) {
|
||||
isChecked = Menu.isOptionChecked(MENU_ITEM_NAME);
|
||||
if (isChecked === true) {
|
||||
MyAvatar.useAdvancedMovementControls = true;
|
||||
disableMappings();
|
||||
} else if (isChecked === false) {
|
||||
MyAvatar.useAdvancedMovementControls = false;
|
||||
enableMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addAdvancedMovementItemToSettingsMenu();
|
||||
|
||||
Script.scriptEnding.connect(scriptEnding);
|
||||
|
||||
Menu.menuItemEvent.connect(menuItemEvent);
|
||||
|
||||
registerBasicMapping();
|
||||
|
||||
Script.setTimeout(function() {
|
||||
|
@ -151,11 +122,16 @@ HMD.displayModeChanged.connect(function(isHMDMode) {
|
|||
|
||||
var HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL = 'Hifi-Advanced-Movement-Disabler';
|
||||
function handleMessage(channel, message, sender) {
|
||||
if (channel == HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL) {
|
||||
if (message == 'disable') {
|
||||
if (channel === HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL) {
|
||||
if (message === 'disable') {
|
||||
isDisabled = true;
|
||||
} else if (message == 'enable') {
|
||||
} else if (message === 'enable') {
|
||||
isDisabled = false;
|
||||
} else if (message === 'enable_mappings') {
|
||||
print("enable mappings")
|
||||
enableMappings();
|
||||
} else if (message === 'disable_mappings') {
|
||||
disableMappings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue