-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(icons): Make sure that UniqueIDs are generated for Lua defined it…
…ems. Fixes an LUA error
- Loading branch information
1 parent
d6f08d4
commit d58728f
Showing
9 changed files
with
139 additions
and
94 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
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,34 @@ | ||
local PANEL = {} | ||
|
||
function PANEL:Init( ) | ||
end | ||
|
||
function PANEL:PerformLayout() | ||
self.BaseClass.PerformLayout(self) | ||
|
||
self.Label:SetWide(self:GetWide()) | ||
self.Label:SetPos(0, self:GetTall() - 25) | ||
self.Label:SetTall(25) | ||
end | ||
|
||
function PANEL:SetItemClass( itemClass ) | ||
self.BaseClass.SetItemClass( self, itemClass ) | ||
|
||
if itemClass.iconInfo.inv.useMaterialIcon then | ||
self.image:SetImage( itemClass.iconInfo.inv.iconMaterial ) | ||
end | ||
end | ||
|
||
function PANEL:SetItem( item ) | ||
self:SetItemClass( item.class ) | ||
end | ||
|
||
function PANEL:OnSelected( ) | ||
hook.Run( "PACItemSelected", self.itemClass ) | ||
end | ||
|
||
function PANEL:OnDeselected( ) | ||
hook.Run( "PACItemDeSelected", self.itemClass ) | ||
end | ||
|
||
derma.DefineControl( "DPointshopHatIcon", "", PANEL, "DCsgoItemIcon" ) |
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
File renamed without changes.
File renamed without changes.
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,66 @@ | ||
--[[ | ||
Provides a renderer for Hat Icons. | ||
]]-- | ||
|
||
local plyModel = hook.Run( "PS2_GetPreviewModel" ) or "models/player/alyx.mdl" | ||
local entity = ClientsideModel( plyModel, RENDER_GROUP_OPAQUE_ENTITY ) | ||
pac.SetupENT( entity ) | ||
entity:SetNoDraw(true) | ||
entity:SetIK( false ) | ||
local colAmbientLight = Color( 50, 50, 50 ) | ||
local colColor = Color( 255, 255, 255, 255 ) | ||
local directionalLight = { | ||
[BOX_TOP] = Color(255, 255, 255), | ||
[BOX_FRONT] = Color(255, 255, 255) | ||
} | ||
local function PaintHatIcon(itemClass) | ||
local outfit = itemClass.getOutfitForModel(plyModel) | ||
pac.SetupENT( entity ) | ||
entity:AttachPACPart(outfit) | ||
entity:FrameAdvance( 100 ) | ||
|
||
|
||
local viewInfo = itemClass.iconInfo.shop.iconViewInfo | ||
for i = 1, 100 do | ||
pac.Think() | ||
end | ||
|
||
cam.Start3D( viewInfo.origin, viewInfo.angles, viewInfo.fov - 20, 0, 0, 512, 512, 5, 4096 ) | ||
cam.IgnoreZ( true ) | ||
render.SuppressEngineLighting( true ) | ||
render.SetLightingOrigin( entity:GetPos() ) | ||
render.ResetModelLighting( colAmbientLight.r/255, colAmbientLight.g/255, colAmbientLight.b/255 ) | ||
render.SetColorModulation( colColor.r/255, colColor.g/255, colColor.b/255 ) | ||
render.SetBlend( 1 ) | ||
|
||
for i=0, 6 do | ||
local col = directionalLight[ i ] | ||
if ( col ) then | ||
render.SetModelLighting( i, col.r/255, col.g/255, col.b/255 ) | ||
end | ||
end | ||
|
||
pac.FlashlightDisable( true ) | ||
pac.ForceRendering( true ) | ||
pac.RenderOverride( entity, "opaque" ) | ||
pac.RenderOverride( entity, "translucent", true ) | ||
entity:DrawModel( ) | ||
pac.RenderOverride( entity, "translucent", true ) | ||
pac.ForceRendering( false ) | ||
pac.FlashlightDisable( false ) | ||
|
||
cam.IgnoreZ( false ) | ||
render.SuppressEngineLighting( false ) | ||
cam.End3D( ) | ||
|
||
entity:RemovePACPart(outfit) | ||
end | ||
|
||
|
||
local HatRendererMixin = {} | ||
function HatRendererMixin:included( klass ) | ||
klass.static.PaintIcon = function(cls) | ||
PaintHatIcon(cls) | ||
end | ||
end | ||
Pointshop2.RegisterItemClassMixin( "base_hat", HatRendererMixin ) |
File renamed without changes.
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
11 changes: 11 additions & 0 deletions
11
lua/ps2/modules/pointshop2/hat/cl_dpointshopsimplehaticon.lua
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,11 @@ | ||
local PANEL = {} | ||
|
||
function PANEL:OnSelected( ) | ||
hook.Run( "PACItemSelected", self.itemClass ) | ||
end | ||
|
||
function PANEL:OnDeselected( ) | ||
hook.Run( "PACItemDeSelected", self.itemClass ) | ||
end | ||
|
||
derma.DefineControl( "DPointshopSimpleHatIcon", "", PANEL, "DPointshopSimpleItemIcon" ) |