This repository has been archived by the owner on Nov 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated YamlDotNet, PCLExt.FileStorage, using SharpZipLib.Portable in…
…stead of DotNetZip Ported to C# 7 (Game) Will add default server by default now. Can be turned off in settings. Returned the GameJolt button if valid GJ Username/Token is saved Internal representation of the filesystem is more abstract
- Loading branch information
Showing
67 changed files
with
2,781 additions
and
1,615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<packages> | ||
<package id="YamlDotNet" version="4.1.0" targetFramework="net452" /> | ||
<package id="YamlDotNet" version="4.2.1" targetFramework="net452" /> | ||
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace P3D.Legacy.Launcher.Storage.Files | ||
{ | ||
public interface IYamlSettings | ||
{ | ||
bool IsValid(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using System; | ||
using System.ComponentModel; | ||
|
||
using P3D.Legacy.Shared.Data; | ||
|
||
namespace P3D.Legacy.Launcher.Data | ||
{ | ||
public class ModificationInfoTable | ||
{ | ||
private ModificationInfo ModificationInfo { get; } | ||
|
||
public ModificationInfoTable(ModificationInfo modificationInfo) { ModificationInfo = modificationInfo; } | ||
|
||
[Browsable(false)] | ||
public string ID => ModificationInfo.ID; | ||
|
||
[DisplayName("Author")] | ||
public string Author => ModificationInfo.Author; | ||
|
||
[DisplayName("Name")] | ||
public string Name => ModificationInfo.Name; | ||
|
||
[Browsable(false)] | ||
public string Description => ModificationInfo.Description; | ||
|
||
[Browsable(false)] | ||
public string InGameDescription => ModificationInfo.InGameDescription; | ||
|
||
[DisplayName("Category")] | ||
public ModificationCategories Category => ModificationInfo.Category; | ||
|
||
[DisplayName("Version")] | ||
public Version Version => ModificationInfo.Version; | ||
|
||
[DisplayName("Game Version")] | ||
public Version GameVersion => ModificationInfo.GameVersion; | ||
|
||
// -- Online Info | ||
|
||
[DisplayName("Downloads")] | ||
public long Downloads => ModificationInfo.Downloads; | ||
|
||
[Browsable(false)] | ||
public byte Rating => ModificationInfo.Rating; | ||
|
||
[DisplayName("Rating")] | ||
public string RatingString => ModificationInfo.RatingString; | ||
|
||
// -- Online Info | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
using P3D.Legacy.Launcher.Services; | ||
using P3D.Legacy.Launcher.Storage.Files; | ||
using P3D.Legacy.Launcher.Storage.Folders; | ||
using P3D.Legacy.Shared.Data; | ||
using P3D.Legacy.Shared.Extensions; | ||
|
||
namespace P3D.Legacy.Launcher.Data | ||
{ | ||
internal sealed class Profile | ||
{ | ||
public static Version NoVersion { get; } = new Version("0.0"); | ||
|
||
public static bool operator ==(Profile a, Profile b) => ReferenceEquals(a, null) ? ReferenceEquals(b, null) : a.Equals((object)b); | ||
public static bool operator !=(Profile a, Profile b) => !(a == b); | ||
|
||
public static async Task<List<Version>> GetAvailableVersionsAsync(ProfileType profileType) | ||
{ | ||
if (!GitHub.WebsiteIsUp) | ||
return new List<Version>(); | ||
|
||
try { return (await GitHub.GetAllReleasesAsync(profileType)).Select(release => release.Version).OrderByDescending(version => version).ToList(); } | ||
catch (Exception) { return new List<Version>(); } | ||
} | ||
|
||
public static async Task DeleteAsync(Profile profile) => await profile.Folder.DeleteAsync(); | ||
|
||
public static ProfileYaml ToYaml(Profile profile) => new ProfileYaml(profile.ProfileType, profile.Name, profile.Version, profile.LaunchArgs); | ||
public static Profile FromYaml(ProfileYaml yaml) => new Profile(yaml.ProfileType, yaml.Name, yaml.Version, yaml.LaunchArgs); | ||
|
||
|
||
public ProfileType ProfileType { get; } | ||
public string Name { get; } | ||
public Version Version { get; } | ||
public Version VersionExe => ExecutionFile != null ? new Version(FileVersionInfo.GetVersionInfo(ExecutionFile.Path).ProductVersion) : NoVersion; | ||
public string LaunchArgs { get; } | ||
|
||
public ProfileExeFile ExecutionFile => Folder.ExecutionFile; | ||
public ProfileFolder Folder => new ProfileFolder(Name, ProfileType); | ||
public List<ModificationInfo> ModificationInfos => Folder.ModFolder.GetModificationFolders().Select(mod => mod.ModificationFile.ModificationInfo).ToList(); | ||
|
||
public bool IsDefault | ||
{ | ||
get | ||
{ | ||
var latestVersion = AsyncExtensions.RunSync(async () => await GetAvailableVersionsAsync()).FirstOrDefault(); | ||
return Name == "Latest" && latestVersion != null ? latestVersion == Version : Version == NoVersion; | ||
} | ||
} | ||
public bool IsSupportingGameJolt => ProfileType.IsSupportingGameJolt(Version); | ||
|
||
public Profile(ProfileType profileType, string name, Version version, string launchArgs = "") | ||
{ | ||
ProfileType = profileType ?? ProfileType.Game; | ||
Name = name; | ||
Version = version; | ||
LaunchArgs = string.IsNullOrEmpty(launchArgs) ? ProfileType.DefaultLaunchArgs : launchArgs; | ||
|
||
Version[] versions; | ||
if (Equals(Version, NoVersion) && (versions = AsyncExtensions.RunSync(async () => await GetAvailableVersionsAsync()).ToArray()).Length > 0) | ||
Version = versions.First(); | ||
} | ||
|
||
public async Task<List<GitHubRelease>> GetAvailableReleasesAsync() => await GitHub.GetAllReleasesAsync(ProfileType); | ||
public async Task<List<Version>> GetAvailableVersionsAsync() => await GetAvailableVersionsAsync(ProfileType); | ||
|
||
public ProfileYaml ToYaml() => ToYaml(this); | ||
public async Task DeleteAsync() => await DeleteAsync(this); | ||
|
||
private bool Equals(Profile other) => string.Equals(Name, other.Name); | ||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != GetType()) return false; | ||
return Equals((Profile)obj); | ||
} | ||
public override int GetHashCode() => Name?.GetHashCode() ?? 0; | ||
|
||
public override string ToString() => Name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,47 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
using P3D.Legacy.Launcher.Storage.Folders; | ||
|
||
namespace P3D.Legacy.Launcher.Data | ||
{ | ||
public class ProfileType : IEnumerable<ProfileType> | ||
internal class ProfileType | ||
{ | ||
private static IList<ProfileType> ProfileTypes { get; } = new List<ProfileType>(); | ||
public static ProfileType[] ToArray() => ProfileTypes.ToArray(); | ||
|
||
public static int GetIndex(ProfileType profileType) => ProfileTypes.IndexOf(profileType); | ||
public static ProfileType GetProfileType(int index) => ProfileTypes[index]; | ||
public static object GetProfileType(string name) => ProfileTypes.SingleOrDefault(profileType => profileType.Name == name) ?? Game; | ||
|
||
public static ProfileType Game { get; } = new ProfileType("Pokémon3D", "Pokemon3D.exe", "", version => version >= new Version("0.55"), 0); | ||
public static ProfileType Server1 { get; } = new ProfileType("PokeD Server", "PokeD.Server.Desktop.exe", "-c", version => false, 1); | ||
public static ProfileType Server2 { get; } = new ProfileType("AGN Server", "Pokemon.3D.Server.Client.GUI.exe", "", version => false, 2); | ||
private static List<ProfileType> ProfileTypes { get; } = new List<ProfileType> { Game , Server1, Server2}; | ||
|
||
public static ProfileType Game { get; } = new ProfileType("Pokémon3D", "Pokemon3D.exe", "GameModes", "", version => version >= new Version("0.55")); | ||
public static ProfileType Server1 { get; } = new ProfileType("PokeD Server", "PokeD.Server.Desktop.exe", "Plugins", "-cn", version => false); | ||
public static ProfileType Server2 { get; } = new ProfileType("AGN Server", "Pokemon.3D.Server.Client.GUI.exe", "Plugins", "", version => false); | ||
|
||
|
||
public string Name { get; } | ||
public string Exe { get; } | ||
public string ModFolder { get; } | ||
public string DefaultLaunchArgs { get; } | ||
private Func<Version, bool> IsSupportingGameJoltFunc { get; } | ||
private int Index { get; } | ||
|
||
private ProfileType(string name, string exe, string defaultLaunchArgs, Func<Version, bool> isSupportingGameJolt, int index) | ||
private ProfileType(string name, string exe, string modFolder, string defaultLaunchArgs, Func<Version, bool> isSupportingGameJolt) | ||
{ | ||
var t = new ProfileFolder(name, this); | ||
IList<ProfileType> y = new ProfileType[0]; | ||
|
||
Name = name; | ||
Exe = exe; | ||
ModFolder = modFolder; | ||
DefaultLaunchArgs = defaultLaunchArgs; | ||
IsSupportingGameJoltFunc = isSupportingGameJolt; | ||
Index = index; | ||
|
||
ProfileTypes.Add(this); | ||
} | ||
|
||
public bool IsSupportingGameJolt(Version version) => IsSupportingGameJoltFunc(version); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
public IEnumerator<ProfileType> GetEnumerator() => ProfileTypes.GetEnumerator(); | ||
|
||
public override string ToString() => Name; | ||
} | ||
} |
Oops, something went wrong.