mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Added /l /d /g chatbar switches and /goto
This commit is contained in:
parent
b8dbb4585f
commit
ae620b78af
2 changed files with 70 additions and 15 deletions
|
@ -194,7 +194,7 @@
|
||||||
var part1 = text.substring(0, firstMatch - 2);
|
var part1 = text.substring(0, firstMatch - 2);
|
||||||
var part2 = text.substring(firstMatch, secondMatch);
|
var part2 = text.substring(firstMatch, secondMatch);
|
||||||
var part3 = text.substring(secondMatch + 2);
|
var part3 = text.substring(secondMatch + 2);
|
||||||
text = part1 + "<i>" + part2 + "</i>" + part3;
|
text = part1 + "<b>" + part2 + "</b>" + part3;
|
||||||
}
|
}
|
||||||
} else if (text.indexOf("*") !== -1) {
|
} else if (text.indexOf("*") !== -1) {
|
||||||
var firstMatch = text.indexOf("*") + 1;
|
var firstMatch = text.indexOf("*") + 1;
|
||||||
|
@ -204,7 +204,7 @@
|
||||||
var part1 = text.substring(0, firstMatch - 1);
|
var part1 = text.substring(0, firstMatch - 1);
|
||||||
var part2 = text.substring(firstMatch, secondMatch);
|
var part2 = text.substring(firstMatch, secondMatch);
|
||||||
var part3 = text.substring(secondMatch + 1);
|
var part3 = text.substring(secondMatch + 1);
|
||||||
text = part1 + "<b>" + part2 + "</b>" + part3;
|
text = part1 + "<i>" + part2 + "</i>" + part3;
|
||||||
}
|
}
|
||||||
} else if (text.indexOf("__") !== -1) {
|
} else if (text.indexOf("__") !== -1) {
|
||||||
var firstMatch = text.indexOf("__") + 2;
|
var firstMatch = text.indexOf("__") + 2;
|
||||||
|
|
|
@ -170,6 +170,51 @@ function chatColour(tab) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var chatBarChannel = "Local";
|
||||||
|
|
||||||
|
|
||||||
|
function gotoConfirm(url) {
|
||||||
|
var result = Window.confirm("Do you want to goto " + ((url.indexOf("/") !== -1) ? url.split("/")[2] : url) + " ?");
|
||||||
|
if (result) {
|
||||||
|
location = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processChat(cmd) {
|
||||||
|
var msg = cmd.message;
|
||||||
|
if (msg.indexOf("/") === 0) {
|
||||||
|
msg = msg.substring(1);
|
||||||
|
var commandList = msg.split(" ");
|
||||||
|
var cmd1 = commandList[0].toLowerCase();
|
||||||
|
if (cmd1 === "l") {
|
||||||
|
chatBarChannel = "Local";
|
||||||
|
msg = "";
|
||||||
|
}
|
||||||
|
if (cmd1 === "d") {
|
||||||
|
chatBarChannel = "Domain";
|
||||||
|
msg = "";
|
||||||
|
}
|
||||||
|
if (cmd1 === "g") {
|
||||||
|
chatBarChannel = "Grid";
|
||||||
|
msg = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd1 === "goto") {
|
||||||
|
gotoConfirm(commandList[1]);
|
||||||
|
msg = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cmd1 === "me") {
|
||||||
|
var tempList = commandList;
|
||||||
|
tempList.shift();
|
||||||
|
msg = cmd.avatarName + " " + tempList.join(" ");
|
||||||
|
cmd.avatarName = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmd.message = msg;
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
function onWebEventReceived(event) {
|
function onWebEventReceived(event) {
|
||||||
event = JSON.parse(event);
|
event = JSON.parse(event);
|
||||||
if (event.type === "ready") {
|
if (event.type === "ready") {
|
||||||
|
@ -189,10 +234,7 @@ function onWebEventReceived(event) {
|
||||||
chatHistory.setPosition({x: 0, y: Window.innerHeight - 700});
|
chatHistory.setPosition({x: 0, y: Window.innerHeight - 700});
|
||||||
}
|
}
|
||||||
if (event.cmd === "GOTO") {
|
if (event.cmd === "GOTO") {
|
||||||
var result = Window.confirm("Do you want to goto " + event.url.split("/")[2] + " ?");
|
gotoConfirm(event.url);
|
||||||
if (result) {
|
|
||||||
location = event.url;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (event.cmd === "URL") {
|
if (event.cmd === "URL") {
|
||||||
new OverlayWebWindow({
|
new OverlayWebWindow({
|
||||||
|
@ -208,6 +250,8 @@ function onWebEventReceived(event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (event.type === "WEBMSG") {
|
if (event.type === "WEBMSG") {
|
||||||
|
event.avatarName = MyAvatar.displayName;
|
||||||
|
event = processChat(event);
|
||||||
if (event.message === "") return;
|
if (event.message === "") return;
|
||||||
sendWS({
|
sendWS({
|
||||||
uuid: "",
|
uuid: "",
|
||||||
|
@ -215,10 +259,12 @@ function onWebEventReceived(event) {
|
||||||
channel: event.tab,
|
channel: event.tab,
|
||||||
colour: chatColour(event.tab),
|
colour: chatColour(event.tab),
|
||||||
message: event.message,
|
message: event.message,
|
||||||
displayName: MyAvatar.displayName
|
displayName: event.avatarName
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (event.type === "MSG") {
|
if (event.type === "MSG") {
|
||||||
|
event.avatarName = MyAvatar.displayName;
|
||||||
|
event = processChat(event);
|
||||||
if (event.message === "") return;
|
if (event.message === "") return;
|
||||||
Messages.sendMessage("Chat", JSON.stringify({
|
Messages.sendMessage("Chat", JSON.stringify({
|
||||||
type: "TransmitChatMessage",
|
type: "TransmitChatMessage",
|
||||||
|
@ -226,7 +272,7 @@ function onWebEventReceived(event) {
|
||||||
channel: event.tab,
|
channel: event.tab,
|
||||||
colour: chatColour(event.tab),
|
colour: chatColour(event.tab),
|
||||||
message: event.message,
|
message: event.message,
|
||||||
displayName: MyAvatar.displayName
|
displayName: event.avatarName
|
||||||
}));
|
}));
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +288,7 @@ function replaceFormatting(text) {
|
||||||
var part1 = text.substring(0, firstMatch - 2);
|
var part1 = text.substring(0, firstMatch - 2);
|
||||||
var part2 = text.substring(firstMatch, secondMatch);
|
var part2 = text.substring(firstMatch, secondMatch);
|
||||||
var part3 = text.substring(secondMatch + 2);
|
var part3 = text.substring(secondMatch + 2);
|
||||||
text = part1 + "<i>" + part2 + "</i>" + part3;
|
text = part1 + "<b>" + part2 + "</b>" + part3;
|
||||||
}
|
}
|
||||||
} else if (text.indexOf("*") !== -1) {
|
} else if (text.indexOf("*") !== -1) {
|
||||||
var firstMatch = text.indexOf("*") + 1;
|
var firstMatch = text.indexOf("*") + 1;
|
||||||
|
@ -252,7 +298,7 @@ function replaceFormatting(text) {
|
||||||
var part1 = text.substring(0, firstMatch - 1);
|
var part1 = text.substring(0, firstMatch - 1);
|
||||||
var part2 = text.substring(firstMatch, secondMatch);
|
var part2 = text.substring(firstMatch, secondMatch);
|
||||||
var part3 = text.substring(secondMatch + 1);
|
var part3 = text.substring(secondMatch + 1);
|
||||||
text = part1 + "<b>" + part2 + "</b>" + part3;
|
text = part1 + "<i>" + part2 + "</i>" + part3;
|
||||||
}
|
}
|
||||||
} else if (text.indexOf("__") !== -1) {
|
} else if (text.indexOf("__") !== -1) {
|
||||||
var firstMatch = text.indexOf("__") + 2;
|
var firstMatch = text.indexOf("__") + 2;
|
||||||
|
@ -386,28 +432,37 @@ function fromQml(message) {
|
||||||
if (cmd.type === "MSG") {
|
if (cmd.type === "MSG") {
|
||||||
if (cmd.message !== "") {
|
if (cmd.message !== "") {
|
||||||
if (cmd.event.modifiers === CONTROL_KEY) {
|
if (cmd.event.modifiers === CONTROL_KEY) {
|
||||||
|
cmd.avatarName = MyAvatar.displayName;
|
||||||
|
cmd = processChat(cmd);
|
||||||
|
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: MyAvatar.displayName
|
displayName: cmd.avatarName
|
||||||
}));
|
}));
|
||||||
} else if (cmd.event.modifiers === CONTROL_KEY + SHIFT_KEY) {
|
} else if (cmd.event.modifiers === CONTROL_KEY + SHIFT_KEY) {
|
||||||
|
cmd.avatarName = MyAvatar.displayName;
|
||||||
|
cmd = processChat(cmd);
|
||||||
|
if (cmd.message === "") return;
|
||||||
sendWS({
|
sendWS({
|
||||||
uuid: "",
|
uuid: "",
|
||||||
type: "WebChat",
|
type: "WebChat",
|
||||||
channel: "Grid",
|
channel: "Grid",
|
||||||
colour: chatColour("Grid"),
|
colour: chatColour("Grid"),
|
||||||
message: cmd.message,
|
message: cmd.message,
|
||||||
displayName: MyAvatar.displayName
|
displayName: cmd.avatarName
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
cmd.avatarName = MyAvatar.displayName;
|
||||||
|
cmd = processChat(cmd);
|
||||||
|
if (cmd.message === "") return;
|
||||||
Messages.sendMessage(FLOOF_CHAT_CHANNEL, JSON.stringify({
|
Messages.sendMessage(FLOOF_CHAT_CHANNEL, JSON.stringify({
|
||||||
type: "TransmitChatMessage",
|
type: "TransmitChatMessage",
|
||||||
channel: "Local",
|
channel: chatBarChannel,
|
||||||
position: MyAvatar.position,
|
position: MyAvatar.position,
|
||||||
colour: chatColour("Local"),
|
colour: chatColour(chatBarChannel),
|
||||||
message: cmd.message,
|
message: cmd.message,
|
||||||
displayName: MyAvatar.displayName
|
displayName: cmd.avatarName
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue