コード例 #1
0
 public UtfTab(MainWindow main, EditableUtf utf, string title)
 {
     this.main = main;
     Utf       = utf;
     Title     = title;
     text      = new TextBuffer();
     main.Resources.AddResources(utf.Export(), Unique.ToString());
 }
コード例 #2
0
ファイル: UtfTab.cs プロジェクト: bin601/Librelancer
 public UtfTab(MainWindow main, EditableUtf utf, string title)
 {
     this.main    = main;
     Utf          = utf;
     DocumentName = title;
     Title        = string.Format("{0}##{1}", title, Unique);
     text         = new TextBuffer();
     main.Resources.AddResources(utf.Export(), Unique.ToString());
     RegisterPopups();
 }
コード例 #3
0
ファイル: UtfTab.cs プロジェクト: Regenhardt/Librelancer
 //generated parameter is used for utf generated internally, like from the collada exporter
 //saves a bunch of copies when opening a large UTF from disk
 public UtfTab(MainWindow main, EditableUtf utf, string title, bool generated = false)
 {
     this.main    = main;
     Utf          = utf;
     DocumentName = title;
     Title        = title;
     text         = new TextBuffer();
     if (generated)
     {
         utf.Source = utf.Export();
     }
     if (utf.Source != null)
     {
         main.Resources.AddResources(utf.Source, Unique.ToString());
         utf.Source = null;
     }
     RegisterPopups();
 }
コード例 #4
0
ファイル: UtfTab.cs プロジェクト: Regenhardt/Librelancer
 public override void Dispose()
 {
     text.Dispose();
     main.Resources.RemoveResourcesForId(Unique.ToString());
 }
