Skip to content
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
6 changes: 5 additions & 1 deletion MapChooserSharp/Modules/MapVote/McsMapVoteController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -915,8 +915,12 @@ private void CastPlayerVote(CCSPlayerController player, byte voteIndex)
}

IMapVoteData votedMap = _mapVoteContent.GetVotingMaps()[voteIndex];

if (_mcsPluginConfigProvider.PluginConfig.VoteConfig.ShouldPrintVoteToChat)
{
PrintLocalizedChatToAll("MapVote.Broadcast.VoteCast", player.PlayerName, GetMapName(votedMap, player).ToString());
}

PrintLocalizedChatToAll("MapVote.Broadcast.VoteCast", player.PlayerName, GetMapName(votedMap, player).ToString());

voteUi.CloseMenu();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ internal interface IMcsVoteConfig
internal McsSupportedMenuType CurrentMenuType { get; }

internal int MaxMenuElements { get; }

internal bool ShouldPrintVoteToChat { get; }
}
16 changes: 12 additions & 4 deletions MapChooserSharp/Modules/PluginConfig/McsPluginConfigParser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MapChooserSharp.Models;
using CounterStrikeSharp.API;
using MapChooserSharp.Models;
using MapChooserSharp.Modules.McsMenu;
using MapChooserSharp.Modules.PluginConfig.Interfaces;
using MapChooserSharp.Modules.PluginConfig.Models;
Expand Down Expand Up @@ -182,13 +183,17 @@ private IMcsVoteConfig ParseVoteConfig(TomlTable tomlModel)
{
throw new InvalidOperationException("MapVote.MaxVoteElements is not found or invalid");
}


if (!voteTable.TryGetValue("ShouldPrintVoteToChat", out var shouldPrintVoteToChatObj) || shouldPrintVoteToChatObj is not bool shouldPrintVoteToChatBool)
{
throw new InvalidOperationException("MapVote.ShouldPrintVoteToChat is not found or invalid");
}

var availableMenus = _avaiableMenuTypes;

var currentMenuType = DecideMenuType(menuTypeStr, availableMenus);

return new McsVoteConfig(availableMenus, currentMenuType, (int)maxVoteElementsLong);
return new McsVoteConfig(availableMenus, currentMenuType, (int)maxVoteElementsLong, shouldPrintVoteToChatBool);
}


Expand Down Expand Up @@ -283,6 +288,9 @@ private void WriteDefaultConfig()
# I would recommend to set 5 when you using BuiltInHtml menu
MaxVoteElements = 5

# Should print vote text to everyone?
ShouldPrintVoteToChat = true


[Nomination]
# What menu type should be use?
Expand Down
3 changes: 2 additions & 1 deletion MapChooserSharp/Modules/PluginConfig/Models/McsVoteConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace MapChooserSharp.Modules.PluginConfig.Models;

public class McsVoteConfig(List<McsSupportedMenuType> availableVoteMenuTypes, McsSupportedMenuType currentMcsVoteMenuType, int maxMenuElements)
public class McsVoteConfig(List<McsSupportedMenuType> availableVoteMenuTypes, McsSupportedMenuType currentMcsVoteMenuType, int maxMenuElements, bool shouldPrintVoteToChat)
: IMcsVoteConfig
{
public List<McsSupportedMenuType> AvailableMenuTypes { get; } = availableVoteMenuTypes;
public McsSupportedMenuType CurrentMenuType { get; } = currentMcsVoteMenuType;
public int MaxMenuElements { get; } = maxMenuElements;
public bool ShouldPrintVoteToChat { get; } = shouldPrintVoteToChat;
}