extract function

This commit is contained in:
in0finite 2021-01-27 01:34:53 +01:00
parent 0d7ac7b6b4
commit b4c0df123c

View file

@ -3,6 +3,7 @@ using UnityEngine;
using SanAndreasUnity.Utilities;
using SanAndreasUnity.Net;
using System.Linq;
using System.Threading.Tasks;
namespace SanAndreasUnity.UI
{
@ -146,13 +147,7 @@ namespace SanAndreasUnity.UI
{
GUI.enabled = !_isRefreshingMasterServerList;
buttonText = _isRefreshingMasterServerList ? ( "Refreshing." + new string('.', (int) ((Time.time * 2) % 3)) ) : "Refresh servers";
buttonAction = async () =>
{
_isRefreshingMasterServerList = true;
_serversFromMasterServer = new List<ServerInfo>();
_serversFromMasterServer = await MasterServerClient.Instance.GetAllServers();
_isRefreshingMasterServerList = false;
};
buttonAction = async () => await RefreshMasterServersButtonPressed();
}
}
@ -161,6 +156,14 @@ namespace SanAndreasUnity.UI
}
async Task RefreshMasterServersButtonPressed()
{
_isRefreshingMasterServerList = true;
_serversFromMasterServer = new List<ServerInfo>();
_serversFromMasterServer = await MasterServerClient.Instance.GetAllServers();
_isRefreshingMasterServerList = false;
}
void ConnectDirectly()
{
this.Connect(m_ipStr, ushort.Parse(m_portStr));