예제 #1
0
 public StylesheetEditor(string xmlFolder, UiXmlLoader xml, UiData context)
 {
     Title      = "Stylesheet";
     textEditor = new ColorTextEdit();
     uiContext  = context;
     path       = Path.Combine(xmlFolder, "stylesheet.xml");
     textEditor.SetText(File.ReadAllText(path));
     this.xml = xml;
     TextChanged();
 }
예제 #2
0
        public static InterfaceTextBundle Compile(string xmlFolder, UiXmlLoader xmlLoader, string outfolder = null)
        {
            if (outfolder != null)
            {
                Directory.CreateDirectory(outfolder);
            }
            var bundle = new InterfaceTextBundle();

            bundle.AddStringCompressed("resources.xml", File.ReadAllText(Path.Combine(xmlFolder, "resources.xml")));
            foreach (var file in LuaFiles(xmlFolder))
            {
                bundle.AddStringCompressed(file, File.ReadAllText(Path.Combine(xmlFolder, file)));
            }
            var mainlua = new StringBuilder();

            if (File.Exists(Path.Combine(xmlFolder, "main.lua")))
            {
                mainlua.AppendLine("require 'main.lua'");
            }
            // uimain boilerplate
            mainlua.AppendLine(BOILERPLATE);
            // classes
            foreach (var file in CompileFiles(xmlFolder))
            {
                try
                {
                    var(classname, source) = xmlLoader.LuaClassDesigner(File.ReadAllText(file), Path.GetFileNameWithoutExtension(file));
                    bundle.AddStringCompressed(classname + ".designer.lua", source);
                    if (outfolder != null)
                    {
                        File.WriteAllText(Path.Combine(outfolder, classname + ".designer.lua"), source);
                    }
                    mainlua.AppendLine($"require '{classname}.designer'");
                    if (File.Exists(Path.Combine(xmlFolder, classname + ".lua")))
                    {
                        mainlua.AppendLine($"require '{classname}'");
                    }
                    mainlua.AppendLine($"_classes.{classname} = {classname}");
                }
                catch (Exception e)
                {
                    throw new Exception($"Error compiling {file}", e);
                }
            }
            // stylesheet
            mainlua.AppendLine(xmlLoader.StylesheetToLua(File.ReadAllText(Path.Combine(xmlFolder, "stylesheet.xml"))));
            bundle.AddStringCompressed("uimain.lua", mainlua.ToString());
            if (outfolder != null)
            {
                File.WriteAllText(Path.Combine(outfolder, "uimain.lua"), mainlua.ToString());
                File.WriteAllText(Path.Combine(outfolder, "interface.json"), bundle.ToJSON());
            }
            return(bundle);
        }
예제 #3
0
        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);
        }