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

@ -100,19 +100,19 @@ Menu::Menu() {
addActionToQMenuAndActionHash(editMenu, redoAction);
editMenu->addSeparator();
// Edit > Cut
addActionToQMenuAndActionHash(editMenu, "Cut", Qt::CTRL | Qt::Key_X);
// Edit > Copy
addActionToQMenuAndActionHash(editMenu, "Copy", Qt::CTRL | Qt::Key_C);
// Edit > Paste
addActionToQMenuAndActionHash(editMenu, "Paste", Qt::CTRL | Qt::Key_V);
// Edit > Delete
addActionToQMenuAndActionHash(editMenu, "Delete", Qt::Key_Delete);
editMenu->addSeparator();
// Edit > Running Scripts
@ -280,7 +280,7 @@ Menu::Menu() {
});
// Settings > Notifications
MenuWrapper * notificationsMenu = settingsMenu->addMenu("Notifications"); //This was in notifications.js. The menu needs to be moved here.
MenuWrapper * notificationsMenu = settingsMenu->addMenu("Notifications"); //This was in notifications.js. The menu needs to be moved here.
//TODO: Hookup notification actions below.
// Settings > Notifications > Play Notification Sounds
@ -308,43 +308,9 @@ 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()));
// Settings > Ask to Reset Settings
addCheckableActionToQMenuAndActionHash(settingsMenu, MenuOption::AskToResetSettings, 0, false);
@ -375,7 +341,7 @@ Menu::Menu() {
if (mainViewShadowTaskConfig) {
if (action->isChecked()) {
mainViewShadowTaskConfig->setPreset("Enabled");
} else {
} else {
mainViewShadowTaskConfig->setPreset("None");
}
}
@ -844,7 +810,7 @@ Menu::Menu() {
// Help/Application menu ----------------------------------
MenuWrapper * helpMenu = addMenu("Help");
// Help > About High Fidelity
action = addActionToQMenuAndActionHash(helpMenu, "About High Fidelity");
connect(action, &QAction::triggered, [] {
@ -852,35 +818,35 @@ Menu::Menu() {
QString("hifi/dialogs/TabletAboutDialog.qml"), "AboutDialog");
});
helpMenu->addSeparator();
// Help > HiFi Docs
action = addActionToQMenuAndActionHash(helpMenu, "Online Documentation");
connect(action, &QAction::triggered, qApp, [] {
QDesktopServices::openUrl(QUrl("https://docs.highfidelity.com/"));
});
// Help > HiFi Forum
action = addActionToQMenuAndActionHash(helpMenu, "Online Forums");
connect(action, &QAction::triggered, qApp, [] {
QDesktopServices::openUrl(QUrl("https://forums.highfidelity.com/"));
});
// Help > Scripting Reference
action = addActionToQMenuAndActionHash(helpMenu, "Online Script Reference");
connect(action, &QAction::triggered, qApp, [] {
QDesktopServices::openUrl(QUrl("https://docs.highfidelity.com/api-reference"));
});
addActionToQMenuAndActionHash(helpMenu, "Controls Reference", 0, qApp, SLOT(showHelp()));
helpMenu->addSeparator();
// Help > Release Notes
action = addActionToQMenuAndActionHash(helpMenu, "Release Notes");
connect(action, &QAction::triggered, qApp, [] {
QDesktopServices::openUrl(QUrl("http://steamcommunity.com/games/390540/announcements/"));
});
// Help > Report a Bug!
action = addActionToQMenuAndActionHash(helpMenu, "Report a Bug!");
connect(action, &QAction::triggered, qApp, [] {

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,132 +11,164 @@
// 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 TURN_RATE = 1000;
var isDisabled = false;
var previousSetting = MyAvatar.useAdvancedMovementControls;
if (previousSetting === false) {
previousSetting = false;
isChecked = false;
}
var flyingMapping = null;
var drivingMapping = null;
if (previousSetting === true) {
previousSetting = true;
isChecked = true;
}
var TURN_RATE = 1000;
var isDisabled = false;
function rotate180() {
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.angleAxis(180, {
x: 0,
y: 1,
z: 0
}))
MyAvatar.orientation = newOrientation
}
var previousFlyingState = MyAvatar.getFlyingEnabled();
var previousDrivingState = MyAvatar.useAdvancedMovementControls;
var inFlipTurn = false;
function rotate180() {
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.angleAxis(180, {
x: 0,
y: 1,
z: 0
}));
MyAvatar.orientation = newOrientation;
}
function registerBasicMapping() {
mappingName = 'Hifi-AdvancedMovement-Dev-' + Math.random();
basicMapping = Controller.newMapping(mappingName);
basicMapping.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) {
if (value > 0.75 && inFlipTurn === false) {
inFlipTurn = true;
var inFlipTurn = false;
function registerBasicMapping() {
drivingMapping = Controller.newMapping(DRIVING_MAPPING_NAME);
drivingMapping.from(Controller.Standard.LY).to(function(value) {
if (isDisabled) {
return;
}
if (value === 1 && Controller.Hardware.OculusTouch !== undefined) {
rotate180();
Script.setTimeout(function() {
inFlipTurn = false;
}, TURN_RATE)
} else if (Controller.Hardware.Vive !== undefined) {
if (value > 0.75 && inFlipTurn === false) {
inFlipTurn = true;
rotate180();
Script.setTimeout(function() {
inFlipTurn = false;
}, TURN_RATE);
}
}
return;
});
flyingMapping = Controller.newMapping(FLYING_MAPPING_NAME);
flyingMapping.from(Controller.Standard.RY).to(function(value) {
if (isDisabled) {
return;
}
if (value === 1 && Controller.Hardware.OculusTouch !== undefined) {
rotate180();
} else if (Controller.Hardware.Vive !== undefined) {
if (value > 0.75 && inFlipTurn === false) {
inFlipTurn = true;
rotate180();
Script.setTimeout(function() {
inFlipTurn = false;
}, TURN_RATE);
}
}
return;
});
}
function scriptEnding() {
Controller.disableMapping(FLYING_MAPPING_NAME);
Controller.disableMapping(DRIVING_MAPPING_NAME);
}
Script.scriptEnding.connect(scriptEnding);
registerBasicMapping();
Script.setTimeout(function() {
if (MyAvatar.useAdvanceMovementControls) {
Controller.disableMapping(DRIVING_MAPPING_NAME);
} else {
Controller.enableMapping(DRIVING_MAPPING_NAME);
}
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 (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);
}
}
}
return;
});
basicMapping.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) {
if (value > 0.75 && inFlipTurn === false) {
inFlipTurn = true;
rotate180();
Script.setTimeout(function() {
inFlipTurn = false;
}, TURN_RATE)
}
}
return;
})
}
function enableMappings() {
Controller.enableMapping(mappingName);
}
function update() {
if ((Controller.Hardware.Vive !== undefined || Controller.Hardware.OculusTouch !== undefined) && HMD.active) {
var flying = MyAvatar.getFlyingEnabled();
var driving = MyAvatar.useAdvancedMovementControls;
function disableMappings() {
Controller.disableMapping(mappingName);
}
if (flying !== previousFlyingState) {
if (flying) {
Controller.disableMapping(FLYING_MAPPING_NAME);
} else {
Controller.enableMapping(FLYING_MAPPING_NAME);
}
function scriptEnding() {
disableMappings();
}
Script.scriptEnding.connect(scriptEnding);
registerBasicMapping();
Script.setTimeout(function() {
if (previousSetting === true) {
disableMappings();
} else {
enableMappings();
}
}, 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();
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) {
if (message === 'disable') {
isDisabled = true;
} else if (message === 'enable') {
isDisabled = false;
}
}
}
});
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') {
isDisabled = true;
} else if (message === 'enable') {
isDisabled = false;
} else if (message === 'enable_mappings') {
print("enable mappings")
enableMappings();
} else if (message === 'disable_mappings') {
disableMappings();
}
}
}
Messages.subscribe(HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL);
Messages.messageReceived.connect(handleMessage);
Messages.subscribe(HIFI_ADVANCED_MOVEMENT_DISABLER_CHANNEL);
Messages.messageReceived.connect(handleMessage);
}()); // END LOCAL_SCOPE