mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 04:12:46 +02:00
Update chat to accept system notifications.
This commit is contained in:
parent
2d7a640935
commit
e8526aa6b7
1 changed files with 27 additions and 3 deletions
|
@ -23,6 +23,7 @@ var CONTROL_KEY = 67108864;
|
||||||
var SHIFT_KEY = 33554432;
|
var SHIFT_KEY = 33554432;
|
||||||
var FLOOF_CHAT_CHANNEL = "Chat";
|
var FLOOF_CHAT_CHANNEL = "Chat";
|
||||||
var FLOOF_NOTIFICATION_CHANNEL = "Floof-Notif";
|
var FLOOF_NOTIFICATION_CHANNEL = "Floof-Notif";
|
||||||
|
var SYSTEM_NOTIFICATION_CHANNEL = "System-Notifications";
|
||||||
|
|
||||||
var MAIN_CHAT_WINDOW_HEIGHT = 450;
|
var MAIN_CHAT_WINDOW_HEIGHT = 450;
|
||||||
var MAIN_CHAT_WINDOW_WIDTH = 750;
|
var MAIN_CHAT_WINDOW_WIDTH = 750;
|
||||||
|
@ -79,6 +80,7 @@ init();
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
Messages.subscribe(FLOOF_CHAT_CHANNEL);
|
Messages.subscribe(FLOOF_CHAT_CHANNEL);
|
||||||
|
Messages.subscribe(SYSTEM_NOTIFICATION_CHANNEL);
|
||||||
historyLog = [];
|
historyLog = [];
|
||||||
try {
|
try {
|
||||||
historyLog = JSON.parse(Settings.getValue(settingsRoot + "/HistoryLog", "[]"));
|
historyLog = JSON.parse(Settings.getValue(settingsRoot + "/HistoryLog", "[]"));
|
||||||
|
@ -435,8 +437,8 @@ function replaceFormatting(text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function messageReceived(channel, message) {
|
function messageReceived(channel, message, sender) {
|
||||||
if (channel === "Chat") {
|
if (channel === FLOOF_CHAT_CHANNEL) {
|
||||||
var cmd = {FAILED: true};
|
var cmd = {FAILED: true};
|
||||||
try {
|
try {
|
||||||
cmd = JSON.parse(message);
|
cmd = JSON.parse(message);
|
||||||
|
@ -518,6 +520,26 @@ function messageReceived(channel, message) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (channel === SYSTEM_NOTIFICATION_CHANNEL && sender == MyAvatar.sessionUUID) {
|
||||||
|
var cmd = {FAILED: true};
|
||||||
|
try {
|
||||||
|
cmd = JSON.parse(message);
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
if (!cmd.FAILED) {
|
||||||
|
if (cmd.type === "Update-Notification") {
|
||||||
|
addToLog(cmd.message, cmd.category, cmd.colour, cmd.channel);
|
||||||
|
|
||||||
|
Messages.sendLocalMessage(FLOOF_NOTIFICATION_CHANNEL, JSON.stringify({
|
||||||
|
sender: "(" + cmd.category + ")",
|
||||||
|
text: replaceFormatting(cmd.message),
|
||||||
|
colour: {text: cmd.colour}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function time() {
|
function time() {
|
||||||
|
@ -569,7 +591,9 @@ function fromQml(message) {
|
||||||
cmd = processChat(cmd);
|
cmd = processChat(cmd);
|
||||||
if (cmd.message === "") return;
|
if (cmd.message === "") return;
|
||||||
Messages.sendMessage(FLOOF_CHAT_CHANNEL, JSON.stringify({
|
Messages.sendMessage(FLOOF_CHAT_CHANNEL, JSON.stringify({
|
||||||
type: "TransmitChatMessage", channel: "Domain", colour: chatColour("Domain"),
|
type: "TransmitChatMessage",
|
||||||
|
channel: "Domain",
|
||||||
|
colour: chatColour("Domain"),
|
||||||
message: cmd.message,
|
message: cmd.message,
|
||||||
displayName: cmd.avatarName
|
displayName: cmd.avatarName
|
||||||
}));
|
}));
|
||||||
|
|
Loading…
Reference in a new issue