More progress towards getting a replay to go

This commit is contained in:
Tim Young 2018-09-22 15:45:37 -05:00
parent 375ea625a6
commit 84304cbc6e
2 changed files with 38 additions and 2 deletions

View File

@ -1687,6 +1687,8 @@ namespace EduNetworkBuilder
{
//replay finished
ReplayInProgress = false;
//If we have succeeded, we need to mark it as passed
//If we have failed to complete, we need to mark it as failed
}
}
}

View File

@ -2168,7 +2168,7 @@ namespace EduNetworkBuilder
}
}
public void LoadNetworkFromResource(string resource)
public void LoadNetworkFromResource(string resource, bool SkipOpeningWindows = false)
{
XmlDocument xmlDoc = new XmlDocument();
//Load(SavePath);
@ -2187,7 +2187,7 @@ namespace EduNetworkBuilder
//myString = System.Text.Encoding.Default.GetString(item);
xmlDoc.LoadXml(myString);
PrepForLoad();
myNetwork.Load(xmlDoc, resource, true);//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
UpdateMenu();
UpdateForm();
}
@ -2829,6 +2829,38 @@ namespace EduNetworkBuilder
#endregion Random Map Stuff
#region network replay stuff
private void replayNetwork(string NetworkName, int delay_between)
{
//Prepare for replay
// reset to original map
// Go through each step and do the actions again in order
NBSettings ourSettings = NB.GetSettings();
if (OurSettings == null) return; //nothing to do
if (OurSettings.ReplayMode == false) return; //We should never be here if we are false.
ActionCollection actions = OurSettings.GetUserActionCollection();
if (actions == null) return; //nothing to do
//Find the replay
NetworkAction replay = actions.FindAction(NetworkName);
if (replay == null) return; //No replay for this network
LoadNetworkFromResource(NetworkName, true);
//Make a boolean that says we are in a replaying state
//make an index that shows the index we are to replay
//make a time for when the next replay happens (.5 sec from now or after all packets are gone)
// On tick. If we are in replay mode.
// Check to see if we need to replay an action
// If so, do it.
// If not, keep ticking
//Disable menuitems & right-click if in replay mode
myNetwork.ReplayInProgress = true;
myNetwork.NextReplayIndex = 0;
myNetwork.NextReplayAction = DateTime.UtcNow.AddMilliseconds(delay_between);
}
private void replayToolStripMenuItem_Click(object sender, EventArgs e)
{
//Prepare for replay
@ -2925,6 +2957,8 @@ namespace EduNetworkBuilder
LBW.ShowDialog();
}
#endregion
private void samplesToolStripMenuItem_DropDownOpening(object sender, EventArgs e)
{
if (OurSettings != null && OurSettings.ReplayMode)