コード例 #1
0
ファイル: EntityContextMenu.cs プロジェクト: mqrause/Pulsar4x
        internal void Display()
        {
            ActiveEntity = _entityState.Entity;
            ImGui.BeginGroup();

            void ContextButton(Type T)
            {
                //Creates a context button if it is valid
                if (EntityUIWindows.checkIfCanOpenWindow(T, _entityState))
                {
                    bool buttonresult = ImGui.SmallButton(GlobalUIState.namesForMenus[T]);
                    EntityUIWindows.openUIWindow(T, _entityState, _state, buttonresult, true);
                }
            }

            //Creates all the context buttons
            ContextButton(typeof(SelectPrimaryBlankMenuHelper));
            ContextButton(typeof(PinCameraBlankMenuHelper));
            ContextButton(typeof(RenameWindow));
            ContextButton(typeof(WeaponTargetingControl));
            ContextButton(typeof(CargoTransfer));
            ContextButton(typeof(ColonyPanel));
            ContextButton(typeof(PlanetaryWindow));
            ContextButton(typeof(GotoSystemBlankMenuHelper));
            ContextButton(typeof(WarpOrderWindow));
            ContextButton(typeof(ChangeCurrentOrbitWindow));

            ImGui.EndGroup();
        }
コード例 #2
0
        //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 (_state.LastClickedEntity != null)
                {
                    //Gets the last clicked entity
                    var _entityState = _state.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     = _state.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(WeaponTargetingControl), "Firecon", "Opens firecontrol menu");

                    //Displays all buttons in a list
                    void PrintButtonList(ref List <ToolbuttonData> PrintButtons)
                    {
                        uint iterations = 0;

                        foreach (var button in PrintButtons)
                        {
                            ImGui.SameLine();
                            ImGui.PushID(iterations.ToString());
                            if (ImGui.ImageButton(button.Picture, BtnSizes))
                            {
                                EntityUIWindows.openUIWindow(button.ClickType, _entityState, _state);
                            }
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip(button.TooltipText);
                            }

                            ImGui.PopID();
                            iterations++;
                        }
                        ImGui.NewLine();
                        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, _state, buttonresult);
                            if (ImGui.IsItemHovered())
                            {
                                ImGui.SetTooltip(GlobalUIState.namesForMenus[T]);
                            }
                        }
                    }

                    //Makes all small buttons
                    ActionButton(typeof(PlanetaryWindow));
                    ActionButton(typeof(GotoSystemBlankMenuHelper));
                    ActionButton(typeof(OrbitOrderWindow));
                    ActionButton(typeof(ChangeCurrentOrbitWindow));
                }
                ImGui.End();
            }
        }