public static void Export(string filename) { var file = Path.Combine(Configuration.AutoSaveFolderPath, filename + ".xml"); if (File.Exists(file)) { ConfirmPanel.ShowModal( Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "OverwriteButton"), string.Format(Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "OverwriteConfirmationMessage"), filename), (comp, ret) => { if (ret != 1) { return; } //DebugUtils.Log("Deleting " + file); File.Delete(file); PresetsUtils.Export(filename); Instance.RefreshFileList(); }); } else { PresetsUtils.Export(filename); Instance.RefreshFileList(); } }
/// <summary> /// This destroys all the used resourced, so that we can start fresh if the user wants to load a new game. /// Before destroying everything, we store an auto-save file containing the current configuration. /// </summary> public void OnDestroy() { try { Log.Info($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Destroying..."); // Remove existing auto-save if (File.Exists(Configuration.AutoSaveFilePath)) { File.Delete(Configuration.AutoSaveFilePath); } Log.Info($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Saving networks..."); // Save current networks PresetsUtils.Export(Configuration.AutoSaveFileName); ToggleDetours(false); UnsubscribeFromUIEvents(); // Reset data structures AvailableRoadTypes.Clear(); SelectedRoadTypes.Clear(); AvailableRoadNames = null; IsSnappingEnabled = false; IsLeftHandTraffic = false; _isToolActive = _isToolEnabled = false; _mainWindow.OnToolChanged -= ToolBaseDetour_OnToolChanged; // Unsubscribe to milestones updated Singleton <UnlockManager> .instance.m_milestonesUpdated -= OnMilestoneUpdate; // Destroy UI Destroy(_mainWindow); _mainWindow = null; Log.Info($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Destroyed"); } catch (Exception e) { // HACK - [ISSUE 31] Log._DebugOnlyError($"[{nameof(ParallelRoadTool)}.{nameof(OnDestroy)}] Destroy failed"); Log.Exception(e); } }