void TextChanged() { try { var text = textEditor.GetText(); if (string.IsNullOrEmpty(text) || string.IsNullOrWhiteSpace(text)) { validXml = false; exceptionText = "Error: Nothing typed yet"; return; } currentStylesheet = (Stylesheet)xml.FromString(text, null); validXml = true; } catch (Exception e) { validXml = false; if (e is NullReferenceException) { exceptionText = $"Error: {e.Message}\n{e.StackTrace}"; } else { exceptionText = $"Error: {e.Message}"; } } }
void Load() { UiData.FlDirectory = FlFolder; UiData.ResourceManager = new GameResourceManager(window); UiData.FileSystem = FileSystem.FromFolder(FlFolder); UiData.Fonts = window.Fonts; var flIni = new FreelancerIni(UiData.FileSystem); var dataPath = UiData.FileSystem.Resolve(flIni.DataPath) + "/"; ResolvedDataDir = dataPath; UiData.DataPath = flIni.DataPath; //TODO: Fix to work with custom game UiData.NavmapIcons = new NavmapIcons(); UiData.OpenFolder(XmlFolder); try { var navbarIni = new LibreLancer.Data.BaseNavBarIni(dataPath, UiData.FileSystem); UiData.NavbarIcons = navbarIni.Navbar; } catch (Exception) { UiData.NavbarIcons = null; } try { var hud = new HudIni(); hud.AddIni(flIni.HudPath, UiData.FileSystem); var maneuvers = new List <Maneuver>(); var p = flIni.DataPath.Replace('\\', Path.DirectorySeparatorChar); foreach (var m in hud.Maneuvers) { maneuvers.Add(new Maneuver() { Action = m.Action, ActiveModel = Path.Combine(p, m.ActiveModel), InactiveModel = Path.Combine(p, m.InactiveModel) }); } window.TestApi.ManeuverData = maneuvers.ToArray(); } catch (Exception) { window.TestApi.ManeuverData = null; } if (flIni.JsonResources != null) { UiData.Infocards = new InfocardManager(flIni.JsonResources, UiData.FileSystem); } else if (flIni.Resources != null) { UiData.Infocards = new InfocardManager(flIni.Resources); } XmlLoader = new UiXmlLoader(UiData.Resources); try { UiData.Stylesheet = (Stylesheet)XmlLoader.FromString(UiData.ReadAllText("stylesheet.xml"), null); } catch (Exception) { } window.Fonts.LoadFontsFromIni(flIni, UiData.FileSystem); //unioners infocard var im = new InfocardManager(flIni.Resources); TestingInfocard = RDLParse.Parse(im.GetXmlResource(65546), window.Fonts); }