コード例 #5
0
ファイル: UtfTab.cs プロジェクト: Regenhardt/Librelancer
        public override void Draw()
        {
            //Child Window
            var size = ImGui.GetWindowSize();

            ImGui.BeginChild("##utfchild", new Vector2(size.X - 15, size.Y - 50), false, 0);
            //Layout
            if (selectedNode != null)
            {
                ImGui.Columns(2, "NodeColumns", true);
            }
            //Headers
            ImGui.Separator();
            ImGui.Text("Nodes");
            if (selectedNode != null)
            {
                ImGui.NextColumn();
                ImGui.Text("Node Information");
                ImGui.NextColumn();
            }
            ImGui.Separator();
            //Tree
            ImGui.BeginChild("##scroll");
            var flags  = selectedNode == Utf.Root ? ImGuiTreeNodeFlags.Selected | tflags : tflags;
            var isOpen = ImGui.TreeNodeEx("/", flags);

            if (ImGui.IsItemClicked(0))
            {
                selectedNode = Utf.Root;
            }
            ImGui.PushID("/##ROOT");
            DoNodeMenu("/##ROOT", Utf.Root, null);
            ImGui.PopID();
            if (isOpen)
            {
                for (int i = 0; i < Utf.Root.Children.Count; i++)
                {
                    DoNode(Utf.Root.Children[i], Utf.Root, i);
                }
                ImGui.TreePop();
            }
            ImGui.EndChild();
            //End Tree
            if (selectedNode != null)
            {
                //Node preview
                ImGui.NextColumn();
                NodeInformation();
            }
            //Action Bar
            ImGui.EndChild();
            ImGui.Separator();
            if (ImGui.Button("Actions"))
            {
                ImGui.OpenPopup("actions");
            }
            if (ImGui.BeginPopup("actions"))
            {
                if (ImGui.MenuItem("View Model"))
                {
                    IDrawable  drawable = null;
                    ModelNodes hpn      = new ModelNodes();
                    try
                    {
                        drawable = LibreLancer.Utf.UtfLoader.GetDrawable(Utf.Export(), main.Resources);
                        drawable.Initialize(main.Resources);
                        if (Utf.Root.Children.Any((x) => x.Name.Equals("cmpnd", StringComparison.OrdinalIgnoreCase)))
                        {
                            foreach (var child in Utf.Root.Children.Where((x) => x.Name.EndsWith(".3db", StringComparison.OrdinalIgnoreCase)))
                            {
                                var n = new ModelHpNode();
                                n.Name           = child.Name;
                                n.Node           = child;
                                n.HardpointsNode = child.Children.FirstOrDefault((x) => x.Name.Equals("hardpoints", StringComparison.OrdinalIgnoreCase));
                                hpn.Nodes.Add(n);
                            }
                            var cmpnd = Utf.Root.Children.First((x) => x.Name.Equals("cmpnd", StringComparison.OrdinalIgnoreCase));
                            hpn.Cons = cmpnd.Children.FirstOrDefault((x) => x.Name.Equals("cons", StringComparison.OrdinalIgnoreCase));
                        }
                        else
                        {
                            var n = new ModelHpNode();
                            n.Name           = "ROOT";
                            n.Node           = Utf.Root;
                            n.HardpointsNode = Utf.Root.Children.FirstOrDefault((x) => x.Name.Equals("hardpoints", StringComparison.OrdinalIgnoreCase));
                            hpn.Nodes.Add(n);
                        }
                    }
                    catch (Exception ex) { ErrorPopup("Could not open as model\n" + ex.Message + "\n" + ex.StackTrace); drawable = null; }
                    if (drawable != null)
                    {
                        main.AddTab(new ModelViewer(DocumentName, drawable, main, this, hpn));
                    }
                }
                if (ImGui.MenuItem("Export Collada"))
                {
                    LibreLancer.Utf.Cmp.ModelFile model = null;
                    LibreLancer.Utf.Cmp.CmpFile   cmp   = null;
                    try
                    {
                        var drawable = LibreLancer.Utf.UtfLoader.GetDrawable(Utf.Export(), main.Resources);
                        model = (drawable as LibreLancer.Utf.Cmp.ModelFile);
                        cmp   = (drawable as LibreLancer.Utf.Cmp.CmpFile);
                    }
                    catch (Exception) { ErrorPopup("Could not open as model"); model = null; }
                    if (model != null)
                    {
                        var output = FileDialog.Save();
                        if (output != null)
                        {
                            model.Path = DocumentName;
                            try
                            {
                                ColladaExport.ExportCollada(model, main.Resources, output);
                            }
                            catch (Exception ex)
                            {
                                ErrorPopup("Error\n" + ex.Message + "\n" + ex.StackTrace);
                            }
                        }
                    }
                    if (cmp != null)
                    {
                        var output = FileDialog.Save();
                        if (output != null)
                        {
                            cmp.Path = DocumentName;
                            try
                            {
                                ColladaExport.ExportCollada(cmp, main.Resources, output);
                            }
                            catch (Exception ex)
                            {
                                ErrorPopup("Error\n" + ex.Message + "\n" + ex.StackTrace);
                            }
                        }
                    }
                }
                if (ImGui.MenuItem("View Ale"))
                {
                    AleFile ale = null;
                    try
                    {
                        ale = new AleFile(Utf.Export());
                    }
                    catch (Exception)
                    {
                        ErrorPopup("Could not open as ale");
                        ale = null;
                    }
                    if (ale != null)
                    {
                        main.AddTab(new AleViewer(Title, ale, main));
                    }
                }

                if (ImGui.MenuItem("Resolve Audio Hashes"))
                {
                    var folder = FileDialog.ChooseFolder();
                    if (folder != null)
                    {
                        var idtable = new IDTable(folder);
                        foreach (var n in Utf.Root.IterateAll())
                        {
                            if (n.Name.StartsWith("0x"))
                            {
                                uint v;
                                if (uint.TryParse(n.Name.Substring(2), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out v))
                                {
                                    idtable.UtfNicknameTable.TryGetValue(v, out n.ResolvedName);
                                }
                            }
                            else
                            {
                                n.ResolvedName = null;
                            }
                        }
                    }
                }
                ImGui.EndPopup();
            }
            ImGui.SameLine();
            if (ImGui.Button("Reload Resources"))
            {
                main.Resources.RemoveResourcesForId(Unique.ToString());
                main.Resources.AddResources(Utf.Export(), Unique.ToString());
            }
            Popups();
        }
