Beispiel #1
0
        public VarHackManager(Control varHackControlControl, VarHackPanel varHackPanel)
        {
            _varHackPanel = varHackPanel;

            // Top buttons

            SplitContainer splitContainerVarHack =
                varHackControlControl.Controls["splitContainerVarHack"] as SplitContainer;

            Button buttonVarHackAddNewVariable =
                splitContainerVarHack.Panel1.Controls["buttonVarHackAddNewVariable"] as Button;

            buttonVarHackAddNewVariable.Click +=
                (sender, e) => _varHackPanel.AddNewControl();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonVarHackAddNewVariable,
                new List <string>()
            {
                "RNG Index",
                "Floor YNorm",
                "Defacto Speed",
                "Mario Action",
                "Mario Animation",
            },
                new List <Action>()
            {
                () => AddVariable(() => "Index " + RngIndexer.GetRngIndex()),
                () => AddVariable(() =>
                {
                    uint triFloorAddress = Config.Stream.GetUInt32(MarioConfig.StructAddress + MarioConfig.FloorTriangleOffset);
                    float yNorm          = Config.Stream.GetSingle(triFloorAddress + TriangleOffsetsConfig.NormY);
                    return("YNorm " + FormatDouble(yNorm, 4, true));
                }),
                () => AddVariable(() => "Defacto " + FormatInteger(WatchVariableSpecialUtilities.GetMarioDeFactoSpeed())),
                () => AddVariable(() => "Action " + TableConfig.MarioActions.GetActionName()),
                () => AddVariable(() => "Animation " + TableConfig.MarioAnimations.GetAnimationName()),
            });

            Button buttonVarHackClearVariables =
                splitContainerVarHack.Panel1.Controls["buttonVarHackClearVariables"] as Button;

            buttonVarHackClearVariables.Click +=
                (sender, e) => _varHackPanel.ClearControls();

            Button buttonVarHackShowVariableBytesInLittleEndian =
                splitContainerVarHack.Panel1.Controls["buttonVarHackShowVariableBytesInLittleEndian"] as Button;

            buttonVarHackShowVariableBytesInLittleEndian.Click +=
                (sender, e) => _varHackPanel.ShowVariableBytesInLittleEndian();

            Button buttonVarHackShowVariableBytesInBigEndian =
                splitContainerVarHack.Panel1.Controls["buttonVarHackShowVariableBytesInBigEndian"] as Button;

            buttonVarHackShowVariableBytesInBigEndian.Click +=
                (sender, e) => _varHackPanel.ShowVariableBytesInBigEndian();

            // Bottom buttons

            Button buttonVarHackApplyVariablesToMemory =
                splitContainerVarHack.Panel1.Controls["buttonVarHackApplyVariablesToMemory"] as Button;

            buttonVarHackApplyVariablesToMemory.Click +=
                (sender, e) => _varHackPanel.ApplyVariablesToMemory();

            Button buttonVarHackClearVariablesInMemory =
                splitContainerVarHack.Panel1.Controls["buttonVarHackClearVariablesInMemory"] as Button;

            buttonVarHackClearVariablesInMemory.Click +=
                (sender, e) => _varHackPanel.ClearVariablesInMemory();

            _buttonEnableDisableRomHack =
                splitContainerVarHack.Panel1.Controls["buttonEnableDisableRomHack"] as BinaryButton;
            _buttonEnableDisableRomHack.Initialize(
                "Enable ROM Hack",
                "Disable ROM Hack",
                () => VarHackConfig.ShowVarRomHack.LoadPayload(),
                () => VarHackConfig.ShowVarRomHack.ClearPayload(),
                () => VarHackConfig.ShowVarRomHack.Enabled);

            // Middle buttons

            _textBoxXPosValue = splitContainerVarHack.Panel1.Controls["textBoxXPosValue"] as BetterTextbox;
            _textBoxXPosValue.AddEnterAction(() => SetPositionsAndApplyVariablesToMemory());
            _textBoxXPosValue.Text = VarHackConfig.DefaultXPos.ToString();
            InitializePositionControls(
                _textBoxXPosValue,
                splitContainerVarHack.Panel1.Controls["textBoxXPosChange"] as TextBox,
                splitContainerVarHack.Panel1.Controls["buttonXPosSubtract"] as Button,
                splitContainerVarHack.Panel1.Controls["buttonXPosAdd"] as Button);

            _textBoxYPosValue = splitContainerVarHack.Panel1.Controls["textBoxYPosValue"] as BetterTextbox;
            _textBoxYPosValue.AddEnterAction(() => SetPositionsAndApplyVariablesToMemory());
            _textBoxYPosValue.Text = VarHackConfig.DefaultYPos.ToString();
            InitializePositionControls(
                _textBoxYPosValue,
                splitContainerVarHack.Panel1.Controls["textBoxYPosChange"] as TextBox,
                splitContainerVarHack.Panel1.Controls["buttonYPosSubtract"] as Button,
                splitContainerVarHack.Panel1.Controls["buttonYPosAdd"] as Button);

            _textBoxYDeltaValue = splitContainerVarHack.Panel1.Controls["textBoxYDeltaValue"] as BetterTextbox;
            _textBoxYDeltaValue.AddEnterAction(() => SetPositionsAndApplyVariablesToMemory());
            _textBoxYDeltaValue.Text = VarHackConfig.DefaultYDelta.ToString();
            InitializePositionControls(
                _textBoxYDeltaValue,
                splitContainerVarHack.Panel1.Controls["textBoxYDeltaChange"] as TextBox,
                splitContainerVarHack.Panel1.Controls["buttonYDeltaSubtract"] as Button,
                splitContainerVarHack.Panel1.Controls["buttonYDeltaAdd"] as Button);

            Button buttonSetPositionsAndApplyVariablesToMemory =
                splitContainerVarHack.Panel1.Controls["buttonSetPositionsAndApplyVariablesToMemory"] as Button;

            buttonSetPositionsAndApplyVariablesToMemory.Click +=
                (sender, e) => SetPositionsAndApplyVariablesToMemory();
        }
