diff --git a/lua/autorun/sh_pulsarui_loader.lua b/lua/autorun/sh_pulsarui_loader.lua index 4c397a9..b6a214b 100644 --- a/lua/autorun/sh_pulsarui_loader.lua +++ b/lua/autorun/sh_pulsarui_loader.lua @@ -36,7 +36,7 @@ function PulsarUI.LoadDirectoryRecursive(basePath, onLoad) end end -PulsarUI.LoadDirectoryRecursive("pixelui") +PulsarUI.LoadDirectoryRecursive("pulsarui") hook.Run("PulsarUI.FullyLoaded") if CLIENT then return end diff --git a/lua/pixelui/core/cl_fonts.lua b/lua/pulsarui/core/cl_fonts.lua similarity index 100% rename from lua/pixelui/core/cl_fonts.lua rename to lua/pulsarui/core/cl_fonts.lua diff --git a/lua/pixelui/core/cl_images.lua b/lua/pulsarui/core/cl_images.lua similarity index 100% rename from lua/pixelui/core/cl_images.lua rename to lua/pulsarui/core/cl_images.lua diff --git a/lua/pixelui/core/cl_overrides.lua b/lua/pulsarui/core/cl_overrides.lua similarity index 100% rename from lua/pixelui/core/cl_overrides.lua rename to lua/pulsarui/core/cl_overrides.lua diff --git a/lua/pixelui/core/cl_scaling.lua b/lua/pulsarui/core/cl_scaling.lua similarity index 100% rename from lua/pixelui/core/cl_scaling.lua rename to lua/pulsarui/core/cl_scaling.lua diff --git a/lua/pixelui/core/sh_color.lua b/lua/pulsarui/core/sh_color.lua similarity index 100% rename from lua/pixelui/core/sh_color.lua rename to lua/pulsarui/core/sh_color.lua diff --git a/lua/pixelui/core/sh_formatting.lua b/lua/pulsarui/core/sh_formatting.lua similarity index 100% rename from lua/pixelui/core/sh_formatting.lua rename to lua/pulsarui/core/sh_formatting.lua diff --git a/lua/pixelui/core/sh_player.lua b/lua/pulsarui/core/sh_player.lua similarity index 100% rename from lua/pixelui/core/sh_player.lua rename to lua/pulsarui/core/sh_player.lua diff --git a/lua/pixelui/core/sv_confetti.lua b/lua/pulsarui/core/sv_confetti.lua similarity index 100% rename from lua/pixelui/core/sv_confetti.lua rename to lua/pulsarui/core/sv_confetti.lua diff --git a/lua/pixelui/drawing/cl_circle.lua b/lua/pulsarui/drawing/cl_circle.lua similarity index 100% rename from lua/pixelui/drawing/cl_circle.lua rename to lua/pulsarui/drawing/cl_circle.lua diff --git a/lua/pixelui/drawing/cl_images.lua b/lua/pulsarui/drawing/cl_images.lua similarity index 100% rename from lua/pixelui/drawing/cl_images.lua rename to lua/pulsarui/drawing/cl_images.lua diff --git a/lua/pixelui/drawing/cl_masks.lua b/lua/pulsarui/drawing/cl_masks.lua similarity index 100% rename from lua/pixelui/drawing/cl_masks.lua rename to lua/pulsarui/drawing/cl_masks.lua diff --git a/lua/pixelui/drawing/cl_misc.lua b/lua/pulsarui/drawing/cl_misc.lua similarity index 100% rename from lua/pixelui/drawing/cl_misc.lua rename to lua/pulsarui/drawing/cl_misc.lua diff --git a/lua/pixelui/drawing/cl_outlined_box.lua b/lua/pulsarui/drawing/cl_outlined_box.lua similarity index 100% rename from lua/pixelui/drawing/cl_outlined_box.lua rename to lua/pulsarui/drawing/cl_outlined_box.lua diff --git a/lua/pixelui/drawing/cl_overheads.lua b/lua/pulsarui/drawing/cl_overheads.lua similarity index 100% rename from lua/pixelui/drawing/cl_overheads.lua rename to lua/pulsarui/drawing/cl_overheads.lua diff --git a/lua/pixelui/drawing/cl_rounded_box.lua b/lua/pulsarui/drawing/cl_rounded_box.lua similarity index 100% rename from lua/pixelui/drawing/cl_rounded_box.lua rename to lua/pulsarui/drawing/cl_rounded_box.lua diff --git a/lua/pixelui/drawing/cl_text.lua b/lua/pulsarui/drawing/cl_text.lua similarity index 100% rename from lua/pixelui/drawing/cl_text.lua rename to lua/pulsarui/drawing/cl_text.lua diff --git a/lua/pixelui/elements/cl_avatar.lua b/lua/pulsarui/elements/cl_avatar.lua similarity index 100% rename from lua/pixelui/elements/cl_avatar.lua rename to lua/pulsarui/elements/cl_avatar.lua diff --git a/lua/pixelui/elements/cl_button.lua b/lua/pulsarui/elements/cl_button.lua similarity index 100% rename from lua/pixelui/elements/cl_button.lua rename to lua/pulsarui/elements/cl_button.lua diff --git a/lua/pixelui/elements/cl_category.lua b/lua/pulsarui/elements/cl_category.lua similarity index 100% rename from lua/pixelui/elements/cl_category.lua rename to lua/pulsarui/elements/cl_category.lua diff --git a/lua/pixelui/elements/cl_check_box.lua b/lua/pulsarui/elements/cl_check_box.lua similarity index 100% rename from lua/pixelui/elements/cl_check_box.lua rename to lua/pulsarui/elements/cl_check_box.lua diff --git a/lua/pixelui/elements/cl_color_picker.lua b/lua/pulsarui/elements/cl_color_picker.lua similarity index 100% rename from lua/pixelui/elements/cl_color_picker.lua rename to lua/pulsarui/elements/cl_color_picker.lua diff --git a/lua/pixelui/elements/cl_combo_box.lua b/lua/pulsarui/elements/cl_combo_box.lua similarity index 100% rename from lua/pixelui/elements/cl_combo_box.lua rename to lua/pulsarui/elements/cl_combo_box.lua diff --git a/lua/pixelui/elements/cl_drag_panel.lua b/lua/pulsarui/elements/cl_drag_panel.lua similarity index 100% rename from lua/pixelui/elements/cl_drag_panel.lua rename to lua/pulsarui/elements/cl_drag_panel.lua diff --git a/lua/pixelui/elements/cl_frame.lua b/lua/pulsarui/elements/cl_frame.lua similarity index 100% rename from lua/pixelui/elements/cl_frame.lua rename to lua/pulsarui/elements/cl_frame.lua diff --git a/lua/pixelui/elements/cl_image.lua b/lua/pulsarui/elements/cl_image.lua similarity index 100% rename from lua/pixelui/elements/cl_image.lua rename to lua/pulsarui/elements/cl_image.lua diff --git a/lua/pixelui/elements/cl_image_button.lua b/lua/pulsarui/elements/cl_image_button.lua similarity index 100% rename from lua/pixelui/elements/cl_image_button.lua rename to lua/pulsarui/elements/cl_image_button.lua diff --git a/lua/pixelui/elements/cl_imgur_button.lua b/lua/pulsarui/elements/cl_imgur_button.lua similarity index 100% rename from lua/pixelui/elements/cl_imgur_button.lua rename to lua/pulsarui/elements/cl_imgur_button.lua diff --git a/lua/pixelui/elements/cl_label.lua b/lua/pulsarui/elements/cl_label.lua similarity index 100% rename from lua/pixelui/elements/cl_label.lua rename to lua/pulsarui/elements/cl_label.lua diff --git a/lua/pixelui/elements/cl_labelled_checkbox.lua b/lua/pulsarui/elements/cl_labelled_checkbox.lua similarity index 100% rename from lua/pixelui/elements/cl_labelled_checkbox.lua rename to lua/pulsarui/elements/cl_labelled_checkbox.lua diff --git a/lua/pixelui/elements/cl_menu.lua b/lua/pulsarui/elements/cl_menu.lua similarity index 100% rename from lua/pixelui/elements/cl_menu.lua rename to lua/pulsarui/elements/cl_menu.lua diff --git a/lua/pixelui/elements/cl_menu_option.lua b/lua/pulsarui/elements/cl_menu_option.lua similarity index 100% rename from lua/pixelui/elements/cl_menu_option.lua rename to lua/pulsarui/elements/cl_menu_option.lua diff --git a/lua/pixelui/elements/cl_navbar.lua b/lua/pulsarui/elements/cl_navbar.lua similarity index 100% rename from lua/pixelui/elements/cl_navbar.lua rename to lua/pulsarui/elements/cl_navbar.lua diff --git a/lua/pixelui/elements/cl_number_entry.lua b/lua/pulsarui/elements/cl_number_entry.lua similarity index 100% rename from lua/pixelui/elements/cl_number_entry.lua rename to lua/pulsarui/elements/cl_number_entry.lua diff --git a/lua/pixelui/elements/cl_property_sheet.lua b/lua/pulsarui/elements/cl_property_sheet.lua similarity index 100% rename from lua/pixelui/elements/cl_property_sheet.lua rename to lua/pulsarui/elements/cl_property_sheet.lua diff --git a/lua/pixelui/elements/cl_scrollbar.lua b/lua/pulsarui/elements/cl_scrollbar.lua similarity index 100% rename from lua/pixelui/elements/cl_scrollbar.lua rename to lua/pulsarui/elements/cl_scrollbar.lua diff --git a/lua/pixelui/elements/cl_scrollpanel.lua b/lua/pulsarui/elements/cl_scrollpanel.lua similarity index 100% rename from lua/pixelui/elements/cl_scrollpanel.lua rename to lua/pulsarui/elements/cl_scrollpanel.lua diff --git a/lua/pixelui/elements/cl_sidebar.lua b/lua/pulsarui/elements/cl_sidebar.lua similarity index 97% rename from lua/pixelui/elements/cl_sidebar.lua rename to lua/pulsarui/elements/cl_sidebar.lua index 59ac38e..44d814c 100644 --- a/lua/pixelui/elements/cl_sidebar.lua +++ b/lua/pulsarui/elements/cl_sidebar.lua @@ -1,269 +1,269 @@ ---[[ - PulsarUI - Copyright Notice - © 2023 Thomas O'Sullivan - All rights reserved - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -]] -local PANEL = {} -AccessorFunc(PANEL, "Name", "Name", FORCE_STRING) -AccessorFunc(PANEL, "ImageURL", "ImageURL", FORCE_STRING) -AccessorFunc(PANEL, "DrawOutline", "DrawOutline", FORCE_BOOL) -AccessorFunc(PANEL, "ImgurID", "ImgurID", FORCE_STRING) -- Deprecated - -AccessorFunc(PANEL, "GradientEnabled", "GradientEnabled", FORCE_BOOL) -AccessorFunc(PANEL, "GradientColor", "GradientColor", FORCE_COLOR) -AccessorFunc(PANEL, "GradientColorLeft", "GradientColorLeft", FORCE_COLOR) -AccessorFunc(PANEL, "GradientColorRight", "GradientColorRight", FORCE_COLOR) - -function PANEL:SetGradientColor(col) - assert(type(col) == "table", "bad argument #1 to 'SetGradientColor' (table expected, got " .. type(col) .. ")") - self:SetGradientColorLeft(col) - local offsetCol = PulsarUI.OffsetColor(col, -40, true) - self:SetGradientColorRight(offsetCol) -end - -function PANEL:SetGradientColorLeft(color) - self.GradientColorLeft = color - self.GradientColorLeftHover = ColorAlpha(color, color.a - 30) - self.GradientColorLeftSelect = ColorAlpha(color, color.a - 40) -end - -function PANEL:SetGradientColorRight(color) - self.GradientColorRight = color - self.GradientColorRightHover = ColorAlpha(color, color.a - 30) - self.GradientColorRightSelect = ColorAlpha(color, color.a - 40) -end - -function PANEL:SetImgurID(id) - assert(type(id) == "string", "bad argument #1 to 'SetImgurID' (string expected, got " .. type(id) .. ")") - print("[PulsarUI] PulsarUI.SidebarItem:SetImgurID is deprecated, use PulsarUI.SidebarItem:SetImageURL instead") - self:SetImageURL("https://i.imgur.com/" .. id .. ".png") - self.ImgurID = id -end - -function PANEL:GetImgurID() - print("[PulsarUI] PulsarUI.SidebarItem:GetImgurID is deprecated, use PulsarUI.SidebarItem:GetImageURL instead") - return (self:GetImageURL() or ""):match("https://i.imgur.com/(.-).png") -end - -PulsarUI.RegisterFont("SidebarItem", "Rubik", 19, 600) - -function PANEL:Init() - self:SetName("N/A") - self:SetDrawOutline(true) - self:SetGradientColor(PulsarUI.Colors.Primary) - self.TextCol = PulsarUI.CopyColor(PulsarUI.Colors.SecondaryText) - self.BackgroundCol = PulsarUI.CopyColor(PulsarUI.Colors.Transparent) - self.BackgroundHoverCol = ColorAlpha(PulsarUI.Colors.Primary, 40) - self.BackgroundSelectCol = ColorAlpha(PulsarUI.Colors.Primary, 80) -end - -function PANEL:Paint(w, h) - local textCol = PulsarUI.Colors.SecondaryText - local backgroundCol = PulsarUI.Colors.Transparent - local leftGradCol = PulsarUI.Colors.Transparent - local rightGradCol = PulsarUI.Colors.Transparent - - local gradientEnabled = self:GetGradientEnabled() - - if self:IsHovered() then - textCol = PulsarUI.Colors.PrimaryText - backgroundCol = self.BackgroundHoverCol - hoverLineCol = PulsarUI.Colors.Primary - - if gradientEnabled then - leftGradCol = self.GradientColorLeftHover - rightGradCol = self.GradientColorRightHover - end - end - - if self:IsDown() or self:GetToggle() then - textCol = PulsarUI.Colors.PrimaryText - backgroundCol = self.BackgroundSelectCol - - if gradientEnabled then - leftGradCol = self.GradientColorLeftSelect - rightGradCol = self.GradientColorRightSelect - end - end - - local animTime = FrameTime() * 24 - self.TextCol = PulsarUI.LerpColor(animTime, self.TextCol, textCol) - self.BackgroundCol = PulsarUI.LerpColor(animTime, self.BackgroundCol, backgroundCol) - - if gradientEnabled then - self.GradientColorLeft = PulsarUI.LerpColor(animTime, self.GradientColorLeft, leftGradCol) - self.GradientColorRight = PulsarUI.LerpColor(animTime, self.GradientColorRight, rightGradCol) - end - - if self:GetDrawOutline() and gradientEnabled then - PulsarUI.Mask(function() - PulsarUI.DrawFullRoundedBox(8, 0, 0, w, h, color_white) - end, function() - local lX, lY = self:LocalToScreen() - PulsarUI.DrawSimpleLinearGradient(lX, lY, w, h, self.GradientColorLeft, self.GradientColorRight, true) - end) - elseif self:GetDrawOutline() then - PulsarUI.DrawRoundedBox(8, 0, 0, w, h, self.BackgroundCol, PulsarUI.Scale(1)) - end - - local imageURL = self:GetImageURL() - if imageURL then - local iconSize = h * .65 - PulsarUI.DrawImage(PulsarUI.Scale(10), (h - iconSize) / 2, iconSize, iconSize, imageURL, self.TextCol) - PulsarUI.DrawSimpleText(self:GetName(), "SidebarItem", PulsarUI.Scale(20) + iconSize, h / 2, self.TextCol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) - return - end - - PulsarUI.DrawSimpleText(self:GetName(), "SidebarItem", PulsarUI.Scale(10), h / 2, self.TextCol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) -end - -vgui.Register("PulsarUI.SidebarItem", PANEL, "PulsarUI.Button") - -PANEL = {} -AccessorFunc(PANEL, "ImageURL", "ImageURL", FORCE_STRING) -AccessorFunc(PANEL, "ImageScale", "ImageScale", FORCE_NUMBER) -AccessorFunc(PANEL, "ImageOffset", "ImageOffset", FORCE_NUMBER) -AccessorFunc(PANEL, "ButtonOffset", "ButtonOffset", FORCE_NUMBER) -AccessorFunc(PANEL, "GradientEnabled", "GradientEnabled", FORCE_BOOL) - -AccessorFunc(PANEL, "ImgurID", "ImgurID", FORCE_STRING) -- Deprecated -AccessorFunc(PANEL, "ImgurScale", "ImgurScale", FORCE_NUMBER) -- Deprecated -AccessorFunc(PANEL, "ImgurOffset", "ImgurOffset", FORCE_NUMBER) -- Deprecated - -function PANEL:SetImgurID(id) - assert(type(id) == "string", "bad argument #1 to 'SetImgurID' (string expected, got " .. type(id) .. ")") - print("[PulsarUI] PulsarUI.Sidebar:SetImgurID is deprecated, use PulsarUI.Sidebar:SetImageURL instead") - self:SetImageURL("https://i.imgur.com/" .. id .. ".png") - self.ImgurID = id -end - -function PANEL:GetImgurID() - print("[PulsarUI] PulsarUI.Sidebar:GetImgurID is deprecated, use PulsarUI.Sidebar:GetImageURL instead") - return (self:GetImageURL() or ""):match("https://i.imgur.com/(.-).png") -end - -function PANEL:SetImgurScale(scale) - assert(type(scale) == "number", "bad argument #1 to 'SetImgurScale' (number expected, got " .. type(scale) .. ")") - print("[PulsarUI] PulsarUI.Sidebar:SetImgurScale is deprecated, use PulsarUI.Sidebar:SetImageScale instead") - self:SetImageScale(scale) - self.ImgurScale = scale -end - -function PANEL:GetImgurScale() - print("[PulsarUI] PulsarUI.Sidebar:GetImgurScale is deprecated, use PulsarUI.Sidebar:GetImageScale instead") - return self:GetImageScale() -end - -function PANEL:SetImgurOffset(offset) - assert(type(offset) == "number", "bad argument #1 to 'SetImgurOffset' (number expected, got " .. type(offset) .. ")") - print("[PulsarUI] PulsarUI.Sidebar:SetImgurOffset is deprecated, use PulsarUI.Sidebar:SetImageOffset instead") - self:SetImageOffset(offset) - self.ImgurOffset = offset -end - -function PANEL:GetImgurOffset() - print("[PulsarUI] PulsarUI.Sidebar:GetImgurOffset is deprecated, use PulsarUI.Sidebar:GetImageOffset instead") - return self:GetImageOffset() -end - -function PANEL:Init() - self.Items = {} - self.Scroller = vgui.Create("PulsarUI.ScrollPanel", self) - self.Scroller:SetBarDockShouldOffset(true) - - self.Scroller.LayoutContent = function(s, w, h) - local spacing = PulsarUI.Scale(8) - local height = PulsarUI.Scale(35) - - for k, v in pairs(self.Items) do - v:SetTall(height) - v:Dock(TOP) - v:DockMargin(0, 0, 0, spacing) - end - end - - self:SetImageScale(.6) - self:SetImageOffset(0) - self:SetButtonOffset(0) - - self.BackgroundCol = PulsarUI.CopyColor(PulsarUI.Colors.Header) -end - -function PANEL:AddItem(id, name, imageURL, doClick, order) - local btn = vgui.Create("PulsarUI.SidebarItem", self.Scroller) - btn:SetZPos(order or table.Count(self.Items) + 1) - btn:SetName(name) - - if imageURL then - local imgurMatch = (imageURL or ""):match("^[a-zA-Z0-9]+$") - if imgurMatch then - imageURL = "https://i.imgur.com/" .. imageURL .. ".png" - end - - btn:SetImageURL(imageURL) - end - - btn.Function = doClick - - btn.DoClick = function(s) - self:SelectItem(id) - end - - self.Items[id] = btn - - return btn -end - -function PANEL:RemoveItem(id) - local item = self.Items[id] - if not item then return end - item:Remove() - self.Items[id] = nil - if self.SelectedItem ~= id then return end - self:SelectItem(next(self.Items)) -end - -function PANEL:SelectItem(id) - local item = self.Items[id] - if not item then return end - if self.SelectedItem and self.SelectedItem == id then return end - self.SelectedItem = id - - for k, v in pairs(self.Items) do - v:SetToggle(false) - end - - item:SetToggle(true) - item.Function(item) -end - -function PANEL:PerformLayout(w, h) - local sideSpacing = PulsarUI.Scale(7) - local topSpacing = PulsarUI.Scale(7) - self:DockPadding(sideSpacing, self:GetImageURL() and w * self:GetImageScale() + self:GetImageOffset() + self:GetButtonOffset() + topSpacing * 2 or topSpacing, sideSpacing, topSpacing) - self.Scroller:Dock(FILL) - self.Scroller:GetCanvas():DockPadding(0, 0, self.Scroller.VBar.Enabled and sideSpacing or 0, 0) -end - -function PANEL:Paint(w, h) - PulsarUI.DrawRoundedBoxEx(PulsarUI.Scale(6), 0, 0, w, h, self.BackgroundCol, false, false, true) - - local imageURL = self:GetImageURL() - if imageURL then - local imageSize = w * self:GetImageScale() - PulsarUI.DrawImage((w - imageSize) / 2, self:GetImageOffset() + PulsarUI.Scale(15), imageSize, imageSize, imageURL, color_white) - end -end - +--[[ + PulsarUI - Copyright Notice + © 2023 Thomas O'Sullivan - All rights reserved + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +]] +local PANEL = {} +AccessorFunc(PANEL, "Name", "Name", FORCE_STRING) +AccessorFunc(PANEL, "ImageURL", "ImageURL", FORCE_STRING) +AccessorFunc(PANEL, "DrawOutline", "DrawOutline", FORCE_BOOL) +AccessorFunc(PANEL, "ImgurID", "ImgurID", FORCE_STRING) -- Deprecated + +AccessorFunc(PANEL, "GradientEnabled", "GradientEnabled", FORCE_BOOL) +AccessorFunc(PANEL, "GradientColor", "GradientColor", FORCE_COLOR) +AccessorFunc(PANEL, "GradientColorLeft", "GradientColorLeft", FORCE_COLOR) +AccessorFunc(PANEL, "GradientColorRight", "GradientColorRight", FORCE_COLOR) + +function PANEL:SetGradientColor(col) + assert(type(col) == "table", "bad argument #1 to 'SetGradientColor' (table expected, got " .. type(col) .. ")") + self:SetGradientColorLeft(col) + local offsetCol = PulsarUI.OffsetColor(col, -40, true) + self:SetGradientColorRight(offsetCol) +end + +function PANEL:SetGradientColorLeft(color) + self.GradientColorLeft = color + self.GradientColorLeftHover = ColorAlpha(color, color.a - 30) + self.GradientColorLeftSelect = ColorAlpha(color, color.a - 40) +end + +function PANEL:SetGradientColorRight(color) + self.GradientColorRight = color + self.GradientColorRightHover = ColorAlpha(color, color.a - 30) + self.GradientColorRightSelect = ColorAlpha(color, color.a - 40) +end + +function PANEL:SetImgurID(id) + assert(type(id) == "string", "bad argument #1 to 'SetImgurID' (string expected, got " .. type(id) .. ")") + print("[PulsarUI] PulsarUI.SidebarItem:SetImgurID is deprecated, use PulsarUI.SidebarItem:SetImageURL instead") + self:SetImageURL("https://i.imgur.com/" .. id .. ".png") + self.ImgurID = id +end + +function PANEL:GetImgurID() + print("[PulsarUI] PulsarUI.SidebarItem:GetImgurID is deprecated, use PulsarUI.SidebarItem:GetImageURL instead") + return (self:GetImageURL() or ""):match("https://i.imgur.com/(.-).png") +end + +PulsarUI.RegisterFont("SidebarItem", "Rubik", 19, 600) + +function PANEL:Init() + self:SetName("N/A") + self:SetDrawOutline(true) + self:SetGradientColor(PulsarUI.Colors.Primary) + self.TextCol = PulsarUI.CopyColor(PulsarUI.Colors.SecondaryText) + self.BackgroundCol = PulsarUI.CopyColor(PulsarUI.Colors.Transparent) + self.BackgroundHoverCol = ColorAlpha(PulsarUI.Colors.Primary, 40) + self.BackgroundSelectCol = ColorAlpha(PulsarUI.Colors.Primary, 80) +end + +function PANEL:Paint(w, h) + local textCol = PulsarUI.Colors.SecondaryText + local backgroundCol = PulsarUI.Colors.Transparent + local leftGradCol = PulsarUI.Colors.Transparent + local rightGradCol = PulsarUI.Colors.Transparent + + local gradientEnabled = self:GetGradientEnabled() + + if self:IsHovered() then + textCol = PulsarUI.Colors.PrimaryText + backgroundCol = self.BackgroundHoverCol + hoverLineCol = PulsarUI.Colors.Primary + + if gradientEnabled then + leftGradCol = self.GradientColorLeftHover + rightGradCol = self.GradientColorRightHover + end + end + + if self:IsDown() or self:GetToggle() then + textCol = PulsarUI.Colors.PrimaryText + backgroundCol = self.BackgroundSelectCol + + if gradientEnabled then + leftGradCol = self.GradientColorLeftSelect + rightGradCol = self.GradientColorRightSelect + end + end + + local animTime = FrameTime() * 24 + self.TextCol = PulsarUI.LerpColor(animTime, self.TextCol, textCol) + self.BackgroundCol = PulsarUI.LerpColor(animTime, self.BackgroundCol, backgroundCol) + + if gradientEnabled then + self.GradientColorLeft = PulsarUI.LerpColor(animTime, self.GradientColorLeft, leftGradCol) + self.GradientColorRight = PulsarUI.LerpColor(animTime, self.GradientColorRight, rightGradCol) + end + + if self:GetDrawOutline() and gradientEnabled then + PulsarUI.Mask(function() + PulsarUI.DrawFullRoundedBox(8, 0, 0, w, h, color_white) + end, function() + local lX, lY = self:LocalToScreen() + PulsarUI.DrawSimpleLinearGradient(lX, lY, w, h, self.GradientColorLeft, self.GradientColorRight, true) + end) + elseif self:GetDrawOutline() then + PulsarUI.DrawRoundedBox(8, 0, 0, w, h, self.BackgroundCol, PulsarUI.Scale(1)) + end + + local imageURL = self:GetImageURL() + if imageURL then + local iconSize = h * .65 + PulsarUI.DrawImage(PulsarUI.Scale(10), (h - iconSize) / 2, iconSize, iconSize, imageURL, self.TextCol) + PulsarUI.DrawSimpleText(self:GetName(), "SidebarItem", PulsarUI.Scale(20) + iconSize, h / 2, self.TextCol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) + return + end + + PulsarUI.DrawSimpleText(self:GetName(), "SidebarItem", PulsarUI.Scale(10), h / 2, self.TextCol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) +end + +vgui.Register("PulsarUI.SidebarItem", PANEL, "PulsarUI.Button") + +PANEL = {} +AccessorFunc(PANEL, "ImageURL", "ImageURL", FORCE_STRING) +AccessorFunc(PANEL, "ImageScale", "ImageScale", FORCE_NUMBER) +AccessorFunc(PANEL, "ImageOffset", "ImageOffset", FORCE_NUMBER) +AccessorFunc(PANEL, "ButtonOffset", "ButtonOffset", FORCE_NUMBER) +AccessorFunc(PANEL, "GradientEnabled", "GradientEnabled", FORCE_BOOL) + +AccessorFunc(PANEL, "ImgurID", "ImgurID", FORCE_STRING) -- Deprecated +AccessorFunc(PANEL, "ImgurScale", "ImgurScale", FORCE_NUMBER) -- Deprecated +AccessorFunc(PANEL, "ImgurOffset", "ImgurOffset", FORCE_NUMBER) -- Deprecated + +function PANEL:SetImgurID(id) + assert(type(id) == "string", "bad argument #1 to 'SetImgurID' (string expected, got " .. type(id) .. ")") + print("[PulsarUI] PulsarUI.Sidebar:SetImgurID is deprecated, use PulsarUI.Sidebar:SetImageURL instead") + self:SetImageURL("https://i.imgur.com/" .. id .. ".png") + self.ImgurID = id +end + +function PANEL:GetImgurID() + print("[PulsarUI] PulsarUI.Sidebar:GetImgurID is deprecated, use PulsarUI.Sidebar:GetImageURL instead") + return (self:GetImageURL() or ""):match("https://i.imgur.com/(.-).png") +end + +function PANEL:SetImgurScale(scale) + assert(type(scale) == "number", "bad argument #1 to 'SetImgurScale' (number expected, got " .. type(scale) .. ")") + print("[PulsarUI] PulsarUI.Sidebar:SetImgurScale is deprecated, use PulsarUI.Sidebar:SetImageScale instead") + self:SetImageScale(scale) + self.ImgurScale = scale +end + +function PANEL:GetImgurScale() + print("[PulsarUI] PulsarUI.Sidebar:GetImgurScale is deprecated, use PulsarUI.Sidebar:GetImageScale instead") + return self:GetImageScale() +end + +function PANEL:SetImgurOffset(offset) + assert(type(offset) == "number", "bad argument #1 to 'SetImgurOffset' (number expected, got " .. type(offset) .. ")") + print("[PulsarUI] PulsarUI.Sidebar:SetImgurOffset is deprecated, use PulsarUI.Sidebar:SetImageOffset instead") + self:SetImageOffset(offset) + self.ImgurOffset = offset +end + +function PANEL:GetImgurOffset() + print("[PulsarUI] PulsarUI.Sidebar:GetImgurOffset is deprecated, use PulsarUI.Sidebar:GetImageOffset instead") + return self:GetImageOffset() +end + +function PANEL:Init() + self.Items = {} + self.Scroller = vgui.Create("PulsarUI.ScrollPanel", self) + self.Scroller:SetBarDockShouldOffset(true) + + self.Scroller.LayoutContent = function(s, w, h) + local spacing = PulsarUI.Scale(8) + local height = PulsarUI.Scale(35) + + for k, v in pairs(self.Items) do + v:SetTall(height) + v:Dock(TOP) + v:DockMargin(0, 0, 0, spacing) + end + end + + self:SetImageScale(.6) + self:SetImageOffset(0) + self:SetButtonOffset(0) + + self.BackgroundCol = PulsarUI.CopyColor(PulsarUI.Colors.Header) +end + +function PANEL:AddItem(id, name, imageURL, doClick, order) + local btn = vgui.Create("PulsarUI.SidebarItem", self.Scroller) + btn:SetZPos(order or table.Count(self.Items) + 1) + btn:SetName(name) + + if imageURL then + local imgurMatch = (imageURL or ""):match("^[a-zA-Z0-9]+$") + if imgurMatch then + imageURL = "https://i.imgur.com/" .. imageURL .. ".png" + end + + btn:SetImageURL(imageURL) + end + + btn.Function = doClick + + btn.DoClick = function(s) + self:SelectItem(id) + end + + self.Items[id] = btn + + return btn +end + +function PANEL:RemoveItem(id) + local item = self.Items[id] + if not item then return end + item:Remove() + self.Items[id] = nil + if self.SelectedItem ~= id then return end + self:SelectItem(next(self.Items)) +end + +function PANEL:SelectItem(id) + local item = self.Items[id] + if not item then return end + if self.SelectedItem and self.SelectedItem == id then return end + self.SelectedItem = id + + for k, v in pairs(self.Items) do + v:SetToggle(false) + end + + item:SetToggle(true) + item.Function(item) +end + +function PANEL:PerformLayout(w, h) + local sideSpacing = PulsarUI.Scale(7) + local topSpacing = PulsarUI.Scale(7) + self:DockPadding(sideSpacing, self:GetImageURL() and w * self:GetImageScale() + self:GetImageOffset() + self:GetButtonOffset() + topSpacing * 2 or topSpacing, sideSpacing, topSpacing) + self.Scroller:Dock(FILL) + self.Scroller:GetCanvas():DockPadding(0, 0, self.Scroller.VBar.Enabled and sideSpacing or 0, 0) +end + +function PANEL:Paint(w, h) + PulsarUI.DrawRoundedBoxEx(PulsarUI.Scale(6), 0, 0, w, h, self.BackgroundCol, false, false, true) + + local imageURL = self:GetImageURL() + if imageURL then + local imageSize = w * self:GetImageScale() + PulsarUI.DrawImage((w - imageSize) / 2, self:GetImageOffset() + PulsarUI.Scale(15), imageSize, imageSize, imageURL, color_white) + end +end + vgui.Register("PulsarUI.Sidebar", PANEL, "Panel") \ No newline at end of file diff --git a/lua/pixelui/elements/cl_slider.lua b/lua/pulsarui/elements/cl_slider.lua similarity index 100% rename from lua/pixelui/elements/cl_slider.lua rename to lua/pulsarui/elements/cl_slider.lua diff --git a/lua/pixelui/elements/cl_state_button.lua b/lua/pulsarui/elements/cl_state_button.lua similarity index 100% rename from lua/pixelui/elements/cl_state_button.lua rename to lua/pulsarui/elements/cl_state_button.lua diff --git a/lua/pixelui/elements/cl_step_counter.lua b/lua/pulsarui/elements/cl_step_counter.lua similarity index 100% rename from lua/pixelui/elements/cl_step_counter.lua rename to lua/pulsarui/elements/cl_step_counter.lua diff --git a/lua/pixelui/elements/cl_text_button.lua b/lua/pulsarui/elements/cl_text_button.lua similarity index 100% rename from lua/pixelui/elements/cl_text_button.lua rename to lua/pulsarui/elements/cl_text_button.lua diff --git a/lua/pixelui/elements/cl_text_entry.lua b/lua/pulsarui/elements/cl_text_entry.lua similarity index 100% rename from lua/pixelui/elements/cl_text_entry.lua rename to lua/pulsarui/elements/cl_text_entry.lua diff --git a/lua/pixelui/elements/cl_text_entry_internal.lua b/lua/pulsarui/elements/cl_text_entry_internal.lua similarity index 100% rename from lua/pixelui/elements/cl_text_entry_internal.lua rename to lua/pulsarui/elements/cl_text_entry_internal.lua diff --git a/lua/pixelui/elements/cl_validated_text_entry.lua b/lua/pulsarui/elements/cl_validated_text_entry.lua similarity index 100% rename from lua/pixelui/elements/cl_validated_text_entry.lua rename to lua/pulsarui/elements/cl_validated_text_entry.lua diff --git a/lua/pixelui/elements/color_picker_v2/cl_alpha_bar.lua b/lua/pulsarui/elements/color_picker_v2/cl_alpha_bar.lua similarity index 100% rename from lua/pixelui/elements/color_picker_v2/cl_alpha_bar.lua rename to lua/pulsarui/elements/color_picker_v2/cl_alpha_bar.lua diff --git a/lua/pixelui/elements/color_picker_v2/cl_color_picker_v2.lua b/lua/pulsarui/elements/color_picker_v2/cl_color_picker_v2.lua similarity index 100% rename from lua/pixelui/elements/color_picker_v2/cl_color_picker_v2.lua rename to lua/pulsarui/elements/color_picker_v2/cl_color_picker_v2.lua diff --git a/lua/pixelui/elements/color_picker_v2/cl_hue_bar.lua b/lua/pulsarui/elements/color_picker_v2/cl_hue_bar.lua similarity index 100% rename from lua/pixelui/elements/color_picker_v2/cl_hue_bar.lua rename to lua/pulsarui/elements/color_picker_v2/cl_hue_bar.lua diff --git a/lua/pixelui/elements/color_picker_v2/cl_luminosity_bar.lua b/lua/pulsarui/elements/color_picker_v2/cl_luminosity_bar.lua similarity index 100% rename from lua/pixelui/elements/color_picker_v2/cl_luminosity_bar.lua rename to lua/pulsarui/elements/color_picker_v2/cl_luminosity_bar.lua diff --git a/lua/pixelui/elements/color_picker_v2/cl_saturation_bar.lua b/lua/pulsarui/elements/color_picker_v2/cl_saturation_bar.lua similarity index 100% rename from lua/pixelui/elements/color_picker_v2/cl_saturation_bar.lua rename to lua/pulsarui/elements/color_picker_v2/cl_saturation_bar.lua diff --git a/lua/pixelui/libraries/cl_arc.lua b/lua/pulsarui/libraries/cl_arc.lua similarity index 100% rename from lua/pixelui/libraries/cl_arc.lua rename to lua/pulsarui/libraries/cl_arc.lua diff --git a/lua/pixelui/libraries/cl_gradient.lua b/lua/pulsarui/libraries/cl_gradient.lua similarity index 100% rename from lua/pixelui/libraries/cl_gradient.lua rename to lua/pulsarui/libraries/cl_gradient.lua diff --git a/lua/pixelui/libraries/cl_masks.lua b/lua/pulsarui/libraries/cl_masks.lua similarity index 96% rename from lua/pixelui/libraries/cl_masks.lua rename to lua/pulsarui/libraries/cl_masks.lua index 4985c7d..78c0691 100644 --- a/lua/pixelui/libraries/cl_masks.lua +++ b/lua/pulsarui/libraries/cl_masks.lua @@ -1,99 +1,99 @@ ---- ---- Modified Melon's Masks ---- https://github.com/melonstuff/melonsmasks/ ---- Licensed under MIT (https://github.com/melonstuff/melonsmasks/blob/main/LICENSE) ---- - -PulsarUI.Masks = {} - -PulsarUI.Masks.Src = {} -PulsarUI.Masks.Dest = {} - -PulsarUI.Masks.Src.RT = GetRenderTargetEx("PIXEL_Masks_Src", ScrW(), ScrH(), RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_SEPARATE, bit.bor(1, 256), 0, IMAGE_FORMAT_BGRA8888) -PulsarUI.Masks.Dest.RT = GetRenderTargetEx("PIXEL_Masks_Dest", ScrW(), ScrH(), RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_SEPARATE, bit.bor(1, 256), 0, IMAGE_FORMAT_BGRA8888) - -PulsarUI.Masks.Src.Mat = CreateMaterial("PIXEL_Masks_Src", "UnlitGeneric", { - ["$basetexture"] = PulsarUI.Masks.Src.RT:GetName(), - ["$translucent"] = "1", - ["$vertexalpha"] = "1", - ["$vertexcolor"] = "1", -}) -PulsarUI.Masks.Dest.Mat = CreateMaterial("PIXEL_Masks_Dest", "UnlitGeneric", { - ["$basetexture"] = PulsarUI.Masks.Dest.RT:GetName(), - ["$translucent"] = "1", - ["$vertexalpha"] = "1", - ["$vertexcolor"] = "1", -}) - -PulsarUI.Masks.KIND_CUT = {BLEND_ZERO, BLEND_SRC_ALPHA, BLENDFUNC_ADD} -PulsarUI.Masks.KIND_STAMP = {BLEND_ZERO, BLEND_ONE_MINUS_SRC_ALPHA, BLENDFUNC_ADD} - -local camStart2D = cam.Start2D -local camEnd2D = cam.End2D -local pushRenderTarget = render.PushRenderTarget -local popRenderTarget = render.PopRenderTarget -local renderClear = render.Clear -local renderOverrideBlend = render.OverrideBlend -local setDrawColor = surface.SetDrawColor -local setMaterial = surface.SetMaterial -local drawTexturedRect = surface.DrawTexturedRect - -function PulsarUI.Masks.Start() - render.PushRenderTarget(PulsarUI.Masks.Dest.RT) - render.Clear(0, 0, 0, 0, true, true) - - camStart2D() -end - -function PulsarUI.Masks.Source() - camEnd2D() - - popRenderTarget() - pushRenderTarget(PulsarUI.Masks.Src.RT) - renderClear(0, 0, 0, 0, true, true) - - camStart2D() -end - -function PulsarUI.Masks.And(kind) - camEnd2D() - - popRenderTarget() - pushRenderTarget(PulsarUI.Masks.Dest.RT) - - camStart2D() - - renderOverrideBlend(true, kind[1], kind[2], kind[3]) - - setDrawColor(255, 255, 255) - setMaterial(PulsarUI.Masks.Src.Mat) - drawTexturedRect(0, 0, ScrW(), ScrH()) - - renderOverrideBlend(false) - - PulsarUI.Masks.Source() -end -function PulsarUI.Masks.End(kind) - kind = kind or PulsarUI.Masks.KIND_CUT - - camEnd2D() - - popRenderTarget() - pushRenderTarget(PulsarUI.Masks.Dest.RT) - - camStart2D() - renderOverrideBlend(true, kind[1], kind[2], kind[3]) - - setDrawColor(255, 255, 255) - setMaterial(PulsarUI.Masks.Src.Mat) - drawTexturedRect(0, 0, ScrW(), ScrH()) - - renderOverrideBlend(false) - camEnd2D() - - popRenderTarget() - - setDrawColor(255, 255, 255) - setMaterial(PulsarUI.Masks.Dest.Mat) - drawTexturedRect(0, 0, ScrW(), ScrH()) +--- +--- Modified Melon's Masks +--- https://github.com/melonstuff/melonsmasks/ +--- Licensed under MIT (https://github.com/melonstuff/melonsmasks/blob/main/LICENSE) +--- + +PulsarUI.Masks = {} + +PulsarUI.Masks.Src = {} +PulsarUI.Masks.Dest = {} + +PulsarUI.Masks.Src.RT = GetRenderTargetEx("PIXEL_Masks_Src", ScrW(), ScrH(), RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_SEPARATE, bit.bor(1, 256), 0, IMAGE_FORMAT_BGRA8888) +PulsarUI.Masks.Dest.RT = GetRenderTargetEx("PIXEL_Masks_Dest", ScrW(), ScrH(), RT_SIZE_NO_CHANGE, MATERIAL_RT_DEPTH_SEPARATE, bit.bor(1, 256), 0, IMAGE_FORMAT_BGRA8888) + +PulsarUI.Masks.Src.Mat = CreateMaterial("PIXEL_Masks_Src", "UnlitGeneric", { + ["$basetexture"] = PulsarUI.Masks.Src.RT:GetName(), + ["$translucent"] = "1", + ["$vertexalpha"] = "1", + ["$vertexcolor"] = "1", +}) +PulsarUI.Masks.Dest.Mat = CreateMaterial("PIXEL_Masks_Dest", "UnlitGeneric", { + ["$basetexture"] = PulsarUI.Masks.Dest.RT:GetName(), + ["$translucent"] = "1", + ["$vertexalpha"] = "1", + ["$vertexcolor"] = "1", +}) + +PulsarUI.Masks.KIND_CUT = {BLEND_ZERO, BLEND_SRC_ALPHA, BLENDFUNC_ADD} +PulsarUI.Masks.KIND_STAMP = {BLEND_ZERO, BLEND_ONE_MINUS_SRC_ALPHA, BLENDFUNC_ADD} + +local camStart2D = cam.Start2D +local camEnd2D = cam.End2D +local pushRenderTarget = render.PushRenderTarget +local popRenderTarget = render.PopRenderTarget +local renderClear = render.Clear +local renderOverrideBlend = render.OverrideBlend +local setDrawColor = surface.SetDrawColor +local setMaterial = surface.SetMaterial +local drawTexturedRect = surface.DrawTexturedRect + +function PulsarUI.Masks.Start() + render.PushRenderTarget(PulsarUI.Masks.Dest.RT) + render.Clear(0, 0, 0, 0, true, true) + + camStart2D() +end + +function PulsarUI.Masks.Source() + camEnd2D() + + popRenderTarget() + pushRenderTarget(PulsarUI.Masks.Src.RT) + renderClear(0, 0, 0, 0, true, true) + + camStart2D() +end + +function PulsarUI.Masks.And(kind) + camEnd2D() + + popRenderTarget() + pushRenderTarget(PulsarUI.Masks.Dest.RT) + + camStart2D() + + renderOverrideBlend(true, kind[1], kind[2], kind[3]) + + setDrawColor(255, 255, 255) + setMaterial(PulsarUI.Masks.Src.Mat) + drawTexturedRect(0, 0, ScrW(), ScrH()) + + renderOverrideBlend(false) + + PulsarUI.Masks.Source() +end +function PulsarUI.Masks.End(kind) + kind = kind or PulsarUI.Masks.KIND_CUT + + camEnd2D() + + popRenderTarget() + pushRenderTarget(PulsarUI.Masks.Dest.RT) + + camStart2D() + renderOverrideBlend(true, kind[1], kind[2], kind[3]) + + setDrawColor(255, 255, 255) + setMaterial(PulsarUI.Masks.Src.Mat) + drawTexturedRect(0, 0, ScrW(), ScrH()) + + renderOverrideBlend(false) + camEnd2D() + + popRenderTarget() + + setDrawColor(255, 255, 255) + setMaterial(PulsarUI.Masks.Dest.Mat) + drawTexturedRect(0, 0, ScrW(), ScrH()) end \ No newline at end of file diff --git a/lua/pixelui/libraries/cl_ui3d2d.lua b/lua/pulsarui/libraries/cl_ui3d2d.lua similarity index 100% rename from lua/pixelui/libraries/cl_ui3d2d.lua rename to lua/pulsarui/libraries/cl_ui3d2d.lua diff --git a/lua/pixelui/menus/cl_message_popup.lua b/lua/pulsarui/menus/cl_message_popup.lua similarity index 100% rename from lua/pixelui/menus/cl_message_popup.lua rename to lua/pulsarui/menus/cl_message_popup.lua diff --git a/lua/pixelui/menus/cl_query_popup.lua b/lua/pulsarui/menus/cl_query_popup.lua similarity index 100% rename from lua/pixelui/menus/cl_query_popup.lua rename to lua/pulsarui/menus/cl_query_popup.lua diff --git a/lua/pixelui/menus/cl_string_request_popup.lua b/lua/pulsarui/menus/cl_string_request_popup.lua similarity index 100% rename from lua/pixelui/menus/cl_string_request_popup.lua rename to lua/pulsarui/menus/cl_string_request_popup.lua diff --git a/lua/pixelui/menus/test/cl_menu.lua b/lua/pulsarui/menus/test/cl_menu.lua similarity index 100% rename from lua/pixelui/menus/test/cl_menu.lua rename to lua/pulsarui/menus/test/cl_menu.lua diff --git a/lua/pixelui/menus/test/pages/cl_avatar.lua b/lua/pulsarui/menus/test/pages/cl_avatar.lua similarity index 100% rename from lua/pixelui/menus/test/pages/cl_avatar.lua rename to lua/pulsarui/menus/test/pages/cl_avatar.lua diff --git a/lua/pixelui/menus/test/pages/cl_buttons.lua b/lua/pulsarui/menus/test/pages/cl_buttons.lua similarity index 100% rename from lua/pixelui/menus/test/pages/cl_buttons.lua rename to lua/pulsarui/menus/test/pages/cl_buttons.lua diff --git a/lua/pixelui/menus/test/pages/cl_navigation.lua b/lua/pulsarui/menus/test/pages/cl_navigation.lua similarity index 100% rename from lua/pixelui/menus/test/pages/cl_navigation.lua rename to lua/pulsarui/menus/test/pages/cl_navigation.lua diff --git a/lua/pixelui/menus/test/pages/cl_other.lua b/lua/pulsarui/menus/test/pages/cl_other.lua similarity index 100% rename from lua/pixelui/menus/test/pages/cl_other.lua rename to lua/pulsarui/menus/test/pages/cl_other.lua diff --git a/lua/pixelui/menus/test/pages/cl_scrollpanel.lua b/lua/pulsarui/menus/test/pages/cl_scrollpanel.lua similarity index 100% rename from lua/pixelui/menus/test/pages/cl_scrollpanel.lua rename to lua/pulsarui/menus/test/pages/cl_scrollpanel.lua diff --git a/lua/pixelui/menus/test/pages/cl_text.lua b/lua/pulsarui/menus/test/pages/cl_text.lua similarity index 100% rename from lua/pixelui/menus/test/pages/cl_text.lua rename to lua/pulsarui/menus/test/pages/cl_text.lua diff --git a/lua/pixelui/sh_config.lua b/lua/pulsarui/sh_config.lua similarity index 100% rename from lua/pixelui/sh_config.lua rename to lua/pulsarui/sh_config.lua