Skip to content

Commit 35046f4

Browse files
committed
Display warning message when auto-update fails and app is installed
1 parent 3a15c6f commit 35046f4

File tree

5 files changed

+166
-13
lines changed

5 files changed

+166
-13
lines changed

Assets/PatchKit Patcher/Patcher.unity

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ RectTransform:
728728
- {fileID: 1882944059}
729729
- {fileID: 1895841004}
730730
m_Father: {fileID: 776156508}
731-
m_RootOrder: 14
731+
m_RootOrder: 15
732732
m_AnchorMin: {x: 0.5, y: 0.5}
733733
m_AnchorMax: {x: 0.5, y: 0.5}
734734
m_AnchoredPosition: {x: 0, y: 0}
@@ -870,6 +870,7 @@ MonoBehaviour:
870870
m_EditorClassIdentifier:
871871
LogServerUrl: http://test.patchkit.net
872872
SendDelaySeconds: 15
873+
IgnoreEditorErrors: 1
873874
--- !u!1 &421519242
874875
GameObject:
875876
m_ObjectHideFlags: 0
@@ -1029,6 +1030,92 @@ Transform:
10291030
m_Children: []
10301031
m_Father: {fileID: 0}
10311032
m_RootOrder: 0
1033+
--- !u!1 &477218054
1034+
GameObject:
1035+
m_ObjectHideFlags: 0
1036+
m_PrefabParentObject: {fileID: 0}
1037+
m_PrefabInternal: {fileID: 0}
1038+
serializedVersion: 4
1039+
m_Component:
1040+
- 224: {fileID: 477218055}
1041+
- 222: {fileID: 477218058}
1042+
- 114: {fileID: 477218057}
1043+
- 114: {fileID: 477218056}
1044+
m_Layer: 5
1045+
m_Name: Warning
1046+
m_TagString: Untagged
1047+
m_Icon: {fileID: 0}
1048+
m_NavMeshLayer: 0
1049+
m_StaticEditorFlags: 0
1050+
m_IsActive: 1
1051+
--- !u!224 &477218055
1052+
RectTransform:
1053+
m_ObjectHideFlags: 0
1054+
m_PrefabParentObject: {fileID: 0}
1055+
m_PrefabInternal: {fileID: 0}
1056+
m_GameObject: {fileID: 477218054}
1057+
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
1058+
m_LocalPosition: {x: 0, y: 0, z: 0}
1059+
m_LocalScale: {x: 1, y: 1, z: 1}
1060+
m_Children: []
1061+
m_Father: {fileID: 776156508}
1062+
m_RootOrder: 7
1063+
m_AnchorMin: {x: 0.5, y: 0.5}
1064+
m_AnchorMax: {x: 0.5, y: 0.5}
1065+
m_AnchoredPosition: {x: -280, y: -109.80002}
1066+
m_SizeDelta: {x: 0, y: 0}
1067+
m_Pivot: {x: 0.5, y: 0.5}
1068+
--- !u!114 &477218056
1069+
MonoBehaviour:
1070+
m_ObjectHideFlags: 0
1071+
m_PrefabParentObject: {fileID: 0}
1072+
m_PrefabInternal: {fileID: 0}
1073+
m_GameObject: {fileID: 477218054}
1074+
m_Enabled: 1
1075+
m_EditorHideFlags: 0
1076+
m_Script: {fileID: 11500000, guid: aa71e577e8cfe47b8aff3e1c254d0edf, type: 3}
1077+
m_Name:
1078+
m_EditorClassIdentifier:
1079+
Text: {fileID: 477218057}
1080+
--- !u!114 &477218057
1081+
MonoBehaviour:
1082+
m_ObjectHideFlags: 0
1083+
m_PrefabParentObject: {fileID: 0}
1084+
m_PrefabInternal: {fileID: 0}
1085+
m_GameObject: {fileID: 477218054}
1086+
m_Enabled: 1
1087+
m_EditorHideFlags: 0
1088+
m_Script: {fileID: 708705254, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
1089+
m_Name:
1090+
m_EditorClassIdentifier:
1091+
m_Material: {fileID: 0}
1092+
m_Color: {r: 0.7058823, g: 0.5111562, b: 0, a: 1}
1093+
m_RaycastTarget: 1
1094+
m_OnCullStateChanged:
1095+
m_PersistentCalls:
1096+
m_Calls: []
1097+
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
1098+
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
1099+
m_FontData:
1100+
m_Font: {fileID: 12800000, guid: a31f75b6c995ad2449719ba320763782, type: 3}
1101+
m_FontSize: 11
1102+
m_FontStyle: 0
1103+
m_BestFit: 0
1104+
m_MinSize: 0
1105+
m_MaxSize: 40
1106+
m_Alignment: 3
1107+
m_AlignByGeometry: 0
1108+
m_RichText: 1
1109+
m_HorizontalOverflow: 1
1110+
m_VerticalOverflow: 1
1111+
m_LineSpacing: 1
1112+
m_Text: Unable to check for updates.
1113+
--- !u!222 &477218058
1114+
CanvasRenderer:
1115+
m_ObjectHideFlags: 0
1116+
m_PrefabParentObject: {fileID: 0}
1117+
m_PrefabInternal: {fileID: 0}
1118+
m_GameObject: {fileID: 477218054}
10321119
--- !u!1 &498869790
10331120
GameObject:
10341121
m_ObjectHideFlags: 0
@@ -1199,7 +1286,7 @@ RectTransform:
11991286
- {fileID: 2086281416}
12001287
- {fileID: 1428188495}
12011288
m_Father: {fileID: 776156508}
1202-
m_RootOrder: 13
1289+
m_RootOrder: 14
12031290
m_AnchorMin: {x: 0.5, y: 0.5}
12041291
m_AnchorMax: {x: 0.5, y: 0.5}
12051292
m_AnchoredPosition: {x: 0, y: 0}
@@ -1312,7 +1399,7 @@ RectTransform:
13121399
m_Children:
13131400
- {fileID: 59275200}
13141401
m_Father: {fileID: 776156508}
1315-
m_RootOrder: 11
1402+
m_RootOrder: 12
13161403
m_AnchorMin: {x: 0.5, y: 0.5}
13171404
m_AnchorMax: {x: 0.5, y: 0.5}
13181405
m_AnchoredPosition: {x: 275, y: 172}
@@ -1578,7 +1665,7 @@ RectTransform:
15781665
- {fileID: 1198658945}
15791666
- {fileID: 1141377189}
15801667
m_Father: {fileID: 776156508}
1581-
m_RootOrder: 10
1668+
m_RootOrder: 11
15821669
m_AnchorMin: {x: 0.5, y: 0.5}
15831670
m_AnchorMax: {x: 0.5, y: 0.5}
15841671
m_AnchoredPosition: {x: 0, y: -1000}
@@ -1673,7 +1760,7 @@ RectTransform:
16731760
m_LocalScale: {x: 1, y: 1, z: 1}
16741761
m_Children: []
16751762
m_Father: {fileID: 776156508}
1676-
m_RootOrder: 7
1763+
m_RootOrder: 8
16771764
m_AnchorMin: {x: 0.5, y: 0.5}
16781765
m_AnchorMax: {x: 0.5, y: 0.5}
16791766
m_AnchoredPosition: {x: -280, y: -114}
@@ -1811,6 +1898,7 @@ RectTransform:
18111898
- {fileID: 1927476306}
18121899
- {fileID: 870074901}
18131900
- {fileID: 50408493}
1901+
- {fileID: 477218055}
18141902
- {fileID: 764284243}
18151903
- {fileID: 1869918834}
18161904
- {fileID: 1274297495}
@@ -2132,7 +2220,7 @@ RectTransform:
21322220
m_Children:
21332221
- {fileID: 1498076102}
21342222
m_Father: {fileID: 776156508}
2135-
m_RootOrder: 12
2223+
m_RootOrder: 13
21362224
m_AnchorMin: {x: 0.5, y: 0.5}
21372225
m_AnchorMax: {x: 0.5, y: 0.5}
21382226
m_AnchoredPosition: {x: 248, y: 172}
@@ -3507,7 +3595,7 @@ RectTransform:
35073595
- {fileID: 1627480853}
35083596
- {fileID: 1026572724}
35093597
m_Father: {fileID: 776156508}
3510-
m_RootOrder: 9
3598+
m_RootOrder: 10
35113599
m_AnchorMin: {x: 0.5, y: 0.5}
35123600
m_AnchorMax: {x: 0.5, y: 0.5}
35133601
m_AnchoredPosition: {x: 0, y: 30}
@@ -4314,7 +4402,7 @@ RectTransform:
43144402
m_Children:
43154403
- {fileID: 1769712922}
43164404
m_Father: {fileID: 776156508}
4317-
m_RootOrder: 8
4405+
m_RootOrder: 9
43184406
m_AnchorMin: {x: 0.5, y: 0.5}
43194407
m_AnchorMax: {x: 0.5, y: 0.5}
43204408
m_AnchoredPosition: {x: 260.99997, y: -106.5}

Assets/PatchKit Patcher/Scripts/Patcher.cs

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,11 @@ public enum UserDecision
2828
None,
2929
RepairApp,
3030
StartApp,
31+
StartAppAutomatically,
3132
InstallApp,
32-
CheckForAppUpdates
33+
InstallAppAutomatically,
34+
CheckForAppUpdates,
35+
CheckForAppUpdatesAutomatically
3336
}
3437

