fixing some menu reog bugs

This commit is contained in:
Dante Ruiz 2018-05-16 10:40:28 -07:00
parent dd05afa974
commit e676348c4f
6 changed files with 160 additions and 172 deletions

View file

@ -79,7 +79,7 @@ ScrollingWindow {
interval: 1000
repeat: true
running: false
onTriggered: developerMenuEnabled = MenuInterface.isMenuEnabled("Developer Menus");
onTriggered: developerMenuEnabled = MenuInterface.isOptionChecked("Developer Menu");
}
Component {
@ -98,7 +98,7 @@ ScrollingWindow {
Component.onCompleted: {
isHMD = HMD.active;
updateRunningScripts();
developerMenuEnabled = MenuInterface.isMenuEnabled("Developer Menus");
developerMenuEnabled = MenuInterface.isOptionChecked("Developer Menu");
checkMenu.restart();
}

View file

@ -65,7 +65,7 @@ Rectangle {
interval: 1000
repeat: true
running: false
onTriggered: developerMenuEnabled = MenuInterface.isMenuEnabled("Developer Menus");
onTriggered: developerMenuEnabled = MenuInterface.isOptionChecked("Developer Menu");
}
Component {
@ -84,7 +84,7 @@ Rectangle {
Component.onCompleted: {
isHMD = HMD.active;
updateRunningScripts();
developerMenuEnabled = MenuInterface.isMenuEnabled("Developer Menus");
developerMenuEnabled = MenuInterface.isOptionChecked("Developer Menu");
checkMenu.restart();
}

View file

@ -308,40 +308,6 @@ Menu::Menu() {
settings->setValue(MenuOption::NotificationSoundsTablet, action->isChecked());
});
//Further sound notificaions disabled until new notification system will be implemented
/*
// Settings > Notifications > Level of Detail
action = addCheckableActionToQMenuAndActionHash(notificationsMenu, "Level of Detail", 0,
settings->getValue("play_notification_sounds_type_1").toBool());
connect(action, &QAction::triggered, [action, settings] {
settings->setValue("play_notification_sounds_type_1", action->isChecked());
});
// Settings > Notifications > Connection
action = addCheckableActionToQMenuAndActionHash(notificationsMenu, "Connection", 0,
settings->getValue("play_notification_sounds_type_2").toBool());
connect(action, &QAction::triggered, [action, settings] {
settings->setValue("play_notification_sounds_type_2", action->isChecked());
});
// Settings > Notifications > Connection Refused
action = addCheckableActionToQMenuAndActionHash(notificationsMenu, "Connection Refused", 0,
settings->getValue("play_notification_sounds_type_3").toBool());
connect(action, &QAction::triggered, [action, settings] {
settings->setValue("play_notification_sounds_type_3", action->isChecked());
});
// Settings > Notifications > Edit Error
action = addCheckableActionToQMenuAndActionHash(notificationsMenu, "Edit Error", 0,
settings->getValue("play_notification_sounds_type_4").toBool());
connect(action, &QAction::triggered, [action, settings] {
settings->setValue("play_notification_sounds_type_4", action->isChecked());
});
// Settings > Notifications > Wallet
addActionToQMenuAndActionHash(notificationsMenu, "Wallet");
action = addCheckableActionToQMenuAndActionHash(notificationsMenu, "Wallet", 0,
settings->getValue("play_notification_sounds_type_6").toBool());
connect(action, &QAction::triggered, [action, settings] {
settings->setValue("play_notification_sounds_type_6", action->isChecked());
});
*/
// Settings > Developer Menu
addCheckableActionToQMenuAndActionHash(settingsMenu, "Developer Menu", 0, false, this, SLOT(toggleDeveloperMenus()));

View file

@ -2654,7 +2654,6 @@ void MyAvatar::updateMotionBehaviorFromMenu() {
} else {
_motionBehaviors &= ~AVATAR_MOTION_SCRIPTED_MOTOR_ENABLED;
}
setCollisionsEnabled(menu->isOptionChecked(MenuOption::EnableAvatarCollisions));
setProperty("lookAtSnappingEnabled", menu->isOptionChecked(MenuOption::EnableLookAtSnapping));
}

View file

@ -266,16 +266,7 @@ void setupPreferences() {
static const QString movementsControlChannel = QStringLiteral("Hifi-Advanced-Movement-Disabler");
auto getter = [=]()->bool { return myAvatar->useAdvancedMovementControls(); };
auto setter = [=](bool value) {
auto messagesClient = DependencyManager::get<MessagesClient>().data();
myAvatar->setUseAdvancedMovementControls(value);
if (value) {
messagesClient->sendMessage(movementsControlChannel, QStringLiteral("enable_mappings"), true);
} else {
messagesClient->sendMessage(movementsControlChannel, QStringLiteral("disable_mappings"), true);
}
};
auto setter = [=](bool value) { myAvatar->setUseAdvancedMovementControls(value); };
preferences->addPreference(new CheckPreference(MOVEMENT,
QStringLiteral("Advanced movement for hand controllers"),
getter, setter));

View file

@ -11,42 +11,44 @@
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
/* jslint bitwise: true */
/* global Script, Quat, MyAvatar, HMD, Controller, Messages*/
(function() { // BEGIN LOCAL_SCOPE
var mappingName, basicMapping, isChecked;
var TWO_SECONDS_INTERVAL = 2000;
var FLYING_MAPPING_NAME = 'Hifi-Flying-Dev-' + Math.random();
var DRIVING_MAPPING_NAME = 'Hifi-Driving-Dev-' + Math.random();
var flyingMapping = null;
var drivingMapping = null;
var TURN_RATE = 1000;
var isDisabled = false;
var previousSetting = MyAvatar.useAdvancedMovementControls;
if (previousSetting === false) {
previousSetting = false;
isChecked = false;
}
if (previousSetting === true) {
previousSetting = true;
isChecked = true;
}
var previousFlyingState = MyAvatar.getFlyingEnabled();
var previousDrivingState = MyAvatar.useAdvancedMovementControls;
function rotate180() {
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.angleAxis(180, {
x: 0,
y: 1,
z: 0
}))
MyAvatar.orientation = newOrientation
}));
MyAvatar.orientation = newOrientation;
}
var inFlipTurn = false;
function registerBasicMapping() {
mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random();
basicMapping = Controller.newMapping(mappingName);
basicMapping.from(Controller.Standard.LY).to(function(value) {
drivingMapping = Controller.newMapping(DRIVING_MAPPING_NAME);
drivingMapping.from(Controller.Standard.LY).to(function(value) {
if (isDisabled) {
return;
}
var stick = Controller.getValue(Controller.Standard.LS);
if (value === 1 && Controller.Hardware.OculusTouch !== undefined) {
rotate180();
} else if (Controller.Hardware.Vive !== undefined) {
@ -55,16 +57,18 @@ function registerBasicMapping() {
rotate180();
Script.setTimeout(function() {
inFlipTurn = false;
}, TURN_RATE)
}, TURN_RATE);
}
}
return;
});
basicMapping.from(Controller.Standard.RY).to(function(value) {
flyingMapping = Controller.newMapping(FLYING_MAPPING_NAME);
flyingMapping.from(Controller.Standard.RY).to(function(value) {
if (isDisabled) {
return;
}
var stick = Controller.getValue(Controller.Standard.RS);
if (value === 1 && Controller.Hardware.OculusTouch !== undefined) {
rotate180();
} else if (Controller.Hardware.Vive !== undefined) {
@ -73,24 +77,16 @@ function registerBasicMapping() {
rotate180();
Script.setTimeout(function() {
inFlipTurn = false;
}, TURN_RATE)
}, TURN_RATE);
}
}
return;
})
}
function enableMappings() {
Controller.enableMapping(mappingName);
}
function disableMappings() {
Controller.disableMapping(mappingName);
});
}
function scriptEnding() {
disableMappings();
Controller.disableMapping(FLYING_MAPPING_NAME);
Controller.disableMapping(DRIVING_MAPPING_NAME);
}
Script.scriptEnding.connect(scriptEnding);
@ -98,21 +94,33 @@ Script.scriptEnding.connect(scriptEnding);
registerBasicMapping();
Script.setTimeout(function() {
if (previousSetting === true) {
disableMappings();
if (MyAvatar.useAdvanceMovementControls) {
Controller.disableMapping(DRIVING_MAPPING_NAME);
} else {
enableMappings();
Controller.enableMapping(DRIVING_MAPPING_NAME);
}
}, 100)
if (MyAvatar.getFyingEnabled()) {
Controller.disableMapping(FLYING_MAPPING_NAME);
} else {
Controller.enableMapping(FLYING_MAPPING_NAME);
}
}, 100);
HMD.displayModeChanged.connect(function(isHMDMode) {
if (isHMDMode) {
if (Controller.Hardware.Vive !== undefined || Controller.Hardware.OculusTouch !== undefined) {
if (isChecked === true) {
disableMappings();
} else if (isChecked === false) {
enableMappings();
if (MyAvatar.useAdvancedMovementControls) {
Controller.disableMapping(DRIVING_MAPPING_NAME);
} else {
Controller.enableMapping(DRIVING_MAPPING_NAME);
}
if (MyAvatar.getFlyingEnabled()) {
Controller.disableMapping(FLYING_MAPPING_NAME);
} else {
Controller.enableMapping(FLYING_MAPPING_NAME);
}
}
@ -120,6 +128,35 @@ HMD.displayModeChanged.connect(function(isHMDMode) {
});
function update() {
if ((Controller.Hardware.Vive !== undefined || Controller.Hardware.OculusTouch !== undefined) && HMD.active) {
var flying = MyAvatar.getFlyingEnabled();
var driving = MyAvatar.useAdvancedMovementControls;
if (flying !== previousFlyingState) {
if (flying) {
Controller.disableMapping(FLYING_MAPPING_NAME);
} else {
Controller.enableMapping(FLYING_MAPPING_NAME);
}
previousFlyingState = flying;
}
if (driving !== previousDrivingState) {
if (driving) {
Controller.disableMapping(DRIVING_MAPPING_NAME);
} else {
Controller.enableMapping(DRIVING_MAPPING_NAME);
}
previousDrivingState = driving;
}
}
Script.setTimeout(update, TWO_SECONDS_INTERVAL);
}
Script.setTimeout(update, TWO_SECONDS_INTERVAL);
var HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL = 'Hifi-Advanced-Movement-Disabler';
function handleMessage(channel, message, sender) {
if (channel === HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL) {
@ -127,11 +164,6 @@ function handleMessage(channel, message, sender) {
isDisabled = true;
} else if (message === 'enable') {
isDisabled = false;
} else if (message === 'enable_mappings') {
print("enable mappings")
enableMappings();
} else if (message === 'disable_mappings') {
disableMappings();
}
}
}