public void ReadFromStream(PacketStream stream) { StatPanels = new Dictionary <string, List <string> >(); int statPanelCount = stream.ReadByte(); for (int i = 0; i < statPanelCount; i++) { string panelName = stream.ReadString(); List <string> lines = new(); int lineCount = stream.ReadByte(); for (int j = 0; j < lineCount; j++) { lines.Add(stream.ReadString()); } StatPanels.Add(panelName, lines); } }
public void ReadFromStream(PacketStream stream) { File = stream.ReadString(); if (File == String.Empty) { File = null; } Channel = stream.ReadUInt16(); Volume = (File != null) ? stream.ReadByte() : 100; }
private void ReadAtomsSection(PacketStream stream) { UInt32 atomCount = stream.ReadUInt32(); for (int i = 0; i < atomCount; i++) { DreamFullState.Atom atom = new DreamFullState.Atom(); atom.AtomID = stream.ReadUInt32(); atom.Type = (AtomType)stream.ReadByte(); atom.LocationID = stream.ReadUInt32(); atom.IconAppearanceID = (int)stream.ReadUInt32(); if (atom.Type == AtomType.Movable) { atom.ScreenLocation = stream.ReadScreenLocation(); } FullState.Atoms[atom.AtomID] = atom; } }
public void ReadFromStream(PacketStream stream) { List <WindowDescriptor> windowDescriptors = new List <WindowDescriptor>(); int windowCount = stream.ReadByte(); for (int i = 0; i < windowCount; i++) { string windowName = stream.ReadString(); List <ElementDescriptor> elementDescriptors = new List <ElementDescriptor>(); int elementCount = stream.ReadByte(); for (int j = 0; j < elementCount; j++) { string elementName = stream.ReadString(); DescriptorType elementType = (DescriptorType)stream.ReadByte(); ElementDescriptor elementDescriptor; switch (elementType) { case DescriptorType.Main: elementDescriptor = new ElementDescriptorMain(elementName); break; case DescriptorType.Input: elementDescriptor = new ElementDescriptorInput(elementName); break; case DescriptorType.Button: elementDescriptor = new ElementDescriptorButton(elementName); break; case DescriptorType.Child: elementDescriptor = new ElementDescriptorChild(elementName); break; case DescriptorType.Output: elementDescriptor = new ElementDescriptorOutput(elementName); break; case DescriptorType.Info: elementDescriptor = new ElementDescriptorInfo(elementName); break; case DescriptorType.Map: elementDescriptor = new ElementDescriptorMap(elementName); break; case DescriptorType.Browser: elementDescriptor = new ElementDescriptorBrowser(elementName); break; default: throw new Exception("Invalid descriptor type '" + elementType + "'"); } elementDescriptors.Add(elementDescriptor); AttributeType valueType; do { valueType = (AttributeType)stream.ReadByte(); switch (valueType) { case AttributeType.Pos: elementDescriptor.Pos = new Point(stream.ReadUInt16(), stream.ReadUInt16()); break; case AttributeType.Size: elementDescriptor.Size = new Size(stream.ReadUInt16(), stream.ReadUInt16()); break; case AttributeType.Anchor1: elementDescriptor.Anchor1 = new Point(stream.ReadUInt16(), stream.ReadUInt16()); break; case AttributeType.Anchor2: elementDescriptor.Anchor2 = new Point(stream.ReadUInt16(), stream.ReadUInt16()); break; case AttributeType.BackgroundColor: elementDescriptor.BackgroundColor = Color.FromArgb(stream.ReadByte(), stream.ReadByte(), stream.ReadByte()); break; case AttributeType.IsVisible: elementDescriptor.IsVisible = stream.ReadBool(); break; case AttributeType.IsDefault: elementDescriptor.IsDefault = stream.ReadBool(); break; case AttributeType.IsPane: ((ElementDescriptorMain)elementDescriptor).IsPane = stream.ReadBool(); break; case AttributeType.Left: ((ElementDescriptorChild)elementDescriptor).Left = stream.ReadString(); break; case AttributeType.Right: ((ElementDescriptorChild)elementDescriptor).Right = stream.ReadString(); break; case AttributeType.IsVert: ((ElementDescriptorChild)elementDescriptor).IsVert = stream.ReadBool(); break; case AttributeType.Text: if (elementDescriptor is ElementDescriptorButton) { ((ElementDescriptorButton)elementDescriptor).Text = stream.ReadString(); } break; case AttributeType.End: break; default: throw new Exception("Invalid attribute type '" + valueType + "'"); } } while (valueType != AttributeType.End); } WindowDescriptor windowDescriptor = new WindowDescriptor(windowName, elementDescriptors); windowDescriptors.Add(windowDescriptor); } InterfaceDescriptor = new InterfaceDescriptor(windowDescriptors); }
private void ReadAtomCreationsSection(PacketStream stream) { UInt16 atomCreationsCount = stream.ReadUInt16(); for (int i = 0; i < atomCreationsCount; i++) { UInt32 atomID = stream.ReadUInt32(); DreamDeltaState.AtomCreation atomCreation = new DreamDeltaState.AtomCreation((AtomType)stream.ReadByte(), (int)stream.ReadUInt32()); atomCreation.LocationID = stream.ReadUInt32(); if (atomCreation.Type == AtomType.Movable) { atomCreation.ScreenLocation = stream.ReadScreenLocation(); } DeltaState.AtomCreations.Add(atomID, atomCreation); } }