void LoadHackFromFile(string hackFileName) { var dataUntrimmed = File.ReadAllText(hackFileName); var data = Regex.Replace(dataUntrimmed, @"\s+", ""); int nextEnd; int prevEnd = data.IndexOf(":"); // Failed to parse file if (prevEnd < 8 || prevEnd == data.Length - 1) { return; } string remData = data.Substring(prevEnd + 1); do { nextEnd = remData.IndexOf(":"); uint address = ParsingUtilities.ParseHex(data.Substring(prevEnd - 8, 8)); string byteData = (nextEnd == -1) ? remData : remData.Substring(0, nextEnd - 8); var hackBytes = new byte[byteData.Length / 2]; for (int i = 0; i < hackBytes.Length; i++) { hackBytes[i] = (byte)ParsingUtilities.ParseHex(byteData.Substring(i * 2, 2)); } _payload.Add(new Tuple <uint, byte[]>(address, hackBytes)); remData = remData.Substring(nextEnd + 1); prevEnd += nextEnd + 1; }while (nextEnd != -1); }
public WatchVariableControlPrecursor(XElement element) { /// Watchvariable params string typeName = (element.Attribute(XName.Get("type"))?.Value); string specialType = element.Attribute(XName.Get("specialType"))?.Value; BaseAddressTypeEnum baseAddressType = WatchVariableUtilities.GetBaseAddressType(element.Attribute(XName.Get("base")).Value); uint?offsetUS = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetUS"))?.Value); uint?offsetJP = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetJP"))?.Value); uint?offsetSH = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetSH"))?.Value); uint?offsetEU = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offsetEU"))?.Value); uint?offsetDefault = ParsingUtilities.ParseHexNullable(element.Attribute(XName.Get("offset"))?.Value); uint?mask = element.Attribute(XName.Get("mask")) != null ? (uint?)ParsingUtilities.ParseHex(element.Attribute(XName.Get("mask")).Value) : null; int?shift = element.Attribute(XName.Get("shift")) != null? int.Parse(element.Attribute(XName.Get("shift")).Value) : (int?)null; bool handleMapping = (element.Attribute(XName.Get("handleMapping")) != null) ? bool.Parse(element.Attribute(XName.Get("handleMapping")).Value) : true; string name = element.Value; WatchVar = new WatchVariable( name, typeName, specialType, baseAddressType, offsetUS, offsetJP, offsetSH, offsetEU, offsetDefault, mask, shift, handleMapping); Name = name; Subclass = WatchVariableUtilities.GetSubclass(element.Attribute(XName.Get("subclass"))?.Value); GroupList = WatchVariableUtilities.ParseVariableGroupList(element.Attribute(XName.Get("groupList"))?.Value); BackgroundColor = (element.Attribute(XName.Get("color")) != null) ? ColorUtilities.GetColorFromString(element.Attribute(XName.Get("color")).Value) : (Color?)null; string displayTypeName = (element.Attribute(XName.Get("display"))?.Value); DisplayType = displayTypeName != null ? TypeUtilities.StringToType[displayTypeName] : null; RoundingLimit = (element.Attribute(XName.Get("round")) != null) ? ParsingUtilities.ParseInt(element.Attribute(XName.Get("round")).Value) : (int?)null; UseHex = (element.Attribute(XName.Get("useHex")) != null) ? bool.Parse(element.Attribute(XName.Get("useHex")).Value) : (bool?)null; InvertBool = element.Attribute(XName.Get("invertBool")) != null? bool.Parse(element.Attribute(XName.Get("invertBool")).Value) : (bool?)null; IsYaw = (element.Attribute(XName.Get("yaw")) != null) ? bool.Parse(element.Attribute(XName.Get("yaw")).Value) : (bool?)null; Coordinate = element.Attribute(XName.Get("coord")) != null? WatchVariableUtilities.GetCoordinate(element.Attribute(XName.Get("coord")).Value) : (Coordinate?)null; FixedAddresses = element.Attribute(XName.Get("fixed")) != null? ParsingUtilities.ParseHexList(element.Attribute(XName.Get("fixed")).Value) : null; VerifyState(); }
private void Annihilate() { List <DataGridViewRow> rows = ControlUtilities.GetTableSelectedRows(dataGridView); rows.ForEach(row => { uint address = ParsingUtilities.ParseHex(row.Cells[0].Value); ButtonUtilities.AnnihilateTriangle(new List <uint>() { address }); }); }
public void RefreshDataGridViewAfterRemoval() { List <DataGridViewRow> rows = ControlUtilities.GetTableAllRows(dataGridView); rows.ForEach(row => { uint address = ParsingUtilities.ParseHex(row.Cells[0].Value); if (!_triAddressList.Contains(address)) { dataGridView.Rows.Remove(row); } }); labelNumTriangles.Text = _triAddressList.Count + " Triangles"; }
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)); } }
private void Remove() { long removeTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; if (removeTime < _lastRemoveTime + 1000) { DialogUtilities.DisplayMessage("Attempted to remove twice in 1 second.", "Warning"); return; } _lastRemoveTime = removeTime; List <DataGridViewRow> rows = ControlUtilities.GetTableSelectedRows(dataGridView); rows.ForEach(row => { uint address = ParsingUtilities.ParseHex(row.Cells[0].Value); _triAddressList.Remove(address); }); RefreshDataGridViewAfterRemoval(); }