Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

Commit

Permalink
Updated YamlDotNet, PCLExt.FileStorage, using SharpZipLib.Portable in…
Browse files Browse the repository at this point in the history
…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
Aragas committed Jun 12, 2017
1 parent a2f8bd9 commit 254469b
Show file tree
Hide file tree
Showing 67 changed files with 2,781 additions and 1,615 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="YamlDotNet, Version=4.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\YamlDotNet.4.1.0\lib\net35\YamlDotNet.dll</HintPath>
<Reference Include="YamlDotNet, Version=4.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>$(SolutionDir)\packages\YamlDotNet.4.2.1\lib\net35\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion P3D-Legacy Launcher UpdateInfoBuilder/packages.config
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>
12 changes: 6 additions & 6 deletions P3D-Legacy Launcher.sln
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26206.0
VisualStudioVersion = 15.0.26430.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P3D-Legacy Launcher", "P3D-Legacy Launcher\P3D-Legacy Launcher.csproj", "{D2A9C01E-686F-4AEA-8B8C-5AE04387F0E0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P3D-Legacy Launcher Updater", "P3D-Legacy Launcher Updater\P3D-Legacy Launcher Updater.csproj", "{6EE47050-ED83-4944-ACBB-D7F74E8C14F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P3D-Legacy Launcher UpdateInfoBuilder", "P3D-Legacy Launcher UpdateInfoBuilder\P3D-Legacy Launcher UpdateInfoBuilder.csproj", "{317AA66C-58E7-4005-9568-93CFAF5353CD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P3D-Legacy Shared", "P3D-Legacy-Shared\P3D-Legacy Shared.csproj", "{73FF082B-42B5-4E0C-A1A2-0B908FBA1406}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "P3D-Legacy Shared", "P3D-Legacy-Shared\P3D-Legacy Shared.csproj", "{13E2FD75-83F6-40CC-BB3A-829E0E834D45}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -29,10 +29,10 @@ Global
{317AA66C-58E7-4005-9568-93CFAF5353CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{317AA66C-58E7-4005-9568-93CFAF5353CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{317AA66C-58E7-4005-9568-93CFAF5353CD}.Release|Any CPU.Build.0 = Release|Any CPU
{73FF082B-42B5-4E0C-A1A2-0B908FBA1406}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73FF082B-42B5-4E0C-A1A2-0B908FBA1406}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73FF082B-42B5-4E0C-A1A2-0B908FBA1406}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73FF082B-42B5-4E0C-A1A2-0B908FBA1406}.Release|Any CPU.Build.0 = Release|Any CPU
{13E2FD75-83F6-40CC-BB3A-829E0E834D45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{13E2FD75-83F6-40CC-BB3A-829E0E834D45}.Debug|Any CPU.Build.0 = Debug|Any CPU
{13E2FD75-83F6-40CC-BB3A-829E0E834D45}.Release|Any CPU.ActiveCfg = Release|Any CPU
{13E2FD75-83F6-40CC-BB3A-829E0E834D45}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
3 changes: 1 addition & 2 deletions P3D-Legacy Launcher/Data/GitHubRelease.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ internal class GitHubRelease
private Release Release { get; }
public ReleaseAsset ReleaseAsset => Release.GetRelease();
public ReleaseAsset UpdateInfoAsset => Release.GetUpdateInfo();

public Version Version => new Version(Release.TagName ?? "0.0");
public Version Version => Version.TryParse(Release.TagName, out var version) ? version : new Version("0.0");
public DateTime ReleaseDate => Release.CreatedAt.DateTime;

public GitHubRelease(Release release) { Release = release; }
Expand Down
7 changes: 7 additions & 0 deletions P3D-Legacy Launcher/Data/IYamlSettings.cs
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();
}
}
51 changes: 51 additions & 0 deletions P3D-Legacy Launcher/Data/ModificationInfoTable.cs
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
}
}
87 changes: 87 additions & 0 deletions P3D-Legacy Launcher/Data/Profile.cs
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;
}
}
31 changes: 18 additions & 13 deletions P3D-Legacy Launcher/Data/ProfileType.cs
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;
}
}
Loading

0 comments on commit 254469b

Please sign in to comment.