Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #141 from patchkit-net/dev/v3.17.x.x
Merge 3.17.1.0 to master
  • Loading branch information
witcher112 committed Jan 24, 2020
2 parents bb48122 + de5dcf1 commit ee5195f
Show file tree
Hide file tree
Showing 10 changed files with 6,775 additions and 11 deletions.
6,656 changes: 6,656 additions & 0 deletions Assets/PatchKit Patcher/Patcher_Multiple_Start_Buttons.unity

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions Assets/PatchKit Patcher/Scripts/AppStarter.cs
Expand Up @@ -63,7 +63,7 @@ private string ResolveExecutablePath(AppVersion? appVersion)
return AppFinder.FindExecutable(_app.LocalDirectory.Path, platformType);
}

public void Start()
public void Start(string customArgs)
{
AppVersion? appVersion = null;

Expand All @@ -81,20 +81,21 @@ public void Start()
"Failed to retrieve app version info. Will try to detect exectuable manually.");
}

StartAppVersion(appVersion);
StartAppVersion(appVersion, customArgs);
}

private void StartAppVersion(AppVersion? appVersion)
private void StartAppVersion(AppVersion? appVersion, string customArgs)
{
DebugLogger.Log("Starting application.");

PlatformType platformType = Platform.GetPlatformType();
string appFilePath = ResolveExecutablePath(appVersion);
string appArgs = null;
string appArgs = customArgs ?? string.Empty;

if (appVersion != null)
if (appVersion != null &&
appVersion.Value.MainExecutableArgs != null)
{
appArgs = appVersion.Value.MainExecutableArgs;
appArgs += " " + appVersion.Value.MainExecutableArgs;
}

if (appFilePath == null)
Expand Down
Expand Up @@ -163,8 +163,29 @@ public override void Execute(CancellationToken cancellationToken)
UnarchivePackage(packageDir.Path, out usedSuffix, cancellationToken);
ProcessAddedFiles(packageDir.Path, usedSuffix, cancellationToken);
ProcessRemovedFiles(cancellationToken);
// To correctly install diff, we need to first remove the
// files & dirs, and later add a new ones.
//
// Otherwise we could encounter a situation when we try to
// add a file/dir, which is already present in the data
// (but should be removed becuase it's in the removed_files)
//
// But only with diff summary 2.6 we can be sure that
// removed_files field contains directories as well.
//
// That's why we're keeping the "wrong" behaviour for diffs
// with version lower than 2.6.
if (IsDiffSummaryVersionAtLeast2_6())
{
ProcessRemovedFiles(cancellationToken);
ProcessAddedFiles(packageDir.Path, usedSuffix, cancellationToken);
}
else
{
ProcessAddedFiles(packageDir.Path, usedSuffix, cancellationToken);
ProcessRemovedFiles(cancellationToken);
}
TemporaryDirectory.ExecuteIn(_packagePath + ".temp_diff_" + Path.GetRandomFileName(), (tempDiffDir) =>
{
Expand All @@ -185,6 +206,33 @@ public override void Execute(CancellationToken cancellationToken)
}
}

private bool IsDiffSummaryVersionAtLeast2_6()
{
try
{
var versionSplit = _diffSummary.Version.Split('.');

int major = int.Parse(versionSplit[0]);
int minor = int.Parse(versionSplit[1]);

if (major > 2)
{
return true;
}

if (major == 2 && minor >= 6)
{
return true;
}

return false;
}
catch
{
return false;
}
}

private void ReadPack1MetaFile()
{
_logger.LogDebug("Parsing package meta file...");
Expand Down
4 changes: 3 additions & 1 deletion Assets/PatchKit Patcher/Scripts/Patcher.cs
Expand Up @@ -95,6 +95,8 @@ public static Patcher Instance

public PatcherConfiguration DefaultConfiguration;

public string StartAppCustomArgs { get; set; }

private readonly ReactiveProperty<IReadOnlyUpdaterStatus> _updaterStatus = new ReactiveProperty<IReadOnlyUpdaterStatus>();

public IReadOnlyReactiveProperty<IReadOnlyUpdaterStatus> UpdaterStatus
Expand Down Expand Up @@ -840,7 +842,7 @@ private void ThreadStartApp()

var appStarter = new AppStarter(_app);

appStarter.Start();
appStarter.Start(StartAppCustomArgs);

PatcherStatistics.DispatchSendEvent(PatcherStatistics.Event.PatcherSucceededGameStarted);
_hasGameBeenStarted = true;
Expand Down
3 changes: 3 additions & 0 deletions Assets/PatchKit Patcher/Scripts/UI/MessagePanel.cs
Expand Up @@ -7,6 +7,8 @@ namespace PatchKit.Unity.Patcher.UI
[RequireComponent(typeof(Animator))]
public class MessagePanel : MonoBehaviour
{
public string StartAppCustomArgs;

public Button PlayButton;

public Button CheckButton;
Expand Down Expand Up @@ -67,6 +69,7 @@ private void Start()

private void OnPlayButtonClicked()
{
Patcher.Instance.StartAppCustomArgs = StartAppCustomArgs;
Patcher.Instance.SetUserDecision(Patcher.UserDecision.StartApp);
}

Expand Down
27 changes: 27 additions & 0 deletions Assets/PatchKit Patcher/Scripts/UI/StartAppButton.cs
@@ -0,0 +1,27 @@
using UnityEngine;
using UnityEngine.UI;
using UniRx;

namespace PatchKit.Unity.Patcher.UI
{
public class StartAppButton : MonoBehaviour
{
public Button Button;

public string StartAppCustomArgs;

private void Start()
{
Button.onClick.AddListener(() =>
{
Patcher.Instance.StartAppCustomArgs = StartAppCustomArgs;
Patcher.Instance.SetUserDecision(Patcher.UserDecision.StartApp);
});

Patcher.Instance.CanStartApp.ObserveOnMainThread().Subscribe(canStartApp =>
{
Button.interactable = canStartApp;
}).AddTo(this);
}
}
}
11 changes: 11 additions & 0 deletions Assets/PatchKit Patcher/Scripts/UI/StartAppButton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Assets/PatchKit Patcher/Scripts/Version.cs
Expand Up @@ -3,8 +3,8 @@ namespace PatchKit.Unity.Patcher
public static class Version
{
public const int Major = 3;
public const int Minor = 16;
public const int Patch = 0;
public const int Minor = 17;
public const int Patch = 1;
public const int Hotfix = 0;

public static string Value
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [3.17.1.0]
### Fixed
- Installing diff which contains the same entry in added_files & removed_files

## [3.17.0.0]
### Added
- Support for custom start app arguments (#1486)

## [3.16.0.0]
### Changed
- Improved stability of downloading (#1422)
Expand Down

0 comments on commit ee5195f

Please sign in to comment.