Skip to content

Commit a2da83b

Browse files
committed
Preparation for AutoSplitterCore 3.0 integration
(See #36)
1 parent e537ec7 commit a2da83b

5 files changed

Lines changed: 108 additions & 16 deletions

File tree

Sources/AutoSplitterCoreModule.cs

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//MIT License
22

3-
//Copyright (c) 2024-2024 Peter Kirmeier
3+
//Copyright (c) 2024-2025 Peter Kirmeier
44

55
//Permission is hereby granted, free of charge, to any person obtaining a copy
66
//of this software and associated documentation files (the "Software"), to deal
@@ -20,10 +20,11 @@
2020
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
//SOFTWARE.
2222

23-
using System.Reflection;
2423
using System;
25-
using System.IO;
24+
using System.Collections.Generic;
2625
using System.Collections.ObjectModel;
26+
using System.IO;
27+
using System.Reflection;
2728
using static HitCounterManager.IAutoSplitterCoreInterface;
2829

2930
namespace HitCounterManager
@@ -39,32 +40,67 @@ public interface IAutoSplitterCoreInterface
3940
int ActiveGameIndex { get; set; }
4041

4142
/// <summary>
42-
/// ????
43+
/// Gets or sets the ASC practice mode activation (no automatic splitting).
4344
/// </summary>
4445
bool PracticeMode { get; set; }
4546

47+
/// <summary>
48+
/// Gets or sets the currently selected profile name.
49+
/// </summary>
50+
string ProfileName { get; set; }
51+
52+
/// <summary>
53+
/// Gets all profile names.
54+
/// </summary>
55+
/// <returns></returns>
56+
List<string> ProfileNames { get; }
57+
58+
/// <summary>
59+
/// Create a profile with the given new name and select it.
60+
/// </summary>
61+
/// <param name="NewName">Name of the new profile</param>
62+
void ProfileNew(string NewName);
63+
4664
/// <summary>
4765
/// Start over a new run.
4866
/// Increased the attempt counter, select first split and reset all values.
4967
/// </summary>
5068
void ProfileReset();
5169

5270
/// <summary>
53-
/// Amount of available splitsin the current run.
71+
/// Amount of available splits in the current run.
5472
/// </summary>
5573
int SplitCount { get; }
5674

75+
/// <summary>
76+
/// Gets all split names of the currently selected profile.
77+
/// </summary>
78+
List<string> SplitsNames { get; }
79+
5780
/// <summary>
5881
/// Index of currently active split.
5982
/// </summary>
6083
int ActiveSplit { get; }
6184

6285
/// <summary>
63-
/// Modifies the currently selected split by Amount.
86+
/// Creates a split at the end of the splits with the given new name.
87+
/// </summary>
88+
/// <param name="NewName">Name of the new split</param>
89+
void SplitAppendNew(string NewName);
90+
91+
/// <summary>
92+
/// Modifies the currently selected split by given <paramref name="Amount"/>.
6493
/// </summary>
6594
/// <param name="Amount">Amount of splits that will be moved forwards/backwards</param>
6695
void ProfileSplitGo(int Amount);
6796

97+
/// <summary>
98+
/// Inreases or decreases the hit counts of the currently selected split by <paramref name="Amount"/>.
99+
/// </summary>
100+
/// <param name="Amount">Positive values will increase and negative will decrease hit count respectively</param>
101+
/// <param name="IsWayHit">true = count towards way hits, false = count towards (boss) hits</param>
102+
public void HitSumUp(int Amount, bool IsWayHit);
103+
68104
/// <summary>
69105
/// Indicates if timer is currently running.
70106
/// </summary>
@@ -125,7 +161,7 @@ public interface IAutoSplitterCoreInterface
125161
Action<int /* ActiveGameIndex */> SetActiveGameIndexMethod { get; set; }
126162

127163
/// <summary>
128-
/// Method that gets called when the user changes the tPracticeMode.
164+
/// Method that gets called when the user changes the PracticeMode.
129165
/// A bool will be given with the new PracticeMode setting.
130166
/// The method should be filled once the registration method is called.
131167
/// </summary>
@@ -137,6 +173,13 @@ public interface IAutoSplitterCoreInterface
137173
/// </summary>
138174
Action SplitterResetMethod { get; set; }
139175

176+
/// <summary>
177+
/// Method that gets called when another profile got selected.
178+
/// A string will be given with the new selected profile name.
179+
/// The method should be filled once the registration method is called.
180+
/// </summary>
181+
Action<string /* ProfileName */> ProfileSelectedMethod { get; set; }
182+
140183
#endregion
141184
}
142185

@@ -206,6 +249,8 @@ public bool GetCurrentInGameTime(out long totalTimeMs)
206249

207250
public void SplitterReset() => SplitterResetMethod?.Invoke();
208251

252+
public void ProfileSelected(string ProfileName) => ProfileSelectedMethod?.Invoke(ProfileName);
253+
209254
#region IAutoSplitterCoreInterface
210255

211256
public int ActiveGameIndex
@@ -220,14 +265,34 @@ public bool PracticeMode
220265
set => form1.PracticeModeCheck.Checked = value;
221266
}
222267

268+
public string ProfileName
269+
{
270+
get => profCtrl.SelectedProfileInfo.ProfileName;
271+
set => profCtrl.SelectedProfileInfo.ProfileName = value;
272+
}
273+
274+
public List<string> ProfileNames => [.. profCtrl.GetProfileList()];
275+
276+
public void ProfileNew(string NewName) => profCtrl.ProfileNew(NewName);
277+
223278
public void ProfileReset() => profCtrl.ProfileReset();
224279

