Ejemplo n.º 1
0
        private void OnImGui()
        {
            //dockspace
            ImGui.DockSpaceOverViewport();

            if (ImGui.BeginMainMenuBar())
            {
                pc.DrawFileMenu();

                ImGui.EndMainMenuBar();
            }

            ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, new System.Numerics.Vector2(160f, 90f));
            if (ImGui.Begin("Viewport"))
            {
                cm.Focus = ImGui.IsWindowFocused();

                var cPos  = ImGui.GetCursorScreenPos();
                var vSize = ImGui.GetContentRegionAvail();

                Renderer.ViewportSize = new Vector2i((int)vSize.X, (int)vSize.Y);

                //display framebuffer texture on window
                ImGui.GetWindowDrawList().AddImage(
                    (IntPtr)Renderer.FramebufferTexture,
                    cPos,
                    cPos + vSize,
                    new System.Numerics.Vector2(0f, 1f),
                    new System.Numerics.Vector2(1f, 0f));

                //gizmos
                ImGui.PushClipRect(cPos, cPos + vSize, false);
                if (SceneHierachy.SelectedEntity != null)
                {
                    var entity = SceneHierachy.SelectedEntity;

                    ImGuizmo.SetOrthographic(false);
                    ImGuizmo.SetDrawlist();

                    ImGuizmo.SetRect(cPos.X, cPos.Y, vSize.X, vSize.Y);

                    Camera.Main.CalculateViewProjection(out var view, out var projection);

                    var transform = entity.Transform.GlobalTransform;
                    ImGuizmo.Manipulate(ref view.Row0.X, ref projection.Row0.X, operation, MODE.LOCAL, ref transform.Row0.X);

                    if (ImGuizmo.IsUsing())
                    {
                        var parentGlobal = entity.Parent != null ? entity.Parent.Transform.GlobalTransform : Matrix4.Identity;
                        var local        = transform * parentGlobal.Inverted();

                        entity.Transform.Position = local.ExtractTranslation();
                        entity.Transform.Rotation = local.ExtractRotation();
                        entity.Transform.Scale    = local.ExtractScale();
                    }
                }

                ImGui.SetCursorScreenPos(cPos + new System.Numerics.Vector2(4f));

                ImGui.SetNextItemWidth(240f);
                if (ImGui.BeginCombo("Gizmo", operation == OPERATION.TRANSLATE ? "Translate" : (operation == OPERATION.ROTATE ? "Rotate" : "Scale")))
                {
                    if (ImGui.Selectable("Translate", operation == OPERATION.TRANSLATE))
                    {
                        operation = OPERATION.TRANSLATE;
                    }
                    if (ImGui.Selectable("Rotate", operation == OPERATION.ROTATE))
                    {
                        operation = OPERATION.ROTATE;
                    }
                    if (ImGui.Selectable("Scale", operation == OPERATION.SCALE))
                    {
                        operation = OPERATION.SCALE;
                    }
                }
                ImGui.PopClipRect();

                //mouse select with raycast
                if (ImGui.IsWindowHovered() && ImGui.IsWindowFocused() && ImGui.IsMouseClicked(ImGuiMouseButton.Left) && !ImGuizmo.IsUsing())
                {
                    Ray ray;
                    ray.Origin = Camera.Main.BaseTransform.GlobalTransform.ExtractTranslation();                      //get cam position

                    var     mPos     = (ImGui.GetMousePos() - cPos) / vSize;                                          //get mouse pos in [0, 1]
                    Vector2 mousePos = new Vector2(mPos.X, mPos.Y) * new Vector2(2f) - new Vector2(1f);               //convert to [-1, 1]

                    Camera.Main.CalculateViewProjection(out var view, out var proj);                                  //get view and proj

                    Vector4 unprojected = new Vector4(mousePos.X, -mousePos.Y, 1f, 1f) * Matrix4.Invert(view * proj); //what the f**k?
                    ray.Direction = Vector3.Normalize(unprojected.Xyz);

                    MouseSelect(ray);
                }

                ImGui.End();
            }
            ImGui.PopStyleVar();

            if (ImGui.Begin("Debug"))
            {
                ImGui.Text($"Frametime: {MathF.Floor(Time.UnscaledDeltaTime * 100000f) / 100f}ms");
                ImGui.Text($"Framerate: {MathF.Floor(1f / Time.UnscaledDeltaTime)}");

#if DEBUG
                ImGui.DragFloat("Exposure", ref ((ForwardRenderer)Engine.Renderer).Exposure, 0.1f);
#endif

                ImGui.End();
            }
        }
Ejemplo n.º 2
0
 public void OnGui(string propname = null)
 {
     if (propname != null)
     {
         ImGui.SetNextWindowFocus();
         PropertyName = propname;
         PropertyType = Universe.GetPropertyType(PropertyName);
         ValidType    = InitializeSearchValue();
     }
     if (ImGui.Begin("Search Properties"))
     {
         ImGui.Columns(2);
         ImGui.Text("Property Name");
         ImGui.NextColumn();
         if (ImGui.InputText("##value", ref PropertyName, 40))
         {
             PropertyType = Universe.GetPropertyType(PropertyName);
             ValidType    = InitializeSearchValue();
         }
         ImGui.NextColumn();
         if (PropertyType != null && ValidType)
         {
             ImGui.Text("Type");
             ImGui.NextColumn();
             ImGui.Text(PropertyType.Name);
             ImGui.NextColumn();
             if (SearchValue())
             {
                 FoundObjects.Clear();
                 foreach (var o in Universe.LoadedObjectContainers.Values)
                 {
                     if (o == null)
                     {
                         continue;
                     }
                     if (o is Map m)
                     {
                         foreach (var ob in m.Objects)
                         {
                             if (ob is MapEntity e)
                             {
                                 var p = ob.GetPropertyValue(PropertyName);
                                 if (p != null && p.Equals(PropertyValue))
                                 {
                                     if (!FoundObjects.ContainsKey(e.ContainingMap.Name))
                                     {
                                         FoundObjects.Add(e.ContainingMap.Name, new List <WeakReference <Entity> >());
                                     }
                                     FoundObjects[e.ContainingMap.Name].Add(new WeakReference <Entity>(e));
                                 }
                             }
                         }
                     }
                 }
             }
         }
         ImGui.Columns(1);
         if (FoundObjects.Count > 0)
         {
             ImGui.Text("Search Results");
             ImGui.Separator();
             ImGui.BeginChild("Search Results");
             foreach (var f in FoundObjects)
             {
                 if (ImGui.TreeNodeEx(f.Key, ImGuiTreeNodeFlags.DefaultOpen))
                 {
                     foreach (var o in f.Value)
                     {
                         Entity obj;
                         if (o.TryGetTarget(out obj))
                         {
                             if (ImGui.Selectable(obj.Name, Universe.Selection.GetSelection().Contains(obj), ImGuiSelectableFlags.AllowDoubleClick))
                             {
                                 if (InputTracker.GetKey(Key.ControlLeft) || InputTracker.GetKey(Key.ControlRight))
                                 {
                                     Universe.Selection.AddSelection(obj);
                                 }
                                 else
                                 {
                                     Universe.Selection.ClearSelection();
                                     Universe.Selection.AddSelection(obj);
                                 }
                             }
                         }
                     }
                     ImGui.TreePop();
                 }
             }
             ImGui.EndChild();
         }
     }
     ImGui.End();
 }
Ejemplo n.º 3
0
        public bool Draw()
        {
            ImGui.SetNextWindowSize(new Vector2(500, 500), ImGuiCond.FirstUseEver);

            var isOpen = true;

            if (!ImGui.Begin(Loc.Localize("DalamudItemSelectHeader", "Select an item"), ref isOpen, ImGuiWindowFlags.NoCollapse))
            {
                ImGui.End();
                return(false);
            }

            // Main window
            ImGui.AlignTextToFramePadding();

            ImGui.Text(Loc.Localize("DalamudItemSelect", "Please select an item."));
            if (this.selectedItemTex != null)
            {
                ImGui.Text(" ");

                ImGui.SetCursorPosY(200f);
                ImGui.SameLine();
                ImGui.Image(this.selectedItemTex.ImGuiHandle, new Vector2(40, 40));
            }
            else
            {
                ImGui.Text(" ");
            }

            ImGui.Separator();


            ImGui.Text("Search: ");
            ImGui.SameLine();
            ImGui.InputText("##searchbox", ref this.searchText, 32);

            var kinds = new List <string> {
                Loc.Localize("DalamudItemSelectAll", "All")
            };

            kinds.AddRange(this.data.GetExcelSheet <ItemSearchCategory>().GetRows().Where(x => !string.IsNullOrEmpty(x.Name)).Select(x => x.Name));
            ImGui.Text(Loc.Localize("DalamudItemSelectCategory", "Category: "));
            ImGui.SameLine();
            ImGui.Combo("##kindbox", ref this.currentKind, kinds.ToArray(),
                        kinds.Count);


            var windowSize = ImGui.GetWindowSize();

            ImGui.BeginChild("scrolling", new Vector2(0, windowSize.Y - ImGui.GetCursorPosY() - 40), true, ImGuiWindowFlags.HorizontalScrollbar);

            ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

            if (this.luminaItems != null)
            {
                if (!string.IsNullOrEmpty(this.searchText) || this.currentKind != 0)
                {
                    if (this.lastSearchText != this.searchText || this.lastKind != this.currentKind)
                    {
                        this.lastSearchText = this.searchText;
                        this.lastKind       = this.currentKind;

                        this.searchCancelTokenSource?.Cancel();

                        this.searchCancelTokenSource = new CancellationTokenSource();

                        var asyncEnum = this.luminaItems.ToAsyncEnumerable();

                        if (!string.IsNullOrEmpty(this.searchText))
                        {
                            Log.Debug("Searching for " + this.searchText);
                            asyncEnum = asyncEnum.Where(
                                x => (x.Name.ToLower().Contains(this.searchText.ToLower()) ||
                                      int.TryParse(this.searchText, out var parsedId) &&
                                      parsedId == x.RowId));
                        }

                        if (this.currentKind != 0)
                        {
                            Log.Debug("Searching for C" + this.currentKind);
                            asyncEnum = asyncEnum.Where(x => x.ItemSearchCategory == this.currentKind);
                        }

                        this.selectedItemIndex = -1;
                        this.selectedItemTex?.Dispose();
                        this.selectedItemTex = null;

                        this.searchTask = asyncEnum.ToListAsync(this.searchCancelTokenSource.Token);
                    }

                    if (this.searchTask.IsCompletedSuccessfully)
                    {
                        for (var i = 0; i < this.searchTask.Result.Count; i++)
                        {
                            if (ImGui.Selectable(this.searchTask.Result[i].Name, this.selectedItemIndex == i))
                            {
                                this.selectedItemIndex = i;

                                var iconTex = this.data.GetIcon(this.searchTask.Result[i].Icon);
                                this.selectedItemTex?.Dispose();
                                this.selectedItemTex =
                                    this.builder.LoadImageRaw(iconTex.GetRgbaImageData(), iconTex.Header.Width,
                                                              iconTex.Header.Height, 4);
                            }
                        }
                    }
                }
                else
                {
                    ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectHint", "Type to start searching..."));

                    this.selectedItemIndex = -1;
                    this.selectedItemTex?.Dispose();
                    this.selectedItemTex = null;
                }
            }
            else
            {
                ImGui.TextColored(new Vector4(0.86f, 0.86f, 0.86f, 1.00f), Loc.Localize("DalamudItemSelectLoading", "Loading item list..."));
            }

            ImGui.PopStyleVar();

            ImGui.EndChild();

            if (ImGui.Button(Loc.Localize("Choose", "Choose")))
            {
                OnItemChosen?.Invoke(this, this.searchTask.Result[this.selectedItemIndex]);

                if (this.closeOnChoose)
                {
                    this.selectedItemTex?.Dispose();
                    isOpen = false;
                }
            }

            if (!this.closeOnChoose)
            {
                ImGui.SameLine();
                if (ImGui.Button(Loc.Localize("Close", "Close")))
                {
                    this.selectedItemTex?.Dispose();
                    isOpen = false;
                }
            }

            ImGui.End();

            return(isOpen);
        }
