Пример #1
0
        public MenuWindow(Core core, SettingsContainer settingsContainer, Dictionary <string, FontContainer> fonts, ref VersionChecker versionChecker)
        {
            this.Core          = core;
            _settingsContainer = settingsContainer;
            CoreSettings       = settingsContainer.CoreSettings;
            Fonts = fonts;
            CoreSettingsDrawers = new List <ISettingsHolder>();
            SettingsParser.Parse(CoreSettings, CoreSettingsDrawers);

            PluginsUpdateSettings        = settingsContainer.PluginsUpdateSettings;
            PluginsUpdateSettingsDrawers = new List <ISettingsHolder>();
            SettingsParser.Parse(PluginsUpdateSettings, PluginsUpdateSettingsDrawers);

            VersionChecker = versionChecker;

            Selected = CoreSettingsAction;

            CoreSettingsAction = () =>
            {
                foreach (var drawer in CoreSettingsDrawers)
                {
                    drawer.Draw();
                }
            };

            _index   = -1;
            Selected = CoreSettingsAction;

            Core.DebugInformations.CollectionChanged += OnDebugInformationsOnCollectionChanged;
            debugInformation = new DebugInformation("DebugWindow", false);
            OpenWindow       = Windows.MainDebugs;
            WindowsName      = Enum.GetValues(typeof(Windows));

            OnWindowChange += () =>
            {
                MoreInformation = null;
                selectedName    = "";
            };

            Input.RegisterKey(CoreSettings.MainMenuKeyToggle);
            CoreSettings.MainMenuKeyToggle.OnValueChanged += () => { Input.RegisterKey(CoreSettings.MainMenuKeyToggle); };

            CoreSettings.Enable.OnValueChanged += (sender, b) =>
            {
                if (!CoreSettings.Enable)
                {
                    try
                    {
                        _settingsContainer.SaveCoreSettings();
                        try
                        {
                            _settingsContainer.SavePluginAutoUpdateSettings();
                        }
                        catch (Exception e)
                        {
                            DebugWindow.LogError($"SaveSettings for PluginAutoUpdate error: {e}");
                        }
                        foreach (var plugin in core.pluginManager.Plugins)
                        {
                            try
                            {
                                _settingsContainer.SaveSettings(plugin.Plugin);
                            }
                            catch (Exception e)
                            {
                                DebugWindow.LogError($"SaveSettings for plugin error: {e}");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        DebugWindow.LogError($"SaveSettings error: {e}");
                    }
                }
            };
        }
Пример #2
0
        public GameController(Memory memory, SoundController soundController, SettingsContainer settings,
                              MultiThreadManager multiThreadManager)
        {
            _settings          = settings.CoreSettings;
            Memory             = memory;
            SoundController    = soundController;
            Settings           = settings;
            MultiThreadManager = multiThreadManager;

            try
            {
                Cache             = new Cache();
                Game              = new TheGame(memory, Cache);
                Area              = new AreaController(Game);
                Window            = new GameWindow(memory.Process);
                Files             = Game.Files;
                EntityListWrapper = new EntityListWrapper(this, _settings, multiThreadManager);
            }
            catch (Exception e)
            {
                DebugWindow.LogError(e.ToString());
            }

            PluginBridge = new PluginBridge();

            IsForeGroundCache = WinApi.IsForegroundWindow(Window.Process.MainWindowHandle);
            var values = Enum.GetValues(typeof(IconPriority));

            LeftPanel  = new PluginPanel(GetLeftCornerMap());
            UnderPanel = new PluginPanel(GetUnderCornerMap());

            var debParseFile = new DebugInformation("Parse files", false);

            debClearCache = new DebugInformation("Clear cache", false);

            // Core.DebugInformations.Add(debParseFile);

            /*Area.OnAreaChange += controller =>
             * {
             *
             *  debParseFile.TickAction(() =>
             *  {
             *      Files.LoadFiles();
             *  });
             * };*/

            debDeltaTime = Core.DebugInformations.FirstOrDefault(x => x.Name == "Delta Time");

            NativeMethods.LogError = _settings.LogReadMemoryError;

            _settings.LogReadMemoryError.OnValueChanged +=
                (obj, b) => NativeMethods.LogError       = _settings.LogReadMemoryError;

            LeftCornerMap  = new TimeCache <Vector2>(GetLeftCornerMap, 500);
            UnderCornerMap = new TimeCache <Vector2>(GetUnderCornerMap, 500);

            eIsForegroundChanged += b =>
            {
                if (b)
                {
                    Core.MainRunner.ResumeCoroutines(Core.MainRunner.Coroutines);
                    Core.ParallelRunner.ResumeCoroutines(Core.ParallelRunner.Coroutines);
                }
                else
                {
                    Core.MainRunner.PauseCoroutines(Core.MainRunner.Coroutines);
                    Core.ParallelRunner.PauseCoroutines(Core.ParallelRunner.Coroutines);
                }

                // DebugWindow.LogMsg($"Foreground: {b}");
            };

            _settings.RefreshArea.OnPressed += () => { Area.ForceRefreshArea(); };
            Area.RefreshState();
            EntityListWrapper.StartWork();
            Initialized = true;
        }
Пример #3
0
        public MenuWindow(Core core, SettingsContainer settingsContainer, Dictionary <string, FontContainer> fonts)
        {
            this.core          = core;
            _settingsContainer = settingsContainer;
            _CoreSettings      = settingsContainer.CoreSettings;
            Fonts       = fonts;
            themeEditor = new ThemeEditor(_CoreSettings);

            /*Input.RegisterKey(Keys.F12);
             * Input.ReleaseKey += (sender, keys) =>
             * {
             *  if (keys== SettingsCoreSettings.MainMenuKeyToggle.Value)
             *  {
             *      Enable = !Enable;
             *  }
             * };*/

            CoreSettingsDrawers = new List <ISettingsHolder>();

            SettingsParser.Parse(_CoreSettings, CoreSettingsDrawers);
            Selected = CoreSettings;

            CoreSettings = () =>
            {
                foreach (var drawer in CoreSettingsDrawers)
                {
                    drawer.Draw();
                }
            };

            _index   = -1;
            Selected = CoreSettings;

            Core.DebugInformations.CollectionChanged += OnDebugInformationsOnCollectionChanged;
            debugInformation = new DebugInformation("DebugWindow", false);
            OpenWindow       = Windows.MainDebugs;
            WindowsName      = Enum.GetValues(typeof(Windows));

            OnWindowChange += () =>
            {
                MoreInformation = null;
                selectedName    = "";
            };

            Input.RegisterKey(_CoreSettings.MainMenuKeyToggle);
            _CoreSettings.MainMenuKeyToggle.OnValueChanged += () => { Input.RegisterKey(_CoreSettings.MainMenuKeyToggle); };

            _CoreSettings.Enable.OnValueChanged += (sender, b) =>
            {
                if (!_CoreSettings.Enable)
                {
                    try
                    {
                        _settingsContainer.SaveCoreSettings();

                        foreach (var plugin in core.pluginManager.Plugins)
                        {
                            try
                            {
                                _settingsContainer.SaveSettings(plugin.Plugin);
                            }
                            catch (Exception e)
                            {
                                DebugWindow.LogError($"SaveSettings for plugin error: {e}");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        DebugWindow.LogError($"SaveSettings error: {e}");
                    }
                }
            };
        }