mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
This make the tablet app to be launched or not based on new setting that control its present in the tablet/toolbar. It also make it able to discard or restore itself on the tablet/toolbar if the option is checked in the Setting menu. (See PR 1274 for the new setting)
102 lines
6.1 KiB
JavaScript
102 lines
6.1 KiB
JavaScript
//
|
|
// graphicsSettings.js
|
|
//
|
|
// Created by Kalila L. on August 5th, 2020
|
|
// Copyright 2020 Vircadia contributors.
|
|
// Copyright 2024 Overte e.V.
|
|
//
|
|
// Distributed under the Apache License, Version 2.0.
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
(function() { // BEGIN LOCAL_SCOPE
|
|
var channelComm = "Overte-ShowGraphicsIconChanged";
|
|
var appStatus = false;
|
|
var GRAPHICS_HIDE_AND_SHOW_SETTING_KEY = "showGraphicsIcon";
|
|
var GRAPHICS_HIDE_AND_SHOW_DEFAULT_VALUE = true;
|
|
|
|
var AppUi = Script.require('appUi');
|
|
|
|
// cellphone-cog MDI
|
|
// var customIcon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="white" d="M9.82,12.5C9.84,12.33 9.86,12.17 9.86,12C9.86,11.83 9.84,11.67 9.82,11.5L10.9,10.69C11,10.62 11,10.5 10.96,10.37L9.93,8.64C9.87,8.53 9.73,8.5 9.62,8.53L8.34,9.03C8.07,8.83 7.78,8.67 7.47,8.54L7.27,7.21C7.27,7.09 7.16,7 7.03,7H5C4.85,7 4.74,7.09 4.72,7.21L4.5,8.53C4.21,8.65 3.92,8.83 3.65,9L2.37,8.5C2.25,8.47 2.12,8.5 2.06,8.63L1.03,10.36C0.97,10.5 1,10.61 1.1,10.69L2.18,11.5C2.16,11.67 2.15,11.84 2.15,12C2.15,12.17 2.17,12.33 2.19,12.5L1.1,13.32C1,13.39 1,13.53 1.04,13.64L2.07,15.37C2.13,15.5 2.27,15.5 2.38,15.5L3.66,15C3.93,15.18 4.22,15.34 4.53,15.47L4.73,16.79C4.74,16.91 4.85,17 5,17H7.04C7.17,17 7.28,16.91 7.29,16.79L7.5,15.47C7.8,15.35 8.09,15.17 8.36,15L9.64,15.5C9.76,15.53 9.89,15.5 9.95,15.37L11,13.64C11.04,13.53 11,13.4 10.92,13.32L9.82,12.5M6,13.75C5,13.75 4.2,12.97 4.2,12C4.2,11.03 5,10.25 6,10.25C7,10.25 7.8,11.03 7.8,12C7.8,12.97 7,13.75 6,13.75M17,1H7A2,2 0 0,0 5,3V6H7V4H17V20H7V18H5V21A2,2 0 0,0 7,23H17A2,2 0 0,0 19,21V3A2,2 0 0,0 17,1Z" /></svg>'
|
|
|
|
// application-cog MDI
|
|
var customIcon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="white" d="M21.7 18.6V17.6L22.8 16.8C22.9 16.7 23 16.6 22.9 16.5L21.9 14.8C21.9 14.7 21.7 14.7 21.6 14.7L20.4 15.2C20.1 15 19.8 14.8 19.5 14.7L19.3 13.4C19.3 13.3 19.2 13.2 19.1 13.2H17.1C16.9 13.2 16.8 13.3 16.8 13.4L16.6 14.7C16.3 14.9 16.1 15 15.8 15.2L14.6 14.7C14.5 14.7 14.4 14.7 14.3 14.8L13.3 16.5C13.3 16.6 13.3 16.7 13.4 16.8L14.5 17.6V18.6L13.4 19.4C13.3 19.5 13.2 19.6 13.3 19.7L14.3 21.4C14.4 21.5 14.5 21.5 14.6 21.5L15.8 21C16 21.2 16.3 21.4 16.6 21.5L16.8 22.8C16.9 22.9 17 23 17.1 23H19.1C19.2 23 19.3 22.9 19.3 22.8L19.5 21.5C19.8 21.3 20 21.2 20.3 21L21.5 21.4C21.6 21.4 21.7 21.4 21.8 21.3L22.8 19.6C22.9 19.5 22.9 19.4 22.8 19.4L21.7 18.6M18 19.5C17.2 19.5 16.5 18.8 16.5 18S17.2 16.5 18 16.5 19.5 17.2 19.5 18 18.8 19.5 18 19.5M11.29 20H5C3.89 20 3 19.1 3 18V6C3 4.89 3.9 4 5 4H19C20.11 4 21 4.9 21 6V11.68C20.38 11.39 19.71 11.18 19 11.08V8H5V18H11C11 18.7 11.11 19.37 11.29 20Z" /></svg>'
|
|
var lqIcon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="white" d="M14.5,13.5H16.5V10.5H14.5M18,14C18,14.6 17.6,15 17,15H16.25V16.5H14.75V15H14C13.4,15 13,14.6 13,14V10C13,9.4 13.4,9 14,9H17C17.6,9 18,9.4 18,10M19,4H5A2,2 0 0,0 3,6V18A2,2 0 0,0 5,20H19A2,2 0 0,0 21,18V6A2,2 0 0,0 19,4M11,13.5V15H6V9H7.5V13.5H11Z" /></svg>';
|
|
var mqIcon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="white" d="M21,6V18A2,2 0 0,1 19,20H5A2,2 0 0,1 3,18V6A2,2 0 0,1 5,4H19A2,2 0 0,1 21,6M12,10C12,9.5 11.5,9 11,9H6.5C6,9 5.5,9.5 5.5,10V15H7V10.5H8V14H9.5V10.5H10.5V15H12V10M14.5,9A1,1 0 0,0 13.5,10V14A1,1 0 0,0 14.5,15H15.5V16.5H16.75V15H17.5A1,1 0 0,0 18.5,14V10A1,1 0 0,0 17.5,9H14.5M15,10.5H17V13.5H15V10.5Z" /></svg>';
|
|
var hqIcon = 'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24"><path fill="white" d="M14.5,13.5H16.5V10.5H14.5M18,14A1,1 0 0,1 17,15H16.25V16.5H14.75V15H14A1,1 0 0,1 13,14V10A1,1 0 0,1 14,9H17A1,1 0 0,1 18,10M11,15H9.5V13H7.5V15H6V9H7.5V11.5H9.5V9H11M19,4H5C3.89,4 3,4.89 3,6V18A2,2 0 0,0 5,20H19A2,2 0 0,0 21,18V6C21,4.89 20.1,4 19,4Z" /></svg>';
|
|
|
|
var BUTTON_NAME = "GRAPHICS";
|
|
var GRAPHICS_QML_SOURCE = "hifi/dialogs/graphics/GraphicsSettings.qml";
|
|
var ui;
|
|
|
|
function getIcon() {
|
|
// TODO: Implement only once AppUi can be told to constantly retrieve / reset icons...
|
|
// var performanceProfile = Performance.getPerformancePreset();
|
|
//
|
|
// switch (performanceProfile) {
|
|
// case 0:
|
|
// return customIcon;
|
|
// break;
|
|
// case 1:
|
|
// return lqIcon;
|
|
// break;
|
|
// case 2:
|
|
// return mqIcon;
|
|
// break;
|
|
// case 3:
|
|
// return hqIcon;
|
|
// break;
|
|
// default:
|
|
// return customIcon;
|
|
// }
|
|
return customIcon;
|
|
}
|
|
|
|
function startup() {
|
|
if (!appStatus) {
|
|
ui = new AppUi({
|
|
buttonName: BUTTON_NAME,
|
|
sortOrder: 8,
|
|
normalButton: getIcon(),
|
|
activeButton: getIcon().replace('white', 'black'),
|
|
home: GRAPHICS_QML_SOURCE
|
|
});
|
|
}
|
|
appStatus = true;
|
|
}
|
|
|
|
function shutdown() {
|
|
if (appStatus) {
|
|
ui.onScriptEnding();
|
|
appStatus = false;
|
|
}
|
|
}
|
|
|
|
function cleanup() {
|
|
Messages.messageReceived.disconnect(onMessageReceived);
|
|
Messages.unsubscribe(channelComm);
|
|
}
|
|
|
|
function onMessageReceived(channel, message, sender, localOnly) {
|
|
if (channel === channelComm && localOnly) {
|
|
if (Settings.getValue(GRAPHICS_HIDE_AND_SHOW_SETTING_KEY, GRAPHICS_HIDE_AND_SHOW_DEFAULT_VALUE)) {
|
|
startup();
|
|
} else {
|
|
shutdown();
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Run the functions.
|
|
//
|
|
if (Settings.getValue(GRAPHICS_HIDE_AND_SHOW_SETTING_KEY, GRAPHICS_HIDE_AND_SHOW_DEFAULT_VALUE)) {
|
|
startup();
|
|
}
|
|
Messages.subscribe(channelComm);
|
|
Messages.messageReceived.connect(onMessageReceived);
|
|
|
|
Script.scriptEnding.connect(cleanup);
|
|
|
|
}()); // END LOCAL_SCOPE
|