Ejemplo n.º 4
0
        private void RenderConfigWindow()
        {
            if (configWindow)
            {
                ImGui.SetNextWindowSize(new Vector2(300, 500), ImGuiCond.FirstUseEver);
                ImGui.Begin("Chat Config", ref configWindow);
                ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                float footer = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();

                if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                {
                    if (ImGui.BeginTabItem("Config"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10);

                        ImGui.Columns(3);

                        ImGui.Checkbox("Show Chat Extender", ref config.ShowChatWindow);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("24 Hour Time", ref config.HourTime);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Switch to 24 Hour (Military) time.");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Hide Scrollbar", ref config.NoScrollBar);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Shows ScrollBar");
                        }
                        ImGui.NextColumn();

                        ImGui.Checkbox("Lock Window Position", ref config.NoMove);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the position of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("Lock Window Size", ref config.NoResize);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Lock/Unlock the size of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Tab Bar", ref config.NoMouse);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Tab Bar of the Chat Extender");
                        }
                        ImGui.NextColumn();
                        ImGui.Checkbox("ClickThrough Chat", ref config.NoMouse2);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Enable/Disable being able to clickthrough the Chat Extension chatbox");
                        }


                        ImGui.Columns(1);

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 30);
                        ImGui.SliderFloat("Chat Extender Alpha", ref config.Alpha, 0.001f, 0.999f);
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Alter the Alpha of the Chat Extender");
                        }

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 50);
                        ImGui.Checkbox("Debug", ref debug);
                        if (debug)
                        {
                            ImGui.Checkbox("Output Error Json", ref outputErrorJsons);
                            ImGui.Checkbox("Output All Json", ref outputAllJsons);
                            ImGui.Text($"Lines in chat buffer: {chatBuffer.Count()}");
                            ImGui.Text($"Lines in current filter: {activeTab.FilteredLogs.Count()}");
                        }

                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Channels"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                        ImGui.Columns(4);
                        ImGui.Text("Setting"); ImGui.NextColumn();
                        ImGui.Text("Example"); ImGui.NextColumn();
                        ImGui.Text("Color 1"); ImGui.NextColumn();
                        ImGui.Text("Color 2"); ImGui.NextColumn();

                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();
                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();
                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();
                        ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 10); ImGui.NextColumn();

                        ImGui.Text("Time"); ImGui.NextColumn();

                        var cursorPos = ImGui.GetCursorPos();
                        ImGui.PushFont(outlineFont);
                        ImGui.TextColored(config.TimeShadowColor, "[12:00]");
                        ImGui.PopFont();

                        ImGui.SetCursorPos(cursorPos);
                        ImGui.PushFont(font);
                        ImGui.TextColored(config.TimeColor, "[12:00]");
                        ImGui.PopFont();

                        ImGui.NextColumn();


                        ImGui.ColorEdit4("Time Color", ref config.TimeColorRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();

                        ImGui.ColorEdit4("Time Outline Color", ref config.TimeColorShadowRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();

                        foreach (var key in ChannelSettingsTable.Keys)
                        {
                            var channelSettings = ChannelSettingsTable[key];
                            ImGui.PushItemWidth(50);
                            ImGui.InputText(channelSettings.Name, ref channelSettings.ShortName, 8); ImGui.NextColumn();
                            ImGui.PopItemWidth();

                            cursorPos = ImGui.GetCursorPos();
                            ImGui.PushFont(outlineFont);
                            ImGui.TextColored(channelSettings.OutlineColor, "[" + channelSettings.Name + "]");
                            ImGui.PopFont();
                            ImGui.SetCursorPos(cursorPos);

                            ImGui.PushFont(font);
                            ImGui.TextColored(channelSettings.FontColor, "[" + channelSettings.Name + "]"); ImGui.NextColumn();
                            ImGui.PopFont();

                            ImGui.ColorEdit4(channelSettings.Name + " Font Color", ref channelSettings.FontColorRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                            ImGui.ColorEdit4(channelSettings.Name + " Outline Color", ref channelSettings.OutlineColorRef.Color, ImGuiColorEditFlags.NoInputs | ImGuiColorEditFlags.NoLabel); ImGui.NextColumn();
                        }

                        ImGui.Columns(1);
                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Tabs"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                        if (ImGui.Button("Add New Tab"))
                        {
                            int i = 1;
                            while (tabs.Any(x => x.Title == $"New Tab ({i})"))
                            {
                                i++;
                            }

                            tabs.Add(new TabBase
                            {
                                Title   = $"New Tab ({i})",
                                Enabled = true
                            });
                            tempTitle = "Title";
                        }
                        if (ImGui.IsItemHovered())
                        {
                            ImGui.SetTooltip("Add a new Tab to the Chat Extender");
                        }

                        if (ImGui.TreeNode("Tab Order"))
                        {
                            ImGui.Columns(3);
                            ImGui.Text("Tab"); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();
                            ImGui.Text(""); ImGui.NextColumn();

                            for (int i = 0; i < tabs.Count; i++)
                            {
                                ImGui.Text(tabs[i].Title); ImGui.NextColumn();
                                if (i > 0)
                                {
                                    if (ImGui.Button("^##" + i.ToString()))
                                    {
                                        TabBase temp = tabs[i];
                                        tabs.RemoveAt(i);
                                        tabs.Insert(i - 1, temp);
                                    }
                                }
                                ImGui.NextColumn();
                                if (i < tabs.Count - 1)
                                {
                                    if (ImGui.Button("v##" + i.ToString()))
                                    {
                                        TabBase temp = tabs[i];
                                        tabs.RemoveAt(i);
                                        tabs.Insert(i + 1, temp);
                                    }
                                }
                                ImGui.NextColumn();
                            }
                            ImGui.Columns(1);
                            ImGui.TreePop();
                        }

                        ImGui.Separator();
                        foreach (var tab in tabs)
                        {
                            if (ImGui.TreeNode(tab.Title))
                            {
                                float footer2 = (ImGui.GetStyle().ItemSpacing.Y) / 2 + ImGui.GetFrameHeightWithSpacing();
                                ImGui.BeginChild("scrolling", new Vector2(0, -footer2), false);
                                ImGui.InputText("##Tab Name", ref tempTitle, bufSize);
                                ImGui.SameLine();
                                if (ImGui.Button("Set Tab Title"))
                                {
                                    if (tempTitle.Length == 0)
                                    {
                                        tempTitle += ".";
                                    }

                                    while (CheckDupe(tabs, tempTitle))
                                    {
                                        tempTitle += ".";
                                    }

                                    tab.Title = tempTitle;
                                    tempTitle = "Title";
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Change the title of the Tab");
                                }

                                ImGui.Columns(4);

                                ImGui.Checkbox("Time Stamp", ref tab.Timestamps);
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Show Timestamps in this Tab");
                                }
                                ImGui.NextColumn();
                                ImGui.Checkbox("Channel", ref tab.ShowChannelTagAll);
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Show the Channel the message came from");
                                }
                                ImGui.NextColumn();
                                ImGui.Checkbox("AutoScroll", ref tab.AutoScroll);
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Enable the Chat to scroll automatically on a new message");
                                }
                                ImGui.NextColumn();
                                if (ImGui.Checkbox("Enable Filter", ref tab.FilterOn))
                                {
                                    tab.UpdateFilteredLines();
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Enable Filtering of text");
                                }
                                ImGui.NextColumn();
                                ImGui.Columns(1);


                                //TODO: Add a confirm prompt

                                if (tabs.Count > 1)
                                {
                                    if (ImGui.Button("Delete Tab"))
                                    {
                                        tab.Enabled = false;
                                        tabs        = tabs.Where(x => x.Enabled).ToList();
                                        if (!activeTab.Enabled)
                                        {
                                            activeTab = tabs[0];
                                        }
                                    }
                                }
                                if (ImGui.IsItemHovered())
                                {
                                    ImGui.SetTooltip("Removes Tab");
                                }


                                ImGui.Columns(2);
                                ImGui.Text("Channel"); ImGui.NextColumn();
                                if (tab.ShowChannelTagAll)
                                {
                                    ImGui.Text("Show Short");
                                }
                                else
                                {
                                    ImGui.Text("");
                                }
                                ImGui.NextColumn();

                                foreach (var channelId in ChannelSettingsTable.Keys)
                                {
                                    var channelSettings = ChannelSettingsTable[channelId];
                                    var channelName     = channelSettings.Name;

                                    ImGui.PushStyleColor(ImGuiCol.Text, channelSettings.FontColor);

                                    if (ImGui.Checkbox("[" + channelSettings.Name + "]", ref tab.EnabledChannels[channelName].Value) && tab == activeTab)
                                    {
                                        tab.UpdateFilteredLines();
                                    }
                                    ImGui.NextColumn();

                                    if (tab.ShowChannelTagAll)
                                    {
                                        if (ImGui.Checkbox(channelSettings.ShortName, ref tab.ShowChannelTag[channelSettings.Name].Value))
                                        {
                                            tab.needsRecomputeCumulativeLengths = true;
                                        }
                                    }
                                    else
                                    {
                                        ImGui.Text("");
                                    }
                                    ImGui.NextColumn();

                                    ImGui.PopStyleColor();
                                }

                                ImGui.Columns(1);
                                ImGui.EndChild();
                                ImGui.TreePop();
                            }
                        }
                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (ImGui.BeginTabItem("Font"))
                    {
                        ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                        ImGui.Columns(1);
                        ImGui.PushItemWidth(124);
                        ImGui.InputFloat("Font Size", ref config.FontSize); ImGui.SameLine();
                        ImGui.PopItemWidth();
                        if (ImGui.SmallButton("Apply"))
                        {
                            UpdateFonts();
                        }

                        ImGui.EndChild();
                        ImGui.EndTabItem();
                    }

                    if (debug)
                    {
                        if (ImGui.BeginTabItem("Style Editor"))
                        {
                            ImGui.BeginChild("scrolling", new Vector2(0, -footer), false);
                            ImGui.ShowStyleEditor();
                            ImGui.EndChild();
                            ImGui.EndTabItem();
                        }
                    }
                }

                ImGui.EndTabBar();

                if (ImGui.Button("Save and Close Config"))
                {
                    SaveConfig();

                    configWindow = false;
                }
                if (ImGui.IsItemHovered())
                {
                    ImGui.SetTooltip("Changes will only be saved for the current session unless you do this!");
                }
                ImGui.End();
            }
        }
Ejemplo n.º 5
0
        public static void Render(Area Area)
        {
            CheatWindow.Render();
            AreaDebug.Render(Area);
            DebugWindow.Render();

            imgui.LocaleEditor.Render();
            debug.PoolEditor.Render();
            state.ItemEditor.Render();
            RenderSettings();
            Lights.RenderDebug();
            SaveDebug.RenderDebug();
            LevelLayerDebug.Render();
            LootTableEditor.Render();
            assets.achievements.Achievements.RenderDebug();

            RunStatistics.RenderDebug();

            if (Rooms && ImGui.Begin("Rooms", ImGuiWindowFlags.AlwaysAutoResize))
            {
                var p = LocalPlayer.Locate(Area);

                if (p != null)
                {
                    var rm = p.GetComponent <RoomComponent>().Room;
                    var rn = new List <Room>();

                    foreach (var r in Area.Tagged[Tags.Room])
                    {
                        rn.Add((Room)r);
                    }

                    rn.Sort((a, b) => a.Type.CompareTo(b.Type));

                    foreach (var r in rn)
                    {
                        var v = rm == r;

                        if (ImGui.Selectable($"{r.Type}#{r.Y}", ref v) && v)
                        {
                            p.Center = r.Center;
                        }
                    }
                }

                ImGui.End();
            }

            ImGui.SetNextWindowPos(new Vector2(Engine.Instance.GetScreenWidth() - size.X - 10, Engine.Instance.GetScreenHeight() - size.Y - 10));
            ImGui.Begin("Windows", ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoTitleBar);

            if (ImGui.Button("Hide"))
            {
                Debug = Entities = RunInfo = Console = ItemEditor = LevelEditor = LocaleEditor = Rooms = Settings = PoolEditor = LootTable = false;
            }

            ImGui.SameLine();

            if (ImGui.Button("Show"))
            {
                Debug = Entities = RunInfo = Console = ItemEditor = LevelEditor = LocaleEditor = Rooms = Settings = PoolEditor = LootTable = true;
            }

            ImGui.Separator();

            ImGui.Checkbox("Cheats", ref Cheats);
            ImGui.Checkbox("Entities", ref Entities);
            ImGui.Checkbox("Run Info", ref RunInfo);
            ImGui.Checkbox("Console", ref Console);
            ImGui.Checkbox("Item Editor", ref ItemEditor);
            ImGui.Checkbox("Level Editor", ref LevelEditor);
            ImGui.Checkbox("Layer Debug", ref LayerDebug);
            ImGui.Checkbox("Locale Editor", ref LocaleEditor);
            ImGui.Checkbox("Debug", ref Debug);
            ImGui.Checkbox("Rooms", ref Rooms);
            ImGui.Checkbox("Settings", ref Settings);
            ImGui.Checkbox("Lighting", ref Lighting);
            ImGui.Checkbox("Achievements", ref Achievements);
            ImGui.Checkbox("Save", ref Save);
            ImGui.Checkbox("Pool Editor", ref PoolEditor);
            ImGui.Checkbox("Loot Table Editor", ref LootTable);

            size = ImGui.GetWindowSize();
            ImGui.End();
        }
Ejemplo n.º 6
0
        private void ShowRomWindow(float opacity)
        {
            ImGui.SetNextWindowPos(new Vector2(0, 0), ImGuiCond.Once);
            ImGui.SetNextWindowSize(new Vector2(500, 50), ImGuiCond.Once);
            ImGui.SetNextWindowBgAlpha(opacity);

            ImGui.Begin("ROM", ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize |
                        ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);

            var games       = _pinMameController.GetGames();
            var currentGame = _pinMameController.CurrentGame;

            var text = "";

            if (currentGame != null)
            {
                text = $"{currentGame.Name} - {currentGame.Description}";
            }
            else
            {
                text = (games.Count > 0) ? "Select..." : "No Games Found";
            }

            if (ImGui.BeginCombo("", text))
            {
                foreach (var game in games)
                {
                    bool isSelected = currentGame != null && currentGame.Name == game.Name;

                    if (ImGui.Selectable($"{game.Name} - {game.Description}", isSelected))
                    {
                        if (!_pinMameController.IsRunning)
                        {
                            _pinMameController.CurrentGame = game;
                        }
                    }

                    if (isSelected)
                    {
                        ImGui.SetItemDefaultFocus();
                    }
                }

                ImGui.EndCombo();
            }

            if (!_pinMameController.IsRunning)
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, .39f, 0, 1));
                if (ImGui.Button("Start"))
                {
                    _pinMameController.Start();
                }
                ImGui.PopStyleColor();
            }
            else
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(1, 0, 0, 1));
                if (ImGui.Button("Stop"))
                {
                    _pinMameController.Stop();
                }
                ImGui.PopStyleColor();

                ImGui.SameLine();

                if (ImGui.Button("Reset"))
                {
                    _pinMameController.Reset();
                }
            }

            ImGui.End();
        }
Ejemplo n.º 7
0
        public void OnGui(GameType game)
        {
            uint[] sdrawgroups = null;
            uint[] sdispgroups = null;
            var    sel         = _selection.GetSingleFilteredSelection <Entity>();

            if (sel != null)
            {
                if (sel.UseDrawGroups)
                {
                    sdrawgroups = sel.Drawgroups;
                }
                sdispgroups = sel.Dispgroups;
            }

            ImGui.SetNextWindowSize(new Vector2(100, 100));
            if (ImGui.Begin("Display Groups"))
            {
                var dg    = _scene.DisplayGroup;
                var count = (game == GameType.DemonsSouls || game == GameType.DarkSoulsPTDE || game == GameType.DarkSoulsIISOTFS) ? 4 : 8;
                if (dg.AlwaysVisible || dg.Drawgroups.Length != count)
                {
                    dg.Drawgroups = new uint[count];
                    for (int i = 0; i < count; i++)
                    {
                        dg.Drawgroups[i] = 0xFFFFFFFF;
                    }
                    dg.AlwaysVisible = false;
                }

                if (ImGui.Button("Check All"))
                {
                    for (int i = 0; i < count; i++)
                    {
                        dg.Drawgroups[i] = 0xFFFFFFFF;
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Uncheck All"))
                {
                    for (int i = 0; i < count; i++)
                    {
                        dg.Drawgroups[i] = 0;
                    }
                }
                ImGui.SameLine();
                if (ImGui.Button("Set from Selected") && sdispgroups != null)
                {
                    for (int i = 0; i < count; i++)
                    {
                        dg.Drawgroups[i] = sdispgroups[i];
                    }
                }

                for (int g = 0; g < dg.Drawgroups.Length; g++)
                {
                    ImGui.Text($@"Display Group {g}: ");
                    for (int i = 0; i < 32; i++)
                    {
                        bool check = ((dg.Drawgroups[g] >> i) & 0x1) > 0;
                        ImGui.SameLine();
                        bool red   = sdrawgroups != null && (((sdrawgroups[g] >> i) & 0x1) > 0);
                        bool green = sdispgroups != null && (((sdispgroups[g] >> i) & 0x1) > 0);
                        if (red)
                        {
                            ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0.4f, 0.06f, 0.06f, 1.0f));
                            ImGui.PushStyleColor(ImGuiCol.CheckMark, new Vector4(1.0f, 0.2f, 0.2f, 1.0f));
                        }
                        else if (green)
                        {
                            ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(0.02f, 0.3f, 0.02f, 1.0f));
                            ImGui.PushStyleColor(ImGuiCol.CheckMark, new Vector4(0.2f, 1.0f, 0.2f, 1.0f));
                        }
                        if (ImGui.Checkbox($@"##dispgroup{g}{i}", ref check))
                        {
                            if (check)
                            {
                                dg.Drawgroups[g] |= (1u << i);
                            }
                            else
                            {
                                dg.Drawgroups[g] &= ~(1u << i);
                            }
                        }
                        if (red || green)
                        {
                            ImGui.PopStyleColor(2);
                        }
                    }
                }
            }
            ImGui.End();
        }
        public bool Draw()
        {
            ImGui.SetNextWindowSize(new Vector2(420, 420), ImGuiCond.FirstUseEver);
            if (ImGui.Begin(ImGuiExt.IDWithExtra($"{name}: {scriptName}", unique), ref open))
            {
                if (string.IsNullOrEmpty(map.ChildName))
                {
                    ImGui.Text($"Target: {map.ParentName}");
                }
                else
                {
                    ImGui.Text($"Parent Name: {map.ParentName}");
                    ImGui.Text($"Child Name: {map.ChildName}");
                }
                ImGui.Text($"Interval: {map.Channel.Interval}");
                ImGui.Text($"Frame Count: {map.Channel.FrameCount}");
                ImGui.Text($"Type: {map.Channel.InterpretedType} (0x{map.Channel.ChannelType.ToString("x")})");
                if (map.Channel.InterpretedType == FrameType.Quaternion ||
                    map.Channel.InterpretedType == FrameType.VecWithQuat)
                {
                    ImGui.Text($"Quaternion Storage: {map.Channel.QuaternionMethod}");
                }
                ImGui.Separator();
                ImGui.BeginChild("##values");
                ImGui.Columns(2);
                float iT = 0;
                for (int i = 0; i < map.Channel.FrameCount; i++)
                {
                    float t = 0;
                    if (map.Channel.Interval > 0)
                    {
                        t   = iT;
                        iT += map.Channel.Interval;
                    }
                    else
                    {
                        t = map.Channel.Times[i];
                    }
                    ImGui.Text(t.ToString());
                    ImGui.NextColumn();
                    switch (map.Channel.InterpretedType)
                    {
                    case FrameType.Float:
                        ImGui.Text(map.Channel.Angles[i].ToString());
                        break;

                    case FrameType.Vector3:
                        ImGui.Text(map.Channel.Positions[i].ToString());
                        break;

                    case FrameType.Quaternion:
                        ImGui.Text(map.Channel.Quaternions[i].ToString());
                        break;

                    case FrameType.VecWithQuat:
                        ImGui.Text($"{map.Channel.Positions[i]} {map.Channel.Quaternions[i]}");
                        break;
                    }
                    ImGui.NextColumn();
                }
                ImGui.EndChild();
                ImGui.End();
            }
            else
            {
                return(false);
            }
            return(open);
        }
