void Join(GameServer server) { if (server == null || !server.CanJoin()) { return; } var host = server.Address.Split(':')[0]; var port = Exts.ParseIntegerInvariant(server.Address.Split(':')[1]); ConnectionLogic.Connect(host, port, "", OpenLobby, DoNothing); }
void Join(GameServer server) { if (server == null || !server.CanJoin()) { return; } var host = server.Address.Split(':')[0]; var port = int.Parse(server.Address.Split(':')[1]); Ui.CloseWindow(); ConnectionLogic.Connect(host, port, OpenLobby, OnExit); }
public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit) { var panel = widget; var sl = panel.GetWidget <ScrollPanelWidget>("SERVER_LIST"); // Menu buttons var refreshButton = panel.GetWidget <ButtonWidget>("REFRESH_BUTTON"); refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.OnClick = () => { searchStatus = SearchStatus.Fetching; sl.RemoveChildren(); currentServer = null; ServerList.Query(games => RefreshServerList(panel, games)); }; var join = panel.GetWidget <ButtonWidget>("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); join.OnClick = () => { if (currentServer == null) { return; } var host = currentServer.Address.Split(':')[0]; var port = int.Parse(currentServer.Address.Split(':')[1]); Ui.CloseWindow(); ConnectionLogic.Connect(host, port, openLobby, onExit); }; panel.GetWidget <ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; // Server list serverTemplate = sl.GetWidget <ScrollItemWidget>("SERVER_TEMPLATE"); // Display the progress label over the server list // The text is only visible when the list is empty var progressText = panel.GetWidget <LabelWidget>("PROGRESS_LABEL"); progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; ServerList.Query(games => RefreshServerList(panel, games)); }
public ServerBrowserLogic(Widget widget, Action openLobby, Action onExit) { var panel = widget; OpenLobby = openLobby; OnExit = onExit; var sl = panel.Get <ScrollPanelWidget>("SERVER_LIST"); // Menu buttons var refreshButton = panel.Get <ButtonWidget>("REFRESH_BUTTON"); refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.OnClick = () => ServerList.Query(games => RefreshServerList(panel, games)); var join = panel.Get <ButtonWidget>("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); join.OnClick = () => Join(currentServer); panel.Get <ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; // Server list serverTemplate = sl.Get <ScrollItemWidget>("SERVER_TEMPLATE"); // Display the progress label over the server list // The text is only visible when the list is empty var progressText = panel.Get <LabelWidget>("PROGRESS_LABEL"); progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; var showWaitingCheckbox = panel.GetOrNull <CheckboxWidget>("WAITING_FOR_PLAYERS"); if (showWaitingCheckbox != null) { showWaitingCheckbox.IsChecked = () => showWaiting; showWaitingCheckbox.OnClick = () => { showWaiting ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; } var showEmptyCheckbox = panel.GetOrNull <CheckboxWidget>("EMPTY"); if (showEmptyCheckbox != null) { showEmptyCheckbox.IsChecked = () => showEmpty; showEmptyCheckbox.OnClick = () => { showEmpty ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; } var showAlreadyStartedCheckbox = panel.GetOrNull <CheckboxWidget>("ALREADY_STARTED"); if (showAlreadyStartedCheckbox != null) { showAlreadyStartedCheckbox.IsChecked = () => showStarted; showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; } var showIncompatibleCheckbox = panel.GetOrNull <CheckboxWidget>("INCOMPATIBLE_VERSION"); if (showIncompatibleCheckbox != null) { showIncompatibleCheckbox.IsChecked = () => showIncompatible; showIncompatibleCheckbox.OnClick = () => { showIncompatible ^= true; ServerList.Query(games => RefreshServerList(panel, games)); }; } ServerList.Query(games => RefreshServerList(panel, games)); }
public ServerBrowserLogic(Widget widget, Action onStart, Action onExit) { panel = widget; this.onStart = onStart; serverList = panel.Get <ScrollPanelWidget>("SERVER_LIST"); serverTemplate = serverList.Get <ScrollItemWidget>("SERVER_TEMPLATE"); // Menu buttons var refreshButton = panel.Get <ButtonWidget>("REFRESH_BUTTON"); refreshButton.IsDisabled = () => searchStatus == SearchStatus.Fetching; refreshButton.GetText = () => searchStatus == SearchStatus.Fetching ? "Refreshing..." : "Refresh"; refreshButton.OnClick = RefreshServerList; panel.Get <ButtonWidget>("DIRECTCONNECT_BUTTON").OnClick = OpenDirectConnectPanel; panel.Get <ButtonWidget>("CREATE_BUTTON").OnClick = OpenCreateServerPanel; var join = panel.Get <ButtonWidget>("JOIN_BUTTON"); join.IsDisabled = () => currentServer == null || !currentServer.CanJoin(); join.OnClick = () => Join(currentServer); panel.Get <ButtonWidget>("BACK_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); }; // Display the progress label over the server list // The text is only visible when the list is empty var progressText = panel.Get <LabelWidget>("PROGRESS_LABEL"); progressText.IsVisible = () => searchStatus != SearchStatus.Hidden; progressText.GetText = ProgressLabelText; var showWaitingCheckbox = panel.GetOrNull <CheckboxWidget>("WAITING_FOR_PLAYERS"); if (showWaitingCheckbox != null) { showWaitingCheckbox.IsChecked = () => showWaiting; showWaitingCheckbox.OnClick = () => { showWaiting ^= true; RefreshServerList(); }; } var showEmptyCheckbox = panel.GetOrNull <CheckboxWidget>("EMPTY"); if (showEmptyCheckbox != null) { showEmptyCheckbox.IsChecked = () => showEmpty; showEmptyCheckbox.OnClick = () => { showEmpty ^= true; RefreshServerList(); }; } var showAlreadyStartedCheckbox = panel.GetOrNull <CheckboxWidget>("ALREADY_STARTED"); if (showAlreadyStartedCheckbox != null) { showAlreadyStartedCheckbox.IsChecked = () => showStarted; showAlreadyStartedCheckbox.OnClick = () => { showStarted ^= true; RefreshServerList(); }; } var showIncompatibleCheckbox = panel.GetOrNull <CheckboxWidget>("INCOMPATIBLE_VERSION"); if (showIncompatibleCheckbox != null) { showIncompatibleCheckbox.IsChecked = () => showIncompatible; showIncompatibleCheckbox.OnClick = () => { showIncompatible ^= true; RefreshServerList(); }; } RefreshServerList(); }