diff --git a/applications/home/app_home.js b/applications/home/app_home.js new file mode 100644 index 0000000..78c3255 --- /dev/null +++ b/applications/home/app_home.js @@ -0,0 +1,61 @@ +"use strict"; +// +// app_home.js +// +// Created by Alezia Kurdis, February 12th, 2022. +// Copyright 2022 Overte e.V. +// +// Fast go home button. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// +(function() { + var jsMainFileName = "app_home.js"; + var ROOT = Script.resolvePath('').split(jsMainFileName)[0]; + var teleporterSoundFileUrl = ROOT + "tpsound.mp3"; + var teleportSound = SoundCache.getSound(teleporterSoundFileUrl); + var APP_NAME = "HOME"; + var APP_ICON_INACTIVE = ROOT + "appicon_i.png"; + var APP_ICON_ACTIVE = ROOT + "appicon_a.png"; + + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); + + var button = tablet.addButton({ + text: APP_NAME, + icon: APP_ICON_INACTIVE, + activeIcon: APP_ICON_ACTIVE, + sortOrder: 3 + }); + + + function clicked(){ + button.editProperties({ + isActive: true + }); + playSound(); + var timer = Script.setTimeout(function () { + if (LocationBookmarks.getHomeLocationAddress()) { + location.handleLookupString(LocationBookmarks.getHomeLocationAddress()); + } else { + location.goToLocalSandbox(); + } + button.editProperties({ + isActive: false + }); + }, 3000); + } + + button.clicked.connect(clicked); + + function cleanup() { + Script.scriptEnding.disconnect(cleanup); + tablet.removeButton(button); + } + + function playSound() { + Audio.playSound(teleportSound, { volume: 0.3, localOnly: true }); + }; + + Script.scriptEnding.connect(cleanup); +}()); diff --git a/applications/home/appicon_a.png b/applications/home/appicon_a.png new file mode 100644 index 0000000..d19d17a Binary files /dev/null and b/applications/home/appicon_a.png differ diff --git a/applications/home/appicon_i.png b/applications/home/appicon_i.png new file mode 100644 index 0000000..aa42613 Binary files /dev/null and b/applications/home/appicon_i.png differ diff --git a/applications/home/tpsound.mp3 b/applications/home/tpsound.mp3 new file mode 100644 index 0000000..fb25a27 Binary files /dev/null and b/applications/home/tpsound.mp3 differ diff --git a/applications/metadata.js b/applications/metadata.js index 0911b61..6b80148 100644 --- a/applications/metadata.js +++ b/applications/metadata.js @@ -67,7 +67,7 @@ var metadata = { "applications": "isActive": true, "directory": "radar", "name": "Radar", - "description": "Show where people are and teleport in the domain. More info...", + "description": "Show where people are and teleport in the domain.", "jsfile": "radar/radar.js", "icon": "radar/assets/radar-i.svg", "caption": "RADAR" @@ -85,7 +85,7 @@ var metadata = { "applications": "isActive": true, "directory": "nametags", "name": "Nametags", - "description": "Display users' display names above their heads. More info...", + "description": "Display users' display names above their heads.", "jsfile": "nametags/nametags.js", "icon": "nametags/assets/nametags-i.svg", "caption": "NAMETAGS" @@ -116,6 +116,15 @@ var metadata = { "applications": "jsfile": "odometer/odometer.js", "icon": "odometer/appicon_i.png", "caption": "ODOMETER" + }, + { + "isActive": true, + "directory": "home", + "name": "Home", + "description": "Add a shortcut on your tablet to teleport home.", + "jsfile": "home/app_home.js", + "icon": "home/appicon_i.png", + "caption": "HOME" } ] };