public override void Update() { if (ListView.SelectedIndex == null) { this.ImportButton.IsEnabled = false; this.DeleteButton.IsEnabled = false; } else { this.ImportButton.IsEnabled = true; this.DeleteButton.IsEnabled = true; } if (this.OK.IsClicked) { DialogsManager.HideDialog(this); } if (DeleteButton.IsClicked) { string sdFile = CreatorMain.Export_ModFile_Directory + "/" + (string)this.ListView.SelectedItem; if (FileOperation.Delete(sdFile)) { player.ComponentGui.DisplaySmallMessage("删除成功!", true, false); UpList(); } else { player.ComponentGui.DisplaySmallMessage("操作失败!", true, false); } } this.ExportOnekeyButton.IsEnabled = File.Exists(CreatorMain.OneKeyFile); this.ExportCopyButton.IsEnabled = File.Exists(CreatorMain.CopyFile); this.ExportOldCopyButton.IsEnabled = File.Exists(CreatorMain.CopyFile); this.ExportOldOnekeyButton.IsEnabled = File.Exists(CreatorMain.OneKeyFile); this.DerivedSpecialButton.IsEnabled = File.Exists(CreatorMain.SpecialCopyFile); if (this.ExportOnekeyButton.IsClicked) { DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView, DataType.OneKey)); } if (this.ExportCopyButton.IsClicked) { DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView)); } if (this.ExportOldCopyButton.IsClicked) { DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView, DataType.OldCopy)); } if (this.ExportOldOnekeyButton.IsClicked) { DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView, DataType.OldOneKey)); } if (this.DerivedSpecialButton.IsClicked) { DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView, DataType.SpecialCopy)); } if (this.ImportButton.IsClicked) { Task.Run(() => { if (!Directory.Exists(CreatorMain.CacheDirectory)) { Directory.CreateDirectory(CreatorMain.CacheDirectory); } string fileName = CreatorMain.Export_ModFile_Directory + "/" + (string)this.ListView.SelectedItem; if (FileOperation.IsFileInUse(fileName)) { player.ComponentGui.DisplaySmallMessage($"操作失败...\n{fileName}", true, false); DialogsManager.HideDialog(this); return; } if (Path.GetExtension(fileName) == ".oMod2") { OnekeyGeneration.ImportOnekeyoMod2(CreatorMain.OneKeyFile, fileName); player.ComponentGui.DisplaySmallMessage("导入一键生成MOD配置文件成功!", true, false); } else if (Path.GetExtension(fileName) == ".wMod2") { CopyAndPaste.ImportCopywMod2(CreatorMain.CopyFile, fileName); player.ComponentGui.DisplaySmallMessage("导入复制MOD配置文件成功!", true, false); } else if (Path.GetExtension(fileName) == ".wMod") { CopyAndPaste.ImportCopywMod(CreatorMain.CopyFile, fileName); player.ComponentGui.DisplaySmallMessage("导入复制MOD配置文件成功!", true, false); } else if (Path.GetExtension(fileName) == ".oMod") { player.ComponentGui.DisplaySmallMessage("抱歉,一键生成的旧文件数据无法导入!", true, false); } else if (Path.GetExtension(fileName) == ".sMod") { if (!Directory.Exists(CreatorMain.CacheDirectory)) { Directory.CreateDirectory(CreatorMain.CacheDirectory); } string sdFile = CreatorMain.SpecialCopyFile; if (!FileOperation.IsFileInUse(fileName) && (!File.Exists(sdFile) || !FileOperation.IsFileInUse(sdFile))) { FileStream fileStream = new FileStream(fileName, FileMode.Open); FileStream file = new FileStream(sdFile, FileMode.Create); fileStream.CopyTo(file); file.Dispose(); fileStream.Dispose(); player.ComponentGui.DisplaySmallMessage("导入成功!", true, false); } else { player.ComponentGui.DisplaySmallMessage("操作失败!", true, false); } } else { player.ComponentGui.DisplaySmallMessage($"操作失败...\n{fileName}", true, false); } }); DialogsManager.HideDialog(this); } }
public override void Update() { if (this.cancelButton.IsClicked) { DialogsManager.HideDialog(this); } if (this.OK.IsClicked) { string dir = CreatorMain.Export_ModFile_Directory; string name; if (TextBox.Text.Length <= 0) { name = $"{DateTime.Now.ToString("yyyy-MM-dd")}_{DateTime.Now.ToLongTimeString().ToString()}"; } else { name = TextBox.Text; } try { if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } string fileName = dir + "/" + name + ".wMod2";; if (this.dataType == DataType.Copy) { CopyAndPaste.ExportCopywMod2(CreatorMain.CopyFile, fileName); } else if (this.dataType == DataType.OneKey) { fileName = dir + "/" + name + ".oMod2"; OnekeyGeneration.ExportOnekeyoMod2(CreatorMain.OneKeyFile, fileName); } else if (this.dataType == DataType.OldCopy) { fileName = dir + "/" + name + ".wMod"; CopyAndPaste.ExportCopywMod(CreatorMain.CopyFile, fileName); } else if (this.dataType == DataType.OldOneKey) { fileName = dir + "/" + name + ".oMod"; OnekeyGeneration.ExportOnekeyoMod(CreatorMain.OneKeyFile, fileName); } else if (this.dataType == DataType.SpecialCopy) { fileName = dir + "/" + name + ".sMod"; FileStream fileStream = new FileStream(CreatorMain.SpecialCopyFile, FileMode.Open); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } FileStream files = new FileStream(fileName, FileMode.OpenOrCreate); fileStream.CopyTo(files); files.Dispose(); fileStream.Dispose(); } this.player.ComponentGui.DisplaySmallMessage($"导出成功!文件所在位置:\n{fileName}", true, false); DialogsManager.HideDialog(this); this.listView.ClearItems(); if (!Directory.Exists(CreatorMain.Export_ModFile_Directory)) { Directory.CreateDirectory(CreatorMain.Export_ModFile_Directory); } foreach (string file in Directory.GetFiles(CreatorMain.Export_ModFile_Directory)) { if (Path.GetExtension(file) == ".oMod" || Path.GetExtension(file) == ".wMod" || Path.GetExtension(file) == ".oMod2" || Path.GetExtension(file) == ".wMod2" || Path.GetExtension(file) == ".sMod") { this.listView.AddItem(Path.GetFileName(file)); } } } catch (Exception e) { this.player.ComponentGui.DisplaySmallMessage($"发生了一个很严重的错误,\n 错误提示 :{e.Message}\n{dir}", true, false); DialogsManager.HideDialog(this); DialogsManager.HideDialog(this.dialog); } DialogsManager.HideDialog(this); } }
public override void Update() { if (this.DirectionSetButton.IsClicked) { if (creatorAPI.pasteRotate) { creatorAPI.pasteRotate = false; this.DirectionSetButton.Color = Color.Red; } else { creatorAPI.pasteRotate = true; this.DirectionSetButton.Color = Color.Yellow; } } if (this.LimitButton.IsClicked) { if (creatorAPI.pasteLimit) { creatorAPI.pasteLimit = false; this.LimitButton.Color = Color.Red; } else { creatorAPI.pasteLimit = true; this.LimitButton.Color = Color.Yellow; } } if (this.cancelButton.IsClicked) { DialogsManager.HideDialog(this); } if (this.PasteButton.IsClicked) { if (!FileOperation.IsFileInUse(CreatorMain.CopyFile)) { Task.Run(() => { try { CopyAndPaste.PasetData(creatorAPI, CreatorMain.CopyFile, creatorAPI.Position[0], creatorAPI.Position[1]); }catch (Exception e) { player.ComponentGui.DisplaySmallMessage(e.Message, true, false); } }); } else { player.ComponentGui.DisplaySmallMessage("操作失败!", true, false); } DialogsManager.HideDialog(this); } if (this.MirrorButton.IsClicked) { if (!FileOperation.IsFileInUse(CreatorMain.CopyFile)) { Task.Run(() => { try { CopyAndPaste.MirrorData(creatorAPI, CreatorMain.CopyFile, creatorAPI.Position[0], creatorAPI.Position[1]); } catch (Exception e) { player.ComponentGui.DisplaySmallMessage(e.Message, true, false); } }); } else { player.ComponentGui.DisplaySmallMessage("操作失败!", true, false); } DialogsManager.HideDialog(this); } if (this.ImportButton.IsClicked) { if (!Directory.Exists(CreatorMain.CacheDirectory)) { Directory.CreateDirectory(CreatorMain.CacheDirectory); } string sdFile = CreatorMain.CopyFile; string _sdFile = CreatorMain.Export_CopyFile_Directory + "/" + (string)this.ListView.SelectedItem; if (!FileOperation.IsFileInUse(_sdFile) && (!File.Exists(sdFile) || !FileOperation.IsFileInUse(sdFile))) { FileStream fileStream = new FileStream(_sdFile, FileMode.Open); FileStream file = new FileStream(sdFile, FileMode.Create); fileStream.CopyTo(file); file.Dispose(); fileStream.Dispose(); player.ComponentGui.DisplaySmallMessage("导入成功!", true, false); } else { player.ComponentGui.DisplaySmallMessage("操作失败!", true, false); } DialogsManager.HideDialog(this); } if (DeleteButton.IsClicked) { string sdFile = CreatorMain.Export_CopyFile_Directory + "/" + (string)this.ListView.SelectedItem; if (FileOperation.Delete(sdFile)) { player.ComponentGui.DisplaySmallMessage("删除成功!", true, false); UpList(); } else { player.ComponentGui.DisplaySmallMessage("操作失败!", true, false); } } this.DerivedButton.IsEnabled = File.Exists(CreatorMain.CopyFile); if (this.DerivedButton.IsClicked) { DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView)); } if (this.CopyButton.IsClicked) { Task.Run(() => { try { if (!Directory.Exists(CreatorMain.CacheDirectory)) { Directory.CreateDirectory(CreatorMain.CacheDirectory); } CopyAndPaste.CreateCopy(creatorAPI, CreatorMain.CacheDirectory, "CacheFile.cd", creatorAPI.Position[0], creatorAPI.Position[1]); } catch (Exception e) { player.ComponentGui.DisplaySmallMessage(e.Message, true, false); } }); DialogsManager.HideDialog(this); } if (ListView.SelectedIndex == null) { this.ImportButton.IsEnabled = false; this.DeleteButton.IsEnabled = false; } else { this.ImportButton.IsEnabled = true; this.DeleteButton.IsEnabled = true; } this.specialCopyButton.IsEnabled = CreatorMain.professional; this.specialPasteButton.IsEnabled = CreatorMain.professional; if (this.specialCopyButton.IsClicked) { Task.Run(() => { try { if (!Directory.Exists(CreatorMain.CacheDirectory)) { Directory.CreateDirectory(CreatorMain.CacheDirectory); } CopyAndPaste.CreateSpecialCopy(creatorAPI, CreatorMain.SpecialCopyFile, creatorAPI.Position[0], creatorAPI.Position[1]); } catch (Exception e) { player.ComponentGui.DisplaySmallMessage(e.Message, true, false); } }); DialogsManager.HideDialog(this); } this.specialPasteButton.IsEnabled = File.Exists(CreatorMain.SpecialCopyFile); if (this.specialPasteButton.IsClicked) { Task.Run(() => { try { CopyAndPaste.SpecialPasetData(creatorAPI, CreatorMain.SpecialCopyFile, creatorAPI.Position[0], creatorAPI.Position[1]); } catch (Exception e) { player.ComponentGui.DisplaySmallMessage(e.Message, true, false); } }); DialogsManager.HideDialog(this); } }