Use new multiplayer commands in gui
This commit is contained in:
parent
419ae89ae2
commit
6ae95ea10a
3 changed files with 50 additions and 62 deletions
|
@ -76,16 +76,10 @@
|
||||||
gui.dialog_update("multiplayer", "host");
|
gui.dialog_update("multiplayer", "host");
|
||||||
}
|
}
|
||||||
|
|
||||||
# listen for results arriving
|
# listen for results arriving
|
||||||
setlistener("/sim/multiplay/got-servers", updateServers);
|
setlistener("/sim/multiplay/got-servers", updateServers);
|
||||||
setlistener("/sim/multiplay/get-servers-failure", updateServersFailed);
|
setlistener("/sim/multiplay/get-servers-failure", updateServersFailed);
|
||||||
|
fgcommand("multiplayer-refreshserverlist");
|
||||||
fgcommand("xmlhttprequest", props.Node.new({
|
|
||||||
"url" : "http://liveries.flightgear.org/mpstatus/mpservers.xml",
|
|
||||||
"targetnode" : "/sim/multiplay/server-list",
|
|
||||||
"complete" : "/sim/multiplay/got-servers",
|
|
||||||
"failure" : "/sim/multiplay/get-servers-failure"
|
|
||||||
}));
|
|
||||||
]]>
|
]]>
|
||||||
</open>
|
</open>
|
||||||
|
|
||||||
|
@ -235,21 +229,11 @@
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>nasal</command>
|
||||||
<script>
|
<script>
|
||||||
var server = getprop("/sim/multiplay/selected-server");
|
fgcommand("multiplayer-connect", props.Node.new({
|
||||||
# Get the server name by splitting on the space between
|
"servername": getprop("/sim/multiplay/selected-server")
|
||||||
# the hostname and the comment.
|
}));
|
||||||
server = split(" ", server)[0];
|
|
||||||
setprop("/sim/multiplay/txhost", server);
|
|
||||||
|
|
||||||
# Standard port is 5000
|
|
||||||
setprop("/sim/multiplay/txport", 5000);
|
|
||||||
setprop("/sim/multiplay/rxport", 5000);
|
|
||||||
</script>
|
</script>
|
||||||
</binding>
|
</binding>
|
||||||
<binding>
|
|
||||||
<command>reinit</command>
|
|
||||||
<subsystem>mp</subsystem>
|
|
||||||
</binding>
|
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<button>
|
<button>
|
||||||
|
@ -262,13 +246,7 @@
|
||||||
<command>dialog-apply</command>
|
<command>dialog-apply</command>
|
||||||
</binding>
|
</binding>
|
||||||
<binding>
|
<binding>
|
||||||
<command>nasal</command>
|
<command>multiplayer-disconnect</command>
|
||||||
<script>
|
|
||||||
setprop("/sim/multiplay/txhost", "");
|
|
||||||
</script>
|
|
||||||
</binding>
|
|
||||||
<binding>
|
|
||||||
<command>reinit</command>
|
|
||||||
<subsystem>mp</subsystem>
|
<subsystem>mp</subsystem>
|
||||||
</binding>
|
</binding>
|
||||||
</button>
|
</button>
|
||||||
|
|
|
@ -2,11 +2,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
(function(factory) {
|
(function(factory) {
|
||||||
if (typeof define === "function" && define.amd)// AMD. Register as an anonymous module.
|
if (typeof define === "function" && define.amd)// AMD. Register as an
|
||||||
define([
|
// anonymous module.
|
||||||
'jquery'
|
define([
|
||||||
], factory); else // Browser globals
|
'jquery'
|
||||||
factory(jQuery);
|
], factory);
|
||||||
|
else
|
||||||
|
// Browser globals
|
||||||
|
factory(jQuery);
|
||||||
}(function(jquery) {
|
}(function(jquery) {
|
||||||
|
|
||||||
fgCommand = {
|
fgCommand = {
|
||||||
|
@ -79,11 +82,13 @@
|
||||||
name : '',
|
name : '',
|
||||||
children : []
|
children : []
|
||||||
};
|
};
|
||||||
if (typeof (subsys) === 'string')arg.children.push({
|
if (typeof (subsys) === 'string')
|
||||||
name : 'subsystem',
|
arg.children.push({
|
||||||
index : 0,
|
name : 'subsystem',
|
||||||
value : subsys
|
index : 0,
|
||||||
});else
|
value : subsys
|
||||||
|
});
|
||||||
|
else
|
||||||
subsys.forEach(function(s, i) {
|
subsys.forEach(function(s, i) {
|
||||||
arg.children.push({
|
arg.children.push({
|
||||||
name : 'subsystem',
|
name : 'subsystem',
|
||||||
|
@ -114,34 +119,39 @@
|
||||||
this.sendCommand("request-metar", this.twoArgs("station", id, "path", path));
|
this.sendCommand("request-metar", this.twoArgs("station", id, "path", path));
|
||||||
},
|
},
|
||||||
|
|
||||||
multiplayer : function(cmd) {
|
multiplayerConnect : function(cmd) {
|
||||||
cmd = cmd || {};
|
cmd = cmd || {};
|
||||||
var arg = {
|
var arg = {
|
||||||
'name' : '',
|
'name' : '',
|
||||||
'children' : [
|
'children' : [],
|
||||||
{
|
|
||||||
'name' : 'command',
|
|
||||||
'value' : '',
|
|
||||||
'index' : 0,
|
|
||||||
}
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
if (cmd.connect) {
|
arg.children.push({
|
||||||
arg.children[0].value = 'connect';
|
'name' : 'servername',
|
||||||
|
'value' : cmd.servername
|
||||||
|
});
|
||||||
|
if (cmd.rxport)
|
||||||
arg.children.push({
|
arg.children.push({
|
||||||
'name' : 'servername',
|
|
||||||
'value' : cmd.connect.servername
|
|
||||||
});
|
|
||||||
if (cmd.connect.rxport)arg.children.push({
|
|
||||||
'name' : 'rxport',
|
'name' : 'rxport',
|
||||||
'value' : Number(cmd.connect.rxport)
|
'value' : Number(cmd.rxport)
|
||||||
});
|
});
|
||||||
if (cmd.connect.txport)arg.children.push({
|
if (cmd.txport)
|
||||||
|
arg.children.push({
|
||||||
'name' : 'txport',
|
'name' : 'txport',
|
||||||
'value' : Number(cmd.connect.txport)
|
'value' : Number(cmd.txport)
|
||||||
});
|
});
|
||||||
} else if (cmd.disconnect)arg.children[0].value = 'disconnect';else if (cmd.refreshserverlist)arg.children[0].value = 'refreshserverlist';
|
this.sendCommand("multiplayer-connect", arg);
|
||||||
this.sendCommand("multiplayer", arg);
|
},
|
||||||
|
|
||||||
|
multiplayerDisconnect : function() {
|
||||||
|
var arg = {
|
||||||
|
'name' : '',
|
||||||
|
'children' : [],
|
||||||
|
};
|
||||||
|
this.sendCommand("multiplayer-disconnect");
|
||||||
|
},
|
||||||
|
|
||||||
|
multiplayerRefreshserverlist : function() {
|
||||||
|
this.sendCommand('multiplayer-refreshserverlist');
|
||||||
},
|
},
|
||||||
|
|
||||||
clearMetar : function(path) {
|
clearMetar : function(path) {
|
||||||
|
|
|
@ -57,17 +57,17 @@ define([
|
||||||
|
|
||||||
self.toggleConnect = function() {
|
self.toggleConnect = function() {
|
||||||
if( self.online() ) {
|
if( self.online() ) {
|
||||||
fgCommand.multiplayer({ disconnect: {} });
|
fgCommand.multiplayerDisconnect();
|
||||||
} else {
|
} else {
|
||||||
fgCommand.multiplayer({ connect: {
|
fgCommand.multiplayerConnect({
|
||||||
'servername': self.selectedServer(),
|
'servername': self.selectedServer(),
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.serverListVisible = ko.observable(true);
|
self.serverListVisible = ko.observable(true);
|
||||||
|
|
||||||
fgCommand.multiplayer({ refreshserverlist: {} });
|
fgCommand.multiplayerRefreshserverlist();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return component definition
|
// Return component definition
|
||||||
|
|
Loading…
Add table
Reference in a new issue