Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Pulsar-Dev/pixel-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
Lythium4848 committed Aug 16, 2023
2 parents 84ba20b + b7b7b49 commit e5d3793
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 93 deletions.
6 changes: 3 additions & 3 deletions lua/autorun/sh_pixelui_loader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
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 <https://www.gnu.org/licenses/>.
--]]
along with this program. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
]]

PIXEL = PIXEL or {}
PIXEL.UI = PIXEL.UI or {}
Expand Down
56 changes: 0 additions & 56 deletions lua/pixelui/core/cl_imgur.lua

This file was deleted.

68 changes: 64 additions & 4 deletions lua/pixelui/elements/cl_avatar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
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 <https://www.gnu.org/licenses/>.
--]]
along with this program. If not, see <https://www.gnu.org/licenses/>.
You should have received a copy of the GNU General Public License
]]

local PANEL = {}

AccessorFunc(PANEL, "Rounding", "Rounding", FORCE_NUMBER)
AccessorFunc(PANEL, "MaskSize", "MaskSize", FORCE_NUMBER)

function PANEL:Init()
Expand Down Expand Up @@ -68,4 +69,63 @@ function PANEL:Paint(w, h)
render.ClearStencil()
end

vgui.Register("PIXEL.Avatar", PANEL, "Panel")
vgui.Register("PIXEL.Avatar", PANEL, "Panel")


-- old avatar

PANEL = {}

AccessorFunc(PANEL, "MaskSize", "MaskSize", FORCE_NUMBER)

function PANEL:Init()
PIXEL.Warn("Please update to using PIXEL.Avatar instead of using PIXEL.OldAvatar! This panel is deprecated and may be removed in a future release.")
self.Avatar = vgui.Create("AvatarImage", self)
self.Avatar:SetPaintedManually(true)

self.CirclePoly = {}
self:SetRounding(10)
end

function PANEL:PerformLayout(w, h)
self.Avatar:SetSize(w, h)
end

function PANEL:SetPlayer(ply, size)
self.Avatar:SetPlayer(ply, size)
end

function PANEL:SetSteamID(id, size)
self.Avatar:SetSteamID(id, size)
end

function PANEL:Paint(w, h)
render.ClearStencil()
render.SetStencilEnable(true)

render.SetStencilWriteMask(1)
render.SetStencilTestMask(1)

render.SetStencilFailOperation(STENCILOPERATION_REPLACE)
render.SetStencilPassOperation(STENCILOPERATION_ZERO)
render.SetStencilZFailOperation(STENCILOPERATION_ZERO)
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_NEVER)
render.SetStencilReferenceValue(1)

PIXEL.DrawFullRoundedBox(self:GetRounding() or self:GetMaskSize(), 0, 0, w, h, color_white)

render.SetStencilFailOperation(STENCILOPERATION_ZERO)
render.SetStencilPassOperation(STENCILOPERATION_REPLACE)
render.SetStencilZFailOperation(STENCILOPERATION_ZERO)
render.SetStencilCompareFunction(STENCILCOMPARISONFUNCTION_EQUAL)
render.SetStencilReferenceValue(1)

self.Avatar:SetPaintedManually(false)
self.Avatar:PaintManual()
self.Avatar:SetPaintedManually(true)

render.SetStencilEnable(false)
render.ClearStencil()
end

vgui.Register("PIXEL.OldAvatar", PANEL, "Panel")
3 changes: 1 addition & 2 deletions lua/pixelui/elements/cl_category.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
--]]

]]
local PANEL = {}
AccessorFunc(PANEL, "Title", "Title", FORCE_STRING)
PIXEL.RegisterFont("UI.CategoryHeader", "Rubik", 19, 600)
Expand Down
22 changes: 15 additions & 7 deletions lua/pixelui/elements/cl_combo_box.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function PANEL:Init()
self:SetTextAlign(TEXT_ALIGN_LEFT)
self:SetSortItems(true)
self:SetSounds(false)
self:SetSounds(false)
end

function PANEL:PerformLayout(w, h)
Expand All @@ -48,6 +47,7 @@ function PANEL:Clear()
if not self.Menu then return end
self.Menu:Remove()
self:OnClose()
self:OnClose()
self.Menu = nil
end

Expand Down Expand Up @@ -87,6 +87,10 @@ function PANEL:ChooseOption(value, index)
index = table.KeyFromValue(self.Data, value)
end

if not index then
index = table.KeyFromValue(self.Data, value)
end

self.selected = index
local choicesKey = table.KeyFromValue(self.Choices, value)

Expand All @@ -96,6 +100,14 @@ function PANEL:ChooseOption(value, index)
self:SetIcon(nil)
end

local choicesKey = table.KeyFromValue(self.Choices, value)

Check warning on line 103 in lua/pixelui/elements/cl_combo_box.lua

View workflow job for this annotation

GitHub Actions / lint / lint

"Shadowing"

