Beispiel #1
0
        void DrawSettingsTab()
        {
            var ret = ImGui.BeginTabItem("Settings");

            if (!ret)
            {
                return;
            }

            // FUCKKKKK
            var basePath = _plugin.Configuration.BaseFolder;

            if (ImGui.InputText("Root Folder", ref basePath, 255))
            {
                _plugin.Configuration.BaseFolder = basePath;
            }

            if (ImGui.Button("Rediscover Mods"))
            {
                ReloadMods();
            }

            if (ImGui.Button("Reload Player Resource"))
            {
                _plugin.ResourceLoader.ReloadPlayerResource();
            }

            if (!_isImportRunning)
            {
                if (ImGui.Button("Import TexTools Modpacks"))
                {
                    _isImportRunning = true;

                    Task.Run(async() =>
                    {
                        var picker = new OpenFileDialog
                        {
                            Multiselect     = true,
                            Filter          = "TexTools TTMP Modpack (*.ttmp2)|*.ttmp*|All files (*.*)|*.*",
                            CheckFileExists = true,
                            Title           = "Pick one or more modpacks."
                        };

                        var result = await picker.ShowDialogAsync();

                        if (result == DialogResult.OK)
                        {
                            try
                            {
                                var importer =
                                    new TexToolsImport(new DirectoryInfo(_plugin.Configuration.BaseFolder));

                                foreach (var fileName in picker.FileNames)
                                {
                                    PluginLog.Log("-> {0} START", fileName);

                                    importer.ImportModPack(new FileInfo(fileName));

                                    PluginLog.Log("-> {0} OK!", fileName);
                                }

                                ReloadMods();
                            }
                            catch (Exception ex)
                            {
                                PluginLog.LogError(ex, "Could not import one or more modpacks.");
                            }
                        }

                        _isImportRunning = false;
                    });
                }
            }
            else
            {
                ImGui.Button("Import in progress...");
            }

            if (ImGui.Button("Save Settings"))
            {
                _plugin.Configuration.Save();
            }

            if (_plugin.ResourceLoader != null)
            {
                ImGui.Checkbox("DEBUG Log all loaded files", ref _plugin.ResourceLoader.LogAllFiles);
            }

            ImGui.EndTabItem();
        }
Beispiel #2
0
        void DrawImportTab()
        {
            var ret = ImGui.BeginTabItem("Import Mods");

            if (!ret)
            {
                return;
            }

            if (!_isImportRunning)
            {
                if (ImGui.Button("Import TexTools Modpacks"))
                {
                    _isImportRunning = true;

                    Task.Run(async() =>
                    {
                        var picker = new OpenFileDialog
                        {
                            Multiselect     = true,
                            Filter          = "TexTools TTMP Modpack (*.ttmp2)|*.ttmp*|All files (*.*)|*.*",
                            CheckFileExists = true,
                            Title           = "Pick one or more modpacks."
                        };

                        var result = await picker.ShowDialogAsync();

                        if (result == DialogResult.OK)
                        {
                            foreach (var fileName in picker.FileNames)
                            {
                                PluginLog.Log("-> {0} START", fileName);

                                try
                                {
                                    _texToolsImport = new TexToolsImport(new DirectoryInfo(_plugin.Configuration.CurrentCollection));
                                    _texToolsImport.ImportModPack(new FileInfo(fileName));
                                }
                                catch (Exception ex)
                                {
                                    PluginLog.LogError(ex, "Could not import one or more modpacks.");
                                }

                                PluginLog.Log("-> {0} OK!", fileName);
                            }

                            _texToolsImport = null;
                            ReloadMods();
                        }

                        _isImportRunning = false;
                    });
                }
            }
            else
            {
                ImGui.Button("Import in progress...");

                if (_texToolsImport != null)
                {
                    switch (_texToolsImport.State)
                    {
                    case ImporterState.None:
                        break;

                    case ImporterState.WritingPackToDisk:
                        ImGui.Text("Writing modpack to disk before extracting...");
                        break;

                    case ImporterState.ExtractingModFiles:
                    {
                        var str =
                            $"{_texToolsImport.CurrentModPack} - {_texToolsImport.CurrentProgress} of {_texToolsImport.TotalProgress} files";

                        ImGui.ProgressBar(_texToolsImport.Progress, new Vector2(-1, 0), str);
                        break;
                    }

                    case ImporterState.Done:
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }

            ImGui.EndTabItem();
        }