/// <summary> /// Save state of the editor /// </summary> /// <returns></returns> private SimulatorSave Save() { // create display save DisplaySave displaySave = this.roadDisplay1.Save(); // create editor save SimulatorSave simulatorSave = new SimulatorSave(); // set fields simulatorSave.displaySave = displaySave; simulatorSave.ArbiterRoads = this.arbiterRoads; simulatorSave.SimEngine = this.simEngine; simulatorSave.Mission = this.defaultMissionDescription; if (this.gridSizeToolStripComboBox.SelectedIndex >= 0) simulatorSave.GridSizeIndex = this.gridSizeToolStripComboBox.SelectedIndex; else simulatorSave.GridSizeIndex = 3; // return return simulatorSave; }
/// <summary> /// Restore from a saved editor save /// </summary> /// <param name="es"></param> private void Restore(SimulatorSave es) { // restore the editor this.gridSizeToolStripComboBox.SelectedIndex = es.GridSizeIndex; this.arbiterRoads = es.ArbiterRoads; this.simEngine = es.SimEngine; this.simEngine.simulationMain = this; this.simEngine.SetPropertyGrid(this.SimulatorPropertyGrid); this.defaultMissionDescription = es.Mission; // restore the display this.roadDisplay1.LoadSave(es.displaySave); // attempt to rehash the clients this.clientHandler.ReBindAll(this.simEngine.Vehicles); }