Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
AleziaKurdis authored Jan 3, 2024
1 parent 099baed commit 287b8d1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 6 deletions.
30 changes: 25 additions & 5 deletions applications/flyAvatar/app-flyAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@

var APP_NAME = "FLY-AV";
var APP_URL = ROOT + "flyAvatar.html";
var APP_ICON_INACTIVE = ROOT + "icon_inactive.png";
var APP_ICON_INACTIVE_ON = ROOT + "icon_inactive_on.png";
var APP_ICON_INACTIVE_OFF = ROOT + "icon_inactive_off.png";
var inactiveIcon = APP_ICON_INACTIVE_ON;
var APP_ICON_ACTIVE = ROOT + "icon_active.png"; // BLACK on
var ICON_CAPTION_COLOR = "#FFFFFF";
var appStatus = false;
var channel = "overte.application.more.flyAvatar";
var timestamp = 0;
var INTERCALL_DELAY = 200; //0.3 sec
var FLY_AVATAR_SETTING_KEY = "overte.application.more.flyAvatar.avatarUrl";
var FLY_AVATAR_SWITCH_SETTING_KEY = "overte.application.more.flyAvatar.switch";
var flyAvatarSwitch = true;
var flyAvatarUrl = "";
var originalAvatarUrl = "";
var isFlying = false;
Expand All @@ -35,7 +39,7 @@

var button = tablet.addButton({
text: APP_NAME,
icon: APP_ICON_INACTIVE,
icon: APP_ICON_INACTIVE_ON,
activeIcon: APP_ICON_ACTIVE,
captionColor: ICON_CAPTION_COLOR
});
Expand All @@ -50,7 +54,7 @@
appStatus = false;
}else{
//Launching the Application UI.
tablet.gotoWebScreen(APP_URL); // <== Data can be transmitted at opening of teh UI by using GET method, through paramater in the URL. + "?parameter=value"
tablet.gotoWebScreen(APP_URL);
tablet.webEventReceived.connect(onAppWebEventReceived);
colorCaption = "#000000";
appStatus = true;
Expand Down Expand Up @@ -79,8 +83,16 @@
sendCurrentFlyAvatarUrlToUI();
} else if (instruction.action === "UPDATE_URL") {
flyAvatarUrl = instruction.url;
flyAvatarSwitch = instruction.mainSwitch;
Settings.setValue( FLY_AVATAR_SETTING_KEY, flyAvatarUrl);
Settings.setValue( FLY_AVATAR_SWITCH_SETTING_KEY, flyAvatarSwitch);
updateAvatar();
if (flyAvatarSwitch) {
inactiveIcon = APP_ICON_INACTIVE_ON;
} else {
inactiveIcon = APP_ICON_INACTIVE_OFF;
}
button.editProperties({icon: inactiveIcon});
} else if (instruction.action === "SELF_UNINSTALL" && (n - timestamp) > INTERCALL_DELAY) { //<== This is a good practice to add a "Uninstall this app" button for rarely used app. (toolbar has a limit in size)
d = new Date();
timestamp = d.getTime();
Expand All @@ -91,7 +103,7 @@
}

function updateAvatar() {
if (MyAvatar.isFlying()) {
if (MyAvatar.isFlying() && flyAvatarSwitch) {
MyAvatar.useFullAvatarURL(flyAvatarUrl);
} else {
if (MyAvatar.skeletonModelURL === flyAvatarUrl) {
Expand Down Expand Up @@ -124,7 +136,8 @@
var message = {
"channel": channel,
"action": "FLY-AVATAR-URL",
"url": flyAvatarUrl
"url": flyAvatarUrl,
"mainSwitch": flyAvatarSwitch
};
tablet.emitScriptEvent(JSON.stringify(message));
}
Expand Down Expand Up @@ -159,5 +172,12 @@
Script.scriptEnding.connect(cleanup);
originalAvatarUrl = MyAvatar.skeletonModelURL;
flyAvatarUrl = Settings.getValue( FLY_AVATAR_SETTING_KEY, "" );
flyAvatarSwitch = Settings.getValue( FLY_AVATAR_SWITCH_SETTING_KEY, true );
if (flyAvatarSwitch) {
inactiveIcon = APP_ICON_INACTIVE_ON;
} else {
inactiveIcon = APP_ICON_INACTIVE_OFF;
}
button.editProperties({icon: inactiveIcon});
Script.update.connect(myTimer);
}());
9 changes: 8 additions & 1 deletion applications/flyAvatar/flyAvatar.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
var ROOTPATH = currentPath.replace(thisPageName, "");
var flyAvatarUrl = "";
var flyAvatarSwitch = true;

EventBridge.scriptEventReceived.connect(function(message){
messageObj = JSON.parse(message);
if (messageObj.channel === channel) {
if (messageObj.action === "FLY-AVATAR-URL") {
flyAvatarUrl = messageObj.url;
flyAvatarSwitch = messageObj.mainSwitch;
document.getElementById("mainSwitch").checked = flyAvatarSwitch;
document.getElementById("avatarUrl").value = flyAvatarUrl;
}
}
Expand Down Expand Up @@ -99,6 +102,8 @@

<h1>FLY AVATAR</h1>
<div id="formContainer"><br><br>
<input type="checkbox" id="mainSwitch" name="mainSwitch" value="true" oninput = "updateAvatarUrl();"><label for="mainSwitch"> Replace avatar when flying.</label>
<br><br>
Avatar Url to use while flying:<br>
<input type = "text" id="avatarUrl" oninput = "updateAvatarUrl();"><br>
</div><hr>
Expand All @@ -121,10 +126,12 @@ <h1>FLY AVATAR</h1>

function updateAvatarUrl() {
flyAvatarUrl = document.getElementById("avatarUrl").value;
flyAvatarSwitch = document.getElementById("mainSwitch").checked;
var message = {
"channel": channel,
"action": "UPDATE_URL",
"url": flyAvatarUrl
"url": flyAvatarUrl,
"mainSwitch": flyAvatarSwitch
};
EventBridge.emitWebEvent(JSON.stringify(message));
}
Expand Down
Binary file added applications/flyAvatar/icon_inactive_off.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added applications/flyAvatar/icon_inactive_on.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 287b8d1

Please sign in to comment.