Skip to content

Commit

Permalink
Remember Selected Path
Browse files Browse the repository at this point in the history
  • Loading branch information
KorGgenT committed Dec 4, 2019
1 parent 891b236 commit aa0f7e7
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ bin/
*.exe
*.pdb
*.zip
cdda_data_path
44 changes: 41 additions & 3 deletions selector.Designer.cs

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

40 changes: 36 additions & 4 deletions selector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,27 @@ public partial class SelectorForm : Form
{
private void TryLoadObjectLists()
{
cddaFolderBrowserDialog.ShowDialog();
if(cddaFolderBrowserDialog.SelectedPath == "")
string cdda_path;
try
{
string cdda_path_file = System.Windows.Forms.Application.StartupPath + "\\cdda_data_path";
cdda_path = File.ReadAllText(cdda_path_file);
}
catch
{
cddaFolderBrowserDialog.ShowDialog();
cdda_path = cddaFolderBrowserDialog.SelectedPath;
}
currentPathLabel.Text = cdda_path;
if (cdda_path == "")
{
return;
}
DirectoryInfo dir = new DirectoryInfo(cddaFolderBrowserDialog.SelectedPath);
else
{
File.WriteAllText(Application.StartupPath + "\\cdda_data_path", cdda_path);
}
DirectoryInfo dir = new DirectoryInfo(cdda_path);
foreach (FileInfo file in dir.GetFiles("*.json", SearchOption.AllDirectories))
{
string file_text = File.ReadAllText(file.FullName);
Expand All @@ -39,7 +54,8 @@ private void TryLoadObjectLists()
switch (generic_object.Type)
{
case "MONSTER":
Program.LoadedObjectDictionary.Add(generic_object.Id, (Mtype)obj.ToObject(typeof(Mtype)));
Mtype temp = (Mtype)obj.ToObject(typeof(Mtype));
Program.LoadedObjectDictionary.Add(generic_object.Id, temp);
break;
case "SPELL":
Program.LoadedObjectDictionary.Add(generic_object.Id, (spell.spell_type)obj.ToObject(typeof(spell.spell_type)));
Expand Down Expand Up @@ -86,6 +102,22 @@ private void viewLoadedItemsButton_Click(object sender, EventArgs e)
form.ShowDialog();
this.Show();
}

private void loadGameDialog_Click(object sender, EventArgs e)
{
string cdda_path;
cddaFolderBrowserDialog.ShowDialog();
cdda_path = cddaFolderBrowserDialog.SelectedPath;
currentPathLabel.Text = cdda_path;
if (cdda_path == "")
{
return;
}
else
{
File.WriteAllText(Application.StartupPath + "\\cdda_data_path", cdda_path);
}
}
}
public class GenericTypedObject
{
Expand Down

0 comments on commit aa0f7e7

Please sign in to comment.