Reorganize models

This commit is contained in:
pizzaboxer 2024-09-15 20:58:28 +01:00
parent c58a8ab739
commit 0b20720fdb
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
23 changed files with 83 additions and 75 deletions

View File

@ -3,7 +3,6 @@ global using System.Collections.Generic;
global using System.Diagnostics; global using System.Diagnostics;
global using System.Globalization; global using System.Globalization;
global using System.IO; global using System.IO;
global using System.IO.Compression;
global using System.Text; global using System.Text;
global using System.Text.Json; global using System.Text.Json;
global using System.Text.Json.Serialization; global using System.Text.Json.Serialization;
@ -18,10 +17,16 @@ global using Bloxstrap.Enums;
global using Bloxstrap.Exceptions; global using Bloxstrap.Exceptions;
global using Bloxstrap.Extensions; global using Bloxstrap.Extensions;
global using Bloxstrap.Models; global using Bloxstrap.Models;
global using Bloxstrap.Models.APIs.Config;
global using Bloxstrap.Models.APIs.GitHub;
global using Bloxstrap.Models.APIs.Roblox;
global using Bloxstrap.Models.Attributes; global using Bloxstrap.Models.Attributes;
global using Bloxstrap.Models.BloxstrapRPC; global using Bloxstrap.Models.BloxstrapRPC;
global using Bloxstrap.Models.RobloxApi; global using Bloxstrap.Models.Entities;
global using Bloxstrap.Models.Manifest; global using Bloxstrap.Models.Manifest;
global using Bloxstrap.Models.Persistable;
global using Bloxstrap.Models.SettingTasks;
global using Bloxstrap.Models.SettingTasks.Base;
global using Bloxstrap.Resources; global using Bloxstrap.Resources;
global using Bloxstrap.UI; global using Bloxstrap.UI;
global using Bloxstrap.Utility; global using Bloxstrap.Utility;

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.APIs.Config
{ {
public class Supporter public class Supporter
{ {

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.APIs.Config
{ {
public class SupporterData public class SupporterData
{ {

View File

@ -0,0 +1,8 @@
public class GithubReleaseAsset
{
[JsonPropertyName("browser_download_url")]
public string BrowserDownloadUrl { get; set; } = null!;
[JsonPropertyName("name")]
public string Name { get; set; } = null!;
}

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.APIs.GitHub
{ {
public class GithubRelease public class GithubRelease
{ {
@ -7,7 +7,7 @@
[JsonPropertyName("name")] [JsonPropertyName("name")]
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
[JsonPropertyName("body")] [JsonPropertyName("body")]
public string Body { get; set; } = null!; public string Body { get; set; } = null!;
@ -17,13 +17,4 @@
[JsonPropertyName("assets")] [JsonPropertyName("assets")]
public List<GithubReleaseAsset>? Assets { get; set; } public List<GithubReleaseAsset>? Assets { get; set; }
} }
public class GithubReleaseAsset
{
[JsonPropertyName("browser_download_url")]
public string BrowserDownloadUrl { get; set; } = null!;
[JsonPropertyName("name")]
public string Name { get; set; } = null!;
}
} }

View File

@ -1,14 +1,14 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.APIs
{ {
public class IPInfoResponse public class IPInfoResponse
{ {
[JsonPropertyName("city")] [JsonPropertyName("city")]
public string City { get; set; } = null!; public string City { get; set; } = null!;
[JsonPropertyName("country")] [JsonPropertyName("country")]
public string Country { get; set; } = null!; public string Country { get; set; } = null!;
[JsonPropertyName("region")] [JsonPropertyName("region")]
public string Region { get; set; } = null!; public string Region { get; set; } = null!;
} }
} }

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models.RobloxApi namespace Bloxstrap.Models.APIs.Roblox
{ {
/// <summary> /// <summary>
/// Roblox.Web.WebAPI.Models.ApiArrayResponse /// Roblox.Web.WebAPI.Models.ApiArrayResponse

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.APIs.Roblox
{ {
public class ClientFlagSettings public class ClientFlagSettings
{ {

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.APIs.Roblox
{ {
public class ClientVersion public class ClientVersion
{ {

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models.RobloxApi namespace Bloxstrap.Models.APIs.Roblox
{ {
/// <summary> /// <summary>
/// Roblox.Games.Api.Models.Response.GameCreator /// Roblox.Games.Api.Models.Response.GameCreator

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models.RobloxApi namespace Bloxstrap.Models.APIs.Roblox
{ {
/// <summary> /// <summary>

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models.RobloxApi namespace Bloxstrap.Models.APIs.Roblox
{ {
/// <summary> /// <summary>
/// Roblox.Web.Responses.Thumbnails.ThumbnailResponse /// Roblox.Web.Responses.Thumbnails.ThumbnailResponse

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models.RobloxApi namespace Bloxstrap.Models.APIs.Roblox
{ {
// lmao its just one property // lmao its just one property
public class UniverseIdResponse public class UniverseIdResponse

View File

@ -1,10 +1,10 @@
using System.Web; using System.Web;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Bloxstrap.Models.APIs;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
namespace Bloxstrap.Models namespace Bloxstrap.Models.Entities
{ {
public class ActivityData public class ActivityData
{ {
@ -16,7 +16,7 @@ namespace Bloxstrap.Models
/// </summary> /// </summary>
public ActivityData? RootActivity; public ActivityData? RootActivity;
public long UniverseId public long UniverseId
{ {
get => _universeId; get => _universeId;
set set
@ -28,19 +28,19 @@ namespace Bloxstrap.Models
public long PlaceId { get; set; } = 0; public long PlaceId { get; set; } = 0;
public string JobId { get; set; } = String.Empty; public string JobId { get; set; } = string.Empty;
/// <summary> /// <summary>
/// This will be empty unless the server joined is a private server /// This will be empty unless the server joined is a private server
/// </summary> /// </summary>
public string AccessCode { get; set; } = String.Empty; public string AccessCode { get; set; } = string.Empty;
public string MachineAddress { get; set; } = String.Empty;
public bool MachineAddressValid => !String.IsNullOrEmpty(MachineAddress) && !MachineAddress.StartsWith("10."); public string MachineAddress { get; set; } = string.Empty;
public bool MachineAddressValid => !string.IsNullOrEmpty(MachineAddress) && !MachineAddress.StartsWith("10.");
public bool IsTeleport { get; set; } = false; public bool IsTeleport { get; set; } = false;
public ServerType ServerType { get; set; } = ServerType.Public; public ServerType ServerType { get; set; } = ServerType.Public;
public DateTime TimeJoined { get; set; } public DateTime TimeJoined { get; set; }
@ -52,15 +52,15 @@ namespace Bloxstrap.Models
/// <summary> /// <summary>
/// This is intended only for other people to use, i.e. context menu invite link, rich presence joining /// This is intended only for other people to use, i.e. context menu invite link, rich presence joining
/// </summary> /// </summary>
public string RPCLaunchData { get; set; } = String.Empty; public string RPCLaunchData { get; set; } = string.Empty;
public UniverseDetails? UniverseDetails { get; set; } public UniverseDetails? UniverseDetails { get; set; }
public string GameHistoryDescription public string GameHistoryDescription
{ {
get get
{ {
string desc = String.Format("{0} • {1} - {2}", UniverseDetails?.Data.Creator.Name, TimeJoined.ToString("h:mm tt"), TimeLeft?.ToString("h:mm tt")); string desc = string.Format("{0} • {1} - {2}", UniverseDetails?.Data.Creator.Name, TimeJoined.ToString("h:mm tt"), TimeLeft?.ToString("h:mm tt"));
if (ServerType != ServerType.Public) if (ServerType != ServerType.Public)
desc += " • " + ServerType.ToTranslatedString(); desc += " • " + ServerType.ToTranslatedString();
@ -82,7 +82,7 @@ namespace Bloxstrap.Models
else else
deeplink += "&gameInstanceId=" + JobId; deeplink += "&gameInstanceId=" + JobId;
if (launchData && !String.IsNullOrEmpty(RPCLaunchData)) if (launchData && !string.IsNullOrEmpty(RPCLaunchData))
deeplink += "&launchData=" + HttpUtility.UrlEncode(RPCLaunchData); deeplink += "&launchData=" + HttpUtility.UrlEncode(RPCLaunchData);
return deeplink; return deeplink;
@ -107,7 +107,7 @@ namespace Bloxstrap.Models
{ {
var ipInfo = await Http.GetJson<IPInfoResponse>($"https://ipinfo.io/{MachineAddress}/json"); var ipInfo = await Http.GetJson<IPInfoResponse>($"https://ipinfo.io/{MachineAddress}/json");
if (String.IsNullOrEmpty(ipInfo.City)) if (string.IsNullOrEmpty(ipInfo.City))
throw new InvalidHTTPResponseException("Reported city was blank"); throw new InvalidHTTPResponseException("Reported city was blank");
if (ipInfo.City == ipInfo.Region) if (ipInfo.City == ipInfo.Region)
@ -127,9 +127,9 @@ namespace Bloxstrap.Models
serverQuerySemaphore.Release(); serverQuerySemaphore.Release();
Frontend.ShowConnectivityDialog( Frontend.ShowConnectivityDialog(
String.Format(Strings.Dialog_Connectivity_UnableToConnect, "ipinfo.io"), string.Format(Strings.Dialog_Connectivity_UnableToConnect, "ipinfo.io"),
Strings.ActivityWatcher_LocationQueryFailed, Strings.ActivityWatcher_LocationQueryFailed,
MessageBoxImage.Warning, MessageBoxImage.Warning,
ex ex
); );
} }
@ -142,7 +142,7 @@ namespace Bloxstrap.Models
private void RejoinServer() private void RejoinServer()
{ {
string playerPath = Path.Combine(Paths.Roblox, "Player", "RobloxPlayerBeta.exe"); string playerPath = Path.Combine(Paths.Roblox, "Player", "RobloxPlayerBeta.exe");
Process.Start(playerPath, GetInviteDeeplink(false)); Process.Start(playerPath, GetInviteDeeplink(false));
} }
} }

View File

@ -1,23 +1,23 @@
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Windows.Markup; using System.Windows.Markup;
namespace Bloxstrap.Models namespace Bloxstrap.Models.Entities
{ {
public class ModPresetFileData public class ModPresetFileData
{ {
public string FilePath { get; private set; } public string FilePath { get; private set; }
public string FullFilePath => Path.Combine(Paths.Modifications, FilePath); public string FullFilePath => Path.Combine(Paths.Modifications, FilePath);
public FileStream FileStream => File.OpenRead(FullFilePath); public FileStream FileStream => File.OpenRead(FullFilePath);
public string ResourceIdentifier { get; private set; } public string ResourceIdentifier { get; private set; }
public Stream ResourceStream => Resource.GetStream(ResourceIdentifier); public Stream ResourceStream => Resource.GetStream(ResourceIdentifier);
public byte[] ResourceHash { get; private set; } public byte[] ResourceHash { get; private set; }
public ModPresetFileData(string contentPath, string resource) public ModPresetFileData(string contentPath, string resource)
{ {
FilePath = contentPath; FilePath = contentPath;
ResourceIdentifier = resource; ResourceIdentifier = resource;

View File

@ -1,11 +1,13 @@
namespace Bloxstrap.Models using Bloxstrap.Models.APIs.Roblox;
namespace Bloxstrap.Models.Entities
{ {
public class UniverseDetails public class UniverseDetails
{ {
private static List<UniverseDetails> _cache { get; set; } = new(); private static List<UniverseDetails> _cache { get; set; } = new();
public GameDetailResponse Data { get; set; } = null!; public GameDetailResponse Data { get; set; } = null!;
/// <summary> /// <summary>
/// Returns data for a 128x128 icon /// Returns data for a 128x128 icon
/// </summary> /// </summary>
@ -13,9 +15,9 @@
public static UniverseDetails? LoadFromCache(long id) public static UniverseDetails? LoadFromCache(long id)
{ {
var cacheQuery = _cache.Where(x => x.Data?.Id == id); var cacheQuery = _cache.Where(x => x.Data?.Id == id);
if (cacheQuery.Any()) if (cacheQuery.Any())
return cacheQuery.First(); return cacheQuery.First();
return null; return null;

View File

@ -1,8 +1,8 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.Persistable
{ {
public class AppState public class AppState
{ {
public string VersionGuid { get; set; } = String.Empty; public string VersionGuid { get; set; } = string.Empty;
public Dictionary<string, string> PackageHashes { get; set; } = new(); public Dictionary<string, string> PackageHashes { get; set; } = new();

View File

@ -1,6 +1,6 @@
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
namespace Bloxstrap.Models namespace Bloxstrap.Models.Persistable
{ {
public class Settings public class Settings
{ {

View File

@ -1,13 +1,13 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.Persistable
{ {
public class State public class State
{ {
public bool ShowFFlagEditorWarning { get; set; } = true; public bool ShowFFlagEditorWarning { get; set; } = true;
public bool PromptWebView2Install { get; set; } = true; public bool PromptWebView2Install { get; set; } = true;
public AppState Player { get; set; } = new(); public AppState Player { get; set; } = new();
public AppState Studio { get; set; } = new(); public AppState Studio { get; set; } = new();
public WindowState SettingsWindow { get; set; } = new(); public WindowState SettingsWindow { get; set; } = new();

View File

@ -1,13 +1,13 @@
namespace Bloxstrap.Models namespace Bloxstrap.Models.Persistable
{ {
public class WindowState public class WindowState
{ {
public double Width { get; set; } public double Width { get; set; }
public double Height { get; set; } public double Height { get; set; }
public double Left { get; set; } public double Left { get; set; }
public double Top { get; set; } public double Top { get; set; }
} }
} }

View File

@ -1,4 +1,5 @@
using Bloxstrap.Models.SettingTasks.Base; using Bloxstrap.Models.Entities;
using Bloxstrap.Models.SettingTasks.Base;
namespace Bloxstrap.Models.SettingTasks namespace Bloxstrap.Models.SettingTasks
{ {

View File

@ -1,4 +1,5 @@
using Bloxstrap.Models.SettingTasks.Base; using Bloxstrap.Models.Entities;
using Bloxstrap.Models.SettingTasks.Base;
namespace Bloxstrap.Models.SettingTasks namespace Bloxstrap.Models.SettingTasks
{ {

View File

@ -14,7 +14,7 @@ namespace Bloxstrap.UI.Elements.Settings
/// </summary> /// </summary>
public partial class MainWindow : INavigationWindow public partial class MainWindow : INavigationWindow
{ {
private Models.WindowState _state => App.State.Prop.SettingsWindow; private Models.Persistable.WindowState _state => App.State.Prop.SettingsWindow;
public MainWindow(bool showAlreadyRunningWarning) public MainWindow(bool showAlreadyRunningWarning)
{ {