Converted the GetAttribute methods in the ToolBox class to extension methods
This commit is contained in:
@@ -12,7 +12,7 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific(XElement element)
|
||||
{
|
||||
string soundPath = ToolBox.GetAttributeString(element, "sound", "");
|
||||
string soundPath = element.GetAttributeString("sound", "");
|
||||
if (!string.IsNullOrWhiteSpace(soundPath))
|
||||
{
|
||||
sound = Sound.Load(soundPath);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific(XDocument doc)
|
||||
{
|
||||
soundInterval = ToolBox.GetAttributeFloat(doc.Root, "soundinterval", 10.0f);
|
||||
soundInterval = doc.Root.GetAttributeFloat("soundinterval", 10.0f);
|
||||
|
||||
keys = new Key[Enum.GetNames(typeof(InputType)).Length];
|
||||
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace Barotrauma
|
||||
public CharacterSound(XElement element)
|
||||
{
|
||||
Sound = Sound.Load(element.Attribute("file").Value);
|
||||
Range = ToolBox.GetAttributeFloat(element, "range", 1000.0f);
|
||||
Range = element.GetAttributeFloat("range", 1000.0f);
|
||||
|
||||
Enum.TryParse<SoundType>(ToolBox.GetAttributeString(element, "state", "Idle"), true, out Type);
|
||||
Enum.TryParse<SoundType>(element.GetAttributeString("state", "Idle"), true, out Type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Barotrauma
|
||||
LightSource = new LightSource(subElement);
|
||||
break;
|
||||
case "sound":
|
||||
hitSound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""));
|
||||
hitSound = Sound.Load(subElement.GetAttributeString("file", ""));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,21 +72,21 @@ namespace Barotrauma
|
||||
|
||||
ChildStyles = new Dictionary<string, GUIComponentStyle>();
|
||||
|
||||
Padding = ToolBox.GetAttributeVector4(element, "padding", Vector4.Zero);
|
||||
Padding = element.GetAttributeVector4("padding", Vector4.Zero);
|
||||
|
||||
Vector4 colorVector = ToolBox.GetAttributeVector4(element, "color", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
Vector4 colorVector = element.GetAttributeVector4("color", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
Color = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "textcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
colorVector = element.GetAttributeVector4("textcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
textColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "hovercolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
colorVector = element.GetAttributeVector4("hovercolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
HoverColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "selectedcolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
colorVector = element.GetAttributeVector4("selectedcolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
SelectedColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
colorVector = ToolBox.GetAttributeVector4(element, "outlinecolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
colorVector = element.GetAttributeVector4("outlinecolor", new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
|
||||
OutlineColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
@@ -95,16 +95,16 @@ namespace Barotrauma
|
||||
{
|
||||
case "sprite":
|
||||
Sprite sprite = new Sprite(subElement);
|
||||
bool maintainAspect = ToolBox.GetAttributeBool(subElement, "maintainaspectratio",false);
|
||||
bool tile = ToolBox.GetAttributeBool(subElement, "tile", true);
|
||||
bool maintainAspect = subElement.GetAttributeBool("maintainaspectratio",false);
|
||||
bool tile = subElement.GetAttributeBool("tile", true);
|
||||
|
||||
string stateStr = ToolBox.GetAttributeString(subElement, "state", "None");
|
||||
string stateStr = subElement.GetAttributeString("state", "None");
|
||||
GUIComponent.ComponentState spriteState = GUIComponent.ComponentState.None;
|
||||
Enum.TryParse(stateStr, out spriteState);
|
||||
|
||||
UISprite newSprite = new UISprite(sprite, tile, maintainAspect);
|
||||
|
||||
Vector4 sliceVec = ToolBox.GetAttributeVector4(subElement, "slice", Vector4.Zero);
|
||||
Vector4 sliceVec = subElement.GetAttributeVector4("slice", Vector4.Zero);
|
||||
if (sliceVec != Vector4.Zero)
|
||||
{
|
||||
Rectangle slice = new Rectangle((int)sliceVec.X, (int)sliceVec.Y, (int)(sliceVec.Z - sliceVec.X), (int)(sliceVec.W - sliceVec.Y));
|
||||
|
||||
@@ -332,14 +332,14 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
campaign.Money = ToolBox.GetAttributeInt(element, "money", 0);
|
||||
campaign.Money = element.GetAttributeInt("money", 0);
|
||||
|
||||
//backwards compatibility with older save files
|
||||
if (campaign.map == null)
|
||||
{
|
||||
string mapSeed = ToolBox.GetAttributeString(element, "mapseed", "a");
|
||||
string mapSeed = element.GetAttributeString("mapseed", "a");
|
||||
campaign.GenerateMap(mapSeed);
|
||||
campaign.map.SetLocation(ToolBox.GetAttributeInt(element, "currentlocation", 0));
|
||||
campaign.map.SetLocation(element.GetAttributeInt("currentlocation", 0));
|
||||
}
|
||||
|
||||
campaign.savedOnStart = true;
|
||||
|
||||
@@ -129,9 +129,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = ToolBox.GetAttributeInt(graphicsMode, "width", 0);
|
||||
GraphicsHeight = ToolBox.GetAttributeInt(graphicsMode, "height", 0);
|
||||
VSyncEnabled = ToolBox.GetAttributeBool(graphicsMode, "vsync", true);
|
||||
GraphicsWidth = graphicsMode.GetAttributeInt("width", 0);
|
||||
GraphicsHeight = graphicsMode.GetAttributeInt("height", 0);
|
||||
VSyncEnabled = graphicsMode.GetAttributeBool("vsync", true);
|
||||
|
||||
if (GraphicsWidth == 0 || GraphicsHeight == 0)
|
||||
{
|
||||
@@ -141,16 +141,16 @@ namespace Barotrauma
|
||||
|
||||
//FullScreenEnabled = ToolBox.GetAttributeBool(graphicsMode, "fullscreen", true);
|
||||
|
||||
var windowModeStr = ToolBox.GetAttributeString(graphicsMode, "displaymode", "Fullscreen");
|
||||
var windowModeStr = graphicsMode.GetAttributeString("displaymode", "Fullscreen");
|
||||
if (!Enum.TryParse<WindowMode>(windowModeStr, out windowMode))
|
||||
{
|
||||
windowMode = WindowMode.Fullscreen;
|
||||
}
|
||||
|
||||
SoundVolume = ToolBox.GetAttributeFloat(doc.Root, "soundvolume", 1.0f);
|
||||
MusicVolume = ToolBox.GetAttributeFloat(doc.Root, "musicvolume", 0.3f);
|
||||
SoundVolume = doc.Root.GetAttributeFloat("soundvolume", 1.0f);
|
||||
MusicVolume = doc.Root.GetAttributeFloat("musicvolume", 0.3f);
|
||||
|
||||
EnableSplashScreen = ToolBox.GetAttributeBool(doc.Root, "enablesplashscreen", true);
|
||||
EnableSplashScreen = doc.Root.GetAttributeBool("enablesplashscreen", true);
|
||||
|
||||
keyMapping = new KeyOrMouse[Enum.GetNames(typeof(InputType)).Length];
|
||||
keyMapping[(int)InputType.Up] = new KeyOrMouse(Keys.W);
|
||||
@@ -198,7 +198,7 @@ namespace Barotrauma
|
||||
JobNamePreferences = new List<string>();
|
||||
foreach (XElement ele in subElement.Element("jobpreferences").Elements("job"))
|
||||
{
|
||||
JobNamePreferences.Add(ToolBox.GetAttributeString(ele, "name", ""));
|
||||
JobNamePreferences.Add(ele.GetAttributeString("name", ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -145,26 +145,26 @@ namespace Barotrauma.Items.Components
|
||||
switch (subElement.Name.ToString().ToLowerInvariant())
|
||||
{
|
||||
case "guiframe":
|
||||
string rectStr = ToolBox.GetAttributeString(subElement, "rect", "0.0,0.0,0.5,0.5");
|
||||
string rectStr = subElement.GetAttributeString("rect", "0.0,0.0,0.5,0.5");
|
||||
|
||||
string[] components = rectStr.Split(',');
|
||||
if (components.Length < 4) break;
|
||||
|
||||
Vector4 rect = ToolBox.GetAttributeVector4(subElement, "rect", Vector4.One);
|
||||
Vector4 rect = subElement.GetAttributeVector4("rect", Vector4.One);
|
||||
if (components[0].Contains(".")) rect.X *= GameMain.GraphicsWidth;
|
||||
if (components[1].Contains(".")) rect.Y *= GameMain.GraphicsHeight;
|
||||
if (components[2].Contains(".")) rect.Z *= GameMain.GraphicsWidth;
|
||||
if (components[3].Contains(".")) rect.W *= GameMain.GraphicsHeight;
|
||||
|
||||
string style = ToolBox.GetAttributeString(subElement, "style", "");
|
||||
string style = subElement.GetAttributeString("style", "");
|
||||
|
||||
Vector4 color = ToolBox.GetAttributeVector4(subElement, "color", Vector4.One);
|
||||
Vector4 color = subElement.GetAttributeVector4("color", Vector4.One);
|
||||
|
||||
Alignment alignment = Alignment.Center;
|
||||
try
|
||||
{
|
||||
alignment = (Alignment)Enum.Parse(typeof(Alignment),
|
||||
ToolBox.GetAttributeString(subElement, "alignment", "Center"), true);
|
||||
subElement.GetAttributeString("alignment", "Center"), true);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -178,9 +178,9 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
break;
|
||||
case "sound":
|
||||
string filePath = ToolBox.GetAttributeString(subElement, "file", "");
|
||||
string filePath = subElement.GetAttributeString("file", "");
|
||||
|
||||
if (filePath == "") filePath = ToolBox.GetAttributeString(subElement, "sound", "");
|
||||
if (filePath == "") filePath = subElement.GetAttributeString("sound", "");
|
||||
|
||||
if (filePath == "")
|
||||
{
|
||||
@@ -197,7 +197,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
try
|
||||
{
|
||||
type = (ActionType)Enum.Parse(typeof(ActionType), ToolBox.GetAttributeString(subElement, "type", ""), true);
|
||||
type = (ActionType)Enum.Parse(typeof(ActionType), subElement.GetAttributeString("type", ""), true);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -207,11 +207,11 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
Sound sound = Sound.Load(filePath);
|
||||
|
||||
float range = ToolBox.GetAttributeFloat(subElement, "range", 800.0f);
|
||||
bool loop = ToolBox.GetAttributeBool(subElement, "loop", false);
|
||||
float range = subElement.GetAttributeFloat("range", 800.0f);
|
||||
bool loop = subElement.GetAttributeBool("loop", false);
|
||||
ItemSound itemSound = new ItemSound(sound, type, range, loop);
|
||||
itemSound.VolumeProperty = ToolBox.GetAttributeString(subElement, "volume", "");
|
||||
itemSound.VolumeMultiplier = ToolBox.GetAttributeFloat(subElement, "volumemultiplier", 1.0f);
|
||||
itemSound.VolumeProperty = subElement.GetAttributeString("volume", "");
|
||||
itemSound.VolumeMultiplier = subElement.GetAttributeFloat("volumemultiplier", 1.0f);
|
||||
|
||||
List<ItemSound> soundList = null;
|
||||
if (!sounds.TryGetValue(itemSound.Type, out soundList))
|
||||
|
||||
@@ -30,10 +30,10 @@ namespace Barotrauma.Items.Components
|
||||
[Editable, HasDefaultValue("0.0,0.0,0.0,1.0", true)]
|
||||
public string TextColor
|
||||
{
|
||||
get { return ToolBox.Vector4ToString(textColor.ToVector4()); }
|
||||
get { return XMLExtensions.Vector4ToString(textColor.ToVector4()); }
|
||||
set
|
||||
{
|
||||
textColor = new Color(ToolBox.ParseToVector4(value));
|
||||
textColor = new Color(XMLExtensions.ParseToVector4(value));
|
||||
if (textBlock != null) textBlock.TextColor = textColor;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ namespace Barotrauma
|
||||
{
|
||||
try
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(configPath);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configPath);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
foreach (XElement element in doc.Root.Elements())
|
||||
|
||||
+7
-7
@@ -21,18 +21,18 @@ namespace Barotrauma
|
||||
|
||||
public BackgroundCreaturePrefab(XElement element)
|
||||
{
|
||||
Speed = ToolBox.GetAttributeFloat(element, "speed", 1.0f);
|
||||
Speed = element.GetAttributeFloat("speed", 1.0f);
|
||||
|
||||
WanderAmount = ToolBox.GetAttributeFloat(element, "wanderamount", 0.0f);
|
||||
WanderAmount = element.GetAttributeFloat("wanderamount", 0.0f);
|
||||
|
||||
WanderZAmount = ToolBox.GetAttributeFloat(element, "wanderzamount", 0.0f);
|
||||
WanderZAmount = element.GetAttributeFloat("wanderzamount", 0.0f);
|
||||
|
||||
SwarmMin = ToolBox.GetAttributeInt(element, "swarmmin", 1);
|
||||
SwarmMax = ToolBox.GetAttributeInt(element, "swarmmax", 1);
|
||||
SwarmMin = element.GetAttributeInt("swarmmin", 1);
|
||||
SwarmMax = element.GetAttributeInt("swarmmax", 1);
|
||||
|
||||
SwarmRadius = ToolBox.GetAttributeFloat(element, "swarmradius", 200.0f);
|
||||
SwarmRadius = element.GetAttributeFloat("swarmradius", 200.0f);
|
||||
|
||||
DisableRotation = ToolBox.GetAttributeBool(element, "disablerotation", false);
|
||||
DisableRotation = element.GetAttributeBool("disablerotation", false);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -121,10 +121,10 @@ namespace Barotrauma.Lights
|
||||
public LightSource (XElement element)
|
||||
: this(Vector2.Zero, 100.0f, Color.White, null)
|
||||
{
|
||||
range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
|
||||
color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
|
||||
range = element.GetAttributeFloat("range", 100.0f);
|
||||
color = new Color(element.GetAttributeVector4("color", Vector4.One));
|
||||
|
||||
CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true);
|
||||
CastShadows = element.GetAttributeBool("castshadows", true);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
|
||||
@@ -1124,7 +1124,7 @@ namespace Barotrauma.Networking
|
||||
if (GameMain.GameSession.Submarine == null)
|
||||
{
|
||||
var gameSessionDoc = SaveUtil.LoadGameSessionDoc(GameMain.GameSession.SavePath);
|
||||
string subPath = Path.Combine(SaveUtil.TempPath, ToolBox.GetAttributeString(gameSessionDoc.Root, "submarine", "")) + ".sub";
|
||||
string subPath = Path.Combine(SaveUtil.TempPath, gameSessionDoc.Root.GetAttributeString("submarine", "")) + ".sub";
|
||||
GameMain.GameSession.Submarine = new Submarine(subPath, "");
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Barotrauma.Particles
|
||||
|
||||
public DecalManager(string configFile)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
prefabs = new Dictionary<string, DecalPrefab>();
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
Color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
|
||||
Color = new Color(element.GetAttributeVector4("color", Vector4.One));
|
||||
|
||||
LifeTime = ToolBox.GetAttributeFloat(element, "lifetime", 10.0f);
|
||||
FadeOutTime = Math.Min(LifeTime, ToolBox.GetAttributeFloat(element, "fadeouttime", 1.0f));
|
||||
FadeInTime = Math.Min(LifeTime - FadeOutTime, ToolBox.GetAttributeFloat(element, "fadeintime", 0.0f));
|
||||
LifeTime = element.GetAttributeFloat("lifetime", 10.0f);
|
||||
FadeOutTime = Math.Min(LifeTime, element.GetAttributeFloat("fadeouttime", 1.0f));
|
||||
FadeInTime = Math.Min(LifeTime - FadeOutTime, element.GetAttributeFloat("fadeintime", 0.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,16 +95,16 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
ParticlePrefab = GameMain.ParticleManager.FindPrefab(ToolBox.GetAttributeString(element, "particle", ""));
|
||||
ParticlePrefab = GameMain.ParticleManager.FindPrefab(element.GetAttributeString("particle", ""));
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
AngleMin = ToolBox.GetAttributeFloat(element, "anglemin", 0.0f);
|
||||
AngleMax = ToolBox.GetAttributeFloat(element, "anglemax", 0.0f);
|
||||
AngleMin = element.GetAttributeFloat("anglemin", 0.0f);
|
||||
AngleMax = element.GetAttributeFloat("anglemax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
AngleMin = ToolBox.GetAttributeFloat(element, "angle", 0.0f);
|
||||
AngleMin = element.GetAttributeFloat("angle", 0.0f);
|
||||
AngleMax = AngleMin;
|
||||
}
|
||||
|
||||
@@ -118,23 +118,23 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
else
|
||||
{
|
||||
ScaleMin = ToolBox.GetAttributeFloat(element,"scalemin",1.0f);
|
||||
ScaleMax = Math.Max(ScaleMin, ToolBox.GetAttributeFloat(element, "scalemax", 1.0f));
|
||||
ScaleMin = element.GetAttributeFloat("scalemin",1.0f);
|
||||
ScaleMax = Math.Max(ScaleMin, element.GetAttributeFloat("scalemax", 1.0f));
|
||||
}
|
||||
|
||||
if (element.Attribute("velocity") == null)
|
||||
{
|
||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocitymin", 0.0f);
|
||||
VelocityMax = ToolBox.GetAttributeFloat(element, "velocitymax", 0.0f);
|
||||
VelocityMin = element.GetAttributeFloat("velocitymin", 0.0f);
|
||||
VelocityMax = element.GetAttributeFloat("velocitymax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
VelocityMin = ToolBox.GetAttributeFloat(element, "velocity", 0.0f);
|
||||
VelocityMin = element.GetAttributeFloat("velocity", 0.0f);
|
||||
VelocityMax = VelocityMin;
|
||||
}
|
||||
|
||||
ParticlesPerSecond = ToolBox.GetAttributeInt(element, "particlespersecond", 0);
|
||||
ParticleAmount = ToolBox.GetAttributeInt(element, "particleamount", 0);
|
||||
ParticlesPerSecond = element.GetAttributeInt("particlespersecond", 0);
|
||||
ParticleAmount = element.GetAttributeInt("particleamount", 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace Barotrauma.Particles
|
||||
|
||||
particles = new Particle[MaxParticles];
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml(configFile);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(configFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
prefabs = new Dictionary<string, ParticlePrefab>();
|
||||
|
||||
@@ -69,17 +69,17 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
AnimDuration = ToolBox.GetAttributeFloat(element, "animduration", 1.0f);
|
||||
LoopAnim = ToolBox.GetAttributeBool(element, "loopanim", true);
|
||||
AnimDuration = element.GetAttributeFloat("animduration", 1.0f);
|
||||
LoopAnim = element.GetAttributeBool("loopanim", true);
|
||||
|
||||
if (element.Attribute("angularvelocity") == null)
|
||||
{
|
||||
AngularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocitymin", 0.0f);
|
||||
AngularVelocityMax = ToolBox.GetAttributeFloat(element, "angularvelocitymax", 0.0f);
|
||||
AngularVelocityMin = element.GetAttributeFloat("angularvelocitymin", 0.0f);
|
||||
AngularVelocityMax = element.GetAttributeFloat("angularvelocitymax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
AngularVelocityMin = ToolBox.GetAttributeFloat(element, "angularvelocity", 0.0f);
|
||||
AngularVelocityMin = element.GetAttributeFloat("angularvelocity", 0.0f);
|
||||
AngularVelocityMax = AngularVelocityMin;
|
||||
}
|
||||
|
||||
@@ -88,33 +88,33 @@ namespace Barotrauma.Particles
|
||||
|
||||
if (element.Attribute("startsize") == null)
|
||||
{
|
||||
StartSizeMin = ToolBox.GetAttributeVector2(element, "startsizemin", Vector2.One);
|
||||
StartSizeMax = ToolBox.GetAttributeVector2(element, "startsizemax", Vector2.One);
|
||||
StartSizeMin = element.GetAttributeVector2("startsizemin", Vector2.One);
|
||||
StartSizeMax = element.GetAttributeVector2("startsizemax", Vector2.One);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartSizeMin = ToolBox.GetAttributeVector2(element, "startsize", Vector2.One);
|
||||
StartSizeMin = element.GetAttributeVector2("startsize", Vector2.One);
|
||||
StartSizeMax = StartSizeMin;
|
||||
}
|
||||
|
||||
if (element.Attribute("sizechange") == null)
|
||||
{
|
||||
SizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechangemin", Vector2.Zero);
|
||||
SizeChangeMax = ToolBox.GetAttributeVector2(element, "sizechangemax", Vector2.Zero);
|
||||
SizeChangeMin = element.GetAttributeVector2("sizechangemin", Vector2.Zero);
|
||||
SizeChangeMax = element.GetAttributeVector2("sizechangemax", Vector2.Zero);
|
||||
}
|
||||
else
|
||||
{
|
||||
SizeChangeMin = ToolBox.GetAttributeVector2(element, "sizechange", Vector2.Zero);
|
||||
SizeChangeMin = element.GetAttributeVector2("sizechange", Vector2.Zero);
|
||||
SizeChangeMax = SizeChangeMin;
|
||||
}
|
||||
|
||||
Drag = ToolBox.GetAttributeFloat(element, "drag", 0.0f);
|
||||
WaterDrag = ToolBox.GetAttributeFloat(element, "waterdrag", 0.0f);
|
||||
Drag = element.GetAttributeFloat("drag", 0.0f);
|
||||
WaterDrag = element.GetAttributeFloat("waterdrag", 0.0f);
|
||||
|
||||
Friction = ToolBox.GetAttributeFloat(element, "friction", 0.5f);
|
||||
Restitution = ToolBox.GetAttributeFloat(element, "restitution", 0.5f);
|
||||
Friction = element.GetAttributeFloat("friction", 0.5f);
|
||||
Restitution = element.GetAttributeFloat("restitution", 0.5f);
|
||||
|
||||
switch (ToolBox.GetAttributeString(element, "blendstate", "alphablend"))
|
||||
switch (element.GetAttributeString("blendstate", "alphablend"))
|
||||
{
|
||||
case "alpha":
|
||||
case "alphablend":
|
||||
@@ -130,42 +130,41 @@ namespace Barotrauma.Particles
|
||||
break;
|
||||
}
|
||||
|
||||
GrowTime = ToolBox.GetAttributeFloat(element, "growtime", 0.0f);
|
||||
GrowTime = element.GetAttributeFloat("growtime", 0.0f);
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotationmin", 0.0f);
|
||||
StartRotationMax = ToolBox.GetAttributeFloat(element, "startrotationmax", 0.0f);
|
||||
StartRotationMin = element.GetAttributeFloat("startrotationmin", 0.0f);
|
||||
StartRotationMax = element.GetAttributeFloat("startrotationmax", 0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
StartRotationMin = ToolBox.GetAttributeFloat(element, "startrotation", 0.0f);
|
||||
StartRotationMin = element.GetAttributeFloat("startrotation", 0.0f);
|
||||
StartRotationMax = StartRotationMin;
|
||||
}
|
||||
|
||||
StartRotationMin = MathHelper.ToRadians(StartRotationMin);
|
||||
StartRotationMax = MathHelper.ToRadians(StartRotationMax);
|
||||
|
||||
StartColor = new Color(ToolBox.GetAttributeVector4(element, "startcolor", Vector4.One));
|
||||
StartAlpha = ToolBox.GetAttributeFloat(element, "startalpha", 1.0f);
|
||||
StartColor = new Color(element.GetAttributeVector4("startcolor", Vector4.One));
|
||||
StartAlpha = element.GetAttributeFloat("startalpha", 1.0f);
|
||||
|
||||
DeleteOnCollision = ToolBox.GetAttributeBool(element, "deleteoncollision", false);
|
||||
CollidesWithWalls = ToolBox.GetAttributeBool(element, "collideswithwalls", false);
|
||||
DeleteOnCollision = element.GetAttributeBool("deleteoncollision", false);
|
||||
CollidesWithWalls = element.GetAttributeBool("collideswithwalls", false);
|
||||
|
||||
CollisionRadius = ToolBox.GetAttributeFloat(element,
|
||||
"collisionradius",
|
||||
CollisionRadius = element.GetAttributeFloat("collisionradius",
|
||||
Sprites.Count > 0 ? 1 : Sprites[0].SourceRect.Width / 2.0f);
|
||||
|
||||
ColorChange = ToolBox.GetAttributeVector4(element, "colorchange", Vector4.Zero);
|
||||
ColorChange = element.GetAttributeVector4("colorchange", Vector4.Zero);
|
||||
|
||||
LifeTime = ToolBox.GetAttributeFloat(element, "lifetime", 5.0f);
|
||||
LifeTime = element.GetAttributeFloat("lifetime", 5.0f);
|
||||
|
||||
VelocityChange = ToolBox.GetAttributeVector2(element, "velocitychange", Vector2.Zero);
|
||||
VelocityChange = element.GetAttributeVector2("velocitychange", Vector2.Zero);
|
||||
VelocityChange = ConvertUnits.ToDisplayUnits(VelocityChange);
|
||||
|
||||
RotateToDirection = ToolBox.GetAttributeBool(element, "rotatetodirection", false);
|
||||
RotateToDirection = element.GetAttributeBool("rotatetodirection", false);
|
||||
|
||||
switch (ToolBox.GetAttributeString(element, "drawtarget", "air").ToLowerInvariant())
|
||||
switch (element.GetAttributeString("drawtarget", "air").ToLowerInvariant())
|
||||
{
|
||||
case "air":
|
||||
default:
|
||||
|
||||
@@ -166,9 +166,9 @@ namespace Barotrauma
|
||||
|
||||
RemoveSaveFrame();
|
||||
|
||||
string subName = ToolBox.GetAttributeString(doc.Root, "submarine", "");
|
||||
string saveTime = ToolBox.GetAttributeString(doc.Root, "savetime", "unknown");
|
||||
string mapseed = ToolBox.GetAttributeString(doc.Root, "mapseed", "unknown");
|
||||
string subName = doc.Root.GetAttributeString("submarine", "");
|
||||
string saveTime = doc.Root.GetAttributeString("savetime", "unknown");
|
||||
string mapseed = doc.Root.GetAttributeString("mapseed", "unknown");
|
||||
|
||||
GUIFrame saveFileFrame = new GUIFrame(new Rectangle((int)(saveList.Rect.Width + 20), 0, 200, 230), Color.Black * 0.4f, "", loadGameContainer);
|
||||
saveFileFrame.UserData = "savefileframe";
|
||||
|
||||
@@ -93,13 +93,13 @@ namespace Barotrauma
|
||||
|
||||
public static Sound Load(XElement element, bool destroyOnGameEnd = true)
|
||||
{
|
||||
string filePath = ToolBox.GetAttributeString(element, "file", "");
|
||||
string filePath = element.GetAttributeString("file", "");
|
||||
|
||||
var newSound = new Sound(filePath, destroyOnGameEnd);
|
||||
if (newSound != null)
|
||||
{
|
||||
newSound.baseVolume = ToolBox.GetAttributeFloat(element, "volume", 1.0f);
|
||||
newSound.range = ToolBox.GetAttributeFloat(element, "range", 1000.0f);
|
||||
newSound.baseVolume = element.GetAttributeFloat("volume", 1.0f);
|
||||
newSound.range = element.GetAttributeFloat("range", 1000.0f);
|
||||
}
|
||||
|
||||
return newSound;
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace Barotrauma
|
||||
{
|
||||
OverrideMusicType = null;
|
||||
|
||||
XDocument doc = ToolBox.TryLoadXml("Content/Sounds/sounds.xml");
|
||||
XDocument doc = XMLExtensions.TryLoadXml("Content/Sounds/sounds.xml");
|
||||
if (doc == null) yield return CoroutineStatus.Failure;
|
||||
|
||||
SoundCount = 16 + doc.Root.Elements().Count();
|
||||
@@ -134,9 +134,9 @@ namespace Barotrauma
|
||||
int i = 0;
|
||||
foreach (XElement element in xMusic)
|
||||
{
|
||||
string file = ToolBox.GetAttributeString(element, "file", "");
|
||||
string type = ToolBox.GetAttributeString(element, "type", "").ToLowerInvariant();
|
||||
Vector2 priority = ToolBox.GetAttributeVector2(element, "priorityrange", new Vector2(0.0f, 100.0f));
|
||||
string file = element.GetAttributeString("file", "");
|
||||
string type = element.GetAttributeString("type", "").ToLowerInvariant();
|
||||
Vector2 priority = element.GetAttributeVector2("priorityrange", new Vector2(0.0f, 100.0f));
|
||||
|
||||
musicClips[i] = new BackgroundMusic(file, type, priority);
|
||||
|
||||
@@ -158,21 +158,21 @@ namespace Barotrauma
|
||||
case "music":
|
||||
continue;
|
||||
case "damagesound":
|
||||
Sound damageSound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""), false);
|
||||
Sound damageSound = Sound.Load(subElement.GetAttributeString("file", ""), false);
|
||||
if (damageSound == null) continue;
|
||||
|
||||
DamageSoundType damageSoundType = DamageSoundType.None;
|
||||
Enum.TryParse<DamageSoundType>(ToolBox.GetAttributeString(subElement, "damagesoundtype", "None"), false, out damageSoundType);
|
||||
Enum.TryParse<DamageSoundType>(subElement.GetAttributeString("damagesoundtype", "None"), false, out damageSoundType);
|
||||
|
||||
damageSounds.Add(new DamageSound(
|
||||
damageSound,
|
||||
ToolBox.GetAttributeVector2(subElement, "damagerange", new Vector2(0.0f, 100.0f)),
|
||||
subElement.GetAttributeVector2("damagerange", new Vector2(0.0f, 100.0f)),
|
||||
damageSoundType,
|
||||
ToolBox.GetAttributeString(subElement, "requiredtag", "")));
|
||||
subElement.GetAttributeString("requiredtag", "")));
|
||||
|
||||
break;
|
||||
default:
|
||||
Sound sound = Sound.Load(ToolBox.GetAttributeString(subElement, "file", ""), false);
|
||||
Sound sound = Sound.Load(subElement.GetAttributeString("file", ""), false);
|
||||
if (sound != null)
|
||||
{
|
||||
miscSoundList.Add(new KeyValuePair<string, Sound>(subElement.Name.ToString().ToLowerInvariant(), sound));
|
||||
|
||||
Reference in New Issue
Block a user