Skip to content

Commit

Permalink
fixed #1069
Browse files Browse the repository at this point in the history
  • Loading branch information
TimGoll committed Oct 8, 2023
1 parent a04e1da commit 5aae69a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 29 deletions.
34 changes: 20 additions & 14 deletions gamemodes/terrortown/gamemode/client/cl_equip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion gamemodes/terrortown/gamemode/client/cl_search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
-- Body search popup
-- @section body_search_manager

local RT = LANG.GetRawTranslation
local net = net
local pairs = pairs
local util = util
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lua/terrortown/menus/gamemode/equipment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lua/terrortown/menus/gamemode/shops/base_shops.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
20 changes: 12 additions & 8 deletions lua/ttt2/libraries/bodysearch.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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
Expand Down

0 comments on commit 5aae69a

Please sign in to comment.