public override void Update(uint updateMode, MemoryInputStream stream) { base.Update(updateMode, stream); if ((updateMode & 0x08) != 0) { // Modifying items var cmd = stream.ReadU32(); var style = stream.ReadU32(); var name = stream.ReadSJIS(); var value = stream.ReadU32(); if (cmd == 1) { // Add new item to end. var newItem = new JORControlSelectorItem(); newItem.Name = name; newItem.Value = value; newItem.Unk3 = style; Items.Add(newItem); } else if (cmd == 5) { // Remove all items. Items.Clear(); } } if ((updateMode & 0x02) != 0) { CurrentValue = stream.ReadU32(); } AfterUpdate(); }
private void ProcessObjectInfo(MemoryInputStream stream) { JORControlSelector currentSelector = null; Stack <JORNode> nodeStack = new Stack <JORNode>(); JORNode node = null; while (stream.HasData()) { JORMessageCommand command = (JORMessageCommand)stream.ReadU32(); // Debug.WriteLine("<- ORef MessageCommand {0}", command); if (command == JORMessageCommand.StartNode) { nodeStack.Push(node); node = ReadGenNodeSub(stream, true); Debug.WriteLine("<- GenObjectInfo Stack {2} Ptr 0x{1:X8} {0}", node.Name, node.NodePtr, nodeStack.Count); JORNode parentNode = nodeStack.Peek(); if (parentNode != null) { parentNode.AddChild(node); } // Debug.WriteLine("StartNodeClear {0}", node); node.Invalidate(); } else if (command == JORMessageCommand.EndNode) { node.Status = JORNodeStatus.Valid; if (NodeUpdated != null) { NodeUpdated(node); } node = nodeStack.Pop(); } else if (command == JORMessageCommand.GenNode) { JORNode child = ReadGenNodeSub(stream, true); child.Invalidate(); node.AddChild(child); } else if (command == JORMessageCommand.GenControl) { var control = ReadControlSub(stream, node); } else if (command == JORMessageCommand.StartSelector) { var control = ReadControlSub(stream, node); Debug.Assert(control is JORControlSelector); currentSelector = control as JORControlSelector; } else if (command == JORMessageCommand.EndSelector) { currentSelector = null; } else if (command == JORMessageCommand.SelectorItem) { var selection = new JORControlSelectorItem(); selection.Name = stream.ReadSJIS(); selection.Value = stream.ReadU32(); selection.Unk3 = stream.ReadU32(); ReadControlLocation(stream, ref selection.Location); if (currentSelector != null) { currentSelector.Items.Add(selection); } } else { throw new Exception("Unknown message type"); } } Debug.Assert(nodeStack.Count == 0); Debug.Assert(node == null); }