From 84304cbc6e557f4ff0b0514dbd78bc5d2a7ad5d9 Mon Sep 17 00:00:00 2001 From: Tim Young Date: Sat, 22 Sep 2018 15:45:37 -0500 Subject: [PATCH] More progress towards getting a replay to go --- EduNetworkBuilder/Network.cs | 2 ++ EduNetworkBuilder/NetworkBuilder.cs | 38 +++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/EduNetworkBuilder/Network.cs b/EduNetworkBuilder/Network.cs index e4907bb..b708d3e 100644 --- a/EduNetworkBuilder/Network.cs +++ b/EduNetworkBuilder/Network.cs @@ -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 } } } diff --git a/EduNetworkBuilder/NetworkBuilder.cs b/EduNetworkBuilder/NetworkBuilder.cs index 652ae42..b178069 100644 --- a/EduNetworkBuilder/NetworkBuilder.cs +++ b/EduNetworkBuilder/NetworkBuilder.cs @@ -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)