Beispiel #1
0
 public static void TipToNewResourcesReference(this DEModPack self)
 {
     try {
         var allowedModPack = from i in DEModManager.GetInstance().ModPacks
                              where !ReferenceEquals(i, self)
                              select i;
         var selector = new View.DEModPackSelectWindow(allowedModPack)
         {
             Owner = Application.Current.MainWindow
         };
         if (selector.ShowDialog() == true)
         {
             foreach (var selectedMod in selector.SelectedModPacks)
             {
                 foreach (var item in selectedMod.Resources)
                 {
                     try {
                         self.NewResource(item.Path);
                     }
                     catch {
                         continue;
                     }
                 }
             }
         }
         DOOMEternal.ModificationSaved = false;
     }
     catch (Exception exp) {
         MessageBox.Show($"添加时模组文件时发生错误,原因:{exp.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #2
0
        public static void TipToRemoveModPack(this DEModManager self, DEModPack modPack)
        {
            var result = MessageBox.Show($"是否删除模组配置:{modPack.PackName}", "警告",
                                         MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            self.RemoveModPack(modPack);
        }
Beispiel #3
0
        public static void TipToUpdateResource(this DEModManager self, DEModResource resource)
        {
            var ofd = new System.Windows.Forms.OpenFileDialog();

            ofd.InitialDirectory = _preOpenModDirectory ?? DOOMEternal.ModPacksDirectory;
            ofd.Title            = $"替换{resource.Path}";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                self.UpdateResource(resource, ofd.FileName);
            }
        }
Beispiel #4
0
        public static async Task <bool> TipToStartGame(this DEModManager self, StartMode startMode)
        {
            if (startMode != StartMode.StartOnly)
            {
                if (!self.IsValidModPackSelected())
                {
                    MessageBox.Show("请先选择一个模组配置", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
                    return(false);
                }
                // 弹出提示窗口,避免误操作
                var result = MessageBox.Show($"加载模组将需要一定时间,在此期间请勿关闭本程序。是否继续?",
                                             $"加载模组:{self.CurrentModPack.PackName}",
                                             MessageBoxButton.YesNo,
                                             MessageBoxImage.Question);
                if (result != MessageBoxResult.Yes)
                {
                    return(false);
                }
            }

            self.IsLaunching = true;
            try {
                switch (startMode)
                {
                case StartMode.LoadOnly:
                    await Task.Run(() => { self.LoadMod(); });

                    break;

                case StartMode.LoadAndStart:
                    await Task.Run(() => { self.LaunchMod(); });

                    break;

                case StartMode.StartOnly:
                    await Task.Run(() => { self.LaunchGame(); });

                    break;

                default:
                    break;
                }
                return(true);
            }
            catch (Exception exp) {
                View.InformationWindow.Show(exp.Message, "启动错误", Application.Current.MainWindow);
                return(false);
            }
            finally {
                self.IsLaunching = false;
            }
        }
Beispiel #5
0
        public static void TipToLoadProfile(this DEModManager self, string file)
        {
            var result = MessageBox.Show("此操作将会重新读取模组配置文件,并丢弃当前设置,是否继续?", "重新读取", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            try {
                self.LoadProfile(file);
            }
            catch (Exception exp) {
                MessageBox.Show(exp.Message, "读取配置文件出错", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #6
0
        public static void TipToSaveProfile(this DEModManager self)
        {
            var result = MessageBox.Show("是否保存当前模组配置?", "保存配置", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result != MessageBoxResult.Yes)
            {
                return;
            }
            try {
                self.SaveProfile(DOOMEternal.LauncherProfileFile);
                DOOMEternal.ModificationSaved = true;
            }
            catch (Exception exp) {
                MessageBox.Show(exp.Message, "保存配置文件出错", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #7
0
        public static void TipToClearUnusedModFiles(this DEModManager self)
        {
            var result = MessageBox.Show("该操作将会移除被使用的模组文件,是否继续?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                try {
                    self.ClearUnusedModFile(out string[] removedFiles);
                    string outputInf = "清理完成,以下文件被移除:\n" + string.Join('\n', removedFiles);
                    View.InformationWindow.Show(outputInf, "清理完成", Application.Current.MainWindow);
                }
                catch (Exception exp) {
                    MessageBox.Show(exp.Message, "文件清理出错", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Beispiel #8
0
        public static void OpenWithEditor(this DEModPack self)
        {
            var setter = new View.DEModPackSetter()
            {
                Owner = Application.Current.MainWindow
            };

            setter.PackName    = self.PackName;
            setter.Description = self.Description;
            setter.ImagePath   = self.ImagePath;

            if (setter.ShowDialog() == true)
            {
                try {
                    if (self.PackName != setter.PackName)
                    {
                        foreach (var modPack in DEModManager.GetInstance().ModPacks)
                        {
                            if (modPack.PackName == setter.PackName)
                            {
                                throw new ArgumentException($"模组配置名[{setter.PackName}]已存在");
                            }
                        }
                    }
                    self.PackName    = setter.PackName;
                    self.Description = setter.Description;
                    if (self.ImagePath != setter.ImagePath)
                    {
                        self.SetImage(setter.ImagePath);
                    }
                    DOOMEternal.ModificationSaved = false;
                }
                catch (Exception exp) {
                    MessageBox.Show(exp.Message, "修改模组配置错误", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Beispiel #9
0
 public static void TipToNewModPack(this DEModManager self)
 {
     try {
         var setter = new View.DEModPackSetter()
         {
             Owner = Application.Current.MainWindow
         };
         setter.PackName    = "模组名";
         setter.Description = "描述信息";
         setter.ImagePath   = DOOMEternal.DefaultModPackImage;
         if (setter.ShowDialog() == true)
         {
             var modPack = self.NewModPack();
             modPack.PackName    = setter.PackName;
             modPack.Description = setter.Description;
             modPack.SetImage(setter.ImagePath);
             self.SetCurrentModPack(modPack);
             DOOMEternal.ModificationSaved = false;
         }
     }
     catch (Exception exp) {
         MessageBox.Show(exp.Message, "添加模组配置错误", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }