Esempio n. 1
0
        public TriangleManager(Control tabControl, string varFilePath, WatchVariableFlowLayoutPanel watchVariablePanel)
            : base(varFilePath, watchVariablePanel, ALL_VAR_GROUPS, VISIBLE_VAR_GROUPS)
        {
            _recordedTriangleAddresses = new List <uint>();

            SplitContainer splitContainerTriangles = tabControl.Controls["splitContainerTriangles"] as SplitContainer;

            _addressBox = splitContainerTriangles.Panel1.Controls["textBoxCustomTriangle"] as BetterTextbox;
            _useMisalignmentOffsetCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxVertexMisalignment"] as CheckBox;

            _addressBox.AddEnterAction(() => AddressBoxEnter());

            _radioButtonTriFloor          = splitContainerTriangles.Panel1.Controls["radioButtonTriFloor"] as RadioButton;
            _radioButtonTriFloor.Click   += (sender, e) => Mode_Click(sender, e, TriangleMode.Floor);
            _radioButtonTriWall           = splitContainerTriangles.Panel1.Controls["radioButtonTriWall"] as RadioButton;
            _radioButtonTriWall.Click    += (sender, e) => Mode_Click(sender, e, TriangleMode.Wall);
            _radioButtonTriCeiling        = splitContainerTriangles.Panel1.Controls["radioButtonTriCeiling"] as RadioButton;
            _radioButtonTriCeiling.Click += (sender, e) => Mode_Click(sender, e, TriangleMode.Ceiling);
            _radioButtonTriCustom         = splitContainerTriangles.Panel1.Controls["radioButtonTriCustom"] as RadioButton;
            _radioButtonTriCustom.Click  += (sender, e) => Mode_Click(sender, e, TriangleMode.Custom);

            ControlUtilities.AddContextMenuStripFunctions(
                _radioButtonTriCustom,
                new List <string>()
            {
                "Paste Addresses",
            },
                new List <Action>()
            {
                () => EnterCustomText(Clipboard.GetText()),
            });

            Label labelTriangleSelection = splitContainerTriangles.Panel1.Controls["labelTriangleSelection"] as Label;

            ControlUtilities.AddContextMenuStripFunctions(
                labelTriangleSelection,
                new List <string>()
            {
                "Update Based on Coordinates",
                "Paste Triangles",
            },
                new List <Action>()
            {
                () => UpdateBasedOnCoordinates(),
                () => PasteTriangles(),
            });

            (splitContainerTriangles.Panel1.Controls["buttonGotoV1"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 1, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV2"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 2, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoV3"] as Button).Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 3, _useMisalignmentOffsetCheckbox.Checked);
            (splitContainerTriangles.Panel1.Controls["buttonGotoVClosest"] as Button).Click += (sender, e) =>
                                                                                               ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], _useMisalignmentOffsetCheckbox.Checked);

            (splitContainerTriangles.Panel1.Controls["buttonRetrieveTriangle"] as Button).Click
                += (sender, e) => ButtonUtilities.RetrieveTriangle(TriangleAddresses);

            Button buttonNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["buttonNeutralizeTriangle"] as Button;

            buttonNeutralizeTriangle.Click += (sender, e) => ButtonUtilities.NeutralizeTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonNeutralizeTriangle,
                new List <string>()
            {
                "Neutralize", "Neutralize with 0", "Neutralize with 0x15"
            },
                new List <Action>()
            {
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, false),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, true),
            });

            Button buttonAnnihilateTriangle = splitContainerTriangles.Panel1.Controls["buttonAnnihilateTriangle"] as Button;

            buttonAnnihilateTriangle.Click += (sender, e) => ButtonUtilities.AnnihilateTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonAnnihilateTriangle,
                new List <string>()
            {
                "Annihilate All Tri But Death Barriers",
                "Annihilate All Ceilings",
            },
                new List <Action>()
            {
                () => TriangleUtilities.AnnihilateAllTrianglesButDeathBarriers(),
                () => TriangleUtilities.AnnihilateAllCeilings(),
            });

            var trianglePosGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTrianglePos"] as GroupBox;

            ControlUtilities.InitializeThreeDimensionController(
                CoordinateSystem.Euler,
                true,
                trianglePosGroupBox,
                trianglePosGroupBox.Controls["buttonTrianglePosXn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXnZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZn"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosXpZp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYp"] as Button,
                trianglePosGroupBox.Controls["buttonTrianglePosYn"] as Button,
                trianglePosGroupBox.Controls["textBoxTrianglePosXZ"] as TextBox,
                trianglePosGroupBox.Controls["textBoxTrianglePosY"] as TextBox,
                trianglePosGroupBox.Controls["checkBoxTrianglePosRelative"] as CheckBox,
                (float hOffset, float vOffset, float nOffset, bool useRelative) =>
            {
                ButtonUtilities.MoveTriangle(
                    TriangleAddresses,
                    hOffset,
                    nOffset,
                    -1 * vOffset,
                    useRelative);
            });

            var triangleNormalGroupBox = splitContainerTriangles.Panel1.Controls["groupBoxTriangleNormal"] as GroupBox;

            ControlUtilities.InitializeScalarController(
                triangleNormalGroupBox.Controls["buttontriangleNormalN"] as Button,
                triangleNormalGroupBox.Controls["buttontriangleNormalP"] as Button,
                triangleNormalGroupBox.Controls["textBoxTriangleNormal"] as TextBox,
                (float normalValue) =>
            {
                ButtonUtilities.MoveTriangleNormal(TriangleAddresses, normalValue);
            });

            _checkBoxNeutralizeTriangle = splitContainerTriangles.Panel1.Controls["checkBoxNeutralizeTriangle"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowCoords"] as Button).Click
                += (sender, e) => ShowTriangleCoordinates();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowEquation"] as Button).Click
                += (sender, e) => ShowTriangleEquation();

            _recordTriangleDataCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRecordTriangleData"] as CheckBox;
            _recordTriangleCountLabel   = splitContainerTriangles.Panel1.Controls["labelRecordTriangleCount"] as Label;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowData"] as Button).Click
                += (sender, e) => ShowTriangleData();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowVertices"] as Button).Click
                += (sender, e) => ShowTriangleVertices();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAddresses"] as Button).Click
                += (sender, e) => ShowTriangleAddresses();
            (splitContainerTriangles.Panel1.Controls["buttonTriangleClearData"] as Button).Click
                += (sender, e) => ClearTriangleData();

            _repeatFirstVertexCheckbox = splitContainerTriangles.Panel1.Controls["checkBoxRepeatFirstVertex"] as CheckBox;

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowLevelTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetLevelTriangles());

            Button buttonTriangleShowObjTris = splitContainerTriangles.Panel1.Controls["buttonTriangleShowObjTris"] as Button;

            buttonTriangleShowObjTris.Click += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles());
            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleShowObjTris,
                new List <string>()
            {
                "Show All Object Tris", "Show Selected Object Tris"
            },
                new List <Action>()
            {
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles()),
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetSelectedObjectTriangles()),
            });

            (splitContainerTriangles.Panel1.Controls["buttonTriangleShowAllTris"] as Button).Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetAllTriangles());

            var buttonTriangleNeutralizeAllTriangles = splitContainerTriangles.Panel1.Controls["buttonTriangleNeutralizeAllTriangles"] as Button;

            buttonTriangleNeutralizeAllTriangles.Click += (sender, e) => TriangleUtilities.NeutralizeTriangles();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleNeutralizeAllTriangles,
                new List <string>()
            {
                "Neutralize All Triangles",
                "Neutralize Wall Triangles",
                "Neutralize Floor Triangles",
                "Neutralize Ceiling Triangles",
                "Neutralize Death Barriers",
                "Neutralize Lava",
                "Neutralize Sleeping",
                "Neutralize Loading Zones"
            },
                new List <Action>()
            {
                () => TriangleUtilities.NeutralizeTriangles(),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Wall),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Floor),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Ceiling),
                () => TriangleUtilities.NeutralizeTriangles(0x0A),
                () => TriangleUtilities.NeutralizeTriangles(0x01),
                () => TriangleUtilities.NeutralizeSleeping(),
                () => {
                    TriangleUtilities.NeutralizeTriangles(0x1B);
                    TriangleUtilities.NeutralizeTriangles(0x1C);
                    TriangleUtilities.NeutralizeTriangles(0x1D);
                    TriangleUtilities.NeutralizeTriangles(0x1E);
                },
            });

            var buttonTriangleDisableAllCamCollision = splitContainerTriangles.Panel1.Controls["buttonTriangleDisableAllCamCollision"] as Button;

            buttonTriangleDisableAllCamCollision.Click += (sender, e) => TriangleUtilities.DisableCamCollision();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleDisableAllCamCollision,
                new List <string>()
            {
                "Disable Cam Collision for All Triangles",
                "Disable Cam Collision for Wall Triangles",
                "Disable Cam Collision for Floor Triangles",
                "Disable Cam Collision for Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.DisableCamCollision(),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Wall),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Floor),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Ceiling),
            });

            GroupBox groupBoxTriangleTypeConversion        = splitContainerTriangles.Panel1.Controls["groupBoxTriangleTypeConversion"] as GroupBox;
            ComboBox comboBoxTriangleTypeConversionConvert = groupBoxTriangleTypeConversion.Controls["comboBoxTriangleTypeConversionConvert"] as ComboBox;
            TextBox  textBoxTriangleTypeConversionFromType = groupBoxTriangleTypeConversion.Controls["textBoxTriangleTypeConversionFromType"] as TextBox;
            TextBox  textBoxTriangleTypeConversionToType   = groupBoxTriangleTypeConversion.Controls["textBoxTriangleTypeConversionToType"] as TextBox;
            Button   buttonTriangleTypeConversionConvert   = groupBoxTriangleTypeConversion.Controls["buttonTriangleTypeConversionConvert"] as Button;

            comboBoxTriangleTypeConversionConvert.DataSource = EnumUtilities.GetEnumValues <TriangleClassificationExtended>(typeof(TriangleClassificationExtended));

            buttonTriangleTypeConversionConvert.Click += (sender, e) =>
            {
                TriangleClassificationExtended classification = (TriangleClassificationExtended)comboBoxTriangleTypeConversionConvert.SelectedItem;
                short?fromType = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionFromType.Text);
                short?toType   = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionToType.Text);
                if (!fromType.HasValue || !toType.HasValue)
                {
                    return;
                }
                TriangleUtilities.ConvertSurfaceTypes(classification, fromType.Value, toType.Value);
            };
        }
