public void RemoveControl(VarHackContainer varHackContainer) { lock (_objectLock) { Controls.Remove(varHackContainer); } }
public void OpenVariables() { List <XElement> elements = DialogUtilities.OpenXmlElements(FileType.StroopVarHackVariables); List <VarHackContainer> varHackContainers = elements.ConvertAll(element => VarHackContainer.CreateFromXml(this, element)); lock (_objectLock) { varHackContainers.ForEach(varHackContainer => Controls.Add(varHackContainer)); } }
public void SetPositions(int xPos, int yPos, int yDelta) { lock (_objectLock) { for (int i = 0; i < Controls.Count; i++) { VarHackContainer varHackContainer = Controls[i] as VarHackContainer; varHackContainer.SetPosition(xPos, yPos - i * yDelta); } } }
public (VarHackContainer, VarHackContainer) GetHexIntVersions() { string name = GetCurrentName(); string name1 = name.Replace(VarHackConfig.EscapeChar, "%04x"); string name2 = "%04x"; uint address = GetCurrentAddress() ?? 0; uint address1 = address; uint address2 = address + 2; int index = name.IndexOf(VarHackConfig.EscapeChar); if (index == -1) { index = 0; } int xPos = GetCurrentXPosition() ?? 0; int xPos1 = xPos; int xPos2 = xPos + (index + 4) * VarHackConfig.CharacterWidth; int yPos = GetCurrentYPosition() ?? 0; int yPos1 = yPos; int yPos2 = yPos; VarHackContainer v1 = new VarHackContainer( _varHackPanel, 0, false /* useDefaults */, null /* specialTypeIn */, true /* noNumIn */, name1 /* varNameIn */, address1 /* addressIn */, typeof(ushort) /* memoryTypeIn */, true /* useHexIn */, null /* pointerOffsetIn */, xPos1 /* xPosIn */, yPos1 /* yPosIn */); VarHackContainer v2 = new VarHackContainer( _varHackPanel, 0, false /* useDefaults */, null /* specialTypeIn */, true /* noNumIn */, name2 /* varNameIn */, address2 /* addressIn */, typeof(ushort) /* memoryTypeIn */, true /* useHexIn */, null /* pointerOffsetIn */, xPos2 /* xPosIn */, yPos2 /* yPosIn */); return(v1, v2); }
// Methods for buttons to modify the controls public void AddNewControl() { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } VarHackContainer varHackContainer = VarHackContainer.CreateDefault(this, Controls.Count); lock (_objectLock) { Controls.Add(varHackContainer); } }
// Methods for buttons to modify the controls public void AddNewControl() { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } VarHackContainer varHackContainer = new VarHackContainer(this, Controls.Count, true); lock (_objectLock) { Controls.Add(varHackContainer); } }
public void AddNewControlWithGetterFunction(Func <string> getterFunction) { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } VarHackContainer varHackContainer = new VarHackContainer(this, Controls.Count, getterFunction); lock (_objectLock) { Controls.Add(varHackContainer); } }
public void MoveDownControl(VarHackContainer varHackContainer) { lock (_objectLock) { int index = Controls.IndexOf(varHackContainer); if (index == Controls.Count - 1) { return; } int newIndex = index + 1; Controls.SetChildIndex(varHackContainer, newIndex); } }
// Methods from a watch var control public void AddNewControlWithParameters(string varName, uint address, Type memoryType, bool useHex, uint?pointerOffset) { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } VarHackContainer varHackContainer = new VarHackContainer(this, Controls.Count, varName, address, memoryType, useHex, pointerOffset); lock (_objectLock) { Controls.Add(varHackContainer); } }
private List <XElement> GetCurrentXmlElements() { List <XElement> elements = new List <XElement>(); lock (_objectLock) { foreach (Control control in Controls) { VarHackContainer varHackContainer = control as VarHackContainer; elements.Add(varHackContainer.ToXml()); } } return(elements); }
// Update method public void UpdateControls() { lock (_objectLock) { for (int i = 0; i < Controls.Count; i++) { VarHackContainer varHackContainer = Controls[i] as VarHackContainer; if (varHackContainer.UpdatesContinuously()) { ApplyVariableToMemory(i); } } } }
public void AddNewControl(string specialType) { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } VarHackContainer varHackContainer = VarHackContainer.CreateSpecial(this, Controls.Count, specialType); lock (_objectLock) { Controls.Add(varHackContainer); } }
public void DuplicateControl(VarHackContainer varHackContainer) { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } int index = Controls.IndexOf(varHackContainer); VarHackContainer duplicate = varHackContainer.Clone(); lock (_objectLock) { Controls.Add(duplicate); Controls.SetChildIndex(duplicate, index + 1); } }
public void ShowVariableBytesInBigEndian() { InfoForm infoForm = new InfoForm(); StringBuilder stringBuilder = new StringBuilder(); lock (_objectLock) { foreach (Control control in Controls) { VarHackContainer varHackContainer = control as VarHackContainer; byte[] bytes = varHackContainer.GetBigEndianByteArray(); string bytesString = VarHackContainer.ConvertBytesToString(bytes); stringBuilder.Append(bytesString); } } infoForm.SetText("Var Hack Info", "Big Endian Bytes", stringBuilder.ToString()); infoForm.Show(); }
public void ConvertToHexIntVersions(VarHackContainer varHackContainer) { if (Controls.Count >= VarHackConfig.MaxPossibleVars) { return; } int index = Controls.IndexOf(varHackContainer); (VarHackContainer v1, VarHackContainer v2) = varHackContainer.GetHexIntVersions(); lock (_objectLock) { Controls.Add(v1); Controls.Add(v2); Controls.SetChildIndex(v1, index + 1); Controls.SetChildIndex(v2, index + 2); Controls.Remove(varHackContainer); } }
private void ApplyVariableToMemory(int index) { uint address = VarHackConfig.VarHackMemoryAddress + (uint)index * VarHackConfig.StructSize; byte[] bytes; if (index < Controls.Count) { VarHackContainer varHackContainer = Controls[index] as VarHackContainer; bytes = varHackContainer.GetLittleEndianByteArray(); } else { bytes = EMPTY_BYTES; } if (bytes == null) { return; } Config.Stream.WriteRamLittleEndian(bytes, address); }
public void ApplyVariableToMemory(VarHackContainer varHackContainer) { int index = Controls.IndexOf(varHackContainer); ApplyVariableToMemory(index); }