Get replay working from dropdown menu. (right now everyone has the replay button. We will hide it for most cases later on)

This commit is contained in:
2018-05-09 10:49:54 -05:00
parent d5a04c9d77
commit e7856a9d3e
5 changed files with 94 additions and 10 deletions

View File

@ -139,7 +139,7 @@ namespace EduNetworkBuilder
UpdateVisuals();
NeedsUpdate = false;
}
myNetwork.Tick();
myNetwork.Tick(false);
}
private void LanguagifyComponents()
@ -1419,7 +1419,8 @@ namespace EduNetworkBuilder
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Ping"),true);
if(todo)
{
ItemClickedOn.PingFromHere(destination);
//ItemClickedOn.PingFromHere(destination);
NB.DoActionPingDevice(ItemClickedOn.GetUniqueIdentifier, destination);
myNetwork.ProcessPackets();
UpdateMessages();
}
@ -1433,7 +1434,8 @@ namespace EduNetworkBuilder
todo = destination.Edit(ItemClickedOn, this, NB.Translate("_Traceroute"), true);
if (todo)
{
ItemClickedOn.TracerouteFromHere(destination);
//ItemClickedOn.TracerouteFromHere(destination);
NB.DoActionTracertDevice(ItemClickedOn.GetUniqueIdentifier, destination);
myNetwork.ProcessPackets();
UpdateMessages();
}
@ -2794,5 +2796,32 @@ namespace EduNetworkBuilder
#endregion Random Map Stuff
private void replayToolStripMenuItem_Click(object sender, EventArgs e)
{
//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
ActionCollection actions = OurSettings.GetUserActionCollection();
if (actions == null) return; //nothing to do
if (actions.GetNet == null) return; //Nothing to do
//If we get here, we have a valid network in the current state.
ChangeToPastState(actions.GetNet);
//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(NB.MillisecondsBetweenReplays);
}
}
}