GetElementString() public static method

Wrapper function for SelectSingleNode that throws an exception mentioning the node name if it is not found. Returns the node text if successful.
public static GetElementString ( XmlNode node, string elementName ) : string
node System.Xml.XmlNode
elementName string
return string
Esempio n. 1
0
File: View.cs Progetto: stee01/ags
 public View(XmlNode node)
 {
     ID   = Convert.ToInt32(SerializeUtils.GetElementString(node, "ID"));
     Name = SerializeUtils.GetElementString(node, "Name");
     foreach (XmlNode loopNode in SerializeUtils.GetChildNodes(node, "Loops"))
     {
         _loops.Add(new ViewLoop(loopNode));
     }
 }
Esempio n. 2
0
 public ViewLoop(XmlNode node)
 {
     ID          = Convert.ToInt32(SerializeUtils.GetElementString(node, "ID"));
     RunNextLoop = Boolean.Parse(SerializeUtils.GetElementString(node, "RunNextLoop"));
     foreach (XmlNode frameNode in SerializeUtils.GetChildNodes(node, "Frames"))
     {
         _frames.Add(new ViewFrame(frameNode));
     }
 }
Esempio n. 3
0
 public Translation(XmlNode node)
 {
     this.Name        = SerializeUtils.GetElementString(node, "Name");
     _modified        = false;
     _normalFont      = null;
     _speechFont      = null;
     _rightToLeftText = null;
     _encodingHint    = null;
     _encoding        = Encoding.Default;
     LoadData();
 }
Esempio n. 4
0
        public void FromXml(XmlNode node)
        {
            XmlNode lipSyncNode = node.SelectSingleNode("LipSync");

            this.Type         = (LipSyncType)Enum.Parse(typeof(LipSyncType), SerializeUtils.GetElementString(lipSyncNode, "Type"));
            this.DefaultFrame = Convert.ToInt32(SerializeUtils.GetElementString(lipSyncNode, "DefaultFrame"));
            int nodeIndex = 0;

            foreach (XmlNode frameNode in SerializeUtils.GetChildNodes(lipSyncNode, "Frames"))
            {
                _lipSyncCharsForFrame[nodeIndex] = frameNode.InnerText;
                nodeIndex++;
            }
        }
Esempio n. 5
0
        public Dialog(XmlNode node)
        {
            _scriptChangedSinceLastCompile = true;
            _id             = Convert.ToInt32(SerializeUtils.GetElementString(node, "ID"));
            _name           = SerializeUtils.GetElementString(node, "Name");
            _showTextParser = Boolean.Parse(SerializeUtils.GetElementString(node, "ShowTextParser"));
            XmlNode scriptNode = node.SelectSingleNode("Script");

            // Luckily the CDATA section is easy to read back
            _script = scriptNode.InnerText;

            foreach (XmlNode child in SerializeUtils.GetChildNodes(node, "DialogOptions"))
            {
                _options.Add(new DialogOption(child));
            }
        }
Esempio n. 6
0
        public Sprite(XmlNode node)
        {
            _number     = Convert.ToInt32(node.Attributes["Slot"].InnerText);
            _width      = Convert.ToInt32(node.Attributes["Width"].InnerText);
            _height     = Convert.ToInt32(node.Attributes["Height"].InnerText);
            _colorDepth = Convert.ToInt32(node.Attributes["ColorDepth"].InnerText);

            if (node.Attributes["AlphaChannel"] != null)
            {
                _alphaChannel = Convert.ToBoolean(node.Attributes["AlphaChannel"].InnerText);
            }

            if (node.Attributes["ColoursLockedToRoom"] != null)
            {
                _coloursLockedToRoom = Convert.ToInt32(node.Attributes["ColoursLockedToRoom"].InnerText);
            }

            if (node.SelectSingleNode("Source") != null)
            {
                XmlNode sourceNode = node.SelectSingleNode("Source");

                try
                {
                    _sourceFile         = SerializeUtils.GetElementString(sourceNode, "FileName");
                    _offsetX            = Convert.ToInt32(SerializeUtils.GetElementString(sourceNode, "OffsetX"));
                    _offsetY            = Convert.ToInt32(SerializeUtils.GetElementString(sourceNode, "OffsetY"));
                    _frame              = Convert.ToInt32(SerializeUtils.GetElementString(sourceNode, "Frame"));
                    _remapToGamePalette = Convert.ToBoolean(SerializeUtils.GetElementString(sourceNode, "RemapToGamePalette"));
                    _remapToRoomPalette = Convert.ToBoolean(SerializeUtils.GetElementString(sourceNode, "RemapToRoomPalette"));
                    _tranparentColour   = (SpriteImportTransparency)Enum.Parse(typeof(SpriteImportTransparency), SerializeUtils.GetElementString(sourceNode, "ImportMethod"));
                }
                catch (InvalidDataException)
                {
                    // pass
                }

                try
                {
                    _importAlphaChannel = Convert.ToBoolean(SerializeUtils.GetElementString(sourceNode, "ImportAlphaChannel"));
                }
                catch (InvalidDataException)
                {
                    _importAlphaChannel = true;
                }
            }
        }
