public static void Reload(string locale = "English") { if (_textBase == null) { _textBase = new Dictionary <string, string> (); } TextAsset _localeString = Resources.Load <TextAsset> ("Locales/" + locale + "/text"); if (_localeString == null) { Debug.LogWarning("CAN'T FIND LOCALE '" + locale + "'. LOADING DEFAULT LOCALE '" + CurrentLocale + "'."); _localeString = Resources.Load <TextAsset> ("Locales/" + locale + "/text"); } NanoXMLDocument document = new NanoXMLDocument(_localeString.text); NanoXMLNode RotNode = document.RootNode; foreach (NanoXMLNode node in RotNode.SubNodes) { if (node.Name.Equals("String")) { _textBase.Add(node.GetAttribute("id").Value, NormalizeDataString(node.Value)); } } }
public List <AccountAddedEventData> Deserialize(string data) { NanoXMLDocument xml = new NanoXMLDocument(data); List <AccountAddedEventData> l = new List <AccountAddedEventData>(); List <NanoXMLNode> xn = xml.RootNode.SubNodes.ToList(); for (int i = 0; i < xn.Count(); i++) { var OBJ = new AccountAddedEventData() { dboId = xn[i]["dboId"].Value, id = Convert.ToInt64(xn[i]["id"].Value), number = xn[i]["number"].Value, formattedNumber = xn[i]["formattedNumber"].Value, info = xn[i]["info"].Value, salias = xn[i]["salias"].Value, balance = Convert.ToDecimal(xn[i]["balance"].Value), limit = Convert.ToDecimal(xn[i]["limit"].Value), actual = Convert.ToDateTime(xn[i]["actual"].Value), beginDate = Convert.ToDateTime(xn[i]["beginDate"].Value), endDate = Convert.ToDateTime(xn[i]["endDate"].Value), currency = Convert.ToInt32(xn[i]["currency"].Value), status = xn[i]["status"].Value, bic = xn[i]["bic"].Value, correspondentAccount = xn[i]["correspondentAccount"].Value, name = xn[i]["name"].Value, payee = xn[i]["payee"].Value, clientRef = Convert.ToInt32(xn[i]["clientRef"].Value) }; l.Add(OBJ); } return(l); }
/// <summary> /// c = command, c_CmdXmlParser /// </summary> public static void c_CmdXmlParser(string txt, short startIndex = 0, int count = 4) { txt = txt.Remove(startIndex, count); string strData = Encoding.UTF8.GetString(File.ReadAllBytes(txt)); NanoXMLDocument xml = new NanoXMLDocument(strData); NanoXMLNode myAttribute = xml.RootNode["text"]; if (myAttribute == null) { Console.WriteLine("[Error] myAttribute null"); } Console.WriteLine(myAttribute.Name); Console.WriteLine(myAttribute.Value); Console.WriteLine(myAttribute.GetAttribute("size").Value); }
public static void Reload(string locale = "English") { if (_textBase == null) { _textBase = new Dictionary <string, string>(); } #if UNITY_STANDALONE string path = Application.streamingAssetsPath + "/Locales/text/text.xml"; // string path = Application.streamingAssetsPath + "/Locales/" + locale + "/text/text.xml"; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(path); XmlNodeList textsList = xmlDoc.GetElementsByTagName("String"); foreach (XmlNode textInfo in textsList) { _textBase.Add(textInfo.Attributes["id"].Value, NormalizeDataString(textInfo.InnerText)); } #else TextAsset _localeString = Resources.Load <TextAsset>("Data/Locales/" + locale + "/text/text"); if (_localeString == null) { Debug.LogWarning("CAN'T FIND LOCALE '" + locale + "'. LOADING DEFAULT LOCALE '" + _defaultLocale + "'."); _localeString = Resources.Load <TextAsset>("Data/Locales/" + _defaultLocale + "/text/text"); } NanoXMLDocument document = new NanoXMLDocument(_localeString.text); NanoXMLNode RotNode = document.RootNode; foreach (NanoXMLNode node in RotNode.SubNodes) { if (node.Name.Equals("String")) { _textBase.Add(node.GetAttribute("id").Value, NormalizeDataString(node.Value)); } } #endif }
public object NanoXml() { var doc = new NanoXMLDocument(_input); return(doc); }
private void parseXmlData() { TextAsset _xmlString = Resources.Load <TextAsset>("Data/GameFlow"); NanoXMLDocument document = new NanoXMLDocument(_xmlString.text); NanoXMLNode RotNode = document.RootNode; foreach (NanoXMLNode node in RotNode.SubNodes) { if (node.Name.Equals("screens")) { foreach (NanoXMLNode nodeScreens in node.SubNodes) { string sceneName = nodeScreens.GetAttribute("name").Value; SceneData sceneData = new SceneData(sceneName); string preloadNextScene = nodeScreens.GetAttribute("preloadNextScene").Value; if (!String.IsNullOrEmpty(preloadNextScene)) { sceneData.PreloadSceneName = convertSceneNameToID(preloadNextScene); } string designResolutionWidth = nodeScreens.GetAttribute("DesignResolutionWidth").Value; if (!String.IsNullOrEmpty(designResolutionWidth)) { sceneData.DesignResolutionWidth = Int32.Parse(designResolutionWidth); } string designResolutionHeight = nodeScreens.GetAttribute("DesignResolutionHeight").Value; if (!String.IsNullOrEmpty(designResolutionHeight)) { sceneData.DesignResolutionHeight = Int32.Parse(designResolutionHeight); } string designMatchWidthOrHeight = nodeScreens.GetAttribute("DesignMatchWidthOrHeight").Value; if (!String.IsNullOrEmpty(designMatchWidthOrHeight)) { sceneData.DesignMatchWidthOrHeight = float.Parse(designMatchWidthOrHeight); } if (nodeScreens.Name.Equals("screen")) { foreach (NanoXMLNode nodeScreensScreen in nodeScreens.SubNodes) { string formName = nodeScreensScreen.GetAttribute("name").Value.ToString(); UIConsts.FORM_ID formID = (UIConsts.FORM_ID)System.Enum.Parse(typeof(UIConsts.FORM_ID), formName); int formType = int.Parse(nodeScreensScreen.GetAttribute("type").Value); EFormCreationMethod creationMethod = EFormCreationMethod.Static; string path = UIConsts.DEFAULT_UI_PATH + formName; NanoXMLAttribute attrPath = nodeScreensScreen.GetAttribute("path"); if (attrPath != null) { path = attrPath.Value; } int faderType = 1; //show transparrent NanoXMLAttribute attrFader = nodeScreensScreen.GetAttribute("fader"); if (attrFader != null) { faderType = int.Parse(attrFader.Value); } NanoXMLAttribute attr = nodeScreensScreen.GetAttribute("creation"); if (attr != null) { if (!string.IsNullOrEmpty(attr.Value)) { if (attr.Value.ToLower() == "static") { creationMethod = EFormCreationMethod.Static; } else if (attr.Value.ToLower() == "dynamic") { creationMethod = EFormCreationMethod.Dynamic; } } } FormData formData = new FormData(formType, formID, path, faderType, creationMethod); sceneData.Forms.Add(formData); if (formType == 1) { sceneData.Menu = formID; } } } _scenesData.Add(sceneName, sceneData); } } } }
private void ReadPropertiesAndVariables() { if (_tiledMapComponent.tileLayers != null && _tiledMapComponent.MakeUniqueTiles != null && _tiledMapComponent.tileLayers.Length > _tiledMapComponent.MakeUniqueTiles.Length) { _changedMap = true; } if (_changedMap || _tiledMapComponent.mapProperties == null || _tiledMapComponent.objectLayerNodes == null || _tiledMapComponent.tileLayersProperties == null || _tiledMapComponent.objectLayersProperties == null || _tiledMapComponent.imageLayersProperties == null || _tiledMapComponent.objectLayers == null || _tiledMapComponent.generateCollider == null || _tiledMapComponent.collidersIs2D == null || _tiledMapComponent.collidersWidth == null || _tiledMapComponent.collidersZDepth == null || _tiledMapComponent.collidersIsInner == null || _tiledMapComponent.collidersIsTrigger == null || _tiledMapComponent.tileLayers == null || _tiledMapComponent.imageLayers == null || _tiledMapComponent.tileLayersFoldoutProperties == null || _tiledMapComponent.objectLayersFoldoutProperties == null || _tiledMapComponent.imageLayersFoldoutProperties == null || _tiledMapComponent.MakeUniqueTiles == null ) { NanoXMLDocument document = new NanoXMLDocument(_tiledMapComponent.MapTMX.text); NanoXMLNode mapNode = document.RootNode; List <Property> mapProperties = new List <Property>(); List <NanoXMLNode> objectLayerNodes = new List <NanoXMLNode>(); List <string> objectLayers = new List <string>(); List <bool> generateCollider = new List <bool>(); List <bool> collidersIs2D = new List <bool>(); List <float> collidersWidth = new List <float>(); List <float> collidersZDepth = new List <float>(); List <bool> collidersIsInner = new List <bool>(); List <bool> collidersIsTrigger = new List <bool>(); List <string> tileLayers = new List <string>(); List <string> imageLayers = new List <string>(); List <bool> makeUniqueTiles = new List <bool>(); List <bool> tileLayersFoldoutProperties = new List <bool>(); List <bool> objectLayersFoldoutProperties = new List <bool>(); List <bool> imageLayersFoldoutProperties = new List <bool>(); Dictionary <int, List <Property> > tileLayersProperties = new Dictionary <int, List <Property> >(); Dictionary <int, List <Property> > objectLayersProperties = new Dictionary <int, List <Property> >(); Dictionary <int, List <Property> > imageLayersProperties = new Dictionary <int, List <Property> >(); foreach (NanoXMLNode layerNode in mapNode.SubNodes) { if (layerNode.Name.Equals("properties")) { foreach (var property in layerNode.SubNodes) { mapProperties.Add( new Property( property.GetAttribute("name").Value, property.GetAttribute("value").Value ) ); } } if (layerNode.Name.Equals("objectgroup")) { objectLayerNodes.Add(layerNode); objectLayers.Add(layerNode.GetAttribute("name").Value); generateCollider.Add(false); collidersIs2D.Add(true); collidersWidth.Add(1); collidersZDepth.Add(0); collidersIsInner.Add(false); collidersIsTrigger.Add(false); // properties objectLayersFoldoutProperties.Add(false); objectLayersProperties.Add(objectLayerNodes.Count - 1, new List <Property>()); foreach (var subNodes in layerNode.SubNodes) { if (subNodes.Name.Equals("properties")) { foreach (var property in subNodes.SubNodes) { objectLayersProperties[objectLayerNodes.Count - 1].Add( new Property( property.GetAttribute("name").Value, property.GetAttribute("value").Value ) ); } } } } if (layerNode.Name.Equals("layer")) { tileLayers.Add(layerNode.GetAttribute("name").Value); // Make Unique Tiles makeUniqueTiles.Add(false); // properties tileLayersFoldoutProperties.Add(false); tileLayersProperties.Add(tileLayers.Count - 1, new List <Property>()); foreach (var subNodes in layerNode.SubNodes) { if (subNodes.Name.Equals("properties")) { foreach (var property in subNodes.SubNodes) { tileLayersProperties[tileLayers.Count - 1].Add( new Property( property.GetAttribute("name").Value, property.GetAttribute("value").Value ) ); } } } } if (layerNode.Name.Equals("imagelayer")) { imageLayers.Add(layerNode.GetAttribute("name").Value); // properties imageLayersFoldoutProperties.Add(false); imageLayersProperties.Add(imageLayers.Count - 1, new List <Property>()); foreach (var subNodes in layerNode.SubNodes) { if (subNodes.Name.Equals("properties")) { foreach (var property in subNodes.SubNodes) { imageLayersProperties[imageLayers.Count - 1].Add( new Property( property.GetAttribute("name").Value, property.GetAttribute("value").Value ) ); } } } } } if (_changedMap || _tiledMapComponent.mapProperties == null) { _tiledMapComponent.mapProperties = mapProperties.ToArray(); } if (_changedMap || _tiledMapComponent.objectLayerNodes == null) { _tiledMapComponent.objectLayerNodes = objectLayerNodes.ToArray(); } if (_changedMap || _tiledMapComponent.tileLayersProperties == null) { _tiledMapComponent.tileLayersProperties = new Dictionary <int, List <Property> >(tileLayersProperties); } if (_changedMap || _tiledMapComponent.objectLayersProperties == null) { _tiledMapComponent.objectLayersProperties = objectLayersProperties; } if (_changedMap || _tiledMapComponent.imageLayersProperties == null) { _tiledMapComponent.imageLayersProperties = imageLayersProperties; } if (_changedMap || _tiledMapComponent.objectLayers == null) { _tiledMapComponent.objectLayers = objectLayers.ToArray(); } if (_changedMap || _tiledMapComponent.generateCollider == null) { _tiledMapComponent.generateCollider = generateCollider.ToArray(); } if (_changedMap || _tiledMapComponent.collidersIs2D == null) { _tiledMapComponent.collidersIs2D = collidersIs2D.ToArray(); } if (_changedMap || _tiledMapComponent.collidersWidth == null) { _tiledMapComponent.collidersWidth = collidersWidth.ToArray(); } if (_changedMap || _tiledMapComponent.collidersZDepth == null) { _tiledMapComponent.collidersZDepth = collidersZDepth.ToArray(); } if (_changedMap || _tiledMapComponent.collidersIsInner == null) { _tiledMapComponent.collidersIsInner = collidersIsInner.ToArray(); } if (_changedMap || _tiledMapComponent.collidersIsTrigger == null) { _tiledMapComponent.collidersIsTrigger = collidersIsTrigger.ToArray(); } if (_changedMap || _tiledMapComponent.tileLayers == null) { _tiledMapComponent.tileLayers = tileLayers.ToArray(); } if (_changedMap || _tiledMapComponent.imageLayers == null) { _tiledMapComponent.imageLayers = imageLayers.ToArray(); } if (_changedMap || _tiledMapComponent.tileLayersFoldoutProperties == null) { _tiledMapComponent.tileLayersFoldoutProperties = tileLayersFoldoutProperties.ToArray(); } if (_changedMap || _tiledMapComponent.objectLayersFoldoutProperties == null) { _tiledMapComponent.objectLayersFoldoutProperties = objectLayersFoldoutProperties.ToArray(); } if (_changedMap || _tiledMapComponent.imageLayersFoldoutProperties == null) { _tiledMapComponent.imageLayersFoldoutProperties = imageLayersFoldoutProperties.ToArray(); } if (_changedMap || _tiledMapComponent.MakeUniqueTiles == null) { _tiledMapComponent.MakeUniqueTiles = makeUniqueTiles.ToArray(); } if (_changedMap) { _changedMap = false; } } }