Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rewrite vote area #49

Merged
merged 8 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lua/mapvote/client/modules/map_vote.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ end
function MapVote.ChangeVote( ply, mapIndex )
if not IsValid( ply ) then return end
if not IsValid( MapVote.Panel ) then return end

local mapData = MapVote.Panel.voteArea:GetMapDataByIndex( mapIndex )
MapVote.Panel.voteArea:SetVote( ply, mapData.map )
MapVote.Panel.voteArea:SetVote( ply, mapIndex )
end

function MapVote.StartVote( maps, endTime )
Expand Down Expand Up @@ -78,19 +76,18 @@ function MapVote.StartVote( maps, endTime )

countdownLabel:SetText( string.FormattedTime( timeLeft or 0, "%02i:%02i" ) )
end )
local voteArea = vgui.Create( "MapVote_Vote", frame ) --[[@as VoteArea]]
local voteArea = vgui.Create( "MapVote_VoteArea", frame )
local margin = 10
voteArea:Dock( FILL )
voteArea:DockMargin( margin, margin, margin, margin )
voteArea:SetMaps( maps )
voteArea:InvalidateLayout( true )
voteArea:InvalidateParent( true )
voteArea:SetMaps( maps )

frame:SetTall( voteArea:GetTotalRowHeight() + infoRow:GetTall() + margin * 2 + 34 )
frame:SetTall( voteArea:GetTotalRowHeight() + infoRow:GetTall() + margin * 3 + 20 )
frame:SetWide( voteArea:GetTotalRowWidth() + margin * 2 + 10 )
voteArea:InvalidateParent( true )
voteArea:InvalidateLayout( true )
frame:Center()
voteArea:UpdateRowPositions()

local lastClicked = CurTime()
---@diagnostic disable-next-line: duplicate-set-field
Expand Down
4 changes: 2 additions & 2 deletions lua/mapvote/client/vgui/map_icon.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---@class MapIcon : Panel
---@class MapVote_MapIcon : Panel
local PANEL = {}

function PANEL:Init()
Expand Down Expand Up @@ -30,7 +30,7 @@ function PANEL:SetMap( map )
MapVote.ThumbDownloader:QueueDownload( map, function( filepath )
MapVote.TaskManager.AddFunc( function()
---@diagnostic disable-next-line: missing-parameter
self.button:SetImage( filepath or noIcon )
self.button:SetImage( filepath )
end )
end )
end
Expand Down
Loading
Loading