使用功能绘制 Derma Button 时出现问题
Trouble with Derma Button draw with function
我在使用 Derma SpawnIcon 时遇到了一些问题。当我绘制 1 个带有函数的 SpawnIcon 时,它工作正常,但是当我尝试使用相同的函数并绘制第二个 SpawnIcon 时,DoClick 函数仅适用于最后一个 SpawnIcon。我不知道为什么会这样,也不知道如何解决这个问题,请帮助我:(
cl_hud.lua(自动)
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
cl_init.lua(在我的实体中)
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 )
我在使用 Derma SpawnIcon 时遇到了一些问题。当我绘制 1 个带有函数的 SpawnIcon 时,它工作正常,但是当我尝试使用相同的函数并绘制第二个 SpawnIcon 时,DoClick 函数仅适用于最后一个 SpawnIcon。我不知道为什么会这样,也不知道如何解决这个问题,请帮助我:(
cl_hud.lua(自动)
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
cl_init.lua(在我的实体中)
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 )