Example #1
0
        public static VarHackContainer CreateFromXml(
            VarHackFlowLayoutPanel varHackPanel,
            XElement element)
        {
            int xPos = ParsingUtilities.ParseInt(element.Attribute(XName.Get("xPos")).Value);
            int yPos = ParsingUtilities.ParseInt(element.Attribute(XName.Get("yPos")).Value);

            string specialType = element.Attribute(XName.Get("specialType"))?.Value;

            if (specialType != null)
            {
                return(new VarHackContainer(
                           varHackPanel,
                           0 /* creationIndex */,
                           false /* useDefaults */,
                           specialType,
                           true /* noNumIn */,
                           null /* varNameIn */,
                           null /* addressIn */,
                           null /* memoryTypeIn */,
                           null /* useHexIn */,
                           null /* pointerOffsetIn */,
                           xPos,
                           yPos));
            }
            else
            {
                string varName       = element.Attribute(XName.Get("name")).Value;
                uint   address       = ParsingUtilities.ParseHex(element.Attribute(XName.Get("address")).Value);
                Type   type          = TypeUtilities.StringToType[element.Attribute(XName.Get("type")).Value];
                bool   useHex        = ParsingUtilities.ParseBool(element.Attribute(XName.Get("useHex")).Value);
                uint?  pointerOffset = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("pointerOffset"))?.Value);
                bool   noNum         = ParsingUtilities.ParseBool(element.Attribute(XName.Get("noNum")).Value);

                return(new VarHackContainer(
                           varHackPanel,
                           0 /* creationIndex */,
                           false /* useDefaults */,
                           null /* sepcialTypeIn */,
                           noNum,
                           varName,
                           address,
                           type,
                           useHex,
                           pointerOffset,
                           xPos,
                           yPos));
            }
        }
Example #2
0
 public static VarHackContainer CreateDefault(
     VarHackFlowLayoutPanel varHackPanel,
     int creationIndex)
 {
     return(new VarHackContainer(
                varHackPanel,
                creationIndex,
                true /* useDefaults */,
                null /* specialTypeIn */,
                null /* noNumIn */,
                null /* varNameIn */,
                null /* addressIn */,
                null /* memoryTypeIn */,
                null /* useHexIn */,
                null /* pointerOffsetIn */,
                null /* xPosIn */,
                null /* yPosIn */));
 }
Example #3
0
 public static VarHackContainer CreateWithParameters(
     VarHackFlowLayoutPanel varHackPanel,
     int creationIndex,
     string varName,
     uint address,
     Type memoryType,
     bool useHex,
     uint?pointerOffset)
 {
     return(new VarHackContainer(
                varHackPanel,
                creationIndex,
                false /* useDefaults */,
                null /* specialTypeIn */,
                false /* noNumIn */,
                varName,
                address,
                memoryType,
                useHex,
                pointerOffset,
                null /* xPosIn */,
                null /* yPosIn */));
 }
Example #4
0
        private VarHackContainer(
            VarHackFlowLayoutPanel varHackPanel,
            int creationIndex,
            bool useDefaults,
            string specialTypeIn,
            bool?noNumIn,
            string varNameIn,
            uint?addressIn,
            Type memoryTypeIn,
            bool?useHexIn,
            uint?pointerOffsetIn,
            int?xPosIn,
            int?yPosIn)
        {
            InitializeComponent();
            tableLayoutPanelVarHack.BorderWidth = 2;
            tableLayoutPanelVarHack.ShowBorder  = true;

            _varHackPanel = varHackPanel;
            VarHackContainerDefaults defaults = new VarHackContainerDefaults(creationIndex);

            string specialType       = useDefaults ? defaults.SpecialType : specialTypeIn;
            bool   noNum             = useDefaults ? defaults.NoNum : (noNumIn ?? VarHackContainerDefaults.StaticNoNum);
            string varName           = useDefaults ? defaults.VarName : (varNameIn ?? VarHackContainerDefaults.StaticVarName);
            uint   address           = useDefaults ? defaults.Address : (addressIn ?? VarHackContainerDefaults.StaticAddress);
            Type   memoryType        = useDefaults ? defaults.MemoryType : (memoryTypeIn ?? VarHackContainerDefaults.StaticMemoryType);
            bool   useHex            = useDefaults ? defaults.UseHex : (useHexIn ?? VarHackContainerDefaults.StaticUseHex);
            uint?  tempPointerOffset = useDefaults ? defaults.PointerOffset : pointerOffsetIn;
            bool   usePointer        = tempPointerOffset.HasValue;
            uint   pointerOffset     = tempPointerOffset ?? VarHackContainerDefaults.StaticPointerOffset;
            int    xPos = (useDefaults || !xPosIn.HasValue) ? defaults.XPos : xPosIn.Value;
            int    yPos = (useDefaults || !yPosIn.HasValue) ? defaults.YPos : yPosIn.Value;

            // Special
            _specialType = specialType;
            _isSpecial   = specialType != null;
            if (_isSpecial)
            {
                (varName, _getterFunction) =
                    VarHackSpecialUtilities.CreateGetterFunction(specialType);
            }

            // Misc
            textBoxNameValue.Text    = varName;
            textBoxAddressValue.Text = "0x" + String.Format("{0:X}", address);
            GetRadioButtonForType(memoryType).Checked = true;
            checkBoxUseHex.Checked   = useHex;
            checkBoxNoNumber.Checked = noNum;

            // Pointer
            checkBoxUsePointer.Checked        = usePointer;
            textBoxPointerOffsetValue.Enabled = usePointer;
            textBoxPointerOffsetValue.Text    = "0x" + String.Format("{0:X}", pointerOffset);

            // Position
            textBoxXPosValue.Text = xPos.ToString();
            textBoxYPosValue.Text = yPos.ToString();

            // Clicking functionality
            pictureBoxUpArrow.Click   += (sender, e) => _varHackPanel.MoveUpControl(this);
            pictureBoxDownArrow.Click += (sender, e) => _varHackPanel.MoveDownControl(this);
            pictureBoxRedX.Click      += (sender, e) => _varHackPanel.RemoveControl(this);
            checkBoxUsePointer.Click  += (sender, e) => textBoxPointerOffsetValue.Enabled = checkBoxUsePointer.Checked;

            // Pressing enter functionality
            textBoxNameValue.AddEnterAction(() => _varHackPanel.ApplyVariableToMemory(this));
            textBoxAddressValue.AddEnterAction(() => _varHackPanel.ApplyVariableToMemory(this));
            textBoxPointerOffsetValue.AddEnterAction(() => _varHackPanel.ApplyVariableToMemory(this));
            textBoxXPosValue.AddEnterAction(() => _varHackPanel.ApplyVariableToMemory(this));
            textBoxYPosValue.AddEnterAction(() => _varHackPanel.ApplyVariableToMemory(this));

            // Context menu strip
            ContextMenuStrip = new ContextMenuStrip();
            ToolStripMenuItem itemDuplicate = new ToolStripMenuItem("Duplicate");

            itemDuplicate.Click += (sender, e) => _varHackPanel.DuplicateControl(this);
            ContextMenuStrip.Items.Add(itemDuplicate);
            ToolStripMenuItem itemConvertToHexIntVersions = new ToolStripMenuItem("Convert to Hex Int Versions");

            itemConvertToHexIntVersions.Click += (sender, e) => _varHackPanel.ConvertToHexIntVersions(this);
            ContextMenuStrip.Items.Add(itemConvertToHexIntVersions);
        }