コード例 #6
0
        public override bool Draw()
        {
            //Child Window
            var size = ImGui.GetWindowSize();

            ImGui.BeginChild("##utfchild", new Vector2(size.X - 15, size.Y - 50), false, 0);
            //Layout
            if (selectedNode != null)
            {
                ImGui.Columns(2, "NodeColumns", true);
            }
            //Headers
            ImGui.Separator();
            ImGui.Text("Nodes");
            if (selectedNode != null)
            {
                ImGui.NextColumn();
                ImGui.Text("Node Information");
                ImGui.NextColumn();
            }
            ImGui.Separator();
            //Tree
            ImGui.BeginChild("##scroll", false, 0);
            var flags  = selectedNode == Utf.Root ? TreeNodeFlags.Selected | tflags : tflags;
            var isOpen = ImGui.TreeNodeEx("/", flags);

            if (ImGuiNative.igIsItemClicked(0))
            {
                selectedNode = Utf.Root;
            }
            ImGui.PushID("/##ROOT");
            DoNodeMenu("/##ROOT", Utf.Root, null);
            ImGui.PopID();
            if (isOpen)
            {
                for (int i = 0; i < Utf.Root.Children.Count; i++)
                {
                    DoNode(Utf.Root.Children[i], Utf.Root, i);
                }
                ImGui.TreePop();
            }
            ImGui.EndChild();
            //End Tree
            if (selectedNode != null)
            {
                //Node preview
                ImGui.NextColumn();
                NodeInformation();
            }
            //Action Bar
            ImGui.EndChild();
            ImGui.Separator();
            if (ImGui.Button("Actions"))
            {
                ImGui.OpenPopup("actions");
            }
            if (ImGui.BeginPopup("actions"))
            {
                if (ImGui.MenuItem("View Model"))
                {
                    IDrawable drawable = null;
                    try
                    {
                        drawable = LibreLancer.Utf.UtfLoader.GetDrawable(Utf.Export(), main.Resources);
                        drawable.Initialize(main.Resources);
                    }
                    catch (Exception) { ErrorPopup("Could not open as model"); drawable = null; }
                    if (drawable != null)
                    {
                        main.AddTab(new ModelViewer("Model Viewer (" + Title + ")", Title, drawable, main, this));
                    }
                }
                if (ImGui.MenuItem("View Ale"))
                {
                    AleFile ale = null;
                    try
                    {
                        ale = new AleFile(Utf.Export());
                    }
                    catch (Exception)
                    {
                        ErrorPopup("Could not open as ale");
                        ale = null;
                    }
                    if (ale != null)
                    {
                        main.AddTab(new AleViewer("Ale Viewer (" + Title + ")", Title, ale, main));
                    }
                }
                if (ImGui.MenuItem("Refresh Resources"))
                {
                    main.Resources.RemoveResourcesForId(Unique.ToString());
                    main.Resources.AddResources(Utf.Export(), Unique.ToString());
                }
                ImGui.EndPopup();
            }
            Popups();
            return(open);
        }
コード例 #7
0
 public override string ToString()
 {
     return(string.Format("{0}:{1}", Origin.ToString(), Unique.ToString()));
 }
