Ejemplo n.º 1
0
 void DisplayInfoXml()
 {
     if (currentInfocard == -1)
     {
         display.SetInfocard(blankInfocard);
         return;
     }
     display.SetInfocard(RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), fonts));
 }
 void SearchResults()
 {
     ImGui.Begin(ImGuiExt.IDWithExtra("Search", Unique), ref searchResultsOpen, ImGuiWindowFlags.AlwaysAutoResize);
     ImGui.Text(resultTitle);
     ImGui.BeginChild("##results", new Vector2(200, 200), true);
     for (int i = 0; i < searchResults.Length; i++)
     {
         if (ImGui.Selectable(searchResults[i].ToString()))
         {
             id = searchResults[i];
             if (isSearchInfocards)
             {
                 GotoInfocard();
             }
             else
             {
                 GotoString();
             }
             ImGui.CloseCurrentPopup();
         }
         if (ImGui.IsItemHovered())
         {
             if (isSearchInfocards)
             {
                 if (searchStringPreviews[i] == null)
                 {
                     try
                     {
                         searchStringPreviews[i] =
                             EllipseIfNeeded(RDLParse.Parse(searchStrings[i], fonts).ExtractText());
                     }
                     catch (Exception)
                     {
                         searchStringPreviews[i] = EllipseIfNeeded(searchStrings[i]);
                     }
                 }
                 ImGui.SetTooltip(searchStringPreviews[i]);
             }
             else
             {
                 ImGui.SetTooltip(EllipseIfNeeded(searchStrings[i]));
             }
         }
     }
     ImGui.EndChild();
     ImGui.End();
 }
 void GotoInfocard()
 {
     for (int i = 0; i < infocardsIds.Length; i++)
     {
         if (id == infocardsIds[i])
         {
             gotoItem        = i;
             currentInfocard = i;
             currentXml      = manager.GetXmlResource(infocardsIds[currentInfocard]);
             if (display == null)
             {
                 display = new InfocardControl(win, RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), fonts), 100);
             }
             else
             {
                 display.SetInfocard(RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), fonts));
             }
         }
     }
 }
Ejemplo n.º 4
0
 public Infocard GetInfocard(int id) =>
 RDLParse.Parse(c.uiContext.Data.Infocards.GetXmlResource(id), c.uiContext.Data.Fonts);
Ejemplo n.º 5
0
        public override void Draw()
        {
            ImGui.Columns(2, "cols", true);
            //strings vs infocards
            if (ImGuiExt.ToggleButton("Strings", showStrings))
            {
                showStrings = true;
            }
            ImGui.SameLine();
            if (ImGuiExt.ToggleButton("Infocards", !showStrings))
            {
                showStrings = false;
            }
            ImGui.SameLine();
            ImGui.PushItemWidth(140);
            ImGui.InputInt("##id", ref id, 0, 0);
            ImGui.PopItemWidth();
            ImGui.SameLine();
            int gotoItem = -1;

            if (ImGui.Button("Go"))
            {
                if (showStrings)
                {
                    for (int i = 0; i < stringsIds.Length; i++)
                    {
                        if (id == stringsIds[i])
                        {
                            gotoItem      = i;
                            currentString = i;
                            txt.SetText(manager.GetStringResource(stringsIds[i]));
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < infocardsIds.Length; i++)
                    {
                        if (id == infocardsIds[i])
                        {
                            gotoItem        = i;
                            currentInfocard = i;
                            if (display == null)
                            {
                                display = new InfocardControl(win, RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts), 100);
                            }
                            else
                            {
                                display.SetInfocard(RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts));
                            }
                        }
                    }
                }
            }
            ImGui.Separator();
            //list
            ImGui.BeginChild("##list");
            if (showStrings)
            {
                if (gotoItem == -1)
                {
                    stringClipper.Begin(stringsIds.Length);
                    while (stringClipper.Step())
                    {
                        for (int i = stringClipper.DisplayStart; i < stringClipper.DisplayEnd; i++)
                        {
                            if (ImGui.Selectable(stringsIds[i] + "##" + i, currentString == i))
                            {
                                currentString = i;
                                txt.SetText(manager.GetStringResource(stringsIds[i]));
                            }
                        }
                    }
                    stringClipper.End();
                }
                else
                {
                    for (int i = 0; i < stringsIds.Length; i++)
                    {
                        ImGui.Selectable(stringsIds[i] + "##" + i, currentString == i);
                        if (currentString == i)
                        {
                            ImGui.SetScrollHere();
                        }
                    }
                }
            }
            else
            {
                if (gotoItem == -1)
                {
                    infocardClipper.Begin(infocardsIds.Length);
                    while (infocardClipper.Step())
                    {
                        for (int i = infocardClipper.DisplayStart; i < infocardClipper.DisplayEnd; i++)
                        {
                            if (ImGui.Selectable(infocardsIds[i] + "##" + i, currentInfocard == i))
                            {
                                currentInfocard = i;
                                if (display == null)
                                {
                                    display = new InfocardControl(win, RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts), 100);
                                }
                                else
                                {
                                    display.SetInfocard(RDLParse.Parse(manager.GetXmlResource(infocardsIds[currentInfocard]), win.Fonts));
                                }
                            }
                        }
                    }
                    infocardClipper.End();
                }
                else
                {
                    for (int i = 0; i < infocardsIds.Length; i++)
                    {
                        ImGui.Selectable(infocardsIds[i] + "##" + i, currentInfocard == i);
                        if (currentInfocard == i)
                        {
                            ImGui.SetScrollHere();
                        }
                    }
                }
            }
            ImGui.EndChild();
            ImGui.NextColumn();
            //Display
            if (showStrings)
            {
                if (currentString != -1)
                {
                    ImGui.Text(stringsIds[currentString].ToString());
                    txt.InputTextMultiline("##txt", new Vector2(-1, ImGui.GetWindowHeight() - 70), ImGuiInputTextFlags.ReadOnly);
                }
            }
            else
            {
                if (currentInfocard != -1)
                {
                    ImGui.Text(infocardsIds[currentInfocard].ToString());
                    ImGui.BeginChild("##display");
                    display.Draw(ImGui.GetWindowWidth() - 15);
                    ImGui.EndChild();
                }
            }
        }
Ejemplo n.º 6
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);
        }