@@ -21,8 +21,8 @@ namespace Refresher.UI;
21
21
private TPipeline ? _pipeline ;
22
22
23
23
private readonly Button _button ;
24
- private readonly Button _revertButton ;
25
- private readonly Button _autoDiscoverButton ;
24
+ private readonly Button ? _revertButton ;
25
+ private readonly Button ? _autoDiscoverButton ;
26
26
private readonly ProgressBar _currentProgressBar ;
27
27
private readonly ProgressBar _progressBar ;
28
28
private readonly ListBox _messages ;
@@ -38,6 +38,7 @@ namespace Refresher.UI;
38
38
39
39
public PipelineForm ( ) : base ( typeof ( TPipeline ) . Name , new Size ( 700 , - 1 ) , false )
40
40
{
41
+ StackLayout layout ;
41
42
this . Content = new Splitter
42
43
{
43
44
Orientation = Orientation . Vertical ,
@@ -47,14 +48,12 @@ namespace Refresher.UI;
47
48
Spacing = new Size ( 5 , 5 ) ,
48
49
Padding = new Padding ( 0 , 0 , 0 , 10 ) ,
49
50
} ,
50
- Panel2 = new StackLayout ( [
51
+ Panel2 = layout = new StackLayout ( [
51
52
new StackLayoutItem ( this . _messages = new ListBox
52
53
{
53
54
Height = - 1 ,
54
55
} , VerticalAlignment . Top , true ) ,
55
56
this . _button = new Button ( this . OnButtonClick ) { Text = "Patch!" } ,
56
- this . _revertButton = new Button ( this . OnRevertEbootClick ) { Text = "Revert EBOOT" } ,
57
- this . _autoDiscoverButton = new Button ( this . OnAutoDiscoverClick ) { Text = "AutoDiscover" } ,
58
57
new Button ( this . OnViewGuideClick ) { Text = "View Guide" } ,
59
58
this . _currentProgressBar = new ProgressBar ( ) ,
60
59
this . _progressBar = new ProgressBar ( ) ,
@@ -71,6 +70,18 @@ namespace Refresher.UI;
71
70
this . InitializePipeline ( ) ;
72
71
this . InitializeFormStateUpdater ( ) ;
73
72
73
+ if ( this . _pipeline ? . ReplacesEboot ?? false )
74
+ {
75
+ this . _revertButton = new Button ( this . OnRevertEbootClick ) { Text = "Revert EBOOT" } ;
76
+ layout . Items . Insert ( 2 , this . _revertButton ) ;
77
+ }
78
+
79
+ if ( this . _pipeline ? . RequiredInputs . Any ( i => i == CommonStepInputs . ServerUrl ) ?? false )
80
+ {
81
+ this . _autoDiscoverButton = new Button ( this . OnAutoDiscoverClick ) { Text = "AutoDiscover" } ;
82
+ layout . Items . Insert ( 2 , this . _autoDiscoverButton ) ;
83
+ }
84
+
74
85
State . Log += this . OnLog ;
75
86
}
76
87
@@ -89,14 +100,19 @@ private void UpdateFormState()
89
100
90
101
// disable other things
91
102
this . _formLayout . Enabled = enableControls ;
92
- this . _autoDiscoverButton . Enabled = enableControls && this . _pipeline ? . AutoDiscover == null ;
93
- this . _revertButton . Enabled = enableControls ;
103
+ if ( this . _autoDiscoverButton != null )
104
+ this . _autoDiscoverButton . Enabled = enableControls && this . _pipeline ? . AutoDiscover == null ;
105
+ if ( this . _revertButton != null )
106
+ this . _revertButton . Enabled = enableControls ;
94
107
95
108
// set text of autodiscover button
96
- if ( this . _autoDiscoverCts != null )
97
- this . _autoDiscoverButton . Text = "Running AutoDiscover... (click to cancel)" ;
98
- else if ( this . _pipeline ? . AutoDiscover == null )
99
- this . _autoDiscoverButton . Text = "AutoDiscover" ;
109
+ if ( this . _autoDiscoverButton != null )
110
+ {
111
+ if ( this . _autoDiscoverCts != null )
112
+ this . _autoDiscoverButton . Text = "Running AutoDiscover... (click to cancel)" ;
113
+ else if ( this . _pipeline ? . AutoDiscover == null )
114
+ this . _autoDiscoverButton . Text = "AutoDiscover" ;
115
+ }
100
116
101
117
this . _button . Text = this . _pipeline ? . State switch
102
118
{
@@ -195,9 +211,9 @@ private void OnButtonClick(object? sender, EventArgs e)
195
211
this . _pipeline . Reset ( ) ;
196
212
}
197
213
198
- if ( ! this . _usedAutoDiscover )
214
+ if ( ! this . _usedAutoDiscover && this . _autoDiscoverButton != null )
199
215
{
200
- DialogResult result = MessageBox . Show ( "You didn 't use AutoDiscover. Would you like to try to run it now?" , "AutoDiscover" ,
216
+ DialogResult result = MessageBox . Show ( "You haven 't used AutoDiscover. Would you like to try to run it now?" , "AutoDiscover" ,
201
217
MessageBoxButtons . YesNoCancel , MessageBoxType . Question ) ;
202
218
203
219
// ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
0 commit comments