Esempio n. 1
0
        public Form1()
        {
            InitializeComponent();
            GameSettingsComboBox.SelectedIndex = 7;

            // Set up saved configs
            current = new SavedConfig();

            // Read all settings values and save to current
            for (int i = 0; i < Program.offsets.Count; i++)
            {
                try
                {
                    // Booleans
                    if (i == 0 || i == 2 || i == 12)
                    {
                        byte[] currentValue = new byte[1];
                        ProcAPI.ReadProcessMemory(Program.hProc, ProcAPI.FindDMAAddy(Program.hProc, Program.dynamicPtrBaseAddr, Program.offsets[i].ToArray()), currentValue, currentValue.Length, out var read);
                        current.settings[i] = currentValue[0];
                    }
                    // Other
                    else
                    {
                        byte[] currentValue = new byte[4];
                        ProcAPI.ReadProcessMemory(Program.hProc, ProcAPI.FindDMAAddy(Program.hProc, Program.dynamicPtrBaseAddr, Program.offsets[i].ToArray()), currentValue, currentValue.Length, out var read);

                        // Floats
                        if (i >= 6 && i <= 9)
                        {
                            float currentF = BitConverter.ToSingle(currentValue, 0);
                            current.settings[i] = currentF;
                        }
                        // Ints
                        else
                        {
                            int currentI = BitConverter.ToInt32(currentValue, 0);
                            current.settings[i] = currentI;
                        }
                    }
                }
                catch { }
            }

            // Set saved to current
            saved = current;
        }
Esempio n. 2
0
        private void GameSettingsComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Reset visible/enabled elements
            GameSettingsValue.Enabled  = true;
            EnumValuesComboBox.Visible = false;

            // Change the decimal places in the number box if the expected value is a float
            if (GameSettingsComboBox.SelectedIndex >= 6 && GameSettingsComboBox.SelectedIndex <= 9)
            {
                GameSettingsValue.DecimalPlaces = 2;
            }
            else
            {
                GameSettingsValue.DecimalPlaces = 0;
            }

            // Disable the number box and show a new combo box if the expected value is part of an enum or is a boolean (eg. Kill Distance or Visual Tasks)
            switch (GameSettingsComboBox.SelectedIndex)
            {
            case 0:
            case 2:
            case 10:
            case 11:
            case 12:
                GameSettingsValue.Enabled  = false;
                EnumValuesComboBox.Visible = true;

                EnumValuesComboBox.Items.Clear();

                // Change the values in the new combo box depending on the targeted value
                switch (GameSettingsComboBox.SelectedIndex)
                {
                case 0:
                case 2:
                case 12:
                    EnumValuesComboBox.Items.Add("Off");
                    EnumValuesComboBox.Items.Add("On");
                    break;

                case 10:
                    EnumValuesComboBox.Items.Add("Short");
                    EnumValuesComboBox.Items.Add("Medium");
                    EnumValuesComboBox.Items.Add("Long");
                    break;

                case 11:
                    EnumValuesComboBox.Items.Add("Always");
                    EnumValuesComboBox.Items.Add("Meetings");
                    EnumValuesComboBox.Items.Add("Never");
                    break;
                }
                break;

            default:
                break;
            }

            // Set the value of GameSettingsValue to the target setting's current value
            try
            {
                if (GameSettingsComboBox.SelectedIndex == 0 || GameSettingsComboBox.SelectedIndex == 2 || GameSettingsComboBox.SelectedIndex == 12)
                {
                    byte[] currentValue = new byte[1];
                    ProcAPI.ReadProcessMemory(Program.hProc, ProcAPI.FindDMAAddy(Program.hProc, Program.dynamicPtrBaseAddr, Program.offsets[GameSettingsComboBox.SelectedIndex].ToArray()), currentValue, currentValue.Length, out var read);
                    GameSettingsValue.Value = currentValue[0];
                }
                else
                {
                    byte[] currentValue = new byte[4];
                    ProcAPI.ReadProcessMemory(Program.hProc, ProcAPI.FindDMAAddy(Program.hProc, Program.dynamicPtrBaseAddr, Program.offsets[GameSettingsComboBox.SelectedIndex].ToArray()), currentValue, currentValue.Length, out var read);

                    if (GameSettingsComboBox.SelectedIndex >= 6 && GameSettingsComboBox.SelectedIndex <= 9)
                    {
                        GameSettingsValue.Value = (decimal)BitConverter.ToSingle(currentValue, 0);
                    }
                    else
                    {
                        GameSettingsValue.Value = BitConverter.ToInt32(currentValue, 0);
                    }
                }
            }
            catch { }

            // Try to update the selected EnumValuesComboBox value if applicable
            try
            {
                EnumValuesComboBox.SelectedIndex = (int)GameSettingsValue.Value;
            }
            catch { }
        }