Ejemplo n.º 9
0
        internal override void Display()
        {
            //resources list include refined or seperate?
            //factories/installations list - expandable to show health and disable/enable specific installations
            //mining stats pannel.
            //refinary panel, expandable?
            //construction pannel, expandable?
            //constructed but not installed components.
            //installation pannel (install constructed components
            if (IsActive)
            {
                if (ImGui.Begin("Cargo", ref IsActive, _flags))
                {
                    if (_storeVM != null)
                    {
                        /*
                         * ImGui.BeginGroup();
                         * foreach (var storetype in _storeVM.CargoResourceStores)
                         * {
                         *  if (ImGui.CollapsingHeader(storetype.HeaderText + "###" + storetype.StorageTypeName, ImGuiTreeNodeFlags.CollapsingHeader))
                         *  {
                         *      foreach (var item in storetype.CargoItems)
                         *      {
                         *          ImGui.Text(item.ItemName);
                         *          ImGui.SameLine();
                         *          ImGui.Text(item.ItemWeightPerUnit);
                         *          ImGui.SameLine();
                         *          ImGui.Text(item.NumberOfItems);
                         *          ImGui.SameLine();
                         *          ImGui.Text(item.TotalWeight);
                         *
                         *      }
                         *
                         *  }
                         * }
                         * ImGui.EndGroup();
                         */
                        _cargoList.Display();
                    }


                    if (_refineryVM != null)
                    {
                        if (ImGui.CollapsingHeader("Refinary"))
                        {
                            ImGui.PushStyleVar(ImGuiStyleVar.ChildRounding, 4f);
                            ImGui.BeginChild("Current Jobs", new System.Numerics.Vector2(280, 100), true, ImGuiWindowFlags.ChildWindow);

                            foreach (var job in _refineryVM.CurrentJobs.ToArray())
                            {
                                bool selected = false;
                                if (job == _refineryVM.CurrentJobSelectedItem)
                                {
                                    selected = true;
                                }

                                if (ImGui.Selectable(job.SingleLineText, ref selected))
                                {
                                    _refineryVM.CurrentJobSelectedItem = job;
                                }

                                if (job.Repeat)
                                {
                                    ImGui.SameLine();
                                    ImGui.Image(_state.SDLImageDictionary["RepeatImg"], new Vector2(16, 16));
                                }
                            }
                            ImGui.EndChild();
                            ImGui.SameLine();

                            ImGui.BeginChild("Buttons", new System.Numerics.Vector2(116, 100), true, ImGuiWindowFlags.ChildWindow);
                            ImGui.BeginGroup();
                            if (ImGui.ImageButton(_state.SDLImageDictionary["UpImg"], new Vector2(16, 8)))
                            {
                                _refineryVM.CurrentJobSelectedItem.ChangePriority(-1);
                            }
                            if (ImGui.ImageButton(_state.SDLImageDictionary["DnImg"], new Vector2(16, 8)))
                            {
                                _refineryVM.CurrentJobSelectedItem.ChangePriority(1);
                            }
                            ImGui.EndGroup();
                            ImGui.SameLine();
                            if (ImGui.ImageButton(_state.SDLImageDictionary["RepeatImg"], new Vector2(16, 16)))
                            {
                                _refineryVM.CurrentJobSelectedItem.ChangeRepeat(!_refineryVM.CurrentJobSelectedItem.Repeat);
                            }
                            ImGui.SameLine();
                            if (ImGui.ImageButton(_state.SDLImageDictionary["CancelImg"], new Vector2(16, 16)))
                            {
                                _refineryVM.CurrentJobSelectedItem.CancelJob();
                            }



                            ImGui.EndGroup();

                            ImGui.EndChild();

                            ImGui.BeginChild("CreateJob", new System.Numerics.Vector2(0, 84), true, ImGuiWindowFlags.ChildWindow);

                            int curItem = _refineryVM.NewJobSelectedIndex;
                            if (ImGui.Combo("NewJobSelection", ref curItem, _refineryVM.ItemDictionary.DisplayList.ToArray(), _refineryVM.ItemDictionary.Count))
                            {
                                _refineryVM.ItemDictionary.SelectedIndex = curItem;
                            }
                            int batchCount = _refineryVM.NewJobBatchCount;
                            if (ImGui.InputInt("Batch Count", ref batchCount))
                            {
                                _refineryVM.NewJobBatchCount = (ushort)batchCount;
                            }
                            bool repeatJob = _refineryVM.NewJobRepeat;
                            if (ImGui.Checkbox("Repeat Job", ref repeatJob))
                            {
                                _refineryVM.NewJobRepeat = repeatJob;
                            }
                            ImGui.SameLine();
                            if (ImGui.Button("Create New Job"))
                            {
                                _refineryVM.OnNewBatchJob();
                            }

                            ImGui.EndChild();
                            ImGui.PopStyleVar();
                        }
                    }
                }
                ImGui.End();
            }
        }