Esempio n. 7
0
        public Script(XmlNode node)
        {
            if (node.Name != "Script")
            {
                throw new AGS.Types.InvalidDataException("Script node incorrect");
            }
            _fileName    = SerializeUtils.GetElementString(node, "FileName");
            _name        = SerializeUtils.GetElementString(node, "Name");
            _description = SerializeUtils.GetElementString(node, "Description");
            _author      = SerializeUtils.GetElementString(node, "Author");
            _version     = SerializeUtils.GetElementString(node, "Version");
            _uniqueKey   = Convert.ToInt32(SerializeUtils.GetElementString(node, "Key"));
            _isHeader    = Convert.ToBoolean(SerializeUtils.GetElementString(node, "IsHeader"));

            LoadFromDisk();

            _modified = false;
        }
Esempio n. 8
0
 public Sprite(XmlNode node)
 {
     _number     = Convert.ToInt32(node.Attributes["Slot"].InnerText);
     _width      = Convert.ToInt32(node.Attributes["Width"].InnerText);
     _height     = Convert.ToInt32(node.Attributes["Height"].InnerText);
     _colorDepth = Convert.ToInt32(node.Attributes["ColorDepth"].InnerText);
     if (node.Attributes["AlphaChannel"] != null)
     {
         _alphaChannel = Convert.ToBoolean(node.Attributes["AlphaChannel"].InnerText);
     }
     if (node.SelectSingleNode("Source") != null)
     {
         XmlNode sourceNode = node.SelectSingleNode("Source");
         _sourceFile = SerializeUtils.GetElementString(sourceNode, "FileName");
     }
     if (node.Attributes["ColoursLockedToRoom"] != null)
     {
         _coloursLockedToRoom = Convert.ToInt32(node.Attributes["ColoursLockedToRoom"].InnerText);
     }
 }
