mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 13:58:51 +02:00
Add goto json support (defaults to darlings goto), gotos (gotosudo) which bypasses the popup window and added history to the main chatbar so you can press up/down on there
This commit is contained in:
parent
64149af8ce
commit
bc35ef5776
2 changed files with 88 additions and 16 deletions
|
@ -28,13 +28,18 @@ var appUUID = Uuid.generate();
|
||||||
|
|
||||||
var chatBar;
|
var chatBar;
|
||||||
var chatHistory;
|
var chatHistory;
|
||||||
|
var chatBarHistoryLimit = Settings.getValue(settingsRoot + "/chatBarHistoryLimit", 256);
|
||||||
|
var chatHistoryLimit = Settings.getValue(settingsRoot + "/chatHistoryLimit", 500);
|
||||||
|
var chatBarHistory = Settings.getValue(settingsRoot + "/chatBarHistory", ["Meow :3"]);
|
||||||
var historyLog = [];
|
var historyLog = [];
|
||||||
|
|
||||||
|
|
||||||
var visible = false;
|
var visible = false;
|
||||||
var historyVisible = false;
|
var historyVisible = false;
|
||||||
var settingsRoot = "FloofChat";
|
var settingsRoot = "FloofChat";
|
||||||
|
|
||||||
|
var darlingGotoUrl = "http://metaverse.darlingvr.club:8081/goto.json";
|
||||||
|
var gotoJSONUrl = Settings.getValue(settingsRoot + "/gotoJSONUrl", darlingGotoUrl);
|
||||||
|
|
||||||
var muted = Settings.getValue(settingsRoot + "/muted", {"Local": false, "Domain": false, "Grid": false});
|
var muted = Settings.getValue(settingsRoot + "/muted", {"Local": false, "Domain": false, "Grid": false});
|
||||||
|
|
||||||
var ws;
|
var ws;
|
||||||
|
@ -69,7 +74,7 @@ function init() {
|
||||||
|
|
||||||
button.clicked.connect(toggleChatHistory);
|
button.clicked.connect(toggleChatHistory);
|
||||||
chatBar.fromQml.connect(fromQml);
|
chatBar.fromQml.connect(fromQml);
|
||||||
chatBar.sendToQml(JSON.stringify({visible: false}));
|
chatBar.sendToQml(JSON.stringify({visible: false, history: chatBarHistory}));
|
||||||
Controller.keyPressEvent.connect(keyPressEvent);
|
Controller.keyPressEvent.connect(keyPressEvent);
|
||||||
Messages.messageReceived.connect(messageReceived);
|
Messages.messageReceived.connect(messageReceived);
|
||||||
|
|
||||||
|
@ -172,42 +177,72 @@ function chatColour(tab) {
|
||||||
|
|
||||||
var chatBarChannel = "Local";
|
var chatBarChannel = "Local";
|
||||||
|
|
||||||
|
function go2(msg) {
|
||||||
|
var dest = false;
|
||||||
|
var domainsList = Script.require("http://metaverse.darlingvr.club:8081/goto.json");
|
||||||
|
domainsList.forEach(function (domain) {
|
||||||
|
if (domain["Domain Name"].toLowerCase().indexOf(msg.toLowerCase()) !== -1) {
|
||||||
|
dest = {"name": domain["Domain Name"], "url": domain["Visit"]};
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
function gotoConfirm(url) {
|
function gotoConfirm(url, name, confirm) {
|
||||||
var result = Window.confirm("Do you want to go to '" + ((url.indexOf("/") !== -1) ? url.split("/")[2] : url) + "'?");
|
confirm = confirm === undefined ? true : confirm;
|
||||||
|
name = name === undefined ? url : name;
|
||||||
|
var result = true;
|
||||||
|
if (confirm) {
|
||||||
|
result = Window.confirm("Do you want to go to '" + ((name.indexOf("/") !== -1) ? url.split("/")[2] : name) + "'?");
|
||||||
|
}
|
||||||
if (result) {
|
if (result) {
|
||||||
location = url;
|
location = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function processChat(cmd) {
|
function processChat(cmd) {
|
||||||
|
|
||||||
|
function commandResult() {
|
||||||
|
msg = "";
|
||||||
|
setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
var msg = cmd.message;
|
var msg = cmd.message;
|
||||||
if (msg.indexOf("/") === 0) {
|
if (msg.indexOf("/") === 0) {
|
||||||
msg = msg.substring(1);
|
msg = msg.substring(1);
|
||||||
var commandList = msg.split(" ");
|
var commandList = msg.split(" ");
|
||||||
|
var tempList = commandList.join(";'#[]").split(";'#[]");
|
||||||
|
tempList.shift();
|
||||||
|
var restOfMsg = tempList.join(" ");
|
||||||
|
|
||||||
|
msg = "/" + msg;
|
||||||
var cmd1 = commandList[0].toLowerCase();
|
var cmd1 = commandList[0].toLowerCase();
|
||||||
if (cmd1 === "l") {
|
if (cmd1 === "l") {
|
||||||
chatBarChannel = "Local";
|
chatBarChannel = "Local";
|
||||||
msg = "";
|
commandResult();
|
||||||
}
|
}
|
||||||
if (cmd1 === "d") {
|
if (cmd1 === "d") {
|
||||||
chatBarChannel = "Domain";
|
chatBarChannel = "Domain";
|
||||||
msg = "";
|
commandResult();
|
||||||
}
|
}
|
||||||
if (cmd1 === "g") {
|
if (cmd1 === "g") {
|
||||||
chatBarChannel = "Grid";
|
chatBarChannel = "Grid";
|
||||||
msg = "";
|
commandResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd1 === "goto") {
|
if (cmd1 === "goto" || cmd1 === "gotos") {
|
||||||
gotoConfirm(commandList[1]);
|
var result = go2(restOfMsg);
|
||||||
msg = "";
|
if (result) {
|
||||||
|
gotoConfirm(result.url, result.name, (cmd1 === "goto"));
|
||||||
|
} else {
|
||||||
|
gotoConfirm(commandList[1], undefined, (cmd1 === "goto"));
|
||||||
|
}
|
||||||
|
commandResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cmd1 === "me") {
|
if (cmd1 === "me") {
|
||||||
var tempList = commandList;
|
msg = cmd.avatarName + " " + restOfMsg;
|
||||||
tempList.shift();
|
|
||||||
msg = cmd.avatarName + " " + tempList.join(" ");
|
|
||||||
cmd.avatarName = "";
|
cmd.avatarName = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -415,12 +450,20 @@ function time() {
|
||||||
function addToLog(msg, dp, colour, tab) {
|
function addToLog(msg, dp, colour, tab) {
|
||||||
historyLog.push([time(), msg, dp, colour, tab]);
|
historyLog.push([time(), msg, dp, colour, tab]);
|
||||||
chatHistory.emitScriptEvent(JSON.stringify({type: "MSG", data: [[time(), msg, dp, colour, tab]]}));
|
chatHistory.emitScriptEvent(JSON.stringify({type: "MSG", data: [[time(), msg, dp, colour, tab]]}));
|
||||||
while (historyLog.length > 500) {
|
while (historyLog.length > chatHistoryLimit) {
|
||||||
historyLog.shift();
|
historyLog.shift();
|
||||||
}
|
}
|
||||||
Settings.setValue(settingsRoot + "/HistoryLog", JSON.stringify(historyLog))
|
Settings.setValue(settingsRoot + "/HistoryLog", JSON.stringify(historyLog))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addToChatBarHistory(msg) {
|
||||||
|
chatBarHistory.unshift(cmd.message);
|
||||||
|
while (chatBarHistory.length > chatBarHistoryLimit) {
|
||||||
|
chatBarHistory.pop();
|
||||||
|
}
|
||||||
|
Settings.setValue(settingsRoot + "/chatBarHistory", chatBarHistory);
|
||||||
|
}
|
||||||
|
|
||||||
function fromQml(message) {
|
function fromQml(message) {
|
||||||
var cmd = {FAILED: true};
|
var cmd = {FAILED: true};
|
||||||
try {
|
try {
|
||||||
|
@ -431,6 +474,7 @@ function fromQml(message) {
|
||||||
if (!cmd.FAILED) {
|
if (!cmd.FAILED) {
|
||||||
if (cmd.type === "MSG") {
|
if (cmd.type === "MSG") {
|
||||||
if (cmd.message !== "") {
|
if (cmd.message !== "") {
|
||||||
|
addToChatBarHistory(cmd.message);
|
||||||
if (cmd.event.modifiers === CONTROL_KEY) {
|
if (cmd.event.modifiers === CONTROL_KEY) {
|
||||||
cmd.avatarName = MyAvatar.displayName;
|
cmd.avatarName = MyAvatar.displayName;
|
||||||
cmd = processChat(cmd);
|
cmd = processChat(cmd);
|
||||||
|
|
|
@ -11,6 +11,8 @@ Rectangle {
|
||||||
Binding { target: window; property: 'shown'; value: false; when: Boolean(window) }
|
Binding { target: window; property: 'shown'; value: false; when: Boolean(window) }
|
||||||
Component.onDestruction: thing && thing.destroy()
|
Component.onDestruction: thing && thing.destroy()
|
||||||
|
|
||||||
|
property var hist : -1;
|
||||||
|
property var history : [];
|
||||||
|
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
|
@ -40,6 +42,9 @@ Rectangle {
|
||||||
thing.visible = false;
|
thing.visible = false;
|
||||||
textArea.focus = false;
|
textArea.focus = false;
|
||||||
}
|
}
|
||||||
|
if(data.history){
|
||||||
|
history = data.history;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,13 +69,36 @@ Rectangle {
|
||||||
clip: false
|
clip: false
|
||||||
font.pointSize: 20
|
font.pointSize: 20
|
||||||
|
|
||||||
function _onEnterPressed(event)
|
function _onEnterPressed(event){
|
||||||
{
|
|
||||||
sendMessage(JSON.stringify({type:"MSG",message:text,event:event}));
|
sendMessage(JSON.stringify({type:"MSG",message:text,event:event}));
|
||||||
|
history.unshift(text);
|
||||||
text = "";
|
text = "";
|
||||||
|
hist = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function upPressed(event){
|
||||||
|
hist++;
|
||||||
|
if(hist > history.length-1){
|
||||||
|
hist = history.length-1;
|
||||||
|
}
|
||||||
|
text = history[hist];
|
||||||
|
}
|
||||||
|
function downPressed(event){
|
||||||
|
hist--;
|
||||||
|
if(hist<-1){
|
||||||
|
hist = -1;
|
||||||
|
}
|
||||||
|
if(hist===-1){
|
||||||
|
text = "";
|
||||||
|
} else{
|
||||||
|
text = history[hist];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Keys.onReturnPressed: { _onEnterPressed(event) }
|
Keys.onReturnPressed: { _onEnterPressed(event) }
|
||||||
Keys.onEnterPressed: { _onEnterPressed(event) }
|
Keys.onEnterPressed: { _onEnterPressed(event) }
|
||||||
|
Keys.onUpPressed: { upPressed(event) }
|
||||||
|
Keys.onDownPressed: { downPressed(event) }
|
||||||
}
|
}
|
||||||
|
|
||||||
MouseArea {
|
MouseArea {
|
||||||
|
|
Loading…
Reference in a new issue