From 92761ce822f482a3762e7962de6a2b016b8f6626 Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Mon, 21 Aug 2023 16:44:38 +0200 Subject: [PATCH] mapvote 2.1.3 Added logic to hide the map when there is only one map players can vote, just like how modes work (forgot to implement maps as well) --- mapvote/mapvote.gsc | 66 ++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/mapvote/mapvote.gsc b/mapvote/mapvote.gsc index f638638..cae1500 100644 --- a/mapvote/mapvote.gsc +++ b/mapvote/mapvote.gsc @@ -198,6 +198,10 @@ ListenForVoteInputs() { continue; // stop/skip execution } + else if (section == "mode" && level.mapvote["maps"]["by_index"].size <= 1 && input == "mapvote_unselect") + { + continue; // stop/skip execution + } if (input == "mapvote_down") { @@ -317,7 +321,7 @@ CreateVoteMenu() { sectionsSeparation = 0; - if (level.mapvote["modes"]["by_index"].size > 1) + if (level.mapvote["modes"]["by_index"].size > 1 && level.mapvote["maps"]["by_index"].size > 1) { sectionsSeparation = 1; } @@ -329,39 +333,42 @@ CreateVoteMenu() hudLastPosY = -(((level.mapvote["maps"]["by_index"].size * spacing) / 2) - (spacing / 2)); } - for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++) + if (level.mapvote["maps"]["by_index"].size > 1) { - mapVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", GetDvarInt("mapvote_horizontal_spacing"), hudLastPosY, true, 0); - mapVotesHud.color = GetGscColor(GetDvar("mapvote_colors_selected")); - - level.mapvote["hud"]["maps"][mapIndex] = mapVotesHud; - - foreach (player in GetHumanPlayers()) + for (mapIndex = 0; mapIndex < level.mapvote["maps"]["by_index"].size; mapIndex++) { - mapName = ""; + mapVotesHud = CreateHudText("", "objective", 1.5, "LEFT", "CENTER", GetDvarInt("mapvote_horizontal_spacing"), hudLastPosY, true, 0); + mapVotesHud.color = GetGscColor(GetDvar("mapvote_colors_selected")); - if (IsMultiplayerMode()) + level.mapvote["hud"]["maps"][mapIndex] = mapVotesHud; + + foreach (player in GetHumanPlayers()) { - mapName = level.mapvote["maps"]["by_index"][mapIndex]; - } - else - { - mapName = level.mapvote["maps"]["by_index"][mapIndex][0]; + mapName = ""; + + if (IsMultiplayerMode()) + { + mapName = level.mapvote["maps"]["by_index"][mapIndex]; + } + else + { + mapName = level.mapvote["maps"]["by_index"][mapIndex][0]; + } + + player.mapvote["map"][mapIndex]["hud"] = player CreateHudText(mapName, "objective", 1.5, "LEFT", "CENTER", -(GetDvarInt("mapvote_horizontal_spacing")), hudLastPosY); + + if (mapIndex == 0) + { + player UpdateSelection("map", 0); + } + else + { + SetElementUnselected(player.mapvote["map"][mapIndex]["hud"]); + } } - player.mapvote["map"][mapIndex]["hud"] = player CreateHudText(mapName, "objective", 1.5, "LEFT", "CENTER", -(GetDvarInt("mapvote_horizontal_spacing")), hudLastPosY); - - if (mapIndex == 0) - { - player UpdateSelection("map", 0); - } - else - { - SetElementUnselected(player.mapvote["map"][mapIndex]["hud"]); - } + hudLastPosY += spacing; } - - hudLastPosY += spacing; } if (IsMultiplayerMode() && level.mapvote["modes"]["by_index"].size > 1) @@ -384,6 +391,11 @@ CreateVoteMenu() hudLastPosY += spacing; } + + if (level.mapvote["maps"]["by_index"].size <= 1) + { + player UpdateSelection("mode", 0); + } } foreach(player in GetHumanPlayers())