예제 #1
0
 void OpenGui(string path)
 {
     Project = new Project(this);
     Project.Open(path);
     Project.UiData.ResourceManager.LoadResourceFile(
         Project.UiData.DataResolve(@"ships\rheinland\rh_playerships.mat"));
     Project.UiData.ResourceManager.LoadResourceFile(
         Project.UiData.DataResolve(@"ships\liberty\li_playerships.mat"));
     recentFiles.FileOpened(path);
     resourceEditor        = new ResourceWindow(this, Project.UiData);
     resourceEditor.IsOpen = true;
     projectWindow         = new ProjectWindow(Project.XmlFolder, this);
     projectWindow.IsOpen  = true;
     tabs.Add(new StylesheetEditor(Project.XmlFolder, Project.XmlLoader, Project.UiData));
     TestApi._Infocard = Project.TestingInfocard;
 }
예제 #2
0
        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));
        }