public void LoadCheats() { string parseable = CheatField.text; ItemArrayEditor <Item> ItemArray; if (SaveMode.value == 0) { ItemArray = new ItemArrayEditor <Item>(UI_ACItemGrid.LastInstanceOfItemGrid.Items); } else { ItemArray = new ItemArrayEditor <Item>(GetNoItems(40)); } byte[] allItemBytes = null; if (EnteredValueParseMode.value == 0) // 0 == cheat { if (parseable != "") { var bytes = ItemCheatCode.ReadCode(parseable); ItemArray = new ItemArrayEditor <Item>(UI_ACItemGrid.LastInstanceOfItemGrid.Items); if (bytes.Length % ItemArray.ItemSize == 0) { ItemArray.ImportItemDataX(bytes, EmptySpacesOnly.isOn, 0); } allItemBytes = bytes; } } else // 1 == hexdata { if (parseable != "") { List <byte[]> loadedItems = new List <byte[]>(); var split = parseable.Split(new[] { " ", "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < split.Length; ++i) { var itemText = split[i]; var item = itemText.Trim(); var asBytes = GetBytesFromString(item); loadedItems.Add(asBytes); } while (loadedItems.Count < 40) { loadedItems.Add(Item.NO_ITEM.ToBytesClass()); } allItemBytes = new byte[Item.SIZE * 40]; for (int i = 0; i < loadedItems.Count; ++i) { Array.Copy(loadedItems[i], 0, allItemBytes, i * Item.SIZE, Item.SIZE); } ItemArray.ImportItemDataX(allItemBytes, EmptySpacesOnly.isOn, 0); } } if (SaveMode.value == 0) // 0 == inventory { if (UI_ACItemGrid.LastInstanceOfItemGrid == null) { return; } for (int i = 0; i < ItemArray.Items.Count; ++i) { UI_ACItemGrid.LastInstanceOfItemGrid.SetItemAt(ItemArray.Items[i], i, i == (ItemArray.Items.Count - 1)); } } else { if (allItemBytes != null) { UI_NFSOACNHHandler.LastInstanceOfNFSO.SaveFile("NHIItems.nhi", allItemBytes); } else { throw new Exception("No valid items."); } } }