private void SyncComboBoxFromJOR(ComboBox comboBox, JORControlSelector jorSelector) { this.SuppressEvent = true; if (jorSelector.SelectedIndex < jorSelector.Items.Count) { comboBox.SelectedIndex = (int)jorSelector.SelectedIndex; } this.SuppressEvent = false; }
private void SyncRadioButtonFromJOR(GroupBox groupBox, JORControlSelector jorSelector) { this.SuppressEvent = true; for (int i = 0; i < groupBox.Controls.Count; i++) { RadioButton radioButton = groupBox.Controls[i] as RadioButton; radioButton.Checked = i == jorSelector.SelectedIndex; } this.SuppressEvent = false; }
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); }
private JORControl ReadControlSub(MemoryInputStream stream, JORNode node) { string controlType = stream.ReadMagic(); JORControl control; if (controlType == "LABL") { control = new JORControlLabel(); } else if (controlType == "BUTN") { control = new JORControlButton(); } else if (controlType == "CHBX") { control = new JORControlCheckBox(); } else if (controlType == "RNGi") { control = new JORControlRangeInt(); } else if (controlType == "RNGf") { control = new JORControlRangeFloat(); } else if (controlType == "CMBX" || controlType == "RBTN") { control = new JORControlSelector(); } else if (controlType == "EDBX") { control = new JORControlEditBox(); } else { control = new JORControlImmutable(); } control.Node = node; control.Type = controlType; control.Kind = (EKind)stream.ReadU32(); control.Name = stream.ReadSJIS(); control.Style = stream.ReadU32(); control.ID = stream.ReadU32(); // Debug.WriteLine("<- Control {0} {1} {2}", control.Type, control.Kind, control.Name); if ((control.Kind & EKind.HasListener) != 0) { control.ListenerPtr = stream.ReadU32(); } if (((control.Kind & EKind.ValueID) != 0) && control.Type != "EDBX") { control.Kind |= (EKind)0x20; } float valueF = 0.0f; uint valueU = 0xFFFFFFFF; uint kindSize = (uint)(control.Kind & EKind.SizeMask); if (kindSize != 0) { if ((control.Kind & EKind.FloatValue) != 0) { valueF = stream.ReadF32(); } else { valueU = stream.ReadU32(); } } if (control is JORControlCheckBox) { var cb = control as JORControlCheckBox; cb.Mask = valueU >> 16; cb.Value = (valueU & 0xFF) != 0; } else if (control is JORControlRangeInt) { var range = control as JORControlRangeInt; range.RangeMin = stream.ReadS32(); range.RangeMax = stream.ReadS32(); range.Value = (int)valueU; } else if (control is JORControlRangeFloat) { var range = control as JORControlRangeFloat; range.RangeMin = stream.ReadF32(); range.RangeMax = stream.ReadF32(); range.Value = valueF; } else if (control is JORControlEditBox) { var editBox = control as JORControlEditBox; editBox.MaxChars = stream.ReadU16(); editBox.Text = stream.ReadSJIS(); } ReadControlLocation(stream, ref control.Location); node.Controls.Add(control); return(control); }