Beispiel #2
0
        public static (string, Func <string>) CreateGetterFunction(string specialType)
        {
            string        name           = DEFAULT_NAME;
            Func <string> getterFunction = DEFAULT_GETTER;

            switch (specialType)
            {
            case "RngIndex":
                name           = "Index " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(RngIndexer.GetRngIndex().ToString());
                };
                break;

            case "FloorYNorm":
                name           = "YNorm " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    uint  triFloorAddress = Config.Stream.GetUInt(MarioConfig.StructAddress + MarioConfig.FloorTriangleOffset);
                    float yNorm           = Config.Stream.GetFloat(triFloorAddress + TriangleOffsetsConfig.NormY);
                    return(FormatDouble(yNorm, 4, true));
                };
                break;

            case "DefactoSpeed":
                name           = "Defacto " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(FormatInteger(WatchVariableSpecialUtilities.GetMarioDeFactoSpeed()));
                };
                break;

            case "SlidingSpeed":
                name           = "Spd " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(FormatInteger(WatchVariableSpecialUtilities.GetMarioSlidingSpeed()));
                };
                break;

            case "MarioAction":
                name           = "Action " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(TableConfig.MarioActions.GetActionName());
                };
                break;

            case "MarioAnimation":
                name           = "Animation " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(TableConfig.MarioAnimations.GetAnimationName());
                };
                break;

            case "DYawIntendFacing":
                name           = "DYaw " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(FormatInteger(WatchVariableSpecialUtilities.GetDeltaYawIntendedFacing()));
                };
                break;

            case "DYawIntendFacingHau":
                name           = "DYaw " + VarHackConfig.EscapeChar;
                getterFunction = () =>
                {
                    return(FormatInteger(WatchVariableSpecialUtilities.GetDeltaYawIntendedFacing() / 16));
                };
                break;

            default:
                break;
            }

            return(name, getterFunction);
        }