protected override void RenderContent(RenderComposer composer) { List <Texture> textures = Texture.AllTextures; ImGui.BeginChild("Texture List", new Vector2(500, 600), true); ImGui.BeginListBox("", new Vector2(490, 580)); for (var i = 0; i < textures.Count; i++) { Texture texture = textures[i]; if (ImGui.Button($"{texture.Pointer} - {texture.CreationStack.Substring(0, Math.Min(100, texture.CreationStack.Length))}")) { _selectedTexture = texture; } } ImGui.EndListBox(); ImGui.EndChild(); ImGui.SameLine(); ImGui.BeginChild("Texture", new Vector2(600, 600), true, ImGuiWindowFlags.HorizontalScrollbar); if (_selectedTexture != null) { ImGui.Text(_selectedTexture.CreationStack); int byteSize = (int)(_selectedTexture.Size.X * _selectedTexture.Size.Y) * Gl.PixelTypeToByteCount(_selectedTexture.PixelType) * Gl.PixelFormatToComponentCount(_selectedTexture.PixelFormat); ImGui.Text( $"Dimensions: {_selectedTexture.Size}, Format: {_selectedTexture.PixelFormat}, Memory Usage: {Helpers.FormatByteAmountAsString(byteSize)}, Smooth: {_selectedTexture.Smooth}"); Tuple <Vector2, Vector2> uv = _selectedTexture.GetImGuiUV(); ImGui.Image(new IntPtr(_selectedTexture.Pointer), _selectedTexture.Size, uv.Item1, uv.Item2); } ImGui.EndChild(); }
private void DrawFileListTabEdit() { if (ImGui.BeginTabItem(LabelFileListTab)) { UpdateFilenameList(); if (ImGui.IsItemHovered()) { ImGui.SetTooltip(_editMode ? TooltipFilesTabEdit : TooltipFilesTab); } ImGui.SetNextItemWidth(-1); if (ImGui.BeginListBox(LabelFileListHeader, AutoFillSize - new Vector2(0, 1.5f * ImGui.GetTextLineHeight()))) { for (var i = 0; i < Mod !.Mod.ModFiles.Count; ++i) { DrawFileAndGamePaths(i); } } ImGui.EndListBox(); DrawGroupRow(); ImGui.EndTabItem(); } else { _fullFilenameList = null; } }
/// <summary> /// Interface /// </summary> public virtual void DrawList() { int lineNum = MATH.Utils.Clamp(m_ID2Obj.Count, 0, MaxItemCount); if (lineNum == 0) { return; } bool onMenuEvent = false; ImGui.BeginListBox("##ListBox" + typeof(T), new Vector2(ImGui.GetColumnWidth(), ImGui.GetTextLineHeightWithSpacing() * lineNum) ); foreach (var varPair in m_ID2Obj) { DrawListItem(varPair.Value, out onMenuEvent); if (onMenuEvent) { break; } if (Dragable) { DragVarProc(varPair.Value, out onMenuEvent); if (onMenuEvent) { break; } } //Call menu drawer when drawer is setted MenuDrawer?.DrawMenuView(varPair.Value, out onMenuEvent); if (onMenuEvent) { break; } } ImGui.EndListBox(); }
private void DrawSingleStatusEffectList(string header, bool which, float width) { using var group = ImGuiRaii.NewGroup(); var list = which ? _plugin.StatusSet.DisabledStatusSet : _plugin.StatusSet.EnabledStatusSet; _seenNames.Clear(); if (ImGui.BeginListBox($"##{header}box", width / 2 * Vector2.UnitX)) { for (var i = 0; i < list.Count; ++i) { var(status, name) = list[i]; if (!name.Contains(_statusFilter) || _seenNames.Contains(name)) { continue; } _seenNames.Add(name); if (ImGui.Selectable($"{status.Name}##status{status.RowId}")) { _plugin.StatusSet.Swap((ushort)status.RowId); --i; } } ImGui.EndListBox(); } if (which) { if (ImGui.Button("Disable All Statuses", width / 2 * Vector2.UnitX)) { _plugin.StatusSet.ClearEnabledList(); } } else if (ImGui.Button("Enable All Statuses", width / 2 * Vector2.UnitX)) { _plugin.StatusSet.ClearDisabledList(); } }
private void RenderLayerUI(RenderComposer c) { var layerBarSize = new Vector2(200, 300); ImGui.SetNextWindowPos(new Vector2(c.CurrentTarget.Size.X - layerBarSize.X, TOP_BARS), ImGuiCond.Always); ImGui.SetNextWindowSize(layerBarSize); ImGui.Begin("Layers", ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoResize); if (ImGui.BeginListBox("LayerList", new(layerBarSize.X, layerBarSize.Y - 55))) { if (_map != null) { for (var i = 0; i < _map.TiledMap !.TileLayers.Count; i++) { TmxLayer curLayer = _map.TiledMap.TileLayers[i]; ImGui.MenuItem($"{curLayer.Name} {curLayer.Width}x{curLayer.Height}" + (curLayer.Visible ? "" : " Hidden"), "", i == _selectedLayer); } } ImGui.EndListBox(); } ImGui.End(); }
private void DrawFileSwapTabEdit() { if (!ImGui.BeginTabItem(LabelFileSwapTab)) { return; } ImGui.SetNextItemWidth(-1); if (ImGui.BeginListBox(LabelFileSwapHeader, AutoFillSize)) { var swaps = Meta.FileSwaps.Keys.ToArray(); var arrow = $"{( char )FontAwesomeIcon.LongArrowAltRight}"; ImGui.PushFont(UiBuilder.IconFont); var arrowWidth = ImGui.CalcTextSize(arrow).X; ImGui.PopFont(); var width = (ImGui.GetWindowWidth() - arrowWidth - 4 * ImGui.GetStyle().ItemSpacing.X) / 2; for (var idx = 0; idx < swaps.Length + 1; ++idx) { var key = idx == swaps.Length ? GamePath.GenerateUnchecked("") : swaps[idx]; var value = idx == swaps.Length ? GamePath.GenerateUnchecked("") : Meta.FileSwaps[key]; string keyString = key; string valueString = value; ImGui.SetNextItemWidth(width); if (ImGui.InputTextWithHint($"##swapLhs_{idx}", "Enter new file to be replaced...", ref keyString, GamePath.MaxGamePathLength, ImGuiInputTextFlags.EnterReturnsTrue)) { var newKey = new GamePath(keyString); if (newKey.CompareTo(key) != 0) { if (idx < swaps.Length) { Meta.FileSwaps.Remove(key); } if (newKey != string.Empty) { Meta.FileSwaps[newKey] = value; } _selector.SaveCurrentMod(); if (Mod.Enabled) { _selector.ReloadCurrentMod(); } } } if (idx < swaps.Length) { ImGui.SameLine(); ImGui.PushFont(UiBuilder.IconFont); ImGui.TextUnformatted(arrow); ImGui.PopFont(); ImGui.SameLine(); ImGui.SetNextItemWidth(width); if (ImGui.InputTextWithHint($"##swapRhs_{idx}", "Enter new replacement path...", ref valueString, GamePath.MaxGamePathLength, ImGuiInputTextFlags.EnterReturnsTrue)) { var newValue = new GamePath(valueString); if (newValue.CompareTo(value) != 0) { Meta.FileSwaps[key] = newValue; _selector.SaveCurrentMod(); if (Mod.Enabled) { _selector.ReloadCurrentMod(); } } } } } ImGui.EndListBox(); } ImGui.EndTabItem(); }
/// <summary> /// Creates a ComboBox with a simple text filter /// </summary> /// <param name="label">Widget label</param> /// <param name="currentItem">Item output</param> /// <param name="itemsDictionary">Input dictionary</param> /// <param name="textBuffer">Buffer for text input</param> /// <param name="maxItems">Maximum amount of items displayed vertically</param> /// <returns></returns> private bool ComboWithFilter(string label, ref ushort currentItem, Dictionary <ushort, string> itemsDictionary, byte[] textBuffer, uint maxItems = 5) { var previewValue = itemsDictionary.ContainsKey(currentItem) ? itemsDictionary[currentItem] : string.Empty; Dictionary <ushort, string> items = new(); foreach (var(key, name) in itemsDictionary) { if (name.Contains( Encoding.UTF8.GetString(textBuffer), StringComparison.InvariantCultureIgnoreCase)) { items[key] = name; } } var valueChanged = false; if (!ImGui.BeginCombo(label, previewValue)) { if (textBuffer[0] != 0) { Array.Clear(textBuffer, 0, textBuffer.Length); } this.comboNewOpen = false; return(valueChanged); } ImGui.PushStyleColor(ImGuiCol.FrameBg, new Vector4(240, 240, 240, 255)); ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(0, 0, 0, 255)); ImGui.PushItemWidth(ImGui.GetWindowContentRegionWidth()); if (!this.comboNewOpen) { ImGui.SetKeyboardFocusHere(); this.comboNewOpen = true; } ImGui.InputText("##ComboWithFilter_inputText", textBuffer, (uint)textBuffer.Length); ImGui.PushFont(UiBuilder.IconFont); var iconString = FontAwesomeIcon.Search.ToIconString(); var iconSize = ImGui.CalcTextSize(iconString, true); ImGui.SameLine(); ImGui.SetCursorPosX(ImGui.GetCursorPosX() - iconSize.X - (ImGui.GetStyle().ItemInnerSpacing.X * 3)); ImGui.Text(iconString); ImGui.PopFont(); ImGui.PopStyleColor(2); if (ImGui.BeginListBox( "##ComboWithFilter_itemList", new Vector2( 0, (ImGui.GetTextLineHeightWithSpacing() * maxItems) + (ImGui.GetStyle().FramePadding.Y * 2.0f)))) { foreach (var(key, name) in items) { ImGui.PushID(key); var itemSelected = key == currentItem; if (ImGui.Selectable(name, itemSelected)) { valueChanged = true; currentItem = key; ImGui.CloseCurrentPopup(); } if (itemSelected) { ImGui.SetItemDefaultFocus(); } ImGui.PopID(); } ImGui.EndListBox(); } ImGui.PopItemWidth(); ImGui.EndCombo(); if (!valueChanged) { return(valueChanged); } this.comboNewOpen = false; Array.Clear(textBuffer, 0, textBuffer.Length); return(valueChanged); }