public static GameConfigXml Load(string configXml, params object[] param) { GameConfigXml config = null; if (File.Exists(configXml)) { Stream stream = null; try { stream = new FileStream(configXml, FileMode.Open, FileAccess.Read); XmlSerializer serializer = new XmlSerializer(typeof(GameConfigXml)); config = serializer.Deserialize(stream) as GameConfigXml; } catch { } finally { if (stream != null) { stream.Close(); } } } else { config = new GameConfigXml(); config.GenerateDefaultConfig(param); } return(config); }
public void Run() { string modArg = gameArgument.GetArgValue("Engine.Mod"); string showConfigArg = gameArgument.GetArgValue("Engine.ShowConfig"); if (string.IsNullOrEmpty(showConfigArg) || showConfigArg == "yes") { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); frmConfigureController controller = new frmConfigureController(new frmConfigure(modArg)); controller.form.ShowDialog(); } else { Root root = new Root(); GameApp app = new GameApp(GameConfigXml.Load("game.xml", root), modArg); app.Run(); } }
public static GameConfigXml Load(string configXml) { GameConfigXml config = new GameConfigXml(); Stream stream = null; try { stream = new FileStream(configXml, FileMode.Open, FileAccess.Read); XmlSerializer serializer = new XmlSerializer(typeof(GameConfigXml)); config = serializer.Deserialize(stream) as GameConfigXml; } catch { } finally { if (stream != null) { stream.Close(); } } return(config); }