public void addLoadedFile(string path, string file, GameData.ModMode mode)
        {
            string extension = Path.GetExtension(file);

            if (extension == ".mod" || extension == ".translation")
            {
                head.isAMod = true;
                this.activeMods.Add(file);
            }
            if (mode == GameData.ModMode.ACTIVE)
            {
                this.nav.HasChanges = false;
                this.nav.setActiveFilename(string.Concat(path, file), navigation.ModFileMode.USER);
                this.updateTitle();
                GameData.nullDesc.description = "这个值不再被游戏使用";
            }
            System.Windows.Forms.Cursor.Current = Cursors.WaitCursor;
            if (!this.nav.ou.gameData.load(string.Concat(path, "\\", file), mode, false))
            {
                baseForm.logger.Error("加载MOD错误 '{0}'.", file);
                return;
            }
            if (mode == GameData.ModMode.ACTIVE)
            {
                baseForm.logger.Info("已加载MOD '{0}'. (激活MOD)", file);
                return;
            }
            baseForm.logger.Info("已加载 '{0}'.", file);
        }
Exemple #2
0
        private void loadButton_Click(object sender, EventArgs e)
        {
            string          str;
            List <TreeNode> treeNodes = new List <TreeNode>();

            foreach (TreeNode node in this.baseList.Nodes)
            {
                if (!node.Checked)
                {
                    continue;
                }
                treeNodes.Add(node);
            }
            foreach (TreeNode treeNode in this.modList.Nodes)
            {
                if (!treeNode.Checked)
                {
                    continue;
                }
                treeNodes.Add(treeNode);
            }
            if (treeNodes[0].TreeView != this.baseList)
            {
                MessageBox.Show("您将要加载没有激活基本文件的mod。\n这可能会导致无效的引用。 被覆盖的项目将显示不正确,您可能会因加载产生大量的错误消息。", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            InheritFiles.DependencyState dependencyState = InheritFiles.DependencyState.OK;
            List <string> strs = new List <string>();

            foreach (TreeNode treeNode1 in treeNodes)
            {
                InheritFiles.DependencyState dependencyState1 = this.checkDependencies(treeNode1);
                if (dependencyState1 == InheritFiles.DependencyState.OK)
                {
                    continue;
                }
                strs.Add(treeNode1.Text);
                if (dependencyState == InheritFiles.DependencyState.MISSING_DEPENDENCIES)
                {
                    continue;
                }
                dependencyState = dependencyState1;
            }
            if (dependencyState == InheritFiles.DependencyState.MISSING_DEPENDENCIES)
            {
                if (MessageBox.Show(string.Concat("您正在尝试加载缺少依赖文件的 ", string.Join(", ", strs), ". 这将导致任何已修改的项目显示为已损坏或缺少某些数据.\n你确定要继续么?"), "缺少依赖", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
            }
            else if (dependencyState == InheritFiles.DependencyState.MISSING_REFERENCES && MessageBox.Show(string.Concat("您正在尝试加载缺少外部引用Mod的MOD ", string.Join(", ", strs), " 这些MOD引用了其他MOD的项目. 这将会导致部分的项目出现非法引用.\n你确定要继续么?"), "缺少依赖", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }
            if (this.activeNode != null && this.activeNode.TreeView == this.baseList && !this.parentForm.nav.SecretDeveloperMode && MessageBox.Show("您即将编辑游戏的主要数据文件之一,我想也许这不应该时你的本意\n\n因为如果你改变这个文件,你的更改将在你下次更新游戏时丢失.您也将无法与其他人共享您的mod.\n您应该创建一个新的mod文件以更改游戏数据,这将使您的更改保持独立.\n\n你确定要继续么?", "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != System.Windows.Forms.DialogResult.Yes)
            {
                return;
            }
            this.parentForm.clearScene();
            head.isAMod = false;
            this.parentForm.nav.ou.gameData.clear();
            this.parentForm.nav.BasePath = this.baseDir;
            this.parentForm.nav.FileMode = navigation.ModFileMode.BASE;
            GameData.ModMode modMode = GameData.ModMode.BASE;
            foreach (TreeNode treeNode2 in treeNodes)
            {
                if (treeNode2 == this.activeNode)
                {
                    modMode = GameData.ModMode.ACTIVE;
                }
                else if (modMode == GameData.ModMode.ACTIVE)
                {
                    modMode = GameData.ModMode.LOCKED;
                }
                if (modMode == GameData.ModMode.ACTIVE && this.cbTranslationMode.Checked)
                {
                    modMode = GameData.ModMode.BASE;
                }
                if (treeNode2.TreeView == this.baseList)
                {
                    str = this.baseDir;
                }
                else
                {
                    string str1 = Path.Combine(this.modDir, Path.GetFileNameWithoutExtension(treeNode2.Text));
                    char   directorySeparatorChar = Path.DirectorySeparatorChar;
                    str = string.Concat(str1, directorySeparatorChar.ToString());
                }
                string str2 = str;
                if (!this.cbTranslationMode.Checked && modMode == GameData.ModMode.ACTIVE)
                {
                    this.parentForm.nav.ModPath = str2;
                }
                this.parentForm.addLoadedFile(str2, treeNode2.Text, modMode);
            }
            if (!this.cbTranslationMode.Checked)
            {
                TranslationManager.ClearActiveTranslation();
            }
            else
            {
                TranslationManager.TranslationCulture selectedItem = this.cbActiveTranslation.SelectedItem as TranslationManager.TranslationCulture;
                if (selectedItem == null)
                {
                    MessageBox.Show("加载翻译失败: 无效的语言", "错误", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    return;
                }
                FileInfo fileInfo = new FileInfo(selectedItem.GetFileName());
                if (!fileInfo.Exists)
                {
                    (new GameData()).save(fileInfo.FullName);
                }
                this.parentForm.addLoadedFile(selectedItem.path, fileInfo.Name, GameData.ModMode.ACTIVE);
                this.parentForm.nav.ModPath = selectedItem.path;
                this.parentForm.nav.ou.gameData.resolveAllReferences();
                if (Control.ModifierKeys != Keys.Alt)
                {
                    TranslationManager.SetActiveTranslation(selectedItem, this.parentForm.nav.ou.gameData);
                }
                else
                {
                    TranslationManager.ClearActiveTranslation();
                }
            }
            this.parentForm.nav.ou.gameData.resolveAllReferences();
            this.parentForm.finishedLoading();
            base.Close();
        }