Esempio n. 9
0
File: Game.cs Progetto: torkleyy/ags
        public void FromXml(XmlNode node)
        {
            node = node.SelectSingleNode("Game");

            _settings.FromXml(node);

            if (node.SelectSingleNode(_defaultSetup.GetType().Name) != null)
            {
                // Only for >= 3.4.1
                _defaultSetup.FromXml(node);
            }

            _lipSync.FromXml(node);
            _propertySchema.FromXml(node);

            if (node.SelectSingleNode("InventoryHotspotMarker") != null)
            {
                // Pre-3.0.3
                InventoryHotspotMarker marker = new InventoryHotspotMarker();
                marker.FromXml(node);
                _settings.InventoryHotspotMarker = marker;
            }

            foreach (XmlNode msgNode in SerializeUtils.GetChildNodes(node, "GlobalMessages"))
            {
                _globalMessages[Convert.ToInt32(msgNode.Attributes["ID"].InnerText) - GLOBAL_MESSAGE_ID_START] = msgNode.InnerText;
            }

            _plugins.Clear();
            foreach (XmlNode pluginNode in SerializeUtils.GetChildNodes(node, "Plugins"))
            {
                _plugins.Add(new Plugin(pluginNode));
            }

            _rooms = new UnloadedRoomFolders(node.SelectSingleNode("Rooms").FirstChild, node);

            _guis = new GUIFolders(node.SelectSingleNode("GUIs").FirstChild, node);

            _inventoryItems = new InventoryItemFolders(node.SelectSingleNode("InventoryItems").FirstChild, node);

            _textParser = new TextParser(node.SelectSingleNode("TextParser"));

            _characters = new CharacterFolders(node.SelectSingleNode("Characters").FirstChild, node);

            _playerCharacter = null;
            string playerCharText = SerializeUtils.GetElementString(node, "PlayerCharacter");

            if (playerCharText.Length > 0)
            {
                int playerCharID = Convert.ToInt32(playerCharText);
                foreach (Character character in RootCharacterFolder.AllItemsFlat)
                {
                    if (character.ID == playerCharID)
                    {
                        _playerCharacter = character;
                        break;
                    }
                }
            }

            _dialogs = new DialogFolders(node.SelectSingleNode("Dialogs").FirstChild, node);

            _cursors.Clear();
            foreach (XmlNode cursNode in SerializeUtils.GetChildNodes(node, "Cursors"))
            {
                _cursors.Add(new MouseCursor(cursNode));
            }

            _fonts.Clear();
            foreach (XmlNode fontNode in SerializeUtils.GetChildNodes(node, "Fonts"))
            {
                _fonts.Add(new Font(fontNode));
            }

            _palette = ReadPaletteFromXML(node);

            _sprites = new SpriteFolder(node.SelectSingleNode("Sprites").FirstChild);

            _views = new ViewFolders(node.SelectSingleNode("Views").FirstChild);

            _deletedViewIDs.Clear();
            if (node.SelectSingleNode("DeletedViews") != null)
            {
                foreach (XmlNode transNode in SerializeUtils.GetChildNodes(node, "DeletedViews"))
                {
                    _deletedViewIDs.Add(Convert.ToInt32(transNode.InnerText), null);
                }
            }

            _scripts = new ScriptFolders(node.SelectSingleNode("Scripts").FirstChild, node);

            if (node.SelectSingleNode("AudioClips") != null)
            {
                _audioClips = new AudioClipFolders(node.SelectSingleNode("AudioClips").FirstChild);
            }
            else
            {
                _audioClips = new AudioClipFolders("Main");
                _audioClips.RootFolder.DefaultPriority = AudioClipPriority.Normal;
                _audioClips.RootFolder.DefaultRepeat   = InheritableBool.False;
                _audioClips.RootFolder.DefaultVolume   = 100;
            }

            _audioClipTypes.Clear();
            if (node.SelectSingleNode("AudioClipTypes") != null)
            {
                foreach (XmlNode clipTypeNode in SerializeUtils.GetChildNodes(node, "AudioClipTypes"))
                {
                    _audioClipTypes.Add(new AudioClipType(clipTypeNode));
                }
            }

            _translations.Clear();
            if (node.SelectSingleNode("Translations") != null)
            {
                foreach (XmlNode transNode in SerializeUtils.GetChildNodes(node, "Translations"))
                {
                    _translations.Add(new Translation(transNode));
                }
            }

            if (node.SelectSingleNode("GlobalVariables") != null)
            {
                _globalVariables = new GlobalVariables(node.SelectSingleNode("GlobalVariables"));
            }
            else
            {
                _globalVariables = new GlobalVariables();
            }

            _oldInteractionVariables.Clear();
            if (node.SelectSingleNode("OldInteractionVariables") != null)
            {
                foreach (XmlNode varNode in SerializeUtils.GetChildNodes(node, "OldInteractionVariables"))
                {
                    _oldInteractionVariables.Add(new OldInteractionVariable(SerializeUtils.GetAttributeString(varNode, "Name"), SerializeUtils.GetAttributeInt(varNode, "Value")));
                }
            }

            if (_savedXmlVersionIndex == null)
            {
                // Pre-3.0.3, upgrade co-ordinates
                ConvertCoordinatesToNativeResolution();
            }
        }
Esempio n. 10
0
 public Plugin(XmlNode pluginNode)
 {
     _fileName       = SerializeUtils.GetElementString(pluginNode, "FileName");
     _serializedData = Convert.FromBase64String(SerializeUtils.GetElementString(pluginNode, "Data"));
 }
Esempio n. 11
0
 public Translation(XmlNode node)
 {
     this.Name = SerializeUtils.GetElementString(node, "Name");
     LoadData();
 }