Skip to content

Commit

Permalink
Implement #99
Browse files Browse the repository at this point in the history
- Take off where you left off. When you close a project. Everything is saved so the next time you open it you can continue from there.
  • Loading branch information
Traderain committed Aug 31, 2018
1 parent 0589e9c commit de5d8c0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
[submodule "discord-rpc-csharp"]
path = discord-rpc-csharp
url = https://github.com/Lachee/discord-rpc-csharp
26 changes: 22 additions & 4 deletions WolvenKit/Forms/frmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,15 @@ private void createNewMod()

private void SaveMod()
{
var ser = new XmlSerializer(typeof(W3Mod));
var modfile = new FileStream(ActiveMod.FileName, FileMode.Create, FileAccess.Write);
ser.Serialize(modfile, ActiveMod);
modfile.Close();
if (ActiveMod != null)
{
if(ActiveMod.LastOpenedFiles != null)
ActiveMod.LastOpenedFiles = OpenDocuments.Select(x => x.File.FileName).ToList();
var ser = new XmlSerializer(typeof(W3Mod));
var modfile = new FileStream(ActiveMod.FileName, FileMode.Create, FileAccess.Write);
ser.Serialize(modfile, ActiveMod);
modfile.Close();
}
}

public IDockContent DeserializeDockContent(string persistString)
Expand Down Expand Up @@ -634,6 +639,17 @@ private void openMod(string file = "")
{
MessageBox.Show("Failed to upgrade the project!\n" + ex,"Error",MessageBoxButtons.OK,MessageBoxIcon.Error);
}

if (ActiveMod?.LastOpenedFiles != null)
{
foreach (var doc in ActiveMod.LastOpenedFiles)
{
if (File.Exists(doc))
{
LoadDocument(doc);
}
}
}
}

/// <summary>
Expand Down Expand Up @@ -1182,6 +1198,8 @@ private void frmMain_FormClosing(object sender, FormClosingEventArgs e)
if (MainController.Get().ProjectUnsaved)
if (MessageBox.Show("There are unsaved changes in your project. Would you like to save them?", "WolvenKit", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
saveAllFiles();

SaveMod();
}

private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
Expand Down
4 changes: 4 additions & 0 deletions WolvenKit/W3Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ public List<string> DLCFiles
}
}

[Browsable(false)]
public List<string> LastOpenedFiles;


[XmlIgnore]
[ReadOnly(true)]
Expand All @@ -120,6 +123,7 @@ public object Clone()
clone.Name = Name;
clone.FileName = FileName;
clone.version = version;
clone.LastOpenedFiles = LastOpenedFiles;
return clone;
}
}
Expand Down
1 change: 0 additions & 1 deletion discord-rpc-csharp
Submodule discord-rpc-csharp deleted from 817c8a

0 comments on commit de5d8c0

Please sign in to comment.