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