-
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite FirstRun module to allow for simple adding of additional steps
- Loading branch information
Showing
13 changed files
with
183 additions
and
87 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
35 changes: 35 additions & 0 deletions
35
osu!StreamCompanion/Code/Modules/FirstRun/FirstRunControl.cs
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,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Windows.Forms; | ||
|
||
namespace osu_StreamCompanion.Code.Modules.FirstRun | ||
{ | ||
public class CompletedEventArgs :EventArgs | ||
{ | ||
public FirstRunControl.status ControlCompletionStatus { get; set; } | ||
} | ||
public class FirstRunControl : UserControl | ||
{ | ||
public event EventHandler<CompletedEventArgs> Completed; | ||
|
||
protected void OnCompleted(status completionStatus) | ||
{ | ||
this.Completed?.Invoke(this,new CompletedEventArgs() {ControlCompletionStatus = completionStatus}); | ||
} | ||
public enum status | ||
{ | ||
Unknown = 0, | ||
Ok = 1, | ||
Fail=2, | ||
} | ||
|
||
public virtual void GotMsn(string msnString) | ||
{ | ||
} | ||
public virtual void GotOsuDirectory(string osuDir) | ||
{ | ||
} | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
osu!StreamCompanion/Code/Modules/FirstRun/FirstRunFrm.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,69 +1,79 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Windows.Forms; | ||
using osu_StreamCompanion.Code.Core; | ||
using osu_StreamCompanion.Code.Misc; | ||
using osu_StreamCompanion.Code.Modules.FirstRun.Phases; | ||
|
||
namespace osu_StreamCompanion.Code.Modules.FirstRun | ||
{ | ||
public partial class FirstRunFrm : Form | ||
{ | ||
private readonly SettingNames _names = SettingNames.Instance; | ||
|
||
private Phase1 _phase1; | ||
private Phase2 _phase2; | ||
|
||
private Settings _settings; | ||
|
||
public bool completedSuccesfully | ||
{ | ||
get { return _phase2 != null; } | ||
} | ||
private List<FirstRunControl> phases = new List<FirstRunControl>(); | ||
public bool CompletedSuccesfully { get; set; } | ||
|
||
public FirstRunFrm(Settings settings) | ||
{ | ||
_settings = settings; | ||
phases.Add(new FirstRunMsn()); | ||
phases.Add(new FirstRunFinish()); | ||
InitializeComponent(); | ||
} | ||
|
||
private int _currentPhase = 0; | ||
public void StartSetup() | ||
{ | ||
_phase1 = new Phase1(); | ||
this.Controls.Add(_phase1); | ||
this.ShowDialog(); | ||
if (phases.Count > 0) | ||
{ | ||
var first = phases[0]; | ||
first.Completed += Phase_Completed; | ||
this.Controls.Add(first); | ||
this.ShowDialog(); | ||
} | ||
else | ||
{ | ||
CompletedSuccesfully = true; | ||
} | ||
} | ||
public void GotMsn(string msnString) | ||
|
||
private void Phase_Completed(object sender, CompletedEventArgs e) | ||
{ | ||
if (_phase1 != null) | ||
this.BeginInvoke((MethodInvoker)delegate | ||
{ | ||
this.BeginInvoke((MethodInvoker)delegate | ||
phases[_currentPhase].Completed -= Phase_Completed; | ||
this.Controls.RemoveAt(0); | ||
if (phases.Count > _currentPhase+1) | ||
{ | ||
this.Controls.RemoveAt(0); | ||
_phase1.Dispose(); | ||
_phase1 = null; | ||
|
||
_phase2 = new Phase2(); | ||
_phase2.button_end.Click += ButtonEndOnClick; | ||
_phase2.label_msnString.Text = msnString; | ||
_phase2.label_osuDirectory.Text = _settings.Get<string>(_names.MainOsuDirectory); | ||
this.Controls.Add(_phase2); | ||
}); | ||
} | ||
if (_phase2 != null) | ||
if (_phase2.Created) | ||
_currentPhase++; | ||
var current = phases[_currentPhase]; | ||
current.Completed += Phase_Completed; | ||
this.Controls.Add(current); | ||
} | ||
else | ||
{ | ||
_phase2.BeginInvoke((MethodInvoker)delegate | ||
CompletedSuccesfully = true; | ||
this.BeginInvoke((MethodInvoker)delegate () | ||
{ | ||
_phase2.label_msnString.Text = msnString; | ||
this.Close(); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
private void ButtonEndOnClick(object sender, EventArgs eventArgs) | ||
public void GotMsn(string msnString) | ||
{ | ||
this.BeginInvoke((MethodInvoker) delegate() | ||
var osuDir = _settings.Get<string>(_names.MainOsuDirectory); | ||
|
||
foreach (var phase in phases) | ||
{ | ||
this.Close(); | ||
}); | ||
phase.GotMsn(msnString); | ||
phase.GotOsuDirectory(osuDir); | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
9 changes: 5 additions & 4 deletions
9
.../Code/Modules/FirstRun/Phase2.Designer.cs → ...irstRun/Phases/FirstRunFinish.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
osu!StreamCompanion/Code/Modules/FirstRun/Phases/FirstRunFinish.cs
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,56 @@ | ||
using System.Windows.Forms; | ||
|
||
namespace osu_StreamCompanion.Code.Modules.FirstRun.Phases | ||
{ | ||
public partial class FirstRunFinish : FirstRunControl | ||
{ | ||
public FirstRunFinish() | ||
{ | ||
InitializeComponent(); | ||
this.HandleCreated += Finish_HandleCreated; | ||
} | ||
|
||
private void Finish_HandleCreated(object sender, System.EventArgs e) | ||
{ | ||
this.label_msnString.Text = msnString; | ||
this.label_osuDirectory.Text = osuDir; | ||
} | ||
|
||
private string msnString; | ||
private string osuDir; | ||
public override void GotMsn(string msnString) | ||
{ | ||
if (this.IsHandleCreated) | ||
{ | ||
this.BeginInvoke((MethodInvoker) delegate | ||
{ | ||
this.label_msnString.Text = msnString; | ||
}); | ||
} | ||
else | ||
{ | ||
this.msnString = msnString; | ||
} | ||
} | ||
|
||
public override void GotOsuDirectory(string osuDir) | ||
{ | ||
if (this.IsHandleCreated) | ||
{ | ||
this.BeginInvoke((MethodInvoker)delegate | ||
{ | ||
this.label_osuDirectory.Text = osuDir; | ||
}); | ||
} | ||
else | ||
{ | ||
this.osuDir = osuDir; | ||
} | ||
} | ||
|
||
private void button_end_Click(object sender, System.EventArgs e) | ||
{ | ||
this.OnCompleted(status.Ok); | ||
} | ||
} | ||
} |
File renamed without changes.
8 changes: 4 additions & 4 deletions
8
.../Code/Modules/FirstRun/Phase1.Designer.cs → ...s/FirstRun/Phases/FirstRunMsn.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
osu!StreamCompanion/Code/Modules/FirstRun/Phases/FirstRunMsn.cs
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,15 @@ | ||
namespace osu_StreamCompanion.Code.Modules.FirstRun.Phases | ||
{ | ||
public partial class FirstRunMsn : FirstRunControl | ||
{ | ||
public FirstRunMsn() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
public override void GotMsn(string msnString) | ||
{ | ||
this.OnCompleted(status.Ok); | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.