Skip to content

Commit

Permalink
new config option UseGamemodeMapPrefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
plally committed Feb 2, 2024
1 parent 5128dc2 commit 599a2b5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lua/mapvote/client/modules/admin_menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ local configMenuOptions = {
{ "Minimum players required to enable RTVing", schema.fields.RTVPlayerCount, "RTVPlayerCount" },
{ seperator = true, text = "Maps" },
{ "Map prefixes automatically enabled, comma seperated list", schema.fields.MapPrefixes, "MapPrefixes" },
{ "Use gamemode map prefixes", schema.fields.UseGamemodeMapPrefixes, "UseGamemodeMapPrefixes" },
{ "Disable a map after its played", schema.fields.EnableCooldown, "EnableCooldown" },
{ "The amount of maps that need to be played before a map is enabled again", schema.fields.MapsBeforeRevote, "MapsBeforeRevote" },
}
Expand Down Expand Up @@ -113,7 +114,7 @@ function MapVote.addMapRow( map )
local row = vgui.Create( "Panel" ) --[[@as Panel]]
row:SetSize( 800, 128 )

local mapIcon = vgui.Create( "MapVote_MapIcon", row ) --[[@as MapIcon]]
local mapIcon = vgui.Create( "MapVote_MapIcon", row )
mapIcon:SetSize( 128, 128 )
mapIcon:SetMap( map )
mapIcon:Dock( LEFT )
Expand Down
6 changes: 4 additions & 2 deletions lua/mapvote/client/vgui/config_panel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ function PANEL:AddConfigItem( displayName, itemType, action, startingValue )
entryPanel:SetEnabled( true )
entryPanel.OnValueChanged = function( _, val )
val = string.Split( val, "," )
for i = 1, #val do
for i = #val, 1, -1 do
val[i] = string.Trim( val[i] )
if val[i] == "" then
table.remove( val, i )
end
end
PrintTable( val )
local ok, err = itemType:Validate( val )
errLabel:SetText( err or "" )
errLabel:Dock( LEFT )
Expand Down
8 changes: 7 additions & 1 deletion lua/mapvote/server/modules/map_vote.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
function MapVote.isMapAllowed( m )
local conf = MapVote.config
local prefixes = conf.MapPrefixes or MapVote.gamemodeMapPrefixes or {}

local prefixes = {}
table.Add( prefixes, conf.MapPrefixes or {} )
if conf.UseGamemodeMapPrefixes then
prefixes = table.Add( prefixes, MapVote.gamemodeMapPrefixes or {} )
end

local hookResult = hook.Run( "MapVote_IsMapAllowed", m )
if hookResult ~= nil then return hookResult end

Expand Down
3 changes: 3 additions & 0 deletions lua/mapvote/shared/modules/config_schema.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ local schema = SV.Object {
RTVPercentPlayersRequired = SV.Number { min = 0, max = 1 },
RTVWait = SV.Number(),
SortMaps = SV.Bool(),
UseGamemodeMapPrefixes = SV.Bool(),
MapPrefixes = SV.List( SV.String() ):Optional(),
EnableCooldown = SV.Bool(),
MapsBeforeRevote = SV.Int { min = 1 },
Expand All @@ -26,6 +27,8 @@ local default = {
EnableCooldown = true,
MapsBeforeRevote = 3,
RTVPlayerCount = 3,
UseGamemodeMapPrefixes = true,
MapPrefixes = {},
IncludedMaps = {},
ExcludedMaps = {},
RTVPercentPlayersRequired = 0.66,
Expand Down

0 comments on commit 599a2b5

Please sign in to comment.