Example #1
0
 /// <summary>
 /// Sets the style color for a particular UI element type.
 /// </summary>
 /// <param name="target">The type of UI element.</param>
 /// <param name="value">The new color.</param>
 public void SetColor(ImGuiCol target, ImVec4 value)
 {
     Native->Colors[(int)target * 4 + 0] = value.X;
     Native->Colors[(int)target * 4 + 1] = value.Y;
     Native->Colors[(int)target * 4 + 2] = value.Z;
     Native->Colors[(int)target * 4 + 3] = value.W;
 }
Example #2
0
            public Color Push(ImGuiCol idx, Vector4 color, bool condition = true)
            {
                if (condition)
                {
                    ImGui.PushStyleColor(idx, color);
                    ++_count;
                }

                return(this);
            }
Example #3
0
        void DisplayButtons(string name, List <ToolbuttonData> DisplayToolButtons)
        {
            if (ImGui.Begin(name, _flags))
            {
                uint     unclickedcolor;
                uint     clickedcolour;
                ImGuiCol buttonidx = ImGuiCol.Button;
                unsafe
                {
                    Vector4 *unclickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.Button);
                    Vector4 *clickedcolorv   = ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive);
                    unclickedcolor = ImGui.ColorConvertFloat4ToU32(*unclickedcolorv);
                    clickedcolour  = ImGui.ColorConvertFloat4ToU32(*clickedcolorv);
                }
                //Store the colors for pressed and unpressed buttons

                uint iterations = 0;
                //displays the default toolbar menu icons
                foreach (var button in DisplayToolButtons)//For each button
                {
                    string id = iterations.ToString();
                    ImGui.PushID(id);

                    if (button.GetActive != null)                           //If the windows state can be checked
                    {
                        if (button.GetActive())                             //If the window is open
                        {
                            ImGui.PushStyleColor(buttonidx, clickedcolour); //Have the button be "pressed"
                        }
                        else//If closed
                        {
                            ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally
                        }
                    }

                    if (ImGui.ImageButton(button.Picture, BtnSizes))//Make the button
                    {
                        button.OnClick();
                    }

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip(button.TooltipText);
                    }


                    ImGui.PopID();
                    iterations++;
                }
                ImGui.PushStyleColor(buttonidx, unclickedcolor);

                ImGui.End();
            }
        }
Example #4
0
 public static void PushStyleColor(ImGuiCol idx, uint col) => PushStyleColorU32(idx, col);
Example #5
0
 public static uint GetColorU32(ImGuiCol idx, float alpha_mul = 1.0f) => GetColorU32Col(idx, alpha_mul);
Example #6
0
 /// <summary>
 /// Gets the current style color for the given UI element type.
 /// </summary>
 /// <param name="target">The type of UI element.</param>
 /// <returns>The element's color as currently configured.</returns>
 public ImVec4 GetColor(ImGuiCol target)
 {
     return(*(ImVec4 *)&Native->Colors[(int)target * 4]);
 }
Example #7
0
 public static void BeginBorder(string label, ImGuiCol colorIdx)
 {
     BeginBorder(label, ImGui.GetColorU32(colorIdx));
 }
Example #8
0
 public static void PushStyleColor(ImGuiCol target, ImVec4 color)
 {
     ImGuiNative.igPushStyleColor(target, color);
 }
Example #9
0
 public abstract byte *igGetStyleColorName(ImGuiCol idx);
Example #10
0
 public abstract Vector4 *igGetStyleColorVec4(ImGuiCol idx);
Example #11
0
 /// <summary>
 /// Gets the current style color for the given UI element type.
 /// </summary>
 /// <param name="target">The type of UI element.</param>
 /// <returns>The element's color as currently configured.</returns>
 public ImVec4 GetColor(ImGuiCol target) => *(ImVec4 *)&Native->Colors[(int)target * 4];
Example #12
0
 public static unsafe Vector4 GetStyleColorVec4Safe(ImGuiCol colorEnum)
 {
     return(*ImGui.GetStyleColorVec4(colorEnum));
 }
Example #13
0
 public ImGuiRaii PushColor(ImGuiCol which, Vector4 color)
 {
     ImGui.PushStyleColor(which, color);
     ++_colorStack;
     return(this);
 }
Example #14
0
 public static Color PushColor(ImGuiCol idx, uint color, bool condition = true)
 => new Color().Push(idx, color, condition);
