-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
F1 menu: Added Option to Change Maps via the F1 Menu (#1512)
This adds the option for admins to change the currently played map while also starting an admin commands menu. This makes use of the combo cards added in #1511. ![image](https://github.com/TTT-2/TTT2/assets/13639408/15eb3fdf-e471-4610-a9b3-b56e97bc424b) ![image](https://github.com/TTT-2/TTT2/assets/13639408/ce814f76-aa30-4424-80d7-d4a40870ecd0) ![image](https://github.com/TTT-2/TTT2/assets/13639408/cb6ce1ad-d113-406c-b91a-1578c827cf9f) One thing that was added, is a hook that is called, once a client finished the hot reload. This is needed so that the server knows when the client is ready to resend the data: ```lua --- -- Called when a player is ready again after they reloaded their game. Can be used to send -- data that is needed after a reload. -- @param Player ply The player that finished the reloading -- @hook -- @realm server function GM:TTT2PlayerFinishedReloading(ply) ``` This PR also greatly extended the `map` module which can also then be used by other addons. Details can be checked in the changed files, but most notably are these additions: This function returns a cached material for a given map. This also includes maps that don't have a material. Since this works by downloading these materials from steam, this system works as long as the map is installed via the workshop and the workshop page has a preview image. ```lua --- -- Returns the cached icon of a map if there is an icon available. -- @note This not only uses the icons available on the client through addons, it also -- searches the workshop and tries to assign the corrent workshop icon if there -- is no locally available map icon. -- @param string name The map name -- @return nil|IMaterial Returns the cached material if available -- @realm client function map.GetIcon(name) ``` This function returns a list of all available maps. It already excludes those maps, where the prefix was disabled in the admin settings. This can be used in map mote addons as a map base. ```lua --- -- Returns a sanitized list of maps installed on the server. Sanitized means that only -- valid maps with a prefix that is enabled are listed here. This list is automatically -- synced between the server and all clients. -- @return table Returns a table with the map names -- @realm shared function map.GetList() ```
- Loading branch information
Showing
18 changed files
with
404 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
gamemodes/terrortown/content/materials/vgui/ttt/vskin/helpscreen/commands.vmt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"UnlitGeneric" | ||
{ | ||
"$basetexture" "vgui/ttt/vskin/helpscreen/commands" | ||
"$nocull" 1 | ||
"$nodecal" 1 | ||
"$nolod" 1 | ||
"$translucent" 1 | ||
"$vertexalpha" 1 | ||
"$vertexcolor" 1 | ||
} |
Binary file added
BIN
+342 KB
gamemodes/terrortown/content/materials/vgui/ttt/vskin/helpscreen/commands.vtf
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- @ignore | ||
|
||
CLGAMEMODEMENU.base = "base_gamemodemenu" | ||
|
||
CLGAMEMODEMENU.icon = Material("vgui/ttt/vskin/helpscreen/commands") | ||
CLGAMEMODEMENU.title = "menu_commands_title" | ||
CLGAMEMODEMENU.description = "menu_commands_description" | ||
CLGAMEMODEMENU.priority = 49 | ||
|
||
function CLGAMEMODEMENU:IsAdminMenu() | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- @ignore | ||
|
||
CLGAMEMODESUBMENU.base = "base_gamemodesubmenu" | ||
|
||
CLGAMEMODESUBMENU.priority = 100 | ||
CLGAMEMODESUBMENU.title = "submenu_commands_maps_title" | ||
|
||
local comboBase | ||
|
||
function CLGAMEMODESUBMENU:Populate(parent) | ||
local prefixes = map.GetPrefixes() | ||
local maps = map.GetList() | ||
|
||
local form = vgui.CreateTTT2Form(parent, "header_maps_prefixes") | ||
|
||
for i = 1, #prefixes do | ||
form:MakeCheckBox({ | ||
label = prefixes[i], | ||
serverConvar = "ttt2_enable_map_prefix_" .. prefixes[i], | ||
OnChange = function(_, value) | ||
-- set global bool on the client to bridge network delay | ||
SetGlobalBool("ttt2_enable_map_prefix_" .. prefixes[i], value) | ||
|
||
vguihandler.Rebuild() | ||
end, | ||
}) | ||
end | ||
|
||
local form2 = vgui.CreateTTT2Form(parent, "header_maps_select") | ||
|
||
-- Create combo boxes to select element from | ||
comboBase = form2:MakeIconLayout() | ||
|
||
for i = 1, #maps do | ||
local mapName = maps[i] | ||
local prefix = map.GetPrefix(mapName) | ||
|
||
form2:MakeComboCard({ | ||
icon = map.GetIcon(mapName), | ||
label = mapName, | ||
tag = prefix, | ||
colorTag = util.StringToColor(prefix or ""), | ||
}, comboBase) | ||
end | ||
end | ||
|
||
function CLGAMEMODESUBMENU:PopulateButtonPanel(parent) | ||
local buttonChange = vgui.Create("DButtonTTT2", parent) | ||
|
||
buttonChange:SetText("button_change_map") | ||
buttonChange:SetSize(175, 45) | ||
buttonChange:SetPos(parent:GetWide() - 195, 20) | ||
buttonChange.DoClick = function(btn) | ||
if not comboBase.checked then | ||
return | ||
end | ||
|
||
local mapName = comboBase.checked:GetText() | ||
|
||
map.ChangeLevel(mapName) | ||
end | ||
buttonChange:SetEnabled(true) | ||
end | ||
|
||
function CLGAMEMODESUBMENU:HasButtonPanel() | ||
return true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.