Skip to content

Commit

Permalink
Multiuser support
Browse files Browse the repository at this point in the history
  • Loading branch information
Vultumast committed Aug 9, 2024
1 parent 920a740 commit 94838bb
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 53 deletions.
61 changes: 31 additions & 30 deletions RainWorldSaveEditor/Editor Classes/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,50 @@
using System.Text;
using System.Threading.Tasks;

namespace RainWorldSaveEditor
namespace RainWorldSaveEditor;

public static class Utils
{
public static class Utils
{
private static ResourceManager _resourceManager = null!;
private static ResourceSet _resourceSet = null!;
public const string RainworldSaveDirectoryPostFix = "AppData\\LocalLow\\Videocult\\Rain World";

public static System.Text.Json.JsonSerializerOptions JSONSerializerOptions { get; private set; } = new() { WriteIndented = true };
private static ResourceManager _resourceManager = null!;
private static ResourceSet _resourceSet = null!;

public static ResourceManager ResourceManager
public static System.Text.Json.JsonSerializerOptions JSONSerializerOptions { get; private set; } = new() { WriteIndented = true };

public static ResourceManager ResourceManager
{
get
{
get
{
if (_resourceManager is null)
_resourceManager = new ResourceManager("RainWorldSaveEditor.Properties.Resources", Assembly.GetExecutingAssembly());
if (_resourceManager is null)
_resourceManager = new ResourceManager("RainWorldSaveEditor.Properties.Resources", Assembly.GetExecutingAssembly());

return _resourceManager;
}
return _resourceManager;
}
}

public static ResourceSet ResourceSet
public static ResourceSet ResourceSet
{
get
{
get
{
if (_resourceSet is null)
_resourceSet = ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true)!;
if (_resourceSet is null)
_resourceSet = ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true)!;

return _resourceSet;
}
return _resourceSet;
}
public static IEnumerable<DictionaryEntry> ResourceList()
}
public static IEnumerable<DictionaryEntry> ResourceList()
{
foreach (var item in ResourceSet)
{
foreach (var item in ResourceSet)
if (item.GetType() != typeof(DictionaryEntry))
{
if (item.GetType() != typeof(DictionaryEntry))
{
Logger.Warn($"Resource: \"{item}\" was not expected type. It was \"{item.GetType()}\"");
continue;
}

yield return (DictionaryEntry)item;
Logger.Warn($"Resource: \"{item}\" was not expected type. It was \"{item.GetType()}\"");
continue;
}
}

yield return (DictionaryEntry)item;
}
}

}
32 changes: 11 additions & 21 deletions RainWorldSaveEditor/Forms/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 37 additions & 2 deletions RainWorldSaveEditor/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,31 @@ private void MainForm_Load(object sender, EventArgs e)
settings.Save();
}

List<string> userDirs = [ ];
var dirs = Directory.GetDirectories("C:\\Users\\");

if (!Directory.Exists(settings.RainWorldSaveDirectory))
foreach (var dir in dirs)
{
Logger.Warn($"RAIN WORLD DIRECTORY DOESNT EXIST WHAT \"{settings.RainWorldSaveDirectory}\"");
if (Directory.Exists(Path.Combine(dir, Utils.RainworldSaveDirectoryPostFix)))
{
userProfileToolStripMenuItem.DropDownItems.Add(Path.GetFileNameWithoutExtension(dir));
var item = userProfileToolStripMenuItem.DropDownItems[userProfileToolStripMenuItem.DropDownItems.Count - 1];
item.Click += Item_Click;
item.Tag = dir;
}
}


if (userProfileToolStripMenuItem.DropDownItems.Count != 0)
{
var item = ((ToolStripMenuItem)userProfileToolStripMenuItem.DropDownItems[0]);
item.Checked = true;
settings.RainWorldSaveDirectory = $"{item.Tag!.ToString()!}\\{Utils.RainworldSaveDirectoryPostFix}";
}



Logger.Warn(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile));

for (var i = 0; i < SlugcatInfo.SlugcatInfos.Length; i++)
{
Expand Down Expand Up @@ -93,6 +113,21 @@ private void MainForm_Load(object sender, EventArgs e)
}
}

private void Item_Click(object? sender, EventArgs e)
{
foreach (var item in userProfileToolStripMenuItem.DropDownItems)
{
var tItem = ((ToolStripMenuItem)item);
if (sender == item)
{
tItem.Checked = true;
settings.RainWorldSaveDirectory = $"{tItem.Tag!.ToString()!}\\{Utils.RainworldSaveDirectoryPostFix}";
}
else
tItem.Checked = false;
}
}

private void SlugcatMenuItem_Click(object? sender, EventArgs e)
{
ToolStripMenuItem menuItem = (ToolStripMenuItem)sender!;
Expand Down

0 comments on commit 94838bb

Please sign in to comment.