コード例 #1
0
        private void ExportButton_OnMouseClick(BaseScreenComponent sender, Vector2 position)
        {
            Preset preset   = settings.Presets[listBox.SelectedIndex];
            string fileName = string.Join("_", preset.Title.Split(Path.GetInvalidFileNameChars())) + ".json";

            string dirPath  = ModManager.CombinePaths(Application.persistentDataPath, "Mods", "ExportedPresets", mod.FileName);
            string filePath = Path.Combine(dirPath, fileName);

            var messageBox = new DaggerfallMessageBox(uiManager, this, true);

            messageBox.AllowCancel = true;
            messageBox.SetText(string.Format(ModManager.GetText("exportMessage"), preset.Title, filePath));
            messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.OK, true);
            messageBox.OnButtonClick += (source, messageBoxButton) =>
            {
                Directory.CreateDirectory(dirPath);
                File.WriteAllText(filePath, SaveLoadManager.Serialize(typeof(Preset), preset, true));
                source.PopWindow();
            };
            uiManager.PushWindow(messageBox);
        }