| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272 |
- function JoinServerMenu::onWake(%this)
- {
- $MenuList = JoinServerList;
- JoinServerList.listPosition = 0;
-
- JoinServerList.syncGui();
- }
- 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();" );
-
- JoinServerActionMap.bindCmd( keyboard, Enter, "JoinServerMenu::join();" );
- JoinServerActionMap.bindCmd( gamepad, btn_a, "JoinServerMenu::join();" );
- }
- //----------------------------------------
- function JoinServerMenu::query(%this)
- {
- //Nuke the current list and indicate we're working on a query...
- JoinServerList.clear();
-
- 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)
- {
- //Nuke the current list and indicate we're working on a query...
- JoinServerList.clear();
-
- 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();
- JoinGame(JoinServerList.listPosition);
- }
- //----------------------------------------
- function JoinServerMenu::refresh(%this)
- {
- cancelServerQuery();
- %index = JoinServerList.listPosition;
- // 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::MissionName @ " | v" @ $ServerInfo::Version @ " | " @ $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);
- }
-
- JoinServerList.syncGui();
- }
- //----------------------------------------
- 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":
- MessagePopup("", %msg, 5000);
- JoinServerList.clear();
- case "ping":
- MessagePopup("", "Pinging Servers", 5000);
- case "query":
- MessagePopup("", "Querying Servers", 5000);
- case "done":
- MessagePopup("", %msg, 1000);
- 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";
- class = "JoinServerEntryButton";
- };
- new GuiTextCtrl() {
- position = "0 0";
- extent = "700 20";
- profile = "MenuSubHeaderText";
- tooltipProfile = "GuiToolTipProfile";
- internalName = "serverNameTxt";
- };
- new GuiTextCtrl() {
- position = $optionsEntryPad SPC 17;
- extent = "700 18";
- profile = "GuiMLTextProfile";
- tooltipProfile = "GuiToolTipProfile";
- internalName = "serverDetailsTxt";
- };
-
- new GuiTextCtrl() {
- position = "700 0";
- extent = "70 40";
- horizSizing = "left";
- vertSizing = "center";
- profile = "MenuSubHeaderCenteredText";
- tooltipProfile = "GuiToolTipProfile";
- internalName = "pingTxt";
- };
-
- new GuiTextCtrl() {
- position = "770 0";
- extent = "130 40";
- horizSizing = "left";
- vertSizing = "center";
- profile = "MenuSubHeaderCenteredText";
- tooltipProfile = "GuiToolTipProfile";
- internalName = "playerCountTxt";
- };
- };
-
- return %entry;
- }
- function JoinServerEntryButton::onHighlighted(%this, %highlighted)
- {
- %container = %this.getParent();
-
- %container-->serverNameTxt.profile = %highlighted ? MenuSubHeaderTextHighlighted : MenuSubHeaderText;
- %container-->serverDetailsTxt.profile = %highlighted ? GuiMLTextProfileHighlighted : GuiMLTextProfile;
- %container-->pingTxt.profile = %highlighted ? MenuSubHeaderCenteredTextHighlighted : MenuSubHeaderCenteredText;
- %container-->playerCountTxt.profile = %highlighted ? MenuSubHeaderCenteredTextHighlighted : MenuSubHeaderCenteredText;
- }
- 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 JoinServerStatusEntry::updateProgress(%this)
- {
- %this-->statusText.text = %this-->statusText.text @ "."; //ellipses.......
-
- %this.schedule(500, "updateProgress");
- }
- 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(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu::join();"));
- JoinServerQLanBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.queryLan();"));
- JoinServerQServerBtn.setBitmap(JoinServerActionMap.getCommandButtonBitmap(%device, "JoinServerMenu.query();"));
-
-
- JoinServerJoinBtn.setActive(JoinServerList.getCount() > 0);
- }
|