diff --git a/gamemodes/terrortown/gamemode/client/cl_equip.lua b/gamemodes/terrortown/gamemode/client/cl_equip.lua index b729dc30d..8c43c7b17 100644 --- a/gamemodes/terrortown/gamemode/client/cl_equip.lua +++ b/gamemodes/terrortown/gamemode/client/cl_equip.lua @@ -408,7 +408,7 @@ local function CreateEquipmentList(t) local ic = nil -- Create icon panel - if item.ttt2_cached_material then + if item.iconMaterial then ic = vgui.Create("LayeredIcon", dlist) if item.custom and showCustomVar:GetBool() then @@ -463,10 +463,10 @@ local function CreateEquipmentList(t) end ic:SetIconSize(itemSize or 64) - ic:SetMaterial(item.ttt2_cached_material) - elseif item.ttt2_cached_model then + ic:SetMaterial(item.iconMaterial) + elseif item.itemModel then ic = vgui.Create("SpawnIcon", dlist) - ic:SetModel(item.ttt2_cached_model) + ic:SetModel(item.itemModel) else print("Equipment item does not have model or material specified: " .. tostring(item) .. "\n") @@ -1109,17 +1109,23 @@ end -- @param table item -- @realm client function TTT2CacheEquipMaterials(item) - --if there is no material or model, the item should probably not be available in the shop - if item.material and item.material ~= "vgui/ttt/icon_id" then - item.ttt2_cached_material = Material(item.material) - if item.ttt2_cached_material:IsError() then - -- Setting fallback material - item.ttt2_cached_material = fallback_mat + item.isEquipment = true + + if item.material then + item.iconMaterial = Material(item.material) + + if item.iconMaterial:IsError() then + -- setting fallback error material + item.iconMaterial = fallback_mat end - elseif item.model and item.model ~= "models/weapons/w_bugbait.mdl" then - --do not use fallback mat and use model instead - item.ttt2_cached_material = nil - item.ttt2_cached_model = model + elseif item.model then + -- do not use fallback mat and use model instead + item.itemModel = model + end + + --if there is no sensible material or model, the item should probably not be available in the shop + if item.material == "vgui/ttt/icon_id" or item.model == "models/weapons/w_bugbait.mdl" then + item.isEquipment = false end end diff --git a/gamemodes/terrortown/gamemode/client/cl_search.lua b/gamemodes/terrortown/gamemode/client/cl_search.lua index d999688dd..074e58f83 100644 --- a/gamemodes/terrortown/gamemode/client/cl_search.lua +++ b/gamemodes/terrortown/gamemode/client/cl_search.lua @@ -2,7 +2,6 @@ -- Body search popup -- @section body_search_manager -local RT = LANG.GetRawTranslation local net = net local pairs = pairs local util = util diff --git a/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua b/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua index eabd51970..865e30042 100644 --- a/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua +++ b/gamemodes/terrortown/gamemode/client/cl_vskin/default_skin.lua @@ -25,7 +25,6 @@ local TryT = LANG.TryTranslation local ParT = LANG.GetParamTranslation local mathRound = math.Round -local mathMax = math.max local utilGetDefaultColor = util.GetDefaultColor local utilGetChangedColor = util.GetChangedColor @@ -1684,7 +1683,7 @@ function SKIN:PaintInfoItemTTT2(panel, w, h) for i = 1, #text do local par = text[i].params - if (par) then + if par then -- process params (translation) for k, v in pairs(par) do par[k] = TryT(v) diff --git a/lua/terrortown/menus/gamemode/equipment.lua b/lua/terrortown/menus/gamemode/equipment.lua index 814434d42..7e9dfa2df 100644 --- a/lua/terrortown/menus/gamemode/equipment.lua +++ b/lua/terrortown/menus/gamemode/equipment.lua @@ -29,14 +29,14 @@ function CLGAMEMODEMENU:InitializeVirtualMenus() local equipment = equipments[i] -- Only keep ttt-equipments that are cached - if not equipment.ttt2_cached_material and not equipment.ttt2_cached_model then continue end + if not equipment.iconMaterial and not equipment.itemModel then continue end counter = counter + 1 virtualSubmenus[counter] = tableCopy(equipmentMenuBase) virtualSubmenus[counter].equipment = equipment virtualSubmenus[counter].isItem = items.IsItem(equipment) - virtualSubmenus[counter].icon = equipment.ttt2_cached_material + virtualSubmenus[counter].icon = equipment.iconMaterial virtualSubmenus[counter].iconFullSize = true end end diff --git a/lua/terrortown/menus/gamemode/shops/base_shops.lua b/lua/terrortown/menus/gamemode/shops/base_shops.lua index f83f7fb73..a3a65b7dc 100644 --- a/lua/terrortown/menus/gamemode/shops/base_shops.lua +++ b/lua/terrortown/menus/gamemode/shops/base_shops.lua @@ -70,7 +70,7 @@ function CLGAMEMODESUBMENU:Populate(parent) local item = items[i] -- Only keep ttt-equipments that are cached - if not item.ttt2_cached_material and not item.ttt2_cached_model then continue end + if not item.isEquipment then continue end counter = counter + 1 @@ -98,7 +98,7 @@ function CLGAMEMODESUBMENU:Populate(parent) form:MakeCard({ label = item.shopTitle, - icon = item.ttt2_cached_material, + icon = item.iconMaterial, initial = item.CanBuy[roleIndex] and MODE_ADDED or MODE_DEFAULT, -- todo: this should be the current mode OnChange = function(_, _, newMode) local isAdded = newMode == MODE_ADDED or newMode == MODE_INHERIT_ADDED diff --git a/lua/ttt2/libraries/bodysearch.lua b/lua/ttt2/libraries/bodysearch.lua index e363a886c..180d212f0 100644 --- a/lua/ttt2/libraries/bodysearch.lua +++ b/lua/ttt2/libraries/bodysearch.lua @@ -393,7 +393,7 @@ if CLIENT then local function TypeToMaterial(type, data) if type == "wep" then - return util.WeaponForClass(data.wep).ttt2_cached_material + return util.WeaponForClass(data.wep).iconMaterial elseif type == "dmg" then return DamageToIconMaterial(data) elseif type == "death_time" then @@ -479,7 +479,8 @@ if CLIENT then local search = {} for i = 1, #bodysearch.searchResultOrder do - local searchData = bodysearch.GetContentFromData(bodysearch.searchResultOrder[i], raw) + local type = bodysearch.searchResultOrder[i] + local searchData = bodysearch.GetContentFromData(type, raw) if not searchData then continue end @@ -499,13 +500,16 @@ if CLIENT then else transText = transText .. LANG.TryTranslation(text[1].body) .. " " end - end - search[bodysearch.searchResultOrder[i]] = { - img = searchData.iconMaterial:GetName(), - text = transText, - p = i -- sorting number - } + search[type] = { + img = searchData.iconMaterial:GetName(), + text = transText, + p = i -- sorting number + } + + -- special cases with icon text + search[type].text_icon = TypeToIconText(type, raw)() + end --- -- @realm client