mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 07:11:34 +02:00
Floofchat compatibility.
Made conversion functions to allow communication between apps. Removed developer console.log function. Signed-off-by: Armored Dragon <publicmail@armoreddragon.com>
This commit is contained in:
parent
eb84de84b4
commit
192d80aece
1 changed files with 35 additions and 1 deletions
|
@ -66,7 +66,6 @@
|
|||
}
|
||||
function toggleMainChatWindow() {
|
||||
appIsVisible = !appIsVisible;
|
||||
console.log(`App is now ${appIsVisible ? "visible" : "hidden"}`);
|
||||
appButton.editProperties({ isActive: appIsVisible });
|
||||
chatOverlayWindow.visible = appIsVisible;
|
||||
|
||||
|
@ -97,6 +96,9 @@
|
|||
if (channel !== "chat") return;
|
||||
message = JSON.parse(message);
|
||||
|
||||
// Floofchat compatibility hook
|
||||
message = floofChatCompatibilityConversion(message);
|
||||
|
||||
message.channel = message.channel.toLowerCase(); // Make sure the "local", "domain", etc. is formatted consistently
|
||||
|
||||
if (!channels.includes(message.channel)) return; // Check the channel
|
||||
|
@ -197,6 +199,8 @@
|
|||
action: "send_chat_message",
|
||||
})
|
||||
);
|
||||
|
||||
floofChatCompatibilitySendMessage(message, channel);
|
||||
}
|
||||
function _avatarAction(type, sessionId) {
|
||||
Script.setTimeout(() => {
|
||||
|
@ -251,4 +255,34 @@
|
|||
function _emitEvent(packet = { type: "" }) {
|
||||
chatOverlayWindow.sendToQml(packet);
|
||||
}
|
||||
|
||||
//
|
||||
// Floofchat compatibility functions
|
||||
// Added to ease the transition between Floofchat to ArmoredChat
|
||||
// These functions can be safely removed at a much later date.
|
||||
function floofChatCompatibilityConversion(message) {
|
||||
if (message.type === "TransmitChatMessage" && !message.forApp) {
|
||||
return {
|
||||
position: message.position,
|
||||
message: message.message,
|
||||
displayName: message.displayName,
|
||||
channel: message.channel.toLowerCase(),
|
||||
};
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
function floofChatCompatibilitySendMessage(message, channel) {
|
||||
Messages.sendMessage(
|
||||
"Chat",
|
||||
JSON.stringify({
|
||||
position: MyAvatar.position,
|
||||
message: message,
|
||||
displayName: MyAvatar.sessionDisplayName,
|
||||
channel: channel.charAt(0).toUpperCase() + channel.slice(1),
|
||||
type: "TransmitChatMessage",
|
||||
forApp: "Floof",
|
||||
})
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
|
Loading…
Reference in a new issue