Пример #1
0
        public static void Build(float elapsedTime, float offsetX, float offsetY)
        {
            ImGui.GetIO().FontGlobalScale = Main.DPIY;

            ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 7.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowBorderSize, 1.0f);
            ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new System.Numerics.Vector2(14.0f, 8.0f));

            DialogManager.UpdateDialogs();

            if (ImGui.BeginMainMenuBar())
            {
                MenuBar.BuildMenuBar();
                ImGui.EndMainMenuBar();
            }



            ImGui.PushStyleColor(ImGuiCol.WindowBg, new System.Numerics.Vector4(0.15f, 0.15f, 0.15f, Focused ? 1 : 0.65f));
            TooltipManager.PreUpdate(elapsedTime, offsetX, offsetY);

            WindowDebug.Update();
            WindowEditPlayerEquip.Update();
            WindowHelp.Update();
            WindowSceneManager.Update();
            WindowToolbox.Update();
            WindowEntitySettings.Update();


            SpWindowEventInspector.Update();


            ImGui.PopStyleColor();
            ImGui.PopStyleVar(3);
            TooltipManager.PostUpdate();
            IsInit = false;

            RequestExpandAllTreeNodes = false;
            RequestCollapse           = false;


            Focused = ImGui.IsAnyItemFocused() || ImGui.IsWindowFocused(ImGuiFocusedFlags.AnyWindow) || DialogManager.AnyDialogsShowing;
            Hovered = ImGui.IsWindowHovered(ImGuiHoveredFlags.AnyWindow) || ImGui.IsAnyItemHovered();

            if (Focused || Hovered)
            {
                Main.Input.CursorType = MouseCursorType.Arrow;
            }
        }
Пример #2
0
        public static void HandleColor(string name, Func <ColorConfig, Color> getColor, Action <ColorConfig, Color> setColor)
        {
            if (OSD.IsInit)
            {
                if (!DefaultColorValueActions.ContainsKey(name))
                {
                    DefaultColorValueActions.Add(name, () => setColor.Invoke(Main.Colors, getColor(DefaultColorConfig)));
                }
            }

            var color = getColor.Invoke(Main.Colors);

            System.Numerics.Vector4 c = new System.Numerics.Vector4(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);

            //ImGui.ColorEdit4(name, ref c);

            float colorLightness = (0.3086f * c.X + 0.6094f * c.Y + 0.0820f * c.Z) * c.W;

            if (colorLightness > 0.5f)
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(0, 0, 0, 1));
            }
            else
            {
                ImGui.PushStyleColor(ImGuiCol.Text, new System.Numerics.Vector4(1, 1, 1, 1));
            }

            ImGui.PushStyleColor(ImGuiCol.Button, c);
            ImGui.PushStyleColor(ImGuiCol.ButtonHovered, c * 1.25f);
            ImGui.PushStyleColor(ImGuiCol.ButtonActive, c * 0.75f);
            ImGui.Button(name, new System.Numerics.Vector2(ColorButtonWidth, ColorButtonHeight));
            ImGui.PopStyleColor();
            ImGui.PopStyleColor();
            ImGui.PopStyleColor();
            ImGui.PopStyleColor();

            if (ImGui.IsItemClicked(ImGuiMouseButton.Left))
            {
                if (CurrentColorEditorOpen == name)
                {
                    CurrentColorEditorOpen = "";
                }
                else
                {
                    CurrentColorEditorOpen = name;
                }
            }
            else if (ImGui.IsItemClicked(ImGuiMouseButton.Middle))
            {
                color = getColor(DefaultColorConfig);
                c     = new System.Numerics.Vector4(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f);
                setColor.Invoke(Main.Colors, color);
                //if (DefaultColorValueActions.ContainsKey(name))
                //    DefaultColorValueActions[name].Invoke();
            }


            //ImGui.ColorButton(name, c);

            if (CurrentColorEditorOpen == name)
            {
                ImGui.ColorPicker4(name, ref c);
                TooltipManager.DoTooltip($"Color: {name}", "Allows you to adjust the color in detail." +
                                         "\n" +
                                         "\nThe number boxes are as follows:" +
                                         "\n    [R] [G] [B] [A] (Red/Green/Blue/Alpha)" +
                                         "\n    [H] [S] [V] [A] (Hue/Saturation/Value/Alpha)" +
                                         "\n    [ Hexadecimal ] (Hexadecimal representation of the color)");
                ImGui.Separator();
            }

            //if (ImGui.IsItemClicked())
            //{
            //    if (CurrentColorEditorOpen == name)
            //    {
            //        CurrentColorEditorOpen = "";
            //    }
            //    else
            //    {
            //        CurrentColorEditorOpen = name;
            //    }

            //}

            setColor(Main.Colors, new Color(c.X, c.Y, c.Z, c.W));
        }