示例#1
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            if (e.Args.Length > 0 && e.Args[0] == "--genLocalizable")
            {
                Loc.ExportLocalizable();
                Environment.Exit(0);
                return;
            }

            if (e.Args.Length > 0 && e.Args[0] == "--genIntegrity")
            {
                var result = IntegrityCheck.RunIntegrityCheckAsync(Settings.GamePath, null).GetAwaiter().GetResult();
                File.WriteAllText($"{result.GameVersion}.json", JsonConvert.SerializeObject(result));

                MessageBox.Show($"Successfully hashed {result.Hashes.Count} files.");
                Environment.Exit(0);
                return;
            }

            // Check if the accountName parameter is provided, if yes, pass it to MainWindow
            var accountName = string.Empty;

            if (e.Args.Length > 0 && e.Args[0].StartsWith("--account="))
            {
                accountName = e.Args[0].Substring(e.Args[0].IndexOf("=", StringComparison.InvariantCulture) + 1);
            }

            Log.Information("Loading MainWindow for account '{0}'", accountName);
            _mainWindow = new MainWindow(accountName);

#if XL_NOAUTOUPDATE
            OnUpdateCheckFinished(null, null);
#endif
        }
示例#2
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            var accountName = string.Empty;

            if (e.Args.Length > 0)
            {
                foreach (string arg in e.Args)
                {
                    if (arg == "--genLocalizable")
                    {
                        Loc.ExportLocalizable();
                        Environment.Exit(0);
                        return;
                    }

                    if (arg == "--genIntegrity")
                    {
                        var result = IntegrityCheck.RunIntegrityCheckAsync(Settings.GamePath, null).GetAwaiter().GetResult();
                        File.WriteAllText($"{result.GameVersion}.json", JsonConvert.SerializeObject(result));

                        MessageBox.Show($"Successfully hashed {result.Hashes.Count} files.");
                        Environment.Exit(0);
                        return;
                    }

                    // Check if the accountName parameter is provided, if yes, pass it to MainWindow
                    if (arg.StartsWith("--account="))
                    {
                        accountName = arg.Substring(arg.IndexOf("=", StringComparison.InvariantCulture) + 1);
                        App.Settings.CurrentAccountId = accountName;
                    }

                    // Override client launch language by parameter
                    if (arg.StartsWith("--clientlang="))
                    {
                        string langarg = arg.Substring(arg.IndexOf("=", StringComparison.InvariantCulture) + 1);
                        Enum.TryParse(langarg, out ClientLanguage lang); // defaults to Japanese if the input was invalid.
                        App.Settings.Language = lang;
                        Log.Information($"Language set as {App.Settings.Language.ToString()} by launch argument.");
                    }
                }
            }

            Log.Information("Loading MainWindow for account '{0}'", accountName);

            if (Util.IsWine)
            {
                OnUpdateCheckFinished(null, null);
            }

#if XL_NOAUTOUPDATE
            OnUpdateCheckFinished(null, null);
#endif
        }
