ALL YOU CAN EAT
26.02.2011, 17:15
Hi,
ich habe eine frage, und zwar möchte ich ein Panel erstellen mit dem ich mein crosshair ändern kann. Die dazu nötigen Infos soll es aus einem table beziehen, diesen frage ich dann mit einer for- Schleife ab.
function CrosshairMenu()
CrossHairs = {
{Crosshair = { x = 5, y = 30, x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0}},
{Crosshair = { x = 12.5, y = 12.5, x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0}}
}
local frame = vgui.Create( "DFrame" )
frame:SetPos( 200,200 )
frame:SetSize( 500,200 )
frame:SetTitle( " Crosshairs " )
local Choose = vgui.Create( "DPanelList", frame )
Choose:SetPos( 10, 25 )
Choose:SetSize( 480 , 80 )
wahr = true
local x , y = 10 , 30
if( wahr == true ) then -- wird noch geändert in eine andere abfrage wie ply:Alive() etc oder panel:Visible()
space = 10
for k, ch in ipairs( CrossHairs ) do
local w,h = 60 , 0
x = x + w + space
local CrosshairButton = vgui.Create( "DButton", frame )
CrosshairButton:SetPos( x , y )
CrosshairButton:SetSize( 60 , 60 )
CrosshairButton:SetText( "" )
CrosshairButton.Paint = function ()
surface.SetDrawColor( Color(255,255,255,255) )
surface.DrawOutlinedRect( 0 , 0 , CrosshairButton:GetWide(), CrosshairButton:GetTall() )
for k, ch in pairs( CrossHairs ) do
local x , y = ch.Crosshair.x , ch.Crosshair.y
surface.SetDrawColor( Color(0,0,255,255) )
surface.DrawRect( x , y , CrosshairButton:GetWide()-2, 2 )
end
end
CrosshairButton.DoClick = function ()
end
end
end
DefineCrosshairs = {}
-- local Option = vgui.Create( "DCheckBox", frame)
RandomCorsshair = {}
local Random = vgui.Create( "DButton", frame)
Random:SetPos( 230, 140 )
Random:SetSize( 80, 20 )
Random:SetText( "Random" )
Random.DoClick = function()
end
local Preview = vgui.Create( "DPanel", frame )
Preview:SetPos(450, 150 )
Preview:SetSize( 30, 60 )
local Add = vgui.Create( "DButton", frame )
Add:SetPos( 70, 450 )
Add:SetSize( 60, 30 )
Add:SetText( " Add Crosshair to List " )
Add.DoClick = function()
end
end
// Zur vollen ansicht
CrosshairButton.Paint = function ()
surface.SetDrawColor( Color(255,255,255,255) )
surface.DrawOutlinedRect( 0 , 0 , CrosshairButton:GetWide(), CrosshairButton:GetTall() )
for k, ch in pairs( CrossHairs ) do -- Das Problem liegt an dieser Schleife
local x , y = ch.Crosshair.x , ch.Crosshair.y
surface.SetDrawColor( Color(0,0,255,255) )
surface.DrawRect( x , y , CrosshairButton:GetWide()-2, 2 )
end
end
Das Problem ist nun das wenn ich die for- Schleife aufrufe und ich mehr als ein Element im table habe wird die Paint function für jeden Knopf so oft aufgerufen wie ich Elemente besitze.
Ich möchte aber die Paint function immer einzeln aufrufen um jedes Crosshair einzeln dazustellen.
Kann mir bei meinem Problem einer weiterhelfen.
ich habe eine frage, und zwar möchte ich ein Panel erstellen mit dem ich mein crosshair ändern kann. Die dazu nötigen Infos soll es aus einem table beziehen, diesen frage ich dann mit einer for- Schleife ab.
function CrosshairMenu()
CrossHairs = {
{Crosshair = { x = 5, y = 30, x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0}},
{Crosshair = { x = 12.5, y = 12.5, x1 = 0, y1 = 0, x2 = 0, y2 = 0, x3 = 0, y3 = 0}}
}
local frame = vgui.Create( "DFrame" )
frame:SetPos( 200,200 )
frame:SetSize( 500,200 )
frame:SetTitle( " Crosshairs " )
local Choose = vgui.Create( "DPanelList", frame )
Choose:SetPos( 10, 25 )
Choose:SetSize( 480 , 80 )
wahr = true
local x , y = 10 , 30
if( wahr == true ) then -- wird noch geändert in eine andere abfrage wie ply:Alive() etc oder panel:Visible()
space = 10
for k, ch in ipairs( CrossHairs ) do
local w,h = 60 , 0
x = x + w + space
local CrosshairButton = vgui.Create( "DButton", frame )
CrosshairButton:SetPos( x , y )
CrosshairButton:SetSize( 60 , 60 )
CrosshairButton:SetText( "" )
CrosshairButton.Paint = function ()
surface.SetDrawColor( Color(255,255,255,255) )
surface.DrawOutlinedRect( 0 , 0 , CrosshairButton:GetWide(), CrosshairButton:GetTall() )
for k, ch in pairs( CrossHairs ) do
local x , y = ch.Crosshair.x , ch.Crosshair.y
surface.SetDrawColor( Color(0,0,255,255) )
surface.DrawRect( x , y , CrosshairButton:GetWide()-2, 2 )
end
end
CrosshairButton.DoClick = function ()
end
end
end
DefineCrosshairs = {}
-- local Option = vgui.Create( "DCheckBox", frame)
RandomCorsshair = {}
local Random = vgui.Create( "DButton", frame)
Random:SetPos( 230, 140 )
Random:SetSize( 80, 20 )
Random:SetText( "Random" )
Random.DoClick = function()
end
local Preview = vgui.Create( "DPanel", frame )
Preview:SetPos(450, 150 )
Preview:SetSize( 30, 60 )
local Add = vgui.Create( "DButton", frame )
Add:SetPos( 70, 450 )
Add:SetSize( 60, 30 )
Add:SetText( " Add Crosshair to List " )
Add.DoClick = function()
end
end
// Zur vollen ansicht
CrosshairButton.Paint = function ()
surface.SetDrawColor( Color(255,255,255,255) )
surface.DrawOutlinedRect( 0 , 0 , CrosshairButton:GetWide(), CrosshairButton:GetTall() )
for k, ch in pairs( CrossHairs ) do -- Das Problem liegt an dieser Schleife
local x , y = ch.Crosshair.x , ch.Crosshair.y
surface.SetDrawColor( Color(0,0,255,255) )
surface.DrawRect( x , y , CrosshairButton:GetWide()-2, 2 )
end
end
Das Problem ist nun das wenn ich die for- Schleife aufrufe und ich mehr als ein Element im table habe wird die Paint function für jeden Knopf so oft aufgerufen wie ich Elemente besitze.
Ich möchte aber die Paint function immer einzeln aufrufen um jedes Crosshair einzeln dazustellen.
Kann mir bei meinem Problem einer weiterhelfen.