- tweak: open content

This commit is contained in:
2025-01-12 15:15:01 +03:00
parent 6d46e02d6f
commit bb0d4fd723
11 changed files with 106 additions and 27 deletions

View File

@@ -10,8 +10,8 @@ namespace Nebula.Shared.Services;
[ServiceRegister]
public class FileService
{
public static string RootPath = Path.Join(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData), "./Datum/");
public static readonly string RootPath = Path.Join(Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData), "Datum");
private readonly DebugService _debugService;
@@ -25,10 +25,10 @@ public class FileService
public FileService(DebugService debugService)
{
_debugService = debugService;
ContentFileApi = CreateFileApi("content/");
EngineFileApi = CreateFileApi("engine/");
ManifestFileApi = CreateFileApi("manifest/");
ConfigurationApi = CreateFileApi("config/");
ContentFileApi = CreateFileApi("content");
EngineFileApi = CreateFileApi("engine");
ManifestFileApi = CreateFileApi("manifest");
ConfigurationApi = CreateFileApi("config");
}
public List<RobustManifestItem> ManifestItems

View File

@@ -10,8 +10,12 @@ public class HubService
public Action<HubServerChangedEventArgs>? HubServerChangedEventArgs;
public Action? HubServerLoaded;
private readonly List<ServerHubInfo> _serverList = new();
public IReadOnlyList<ServerHubInfo> ServerList => _serverList;
private bool _isUpdating = false;
public bool IsUpdating => _isUpdating;
public HubService(ConfigurationService configurationService, RestService restService)
{
_configurationService = configurationService;
@@ -23,6 +27,10 @@ public class HubService
public async void UpdateHub()
{
if(_isUpdating) return;
_serverList.Clear();
_isUpdating = true;
@@ -32,6 +40,7 @@ public class HubService
foreach (var urlStr in _configurationService.GetConfigValue(CurrentConVar.Hub)!)
{
var servers = await _restService.GetAsyncDefault<List<ServerHubInfo>>(new Uri(urlStr), [], CancellationToken.None);
_serverList.AddRange(servers);
HubServerChangedEventArgs?.Invoke(new HubServerChangedEventArgs(servers, HubServerChangeAction.Add));
}