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(FireControl)); ContextButton(typeof(CargoTransfer)); ContextButton(typeof(ColonyPanel)); ContextButton(typeof(PlanetaryWindow)); ContextButton(typeof(GotoSystemBlankMenuHelper)); ContextButton(typeof(WarpOrderWindow)); ContextButton(typeof(ChangeCurrentOrbitWindow)); ContextButton(typeof(NavWindow)); ImGui.EndGroup(); }
//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(); } }