Changes to settings/contentpackage exception handling
This commit is contained in:
@@ -54,13 +54,14 @@ namespace Subsurface
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
|
||||
Path = filePath;
|
||||
|
||||
if (doc==null)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't load content package ''"+filePath+"''!");
|
||||
return;
|
||||
}
|
||||
|
||||
Path = filePath;
|
||||
|
||||
name = ToolBox.GetAttributeString(doc.Root, "name", "");
|
||||
|
||||
@@ -78,7 +79,7 @@ namespace Subsurface
|
||||
|
||||
public static ContentPackage CreatePackage(string name)
|
||||
{
|
||||
ContentPackage newPackage = new ContentPackage();
|
||||
ContentPackage newPackage = new ContentPackage("Content/Data/"+name);
|
||||
newPackage.name = name;
|
||||
list.Add(newPackage);
|
||||
|
||||
|
||||
@@ -45,23 +45,30 @@ namespace Subsurface
|
||||
public void Load(string filePath)
|
||||
{
|
||||
XDocument doc = ToolBox.TryLoadXml(filePath);
|
||||
try
|
||||
{
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = int.Parse(graphicsMode.Attribute("width").Value);
|
||||
GraphicsHeight = int.Parse(graphicsMode.Attribute("height").Value);
|
||||
|
||||
FullScreenEnabled = graphicsMode.Attribute("fullscreen").Value == "true";
|
||||
}
|
||||
catch
|
||||
|
||||
if (doc == null)
|
||||
{
|
||||
DebugConsole.ThrowError("No config file found");
|
||||
|
||||
GraphicsWidth = 1024;
|
||||
GraphicsHeight = 768;
|
||||
GraphicsHeight = 678;
|
||||
|
||||
MasterServerUrl = "";
|
||||
|
||||
SelectedContentPackage = new ContentPackage("");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
XElement graphicsMode = doc.Root.Element("graphicsmode");
|
||||
GraphicsWidth = int.Parse(graphicsMode.Attribute("width").Value);
|
||||
GraphicsHeight = int.Parse(graphicsMode.Attribute("height").Value);
|
||||
|
||||
FullScreenEnabled = graphicsMode.Attribute("fullscreen").Value == "true";
|
||||
|
||||
MasterServerUrl = ToolBox.GetAttributeString(doc.Root, "masterserverurl", "");
|
||||
|
||||
|
||||
foreach (XElement subElement in doc.Root.Elements())
|
||||
{
|
||||
switch (subElement.Name.ToString().ToLower())
|
||||
@@ -73,8 +80,7 @@ namespace Subsurface
|
||||
if (SelectedContentPackage == null) SelectedContentPackage = new ContentPackage(path);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(string filePath)
|
||||
|
||||
@@ -99,23 +99,8 @@ namespace Subsurface.Items.Components
|
||||
}
|
||||
|
||||
rotation = MathUtils.CurveAngle(rotation, targetRotation, 0.05f);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//public override void SecondaryUse(float deltaTime, Character character = null)
|
||||
//{
|
||||
// if (character == null) return;
|
||||
|
||||
// Vector2 centerPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
|
||||
|
||||
// if (character == Character.Controlled && cam!=null)
|
||||
// {
|
||||
// Lights.LightManager.ViewPos = centerPos;
|
||||
// cam.TargetPos = new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y);
|
||||
// }
|
||||
//}
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (reload > 0.0f) return false;
|
||||
@@ -176,8 +161,6 @@ namespace Subsurface.Items.Components
|
||||
projectile.body.Enabled = true;
|
||||
projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.Rect.X + barrelPos.X, item.Rect.Y - barrelPos.Y)), -rotation);
|
||||
|
||||
//if (useSounds.Count() > 0) useSounds[Game1.localRandom.Next(useSounds.Count())].Play(1.0f, 800.0f, item.body.FarseerBody);
|
||||
|
||||
projectileComponent.Use(deltaTime);
|
||||
item.RemoveContained(projectile);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user