private void DeleteButtonOnEventClicked(UIComponent component, UIMouseEventParameter eventparam) { ConfirmPanel.ShowModal( Locale.Get($"{Configuration.ResourcePrefix}TOOLTIPS", "DeleteButton"), string.Format(Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "DeleteConfirmationMessage"), _fileNameLabel.text), (comp, ret) => { if (ret != 1) { return; } PresetsUtils.Delete(_fileNameLabel.text); if (UISaveWindow.Instance != null) { UISaveWindow.Instance.RefreshFileList(); } else { UILoadWindow.Instance.RefreshFileList(); } }); }
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(); } }
private void SaveLoadButtonOnEventClicked(UIComponent component, UIMouseEventParameter eventparam) { if (UISaveWindow.Instance != null) { UISaveWindow.Export(_fileNameLabel.text); } else { UILoadWindow.Close(); PresetsUtils.Import(_fileNameLabel.text); } }
/// <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); } }
public override void Start() { name = $"{Configuration.ResourcePrefix}NetList"; padding = new RectOffset(4, 4, 4, 0); size = new Vector2(500 - 8 * 2, 200); autoLayoutPadding = new RectOffset(0, 0, 0, 4); autoFitChildrenVertically = true; autoLayout = true; autoLayoutDirection = LayoutDirection.Vertical; backgroundSprite = "GenericPanel"; color = Color.black; _space = AddUIComponent <UIPanel>(); _space.size = new Vector2(1, 1); _items = new List <UINetTypeItem>(); AddItem(null, true); PresetsUtils.Import(Configuration.AutoSaveFileName); }