Advertisement
Guest User

Untitled

a guest
Mar 5th, 2017
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.97 KB | None | 0 0
  1. 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.
  2.  
  3. Add this to MainWindow:
  4.  
  5.         public void UpdateItemName(Item item)
  6.         {
  7.             byte[] name = System.Text.Encoding.ASCII.GetBytes(item.Name + "\0");
  8.  
  9.             uint addr = item.Address + 0x1C;
  10.  
  11.             for (uint i = 0; i < name.Length; i++)
  12.                 tcpGecko.poke08(addr + i, name[i]);
  13.         }
  14.        
  15.         private string ReadString(uint addr)
  16.         {
  17.             MemoryStream dump = new MemoryStream();
  18.             tcpGecko.Dump(addr, addr + 0x20, dump);
  19.             dump.Position = 0;
  20.  
  21.             StringBuilder builder = new StringBuilder();
  22.  
  23.             for(int i = 0; i < dump.Length; i++)
  24.             {
  25.                 int data = dump.ReadByte();
  26.                 if (data == 0) break;
  27.  
  28.                 builder.Append((char)data);
  29.             }
  30.  
  31.             return builder.ToString();
  32.         }
  33.  
  34. Update the initialization of Item in MainWindow::LoadDataAsync to:
  35.  
  36.                     var item = new Item
  37.                     {
  38.                         Address = end,
  39.                         Page = Convert.ToInt32(page),
  40.                         Unknown = Convert.ToInt32(this.tcpGecko.peek(end + 0x4)),
  41.                         Value = this.tcpGecko.peek(end + 0x8),
  42.                         Equipped = this.tcpGecko.peek(end + 0xC),
  43.                         ModAmount = this.tcpGecko.peek(end + 0x5C),
  44.                         ModType = this.tcpGecko.peek(end + 0x64),
  45.                         Name = ReadString(end + 0x1C),
  46.                         Parent = this,
  47.                     };
  48.  
  49. Add this to Item:
  50.  
  51.         private string m_name;
  52.         public string Name
  53.         {
  54.             get { return m_name; }
  55.             set { m_name = value; }
  56.         }
  57.  
  58.         public string EditableName
  59.         {
  60.             get { return m_name; }
  61.             set
  62.             {
  63.                 m_name = value;
  64.  
  65.                 if (Parent != null)
  66.                     Parent.UpdateItemName(this);
  67.             }
  68.         }
  69.  
  70.         public MainWindow Parent;
  71.  
  72. 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