225280
public int SplitCount => profCtrl.SelectedProfileInfo.SplitCount;
226281

282+
public List<string> SplitsNames => profCtrl.SelectedProfileInfo.SplitNames;
283+
227284
public int ActiveSplit => profCtrl.SelectedProfileInfo.ActiveSplit;
228285

286+
public void SplitAppendNew(string NewName) => profCtrl.SelectedProfileInfo.AddSplit(NewName, 0, 0, 0, 0, 0, 0);
287+
229288
public void ProfileSplitGo(int Amount) => profCtrl.ProfileSplitGo(Amount);
230289

290+
public void HitSumUp(int Amount, bool IsWayHit)
291+
{
292+
if (IsWayHit) profCtrl.SelectedProfileInfo.WayHit(Amount);
293+
else profCtrl.SelectedProfileInfo.Hit(Amount);
294+
}
295+
231296
public bool TimerRunning => profCtrl.TimerRunning;
232297

233298
public void StartStopTimer(bool Start) => form1.StartStopTimer(Start);
@@ -248,6 +313,8 @@ public bool PracticeMode
248313

249314
public Action SplitterResetMethod { get; set; }
250315

316+
public Action<string /* ProfileName */> ProfileSelectedMethod { get; set; }
317+
251318
#endregion
252319
}
253320
}

Sources/Form1.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//MIT License
22

3-
//Copyright (c) 2016-2024 Peter Kirmeier and Ezequiel Medina
3+
//Copyright (c) 2016-2025 Peter Kirmeier and Ezequiel Medina
44

55
//Permission is hereby granted, free of charge, to any person obtaining a copy
66
//of this software and associated documentation files (the "Software"), to deal
@@ -200,7 +200,13 @@ private void btnCheckVersion_Click(object sender, EventArgs e)
200200
}
201201
private void btnAbout_Click(object sender, EventArgs e) { new About().ShowDialog(this); }
202202

203-
private void btnNew_Click(object sender, EventArgs e) { profCtrl.ProfileNew(); }
203+
private void btnNew_Click(object sender, EventArgs e)
204+
{
205+
string NameNew = VisualBasic.Interaction.InputBox("Enter name of new profile", "New profile", profCtrl.SelectedProfile);
206+
if (NameNew.Length == 0) return;
207+
208+
profCtrl.ProfileNew(NameNew);
209+
}
204210
private void btnRename_Click(object sender, EventArgs e) { profCtrl.ProfileRename(); }
205211
private void btnCopy_Click(object sender, EventArgs e) { profCtrl.ProfileCopy(); }
206212
private void btnDelete_Click(object sender, EventArgs e) { profCtrl.ProfileDelete(); }

Sources/ProfileViewControl.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,22 @@ public int AttemptsCount
387387
[Browsable(false)] // Hide from designer
388388
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // Hide from designer generator
389389
public int SplitCount { get { return RowCount - 1; } } // Remove the "new line"
390-
390+
391+
[Browsable(false)] // Hide from designer
392+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // Hide from designer generator
393+
public List<string> SplitNames
394+
{
395+
get
396+
{
397+
List<string> splitsNames = new(SplitCount);
398+
for (int Index = 0; Index < SplitCount; Index++)
399+
{
400+
splitsNames.Add(GetSplitTitle(Index));
401+
}
402+
return splitsNames;
403+
}
404+
}
405+
391406
[Browsable(false)] // Hide from designer
392407
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] // Hide from designer generator
393408
public int ActiveSplit

Sources/Profiles.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//MIT License
22

3-
//Copyright (c) 2016-2022 Peter Kirmeier
3+
//Copyright (c) 2016-2025 Peter Kirmeier
44

55
//Permission is hereby granted, free of charge, to any person obtaining a copy
66
//of this software and associated documentation files (the "Software"), to deal
@@ -215,6 +215,12 @@ public interface IProfileInfo
215215
/// </summary>
216216
int SplitCount { get; }
217217

218+
/// <summary>
219+
/// Return all split names
220+
/// </summary>
221+
/// <returns></returns>
222+
List<string> SplitNames { get; }
223+
218224
/// <summary>
219225
/// Index of currently active split
220226
/// </summary>

Sources/ProfilesControl.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//MIT License
22

3-
//Copyright (c) 2019-2024 Peter Kirmeier
3+
//Copyright (c) 2019-2025 Peter Kirmeier
44

55
//Permission is hereby granted, free of charge, to any person obtaining a copy
66
//of this software and associated documentation files (the "Software"), to deal
@@ -124,6 +124,7 @@ public void SetIGTSource(MethodInfo ReturnCurrentIGT, MethodInfo GetIsIGTActive,
124124
this.ReturnCurrentIGT = ReturnCurrentIGT;
125125
this.GetIsIGTActive = GetIsIGTActive;
126126
}
127+
public string[] GetProfileList() => profs.GetProfileList();
127128
#endregion
128129

129130
#region Succession related
@@ -300,11 +301,8 @@ private void ProfileTabSelect(object sender, ProfileTabControl.ProfileTabSelectA
300301
}
301302
}
302303

303-
public void ProfileNew()
304+
public void ProfileNew(string NameNew)
304305
{
305-
string NameNew = VisualBasic.Interaction.InputBox("Enter name of new profile", "New profile", SelectedProfile);
306-
if (NameNew.Length == 0) return;
307-
308306
if (profs.HasProfile(NameNew))
309307
{
310308
MessageBox.Show("A profile with this name already exists!", "Profile already exists", MessageBoxButtons.OK, MessageBoxIcon.Stop);

0 commit comments

Comments
 (0)