3538
private static readonly DebugLogger DebugLogger = new DebugLogger(typeof(Patcher));
@@ -123,6 +126,13 @@ public IReadOnlyReactiveProperty<PatcherData> Data
123126
{
124127
get { return _data; }
125128
}
129+
130+
private readonly ReactiveProperty<string> _warning = new ReactiveProperty<string>();
131+
132+
public IReadOnlyReactiveProperty<string> Warning
133+
{
134+
get { return _warning; }
135+
}
126136

127137
public void SetUserDecision(UserDecision userDecision)
128138
{
@@ -464,7 +474,7 @@ private void ThreadWaitForUserDecision(CancellationToken cancellationToken)
464474
{
465475
DebugLogger.Log("Automatically deciding to install app.");
466476
_hasAutomaticallyInstalledApp = true;
467-
_userDecision = UserDecision.InstallApp;
477+
_userDecision = UserDecision.InstallAppAutomatically;
468478
return;
469479
}
470480

@@ -473,15 +483,15 @@ private void ThreadWaitForUserDecision(CancellationToken cancellationToken)
473483
{
474484
DebugLogger.Log("Automatically deciding to check for app updates.");
475485
_hasAutomaticallyCheckedForAppUpdate = true;
476-
_userDecision = UserDecision.CheckForAppUpdates;
486+
_userDecision = UserDecision.CheckForAppUpdatesAutomatically;
477487
return;
478488
}
479489

480490
if (_canStartApp.Value && _configuration.AutomaticallyStartApp && !_hasAutomaticallyStartedApp)
481491
{
482492
DebugLogger.Log("Automatically deciding to start app.");
483493
_hasAutomaticallyStartedApp = true;
484-
_userDecision = UserDecision.StartApp;
494+
_userDecision = UserDecision.StartAppAutomatically;
485495
return;
486496
}
487497

@@ -518,8 +528,12 @@ private void ThreadWaitForUserDecision(CancellationToken cancellationToken)
518528

519529
private void ThreadExecuteUserDecision(CancellationToken cancellationToken)
520530
{
531+
bool displayWarningInsteadOfError = false;
532+
521533
try
522534
{
535+
_warning.Value = string.Empty;
536+
523537
DebugLogger.Log(string.Format("Executing user decision {0}...", _userDecision));
524538

525539
switch (_userDecision)
@@ -528,12 +542,21 @@ private void ThreadExecuteUserDecision(CancellationToken cancellationToken)
528542
break;
529543
case UserDecision.RepairApp:
530544
break;
545+
case UserDecision.StartAppAutomatically:
531546
case UserDecision.StartApp:
532547
ThreadStartApp();
533548
break;
549+
case UserDecision.InstallAppAutomatically:
550+
displayWarningInsteadOfError = _app.IsInstalled();
551+
ThreadUpdateApp(cancellationToken);
552+
break;
534553
case UserDecision.InstallApp:
535554
ThreadUpdateApp(cancellationToken);
536555
break;
556+
case UserDecision.CheckForAppUpdatesAutomatically:
557+
displayWarningInsteadOfError = _app.IsInstalled();
558+
ThreadUpdateApp(cancellationToken);
559+
break;
537560
case UserDecision.CheckForAppUpdates:
538561
ThreadUpdateApp(cancellationToken);
539562
break;
@@ -585,7 +608,14 @@ private void ThreadExecuteUserDecision(CancellationToken cancellationToken)
585608
"Error while executing user decision {0}: an exception has occured.", _userDecision));
586609
DebugLogger.LogException(exception);
587610

588-
ThreadDisplayError(PatcherError.Other, cancellationToken);
611+
if (displayWarningInsteadOfError)
612+
{
613+
_warning.Value = "Unable to check for updates. Please check your internet connection.";
614+
}
615+
else
616+
{
617+
ThreadDisplayError(PatcherError.Other, cancellationToken);
618+
}
589619
}
590620
}
591621

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using UniRx;
3+
using UnityEngine;
4+
using UnityEngine.UI;
5+
6+
namespace PatchKit.Unity.Patcher.UI
7+
{
8+
public class WarningText : MonoBehaviour
9+
{
10+
public Text Text;
11+
12+
private void Start()
13+
{
14+
Patcher.Instance.Warning.ObserveOnMainThread().Subscribe(warning =>
15+
{
16+
Text.text = warning;
17+
}).AddTo(this);
18+
}
19+
}
20+
}

Assets/PatchKit Patcher/Scripts/UI/WarningText.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
- Using geolocation to find closest http server available
1010
- Decides on torrents based on publish_method remote app property
1111

12+
### Changed
13+
- Display warning message when auto-update fails and app is installed
14+
1215
### Fixed
1316
- HTTP downloader resumes the download on error
1417
- Moving files after installation instead of copying them

0 commit comments

Comments
 (0)