Variable 'choicesKey' shadows existing binding, defined at line 95, column 11

if self.ChoiceIcons[choicesKey] then
self:SetIcon(self.ChoiceIcons[choicesKey])
else
self:SetIcon(nil)
end

self:OnSelect(index, value, self.Data[index])

if not self:GetSizeToText() then return end
Expand Down Expand Up @@ -188,6 +200,8 @@ function PANEL:OpenMenu(pControlOpener)
if not IsValid(self) then return end
PIXEL.PlayExpand("close")
self:OnClose()
PIXEL.PlayExpand("close")
self:OnClose()
self:SetToggle(false)
end
end
Expand Down Expand Up @@ -227,12 +241,6 @@ end
function PANEL:OnClose()
end

function PANEL:OnOpen()
end

function PANEL:OnClose()
end

function PANEL:PaintOver(w, h)
local dropBtnSize = PIXEL.Scale(8)
PIXEL.DrawImgur(w - dropBtnSize - PIXEL.Scale(8), h / 2 - dropBtnSize / 2, dropBtnSize, dropBtnSize, "IP0UlBl", PIXEL.Colors.PrimaryText)
Expand Down
10 changes: 3 additions & 7 deletions lua/pixelui/elements/cl_frame.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
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 <https://www.gnu.org/licenses/>.
--]]

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]
local PANEL = {}
AccessorFunc(PANEL, "Draggable", "Draggable", FORCE_BOOL)
AccessorFunc(PANEL, "Sizable", "Sizable", FORCE_BOOL)
Expand Down Expand Up @@ -291,9 +290,6 @@ end
function PANEL:PaintMore(w, h)
end

function PANEL:PaintMore(w, h)
end

function PANEL:Paint(w, h)
PIXEL.DrawRoundedBox(8, 0, 0, w, h, PIXEL.Colors.Header)
local contentX, contentY = self.SideBar and PIXEL.Scale(200) or self.ContentPadding, self.HeaderH
Expand Down
4 changes: 4 additions & 0 deletions lua/pixelui/elements/cl_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ function PANEL:Paint(w, h)
PIXEL.DrawRoundedBox(8, 0, 0, w, h, self.BackgroundCol)
end

function PANEL:Paint(w, h)
PIXEL.DrawRoundedBox(8, 0, 0, w, h, self.BackgroundCol)
end

function PANEL:OptionSelectedInternal(option)
self:OptionSelected(option, option:GetText())
end
Expand Down
9 changes: 3 additions & 6 deletions lua/pixelui/elements/cl_sidebar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
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 <https://www.gnu.org/licenses/>.
--]]

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]
local PANEL = {}
AccessorFunc(PANEL, "Name", "Name", FORCE_STRING)
AccessorFunc(PANEL, "ImgurID", "ImgurID", FORCE_STRING)
Expand All @@ -24,7 +23,6 @@ PIXEL.RegisterFont("SidebarItem", "Rubik", 19, 600)
function PANEL:Init()
self:SetName("N/A")
self:SetDrawOutline(true)

self:SetSounds(false)
self.TextCol = PIXEL.CopyColor(PIXEL.Colors.SecondaryText)
self.BackgroundCol = PIXEL.CopyColor(PIXEL.Colors.Transparent)
Expand Down Expand Up @@ -75,7 +73,6 @@ AccessorFunc(PANEL, "ImgurScale", "ImgurScale", FORCE_NUMBER)
AccessorFunc(PANEL, "ImgurOffset", "ImgurOffset", FORCE_NUMBER)
AccessorFunc(PANEL, "ButtonOffset", "ButtonOffset", FORCE_NUMBER)
AccessorFunc(PANEL, "ButtonBtmOffset", "ButtonBtmOffset", FORCE_NUMBER)
AccessorFunc(PANEL, "ButtonBtmOffset", "ButtonBtmOffset", FORCE_NUMBER)

function PANEL:Init()
self.Items = {}
Expand Down
7 changes: 3 additions & 4 deletions lua/pixelui/elements/cl_text_button.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
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 <https://www.gnu.org/licenses/>.
--]]

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]
local PANEL = {}
AccessorFunc(PANEL, "Text", "Text", FORCE_STRING)
AccessorFunc(PANEL, "TextAlign", "TextAlign", FORCE_NUMBER)
Expand Down
6 changes: 3 additions & 3 deletions lua/pixelui/elements/cl_text_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
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 <https://www.gnu.org/licenses/>.
--]]
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
]]

local PANEL = {}

Expand Down
1 change: 0 additions & 1 deletion lua/pixelui/sh_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
0 = No - forced off.
1 = No - but users can opt in via convar (pixel_ui_override_popups).
2 = Yes - but users must opt in via convar.
2 = Yes - but users must opt in via convar.
3 = Yes - forced on.
]]
PIXEL.OverrideDermaMenus = 0
Expand Down

0 comments on commit e5d3793

Please sign in to comment.