コード例 #8
0
ファイル: Input.cs プロジェクト: aiplugs/tags
        public override void Process(TagHelperContext context, TagHelperOutput output)
        {
            base.Process(context, output);
            RenderFieldHeader(context, output);

            var id   = GetDomId();
            var type = (Type ?? "text").ToLower().Trim();

            if (Ajax != null)
            {
                output.Attributes.Add($"data-aiplugs-input-ajax-url", Ajax.Url ?? "");
                if (Ajax.Headers != null)
                {
                    foreach (var kv in Ajax.Headers)
                    {
                        output.Attributes.Add($"data-aiplugs-input-ajax-headers-{kv.Key}", kv.Value);
                    }
                }
                output.Attributes.Add("data-aiplugs-input-ajax-label", Ajax.Label ?? "label");
                output.Attributes.Add("data-aiplugs-input-ajax-value", Ajax.Value ?? "value");
            }

            output.Attributes.Add("data-aiplugs-input-unique", Unique.ToString().ToLower());
            output.Attributes.Add("data-aiplugs-input-ignore-case", IgnoreCase.ToString().ToLower());

            output.Html("<div class=\"aiplugs-input__field\">");

            output.Tag("input", () => {
                output.Attr("type", type);
                output.Attr("data-target", "aiplugs-input.input");
                output.Attr("data-action", "input->aiplugs-input#onInput blur->aiplugs-input#onBlur");
                output.Attr("data-val", "true");

                if (id != null)
                {
                    output.Attr("id", id);
                    output.Attr("list", $"suggestion-{id}");
                }

                if (Name != null)
                {
                    output.Attr("name", Name);
                }

                if (Value != null)
                {
                    output.Attr("value", Value);
                }

                if (ValueFrom != null)
                {
                    output.Attributes.Add("data-aiplugs-input-value-from", ValueFrom);
                }

                if (type == "email")
                {
                    output.Attr("data-val-email", Localizer.MsgValEmail(Label));
                }

                if (Readonly)
                {
                    output.Html(" readonly");
                }

                if (Required)
                {
                    output.Html(" required");
                    output.Attr("data-val-required", Localizer.MsgValRequired(Label));
                }

                if (!string.IsNullOrEmpty(Placeholder))
                {
                    output.Attr("placeholder", Placeholder);
                }

                if (!string.IsNullOrEmpty(Pattern))
                {
                    var message = !string.IsNullOrEmpty(PatternErrorMessage) ? PatternErrorMessage : Localizer.MsgValPattern(Label, Pattern);
                    output.Attr("data-val-regex", message);
                    output.Attr("data-val-regex-pattern", Pattern);
                }

                if (MaxLength.HasValue)
                {
                    output.Attr("data-val-maxlength", Localizer.MsgValMaxLengthForString(Label, MaxLength.Value));
                    output.Attr("data-val-maxlength-max", MaxLength.ToString());
                }

                if (MinLength.HasValue)
                {
                    output.Attr("data-val-minlength", Localizer.MsgValMinLengthForString(Label, MinLength.Value));
                    output.Attr("data-val-minlength-min", MinLength.ToString());
                }

                if (type == "number")
                {
                    output.Attr("data-val-number", Localizer.MsgValNumber(Label));

                    if (Max.HasValue || Min.HasValue)
                    {
                        var message = Max.HasValue && Min.HasValue ? Localizer.MsgValRange(Label, Min.Value, Max.Value)
                                    : Max.HasValue ? Localizer.MsgValMaxValue(Label, Max.Value)
                                    : Localizer.MsgValMinValue(Label, Min.Value);

                        output.Attr($"data-val-range", message);
                    }

                    if (Step.HasValue)
                    {
                        output.Html($"step=\"{Step}\"");
                    }

                    if (Max.HasValue)
                    {
                        output.Html($"max=\"{Max}\" data-val-range-max=\"{Max}\"");
                    }

                    if (Min.HasValue)
                    {
                        output.Html($"min=\"{Min}\" data-val-range-min=\"{Min}\"");
                    }
                }
            });

            output.Html("</div>");

            if (id != null)
            {
                output.Tag("datalist", () => {
                    output.Attr("id", $"suggestion-{id}");
                    output.Attr("data-target", "aiplugs-input.suggestion");
                });
            }

            RenderFieldFooter(context, output, Name);
        }