Skip to content

Commit

Permalink
Added warning to profile creation overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperbx committed Mar 16, 2021
1 parent eccc88e commit 23aa12c
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Sonic-06-Mod-Manager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
[assembly: ComVisible(false)]
[assembly: Guid("277111e3-79d8-41b5-b0d7-7609dff6e36f")]
[assembly: AssemblyVersion("2.0.0.6")]
[assembly: AssemblyFileVersion("3.3.4.0")]
[assembly: AssemblyFileVersion("3.3.5.0")]
20 changes: 16 additions & 4 deletions Sonic-06-Mod-Manager/src/Environment3/ProfileSelect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,24 @@ private void UpdateInfo()
ListBox_Patches.Items.Clear();
ListBox_Tweaks.Items.Clear();

string noneSelected = "Please select a profile...";
string none = "N/A";

if (ListView_ProfilesList.SelectedItems.Count == 0)
{
string noneSelected = "Please select a profile...";

// No profile selected, so 'disable' preview
ListBox_Mods.Items.Add(noneSelected);
ListBox_Patches.Items.Add(noneSelected);
ListBox_Tweaks.Items.Add(noneSelected);

return;
}

// Update mod info list box
if (Profile.Mods.Count == 0)
{
ListBox_Mods.Items.Add(noneSelected);
ListBox_Mods.Items.Add(none);
}
else
{
Expand All @@ -124,7 +136,7 @@ private void UpdateInfo()
// Update patch info list box
if (Profile.Patches.Count == 0)
{
ListBox_Patches.Items.Add(noneSelected);
ListBox_Patches.Items.Add(none);
}
else
{
Expand All @@ -135,7 +147,7 @@ private void UpdateInfo()
// Update tweak info list box
if (Profile.Tweaks.Count == 0)
{
ListBox_Tweaks.Items.Add(noneSelected);
ListBox_Tweaks.Items.Add(none);
}
else
{
Expand Down
20 changes: 20 additions & 0 deletions Sonic-06-Mod-Manager/src/UnifyProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.Collections.Generic;
using Unify.Serialisers;
using Unify.Globalisation;
using Unify.Messenger;

namespace Unify
{
Expand Down Expand Up @@ -59,6 +60,22 @@ public static void Create(string name, ListView modsList, ListView patchesList)
#endif
string profile = Path.Combine(Program.Profiles, $"{Literal.UseSafeFormattedCharacters(name)}.06mm");

if (File.Exists(profile))
{
DialogResult confirmation = UnifyMessenger.UnifyMessage.ShowDialog
(
"A profile already exists with this name! Would you like to overwrite it?",
"Profile already exists...",
MessageBoxButtons.YesNo,
MessageBoxIcon.Warning
);

if (confirmation == DialogResult.No)
{
return;
}
}

using (StreamWriter sw = File.CreateText(profile))
{
sw.WriteLine($"Sonic '06 Mod Manager\n{DateTime.Now}");
Expand Down Expand Up @@ -107,6 +124,9 @@ public static void Create(string name, ListView modsList, ListView patchesList)
}
}

// Set last used profile to the newly created one
Properties.Settings.Default.General_Profile = name;

Console.WriteLine($"[{DateTime.Now:HH:mm:ss tt}] [Success] Created profile successfully!");
}
#if !DEBUG
Expand Down
2 changes: 1 addition & 1 deletion Sonic-06-Mod-Manager/src/UnifyProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Unify
{
static class Program
{
public static readonly string GlobalVersionNumber = $"Version 3.34";
public static readonly string GlobalVersionNumber = $"Version 3.35";

#if !DEBUG
public static readonly string VersionNumber = GlobalVersionNumber;
Expand Down

0 comments on commit 23aa12c

Please sign in to comment.