Ejemplo n.º 10
0
        protected override void Draw(double elapsed)
        {
            VertexBuffer.TotalDrawcalls = 0;
            EnableTextInput();
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            //
            if (world != null)
            {
                if (wireFrame)
                {
                    RenderState.Wireframe = true;
                }
                world.Renderer.Draw();
                RenderState.Wireframe = false;
            }
            //
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            //Main Menu
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var folder = FileDialog.ChooseFolder();
                    if (folder != null)
                    {
                        if (GameConfig.CheckFLDirectory(folder))
                        {
                            openLoad = true;
                            LoadData(folder);
                        }
                        else
                        {
                            //Error dialog
                        }
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            if (world != null)
            {
                if (ImGui.MenuItem("Change System (F6)"))
                {
                    sysIndex         = sysIndexLoaded;
                    openChangeSystem = true;
                }
            }
            if (ImGui.BeginMenu("View"))
            {
                if (ImGui.MenuItem("Debug Text", "", showDebug, true))
                {
                    showDebug = !showDebug;
                }
                if (ImGui.MenuItem("Wireframe", "", wireFrame, true))
                {
                    wireFrame = !wireFrame;
                }
                if (ImGui.MenuItem("Infocard", "", infocardOpen, true))
                {
                    infocardOpen = !infocardOpen;
                }
                if (ImGui.MenuItem("VSync", "", vSync, true))
                {
                    vSync = !vSync;
                    SetVSync(vSync);
                }
                ImGui.EndMenu();
            }
            var h = ImGui.GetWindowHeight();

            ImGui.EndMainMenuBar();
            //Other Windows
            if (world != null)
            {
                if (showDebug)
                {
                    ImGui.SetNextWindowPos(new Vector2(0, h), ImGuiCond.Always, Vector2.Zero);

                    ImGui.Begin("##debugWindow", ImGuiWindowFlags.NoTitleBar |
                                ImGuiWindowFlags.NoMove | ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBringToFrontOnFocus);
                    ImGui.Text(string.Format(DEBUG_TEXT, curSystem.Name, curSystem.Nickname,
                                             camera.Position.X, camera.Position.Y, camera.Position.Z,
                                             DebugDrawing.SizeSuffix(GC.GetTotalMemory(false)), (int)Math.Round(RenderFrequency), VertexBuffer.TotalDrawcalls, VertexBuffer.TotalBuffers));
                    ImGui.End();
                }
                ImGui.SetNextWindowSize(new Vector2(100, 100), ImGuiCond.FirstUseEver);
                if (infocardOpen)
                {
                    if (ImGui.Begin("Infocard", ref infocardOpen))
                    {
                        var szX = Math.Max(20, ImGui.GetWindowWidth());
                        var szY = Math.Max(20, ImGui.GetWindowHeight());
                        if (icard == null)
                        {
                            icard = new InfocardControl(this, systemInfocard, szX);
                        }
                        icard.Draw(szX);
                    }
                    ImGui.End();
                }
            }
            //dialogs must be children of window or ImGui default "Debug" window appears
            if (openChangeSystem)
            {
                ImGui.OpenPopup("Change System");
                openChangeSystem = false;
            }
            bool popupopen = true;

            if (ImGui.BeginPopupModal("Change System", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Combo("System", ref sysIndex, systems, systems.Length);
                if (ImGui.Button("Ok"))
                {
                    if (sysIndex != sysIndexLoaded)
                    {
                        camera.UpdateProjection();
                        camera.Free = false;
                        camera.Zoom = 5000;
                        Resources.ClearTextures();
                        curSystem      = GameData.GetSystem(systems[sysIndex]);
                        systemInfocard = GameData.GetInfocard(curSystem.Infocard, fontMan);
                        if (icard != null)
                        {
                            icard.SetInfocard(systemInfocard);
                        }
                        GameData.LoadAllSystem(curSystem);
                        world.LoadSystem(curSystem, Resources);
                        sysIndexLoaded = sysIndex;
                    }
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("Cancel"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            if (openLoad)
            {
                ImGui.OpenPopup("Loading");
                openLoad = false;
            }
            popupopen = true;
            if (ImGui.BeginPopupModal("Loading", ref popupopen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                if (world != null)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Loading");
                ImGui.EndPopup();
            }
            ImGui.PopFont();
            guiHelper.Render(RenderState);
        }
Ejemplo n.º 11
0
        public override void Draw()
        {
            bool doTabs = false;

            popups.Run();
            HardpointEditor();
            PartEditor();
            foreach (var t in openTabs)
            {
                if (t)
                {
                    doTabs = true; break;
                }
            }
            var contentw = ImGui.GetWindowContentRegionWidth();

            if (doTabs)
            {
                ImGui.Columns(2, "##panels", true);
                if (firstTab)
                {
                    ImGui.SetColumnWidth(0, contentw * 0.23f);
                    firstTab = false;
                }
                ImGui.BeginChild("##tabchild");
                if (openTabs[0])
                {
                    HierarchyPanel();
                }
                if (openTabs[1])
                {
                    AnimationPanel();
                }
                if (openTabs[2])
                {
                    SkeletonPanel();
                }
                if (openTabs[3])
                {
                    RenderPanel();
                }
                ImGui.EndChild();
                ImGui.NextColumn();
            }
            TabButtons();
            ImGui.BeginChild("##main");
            ViewerControls.DropdownButton("View Mode", ref viewMode, viewModes);
            ImGui.SameLine();
            ImGui.Checkbox("Background", ref doBackground);
            ImGui.SameLine();
            if (!(drawable is SphFile)) //Grid too small for planets lol
            {
                ImGui.Checkbox("Grid", ref showGrid);
                ImGui.SameLine();
            }
            if (hasVWire)
            {
                ImGui.Checkbox("VMeshWire", ref drawVMeshWire);
                ImGui.SameLine();
            }
            ImGui.Checkbox("Wireframe", ref doWireframe);
            DoViewport();
            //
            var camModes = (cameraPart != null) ? camModesCockpit : camModesNormal;

            ViewerControls.DropdownButton("Camera Mode", ref selectedCam, camModes);
            modelViewport.Mode = (CameraModes)(camModes[selectedCam].Tag);
            ImGui.SameLine();
            if (ImGui.Button("Reset Camera (Ctrl+R)"))
            {
                ResetCamera();
            }
            ImGui.SameLine();
            //
            if (!(drawable is SphFile) && !(drawable is DF.DfmFile))
            {
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Level of Detail:");
                ImGui.SameLine();
                ImGui.Checkbox("Use Distance", ref useDistance);
                ImGui.SameLine();
                ImGui.PushItemWidth(-1);
                if (useDistance)
                {
                    ImGui.SliderFloat("Distance", ref levelDistance, 0, maxDistance, "%f", 1);
                }
                else
                {
                    ImGui.Combo("Level", ref level, levels, levels.Length);
                }
                ImGui.PopItemWidth();
            }
            ImGui.EndChild();

            if (_window.Config.ViewButtons)
            {
                ImGui.SetNextWindowPos(new Vector2(_window.Width - viewButtonsWidth, 90));
                ImGui.Begin("viewButtons#" + Unique, ImGuiWindowFlags.AlwaysAutoResize |
                            ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoMove);
                ImGui.Dummy(new Vector2(120, 2));
                ImGui.Columns(2, "##border", false);
                if (ImGui.Button("Top", new Vector2(55, 0)))
                {
                    modelViewport.GoTop();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Bottom", new Vector2(55, 0)))
                {
                    modelViewport.GoBottom();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Left", new Vector2(55, 0)))
                {
                    modelViewport.GoLeft();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Right", new Vector2(55, 0)))
                {
                    modelViewport.GoRight();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Front", new Vector2(55, 0)))
                {
                    modelViewport.GoFront();
                }
                ImGui.NextColumn();
                if (ImGui.Button("Back", new Vector2(55, -1)))
                {
                    modelViewport.GoBack();
                }
                viewButtonsWidth = ImGui.GetWindowWidth() + 60;
                ImGui.End();
            }
        }
Ejemplo n.º 12
0
        public static void RenderDebug()
        {
            if (!WindowManager.Achievements)
            {
                return;
            }

            if (selected != null)
            {
                RenderSelectedInfo();
            }

            ImGui.SetNextWindowSize(size, ImGuiCond.Once);

            if (!ImGui.Begin("Achievements"))
            {
                ImGui.End();
                return;
            }

            if (ImGui.Button("New"))
            {
                ImGui.OpenPopup("New achievement");
            }

            ImGui.SameLine();

            if (ImGui.Button("Save"))
            {
                Log.Info("Saving achievements");
                Save();
            }

            if (ImGui.BeginPopupModal("New achievement"))
            {
                ImGui.PushItemWidth(300);
                ImGui.InputText("Id", ref achievementName, 64);
                ImGui.PopItemWidth();

                if (ImGui.Button("Create") || Input.Keyboard.WasPressed(Keys.Enter, true))
                {
                    Defined[achievementName] = selected = new Achievement(achievementName);
                    achievementName          = "";
                    forceFocus = true;

                    ImGui.CloseCurrentPopup();
                }

                ImGui.SameLine();

                if (ImGui.Button("Cancel") || Input.Keyboard.WasPressed(Keys.Escape, true))
                {
                    achievementName = "";
                    ImGui.CloseCurrentPopup();
                }

                ImGui.EndPopup();
            }

            ImGui.Separator();

            if (ImGui.Button("Unlock all"))
            {
                foreach (var a in Defined.Keys)
                {
                    Unlock(a);
                }
            }

            ImGui.SameLine();

            if (ImGui.Button("Lock all"))
            {
                foreach (var a in Defined.Keys)
                {
                    Lock(a);
                }
            }

            ImGui.Separator();
            ImGuiHelper.filter2.Draw("Search");

            ImGui.SameLine();
            ImGui.Text($"{count}");
            count = 0;

            ImGui.Checkbox("Hide unlocked", ref hideUnlocked);
            ImGui.SameLine();
            ImGui.Checkbox("Hide locked", ref hideLocked);
            ImGui.Separator();

            var height = ImGui.GetStyle().ItemSpacing.Y;

            ImGui.BeginChild("ScrollingRegionItems", new System.Numerics.Vector2(0, -height),
                             false, ImGuiWindowFlags.HorizontalScrollbar);

            foreach (var i in Defined.Values)
            {
                ImGui.PushID(i.Id);

                if (forceFocus && i == selected)
                {
                    ImGui.SetScrollHereY();
                    forceFocus = false;
                }

                if (ImGuiHelper.filter2.PassFilter(i.Id))
                {
                    if ((hideLocked && !i.Unlocked) || (hideUnlocked && i.Unlocked))
                    {
                        continue;
                    }

                    count++;

                    if (ImGui.Selectable(i.Id, i == selected))
                    {
                        selected = i;

                        if (ImGui.IsMouseDown(1))
                        {
                            if (ImGui.Button("Give"))
                            {
                                LocalPlayer.Locate(Engine.Instance.State.Area)
                                ?.GetComponent <InventoryComponent>()
                                .Pickup(Items.CreateAndAdd(
                                            selected.Id, Engine.Instance.State.Area
                                            ), true);
                            }
                        }
                    }
                }

                ImGui.PopID();
            }

            ImGui.EndChild();
            ImGui.End();
        }
Ejemplo n.º 13
0
        private static void RenderSelectedInfo()
        {
            var open = true;

            if (!ImGui.Begin("Achievement", ref open, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.End();
                return;
            }

            if (!open)
            {
                selected = null;
                ImGui.End();

                return;
            }

            ImGui.Text(selected.Id);
            ImGui.Separator();

            ImGui.InputText("Unlocks", ref selected.Unlock, 128);
            ImGui.InputText("Group", ref selected.Group, 128);

            ImGui.InputInt("Max progress", ref selected.Max);
            ImGui.Checkbox("Secret", ref selected.Secret);

            var u = selected.Unlocked;

            if (ImGui.Checkbox("Unlocked", ref u))
            {
                if (u)
                {
                    Unlock(selected.Id);
                }
                else
                {
                    Lock(selected.Id);
                }
            }

            ImGui.SameLine();

            if (ImGui.Button("Delete##ach"))
            {
                Defined.Remove(selected.Id);
                selected = null;

                ImGui.End();
                return;
            }

            ImGui.Separator();

            var k    = $"ach_{selected.Id}";
            var name = Locale.Get(k);

            if (ImGui.InputText("Name##ac", ref name, 64))
            {
                Locale.Map[k] = name;
            }

            var key  = $"ach_{selected.Id}_desc";
            var desc = Locale.Get(key);

            if (ImGui.InputText("Description##ac", ref desc, 256))
            {
                Locale.Map[key] = desc;
            }

            ImGui.End();
        }
Ejemplo n.º 14
0
        public void UpdateFrame(SharpDX.Direct3D11.Device device, TimeSpan deltaTime, ref MouseState mouse)
        {
            var nextSize = new Vector2(200, 200);

            ImGui.SetNextWindowSize(ref nextSize, ImGuiCond.FirstUseEver);
            var padding = Vector2.Zero;

            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, ref padding);
            if (ImGui.Begin(m_name))
            {
                var size        = ImGui.GetContentRegionAvail();
                var pos         = ImGui.GetWindowPos();
                var frameHeight = ImGui.GetFrameHeight();
                var localMouse  = ImGui.GetMousePos() - pos - new Vector2(0, frameHeight);
                var width       = (int)size.X;
                var height      = (int)size.Y;
                if (localMouse.X >= 0 && localMouse.Y >= 0 && localMouse.X < size.X && localMouse.Y < size.Y)
                {
                    m_mouse = mouse;
                    // cursor on view
                    m_mouse.X = (int)localMouse.X;
                    m_mouse.Y = (int)localMouse.Y;
                }

                m_camera.MouseInput(m_mouse, width, height);

                // update
                m_im3d.Set();
                Im3d.Im3dGui_NewFrame(ref m_camera.state, ref m_mouse, (float)deltaTime.TotalSeconds, -1);
                Im3d.Gizmo("gizmo", ref m_model.M11);
                Im3d.EndFrame();


                if (m_renderTexture != null)
                {
                    var desc = m_renderTexture.Description;
                    if (desc.Width != width || desc.Height != height)
                    {
                        m_renderTexture.Dispose();
                        m_renderTexture = null;

                        m_srv.Dispose();
                        m_srv = null;
                    }
                }
                if (m_renderTexture == null)
                {
                    m_renderTexture = new Texture2D(device, new Texture2DDescription
                    {
                        Format            = SharpDX.DXGI.Format.B8G8R8X8_UNorm,
                        ArraySize         = 1,
                        MipLevels         = 1,
                        Width             = width,
                        Height            = height,
                        SampleDescription = new SharpDX.DXGI.SampleDescription
                        {
                            Count   = 1,
                            Quality = 0
                        },
                        BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource
                    });

                    m_srv = new ShaderResourceView(device, m_renderTexture);

                    m_rt.FromTexture(device, m_renderTexture);
                }
                m_rt.Setup(device, m_clearColor);

                // render
                ImGui.DX11_DrawTeapot(device.ImmediateContext.NativePointer, ref m_camera.state.viewProjection.M11, ref m_model.M11);

                // im3d
                Im3d.Im3d_DX11_Draw(device.ImmediateContext.NativePointer, ref m_camera.state.viewProjection.M11,
                                    (int)m_camera.state.viewportWidth,
                                    (int)m_camera.state.viewportHeight,
                                    Im3d.GetDrawLists(), (int)Im3d.GetDrawListCount().Value);

                //
                // show render target
                //
                var uv0  = Vector2.Zero;
                var uv1  = Vector2.One;
                var bg   = new Vector4(1, 1, 1, 1);
                var tint = new Vector4(1, 1, 1, 1);
                ImGui.ImageButton(m_srv.NativePointer, ref size, ref uv0, ref uv1, 0, ref bg, ref tint);
            }
            ImGui.End();
            ImGui.PopStyleVar();
        }
Ejemplo n.º 15
0
        public bool DrawConfigUI()
        {
            bool drawConfig = true;

            ImGui.SetNextWindowSizeConstraints(new Vector2(400, 400), new Vector2(1200, 1200));
            if (!ImGui.Begin($"{plugin.Name} - Configuration###cooldownMonitorSetup", ref drawConfig))
            {
                return(drawConfig);
            }
            if (InstallNoticeDismissed != 1)
            {
                ImGui.TextWrapped($"Thank you for installing {plugin.Name}.\nI am currently working on completely rewriting the plugin but please don't hesitate to bring up any issues you have with the current version. Things seem to be relatively stable, but some things may still pop up.");

                if (ImGui.SmallButton("Dismiss"))
                {
                    InstallNoticeDismissed = 1;
                    Save();
                }
                ImGui.Separator();
            }

            ImGui.BeginTabBar("###remindMeConfigTabs");

            if (ImGui.BeginTabItem("Displays"))
            {
                DrawDisplaysTab();
                ImGui.EndTabItem();
            }

            if (MonitorDisplays.Values.Count(d => d.Enabled) > 0)
            {
                if (ImGui.BeginTabItem("Actions"))
                {
                    DrawActionsTab();
                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem("Status Effects"))
                {
                    DrawStatusEffectsTab();
                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem("Raid Effects"))
                {
                    DrawRaidEffectsTab();
                    ImGui.EndTabItem();
                }

                if (ImGui.BeginTabItem("Reminders"))
                {
                    DrawRemindersTab();
                    ImGui.EndTabItem();
                }
            }

#if DEBUG
            if (ImGui.BeginTabItem("Debug"))
            {
                DrawDebugTab();
                ImGui.EndTabItem();
            }
#endif
            ImGui.EndTabBar();
            ImGui.End();

            return(drawConfig);
        }
Ejemplo n.º 16
0
        private void RenderFollowerCommandImgui()
        {
            DateTime emptyDateTime = new DateTime(1, 1, 1, 0, 0, 0, DateTimeKind.Utc);

            var newWindowFlags = ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoBackground |
                                 ImGuiWindowFlags.NoScrollbar;
            string resizeButtonLabel = "Allowing resize";
            string lockButtonLabel   = "Unlocked";

            if (Settings.FollowerCommandsImguiSettings.LockPanel.Value)
            {
                newWindowFlags |= ImGuiWindowFlags.NoMove;
                lockButtonLabel = "Locked";
            }

            if (Settings.FollowerCommandsImguiSettings.NoResize.Value)
            {
                newWindowFlags   |= ImGuiWindowFlags.NoResize;
                resizeButtonLabel = "Restricting resizing";
            }

            ImGui.SetNextWindowBgAlpha(0.35f);
            ImGui.Begin("FollowerV2", newWindowFlags);

            ImGui.TextUnformatted("This window commands");
            ImGui.SameLine();
            if (ImGui.Button(lockButtonLabel))
            {
                Settings.FollowerCommandsImguiSettings.LockPanel.Value = !Settings.FollowerCommandsImguiSettings.LockPanel.Value;
            }
            ImGui.SameLine();
            if (ImGui.Button(resizeButtonLabel))
            {
                Settings.FollowerCommandsImguiSettings.NoResize.Value = !Settings.FollowerCommandsImguiSettings.NoResize.Value;
            }
            ImGui.Spacing();

            int userNumber = 1;

            foreach (var follower in Settings.LeaderModeSettings.FollowerCommandSetting.FollowerCommandsDataSet)
            {
                ImGui.TextUnformatted($"User {userNumber}: {follower.FollowerName}:");
                ImGui.SameLine();
                if (follower.LastTimeEntranceUsedDateTime != emptyDateTime)
                {
                    ImGui.TextUnformatted("E");
                    ImGui.SameLine();
                }
                if (follower.LastTimePortalUsedDateTime != emptyDateTime)
                {
                    ImGui.TextUnformatted(" P");
                    ImGui.SameLine();
                }
                if (follower.LastTimeQuestItemPickupDateTime != emptyDateTime)
                {
                    ImGui.TextUnformatted(" Q");
                    ImGui.SameLine();
                }
                if (follower.LastTimeNormalItemPickupDateTime != emptyDateTime)
                {
                    ImGui.TextUnformatted(" I");
                    ImGui.SameLine();
                }

                if (ImGui.Button($"E##{follower.FollowerName}"))
                {
                    follower.SetToUseEntrance();
                }

                ImGui.SameLine();
                if (ImGui.Button($"P##{follower.FollowerName}"))
                {
                    follower.SetToUsePortal();
                }

                ImGui.SameLine();
                if (ImGui.Button($"QIPick##{follower.FollowerName}"))
                {
                    follower.SetPickupQuestItem();
                }

                ImGui.SameLine();
                if (ImGui.Button($"Del##{follower.FollowerName}"))
                {
                    Settings.LeaderModeSettings.FollowerCommandSetting.RemoveFollower(follower.FollowerName);
                }

                ImGui.SameLine();
                ImGui.TextUnformatted($"I: Ctrl+{userNumber}");

                userNumber++;
            }
            ImGui.Spacing();

            List <FollowerCommandsDataClass> followers = Settings.LeaderModeSettings.FollowerCommandSetting.FollowerCommandsDataSet.ToList();

            ImGui.SameLine();
            ImGui.TextUnformatted($"All:  ");
            ImGui.SameLine();
            if (ImGui.Button("Entrance##AllEntrance"))
            {
                followers.ForEach(f => f.SetToUseEntrance());
            }
            ImGui.SameLine();
            if (ImGui.Button("Portal##AllPortal"))
            {
                followers.ForEach(f => f.SetToUsePortal());
            }
            ImGui.SameLine();
            if (ImGui.Button("PickQuestItem##AllPickQuestItem"))
            {
                followers.ForEach(f => f.SetPickupQuestItem());
            }
            ImGui.Spacing();

            ImGui.Spacing();
            ImGui.End();
        }
Ejemplo n.º 17
0
        private void ShowStylesWindow(float opacity)
        {
            ImGui.SetNextWindowPos(new Vector2(_window.Size.X - 310, (_window.Size.Y - 165) / 2), ImGuiCond.Always);
            ImGui.SetNextWindowSize(new Vector2(310, 165), ImGuiCond.Always);
            ImGui.SetNextWindowBgAlpha(opacity);

            ImGui.Begin("Styles", ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize |
                        ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoBackground);

            var styleChange   = false;
            var paletteChange = false;

            var dmdStyle = _dmdController.DmdStyle;

            float tmpFloat = (float)dmdStyle.DotSize;

            if (ImGui.SliderFloat("Dot Size", ref tmpFloat, 0, 1))
            {
                dmdStyle.DotSize = tmpFloat;

                styleChange = true;
            }

            tmpFloat = (float)dmdStyle.DotRounding;

            if (ImGui.SliderFloat("Dot Rounding", ref tmpFloat, 0, 1))
            {
                dmdStyle.DotRounding = tmpFloat;

                styleChange = true;
            }

            tmpFloat = (float)dmdStyle.DotSharpness;

            if (ImGui.SliderFloat("Dot Sharpness", ref tmpFloat, 0, 1))
            {
                dmdStyle.DotSharpness = tmpFloat;

                styleChange = true;
            }

            tmpFloat = (float)dmdStyle.Brightness;

            if (ImGui.SliderFloat("Brightness", ref tmpFloat, 0, 1))
            {
                dmdStyle.Brightness = tmpFloat;

                styleChange = true;
            }

            tmpFloat = (float)dmdStyle.DotGlow;

            if (ImGui.SliderFloat("Dot Glow", ref tmpFloat, 0, 1))
            {
                dmdStyle.DotGlow = tmpFloat;

                styleChange   = true;
                paletteChange = true;
            }

            tmpFloat = (float)dmdStyle.BackGlow;

            if (ImGui.SliderFloat("Back Glow", ref tmpFloat, 0, 1))
            {
                dmdStyle.BackGlow = tmpFloat;

                styleChange   = true;
                paletteChange = true;
            }

            tmpFloat = (float)dmdStyle.Gamma;

            if (ImGui.SliderFloat("Gamma", ref tmpFloat, 0, 1))
            {
                dmdStyle.Gamma = tmpFloat;

                styleChange = true;
            }

            if (paletteChange)
            {
                _dmdController.InvalidatePalette();
            }

            if (styleChange)
            {
                _dmdController.InvalidateStyle();
            }

            ImGui.End();
        }
Ejemplo n.º 18
0
        protected override void Draw(double elapsed)
        {
            //Don't process all the imgui stuff when it isn't needed
            if (!guiHelper.DoRender(elapsed))
            {
                if (lastFrame != null)
                {
                    lastFrame.BlitToScreen();
                }
                WaitForEvent(); //Yield like a regular GUI program
                return;
            }
            TimeStep = elapsed;
            Viewport.Replace(0, 0, Width, Height);
            RenderState.ClearColor = new Color4(0.2f, 0.2f, 0.2f, 1f);
            RenderState.ClearAll();
            guiHelper.NewFrame(elapsed);
            ImGui.PushFont(ImGuiHelper.Noto);
            ImGui.BeginMainMenuBar();
            if (ImGui.BeginMenu("File"))
            {
                if (Theme.IconMenuItem("New", "new", Color4.White, true))
                {
                    var t = new UtfTab(this, new EditableUtf(), "Untitled");
                    ActiveTab = t;
                    AddTab(t);
                }
                if (Theme.IconMenuItem("Open", "open", Color4.White, true))
                {
                    var f = FileDialog.Open(UtfFilters);
                    OpenFile(f);
                }
                if (ActiveTab == null)
                {
                    Theme.IconMenuItem("Save", "save", Color4.LightGray, false);
                    Theme.IconMenuItem("Save As", "saveas", Color4.LightGray, false);
                }
                else
                {
                    if (Theme.IconMenuItem(string.Format("Save '{0}'", ActiveTab.DocumentName), "saveas", Color4.White, true))
                    {
                        Save();
                    }
                    if (Theme.IconMenuItem("Save As", "saveas", Color4.White, true))
                    {
                        SaveAs();
                    }
                }
                if (Theme.IconMenuItem("Quit", "quit", Color4.White, true))
                {
                    Exit();
                }
                ImGui.EndMenu();
            }
            bool openLoading = false;

            if (ImGui.BeginMenu("View"))
            {
                Theme.IconMenuToggle("Log", "log", Color4.White, ref showLog, true);
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Tools"))
            {
                if (Theme.IconMenuItem("Options", "options", Color4.White, true))
                {
                    showOptions = true;
                }

                if (Theme.IconMenuItem("Resources", "resources", Color4.White, true))
                {
                    AddTab(new ResourcesTab(this, Resources, MissingResources, ReferencedMaterials, ReferencedTextures));
                }
                if (Theme.IconMenuItem("Import Collada", "import", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(ColladaFilters)) != null)
                    {
                        openLoading   = true;
                        finishLoading = false;
                        new Thread(() =>
                        {
                            List <ColladaObject> dae = null;
                            try
                            {
                                dae = ColladaSupport.Parse(input);
                                EnsureUIThread(() => FinishColladaLoad(dae, System.IO.Path.GetFileName(input)));
                            }
                            catch (Exception ex)
                            {
                                EnsureUIThread(() => ColladaError(ex));
                            }
                        }).Start();
                    }
                }
                if (Theme.IconMenuItem("Infocard Browser", "browse", Color4.White, true))
                {
                    string input;
                    if ((input = FileDialog.Open(FreelancerIniFilter)) != null)
                    {
                        AddTab(new InfocardBrowserTab(input, this));
                    }
                }
                ImGui.EndMenu();
            }
            if (ImGui.BeginMenu("Help"))
            {
                if (Theme.IconMenuItem("Topics", "help", Color4.White, true))
                {
                    Shell.OpenCommand("https://wiki.librelancer.net/lanceredit:lanceredit");
                }
                if (Theme.IconMenuItem("About", "about", Color4.White, true))
                {
                    openAbout = true;
                }
                ImGui.EndMenu();
            }
            if (openAbout)
            {
                ImGui.OpenPopup("About");
                openAbout = false;
            }
            if (openError)
            {
                ImGui.OpenPopup("Error");
                openError = false;
            }
            if (openLoading)
            {
                ImGui.OpenPopup("Processing");
            }
            bool pOpen = true;

            if (ImGui.BeginPopupModal("Error", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text("Error:");
                errorText.InputTextMultiline("##etext", new Vector2(430, 200), ImGuiInputTextFlags.ReadOnly);
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("About", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - 64);
                Theme.Icon("reactor_128", Color4.White);
                CenterText(Version);
                CenterText("Callum McGing 2018-2019");
                ImGui.Separator();
                CenterText("Icons from Icons8: https://icons8.com/");
                CenterText("Icons from komorra: https://opengameart.org/content/kmr-editor-icon-set");
                ImGui.Separator();
                var btnW = ImGui.CalcTextSize("OK").X + ImGui.GetStyle().FramePadding.X * 2;
                ImGui.Dummy(Vector2.One);
                ImGui.SameLine(ImGui.GetWindowWidth() / 2 - (btnW / 2));
                if (ImGui.Button("OK"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Processing", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGuiExt.Spinner("##spinner", 10, 2, ImGuiNative.igGetColorU32(ImGuiCol.ButtonHovered, 1));
                ImGui.SameLine();
                ImGui.Text("Processing");
                if (finishLoading)
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            //Confirmation
            if (doConfirm)
            {
                ImGui.OpenPopup("Confirm?##mainwindow");
                doConfirm = false;
            }
            pOpen = true;
            if (ImGui.BeginPopupModal("Confirm?##mainwindow", ref pOpen, ImGuiWindowFlags.AlwaysAutoResize))
            {
                ImGui.Text(confirmText);
                if (ImGui.Button("Yes"))
                {
                    confirmAction();
                    ImGui.CloseCurrentPopup();
                }
                ImGui.SameLine();
                if (ImGui.Button("No"))
                {
                    ImGui.CloseCurrentPopup();
                }
                ImGui.EndPopup();
            }
            var menu_height = ImGui.GetWindowSize().Y;

            ImGui.EndMainMenuBar();
            var size = (Vector2)ImGui.GetIO().DisplaySize;

            size.Y -= menu_height;
            //Window
            MissingResources.Clear();
            ReferencedMaterials.Clear();
            ReferencedTextures.Clear();
            foreach (var tab in tabs)
            {
                ((EditorTab)tab).DetectResources(MissingResources, ReferencedMaterials, ReferencedTextures);
            }
            ImGui.SetNextWindowSize(new Vector2(size.X, size.Y - 25), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, menu_height), ImGuiCond.Always, Vector2.Zero);
            bool childopened = true;

            ImGui.Begin("tabwindow", ref childopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            TabHandler.TabLabels(tabs, ref selected);
            var totalH = ImGui.GetWindowHeight();

            if (showLog)
            {
                ImGuiExt.SplitterV(2f, ref h1, ref h2, 8, 8, -1);
                h1 = totalH - h2 - 24f;
                if (tabs.Count > 0)
                {
                    h1 -= 20f;
                }
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""), new Vector2(-1, h1), false, ImGuiWindowFlags.None);
            }
            else
            {
                ImGui.BeginChild("###tabcontent" + (selected != null ? selected.RenderTitle : ""));
            }
            if (selected != null)
            {
                selected.Draw();
                ((EditorTab)selected).SetActiveTab(this);
            }
            else
            {
                ActiveTab = null;
            }
            ImGui.EndChild();
            if (showLog)
            {
                ImGui.BeginChild("###log", new Vector2(-1, h2), false, ImGuiWindowFlags.None);
                ImGui.Text("Log");
                ImGui.SameLine(ImGui.GetWindowWidth() - 20);
                if (Theme.IconButton("closelog", "x", Color4.White))
                {
                    showLog = false;
                }
                logBuffer.InputTextMultiline("##logtext", new Vector2(-1, h2 - 24), ImGuiInputTextFlags.ReadOnly);
                ImGui.EndChild();
            }
            ImGui.End();
            //Status bar
            ImGui.SetNextWindowSize(new Vector2(size.X, 25f), ImGuiCond.Always);
            ImGui.SetNextWindowPos(new Vector2(0, size.Y - 6f), ImGuiCond.Always, Vector2.Zero);
            bool sbopened = true;

            ImGui.Begin("statusbar", ref sbopened,
                        ImGuiWindowFlags.NoTitleBar |
                        ImGuiWindowFlags.NoSavedSettings |
                        ImGuiWindowFlags.NoBringToFrontOnFocus |
                        ImGuiWindowFlags.NoMove |
                        ImGuiWindowFlags.NoResize);
            if (updateTime > 9)
            {
                updateTime = 0;
                frequency  = RenderFrequency;
            }
            else
            {
                updateTime++;
            }
            string activename = ActiveTab == null ? "None" : ActiveTab.DocumentName;
            string utfpath    = ActiveTab == null ? "None" : ActiveTab.GetUtfPath();

            ImGui.Text(string.Format("FPS: {0} | {1} Materials | {2} Textures | Active: {3} - {4}",
                                     (int)Math.Round(frequency),
                                     Resources.MaterialDictionary.Count,
                                     Resources.TextureDictionary.Count,
                                     activename,
                                     utfpath));
            ImGui.End();
            if (errorTimer > 0)
            {
                ImGuiExt.ToastText("An error has occurred\nCheck the log for details",
                                   new Color4(21, 21, 22, 128),
                                   Color4.Red);
            }
            if (showOptions)
            {
                ImGui.Begin("Options", ref showOptions, ImGuiWindowFlags.AlwaysAutoResize);
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    SetTexFilter();
                    Config.TextureFilter = cFilter;
                }
                ImGui.Combo("Antialiasing", ref cMsaa, msaaStrings, Math.Min(msaaLevels.Length, msaaStrings.Length));
                Config.MSAA = msaaLevels[cMsaa];
                int cm = (int)Config.CameraMode;
                ImGui.Combo("Camera Mode", ref cm, cameraModes, cameraModes.Length);
                Config.CameraMode = (CameraModes)cm;
                ImGui.Checkbox("View Buttons", ref Config.ViewButtons);
                ImGui.Checkbox("Pause When Unfocused", ref Config.PauseWhenUnfocused);
                guiHelper.PauseWhenUnfocused = Config.PauseWhenUnfocused;
                ImGui.End();
            }
            ImGui.PopFont();
            if (lastFrame == null ||
                lastFrame.Width != Width ||
                lastFrame.Height != Height)
            {
                if (lastFrame != null)
                {
                    lastFrame.Dispose();
                }
                lastFrame = new RenderTarget2D(Width, Height);
            }
            lastFrame.BindFramebuffer();
            guiHelper.Render(RenderState);
            RenderTarget2D.ClearBinding();
            lastFrame.BlitToScreen();
            foreach (var tab in toAdd)
            {
                tabs.Add(tab);
                selected = tab;
            }
            toAdd.Clear();
        }
Ejemplo n.º 19
0
        /// <summary>
        /// handles any SetNextWindow* options chosen from a menu
        /// </summary>
        void HandleForcedGameViewParams()
        {
            if (_gameViewForcedSize.HasValue)
            {
                ImGui.SetNextWindowSize(_gameViewForcedSize.Value);
                _gameViewForcedSize = null;
            }

            if (_gameViewForcedPos.HasValue)
            {
                ImGui.Begin(_gameWindowTitle, _gameWindowFlags);
                var windowSize = ImGui.GetWindowSize();
                ImGui.End();

                var pos = new Num.Vector2();
                switch (_gameViewForcedPos.Value)
                {
                case WindowPosition.TopLeft:
                    pos.Y = _mainMenuBarHeight;
                    pos.X = 0;
                    break;

                case WindowPosition.Top:
                    pos.Y = _mainMenuBarHeight;
                    pos.X = (Screen.Width / 2f) - (windowSize.X / 2f);
                    break;

                case WindowPosition.TopRight:
                    pos.Y = _mainMenuBarHeight;
                    pos.X = Screen.Width - windowSize.X;
                    break;

                case WindowPosition.Left:
                    pos.Y = (Screen.Height / 2f) - (windowSize.Y / 2f);
                    pos.X = 0;
                    break;

                case WindowPosition.Center:
                    pos.Y = (Screen.Height / 2f) - (windowSize.Y / 2f);
                    pos.X = (Screen.Width / 2f) - (windowSize.X / 2f);
                    break;

                case WindowPosition.Right:
                    pos.Y = (Screen.Height / 2f) - (windowSize.Y / 2f);
                    pos.X = Screen.Width - windowSize.X;
                    break;

                case WindowPosition.BottomLeft:
                    pos.Y = Screen.Height - windowSize.Y;
                    pos.X = 0;
                    break;

                case WindowPosition.Bottom:
                    pos.Y = Screen.Height - windowSize.Y;
                    pos.X = (Screen.Width / 2f) - (windowSize.X / 2f);
                    break;

                case WindowPosition.BottomRight:
                    pos.Y = Screen.Height - windowSize.Y;
                    pos.X = Screen.Width - windowSize.X;
                    break;
                }

                ImGui.SetNextWindowPos(pos);
                _gameViewForcedPos = null;
            }
        }
Ejemplo n.º 20
0
        //checks wether the planet icon is clicked
        internal void MapClicked(ECSLib.Vector3 worldCoord, MouseButtons button)
        {
            if (button == MouseButtons.Primary)
            {
                LastWorldPointClicked_m = worldCoord;
            }

            if (ActiveWindow != null)
            {
                ActiveWindow.MapClicked(worldCoord, button);
            }

            if (LoadedWindows.ContainsKey(typeof(DistanceRuler)))
            {
                LoadedWindows[typeof(DistanceRuler)].MapClicked(worldCoord, button);
            }

            Dictionary <Guid, EntityState> allEntities = null;

            if (StarSystemStates.ContainsKey(SelectedStarSysGuid))
            {
                allEntities = StarSystemStates[SelectedStarSysGuid].EntityStatesWithNames;
            }
            //gets all entities with a position on the map
            double closestEntityDistInM = double.MaxValue;
            Entity closestEntity        = null;

            //iterates over entities. Compares the next one with the previous closest-to-click one, if next one is closer, set that one as the closest, repeat for all entities.
            if (allEntities != null)
            {
                foreach (var oneEntityState in allEntities)
                {
                    var oneEntity = oneEntityState.Value.Entity;
                    if (oneEntity.HasDataBlob <PositionDB>())
                    {
                        var thisDistanceInM = Math.Sqrt(Math.Pow(oneEntity.GetDataBlob <PositionDB>().AbsolutePosition_m.X - worldCoord.X, 2) + Math.Pow(oneEntity.GetDataBlob <PositionDB>().AbsolutePosition_m.Y - worldCoord.Y, 2));
                        if (thisDistanceInM <= closestEntityDistInM)
                        {
                            closestEntityDistInM = thisDistanceInM;
                            closestEntity        = oneEntity;
                        }
                    }
                }
            }



            //checks if there is a closest entity
            if (closestEntity != null)
            {
                if (closestEntity.HasDataBlob <MassVolumeDB>())
                {
                    int minPixelRadius = 20;


                    //var distanceBetweenMouseAndEntity = Math.Sqrt(Math.Pow(closestEntity.GetDataBlob<PositionDB>().AbsolutePosition_m - worldCoord,2) + Math.Pow(entityPositionInScreenPixels.Y- mousePosInPixels.Y,2));
                    //int distComp = (int)Math.Sqrt(Math.Pow(50,2)/2);

                    if (closestEntityDistInM <= closestEntity.GetDataBlob <MassVolumeDB>().RadiusInM || Camera.WorldDistance(minPixelRadius) >= Distance.MToAU(closestEntityDistInM))
                    {
                        ImGui.Begin("--crash fixer--(this menu`s whole purpose is preventing a ImGui global state related game crash)");

                        EntityClicked(closestEntity.Guid, SelectedStarSysGuid, button);
                        ImGui.End();

                        if (button == MouseButtons.Alt)
                        {
                            _lastContextMenuOpenedEntityGuid = closestEntity.Guid;
                        }
                    }
                }
            }


            if (LoadedWindows.ContainsKey(typeof(ToolBarUI)))
            {
                LoadedWindows[typeof(ToolBarUI)].MapClicked(worldCoord, button);
            }
        }
Ejemplo n.º 21
0
        public void Draw(ref bool isGameViewFocused)
        {
            ImGui.DockSpaceOverViewport(ImGui.GetMainViewport());

            float menuBarHeight = 0;

            if (ImGui.BeginMainMenuBar())
            {
                menuBarHeight = ImGui.GetWindowHeight();

                if (ImGui.BeginMenu("File"))
                {
                    if (ImGui.MenuItem("Exit", "Alt+F4", false, true))
                    {
                        Environment.Exit(0);
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Jump"))
                {
                    if (ImGui.BeginMenu("Faction: " + _faction?.Side ?? "<null reference>"))
                    {
                        foreach (var side in _playableSides)
                        {
                            if (ImGui.MenuItem(side.Side))
                            {
                                _faction = side;
                                ImGui.SetWindowFocus(side.Name);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Map: " + _map.Item2))
                    {
                        foreach (var mapCache in _maps)
                        {
                            if (ImGui.MenuItem(mapCache.Value))
                            {
                                _map = (mapCache.Key, mapCache.Value);
                            }
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.Button("Go!"))
                    {
                        var random   = new Random();
                        var faction2 = _playableSides[random.Next(0, _playableSides.Count())];

                        if (_map.Item1.IsMultiplayer)
                        {
                            _context.Game.StartSkirmishOrMultiPlayerGame(
                                _map.Item1.Name,
                                new EchoConnection(),
                                new PlayerSetting[]
                            {
                                new PlayerSetting(1, $"Faction{_faction.Side}", new ColorRgb(255, 0, 0), 0, PlayerOwner.Player),
                                new PlayerSetting(2, $"Faction{faction2.Side}", new ColorRgb(255, 255, 255), 0, PlayerOwner.EasyAi),
                            },
                                Environment.TickCount,
                                false
                                );
                        }
                        else
                        {
                            _context.Game.StartSinglePlayerGame(_map.Item1.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Windows"))
                {
                    foreach (var view in _views)
                    {
                        if (ImGui.MenuItem(view.DisplayName, null, view.IsVisible, true))
                        {
                            view.IsVisible = true;

                            ImGui.SetWindowFocus(view.Name);
                        }
                    }

                    ImGui.EndMenu();
                }

                if (ImGui.BeginMenu("Preferences"))
                {
                    var isVSyncEnabled = _context.Game.GraphicsDevice.SyncToVerticalBlank;
                    if (ImGui.MenuItem("VSync", null, ref isVSyncEnabled, true))
                    {
                        _context.Game.GraphicsDevice.SyncToVerticalBlank = isVSyncEnabled;
                    }
                    var isFullscreen = _context.Window.Fullscreen;
                    if (ImGui.MenuItem("Fullscreen", "Alt+Enter", ref isFullscreen, true))
                    {
                        _context.Window.Fullscreen = isFullscreen;
                    }
                    ImGui.EndMenu();
                }

                if (_context.Game.Configuration.UseRenderDoc && ImGui.BeginMenu("RenderDoc"))
                {
                    var renderDoc         = Game.RenderDoc;
                    var isRenderDocActive = renderDoc != null;

                    if (ImGui.MenuItem("Trigger Capture", isRenderDocActive))
                    {
                        renderDoc.TriggerCapture();
                    }
                    if (ImGui.BeginMenu("Options", isRenderDocActive))
                    {
                        bool allowVsync = renderDoc.AllowVSync;
                        if (ImGui.Checkbox("Allow VSync", ref allowVsync))
                        {
                            renderDoc.AllowVSync = allowVsync;
                        }
                        bool validation = renderDoc.APIValidation;
                        if (ImGui.Checkbox("API Validation", ref validation))
                        {
                            renderDoc.APIValidation = validation;
                        }
                        int delayForDebugger = (int)renderDoc.DelayForDebugger;
                        if (ImGui.InputInt("Debugger Delay", ref delayForDebugger))
                        {
                            delayForDebugger           = Math.Clamp(delayForDebugger, 0, int.MaxValue);
                            renderDoc.DelayForDebugger = (uint)delayForDebugger;
                        }
                        bool verifyBufferAccess = renderDoc.VerifyBufferAccess;
                        if (ImGui.Checkbox("Verify Buffer Access", ref verifyBufferAccess))
                        {
                            renderDoc.VerifyBufferAccess = verifyBufferAccess;
                        }
                        bool overlayEnabled = renderDoc.OverlayEnabled;
                        if (ImGui.Checkbox("Overlay Visible", ref overlayEnabled))
                        {
                            renderDoc.OverlayEnabled = overlayEnabled;
                        }
                        bool overlayFrameRate = renderDoc.OverlayFrameRate;
                        if (ImGui.Checkbox("Overlay Frame Rate", ref overlayFrameRate))
                        {
                            renderDoc.OverlayFrameRate = overlayFrameRate;
                        }
                        bool overlayFrameNumber = renderDoc.OverlayFrameNumber;
                        if (ImGui.Checkbox("Overlay Frame Number", ref overlayFrameNumber))
                        {
                            renderDoc.OverlayFrameNumber = overlayFrameNumber;
                        }
                        bool overlayCaptureList = renderDoc.OverlayCaptureList;
                        if (ImGui.Checkbox("Overlay Capture List", ref overlayCaptureList))
                        {
                            renderDoc.OverlayCaptureList = overlayCaptureList;
                        }
                        ImGui.EndMenu();
                    }
                    if (ImGui.MenuItem("Launch Replay UI", isRenderDocActive))
                    {
                        renderDoc.LaunchReplayUI();
                    }

                    ImGui.EndMenu();
                }

                DrawTimingControls();

                var fpsText     = $"{ImGui.GetIO().Framerate:N2} FPS";
                var fpsTextSize = ImGui.CalcTextSize(fpsText).X;
                ImGui.SetCursorPosX(ImGui.GetContentRegionAvail().X - fpsTextSize);
                ImGui.Text(fpsText);

                ImGui.EndMainMenuBar();
            }

            foreach (var view in _views)
            {
                view.Draw(ref isGameViewFocused);
            }

            var launcherImage = _context.Game.LauncherImage;

            if (launcherImage != null)
            {
                var launcherImageMaxSize = new Vector2(150, 150);

                var launcherImageSize = SizeF.CalculateSizeFittingAspectRatio(
                    new SizeF(launcherImage.Width, launcherImage.Height),
                    new Size((int)launcherImageMaxSize.X, (int)launcherImageMaxSize.Y));

                const int launcherImagePadding = 10;
                ImGui.SetNextWindowPos(new Vector2(
                                           _context.Window.ClientBounds.Width - launcherImageSize.Width - launcherImagePadding,
                                           menuBarHeight + launcherImagePadding));

                ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, Vector2.Zero);
                ImGui.Begin("LauncherImage", ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoSavedSettings | ImGuiWindowFlags.NoInputs | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration);

                ImGui.Image(
                    _context.ImGuiRenderer.GetOrCreateImGuiBinding(_context.Game.GraphicsDevice.ResourceFactory, launcherImage),
                    new Vector2(launcherImageSize.Width, launcherImageSize.Height),
                    Vector2.Zero,
                    Vector2.One,
                    Vector4.One,
                    Vector4.Zero);

                ImGui.End();
                ImGui.PopStyleVar();
            }
        }
Ejemplo n.º 22
0
        public bool Draw()
        {
            bool doDraw = true;

            ImGui.PushID("DalamudPluginStatWindow");
            ImGui.Begin("Plugin Statistics", ref doDraw);
            ImGui.BeginTabBar("Stat Tabs");

            if (ImGui.BeginTabItem("Draw times"))
            {
                bool doStats = UiBuilder.DoStats;

                if (ImGui.Checkbox("Enable Draw Time Tracking", ref doStats))
                {
                    UiBuilder.DoStats = doStats;
                }

                if (doStats)
                {
                    ImGui.SameLine();
                    if (ImGui.Button("Reset"))
                    {
                        foreach (var a in this.pluginManager.Plugins)
                        {
                            a.PluginInterface.UiBuilder.lastDrawTime = -1;
                            a.PluginInterface.UiBuilder.maxDrawTime  = -1;
                            a.PluginInterface.UiBuilder.drawTimeHistory.Clear();
                        }
                    }


                    ImGui.Columns(4);
                    ImGui.SetColumnWidth(0, 180f);
                    ImGui.SetColumnWidth(1, 100f);
                    ImGui.SetColumnWidth(2, 100f);
                    ImGui.SetColumnWidth(3, 100f);
                    ImGui.Text("Plugin");
                    ImGui.NextColumn();
                    ImGui.Text("Last");
                    ImGui.NextColumn();
                    ImGui.Text("Longest");
                    ImGui.NextColumn();
                    ImGui.Text("Average");
                    ImGui.NextColumn();
                    ImGui.Separator();
                    foreach (var a in this.pluginManager.Plugins)
                    {
                        ImGui.Text(a.Definition.Name);
                        ImGui.NextColumn();
                        ImGui.Text($"{a.PluginInterface.UiBuilder.lastDrawTime/10000f:F4}ms");
                        ImGui.NextColumn();
                        ImGui.Text($"{a.PluginInterface.UiBuilder.maxDrawTime/10000f:F4}ms");
                        ImGui.NextColumn();
                        if (a.PluginInterface.UiBuilder.drawTimeHistory.Count > 0)
                        {
                            ImGui.Text($"{a.PluginInterface.UiBuilder.drawTimeHistory.Average()/10000f:F4}ms");
                        }
                        else
                        {
                            ImGui.Text("-");
                        }
                        ImGui.NextColumn();
                    }

                    ImGui.Columns(1);
                }
                ImGui.EndTabItem();
            }

            if (ImGui.BeginTabItem("Framework times"))
            {
                var doStats = Framework.StatsEnabled;

                if (ImGui.Checkbox("Enable Framework Update Tracking", ref doStats))
                {
                    Framework.StatsEnabled = doStats;
                }

                if (doStats)
                {
                    ImGui.SameLine();
                    if (ImGui.Button("Reset"))
                    {
                        Framework.StatsHistory.Clear();
                    }

                    ImGui.Columns(4);
                    ImGui.SetColumnWidth(0, ImGui.GetWindowContentRegionWidth() - 300);
                    ImGui.SetColumnWidth(1, 100f);
                    ImGui.SetColumnWidth(2, 100f);
                    ImGui.SetColumnWidth(3, 100f);
                    ImGui.Text("Method");
                    ImGui.NextColumn();
                    ImGui.Text("Last");
                    ImGui.NextColumn();
                    ImGui.Text("Longest");
                    ImGui.NextColumn();
                    ImGui.Text("Average");
                    ImGui.NextColumn();
                    ImGui.Separator();
                    ImGui.Separator();

                    foreach (var handlerHistory in Framework.StatsHistory)
                    {
                        if (handlerHistory.Value.Count == 0)
                        {
                            continue;
                        }
                        ImGui.SameLine();
                        ImGui.Text($"{handlerHistory.Key}");
                        ImGui.NextColumn();
                        ImGui.Text($"{handlerHistory.Value.Last():F4}ms");
                        ImGui.NextColumn();
                        ImGui.Text($"{handlerHistory.Value.Max():F4}ms");
                        ImGui.NextColumn();
                        ImGui.Text($"{handlerHistory.Value.Average():F4}ms");
                        ImGui.NextColumn();
                        ImGui.Separator();
                    }
                    ImGui.Columns(0);
                }

                ImGui.EndTabItem();
            }

            if (ImGui.BeginTabItem("Hooks"))
            {
                ImGui.Columns(3);
                ImGui.SetColumnWidth(0, ImGui.GetWindowContentRegionWidth() - 280);
                ImGui.SetColumnWidth(1, 180f);
                ImGui.SetColumnWidth(2, 100f);
                ImGui.Text("Detour Method");
                ImGui.SameLine();
                ImGui.Text("   ");
                ImGui.SameLine();
                ImGui.Checkbox("Show Dalamud Hooks ###showDalamudHooksCheckbox", ref showDalamudHooks);
                ImGui.NextColumn();
                ImGui.Text("Address");
                ImGui.NextColumn();
                ImGui.Text("Status");
                ImGui.NextColumn();
                ImGui.Separator();
                ImGui.Separator();

                foreach (var trackedHook in HookInfo.TrackedHooks)
                {
                    try {
                        if (!this.showDalamudHooks && trackedHook.Assembly == Assembly.GetExecutingAssembly())
                        {
                            continue;
                        }

                        ImGui.Text($"{trackedHook.Delegate.Target} :: {trackedHook.Delegate.Method.Name}");
                        ImGui.TextDisabled(trackedHook.Assembly.FullName);
                        ImGui.NextColumn();
                        if (!trackedHook.Hook.IsDisposed)
                        {
                            ImGui.Text($"{trackedHook.Hook.Address.ToInt64():X}");
                            if (ImGui.IsItemClicked())
                            {
                                ImGui.SetClipboardText($"{trackedHook.Hook.Address.ToInt64():X}");
                            }

                            var processMemoryOffset = trackedHook.InProcessMemory;
                            if (processMemoryOffset.HasValue)
                            {
                                ImGui.Text($"ffxiv_dx11.exe + {processMemoryOffset:X}");
                                if (ImGui.IsItemClicked())
                                {
                                    ImGui.SetClipboardText($"ffxiv_dx11.exe+{processMemoryOffset:X}");
                                }
                            }
                        }
                        ImGui.NextColumn();

                        if (trackedHook.Hook.IsDisposed)
                        {
                            ImGui.Text("Disposed");
                        }
                        else
                        {
                            ImGui.Text(trackedHook.Hook.IsEnabled ? "Enabled" : "Disabled");
                        }

                        ImGui.NextColumn();
                    } catch (Exception ex) {
                        ImGui.Text(ex.Message);
                        ImGui.NextColumn();
                        while (ImGui.GetColumnIndex() != 0)
                        {
                            ImGui.NextColumn();
                        }
                    }

                    ImGui.Separator();
                }

                ImGui.Columns();
            }

            if (ImGui.IsWindowAppearing())
            {
                HookInfo.TrackedHooks.RemoveAll(h => h.Hook.IsDisposed);
            }

            ImGui.EndTabBar();

            ImGui.End();
            ImGui.PopID();

            return(doDraw);
        }
Ejemplo n.º 23
0
        private void RenderUI()
        {
            ImGuiWindowFlags chat_window_flags     = 0;
            ImGuiWindowFlags chat_sub_window_flags = 0;

            if (no_titlebar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoTitleBar;
            }
            if (no_collapse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoCollapse;
            }
            if (!no_menu)
            {
                chat_window_flags |= ImGuiWindowFlags.MenuBar;
            }
            if (no_nav)
            {
                chat_window_flags |= ImGuiWindowFlags.NoNav;
            }

            if (config.NoScrollBar)
            {
                chat_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (config.NoScrollBar)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoScrollbar;
            }
            if (config.NoMove)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMove;
            }
            if (config.NoResize)
            {
                chat_window_flags |= ImGuiWindowFlags.NoResize;
            }
            if (config.NoMouse)
            {
                chat_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }
            if (config.NoMouse2)
            {
                chat_sub_window_flags |= ImGuiWindowFlags.NoMouseInputs;
            }

            if (fontsLoaded)
            {
                if (hideWithChat && Alpha != 0)
                {
                    if (config.ShowChatWindow)
                    {
                        if (flickback)
                        {
                            config.NoMouse = false;
                            flickback      = false;
                        }
                        ImGui.SetNextWindowSize(new Vector2(200, 100), ImGuiCond.FirstUseEver);
                        ImGui.SetNextWindowBgAlpha(config.Alpha);
                        ImGui.Begin("Another Window", ref config.ShowChatWindow, chat_window_flags);
                        ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags.None;

                        if (ImGui.BeginTabBar("Tabs", tab_bar_flags))
                        {
                            foreach (var tab in tabs)
                            {
                                if (ImGui.BeginTabItem(tab.Title))
                                {
                                    if (tab != activeTab)
                                    {
                                        activeTab = tab;
                                    }

                                    var prevWindowSize = windowSize;
                                    windowSize = ImGui.GetContentRegionMax();

                                    if (windowSize != prevWindowSize)
                                    {
                                        tab.needsRecomputeCumulativeLengths = true;
                                    }

                                    ImGui.PushStyleVar(ImGuiStyleVar.ItemSpacing, new Vector2(0, 0));

                                    RenderChatArea(tab, chat_sub_window_flags);

                                    ImGui.PopStyleVar();

                                    if (config.NoMouse2 && !config.NoMouse)
                                    {
                                        Vector2 vMin = ImGui.GetWindowContentRegionMin();
                                        Vector2 vMax = ImGui.GetWindowContentRegionMax();

                                        vMin.X += ImGui.GetWindowPos().X;
                                        vMin.Y += ImGui.GetWindowPos().Y + 22;
                                        vMax.X += ImGui.GetWindowPos().X - 22;
                                        vMax.Y += ImGui.GetWindowPos().Y;

                                        if (ImGui.IsMouseHoveringRect(vMin, vMax))
                                        {
                                            config.NoMouse = true; flickback = true;
                                        }
                                    }
                                    tab.msg = false;
                                    ImGui.EndTabItem();
                                }
                            }
                            ImGui.EndTabBar();
                            ImGui.End();
                        }
                    }
                }
            }

            RenderConfigWindow();
        }
Ejemplo n.º 24
0
        public void Draw()
        {
            // temporary bugfix for a race condition where it was possible that
            // we would attempt to load the icon before the ImGuiScene was created in dalamud
            // which would fail and lead to this icon being null
            // Hopefully later the UIBuilder API can add an event to notify when it is ready
            if (this.favoriteIcon == null)
            {
                this.favoriteIcon = loader.LoadUIImage("favoriteIcon.png");
                this.settingsIcon = loader.LoadUIImage("settings.png");
            }

            if (!Visible)
            {
                // manually draw this here only if the main window is hidden
                // This is just so the config ui can work independently
                if (SettingsVisible)
                {
                    DrawSettings();
                }
                return;
            }

            var windowTitle = new StringBuilder("Orchestrion");

            if (this.configuration.ShowSongInTitleBar)
            {
                // TODO: subscribe to the event so this only has to be constructed on change?
                var currentSong = this.controller.CurrentSong;
                if (this.songs.ContainsKey(currentSong))
                {
                    windowTitle.Append($" - [{this.songs[currentSong].Id}] {this.songs[currentSong].Name}");
                }
            }
            windowTitle.Append("###Orchestrion");

            ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, new Vector2(370, 150));
            ImGui.SetNextWindowSize(new Vector2(370, 440), ImGuiCond.FirstUseEver);
            // these flags prevent the entire window from getting a secondary scrollbar sometimes, and also keep it from randomly moving slightly with the scrollwheel
            if (ImGui.Begin(windowTitle.ToString(), ref this.visible, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse))
            {
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Search: ");
                ImGui.SameLine();
                ImGui.InputText("##searchbox", ref searchText, 32);

                ImGui.SameLine();
                ImGui.SetCursorPosX(ImGui.GetWindowSize().X - 32);
                ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 1);
                if (ImGui.ImageButton(this.settingsIcon.ImGuiHandle, new Vector2(16, 16)))
                {
                    this.settingsVisible = true;
                }

                ImGui.Separator();

                ImGui.BeginChild("##songlist", new Vector2(0, -35));
                if (ImGui.BeginTabBar("##songlist tabs"))
                {
                    if (ImGui.BeginTabItem("All songs"))
                    {
                        DrawSonglist(false);
                        ImGui.EndTabItem();
                    }
                    if (ImGui.BeginTabItem("Favorites"))
                    {
                        DrawSonglist(true);
                        ImGui.EndTabItem();
                    }
                    ImGui.EndTabBar();
                }
                ImGui.EndChild();

                ImGui.Separator();

                ImGui.Columns(2, "footer columns", false);
                ImGui.SetColumnWidth(-1, ImGui.GetWindowSize().X - 100);

                ImGui.TextWrapped(this.selectedSong > 0 ? this.songs[this.selectedSong].Locations : string.Empty);

                ImGui.NextColumn();

                ImGui.SameLine();
                ImGui.SetCursorPosX(ImGui.GetWindowSize().X - 100);
                ImGui.SetCursorPosY(ImGui.GetWindowSize().Y - 30);

                if (ImGui.Button("Stop"))
                {
                    Stop();
                }

                ImGui.SameLine();
                if (ImGui.Button("Play"))
                {
                    Play(this.selectedSong);
                }

                ImGui.Columns(1);
            }
            ImGui.End();

            ImGui.PopStyleVar();

            DrawSettings();
        }
Ejemplo n.º 25
0
 public bool Draw()
 {
     ImGui.SetNextWindowSize(new Vector2(500, 400), ImGuiCond.FirstUseEver);
     if (ImGui.Begin($"Script##{unique}", ref isOpen))
     {
         if (doUpdate)
         {
             ImGuiHelper.AnimatingElement();          //Stops sleeping when running task on background thread
         }
         ImGui.Text(script.Info.Name);
         ImGui.Separator();
         if (running)
         {
             if (doUpdate)
             {
                 string text = "Running.";
                 var    t    = main.TotalTime - Math.Truncate(main.TotalTime);
                 if (t > 0.66)
                 {
                     text += "..";
                 }
                 else if (t > 0.33)
                 {
                     text += ".";
                 }
                 ImGui.Text(text);
             }
             else
             {
                 ImGui.Text("Finished");
             }
             ImGui.BeginChild($"##SCRIPTlog{unique}");
             ImGui.PushFont(ImGuiHelper.SystemMonospace);
             foreach (var line in lines)
             {
                 ImGui.TextWrapped(line);
             }
             if (lines.Count != lastCount && ImGui.GetScrollY() >= ImGui.GetScrollMaxY())
             {
                 ImGui.SetScrollHereY(1.0f);
             }
             lastCount = lines.Count;
             ImGui.PopFont();
             ImGui.EndChild();
         }
         else
         {
             for (int i = 0; i < arguments.Count; i++)
             {
                 arguments[i].Draw(i);
             }
             ImGui.Separator();
             if (ImGui.Button("Run"))
             {
                 Invoke();
             }
         }
         ImGui.End();
     }
     return(isOpen);
 }
Ejemplo n.º 26
0
        public void DrawSettings()
        {
            if (!this.settingsVisible)
            {
                return;
            }

            var settingsSize = AllowDebug ? new Vector2(490, 270) : new Vector2(490, 120);

            ImGui.SetNextWindowSize(settingsSize, ImGuiCond.Appearing);
            if (ImGui.Begin("Orchestrion Settings", ref this.settingsVisible, ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoCollapse))
            {
                if (ImGui.IsWindowAppearing())
                {
                    this.showDebugOptions = false;
                }

                ImGui.SetNextItemOpen(true, ImGuiCond.Appearing);
                if (ImGui.TreeNode("Display##orch options"))
                {
                    ImGui.Spacing();

                    var showSongInTitlebar = this.configuration.ShowSongInTitleBar;
                    if (ImGui.Checkbox("Show current song in player title bar", ref showSongInTitlebar))
                    {
                        this.configuration.ShowSongInTitleBar = showSongInTitlebar;
                        this.configuration.Save();
                    }

                    var showSongInChat = this.configuration.ShowSongInChat;
                    if (ImGui.Checkbox("Show \"Now playing\" messages in game chat when the current song changes", ref showSongInChat))
                    {
                        this.configuration.ShowSongInChat = showSongInChat;
                        this.configuration.Save();
                    }

                    if (AllowDebug)
                    {
                        ImGui.Checkbox("Show debug options (Only if you have issues!)", ref this.showDebugOptions);
                    }

                    ImGui.TreePop();
                }

                // I'm sure there are better ways to do this, but I didn't want to change global spacing
                ImGui.Spacing();
                ImGui.Spacing();
                ImGui.Spacing();

                if (this.showDebugOptions && AllowDebug)
                {
                    ImGui.SetNextItemOpen(true, ImGuiCond.Appearing);
                    if (ImGui.TreeNode("Debug##orch options"))
                    {
                        ImGui.Spacing();

                        bool useFallbackPlayer = this.controller.EnableFallbackPlayer;
                        if (ImGui.Checkbox("Use fallback player", ref useFallbackPlayer))
                        {
                            this.Stop();
                            // this automatically will validate if we can change this, and save the config if so
                            this.controller.EnableFallbackPlayer = useFallbackPlayer;
                        }
                        ImGui.SameLine();
                        HelpMarker("This uses the old version of the player, in case the new version has problems.\n" +
                                   "You typically should not use this unless the new version does not work at all.\n" +
                                   "(In which case, please report it on discord!)");

                        ImGui.Spacing();

                        int targetPriority = this.configuration.TargetPriority;

                        ImGui.SetNextItemWidth(100.0f);
                        if (ImGui.SliderInt("BGM priority", ref targetPriority, 0, 11))
                        {
                            // stop the current song so it doesn't get 'stuck' on in case we switch to a lower priority
                            this.Stop();

                            this.configuration.TargetPriority = targetPriority;
                            this.configuration.Save();

                            // don't (re)start a song here for now
                        }
                        ImGui.SameLine();
                        HelpMarker("Songs play at various priority levels, from 0 to 11.\n" +
                                   "Songs at lower numbers will override anything playing at a higher number, with 0 winning out over everything else.\n" +
                                   "You can experiment with changing this value if you want the game to be able to play certain music even when Orchestrion is active.\n" +
                                   "(Usually) zone music is 10-11, mount music is 6, GATEs are 4.  There is a lot of variety in this, however.\n" +
                                   "The old Orchestrion used to play at level 3 (it now uses 0 by default).");

                        ImGui.Spacing();
                        if (ImGui.Button("Dump priority info"))
                        {
                            this.controller.DumpDebugInformation();
                        }

                        ImGui.TreePop();
                    }
                }
            }
            ImGui.End();
        }
Ejemplo n.º 27
0
        internal override void Display()
        {
            if (IsActive)
            {
                Vector2 size = new Vector2(200, 100);
                Vector2 pos  = new Vector2(0, 0);

                ImGui.SetNextWindowSize(size, ImGuiCond.FirstUseEver);
                ImGui.SetNextWindowPos(pos, ImGuiCond.Appearing);

                if (ImGui.Begin("Settings", ref IsActive, _flags))
                {
                    bool debugActive = DebugWindow.GetInstance().GetActive();

                    if (ImGui.Checkbox("Show Pulsar Debug Window", ref debugActive))
                    {
                        DebugWindow.GetInstance().ToggleActive();
                    }

                    if (_uiState.LastClickedEntity != null && _uiState.LastClickedEntity.Entity.HasDataBlob <OrbitDB>())
                    {
                        bool orbitDebugActive = _orbitalDebugWindow.GetActive();
                        if (ImGui.Checkbox("Show Orbit Debug Lines", ref orbitDebugActive))
                        {
                            OrbitalDebugWindow.GetInstance().ToggleActive();
                        }
                    }

                    bool sensorActive = SensorDraw.GetInstance().GetActive();
                    if (ImGui.Checkbox("Show Sensor Draw", ref sensorActive))
                    {
                        SensorDraw.GetInstance().ToggleActive();
                    }
                    if (ImGui.Checkbox("Show Pulsar GUI Debug Window", ref debugActive))
                    {
                        DebugGUIWindow.GetInstance().ToggleActive();
                    }

                    bool perfActive = PerformanceDisplay.GetInstance().GetActive();
                    if (ImGui.Checkbox("Show Pulsar Performance Window", ref perfActive))
                    {
                        PerformanceDisplay.GetInstance().ToggleActive();
                    }

                    ImGui.Checkbox("Show ImguiMetrix", ref _uiState.ShowMetrixWindow);
                    ImGui.Checkbox("Show ImgDebug", ref _uiState.ShowImgDbg);
                    ImGui.Checkbox("DemoWindow", ref _uiState.ShowDemoWindow);
                    if (ImGui.Checkbox("DamageWindow", ref _uiState.ShowDamageWindow))
                    {
                        if (_uiState.ShowDamageWindow)
                        {
                            DamageViewer.GetInstance().SetActive();
                        }
                        else
                        {
                            DamageViewer.GetInstance().SetActive(false);
                        }
                    }


                    if (ImGui.CollapsingHeader("Process settings", _xpanderFlags))
                    {
                        if (ImGui.Checkbox("MultiThreaded", ref IsThreaded))
                        {
                            _uiState.Game.Settings.EnableMultiThreading = IsThreaded;
                        }

                        if (ImGui.Checkbox("EnforceSingleThread", ref EnforceSingleThread))
                        {
                            _uiState.Game.Settings.EnforceSingleThread = EnforceSingleThread;
                            if (EnforceSingleThread)
                            {
                                IsThreaded = false;
                                _uiState.Game.Settings.EnableMultiThreading = false;
                            }
                        }

                        if (ImGui.Checkbox("Translate Uses Ralitive Velocity", ref RalitiveOrbitVelocity))
                        {
                            ECSLib.OrbitProcessor.UseRalitiveVelocity = RalitiveOrbitVelocity;
                        }
                        if (ImGui.IsItemHovered())
                        {
                            if (RalitiveOrbitVelocity)
                            {
                                ImGui.SetTooltip("Ships exiting from a non newtonion translation will enter an orbit: \n Using a vector ralitive to it's origin parent");
                            }
                            else
                            {
                                ImGui.SetTooltip("Ships exiting from a non newtonion translation will enter an orbit: \n Using the absolute Vector (ie raltive to the root'sun'");
                            }
                        }
                    }


                    if (ImGui.CollapsingHeader("Map Settings", _xpanderFlags))
                    {
                        for (int i = 0; i < (int)UserOrbitSettings.OrbitBodyType.NumberOf; i++)
                        {
                            UserOrbitSettings.OrbitBodyType otype = (UserOrbitSettings.OrbitBodyType)i;
                            string typeStr = otype.ToString();
                            if (ImGui.TreeNode(typeStr))
                            {
                                float _nameZoomLevel = _uiState.DrawNameZoomLvl[(int)otype];
                                ImGui.SliderFloat("Draw Names at Zoom: ", ref _nameZoomLevel, 0.01f, 10000f);
                                _uiState.DrawNameZoomLvl[(int)otype] = _nameZoomLevel;
                                for (int j = 0; j < (int)UserOrbitSettings.OrbitTrajectoryType.NumberOf; j++)
                                {
                                    UserOrbitSettings.OrbitTrajectoryType trtype = (UserOrbitSettings.OrbitTrajectoryType)j;
                                    string trtypeStr = trtype.ToString();
                                    if (ImGui.TreeNode(trtypeStr))
                                    {
                                        UserOrbitSettings _userOrbitSettings = _userOrbitSettingsMtx[i][j];
                                        int     _arcSegments = _userOrbitSettings.NumberOfArcSegments;
                                        Vector3 _colour      = Helpers.Color(_userOrbitSettings.Red, _userOrbitSettings.Grn, _userOrbitSettings.Blu);
                                        int     _maxAlpha    = _userOrbitSettings.MaxAlpha;
                                        int     _minAlpha    = _userOrbitSettings.MinAlpha;


                                        //TODO: make this a knob/dial? need to create a custom control: https://github.com/ocornut/imgui/issues/942
                                        if (ImGui.SliderAngle("Sweep Angle ##" + i + j, ref _userOrbitSettings.EllipseSweepRadians, 1f, 360f))
                                        {
                                            _uiState.SelectedSysMapRender.UpdateUserOrbitSettings();
                                        }

                                        if (ImGui.SliderInt("Number Of Segments ##" + i + j, ref _arcSegments, 1, 255, _userOrbitSettings.NumberOfArcSegments.ToString()))
                                        {
                                            _userOrbitSettings.NumberOfArcSegments = (byte)_arcSegments;
                                            _uiState.SelectedSysMapRender.UpdateUserOrbitSettings();
                                        }

                                        if (ImGui.ColorEdit3("Orbit Ring Colour ##" + i + j, ref _colour))
                                        {
                                            _userOrbitSettings.Red = Helpers.Color(_colour.X);
                                            _userOrbitSettings.Grn = Helpers.Color(_colour.Y);
                                            _userOrbitSettings.Blu = Helpers.Color(_colour.Z);
                                        }
                                        if (ImGui.SliderInt("Max Alpha ##" + i + j, ref _maxAlpha, _minAlpha, 255, ""))
                                        {
                                            _userOrbitSettings.MaxAlpha = (byte)_maxAlpha;
                                            _uiState.SelectedSysMapRender.UpdateUserOrbitSettings();
                                        }

                                        if (ImGui.SliderInt("Min Alpha  ##" + i + j, ref _minAlpha, 0, _maxAlpha, ""))
                                        {
                                            _userOrbitSettings.MinAlpha = (byte)_minAlpha;
                                            _uiState.SelectedSysMapRender.UpdateUserOrbitSettings();
                                        }
                                    }
                                }
                                ImGui.TreePop();
                            }
                        }
                    }
                }

                ImGui.End();
            }
        }
 public unsafe void PartEditor()
 {
     if (editingPart == null)
     {
         return;
     }
     if (editingPart != null && !partEditorOpen)
     {
         partEditorOpen = true;
         partFirst      = true;
         SetPartValues();
     }
     if (ImGui.Begin("Part Editor##" + editingPart.ChildName, ref partEditorOpen, partFirst ? ImGuiWindowFlags.AlwaysAutoResize : ImGuiWindowFlags.None))
     {
         partFirst = false;
         ImGui.Text(editingPart.ChildName);
         ImGui.Text("Type: " + ModelViewer.ConType(editingPart));
         if (ImGui.Button("Reset"))
         {
             SetPartValues();
         }
         ImGui.Separator();
         ImGui.Text("Position");
         ImGui.InputFloat("X##posX", ref partX, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Y##posY", ref partY, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Z##posZ", ref partZ, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.Separator();
         ImGui.Text("Rotation");
         ImGui.InputFloat("Pitch", ref partPitch, 0.1f, 1f, "%.7f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Yaw", ref partYaw, 0.1f, 1f, "%.7f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.InputFloat("Roll", ref partRoll, 0.1f, 1f, "%.7f", ImGuiInputTextFlags.CharsDecimal);
         ImGui.Separator();
         if (!(editingPart is FixConstruct))
         {
             ImGui.Text("Offset");
             ImGui.InputFloat("X##offX", ref partOX, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Y##offY", ref partOY, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Z##offZ", ref partOZ, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.Separator();
         }
         if ((editingPart is RevConstruct) || (editingPart is PrisConstruct))
         {
             ImGui.Text("Axis");
             ImGui.InputFloat("X##axX", ref partAxX, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Y##axY", ref partAxY, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Z##axZ", ref partAxZ, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Min", ref partMin, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Max", ref partMax, 0.1f, 1f, "%.4f", ImGuiInputTextFlags.CharsDecimal);
             if (ImGui.Button("0"))
             {
                 partPreview = 0;
             }
             ImGui.SameLine();
             ImGui.PushItemWidth(-1);
             if (partMax > partMin)
             {
                 ImGui.SliderFloat("Preview", ref partPreview, partMin, partMax, "%f", 1);
             }
             else
             {
                 ImGui.SliderFloat("Preview", ref partPreview, partMax, partMin, "%f", 1);
             }
             ImGui.PopItemWidth();
             ImGui.Separator();
         }
         if (editingPart is SphereConstruct)
         {
             ImGui.InputFloat("Min1", ref min1, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Max1", ref max1, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Min2", ref min2, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Max2", ref max2, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Min3", ref min3, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.InputFloat("Max3", ref max3, 0.01f, 0.25f, "%.5f", ImGuiInputTextFlags.CharsDecimal);
             ImGui.Separator();
         }
         var jointPreview = Matrix4x4.Identity;
         if (editingPart is RevConstruct)
         {
             jointPreview = Matrix4x4.CreateFromAxisAngle(
                 new Vector3(partAxX, partAxY, partAxZ),
                 MathHelper.DegreesToRadians(partPreview));
         }
         else if (editingPart is PrisConstruct)
         {
             var translate = new Vector3(partAxX, partAxY, partAxZ).Normalized() * partPreview;
             jointPreview = Matrix4x4.CreateTranslation(translate);
         }
         editingPart.OverrideTransform = Matrix4x4.CreateFromYawPitchRoll(
             MathHelper.DegreesToRadians(partPitch),
             MathHelper.DegreesToRadians(partYaw),
             MathHelper.DegreesToRadians(partRoll)) * jointPreview *
                                         Matrix4x4.CreateTranslation(new Vector3(partX, partY, partZ) + new Vector3(partOX, partOY, partOZ));
         if (ImGui.Button("Apply"))
         {
             editingPart.Origin   = new Vector3(partX, partY, partZ);
             editingPart.Rotation = Matrix4x4.CreateFromYawPitchRoll(
                 MathHelper.DegreesToRadians(partYaw),
                 MathHelper.DegreesToRadians(partPitch),
                 MathHelper.DegreesToRadians(partRoll)
                 );
             if (editingPart is RevConstruct)
             {
                 var rev = (RevConstruct)editingPart;
                 rev.Offset       = new Vector3(partOX, partOY, partOZ);
                 rev.AxisRotation = new Vector3(partAxX, partAxY, partAxZ);
                 rev.Min          = MathHelper.DegreesToRadians(partMin);
                 rev.Max          = MathHelper.DegreesToRadians(partMax);
             }
             if (editingPart is PrisConstruct)
             {
                 var pris = (PrisConstruct)editingPart;
                 pris.Offset          = new Vector3(partOX, partOY, partOZ);
                 pris.AxisTranslation = new Vector3(partAxX, partAxY, partAxZ);
                 pris.Min             = partMin;
                 pris.Max             = partMax;
             }
             if (editingPart is SphereConstruct)
             {
                 var sphere = (SphereConstruct)editingPart;
                 sphere.Offset = new Vector3(partOX, partOY, partOZ);
                 sphere.Min1   = min1;
                 sphere.Max1   = max1;
                 sphere.Min2   = min2;
                 sphere.Max2   = max2;
                 sphere.Min3   = min3;
                 sphere.Max3   = max3;
             }
             mv.OnDirtyPart();
         }
         ImGui.SameLine();
         if (ImGui.Button("Cancel"))
         {
             partEditorOpen = false;
         }
         ImGui.End();
     }
     if (!partEditorOpen)
     {
         editingPart.OverrideTransform = null;
         editingPart = null;
     }
 }
Ejemplo n.º 29
0
        public void Draw()
        {
            if (windowOpen)
            {
                ImGui.Begin("Options", ref windowOpen, ImGuiWindowFlags.AlwaysAutoResize);
                ViewerControls.DropdownButton("Default Camera", ref config.DefaultCameraMode, camModesNormal);
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Default Camera");
                var pastC = cFilter;
                ImGui.Combo("Texture Filter", ref cFilter, filters, filters.Length);
                if (cFilter != pastC)
                {
                    SetTexFilter();
                    config.TextureFilter = cFilter;
                }
                ImGui.Combo("Antialiasing", ref cMsaa, msaaStrings, Math.Min(msaaLevels.Length, msaaStrings.Length));
                config.MSAA = msaaLevels[cMsaa];
                ImGui.Checkbox("View Buttons", ref config.ViewButtons);
                ImGui.Checkbox("Pause When Unfocused", ref config.PauseWhenUnfocused);
                if (ViewerControls.GradientButton("Viewport Background", config.Background, config.Background2, new Vector2(22), vps, config.BackgroundGradient))
                {
                    ImGui.OpenPopup("Viewport Background");
                    editCol  = new Vector3(config.Background.R, config.Background.G, config.Background.B);
                    editCol2 = new Vector3(config.Background2.R, config.Background2.G, config.Background2.B);
                    editGrad = config.BackgroundGradient;
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Viewport Background");
                bool wOpen = true;
                if (ImGui.BeginPopupModal("Viewport Background", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.Checkbox("Gradient", ref editGrad);

                    ImGui.ColorPicker3(editGrad ? "Top###a" : "###a", ref editCol);
                    if (editGrad)
                    {
                        ImGui.SameLine();
                        ImGui.ColorPicker3("Bottom###b", ref editCol2);
                    }
                    if (ImGui.Button("OK"))
                    {
                        config.Background         = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        config.Background2        = new Color4(editCol2.X, editCol2.Y, editCol2.Z, 1);
                        config.BackgroundGradient = editGrad;
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue * new Color4(0.3f, 0.3f, 0.3f, 1f);
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Cancel"))
                    {
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.EndPopup();
                }
                if (ImGui.ColorButton("Grid Color", config.GridColor, ImGuiColorEditFlags.NoAlpha, new Vector2(22)))
                {
                    ImGui.OpenPopup("Grid Color");
                    editCol = new Vector3(config.GridColor.R, config.GridColor.G, config.GridColor.B);
                }
                ImGui.SameLine();
                ImGui.AlignTextToFramePadding();
                ImGui.Text("Grid Color");
                if (ImGui.BeginPopupModal("Grid Color", ref wOpen, ImGuiWindowFlags.AlwaysAutoResize))
                {
                    ImGui.ColorPicker3("###a", ref editCol);
                    if (ImGui.Button("OK"))
                    {
                        config.GridColor = new Color4(editCol.X, editCol.Y, editCol.Z, 1);
                        ImGui.CloseCurrentPopup();
                    }
                    ImGui.SameLine();
                    if (ImGui.Button("Default"))
                    {
                        var def = Color4.CornflowerBlue;
                        editCol  = new Vector3(def.R, def.G, def.B);
                        editGrad = false;
                    }
                    ImGui.EndPopup();
                }
                guiHelper.PauseWhenUnfocused = config.PauseWhenUnfocused;
                ImGui.End();
            }
        }
Ejemplo n.º 30
0
        private void BuildDalamudUi()
        {
            if (!this.isImguiDrawDevMenu && !ClientState.Condition.Any())
            {
                ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.ButtonActive, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(0, 0, 0, 0));
                ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.TextSelectedBg, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.Border, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.BorderShadow, new Vector4(0, 0, 0, 1));
                ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0, 0, 0, 1));

                ImGui.SetNextWindowPos(new Vector2(0, 0), ImGuiCond.Always);
                ImGui.SetNextWindowBgAlpha(1);

                if (ImGui.Begin("DevMenu Opener", ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoBackground | ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoSavedSettings))
                {
                    if (ImGui.Button("###devMenuOpener", new Vector2(40, 25)))
                    {
                        this.isImguiDrawDevMenu = true;
                    }

                    ImGui.End();
                }

                ImGui.PopStyleColor(8);
            }

            if (this.isImguiDrawDevMenu)
            {
                if (ImGui.BeginMainMenuBar())
                {
                    if (ImGui.BeginMenu("Dalamud"))
                    {
                        ImGui.MenuItem("Draw Dalamud dev menu", "", ref this.isImguiDrawDevMenu);
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Log window"))
                        {
                            this.logWindow            = new DalamudLogWindow(CommandManager);
                            this.isImguiDrawLogWindow = true;
                        }
                        if (ImGui.BeginMenu("Set log level..."))
                        {
                            foreach (var logLevel in Enum.GetValues(typeof(LogEventLevel)).Cast <LogEventLevel>())
                            {
                                if (ImGui.MenuItem(logLevel + "##logLevelSwitch", "", this.loggingLevelSwitch.MinimumLevel == logLevel))
                                {
                                    this.loggingLevelSwitch.MinimumLevel = logLevel;
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Open Data window"))
                        {
                            this.dataWindow            = new DalamudDataWindow(this);
                            this.isImguiDrawDataWindow = true;
                        }
                        if (ImGui.MenuItem("Open Credits window"))
                        {
                            OnOpenCreditsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Settings window"))
                        {
                            OnOpenSettingsCommand(null, null);
                        }
                        if (ImGui.MenuItem("Open Changelog window"))
                        {
                            OpenChangelog();
                        }
                        ImGui.MenuItem("Draw ImGui demo", "", ref this.isImguiDrawDemoWindow);
                        if (ImGui.MenuItem("Dump ImGui info"))
                        {
                            OnDebugImInfoCommand(null, null);
                        }
                        ImGui.Separator();
                        if (ImGui.MenuItem("Unload Dalamud"))
                        {
                            Unload();
                        }
                        if (ImGui.MenuItem("Kill game"))
                        {
                            Process.GetCurrentProcess().Kill();
                        }
                        if (ImGui.MenuItem("Cause AccessViolation"))
                        {
                            var a = Marshal.ReadByte(IntPtr.Zero);
                        }
                        ImGui.Separator();
                        ImGui.MenuItem(Util.AssemblyVersion, false);
                        ImGui.MenuItem(this.StartInfo.GameVersion, false);

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Game"))
                    {
                        if (ImGui.MenuItem("Replace ExceptionHandler"))
                        {
                            ReplaceExceptionHandler();
                        }

                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Plugins"))
                    {
                        if (ImGui.MenuItem("Open Plugin installer"))
                        {
                            this.pluginWindow            = new PluginInstallerWindow(this, this.StartInfo.GameVersion);
                            this.isImguiDrawPluginWindow = true;
                        }
                        if (ImGui.MenuItem("Open Plugin Stats"))
                        {
                            if (!this.isImguiDrawPluginStatWindow)
                            {
                                this.pluginStatWindow            = new DalamudPluginStatWindow(this.PluginManager);
                                this.isImguiDrawPluginStatWindow = true;
                            }
                        }
                        if (ImGui.MenuItem("Print plugin info"))
                        {
                            foreach (var plugin in this.PluginManager.Plugins)
                            {
                                // TODO: some more here, state maybe?
                                Log.Information($"{plugin.Plugin.Name}");
                            }
                        }
                        if (ImGui.MenuItem("Reload plugins"))
                        {
                            OnPluginReloadCommand(string.Empty, string.Empty);
                        }

                        ImGui.Separator();
                        ImGui.MenuItem("API Level:" + PluginManager.DALAMUD_API_LEVEL, false);
                        ImGui.MenuItem("Loaded plugins:" + PluginManager?.Plugins.Count, false);
                        ImGui.EndMenu();
                    }

                    if (ImGui.BeginMenu("Localization"))
                    {
                        if (ImGui.MenuItem("Export localizable"))
                        {
                            Loc.ExportLocalizable();
                        }

                        if (ImGui.BeginMenu("Load language..."))
                        {
                            if (ImGui.MenuItem("From Fallbacks"))
                            {
                                Loc.SetupWithFallbacks();
                            }

                            if (ImGui.MenuItem("From UICulture"))
                            {
                                this.LocalizationManager.SetupWithUiCulture();
                            }

                            foreach (var applicableLangCode in Localization.ApplicableLangCodes)
                            {
                                if (ImGui.MenuItem($"Applicable: {applicableLangCode}"))
                                {
                                    this.LocalizationManager.SetupWithLangCode(applicableLangCode);
                                }
                            }

                            ImGui.EndMenu();
                        }
                        ImGui.EndMenu();
                    }

                    if (this.Framework.Gui.GameUiHidden)
                    {
                        ImGui.BeginMenu("UI is hidden...", false);
                    }

                    ImGui.EndMainMenuBar();
                }
            }

            if (this.Framework.Gui.GameUiHidden)
            {
                return;
            }

            if (this.isImguiDrawLogWindow)
            {
                this.isImguiDrawLogWindow = this.logWindow != null && this.logWindow.Draw();

                if (this.isImguiDrawLogWindow == false)
                {
                    this.logWindow?.Dispose();
                    this.logWindow = null;
                }
            }

            if (this.isImguiDrawDataWindow)
            {
                this.isImguiDrawDataWindow = this.dataWindow != null && this.dataWindow.Draw();
            }

            if (this.isImguiDrawPluginWindow)
            {
                this.isImguiDrawPluginWindow = this.pluginWindow != null && this.pluginWindow.Draw();
            }

            if (this.isImguiDrawCreditsWindow)
            {
                this.isImguiDrawCreditsWindow = this.creditsWindow != null && this.creditsWindow.Draw();

                if (this.isImguiDrawCreditsWindow == false)
                {
                    this.creditsWindow?.Dispose();
                    this.creditsWindow = null;
                }
            }

            if (this.isImguiDrawSettingsWindow)
            {
                this.isImguiDrawSettingsWindow = this.settingsWindow != null && this.settingsWindow.Draw();
            }

            if (this.isImguiDrawDemoWindow)
            {
                ImGui.ShowDemoWindow();
            }

            if (this.isImguiDrawPluginStatWindow)
            {
                this.isImguiDrawPluginStatWindow = this.pluginStatWindow != null && this.pluginStatWindow.Draw();
                if (!this.isImguiDrawPluginStatWindow)
                {
                    this.pluginStatWindow?.Dispose();
                    this.pluginStatWindow = null;
                }
            }

            if (this.isImguiDrawChangelogWindow)
            {
                this.isImguiDrawChangelogWindow = this.changelogWindow != null && this.changelogWindow.Draw();
            }
        }