mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
246 lines
7 KiB
Plaintext
246 lines
7 KiB
Plaintext
|
|
function JoinServerMenu::onWake(%this)
|
|
{
|
|
$MenuList = JoinServerList;
|
|
JoinServerList.listPosition = 0;
|
|
}
|
|
|
|
if(!isObject( JoinServerActionMap ) )
|
|
{
|
|
new ActionMap(JoinServerActionMap){};
|
|
|
|
JoinServerActionMap.bindCmd( keyboard, q, "JoinServerMenu.query();" );
|
|
JoinServerActionMap.bindCmd( gamepad, btn_x, "JoinServerMenu.query();" );
|
|
|
|
JoinServerActionMap.bindCmd( keyboard, e, "JoinServerMenu.queryLan();" );
|
|
JoinServerActionMap.bindCmd( gamepad, btn_y, "JoinServerMenu.queryLan();" );
|
|
}
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::query(%this)
|
|
{
|
|
queryMasterServer(
|
|
0, // Query flags
|
|
$Client::GameTypeQuery, // gameTypes
|
|
$Client::MissionTypeQuery, // missionType
|
|
0, // minPlayers
|
|
100, // maxPlayers
|
|
0, // maxBots
|
|
2, // regionMask
|
|
0, // maxPing
|
|
100, // minCPU
|
|
0 // filterFlags
|
|
);
|
|
}
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::queryLan(%this)
|
|
{
|
|
queryLANServers(
|
|
$pref::Net::Port, // lanPort for local queries
|
|
0, // Query flags
|
|
$Client::GameTypeQuery, // gameTypes
|
|
$Client::MissionTypeQuery, // missionType
|
|
0, // minPlayers
|
|
100, // maxPlayers
|
|
0, // maxBots
|
|
2, // regionMask
|
|
0, // maxPing
|
|
100, // minCPU
|
|
0 // filterFlags
|
|
);
|
|
}
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::cancel(%this)
|
|
{
|
|
cancelServerQuery();
|
|
JS_queryStatus.setVisible(false);
|
|
}
|
|
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::join(%this)
|
|
{
|
|
cancelServerQuery();
|
|
%index = JS_serverList.getSelectedId();
|
|
|
|
JoinGame(%index);
|
|
}
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::refresh(%this)
|
|
{
|
|
cancelServerQuery();
|
|
%index= JoinServerList.getActiveRow();
|
|
|
|
// The server info index is stored in the row along with the
|
|
// rest of displayed info.
|
|
if( setServerInfo( %index ) )
|
|
querySingleServer( $ServerInfo::Address, 0 );
|
|
}
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::refreshSelectedServer( %this )
|
|
{
|
|
querySingleServer( $JoinGameAddress, 0 );
|
|
}
|
|
|
|
//----------------------------------------
|
|
function JoinServerMenu::update(%this)
|
|
{
|
|
// Copy the servers into the server list.
|
|
JS_queryStatus.setVisible(false);
|
|
JoinServerList.clear();
|
|
%sc = getServerCount();
|
|
for( %i = 0; %i < %sc; %i ++ ) {
|
|
setServerInfo(%i);
|
|
|
|
%serverEntry = %this.addServerEntry();
|
|
%serverEntry-->serverNameTxt.text = $ServerInfo::Name;
|
|
%serverEntry-->serverDetailsTxt.text = $ServerInfo::Version @ " | " @ $ServerInfo::MissionName @ " | " @ $ServerInfo::MissionType;
|
|
%serverEntry-->pingTxt.text = $ServerInfo::Ping @ " ms";
|
|
%serverEntry-->playerCountTxt.text = $ServerInfo::PlayerCount @ "|" @ $ServerInfo::MaxPlayers;
|
|
|
|
%serverEntry.resize(0, 0, JoinServerList.extent.x, %serverEntry.extent.y);
|
|
|
|
JoinServerList.add(%serverEntry);
|
|
}
|
|
}
|
|
|
|
//----------------------------------------
|
|
function onServerQueryStatus(%status, %msg, %value)
|
|
{
|
|
echo("ServerQuery: " SPC %status SPC %msg SPC %value);
|
|
// Update query status
|
|
// States: start, update, ping, query, done
|
|
// value = % (0-1) done for ping and query states
|
|
if (!JS_queryStatus.isVisible())
|
|
JS_queryStatus.setVisible(true);
|
|
|
|
switch$ (%status) {
|
|
case "start":
|
|
JS_statusText.setText(%msg);
|
|
JS_statusBar.setValue(0);
|
|
JoinServerList.clear();
|
|
|
|
case "ping":
|
|
JS_statusText.setText("Ping Servers");
|
|
JS_statusBar.setValue(%value);
|
|
|
|
case "query":
|
|
JS_statusText.setText("Query Servers");
|
|
JS_statusBar.setValue(%value);
|
|
|
|
case "done":
|
|
JS_queryStatus.setVisible(false);
|
|
JS_status.setText(%msg);
|
|
JoinServerMenu.update();
|
|
}
|
|
}
|
|
|
|
function JoinServerMenu::addServerEntry(%this)
|
|
{
|
|
%entry = new GuiContainer() {
|
|
position = "0 0";
|
|
extent = "900 40";
|
|
profile = GuiMenuDefaultProfile;
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
horizSizing = "width";
|
|
vertSizing = "bottom";
|
|
class = "JoinServerServerEntry";
|
|
|
|
new GuiButtonCtrl() {
|
|
profile = GuiMenuButtonProfile;
|
|
position = "0 0";
|
|
extent = "900 40";
|
|
horizSizing = "width";
|
|
vertSizing = "height";
|
|
internalName = "button";
|
|
};
|
|
|
|
new GuiTextCtrl() {
|
|
position = "0 0";
|
|
extent = "730 20";
|
|
profile = "MenuSubHeaderText";
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
internalName = "serverNameTxt";
|
|
};
|
|
new GuiTextCtrl() {
|
|
position = $optionsEntryPad SPC 17;
|
|
extent = "730 18";
|
|
profile = "GuiMLTextProfile";
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
internalName = "serverDetailsTxt";
|
|
};
|
|
|
|
new GuiTextCtrl() {
|
|
position = "730 0";
|
|
extent = "50 40";
|
|
horizSizing = "left";
|
|
vertSizing = "center";
|
|
profile = "MenuSubHeaderText";
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
internalName = "pingTxt";
|
|
};
|
|
|
|
new GuiTextCtrl() {
|
|
position = "780 0";
|
|
extent = "120 40";
|
|
horizSizing = "left";
|
|
vertSizing = "center";
|
|
profile = "MenuSubHeaderText";
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
internalName = "playerCountTxt";
|
|
};
|
|
};
|
|
|
|
return %entry;
|
|
}
|
|
|
|
function JoinServerMenu::addStatusEntry(%this)
|
|
{
|
|
%entry = new GuiContainer() {
|
|
position = "0 0";
|
|
extent = "900 40";
|
|
profile = GuiMenuDefaultProfile;
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
horizSizing = "width";
|
|
vertSizing = "bottom";
|
|
class = "JoinServerStatusEntry";
|
|
|
|
new GuiTextCtrl() {
|
|
position = "0 0";
|
|
extent = "730 20";
|
|
profile = "MenuSubHeaderCenteredText";
|
|
tooltipProfile = "GuiToolTipProfile";
|
|
internalName = "statusTxt";
|
|
};
|
|
};
|
|
|
|
return %entry;
|
|
}
|
|
|
|
function JoinServerList::syncGui(%this)
|
|
{
|
|
%this.callOnChildren("setHighlighted", false);
|
|
|
|
if(%this.listPosition < %this.getCount())
|
|
{
|
|
%btn = %this.getObject(%this.listPosition);
|
|
%btn-->button.setHighlighted(true);
|
|
}
|
|
|
|
//
|
|
//Update the button imagery to comply to the last input device we'd used
|
|
%device = Canvas.getLastInputDevice();
|
|
if(%device $= "mouse")
|
|
%device = "keyboard";
|
|
|
|
JoinServerBackBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIBackOut"));
|
|
JoinServerJoinBtn.setBitmap(BaseUIActionMap.getCommandButtonBitmap(%device, "BaseUIActivateSelected"));
|
|
JoinServerQLanBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.queryLan();"));
|
|
JoinServerQServerBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.query();"));
|
|
|
|
//JoinServerJoinBtn.setActive($selectedLevelAsset !$= "");
|
|
} |