Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Started on #51
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewguilas committed Sep 16, 2020
1 parent c5e6320 commit c35a837
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 76 deletions.
126 changes: 51 additions & 75 deletions src/Server/VelocityAdmin/Client/AutoComplete.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,26 @@ function Module.UpdateResponse(Success, Status)
end

function Module.UpdateSelectedField(Step)
for FrameIndex, Frame in pairs(Core.Get(AutoComplete, "Frame")) do
for _,Field in pairs(Core.Get(Frame, "TextButton")) do
if Field.IsSelected.Value then

-- Finds the next possible selected field
local NewSelectedField = Frame:FindFirstChild(Field.Name + Step)
if not NewSelectedField then
for _, NextFrame in pairs(Core.Get(AutoComplete, "Frame")) do
if NextFrame.LayoutOrder == (Step == 1 and Frame.LayoutOrder + 10) or (Step == -1 and Frame.LayoutOrder - 10) then
NewSelectedField = (Step == 1 and Core.Get(NextFrame, "TextButton")[1]) or (Step == -1 and Core.Get(NextFrame, "TextButton")[#Core.Get(NextFrame, "TextButton")])
break
end
end
end
local CurrentSelectedField = Handler.Data.SelectedField
if CurrentSelectedField then
local NewSelectedField = Handler.Data.Fields[table.find(Handler.Data.Fields, CurrentSelectedField) + Step] or Step == -1 and Handler.Data.Fields[#Handler.Data.Fields] or Step == 1 and Handler.Data.Fields[1]
if NewSelectedField then
CurrentSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.UnselectedColor
NewSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
CurrentSelectedField.IsSelected.Value, NewSelectedField.IsSelected.Value = false, true
Handler.Data.SelectedField = NewSelectedField
end
end
end

-- Sets a new selection
if NewSelectedField then
Field.BackgroundColor3 = Settings.CommandBar.AutoComplete.UnselectedColor
NewSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
NewSelectedField.IsSelected.Value, Field.IsSelected.Value = true, false
end
return
function Module.UpdateFieldTable()
Handler.Data.Fields = {}
for _,Frame in pairs(Core.Get(AutoComplete, "Frame")) do
for __,Field in pairs(Core.Get(Frame, "TextButton")) do
if Frame.Visible then
table.insert(Handler.Data.Fields, Field)
else
Core.TableRemove(Handler.Data.Fields, Field)
end
end
end
Expand Down Expand Up @@ -141,6 +139,7 @@ function Module.CreateFields(PossibleFields)
local HeadingNum = 0

-- Creates the auto completion section
Handler.Data.Fields = {}
for Heading, Cmds in pairs(PossibleFields) do
HeadingNum = HeadingNum + 1

Expand All @@ -164,59 +163,44 @@ function Module.CreateFields(PossibleFields)
-- Event for heading clicked
NewHeading.MouseButton1Click:Connect(function()
NewFieldFrame.Visible = not NewFieldFrame.Visible
Module.UpdateFieldTable()

-- If a field is selected in the frame that is being collapsed, then it will switch the selection to the next possible field
if NewFieldFrame.Visible then

local aFieldIsSelected
for _,Frame in pairs(Core.Get(AutoComplete, "Frame")) do
for __,Field in pairs(Core.Get(Frame, "TextButton")) do
if Field.IsSelected.Value then
aFieldIsSelected = true
end
end
end

if not aFieldIsSelected then
local Field = NewFieldFrame[1]
Field.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
Field.IsSelected.Value = true
print(Field:GetFullName() .. " was selected")
if not Handler.Data.SelectedField then
local NewSelectedField = NewFieldFrame["1"]
NewSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
NewSelectedField.IsSelected.Value = true
Handler.Data.SelectedField = NewSelectedField
end
else
for _,Field in pairs(Core.Get(NewFieldFrame, "TextButton")) do
if Field.IsSelected.Value then

-- Gets the next possible field to be selected
local NewSelectedField
local CurrentSelectedField = Handler.Data.SelectedField.Parent == NewFieldFrame and Handler.Data.SelectedField
if CurrentSelectedField then

for __,FieldFrame in pairs(Core.Get(AutoComplete, "Frame")) do
if FieldFrame.LayoutOrder == NewFieldFrame.LayoutOrder + 10 and FieldFrame.Visible then
NewSelectedField = FieldFrame["1"]
local SelectionChanged
for i = 1, #Handler.Data.Fields do
local NewSelectedField
if NewSelectedField and NewSelectedField.Parent.Visible then
NewSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
NewSelectedField.IsSelected.Value = true
Handler.Data.SelectedField = NewSelectedField
SelectionChanged = true
break
else
if NewSelectedField and NewSelectedField.Parent.Visible then
NewSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
NewSelectedField.IsSelected.Value = true
Handler.Data.SelectedField = NewSelectedField
SelectionChanged = true
break
end
end
end

if not NewSelectedField then
for __,FieldFrame in pairs(Core.Get(AutoComplete, "Frame")) do
if FieldFrame.LayoutOrder == NewFieldFrame.LayoutOrder - 10 and FieldFrame.Visible then
NewSelectedField = FieldFrame[#Core.Get(FieldFrame, "TextButton")]
break
end
end
end

-- Selects the next possible field
if NewSelectedField then
NewSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
NewSelectedField.IsSelected.Value = true
print(NewSelectedField:GetFullName() .. " was selected")
end
CurrentSelectedField.IsSelected.Value = false
CurrentSelectedField.BackgroundColor3 = Settings.CommandBar.AutoComplete.UnselectedColor

Field.BackgroundColor3 = Settings.CommandBar.AutoComplete.UnselectedColor
Field.IsSelected.Value = false
print(Field:GetFullName() .. " was unselected")
break
if not SelectionChanged then
Handler.Data.SelectedField = nil
end
end
end
Expand All @@ -236,19 +220,10 @@ function Module.CreateFields(PossibleFields)
end

-- Sets the selection
local aFieldIsSelected
for _,Frame in pairs(Core.Get(AutoComplete, "Frame")) do
for __,Field in pairs(Core.Get(Frame, "TextButton")) do
if Field.IsSelected.Value then
aFieldIsSelected = true
end
end
end

if not aFieldIsSelected and HeadingNum == 1 and FieldNum == 1 then
if not Handler.Data.SelectedField and HeadingNum == 1 and FieldNum == 1 then
NewField.IsSelected.Value = true
NewField.BackgroundColor3 = Settings.CommandBar.AutoComplete.SelectedColor
print(NewField:GetFullName() .. " was selected")
Handler.Data.SelectedField = NewField
end

-- Other properties
Expand All @@ -274,6 +249,7 @@ function Module.CreateFields(PossibleFields)
NewFieldFrame.Size = UDim2.new(1, 0, 0, NewFieldFrame.ListLayout.AbsoluteContentSize.Y)
end
end
Module.UpdateFieldTable()
end

function Module.CheckDifference(Heading, Title, Description, LastArg, Table, GetAll)
Expand Down
4 changes: 3 additions & 1 deletion src/Server/VelocityAdmin/Client/Handler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ local Module = {
Command = nil,
CommandInfo = {},
Argument = nil,
Arguments = {}
Arguments = {},
Fields = {},
SelectedField = nil,
},
Cons = {},
}
Expand Down

0 comments on commit c35a837

Please sign in to comment.