From 041f1019857e3883682dab918c33648c48aa773d Mon Sep 17 00:00:00 2001 From: Wil <63251107+wilyt1@users.noreply.github.com> Date: Thu, 15 Jun 2023 15:45:59 -0400 Subject: [PATCH 1/3] Fix AutoComplete Menu Max Size --- .../CmdrClient/CmdrInterface/AutoComplete.lua | 21 ++++++++++++++++++- Cmdr/CreateGui.lua | 7 ++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua b/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua index 01486fc..57dc103 100644 --- a/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua +++ b/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua @@ -64,7 +64,15 @@ return function(Cmdr) -- Update container wait() Gui.UIListLayout:ApplyLayout() - Gui.Size = UDim2.new(0, guiWidth, 0, Gui.UIListLayout.AbsoluteContentSize.Y) + Gui.Size = UDim2.new( + 0, + guiWidth, + 0, + math.min( + Gui.UIListLayout.AbsoluteContentSize.Y, + workspace.CurrentCamera.ViewportSize.Y - Gui.AbsolutePosition.Y - 46 + ) + ) end --- Shows the auto complete menu with the given list and possible options @@ -179,6 +187,17 @@ return function(Cmdr) item.gui.BackgroundTransparency = i == self.SelectedItem and 0.5 or 1 end + Gui.CanvasPosition = Vector2.new( + 0, + math.max( + 0, + Title.Size.Y.Offset + + Description.Size.Y.Offset + + self.SelectedItem * AutoItem.Size.Y.Offset + - Gui.Size.Y.Offset + ) + ) + if self.Items[self.SelectedItem] and self.Items[self.SelectedItem].options then UpdateInfoDisplay(self.Items[self.SelectedItem].options or {}) end diff --git a/Cmdr/CreateGui.lua b/Cmdr/CreateGui.lua index 0390a71..ef23958 100644 --- a/Cmdr/CreateGui.lua +++ b/Cmdr/CreateGui.lua @@ -20,14 +20,19 @@ return function() Frame.AutomaticCanvasSize = Enum.AutomaticSize.Y Frame.Parent = Cmdr - local Autocomplete = Instance.new("Frame") + local Autocomplete = Instance.new("ScrollingFrame") Autocomplete.BackgroundColor3 = Color3.fromRGB(59, 59, 59) Autocomplete.BackgroundTransparency = 0.5 Autocomplete.BorderSizePixel = 0 + Autocomplete.CanvasSize = UDim2.new(0, 0, 0, 0) Autocomplete.Name = "Autocomplete" Autocomplete.Position = UDim2.new(0, 167, 0, 75) + Autocomplete.ScrollBarThickness = 6 + Autocomplete.ScrollingDirection = Enum.ScrollingDirection.Y + Autocomplete.Selectable = false Autocomplete.Size = UDim2.new(0, 200, 0, 200) Autocomplete.Visible = false + Autocomplete.AutomaticCanvasSize = Enum.AutomaticSize.Y Autocomplete.Parent = Cmdr local UIListLayout = Instance.new("UIListLayout") From ae329eefa0ae9ea5e534d135a10d78c00c430eb3 Mon Sep 17 00:00:00 2001 From: Wil <63251107+wilyt1@users.noreply.github.com> Date: Thu, 15 Jun 2023 17:19:26 -0400 Subject: [PATCH 2/3] Fix Scroll Bar Flashing Issue --- Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua b/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua index 57dc103..3ab4d40 100644 --- a/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua +++ b/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua @@ -18,6 +18,8 @@ return function(Cmdr) local Entry = Gui.Parent:WaitForChild("Frame"):WaitForChild("Entry") AutoItem.Parent = nil + local defaultBarThickness = Gui.ScrollBarThickness + -- Helper function that sets text and resizes labels local function SetText(obj, textObj, text, sizeFromContents) obj.Visible = text ~= nil @@ -73,6 +75,7 @@ return function(Cmdr) workspace.CurrentCamera.ViewportSize.Y - Gui.AbsolutePosition.Y - 46 ) ) + Gui.ScrollBarThickness = defaultBarThickness end --- Shows the auto complete menu with the given list and possible options @@ -109,6 +112,8 @@ return function(Cmdr) -- Generate the new option labels local autocompleteWidth = 200 + Gui.ScrollBarThickness = 0 + for i, item in pairs(self.Items) do local leftText = item[1] local rightText = item[2] From bce913e066d97089ee4f4364c8cecceffe5c987e Mon Sep 17 00:00:00 2001 From: Wil <63251107+wilyt1@users.noreply.github.com> Date: Wed, 5 Jul 2023 15:50:55 -0400 Subject: [PATCH 3/3] Adjust Container Size With Screen Size Updates --- .../CmdrClient/CmdrInterface/AutoComplete.lua | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua b/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua index 3ab4d40..ae2bf81 100644 --- a/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua +++ b/Cmdr/CmdrClient/CmdrInterface/AutoComplete.lua @@ -35,6 +35,15 @@ return function(Cmdr) end end + local function UpdateContainerSize() + Gui.Size = UDim2.new( + 0, + math.max(Title.Field.TextBounds.X + Title.Field.Type.TextBounds.X, Gui.Size.X.Offset), + 0, + math.min(Gui.UIListLayout.AbsoluteContentSize.Y, Gui.Parent.AbsoluteSize.Y - Gui.AbsolutePosition.Y - 10) + ) + end + -- Update the info display (Name, type, and description) based on given options. local function UpdateInfoDisplay(options) -- Update the objects' text and sizes @@ -47,11 +56,6 @@ return function(Cmdr) SetText(Description, Description.Label, options.description) Description.Label.TextColor3 = options.invalid and Color3.fromRGB(255, 73, 73) or Color3.fromRGB(255, 255, 255) - - -- Calculate needed width and height - local infoWidth = Title.Field.TextBounds.X + Title.Field.Type.TextBounds.X - - local guiWidth = math.max(infoWidth, Gui.Size.X.Offset) Description.Size = UDim2.new(1, 0, 0, 40) -- Flow description text @@ -64,17 +68,9 @@ return function(Cmdr) end -- Update container - wait() + task.wait() Gui.UIListLayout:ApplyLayout() - Gui.Size = UDim2.new( - 0, - guiWidth, - 0, - math.min( - Gui.UIListLayout.AbsoluteContentSize.Y, - workspace.CurrentCamera.ViewportSize.Y - Gui.AbsolutePosition.Y - 46 - ) - ) + UpdateContainerSize() Gui.ScrollBarThickness = defaultBarThickness end @@ -208,5 +204,7 @@ return function(Cmdr) end end + Gui.Parent:GetPropertyChangedSignal("AbsoluteSize"):Connect(UpdateContainerSize) + return AutoComplete end