From 04e3710a65efdcae324d6f157a0afe4650f57864 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 14 Nov 2017 22:45:22 +0200 Subject: [PATCH] Renaming fields for consistency --- .../Source/Items/ItemPrefab.cs | 6 +-- .../Source/Map/MapEntityPrefab.cs | 4 +- .../Source/Map/StructurePrefab.cs | 4 +- .../Source/Networking/GameServerSettings.cs | 4 +- .../Source/Screens/CampaignUI.cs | 4 +- .../Source/Screens/EditMapScreen.cs | 4 +- .../GameModes/MultiplayerCampaign.cs | 8 ++-- .../Items/Components/Holdable/RepairTool.cs | 2 +- .../Source/Items/ItemPrefab.cs | 26 +++++----- .../Source/Map/LinkedSubmarine.cs | 2 +- .../Source/Map/MapEntityPrefab.cs | 48 ++++++++----------- .../BarotraumaShared/Source/Map/Structure.cs | 36 +++++--------- .../Source/Map/StructurePrefab.cs | 16 +++---- .../Source/Networking/GameServer.cs | 2 +- .../Source/Serialization/XMLExtensions.cs | 25 ++++------ 15 files changed, 83 insertions(+), 108 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaClient/Source/Items/ItemPrefab.cs index ec30e9a61..7236db0a5 100644 --- a/Barotrauma/BarotraumaClient/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaClient/Source/Items/ItemPrefab.cs @@ -16,7 +16,7 @@ namespace Barotrauma return; } - if (!resizeHorizontal && !resizeVertical) + if (!ResizeHorizontal && !ResizeVertical) { sprite.Draw(spriteBatch, new Vector2(position.X + sprite.size.X / 2.0f, -position.Y + sprite.size.Y / 2.0f), SpriteColor); } @@ -30,9 +30,9 @@ namespace Barotrauma } else { - if (resizeHorizontal) + if (ResizeHorizontal) placeSize.X = Math.Max(position.X - placePosition.X, size.X); - if (resizeVertical) + if (ResizeVertical) placeSize.Y = Math.Max(placePosition.Y - position.Y, size.Y); position = placePosition; diff --git a/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs b/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs index d4a7fb1d3..c268e070b 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/MapEntityPrefab.cs @@ -22,8 +22,8 @@ namespace Barotrauma { Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub); - if (resizeHorizontal) placeSize.X = position.X - placePosition.X; - if (resizeVertical) placeSize.Y = placePosition.Y - position.Y; + if (ResizeHorizontal) placeSize.X = position.X - placePosition.X; + if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y; Rectangle newRect = Submarine.AbsRect(placePosition, placeSize); newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X); diff --git a/Barotrauma/BarotraumaClient/Source/Map/StructurePrefab.cs b/Barotrauma/BarotraumaClient/Source/Map/StructurePrefab.cs index 3092d38b5..5a401d4b9 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/StructurePrefab.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/StructurePrefab.cs @@ -26,8 +26,8 @@ namespace Barotrauma else { Vector2 placeSize = size; - if (resizeHorizontal) placeSize.X = position.X - placePosition.X; - if (resizeVertical) placeSize.Y = placePosition.Y - position.Y; + if (ResizeHorizontal) placeSize.X = position.X - placePosition.X; + if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y; newRect = Submarine.AbsRect(placePosition, placeSize); } diff --git a/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs b/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs index b0d984975..c3b2afca4 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/GameServerSettings.cs @@ -245,9 +245,9 @@ namespace Barotrauma.Networking }; - foreach (MapEntityPrefab pf in MapEntityPrefab.list) + foreach (MapEntityPrefab pf in MapEntityPrefab.List) { - if (!(pf is ItemPrefab) || (pf.Price <= 0.0f && !pf.tags.Contains("smallitem"))) continue; + if (!(pf is ItemPrefab) || (pf.Price <= 0.0f && !pf.Tags.Contains("smallitem"))) continue; GUITextBlock textBlock = new GUITextBlock( new Rectangle(0, 0, 260, 25), diff --git a/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs b/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs index efea67feb..3f07ea7cf 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/CampaignUI.cs @@ -94,7 +94,7 @@ namespace Barotrauma List itemCategories = Enum.GetValues(typeof(MapEntityCategory)).Cast().ToList(); //don't show categories with no buyable items - itemCategories.RemoveAll(c => !MapEntityPrefab.list.Any(ep => ep.Price > 0.0f && ep.Category.HasFlag(c))); + itemCategories.RemoveAll(c => !MapEntityPrefab.List.Any(ep => ep.Price > 0.0f && ep.Category.HasFlag(c))); int buttonWidth = Math.Min(sellColumnWidth / itemCategories.Count, 100); foreach (MapEntityCategory category in itemCategories) @@ -311,7 +311,7 @@ namespace Barotrauma storeItemList.ClearChildren(); MapEntityCategory category = (MapEntityCategory)selection; - var items = MapEntityPrefab.list.FindAll(ep => ep.Price > 0.0f && ep.Category.HasFlag(category)); + var items = MapEntityPrefab.List.FindAll(ep => ep.Price > 0.0f && ep.Category.HasFlag(category)); int width = storeItemList.Rect.Width; diff --git a/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs index e30e85880..2ad615a5e 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/EditMapScreen.cs @@ -210,7 +210,7 @@ namespace Barotrauma itemList.OnSelected = SelectPrefab; itemList.CheckSelected = MapEntityPrefab.GetSelected; - foreach (MapEntityPrefab ep in MapEntityPrefab.list) + foreach (MapEntityPrefab ep in MapEntityPrefab.List) { if (!ep.Category.HasFlag(category)) continue; @@ -756,7 +756,7 @@ namespace Barotrauma GUIListBox listBox = new GUIListBox(Rectangle.Empty, "", frame); listBox.OnSelected = SelectWire; - foreach (MapEntityPrefab ep in MapEntityPrefab.list) + foreach (MapEntityPrefab ep in MapEntityPrefab.List) { var itemPrefab = ep as ItemPrefab; if (itemPrefab == null || itemPrefab.Name == null) continue; diff --git a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs index d2f60a1cc..1f60618a8 100644 --- a/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs +++ b/Barotrauma/BarotraumaShared/Source/GameSession/GameModes/MultiplayerCampaign.cs @@ -307,7 +307,7 @@ namespace Barotrauma msg.Write((UInt16)CargoManager.PurchasedItems.Count); foreach (ItemPrefab ip in CargoManager.PurchasedItems) { - msg.Write((UInt16)MapEntityPrefab.list.IndexOf(ip)); + msg.Write((UInt16)MapEntityPrefab.List.IndexOf(ip)); } } @@ -329,7 +329,7 @@ namespace Barotrauma for (int i = 0; i 0 && nextSectionLength < Structure.wallSectionSize * 0.3f)) + (nextSectionLength > 0 && nextSectionLength < Structure.WallSectionSize * 0.3f)) { //targetStructure.HighLightSection(sectionIndex + i); targetStructure.AddDamage(sectionIndex + i, -StructureFixAmount * degreeOfSuccess); diff --git a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs index 28c2ac22c..3bf25f058 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/ItemPrefab.cs @@ -146,7 +146,7 @@ namespace Barotrauma return; } - if (!resizeHorizontal && !resizeVertical) + if (!ResizeHorizontal && !ResizeVertical) { if (PlayerInput.LeftButtonClicked()) { @@ -172,9 +172,9 @@ namespace Barotrauma } else { - if (resizeHorizontal) + if (ResizeHorizontal) placeSize.X = Math.Max(position.X - placePosition.X, size.X); - if (resizeVertical) + if (ResizeVertical) placeSize.Y = Math.Max(placePosition.Y - position.Y, size.Y); if (PlayerInput.LeftButtonReleased()) @@ -237,9 +237,9 @@ namespace Barotrauma ConfigElement = element; name = element.GetAttributeString("name", ""); - if (name == "") DebugConsole.ThrowError("Unnamed item in "+filePath+"!"); + if (name == "") DebugConsole.ThrowError("Unnamed item in " + filePath + "!"); - DebugConsole.Log(" "+name); + DebugConsole.Log(" " + name); Description = element.GetAttributeString("description", ""); @@ -249,8 +249,8 @@ namespace Barotrauma isLinkable = element.GetAttributeBool("linkable", false); - resizeHorizontal = element.GetAttributeBool("resizehorizontal", false); - resizeVertical = element.GetAttributeBool("resizevertical", false); + ResizeHorizontal = element.GetAttributeBool("resizehorizontal", false); + ResizeVertical = element.GetAttributeBool("resizevertical", false); focusOnSelected = element.GetAttributeBool("focusonselected", false); @@ -277,10 +277,8 @@ namespace Barotrauma } Category = category; - - - string spriteColorStr = element.GetAttributeString("spritecolor", "1.0,1.0,1.0,1.0"); - SpriteColor = new Color(XMLExtensions.ParseVector4(spriteColorStr)); + + SpriteColor = element.GetAttributeColor("spritecolor", Color.White); price = element.GetAttributeInt("price", 0); @@ -289,8 +287,8 @@ namespace Barotrauma DeconstructItems = new List(); DeconstructTime = 1.0f; - tags = new List(); - tags.AddRange(element.GetAttributeString("tags", "").Split(',')); + Tags = new List(); + Tags.AddRange(element.GetAttributeString("tags", "").Split(',')); foreach (XElement subElement in element.Elements()) { @@ -337,7 +335,7 @@ namespace Barotrauma } } - list.Add(this); + List.Add(this); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Map/LinkedSubmarine.cs b/Barotrauma/BarotraumaShared/Source/Map/LinkedSubmarine.cs index 847cdf499..0fd2d4848 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/LinkedSubmarine.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/LinkedSubmarine.cs @@ -105,7 +105,7 @@ namespace Barotrauma List points = new List(); var wallPrefabs = - MapEntityPrefab.list.FindAll(mp => (mp is StructurePrefab) && ((StructurePrefab)mp).HasBody); + MapEntityPrefab.List.FindAll(mp => (mp is StructurePrefab) && ((StructurePrefab)mp).HasBody); foreach (XElement element in rootElement.Elements()) { diff --git a/Barotrauma/BarotraumaShared/Source/Map/MapEntityPrefab.cs b/Barotrauma/BarotraumaShared/Source/Map/MapEntityPrefab.cs index 1180e6f32..c3a5ac9b8 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/MapEntityPrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/MapEntityPrefab.cs @@ -14,11 +14,15 @@ namespace Barotrauma partial class MapEntityPrefab { - public static List list = new List(); + public readonly static List List = new List(); protected string name; - public List tags; + public List Tags + { + get; + protected set; + } protected bool isLinkable; @@ -30,8 +34,8 @@ namespace Barotrauma protected ConstructorInfo constructor; //is it possible to stretch the entity horizontally/vertically - public bool resizeHorizontal { get; protected set; } - public bool resizeVertical { get; protected set; } + public bool ResizeHorizontal { get; protected set; } + public bool ResizeVertical { get; protected set; } //which prefab has been selected for placing protected static MapEntityPrefab selected; @@ -60,17 +64,7 @@ namespace Barotrauma { get { return isLinkable; } } - - public bool ResizeHorizontal - { - get { return resizeHorizontal; } - } - - public bool ResizeVertical - { - get { return resizeVertical; } - } - + public MapEntityCategory Category { get; @@ -102,27 +96,27 @@ namespace Barotrauma ep.name = "Hull"; ep.Description = "Hulls determine which parts are considered to be \"inside the sub\". Generally every room should be enclosed by a hull."; ep.constructor = typeof(Hull).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }); - ep.resizeHorizontal = true; - ep.resizeVertical = true; - list.Add(ep); + ep.ResizeHorizontal = true; + ep.ResizeVertical = true; + List.Add(ep); ep = new MapEntityPrefab(); ep.name = "Gap"; ep.Description = "Gaps allow water and air to flow between two hulls. "; ep.constructor = typeof(Gap).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }); - ep.resizeHorizontal = true; - ep.resizeVertical = true; - list.Add(ep); + ep.ResizeHorizontal = true; + ep.ResizeVertical = true; + List.Add(ep); ep = new MapEntityPrefab(); ep.name = "Waypoint"; ep.constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }); - list.Add(ep); + List.Add(ep); ep = new MapEntityPrefab(); ep.name = "Spawnpoint"; ep.constructor = typeof(WayPoint).GetConstructor(new Type[] { typeof(MapEntityPrefab), typeof(Rectangle) }); - list.Add(ep); + List.Add(ep); } public MapEntityPrefab() @@ -144,8 +138,8 @@ namespace Barotrauma { Vector2 position = Submarine.MouseToWorldGrid(cam, Submarine.MainSub); - if (resizeHorizontal) placeSize.X = position.X - placePosition.X; - if (resizeVertical) placeSize.Y = placePosition.Y - position.Y; + if (ResizeHorizontal) placeSize.X = position.X - placePosition.X; + if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y; Rectangle newRect = Submarine.AbsRect(placePosition, placeSize); newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X); @@ -196,7 +190,7 @@ namespace Barotrauma { if (caseSensitive) { - foreach (MapEntityPrefab prefab in list) + foreach (MapEntityPrefab prefab in List) { if (prefab.name == name || (prefab.Aliases != null && prefab.Aliases.Contains(name))) return prefab; } @@ -204,7 +198,7 @@ namespace Barotrauma else { name = name.ToLowerInvariant(); - foreach (MapEntityPrefab prefab in list) + foreach (MapEntityPrefab prefab in List) { if (prefab.name.ToLowerInvariant() == name || (prefab.Aliases != null && prefab.Aliases.Any(a => a.ToLowerInvariant() == name))) return prefab; } diff --git a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs index 7b2f2e258..c5bcc9223 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/Structure.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/Structure.cs @@ -42,7 +42,7 @@ namespace Barotrauma partial class Structure : MapEntity, IDamageable, IServerSerializable, ISerializableEntity { - public static int wallSectionSize = 96; + public const int WallSectionSize = 96; public static List WallList = new List(); private StructurePrefab prefab; @@ -54,24 +54,14 @@ namespace Barotrauma private SpriteEffects SpriteEffects = SpriteEffects.None; + private bool flippedX; + //sections of the wall that are supposed to be rendered public WallSection[] sections { get; private set; - } - - public bool resizeHorizontal - { - get { return prefab.resizeHorizontal; } - } - - public bool resizeVertical - { - get { return prefab.resizeVertical; } - } - - private bool flippedX; + } public override Sprite Sprite { @@ -145,7 +135,7 @@ namespace Barotrauma public List Tags { - get { return prefab.tags; } + get { return prefab.Tags; } } protected Color spriteColor; @@ -334,15 +324,15 @@ namespace Barotrauma { if (isHorizontal) { - xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize); + xsections = (int)Math.Ceiling((float)rect.Width / WallSectionSize); sections = new WallSection[xsections]; - width = (int)wallSectionSize; + width = (int)WallSectionSize; } else { - ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize); + ysections = (int)Math.Ceiling((float)rect.Height / WallSectionSize); sections = new WallSection[ysections]; - height = (int)wallSectionSize; + height = (int)WallSectionSize; } } @@ -599,14 +589,14 @@ namespace Barotrauma //if the sub has been flipped horizontally, the first section may be smaller than wallSectionSize //and we need to adjust the position accordingly - if (sections[0].rect.Width < wallSectionSize) + if (sections[0].rect.Width < WallSectionSize) { - displayPos.X += wallSectionSize - sections[0].rect.Width; + displayPos.X += WallSectionSize - sections[0].rect.Width; } int index = (isHorizontal) ? - (int)Math.Floor((displayPos.X - rect.X) / wallSectionSize) : - (int)Math.Floor((rect.Y - displayPos.Y) / wallSectionSize); + (int)Math.Floor((displayPos.X - rect.X) / WallSectionSize) : + (int)Math.Floor((rect.Y - displayPos.Y) / WallSectionSize); if (index < 0 || index > sections.Length - 1) return -1; return index; diff --git a/Barotrauma/BarotraumaShared/Source/Map/StructurePrefab.cs b/Barotrauma/BarotraumaShared/Source/Map/StructurePrefab.cs index c04ddec6d..6b4678409 100644 --- a/Barotrauma/BarotraumaShared/Source/Map/StructurePrefab.cs +++ b/Barotrauma/BarotraumaShared/Source/Map/StructurePrefab.cs @@ -74,7 +74,7 @@ namespace Barotrauma { StructurePrefab sp = Load(el); - list.Add(sp); + List.Add(sp); } } } @@ -84,8 +84,8 @@ namespace Barotrauma StructurePrefab sp = new StructurePrefab(); sp.name = element.Name.ToString(); - sp.tags = new List(); - sp.tags.AddRange(element.GetAttributeString("tags", "").Split(',')); + sp.Tags = new List(); + sp.Tags.AddRange(element.GetAttributeString("tags", "").Split(',')); foreach (XElement subElement in element.Elements()) { @@ -140,8 +140,8 @@ namespace Barotrauma sp.maxHealth = element.GetAttributeFloat("health", 100.0f); - sp.resizeHorizontal = element.GetAttributeBool("resizehorizontal", false); - sp.resizeVertical = element.GetAttributeBool("resizevertical", false); + sp.ResizeHorizontal = element.GetAttributeBool("resizehorizontal", false); + sp.ResizeVertical = element.GetAttributeBool("resizevertical", false); sp.isPlatform = element.GetAttributeBool("platform", false); sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), element.GetAttributeString("stairdirection", "None"), true); @@ -169,15 +169,15 @@ namespace Barotrauma else { Vector2 placeSize = size; - if (resizeHorizontal) placeSize.X = position.X - placePosition.X; - if (resizeVertical) placeSize.Y = placePosition.Y - position.Y; + if (ResizeHorizontal) placeSize.X = position.X - placePosition.X; + if (ResizeVertical) placeSize.Y = placePosition.Y - position.Y; newRect = Submarine.AbsRect(placePosition, placeSize); if (PlayerInput.LeftButtonReleased()) { //don't allow resizing width/height to zero - if ((!resizeHorizontal || placeSize.X != 0.0f) && (!resizeVertical || placeSize.Y != 0.0f)) + if ((!ResizeHorizontal || placeSize.X != 0.0f) && (!ResizeVertical || placeSize.Y != 0.0f)) { newRect.Location -= MathUtils.ToPoint(Submarine.MainSub.Position); diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index f99cd6705..0cf3eb2fd 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1295,7 +1295,7 @@ namespace Barotrauma.Networking foreach (string s in extraCargo.Keys) { - ItemPrefab itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name == s) as ItemPrefab; + ItemPrefab itemPrefab = MapEntityPrefab.Find(s) as ItemPrefab; if (itemPrefab == null) continue; for (int i = 0; i < extraCargo[s]; i++) diff --git a/Barotrauma/BarotraumaShared/Source/Serialization/XMLExtensions.cs b/Barotrauma/BarotraumaShared/Source/Serialization/XMLExtensions.cs index 169835f90..89e936b27 100644 --- a/Barotrauma/BarotraumaShared/Source/Serialization/XMLExtensions.cs +++ b/Barotrauma/BarotraumaShared/Source/Serialization/XMLExtensions.cs @@ -164,7 +164,6 @@ namespace Barotrauma public static bool GetAttributeBool(this XElement element, string name, bool defaultValue) { if (element?.Attribute(name) == null) return defaultValue; - return element.Attribute(name).GetAttributeBool(defaultValue); } @@ -189,37 +188,31 @@ namespace Barotrauma public static Vector2 GetAttributeVector2(this XElement element, string name, Vector2 defaultValue) { if (element?.Attribute(name) == null) return defaultValue; - - string val = element.Attribute(name).Value; - - return ParseVector2(val); + return ParseVector2(element.Attribute(name).Value); } public static Vector3 GetAttributeVector3(this XElement element, string name, Vector3 defaultValue) { if (element == null || element.Attribute(name) == null) return defaultValue; - - string val = element.Attribute(name).Value; - - return ParseVector3(val); + return ParseVector3(element.Attribute(name).Value); } public static Vector4 GetAttributeVector4(this XElement element, string name, Vector4 defaultValue) { if (element == null || element.Attribute(name) == null) return defaultValue; + return ParseVector4(element.Attribute(name).Value); + } - string val = element.Attribute(name).Value; - - return ParseVector4(val); + public static Color GetAttributeColor(this XElement element, string name, Color defaultValue) + { + if (element == null || element.Attribute(name) == null) return defaultValue; + return ParseColor(element.Attribute(name).Value); } public static Rectangle GetAttributeRect(this XElement element, string name, Rectangle defaultValue) { if (element == null || element.Attribute(name) == null) return defaultValue; - - string val = element.Attribute(name).Value; - - return ParseRect(val, false); + return ParseRect(element.Attribute(name).Value, false); } public static string ElementInnerText(this XElement el)