Make reload work for all puzzles. We want to use that when making replays. It is nice to reload it once we know the solution so we can save a clean replay.

This commit is contained in:
Tim Young 2018-10-05 13:58:54 -05:00
parent bee42488d2
commit de5acab132

View File

@ -532,7 +532,7 @@ namespace EduNetworkBuilder
public void UpdateMenu()
{
if (myNetwork.NetworkFilename != "")
if (myNetwork.NetworkFilename != "" || storedNetworkStates.Count > 0)
{
reloadToolStripMenuItem.Enabled = true;
}
@ -2032,6 +2032,17 @@ namespace EduNetworkBuilder
PrepForLoad();
myNetwork.Load(oldfile);
}
else
{
if(storedNetworkStates.Count > 0)
{
Network theNet = storedNetworkStates[storedNetworkStates.Count -1];
storedNetworkStates.Clear();
ForwardstoredNetworkStates.Clear();
PrepForLoad();
LoadNetworkFromNetwork(theNet);
}
}
UpdateMenu();
UpdateForm();
}
@ -2189,6 +2200,7 @@ namespace EduNetworkBuilder
xmlDoc.LoadXml(myString);
PrepForLoad();
myNetwork.Load(xmlDoc, resource, true, SkipOpeningWindows);//Load it from resource. Set the bool saying it was from resource
StoreNetworkState(myNetwork); //Store a clean state
UpdateMenu();
UpdateForm();
}
@ -2205,6 +2217,7 @@ namespace EduNetworkBuilder
UpdateLinks();
UpdateForm();
NBSettings ns = NB.GetSettings();
StoreNetworkState(myNetwork); //Store a clean state
if (ns != null && ns.AutoDHCPAllMachinesAtNetworkLoad)
myNetwork.DoAllDHCP();
}
@ -2212,7 +2225,9 @@ namespace EduNetworkBuilder
private void LoadSolvedResource(string what)
{
PrepForLoad();
LoadNetworkFromResource(what);
StoreNetworkState(myNetwork); //Store a clean state
myNetwork.OverrideFromResources();
UpdateForm();
UpdateMessages();
@ -2225,6 +2240,7 @@ namespace EduNetworkBuilder
//Then "unsolve" it
myNetwork.DoAllClearIPs();
myNetwork.OverrideFromResources();
StoreNetworkState(myNetwork); //Store a clean state
UpdateForm();
UpdateMessages();
}