Esempio n. 2
0
        public override void InitializeTab()
        {
            base.InitializeTab();

            _recordedTriangleAddresses = new List <uint>();

            textBoxCustomTriangle.AddEnterAction(() => AddressBoxEnter());

            radioButtonTriFloor.Click   += (sender, e) => Mode_Click(sender, e, TriangleMode.Floor);
            radioButtonTriWall.Click    += (sender, e) => Mode_Click(sender, e, TriangleMode.Wall);
            radioButtonTriCeiling.Click += (sender, e) => Mode_Click(sender, e, TriangleMode.Ceiling);
            radioButtonTriCustom.Click  += (sender, e) => Mode_Click(sender, e, TriangleMode.Custom);

            ControlUtilities.AddContextMenuStripFunctions(
                radioButtonTriCustom,
                new List <string>()
            {
                "Paste Addresses",
            },
                new List <Action>()
            {
                () => EnterCustomText(Clipboard.GetText()),
            });

            Label labelTriangleSelection = splitContainerTriangles.Panel1.Controls["labelTriangleSelection"] as Label;

            ControlUtilities.AddContextMenuStripFunctions(
                labelTriangleSelection,
                new List <string>()
            {
                "Update Based on Coordinates",
                "Paste Triangles",
            },
                new List <Action>()
            {
                () => UpdateBasedOnCoordinates(),
                () => PasteTriangles(),
            });


            buttonGotoV1.Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 1, checkBoxVertexMisalignment.Checked);
            buttonGotoV2.Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 2, checkBoxVertexMisalignment.Checked);
            buttonGotoV3.Click
                += (sender, e) => ButtonUtilities.GotoTriangleVertex(TriangleAddresses[0], 3, checkBoxVertexMisalignment.Checked);
            buttonGotoVClosest.Click += (sender, e) =>
                                        ButtonUtilities.GotoTriangleVertexClosest(TriangleAddresses[0], checkBoxVertexMisalignment.Checked);

            buttonRetrieveTriangle.Click
                += (sender, e) => ButtonUtilities.RetrieveTriangle(TriangleAddresses);

            buttonNeutralizeTriangle.Click += (sender, e) => ButtonUtilities.NeutralizeTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonNeutralizeTriangle,
                new List <string>()
            {
                "Neutralize", "Neutralize with 0", "Neutralize with 0x15"
            },
                new List <Action>()
            {
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, false),
                () => ButtonUtilities.NeutralizeTriangle(TriangleAddresses, true),
            });

            buttonAnnihilateTriangle.Click += (sender, e) => ButtonUtilities.AnnihilateTriangle(TriangleAddresses);
            ControlUtilities.AddContextMenuStripFunctions(
                buttonAnnihilateTriangle,
                new List <string>()
            {
                "Annihilate All Tri But Death Barriers",
                "Annihilate All Ceilings",
            },
                new List <Action>()
            {
                () => TriangleUtilities.AnnihilateAllTrianglesButDeathBarriers(),
                () => TriangleUtilities.AnnihilateAllCeilings(),
            });

            ControlUtilities.InitializeThreeDimensionController(
                CoordinateSystem.Euler,
                true,
                groupBoxTrianglePos,
                buttonTrianglePosXn,
                buttonTrianglePosXp,
                buttonTrianglePosZn,
                buttonTrianglePosZp,
                buttonTrianglePosXnZn,
                buttonTrianglePosXnZp,
                buttonTrianglePosXpZn,
                buttonTrianglePosXpZp,
                buttonTrianglePosYp,
                buttonTrianglePosYn,
                textBoxTrianglePosXZ,
                textBoxTrianglePosY,
                checkBoxTrianglePosRelative,
                (float hOffset, float vOffset, float nOffset, bool useRelative) =>
            {
                ButtonUtilities.MoveTriangle(
                    TriangleAddresses,
                    hOffset,
                    nOffset,
                    -1 * vOffset,
                    useRelative,
                    true);
            });

            ControlUtilities.InitializeScalarController(
                buttonTriangleNormalN,
                buttonTriangleNormalP,
                textBoxTriangleNormal,
                (float normalValue) =>
            {
                ButtonUtilities.MoveTriangleNormal(TriangleAddresses, normalValue);
            });


            buttonTriangleShowCoords.Click
                += (sender, e) => ShowTriangleCoordinates();
            buttonTriangleShowEquation.Click
                += (sender, e) => ShowTriangleEquation();


            buttonTriangleShowData.Click
                += (sender, e) => ShowTriangleData();
            buttonTriangleShowVertices.Click
                += (sender, e) => ShowTriangleVertices();
            buttonTriangleShowAddresses.Click
                += (sender, e) => ShowTriangleAddresses();
            buttonTriangleClearData.Click
                += (sender, e) => ClearTriangleData();

            buttonTriangleShowLevelTris.Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetLevelTriangles());

            buttonTriangleShowObjTris.Click += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles());
            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleShowObjTris,
                new List <string>()
            {
                "Show All Object Tris", "Show Selected Object Tris"
            },
                new List <Action>()
            {
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetObjectTriangles()),
                () => TriangleUtilities.ShowTriangles(TriangleUtilities.GetSelectedObjectTriangles()),
            });

            buttonTriangleShowAllTris.Click
                += (sender, e) => TriangleUtilities.ShowTriangles(TriangleUtilities.GetAllTriangles());

            buttonTriangleNeutralizeAllTriangles.Click += (sender, e) => TriangleUtilities.NeutralizeTriangles();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleNeutralizeAllTriangles,
                new List <string>()
            {
                "Neutralize All Triangles",
                "Neutralize Wall Triangles",
                "Neutralize Floor Triangles",
                "Neutralize Ceiling Triangles",
                "Neutralize Death Barriers",
                "Neutralize Lava",
                "Neutralize Sleeping",
                "Neutralize Loading Zones"
            },
                new List <Action>()
            {
                () => TriangleUtilities.NeutralizeTriangles(),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Wall),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Floor),
                () => TriangleUtilities.NeutralizeTriangles(TriangleClassification.Ceiling),
                () => TriangleUtilities.NeutralizeTriangles(0x0A),
                () => TriangleUtilities.NeutralizeTriangles(0x01),
                () => TriangleUtilities.NeutralizeSleeping(),
                () => {
                    TriangleUtilities.NeutralizeTriangles(0x1B);
                    TriangleUtilities.NeutralizeTriangles(0x1C);
                    TriangleUtilities.NeutralizeTriangles(0x1D);
                    TriangleUtilities.NeutralizeTriangles(0x1E);
                },
            });

            var buttonTriangleDisableAllCamCollision = splitContainerTriangles.Panel1.Controls["buttonTriangleDisableAllCamCollision"] as Button;

            buttonTriangleDisableAllCamCollision.Click += (sender, e) => TriangleUtilities.DisableCamCollision();

            ControlUtilities.AddContextMenuStripFunctions(
                buttonTriangleDisableAllCamCollision,
                new List <string>()
            {
                "Disable Cam Collision for All Triangles",
                "Disable Cam Collision for Wall Triangles",
                "Disable Cam Collision for Floor Triangles",
                "Disable Cam Collision for Ceiling Triangles",
            },
                new List <Action>()
            {
                () => TriangleUtilities.DisableCamCollision(),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Wall),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Floor),
                () => TriangleUtilities.DisableCamCollision(TriangleClassification.Ceiling),
            });

            comboBoxTriangleTypeConversionConvert.DataSource = EnumUtilities.GetEnumValues <TriangleClassificationExtended>(typeof(TriangleClassificationExtended));

            buttonTriangleTypeConversionConvert.Click += (sender, e) =>
            {
                TriangleClassificationExtended classification = (TriangleClassificationExtended)comboBoxTriangleTypeConversionConvert.SelectedItem;
                short?fromType = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionFromType.Text);
                short?toType   = (short?)ParsingUtilities.ParseHexNullable(textBoxTriangleTypeConversionToType.Text);
                if (!fromType.HasValue || !toType.HasValue)
                {
                    return;
                }
                TriangleUtilities.ConvertSurfaceTypes(classification, fromType.Value, toType.Value);
            };
        }