示例#3
0
        private void BuildDalamudUi()
        {
            if (this.isImguiDrawDevMenu)
            {
                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Dalamud"))
                    {
                        ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Log window"))
                        {
                            this.logWindow            = new DalamudLogWindow(CommandManager);
                            this.isImguiDrawLogWindow = true;
                        }
                        if (ImGui.BeginMenu("Set log level..."))
                        {
                            foreach (var logLevel in Enum.GetValues(typeof(LogEventLevel)).Cast <LogEventLevel>())
                            {
                                if (ImGui.MenuItem(logLevel + "##logLevelSwitch", "", this.loggingLevelSwitch.MinimumLevel == logLevel))
                                {
                                    this.loggingLevelSwitch.MinimumLevel = logLevel;
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Data window"))
                        {
                            this.dataWindow            = new DalamudDataWindow(this);
                            this.isImguiDrawDataWindow = true;
                        }
                        if (ImGui.MenuItem("Open Credits window"))
                        {
                            OnOpenCreditsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Settings window"))
                        {
                            OnOpenSettingsCommand(null, null);
                        }
                        ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
                        if (ImGui.MenuItem("Dump ImGui info"))
                        {
                            OnDebugImInfoCommand(null, null);
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Unload Dalamud"))
                        {
                            Unload();
                        }
                        if (ImGui.MenuItem("Kill game"))
                        {
                            Process.GetCurrentProcess().Kill();
                        }
                        if (ImGui.MenuItem("Cause AccessViolation"))
                        {
                            var a = Marshal.ReadByte(IntPtr.Zero);
                        }
                        ImGui.Separator();
                        ImGui.MenuItem(Util.AssemblyVersion, false);
                        ImGui.MenuItem(this.StartInfo.GameVersion, false);

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Game"))
                    {
                        if (ImGui.MenuItem("Replace ExceptionHandler"))
                        {
                            ReplaceExceptionHandler();
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Plugins"))
                    {
                        if (ImGui.MenuItem("Open Plugin installer"))
                        {
                            this.pluginWindow            = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
                            this.isImguiDrawPluginWindow = true;
                        }
                        if (ImGui.MenuItem("Open Plugin Stats"))
                        {
                            if (!this.isImguiDrawPluginStatWindow)
                            {
                                this.pluginStatWindow            = new DalamudPluginStatWindow(this.PluginManager);
                                this.isImguiDrawPluginStatWindow = true;
                            }
                        }
                        if (ImGui.MenuItem("Print plugin info"))
                        {
                            foreach (var plugin in this.PluginManager.Plugins)
                            {
                                // TODO: some more here, state maybe?
                                Log.Information($"{plugin.Plugin.Name}");
                            }
                        }
                        if (ImGui.MenuItem("Reload plugins"))
                        {
                            OnPluginReloadCommand(string.Empty, string.Empty);
                        }

                        ImGui.Separator();
                        ImGui.MenuItem("API Level:" + PluginManager.DALAMUD_API_LEVEL, false);
                        ImGui.MenuItem("Loaded plugins:" + PluginManager?.Plugins.Count, false);
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Localization"))
                    {
                        if (ImGui.MenuItem("Export localizable"))
                        {
                            Loc.ExportLocalizable();
                        }

                        if (ImGui.BeginMenu("Load language..."))
                        {
                            if (ImGui.MenuItem("From Fallbacks"))
                            {
                                Loc.SetupWithFallbacks();
                            }

                            if (ImGui.MenuItem("From UICulture"))
                            {
                                this.LocalizationManager.SetupWithUiCulture();
                            }

                            foreach (var applicableLangCode in Localization.ApplicableLangCodes)
                            {
                                if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
                                {
                                    this.LocalizationManager.SetupWithLangCode(applicableLangCode);
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.EndMenu();
                    }

                    ImGui.EndMainMenuBar();
                }
            }

            if (this.isImguiDrawLogWindow)
            {
                this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();

                if (this.isImguiDrawLogWindow == false)
                {
                    this.logWindow?.Dispose();
                    this.logWindow = null;
                }
            }

            if (this.isImguiDrawDataWindow)
            {
                this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
            }

            if (this.isImguiDrawPluginWindow)
            {
                this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();
            }

            if (this.isImguiDrawCreditsWindow)
            {
                this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();

                if (this.isImguiDrawCreditsWindow == false)
                {
                    this.creditsWindow?.Dispose();
                    this.creditsWindow = null;
                }
            }

            if (this.isImguiDrawSettingsWindow)
            {
                this.isImguiDrawSettingsWindow = this.settingsWindow != null && this.settingsWindow.Draw();
            }

            if (this.isImguiDrawDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }

            if (this.isImguiDrawPluginStatWindow)
            {
                this.isImguiDrawPluginStatWindow = this.pluginStatWindow != null && this.pluginStatWindow.Draw();
                if (!this.isImguiDrawPluginStatWindow)
                {
                    this.pluginStatWindow?.Dispose();
                    this.pluginStatWindow = null;
                }
            }
        }
示例#4
0
        private void BuildDalamudUi()
        {
            if (!this.isImguiDrawDevMenu && !ClientState.Condition.Any())
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.TextSelectedBg, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.Border, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 1));

                ImGui.SetNextWindowPos(new Vector2(0, 0), ImGuiCond.Always);
                ImGui.SetNextWindowBgAlpha(1);

                if (ImGui.Begin("DevMenu Opener", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoSavedSettings))
                {
                    if (ImGui.Button("###devMenuOpener", new Vector2(40, 25)))
                    {
                        this.isImguiDrawDevMenu = true;
                    }

                    ImGui.End();
                }

                ImGui.PopStyleColor(8);
            }

            if (this.isImguiDrawDevMenu)
            {
                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Dalamud"))
                    {
                        ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Log window"))
                        {
                            this.logWindow            = new DalamudLogWindow(CommandManager);
                            this.isImguiDrawLogWindow = true;
                        }
                        if (ImGui.BeginMenu("Set log level..."))
                        {
                            foreach (var logLevel in Enum.GetValues(typeof(LogEventLevel)).Cast <LogEventLevel>())
                            {
                                if (ImGui.MenuItem(logLevel + "##logLevelSwitch", "", this.loggingLevelSwitch.MinimumLevel == logLevel))
                                {
                                    this.loggingLevelSwitch.MinimumLevel = logLevel;
                                }
                            }

                            ImGui.EndMenu();
                        }
                        if (AntiDebug == null && ImGui.MenuItem("Enable AntiDebug"))
                        {
                            AntiDebug = new AntiDebug(this.SigScanner);
                            AntiDebug.Enable();
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Data window"))
                        {
                            this.dataWindow            = new DalamudDataWindow(this);
                            this.isImguiDrawDataWindow = true;
                        }
                        if (ImGui.MenuItem("Open Credits window"))
                        {
                            OnOpenCreditsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Settings window"))
                        {
                            OnOpenSettingsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Changelog window"))
                        {
                            OpenChangelog();
                        }
                        ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
                        if (ImGui.MenuItem("Dump ImGui info"))
                        {
                            OnDebugImInfoCommand(null, null);
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Unload Dalamud"))
                        {
                            Unload();
                        }
                        if (ImGui.MenuItem("Kill game"))
                        {
                            Process.GetCurrentProcess().Kill();
                        }
                        if (ImGui.MenuItem("Cause AccessViolation"))
                        {
                            var a = Marshal.ReadByte(IntPtr.Zero);
                        }
                        ImGui.Separator();
                        ImGui.MenuItem(Util.AssemblyVersion, false);
                        ImGui.MenuItem(this.StartInfo.GameVersion, false);

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Game"))
                    {
                        if (ImGui.MenuItem("Replace ExceptionHandler"))
                        {
                            ReplaceExceptionHandler();
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Plugins"))
                    {
                        if (ImGui.MenuItem("Open Plugin installer"))
                        {
                            this.pluginWindow            = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
                            this.isImguiDrawPluginWindow = true;
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Plugin Stats"))
                        {
                            if (!this.isImguiDrawPluginStatWindow)
                            {
                                this.pluginStatWindow            = new DalamudPluginStatWindow(this.PluginManager);
                                this.isImguiDrawPluginStatWindow = true;
                            }
                        }
                        if (ImGui.MenuItem("Print plugin info"))
                        {
                            foreach (var plugin in this.PluginManager.Plugins)
                            {
                                // TODO: some more here, state maybe?
                                Log.Information($"{plugin.Plugin.Name}");
                            }
                        }
                        if (ImGui.MenuItem("Reload plugins"))
                        {
                            OnPluginReloadCommand(string.Empty, string.Empty);
                        }

                        ImGui.Separator();
                        ImGui.MenuItem("API Level:" + PluginManager.DALAMUD_API_LEVEL, false);
                        ImGui.MenuItem("Loaded plugins:" + PluginManager?.Plugins.Count, false);
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Localization"))
                    {
                        if (ImGui.MenuItem("Export localizable"))
                        {
                            Loc.ExportLocalizable();
                        }

                        if (ImGui.BeginMenu("Load language..."))
                        {
                            if (ImGui.MenuItem("From Fallbacks"))
                            {
                                Loc.SetupWithFallbacks();
                            }

                            if (ImGui.MenuItem("From UICulture"))
                            {
                                this.LocalizationManager.SetupWithUiCulture();
                            }

                            foreach (var applicableLangCode in Localization.ApplicableLangCodes)
                            {
                                if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
                                {
                                    this.LocalizationManager.SetupWithLangCode(applicableLangCode);
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.EndMenu();
                    }

                    if (this.Framework.Gui.GameUiHidden)
                    {
                        ImGui.BeginMenu("UI is hidden...", false);
                    }

                    ImGui.EndMainMenuBar();
                }
            }

            if (this.Framework.Gui.GameUiHidden)
            {
                return;
            }

            if (this.isImguiDrawLogWindow)
            {
                this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();

                if (this.isImguiDrawLogWindow == false)
                {
                    this.logWindow?.Dispose();
                    this.logWindow = null;
                }
            }

            if (this.isImguiDrawDataWindow)
            {
                this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
            }

            if (this.isImguiDrawPluginWindow)
            {
                this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();

                if (!this.isImguiDrawPluginWindow)
                {
                    this.pluginWindow = null;
                }
            }

            if (this.isImguiDrawCreditsWindow)
            {
                this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();

                if (this.isImguiDrawCreditsWindow == false)
                {
                    this.creditsWindow?.Dispose();
                    this.creditsWindow = null;
                }
            }

            if (this.isImguiDrawSettingsWindow)
            {
                this.isImguiDrawSettingsWindow = this.settingsWindow != null && this.settingsWindow.Draw();
            }

            if (this.isImguiDrawDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }

            if (this.isImguiDrawPluginStatWindow)
            {
                this.isImguiDrawPluginStatWindow = this.pluginStatWindow != null && this.pluginStatWindow.Draw();
                if (!this.isImguiDrawPluginStatWindow)
                {
                    this.pluginStatWindow?.Dispose();
                    this.pluginStatWindow = null;
                }
            }

            if (this.isImguiDrawChangelogWindow)
            {
                this.isImguiDrawChangelogWindow = this.changelogWindow != null && this.changelogWindow.Draw();
            }
        }
示例#5
0
        private void BuildDalamudUi()
        {
            if (this.isImguiDrawDevMenu)
            {
                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Dalamud"))
                    {
                        ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Log window"))
                        {
                            this.logWindow            = new DalamudLogWindow();
                            this.isImguiDrawLogWindow = true;
                        }
                        if (ImGui.BeginMenu("Set log level..."))
                        {
                            foreach (var logLevel in Enum.GetValues(typeof(LogEventLevel)).Cast <LogEventLevel>())
                            {
                                if (ImGui.MenuItem(logLevel + "##logLevelSwitch", "", this.loggingLevelSwitch.MinimumLevel == logLevel))
                                {
                                    this.loggingLevelSwitch.MinimumLevel = logLevel;
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Data window"))
                        {
                            this.dataWindow            = new DalamudDataWindow(this);
                            this.isImguiDrawDataWindow = true;
                        }
                        if (ImGui.MenuItem("Open Credits window"))
                        {
                            var logoGraphic =
                                this.InterfaceManager.LoadImage(
                                    Path.Combine(this.StartInfo.WorkingDirectory, "UIRes", "logo.png"));
                            this.creditsWindow            = new DalamudCreditsWindow(logoGraphic, this.Framework);
                            this.isImguiDrawCreditsWindow = true;
                        }
                        ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
                        if (ImGui.MenuItem("Dump ImGui info"))
                        {
                            OnDebugImInfoCommand(null, null);
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Unload Dalamud"))
                        {
                            Unload();
                        }
                        if (ImGui.MenuItem("Kill game"))
                        {
                            Process.GetCurrentProcess().Kill();
                        }
                        ImGui.Separator();
                        ImGui.MenuItem(this.assemblyVersion, false);
                        ImGui.MenuItem(this.StartInfo.GameVersion, false);

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Plugins"))
                    {
                        if (ImGui.MenuItem("Open Plugin installer"))
                        {
                            this.pluginWindow            = new PluginInstallerWindow(this.PluginManager, this.PluginRepository, this.StartInfo.GameVersion);
                            this.isImguiDrawPluginWindow = true;
                        }
                        if (ImGui.MenuItem("Print plugin info"))
                        {
                            foreach (var plugin in this.PluginManager.Plugins)
                            {
                                // TODO: some more here, state maybe?
                                Log.Information($"{plugin.Plugin.Name}");
                            }
                        }
                        if (ImGui.MenuItem("Reload plugins"))
                        {
                            OnPluginReloadCommand(string.Empty, string.Empty);
                        }
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Localization"))
                    {
                        if (ImGui.MenuItem("Export localizable"))
                        {
                            Loc.ExportLocalizable();
                        }

                        if (ImGui.BeginMenu("Load language..."))
                        {
                            if (ImGui.MenuItem("From Fallbacks"))
                            {
                                Loc.SetupWithFallbacks();
                            }

                            if (ImGui.MenuItem("From UICulture"))
                            {
                                this.localizationMgr.SetupWithUiCulture();
                            }

                            foreach (var applicableLangCode in Localization.ApplicableLangCodes)
                            {
                                if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
                                {
                                    this.localizationMgr.SetupWithLangCode(applicableLangCode);
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.EndMenu();
                    }

                    ImGui.EndMainMenuBar();
                }
            }

            if (this.isImguiDrawLogWindow)
            {
                this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();

                if (this.isImguiDrawLogWindow == false)
                {
                    this.logWindow?.Dispose();
                    this.logWindow = null;
                }
            }

            if (this.isImguiDrawDataWindow)
            {
                this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
            }

            if (this.isImguiDrawPluginWindow)
            {
                this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();
            }

            if (this.isImguiDrawItemSearchWindow)
            {
                this.isImguiDrawItemSearchWindow = this.itemSearchCommandWindow != null && this.itemSearchCommandWindow.Draw();

                if (this.isImguiDrawItemSearchWindow == false)
                {
                    this.itemSearchCommandWindow?.Dispose();
                    this.itemSearchCommandWindow = null;
                }
            }

            if (this.isImguiDrawCreditsWindow)
            {
                this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();

                if (this.isImguiDrawCreditsWindow == false)
                {
                    this.creditsWindow?.Dispose();
                    this.creditsWindow = null;
                }
            }

            if (this.isImguiDrawDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }
        }
示例#6
0
 private void button2_Click(object sender, EventArgs e)
 {
     Loc.ExportLocalizable();
 }