Lua 带功能的真皮按钮绘图故障
我在这方面有点麻烦。当我使用函数绘制1个SpawnIcon时,它可以正常工作,但当我尝试使用相同的函数并绘制第二个SpawnIcon DoClick函数时,它只能对最后一个SpawnIcon工作。我不知道为什么会发生这种情况,以及如何解决这个问题,请帮助我:( cl_hud.lua(奥特鲁恩) cl_init.lua(在我的实体中) 一些图片,如果我的英语太差的话,你从上面的文字里什么也看不懂Lua 带功能的真皮按钮绘图故障,lua,garrys-mod,Lua,Garrys Mod,我在这方面有点麻烦。当我使用函数绘制1个SpawnIcon时,它可以正常工作,但当我尝试使用相同的函数并绘制第二个SpawnIcon DoClick函数时,它只能对最后一个SpawnIcon工作。我不知道为什么会发生这种情况,以及如何解决这个问题,请帮助我:( cl_hud.lua(奥特鲁恩) cl_init.lua(在我的实体中) 一些图片,如果我的英语太差的话,你从上面的文字里什么也看不懂 DButton和DButtonImage也会出现同样的小UPD:(这是一个很好的实践,用一些论据来宣
DButton和DButtonImage也会出现同样的小UPD:(这是一个很好的实践,用一些论据来宣传你的解决方案,这是可行的!现在我明白了,DScrollPanel就是这个问题。谢谢!在你的代码的原始变量中,SpawnIcon是draw behind Frame,但在DScrollPanel中,我将panel更改为panel1,它开始工作了!谢谢你的帮助!在gmod和parent pan中学习dock埃尔斯
function DrawCrateDERMA( textebat, mdl )
Frame = vgui.Create( "DFrame" ) --Создаёт окно.
Frame:SetTitle( "Оружейный ящик" ) --Устанавливает название окна.
Frame:SetSize( ScrW() * 800/1920, ScrH() * 600/1080 )
Frame:Center()
Frame:SetDraggable( false )
Frame:ShowCloseButton( true )
Frame:MakePopup(true)
Frame:SetBackgroundBlur(false)
Frame.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 5, 0, 0, w, h, Color( 25, 25, 25, 200 ) ) -- Draw a red box instead of the frame
end
--[[----------------Создаём панельки--------------]]
sheet = vgui.Create( "DPropertySheet", Frame )
sheet:Dock( FILL )
--[[----------------Панелька 1--------------]]
panel1 = vgui.Create( "DPanel", sheet )
panel1.Paint = function( self, w, h ) draw.RoundedBox( 100, 0, 0, 280, 120, Color( 0, 0, 0, 0) ) end
sheet:AddSheet( "Основное оружие", panel1, "materials/gunsicon.png" )
sheet.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 5, 0, 0, w, h, Color( 50, 50, 50, 150 ) ) -- Draw a red box instead of the frame
end
end
function DrawCratePrimWeapon(textebat, mdl, posx, posy, functonclick)
local DScrollPanel = vgui.Create( "DScrollPanel" , panel1 )
DScrollPanel:Dock( FILL )
DPanel = DScrollPanel:Add( "DPanel")
DPanel:SetPos( ScrW() * posx/1920, ScrH() * posy/1080 )
DPanel:SetSize( ScrW() * 200/1920, ScrH() * 100/1080 ) -- Set the size of the panel
DPanel:SetBackgroundColor(Color(25,25,25,155))
local ImgKnop = DScrollPanel:Add( "SpawnIcon", panel1 )
ImgKnop:SetPos( ScrW() * 0/1920, ScrH() * 0/1080 ) --// Set position
ImgKnop:SetSize( ScrW() * 200/1920, ScrH() * 100/1080 ) --// OPTIONAL: Use instead of SizeToContents() if you know/want to fix the size
ImgKnop:SetModel( mdl ) --// Set the material - relative to /materials/ directory
ImgKnop:SetParent(DPanel)
ImgKnop.DoClick = function()
print("SUKA")
end
local text1 = DScrollPanel:Add("DLabel",panel1)
text1:SetPos(ScrW() * 0/1920, ScrH() * 75/1080)
text1:SetText(textebat)
text1:SizeToContents()
text1:SetParent(DPanel)
end
include("shared.lua")
function ENT:Draw()
self:DrawModel()
end
dob = 260
net.Receive("poslat", function()
DrawCrateDERMA("GAVNO","models/props_interiors/Furniture_Couch02a.mdl")
DrawCratePrimWeapon("228/1337","models/props_c17/furnitureStove001a.mdl", 25 , 25 )
DrawCratePrimWeapon("22345528/1337","models/props_c17/oildrum001.mdl", 25+dob , 25 )
DrawCratePrimWeapon("22328/1337","models/props_c17/lampShade001a.mdl", 25+dob+dob , 25 )
end)
function DrawCrateDERMA( textebat, mdl )
local Frame = vgui.Create( "DFrame" ) --Создаёт окно.
Frame:SetTitle( "Оружейный ящик" ) --Устанавливает название окна.
Frame:SetSize( ScrW() * 800/1920, ScrH() * 600/1080 )
Frame:Center()
Frame:SetDraggable( false )
Frame:ShowCloseButton( true )
Frame:MakePopup(true)
Frame:SetBackgroundBlur(false)
Frame.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 5, 0, 0, w, h, Color( 25, 25, 25, 200 ) ) -- Draw a red box instead of the frame
end
--[[----------------Создаём панельки--------------]]
local sheet = vgui.Create( "DPropertySheet", Frame )
sheet:Dock( FILL )
--[[----------------Панелька 1--------------]]
local panel1 = vgui.Create( "DPanel", sheet )
panel1.Paint = function( self, w, h ) draw.RoundedBox( 100, 0, 0, 280, 120, Color( 0, 0, 0, 0) ) end
sheet:AddSheet( "Основное оружие", panel1, "materials/gunsicon.png" )
sheet.Paint = function( self, w, h ) -- 'function Frame:Paint( w, h )' works too
draw.RoundedBox( 5, 0, 0, w, h, Color( 50, 50, 50, 150 ) ) -- Draw a red box instead of the frame
end
local DScrollPanel = vgui.Create( "DScrollPanel" , panel)
DScrollPanel:Dock( FILL )
return DScrollPanel
end
function DrawCratePrimWeapon(panel, textebat, mdl, posx, posy, functonclick)
local DPanel = panel:Add( "DPanel")
DPanel:SetPos( ScrW() * posx/1920, ScrH() * posy/1080 )
DPanel:SetSize( ScrW() * 200/1920, ScrH() * 100/1080 ) -- Set the size of the panel
DPanel:SetBackgroundColor(Color(25,25,25,155))
local ImgKnop = DPanel:Add( "SpawnIcon" )
ImgKnop:SetPos( ScrW() * 0/1920, ScrH() * 0/1080 ) --// Set position
ImgKnop:SetSize( ScrW() * 200/1920, ScrH() * 100/1080 ) --// OPTIONAL: Use instead of SizeToContents() if you know/want to fix the size
ImgKnop:SetModel( mdl ) --// Set the material - relative to /materials/ directory
ImgKnop:SetParent(DPanel)
ImgKnop.DoClick = function()
print("SUKA")
end
local text1 = DScrollPanel:Add("DLabel",panel)
text1:SetPos(ScrW() * 0/1920, ScrH() * 75/1080)
text1:SetText(textebat)
text1:SizeToContents()
text1:SetParent(DPanel)
end
local panel = DrawCrateDERMA("GAVNO","models/props_interiors/Furniture_Couch02a.mdl")
DrawCratePrimWeapon(panel,"228/1337","models/props_c17/furnitureStove001a.mdl", 25 , 25 )
DrawCratePrimWeapon(panel,"22345528/1337","models/props_c17/oildrum001.mdl", 25+dob , 25 )
DrawCratePrimWeapon(panel,"22328/1337","models/props_c17/lampShade001a.mdl", 25+dob+dob , 25 )