removed startup/unload apis from the 3 main modules

This commit is contained in:
milad 2019-09-04 16:48:24 -07:00
parent d316f014eb
commit 79b7271729
5 changed files with 56 additions and 97 deletions

View file

@ -388,11 +388,13 @@ function playPopAnimation() {
var emojiCodeMap; var emojiCodeMap;
var customEmojiCodeMap; var customEmojiCodeMap;
var signalsConnected = false; var signalsConnected = false;
function init() { var _this;
function startup() {
// make a map of just the utf codes to help with accesing // make a map of just the utf codes to help with accesing
emojiCodeMap = emojiList.reduce(function (codeMap, currentEmojiInList, index) { emojiCodeMap = emojiList.reduce(function (codeMap, currentEmojiInList, index) {
if ( if (
currentEmojiInList && currentEmojiInList &&
currentEmojiInList.code && currentEmojiInList.code &&
currentEmojiInList.code.length > 0 && currentEmojiInList.code.length > 0 &&
currentEmojiInList.code[UTF_CODE]) { currentEmojiInList.code[UTF_CODE]) {
@ -414,9 +416,22 @@ function init() {
pruneOldAvimojis(); pruneOldAvimojis();
Script.scriptEnding.connect(unload);
Window.domainChanged.connect(onDomainChanged); Window.domainChanged.connect(onDomainChanged);
MyAvatar.scaleChanged.connect(onScaleChanged); MyAvatar.scaleChanged.connect(onScaleChanged);
signalsConnected = true; signalsConnected = true;
function AviMoji() {
_this = this;
this._avimojiQMLWindow;
}
AviMoji.prototype = {
addEmoji: addEmojiFromQML,
registerAvimojiQMLWindow: registerAvimojiQMLWindow
};
return new AviMoji();
} }
@ -440,12 +455,6 @@ function init() {
// ************************************* // *************************************
// #region API // #region API
var _this;
function AviMoji() {
_this = this;
this._avimojiQMLWindow;
}
function registerAvimojiQMLWindow(avimojiQMLWindow) { function registerAvimojiQMLWindow(avimojiQMLWindow) {
this._avimojiQMLWindow = avimojiQMLWindow; this._avimojiQMLWindow = avimojiQMLWindow;
} }
@ -471,17 +480,7 @@ function unload() {
} }
} }
function startup() { var AviMoji = startup();
init();
}
AviMoji.prototype = {
startup: startup,
addEmoji: addEmojiFromQML,
unload: unload,
registerAvimojiQMLWindow: registerAvimojiQMLWindow
};
module.exports = AviMoji; module.exports = AviMoji;

View file

@ -544,8 +544,7 @@ function onDisplayModeChanged(isHMDMode) {
} }
var EmojiAPI = Script.require("./emojiApp/simplifiedEmoji.js"); var emojiAPI = Script.require("./emojiApp/simplifiedEmoji.js");
var emojiAPI = new EmojiAPI();
var keyPressSignalsConnected = false; var keyPressSignalsConnected = false;
var emojiCodeMap; var emojiCodeMap;
var customEmojiCodeMap; var customEmojiCodeMap;
@ -578,7 +577,6 @@ function init() {
Window.minimizedChanged.connect(onWindowMinimizedChanged); Window.minimizedChanged.connect(onWindowMinimizedChanged);
Window.geometryChanged.connect(onGeometryChanged); Window.geometryChanged.connect(onGeometryChanged);
HMD.displayModeChanged.connect(onDisplayModeChanged); HMD.displayModeChanged.connect(onDisplayModeChanged);
emojiAPI.startup();
getSounds(); getSounds();
handleEmoteIndicatorVisibleChanged(true); handleEmoteIndicatorVisibleChanged(true);
@ -586,11 +584,11 @@ function init() {
Controller.keyPressEvent.connect(keyPressHandler); Controller.keyPressEvent.connect(keyPressHandler);
Controller.keyReleaseEvent.connect(keyReleaseHandler); Controller.keyReleaseEvent.connect(keyReleaseHandler);
keyPressSignalsConnected = true; keyPressSignalsConnected = true;
Script.scriptEnding.connect(unload);
} }
function shutdown() { function unload() {
if (emoteAppBarWindow) { if (emoteAppBarWindow) {
emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar); emoteAppBarWindow.fromQml.disconnect(onMessageFromEmoteAppBar);
emoteAppBarWindow.close(); emoteAppBarWindow.close();
@ -605,7 +603,6 @@ function shutdown() {
endReactionWrapper(react); endReactionWrapper(react);
}); });
emojiAPI.unload();
maybeClearClapSoundInterval(); maybeClearClapSoundInterval();
maybeClearReticleUpdateLimiterTimeout(); maybeClearReticleUpdateLimiterTimeout();
maybeDeleteRemoteIndicatorTimeout(); maybeDeleteRemoteIndicatorTimeout();
@ -758,37 +755,4 @@ function toggleEmojiApp() {
// END EMOJI // END EMOJI
// ************************************* // *************************************
// ************************************* init();
// START API
// *************************************
// #region API
function startup() {
init();
}
function unload() {
shutdown();
}
var _this;
function EmoteBar() {
_this = this;
}
EmoteBar.prototype = {
startup: startup,
unload: unload
};
module.exports = EmoteBar;
// #endregion
// *************************************
// END API
// *************************************

View file

@ -47,15 +47,24 @@ function onAvatarAdded(uuid) {
} }
// Called on init // Create a new nametag list manager, connect signals, and return back a new Nametag object.
var avatarNametagMode; var avatarNametagMode;
function startup() { function startup() {
nameTagListManager.create(); nameTagListManager.create();
handleAvatarNametagMode(Settings.getValue("simplifiedNametag/avatarNametagMode", "on")); handleAvatarNametagMode(Settings.getValue("simplifiedNametag/avatarNametagMode", "on"));
Script.scriptEnding.connect(unload);
Window.domainChanged.connect(onDomainChange); Window.domainChanged.connect(onDomainChange);
AvatarManager.avatarRemovedEvent.connect(onAvatarRemoved); AvatarManager.avatarRemovedEvent.connect(onAvatarRemoved);
AvatarManager.avatarAddedEvent.connect(onAvatarAdded); AvatarManager.avatarAddedEvent.connect(onAvatarAdded);
function NameTag() {}
NameTag.prototype = {
handleAvatarNametagMode: handleAvatarNametagMode
};
return new NameTag();
} }
@ -82,15 +91,10 @@ function handleAvatarNametagMode(newAvatarNameTagMode) {
// ************************************* // *************************************
// #region api // #region api
function NameTag() {}
NameTag.prototype = { var nameTag = startup();
startup: startup,
unload: unload,
handleAvatarNametagMode: handleAvatarNametagMode
};
module.exports = NameTag; module.exports = nameTag;
// #endregion // #endregion

View file

@ -8,7 +8,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
function simplifiedStatusIndicator(properties) { function SimplifiedStatusIndicator() {
var that = this; var that = this;
var DEBUG = false; var DEBUG = false;
@ -125,6 +125,16 @@ function simplifiedStatusIndicator(properties) {
// #region SIGNALS // #region SIGNALS
function updateProperties(properties) {
// Overwrite with the given properties
var overwriteableKeys = ["statusChanged"];
Object.keys(properties).forEach(function (key) {
if (overwriteableKeys.indexOf(key) > -1) {
that[key] = properties[key];
}
});
}
var currentStatus = "available"; // Default is available var currentStatus = "available"; // Default is available
function toggleStatus() { function toggleStatus() {
if (currentStatus === "busy") { if (currentStatus === "busy") {
@ -207,6 +217,8 @@ function simplifiedStatusIndicator(properties) {
Window.domainChanged.connect(onDomainChanged); Window.domainChanged.connect(onDomainChanged);
getStatus(setStatus); getStatus(setStatus);
Script.scriptEnding.connect(unload);
} }
@ -224,20 +236,13 @@ function simplifiedStatusIndicator(properties) {
// #endregion APP LIFETIME // #endregion APP LIFETIME
that.startup = startup;
that.unload = unload;
that.toggleStatus = toggleStatus; that.toggleStatus = toggleStatus;
that.setStatus = setStatus; that.setStatus = setStatus;
that.getLocalStatus = getLocalStatus; that.getLocalStatus = getLocalStatus;
that.statusChanged = statusChanged; that.statusChanged = statusChanged;
that.updateProperties = updateProperties;
// Overwrite with the given properties
var overwriteableKeys = ["statusChanged"]; startup();
Object.keys(properties).forEach(function (key) {
if (overwriteableKeys.indexOf(key) > -1) {
that[key] = properties[key];
}
});
} }
module.exports = simplifiedStatusIndicator; module.exports = new SimplifiedStatusIndicator();

View file

@ -583,12 +583,11 @@ function restoreLODSettings() {
} }
var SimplifiedNametag = Script.require("./simplifiedNametag/simplifiedNametag.js?" + Date.now()); var nametag = Script.require("./simplifiedNametag/simplifiedNametag.js?" + Date.now());
var SimplifiedStatusIndicator = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js?" + Date.now()); var si = Script.require("./simplifiedStatusIndicator/simplifiedStatusIndicator.js?" + Date.now())
var SimplifiedEmote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now()); var emote = Script.require("../simplifiedEmote/simplifiedEmote.js?" + Date.now());
var si; // var nametag;
var nametag; // var emote;
var emote;
var oldShowAudioTools; var oldShowAudioTools;
var oldShowBubbleTools; var oldShowBubbleTools;
var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false); var keepExistingUIAndScriptsSetting = Settings.getValue("simplifiedUI/keepExistingUIAndScripts", false);
@ -607,16 +606,8 @@ function startup() {
loadSimplifiedTopBar(); loadSimplifiedTopBar();
si = new SimplifiedStatusIndicator({
statusChanged: onStatusChanged
});
si.startup();
nametag = new SimplifiedNametag(); si.updateProperties({ statusChanged: onStatusChanged });
nametag.startup();
emote = new SimplifiedEmote();
emote.startup();
updateInputDeviceMutedOverlay(Audio.muted); updateInputDeviceMutedOverlay(Audio.muted);
updateOutputDeviceMutedOverlay(isOutputMuted()); updateOutputDeviceMutedOverlay(isOutputMuted());
@ -665,10 +656,6 @@ function shutdown() {
maybeDeleteInputDeviceMutedOverlay(); maybeDeleteInputDeviceMutedOverlay();
maybeDeleteOutputDeviceMutedOverlay(); maybeDeleteOutputDeviceMutedOverlay();
nametag.unload();
si.unload();
emote.unload();
Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged); Audio.mutedDesktopChanged.disconnect(onDesktopInputDeviceMutedChanged);
Audio.mutedHMDChanged.disconnect(onHMDInputDeviceMutedChanged); Audio.mutedHMDChanged.disconnect(onHMDInputDeviceMutedChanged);
Window.geometryChanged.disconnect(onGeometryChanged); Window.geometryChanged.disconnect(onGeometryChanged);