コード例 #1
0
 internal static void UpdateForm(SavedSettings newSettings)
 {
     SettingsForm.UpdateFromSettings(newSettings);
 }
コード例 #2
0
        public void Start()
        {
            try
            {
                _dir = Path.Combine(Environment.ExpandEnvironmentVariables("%userprofile%/Desktop"), "NGUIndustriesInjector");
                if (!Directory.Exists(_dir))
                {
                    Directory.CreateDirectory(_dir);
                }

                var logDir = Path.Combine(_dir, "logs");
                if (!Directory.Exists(logDir))
                {
                    Directory.CreateDirectory(logDir);
                }

                OutputWriter = new StreamWriter(Path.Combine(logDir, "inject.log"))
                {
                    AutoFlush = true
                };
                DebugWriter = new StreamWriter(Path.Combine(logDir, "debug.log"))
                {
                    AutoFlush = true
                };
                LootWriter = new StreamWriter(Path.Combine(logDir, "loot.log"))
                {
                    AutoFlush = true
                };
                CombatWriter = new StreamWriter(Path.Combine(logDir, "combat.log"))
                {
                    AutoFlush = true
                };
                PitSpinWriter = new StreamWriter(Path.Combine(logDir, "pitspin.log"), true)
                {
                    AutoFlush = true
                };

                var _profilesDir = Path.Combine(_dir, "profiles");
                if (!Directory.Exists(_profilesDir))
                {
                    Directory.CreateDirectory(_profilesDir);
                }

                var oldPath = Path.Combine(_dir, "allocation.json");
                var newPath = Path.Combine(_profilesDir, "default.json");

                if (File.Exists(oldPath) && !File.Exists(newPath))
                {
                    File.Move(oldPath, newPath);
                }
                SetUpDDLLoading();
            }
            catch (Exception e)
            {
                MessageBox.Show($"Loader intialization error: {e.Message}");
                Log(e.Message);
                Log(e.StackTrace);
                Loader.Unload();
                return;
            }

            try
            {
                Log("Injected");
                LogLoot("Starting Loot Writer");
                LogCombat("Starting Combat Writer");

                Settings     = new SavedSettings(_dir);
                SettingsForm = new SettingsForm();

                ConfigWatcher = new FileSystemWatcher
                {
                    Path                = _dir,
                    Filter              = "settings.json",
                    NotifyFilter        = NotifyFilters.LastWrite,
                    EnableRaisingEvents = true
                };

                ConfigWatcher.Changed += (sender, args) =>
                {
                    if (IgnoreNextChange)
                    {
                        IgnoreNextChange = false;
                        return;
                    }
                    Settings.LoadSettings();
                    SettingsForm.UpdateFromSettings(Settings);
                };

                Settings.LoadSettings();
                SettingsForm.UpdateFromSettings(Settings);
                SettingsForm.Show();

                InvokeRepeating("AutomationRoutine", 1.0f, MAIN_DELAY);
                InvokeRepeating("SnipeZone", 0.0f, .1f);
                InvokeRepeating("MonitorLog", 0.0f, 1f);
                InvokeRepeating("QuickStuff", 0.0f, .5f);
                InvokeRepeating("ShowBoostProgress", 0.0f, 60.0f);
                InvokeRepeating("SetResnipe", 0f, 1f);

                Reference = this;

                materialState = new List <MaterialState>();
                MaterialState.SetState(materialState, FindObjectOfType <Player>());
                foreach (var buildingType in Enum.GetValues(typeof(BuildingType)).Cast <BuildingType>())
                {
                    materialState.Add(new MaterialState(buildingType));
                }
            }
            catch (Exception e)
            {
                MessageBox.Show($"Loader startup error: {e.Message}");
                Log(e.ToString());
                Log(e.StackTrace);
                Log(e.InnerException.ToString());
            }
        }