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.Globalization;
global using System.IO;
global using System.IO.Compression;
global using System.Text;
global using System.Text.Json;
global using System.Text.Json.Serialization;
@ -18,10 +17,16 @@ global using Bloxstrap.Enums;
global using Bloxstrap.Exceptions;
global using Bloxstrap.Extensions;
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.BloxstrapRPC;
global using Bloxstrap.Models.RobloxApi;
global using Bloxstrap.Models.Entities;
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.UI;
global using Bloxstrap.Utility;

View File

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

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models
namespace Bloxstrap.Models.APIs.Config
{
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
{
@ -7,7 +7,7 @@
[JsonPropertyName("name")]
public string Name { get; set; } = null!;
[JsonPropertyName("body")]
public string Body { get; set; } = null!;
@ -17,13 +17,4 @@
[JsonPropertyName("assets")]
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
{
public class IPInfoResponse
{
[JsonPropertyName("city")]
public string City { get; set; } = null!;
[JsonPropertyName("country")]
public string Country { get; set; } = null!;
[JsonPropertyName("region")]
public string Region { get; set; } = null!;
}
}
namespace Bloxstrap.Models.APIs
{
public class IPInfoResponse
{
[JsonPropertyName("city")]
public string City { get; set; } = null!;
[JsonPropertyName("country")]
public string Country { get; set; } = null!;
[JsonPropertyName("region")]
public string Region { get; set; } = null!;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
namespace Bloxstrap.Models.RobloxApi
namespace Bloxstrap.Models.APIs.Roblox
{
/// <summary>
/// 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
public class UniverseIdResponse

View File

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

View File

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

View File

@ -1,11 +1,13 @@
namespace Bloxstrap.Models
using Bloxstrap.Models.APIs.Roblox;
namespace Bloxstrap.Models.Entities
{
public class UniverseDetails
{
private static List<UniverseDetails> _cache { get; set; } = new();
public GameDetailResponse Data { get; set; } = null!;
/// <summary>
/// Returns data for a 128x128 icon
/// </summary>
@ -13,9 +15,9 @@
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 null;

View File

@ -1,8 +1,8 @@
namespace Bloxstrap.Models
namespace Bloxstrap.Models.Persistable
{
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();

View File

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

View File

@ -1,13 +1,13 @@
namespace Bloxstrap.Models
namespace Bloxstrap.Models.Persistable
{
public class State
{
public bool ShowFFlagEditorWarning { get; set; } = true;
public bool PromptWebView2Install { get; set; } = true;
public AppState Player { get; set; } = new();
public AppState Studio { 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 double Width { get; set; }
public double Height { get; set; }
public double Left { 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
{

View File

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

View File

@ -14,7 +14,7 @@ namespace Bloxstrap.UI.Elements.Settings
/// </summary>
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)
{