Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ReadString isn't generic - for strings longer than 0x20 characters it would need to call Dump multiple times and terminate if a block contained a null terminator. This also probably isn't the best way to do string conversion in C# either, but oh well.
- Add this to MainWindow:
- public void UpdateItemName(Item item)
- {
- byte[] name = System.Text.Encoding.ASCII.GetBytes(item.Name + "\0");
- uint addr = item.Address + 0x1C;
- for (uint i = 0; i < name.Length; i++)
- tcpGecko.poke08(addr + i, name[i]);
- }
- private string ReadString(uint addr)
- {
- MemoryStream dump = new MemoryStream();
- tcpGecko.Dump(addr, addr + 0x20, dump);
- dump.Position = 0;
- StringBuilder builder = new StringBuilder();
- for(int i = 0; i < dump.Length; i++)
- {
- int data = dump.ReadByte();
- if (data == 0) break;
- builder.Append((char)data);
- }
- return builder.ToString();
- }
- Update the initialization of Item in MainWindow::LoadDataAsync to:
- var item = new Item
- {
- Address = end,
- Page = Convert.ToInt32(page),
- Unknown = Convert.ToInt32(this.tcpGecko.peek(end + 0x4)),
- Value = this.tcpGecko.peek(end + 0x8),
- Equipped = this.tcpGecko.peek(end + 0xC),
- ModAmount = this.tcpGecko.peek(end + 0x5C),
- ModType = this.tcpGecko.peek(end + 0x64),
- Name = ReadString(end + 0x1C),
- Parent = this,
- };
- Add this to Item:
- private string m_name;
- public string Name
- {
- get { return m_name; }
- set { m_name = value; }
- }
- public string EditableName
- {
- get { return m_name; }
- set
- {
- m_name = value;
- if (Parent != null)
- Parent.UpdateItemName(this);
- }
- }
- public MainWindow Parent;
- Then change one of the column data bindings in the xaml to point to EditableName.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement