void NewGui(string folder) { UiData = new UiData(); UiData.FlDirectory = folder; UiData.ResourceManager = new GameResourceManager(this); UiData.FileSystem = FileSystem.FromFolder(folder); UiData.Fonts = Fonts; var flIni = new FreelancerIni(UiData.FileSystem); if (flIni.XInterfacePath != null) { XmlFolder = UiData.FileSystem.Resolve(flIni.XInterfacePath); if (!UiData.FileSystem.FileExists(Path.Combine(flIni.XInterfacePath, "resources.xml"))) { WriteBlankFiles(); } } else { var dataPath = UiData.FileSystem.Resolve(flIni.DataPath); XmlFolder = Path.Combine(dataPath, "XmlUi"); Directory.CreateDirectory(XmlFolder); WriteBlankFiles(); var flIniPath = UiData.FileSystem.Resolve("EXE\\freelancer.ini"); var flIniText = File.ReadAllText(flIniPath); File.WriteAllText(flIniPath, $"{flIniText}\n\n[Extended]\nxinterface = XmlUi"); } UiData.OpenFolder(flIni.XInterfacePath); try { var navbarIni = new LibreLancer.Data.BaseNavBarIni(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) }); } TestApi.ManeuverData = maneuvers.ToArray(); } catch (Exception) { TestApi.ManeuverData = null; } if (flIni.JsonResources != null) { UiData.Infocards = new InfocardManager(flIni.JsonResources.Item1, flIni.JsonResources.Item2); } else if (flIni.Resources != null) { UiData.Infocards = new InfocardManager(flIni.Resources); } Fonts.LoadFontsFromIni(flIni, UiData.FileSystem); UiData.DataPath = flIni.DataPath; resourceEditor = new ResourceWindow(this, UiData); resourceEditor.IsOpen = true; projectWindow = new ProjectWindow(XmlFolder, this); projectWindow.IsOpen = true; tabs.Add(new StylesheetEditor(XmlFolder, UiData)); }
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); }