Torque3D/Templates/BaseGame/game/data/ui/scripts/joinServerMenu.cs
Areloch 1ed8b05169 Initial implementation of the new Base Game Template and some starting modules.
This makes some tweaks to the engine to support this, specifically, it tweaks the hardcoded shaderpaths to defer to a pref variable, so none of the shader paths are hardcoded.

Also tweaks how post effects read in texture files, removing a bizzare filepath interpretation choice, where if the file path didn't start with "/" it forcefully appended the script's file path. This made it impossible to have images not in the same dir as the script file defining the post effect.

This was changed and the existing template's post effects tweaked for now to just add "./" to those few paths impacted, as well as the perf vars to support the non-hardcoded shader paths in the engine.
2017-02-24 02:40:56 -06:00

144 lines
3.8 KiB
C#

function JoinServerMenu::onWake()
{
// Double check the status. Tried setting this the control
// inactive to start with, but that didn't seem to work.
JoinServerJoinBtn.setActive(JS_serverList.rowCount() > 0);
}
//----------------------------------------
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= JS_serverList.getSelectedId();
// 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::exit(%this)
{
cancelServerQuery();
Canvas.popDialog(JoinServerMenu);
}
//----------------------------------------
function JoinServerMenu::update(%this)
{
// Copy the servers into the server list.
JS_queryStatus.setVisible(false);
JS_serverList.clear();
%sc = getServerCount();
for( %i = 0; %i < %sc; %i ++ ) {
setServerInfo(%i);
JS_serverList.addRow( %i,
$ServerInfo::Name TAB
$ServerInfo::Ping TAB
$ServerInfo::PlayerCount @ "/" @ $ServerInfo::MaxPlayers TAB
$ServerInfo::Version TAB
$ServerInfo::MissionName
);
}
JS_serverList.sort(0);
JS_serverList.setSelectedRow(0);
JS_serverList.scrollVisible(0);
JoinServerJoinBtn.setActive(JS_serverList.rowCount() > 0);
}
//----------------------------------------
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":
JoinServerJoinBtn.setActive(false);
JoinServerQryInternetBtn.setActive(false);
JS_statusText.setText(%msg);
JS_statusBar.setValue(0);
JS_serverList.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":
JoinServerQryInternetBtn.setActive(true);
JS_queryStatus.setVisible(false);
JS_status.setText(%msg);
JoinServerMenu.update();
}
}