making requested changes

This commit is contained in:
Dante Ruiz 2018-05-18 16:41:39 -07:00
parent 6eb5a78611
commit 60dd7e49ab
7 changed files with 75 additions and 26 deletions

View file

@ -24,6 +24,7 @@ Slider {
property alias minimumValue: slider.from property alias minimumValue: slider.from
property alias maximumValue: slider.to property alias maximumValue: slider.to
property alias step: slider.stepSize
property bool tickmarksEnabled: false property bool tickmarksEnabled: false
height: hifi.fontSizes.textFieldInput + 14 // Match height of TextField control. height: hifi.fontSizes.textFieldInput + 14 // Match height of TextField control.

View file

@ -55,6 +55,7 @@ Preference {
value: preference.value value: preference.value
minimumValue: preference.min minimumValue: preference.min
maximumValue: preference.max maximumValue: preference.max
step: preference.step
width: 130 width: 130
anchors { anchors {
right: parent.right right: parent.right

View file

@ -29,7 +29,10 @@ Item {
TabBar { TabBar {
id: bar id: bar
spacing: 0 spacing: 0
anchors.top: controllerSettings.top
width: parent.width width: parent.width
height: 40
z: 10
TabButton { TabButton {
height: parent.height height: parent.height
@ -284,7 +287,7 @@ Item {
anchors.fill: stackView anchors.fill: stackView
id: controllerPrefereneces id: controllerPrefereneces
objectName: "TabletControllerPreferences" objectName: "TabletControllerPreferences"
showCategories: ["VR Movement"] showCategories: ["VR Movement", "Game Controller", "Sixense Controllers", "Perception Neuron", "Leap Motion"]
} }
} }
} }

View file

@ -32,6 +32,6 @@ StackView {
TabletPreferencesDialog { TabletPreferencesDialog {
id: root id: root
objectName: "TabletGeneralPreferences" objectName: "TabletGeneralPreferences"
showCategories: ["UI", "Snapshots", "Scripts", "Privacy", "Octree", "HMD", "Game Controller", "Sixense Controllers", "Perception Neuron", "Kinect", "Leap Motion"] showCategories: ["User Interface", "HMD", "Snapshots", "Privacy"]
} }
} }

View file

@ -50,8 +50,6 @@ Window {
property var proxy: modelData; property var proxy: modelData;
onClicked: proxy.clicked() onClicked: proxy.clicked()
Component.onCompleted: updateProperties() Component.onCompleted: updateProperties()
//menu button should be visible only in VR mode
visible: text !== "MENU"
Connections { Connections {
target: proxy; target: proxy;

View file

@ -58,39 +58,55 @@ void setupPreferences() {
{ {
static const float MAX_DESKTOP_FPS = 60; static const float MAX_DESKTOP_FPS = 60;
static const float MAX_HMD_FPS = 90; static const float MAX_HMD_FPS = 90;
static const float MIN_HMD_FPS = 35; static const float LOW = 0.25f;
static const float MEDIUM = 0.5f;
static const float HIGH = 0.75f;
auto getter = []()->float { auto getter = []()->float {
auto lodManager = DependencyManager::get<LODManager>(); auto lodManager = DependencyManager::get<LODManager>();
float sliderValue = 0;
bool inHMD = qApp->isHMDMode(); bool inHMD = qApp->isHMDMode();
float increaseFPS = 0;
if (inHMD) { if (inHMD) {
float hmdMinFPS = lodManager->getHMDLODDecreaseFPS(); increaseFPS = lodManager->getHMDLODDecreaseFPS();
sliderValue = (MAX_HMD_FPS - hmdMinFPS) / MAX_HMD_FPS;
} else { } else {
float desktopMinFPS = lodManager->getDesktopLODDecreaseFPS(); increaseFPS = lodManager->getDesktopLODDecreaseFPS();
sliderValue = (MAX_DESKTOP_FPS - desktopMinFPS) / MAX_DESKTOP_FPS;
} }
return sliderValue; float maxFPS = inHMD ? MAX_HMD_FPS : MAX_DESKTOP_FPS;
float percentage = increaseFPS / maxFPS;
if (percentage >= HIGH) {
return HIGH;
} else if (percentage >= LOW) {
return MEDIUM;
}
return LOW;
}; };
auto setter = [](float value) { auto setter = [](float value) {
static const float THRASHING_DIFFERENCE = 10; static const float THRASHING_DIFFERENCE = 10;
auto lodManager = DependencyManager::get<LODManager>(); auto lodManager = DependencyManager::get<LODManager>();
if (qApp->isHMDMode()) {
float desiredHMDFPS = (MAX_HMD_FPS - (MAX_HMD_FPS * value)) - THRASHING_DIFFERENCE; bool isMaxValue = value == HIGH;
float actualHMDFPS = desiredHMDFPS > MIN_HMD_FPS ? desiredHMDFPS : MIN_HMD_FPS; bool isHMDMode = qApp->isHMDMode();
lodManager->setHMDLODDecreaseFPS(actualHMDFPS);
float maxFPS = isHMDMode ? MAX_HMD_FPS : MAX_DESKTOP_FPS;
float desiredFPS = maxFPS - THRASHING_DIFFERENCE;
if (!isMaxValue) {
desiredFPS = (maxFPS * value) - THRASHING_DIFFERENCE;
}
if (isHMDMode) {
lodManager->setHMDLODDecreaseFPS(desiredFPS);
} else { } else {
float desiredDesktopFPS = (MAX_DESKTOP_FPS - (MAX_DESKTOP_FPS * value)) - THRASHING_DIFFERENCE; lodManager->setDesktopLODDecreaseFPS(desiredFPS);
lodManager->setDesktopLODDecreaseFPS(desiredDesktopFPS);
} }
}; };
auto wodSlider = new SliderPreference(GRAPHICS_QUALITY, "World Detail", getter, setter); auto wodSlider = new SliderPreference(GRAPHICS_QUALITY, "World Detail", getter, setter);
wodSlider->setMin(0); wodSlider->setMin(0.25f);
wodSlider->setMax(1); wodSlider->setMax(0.75f);
wodSlider->setStep(0.1f); wodSlider->setStep(0.25f);
preferences->addPreference(wodSlider); preferences->addPreference(wodSlider);
auto getterShadow = []()->bool { auto getterShadow = []()->bool {

View file

@ -9,17 +9,29 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
/* jslint bitwise: true */
/* global Script, HMD, Tablet, Entities */
var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png"; var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
// var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png"; // var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
(function() { (function() {
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var lastHMDStatus = false;
var button = tablet.addButton({ var buttonProperties = {
icon: "icons/tablet-icons/menu-i.svg", icon: "icons/tablet-icons/menu-i.svg",
activeIcon: "icons/tablet-icons/menu-a.svg", activeIcon: "icons/tablet-icons/menu-a.svg",
text: "MENU", text: "MENU",
sortOrder: 3 sortOrder: 3
}); };
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
var button = null;
if (HMD.active) {
button = tablet.addButton(buttonProperties);
button.clicked.connect(onClicked);
lastHMDStatus = true;
}
var onMenuScreen = false; var onMenuScreen = false;
@ -35,19 +47,37 @@ var HOME_BUTTON_TEXTURE = "http://hifi-content.s3.amazonaws.com/alan/dev/tablet-
} }
} }
HMD.displayModeChanged.connect(function(isHMDMode) {
if (lastHMDStatus !== isHMDMode) {
if (isHMDMode) {
button = tablet.addButton(buttonProperties);
button.clicked.connect(onClicked);
} else if (button) {
button.clicked.disconnect(onClicked);
tablet.removeButton(button);
button = null;
}
lastHMDStatus = isHMDMode;
}
});
function onScreenChanged(type, url) { function onScreenChanged(type, url) {
onMenuScreen = type === "Menu"; onMenuScreen = type === "Menu";
button.editProperties({isActive: onMenuScreen}); if (button) {
button.editProperties({isActive: onMenuScreen});
}
} }
button.clicked.connect(onClicked);
tablet.screenChanged.connect(onScreenChanged); tablet.screenChanged.connect(onScreenChanged);
Script.scriptEnding.connect(function () { Script.scriptEnding.connect(function () {
if (onMenuScreen) { if (onMenuScreen) {
tablet.gotoHomeScreen(); tablet.gotoHomeScreen();
} }
button.clicked.disconnect(onClicked);
if (button) {
button.clicked.disconnect(onClicked);
}
tablet.removeButton(button); tablet.removeButton(button);
tablet.screenChanged.disconnect(onScreenChanged); tablet.screenChanged.disconnect(onScreenChanged);
}); });