Example #15
0
 public static void PushStyleColor(ImGuiCol idx, ImVec4 col) => PushStyleColorVec4(idx, col);
        //displays selected entity info



        internal override void Display()
        {
            ImGui.SetNextWindowSize(new Vector2(150, 200), ImGuiCond.Once);
            if (ImGui.Begin("Actions", _flags))
            {
                //check if ANY entity has been clicked
                //if true, display all possible toolbar menu icons for it
                if (_uiState.LastClickedEntity != null)
                {
                    //Gets the last clicked entity
                    var _entityState = _uiState.LastClickedEntity;

                    ToolbuttonData btn;

                    void NewButton(Type T, string PictureString, string TooltipText, List <ToolbuttonData> ButtonList)
                    {
                        //Creates a buttton if it is usuable in this situation
                        if (EntityUIWindows.checkIfCanOpenWindow(T, _entityState))
                        {
                            btn = new ToolbuttonData()
                            {
                                Picture     = _uiState.SDLImageDictionary[PictureString],
                                TooltipText = TooltipText,
                                ClickType   = T
                                              //Opens up the componet design menu
                            };
                            ButtonList.Add(btn);
                        }
                    }

                    void NewCondtionalButton(Type T, string PictureString, string TooltipText)
                    {
                        NewButton(T, PictureString, TooltipText, CondtionalButtons);
                    }

                    void NewStandardButton(Type T, string PictureString, string TooltipText)
                    {
                        NewButton(T, PictureString, TooltipText, StandardButtons);
                    }

                    //Populates Buttons

                    NewStandardButton(typeof(SelectPrimaryBlankMenuHelper), "Select", "Selects the entity");
                    NewStandardButton(typeof(PinCameraBlankMenuHelper), "Pin", "Focuses camera");
                    NewStandardButton(typeof(RenameWindow), "Rename", "Renames the entity");

                    NewCondtionalButton(typeof(PowerGen), "Power", "Shows power stats");
                    NewCondtionalButton(typeof(CargoTransfer), "Cargo", "Shows cargo");
                    NewCondtionalButton(typeof(ColonyPanel), "Industry", "Opens Industry menu");
                    NewCondtionalButton(typeof(FireControl), "Firecon", "Opens firecontrol menu");

                    //Displays all buttons in a list
                    void PrintButtonList(ref List <ToolbuttonData> PrintButtons)
                    {
                        uint     iterations = 0;
                        uint     unclickedcolor;
                        uint     clickedcolour;
                        ImGuiCol buttonidx = ImGuiCol.Button;

                        unsafe
                        {
                            Vector4 *unclickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.Button);
                            Vector4 *clickedcolorv   = ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive);
                            unclickedcolor = ImGui.ColorConvertFloat4ToU32(*unclickedcolorv);
                            clickedcolour  = ImGui.ColorConvertFloat4ToU32(*clickedcolorv);
                        }
                        foreach (var button in PrintButtons)
                        {
                            ImGui.SameLine();
                            ImGui.PushID(iterations.ToString());
                            if (EntityUIWindows.checkopenUIWindow(button.ClickType, _entityState, _uiState)) //If the window is open
                            {
                                ImGui.PushStyleColor(buttonidx, clickedcolour);                              //Have the button be "pressed"
                            }
                            else//If closed
                            {
                                ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally
                            }
                            if (ImGui.ImageButton(button.Picture, BtnSizes))
                            {
                                EntityUIWindows.openUIWindow(button.ClickType, _entityState, _uiState);
                            }

                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip(button.TooltipText);
                            }

                            ImGui.PopID();
                            iterations++;
                        }

                        ImGui.NewLine();
                        ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally
                        PrintButtons = new List <ToolbuttonData>();
                    }

                    //Prints both button lists
                    PrintButtonList(ref StandardButtons);
                    PrintButtonList(ref CondtionalButtons);

                    void ActionButton(Type T)
                    {
                        //Makes a small button if it is usable in this situation
                        if (EntityUIWindows.checkIfCanOpenWindow(T, _entityState))
                        {
                            bool buttonresult = ImGui.SmallButton(GlobalUIState.namesForMenus[T]);
                            EntityUIWindows.openUIWindow(T, _entityState, _uiState, buttonresult);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip(GlobalUIState.namesForMenus[T]);
                            }
                        }
                    }

                    //Makes all small buttons
                    ActionButton(typeof(PlanetaryWindow));
                    ActionButton(typeof(GotoSystemBlankMenuHelper));
                    ActionButton(typeof(WarpOrderWindow));
                    ActionButton(typeof(ChangeCurrentOrbitWindow));
                }
                ImGui.End();
            }
        }
Example #17
0
 public abstract void igPushStyleColorU32(ImGuiCol idx, uint col);
Example #18
0
 public abstract void igPushStyleColor(ImGuiCol idx, Vector4 col);
Example #19
0
 public abstract uint igGetColorU32(ImGuiCol idx, float alpha_mul);
Example #20
0
 static void SetColor(ImGuiCol col, Vector4 rgba)
 {
     ImGui.GetStyle().Colors[(int)col] = rgba;
 }
Example #21
0
        internal override void Display()
        {
            float xpad = 24;
            float ypad = 16;
            float x    = _btnSize + xpad;
            float y    = (_btnSize + ypad) * ToolButtons.Count;



            ImGui.SetNextWindowSize(new Vector2(x, y));
            if (ImGui.Begin("##Toolbar", _flags))
            {
                uint     unclickedcolor;
                uint     clickedcolour;
                ImGuiCol buttonidx = ImGuiCol.Button;
                unsafe
                {
                    Vector4 *unclickedcolorv = ImGui.GetStyleColorVec4(ImGuiCol.Button);
                    Vector4 *clickedcolorv   = ImGui.GetStyleColorVec4(ImGuiCol.ButtonActive);
                    unclickedcolor = ImGui.ColorConvertFloat4ToU32(*unclickedcolorv);
                    clickedcolour  = ImGui.ColorConvertFloat4ToU32(*clickedcolorv);
                }
                //Store the colors for pressed and unpressed buttons

                uint iterations = 0;
                //displays the default toolbar menu icons
                foreach (var button in ToolButtons)//For each button
                {
                    string id = iterations.ToString();
                    ImGui.PushID(id);

                    if (button.GetActive != null)                           //If the windows state can be checked
                    {
                        if (button.GetActive())                             //If the window is open
                        {
                            ImGui.PushStyleColor(buttonidx, clickedcolour); //Have the button be "pressed"
                        }
                        else//If closed
                        {
                            ImGui.PushStyleColor(buttonidx, unclickedcolor);//Have the button be colored normally
                        }
                    }

                    if (ImGui.ImageButton(button.Picture, BtnSizes))//Make the button
                    {
                        button.OnClick();
                    }

                    if (ImGui.IsItemHovered())
                    {
                        ImGui.SetTooltip(button.TooltipText);
                    }


                    ImGui.PopID();
                    iterations++;
                }
                ImGui.PushStyleColor(buttonidx, unclickedcolor);

                ImGui.End();
            }
        }