summaryrefslogtreecommitdiff
path: root/data/artery/global/art_shipyardcontrol/cl_ent_shipyardcontrol.lua
blob: a38213234bde9ba6157dd5a6f72da8389dbdc0e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
--[[
	Client stuff!
]]
local ENT = nrequire("sh_ent_shipyardcontrol.lua")

function ENT:Draw()
	self:DrawModel()

end

net.Receive("art_shipyard_open",function()
	local who = net.ReadEntity()
	print("Opening shipyard")
	local selectframe = vgui.Create("DFrame")
	selectframe:SetSize(ScrW() / 2, ScrH() / 2)
	selectframe:Center()
	selectframe:SetTitle("Shipyard")

	local scroll = vgui.Create( "DScrollPanel",selectframe )
	scroll:Dock(FILL)

	local labelname = vgui.Create("DLabel",scroll)
	labelname:Dock(TOP)
	labelname:SetText("Ship name:")
	labelname:SetDark(true)

	local textname = vgui.Create("DTextEntry",scroll)
	textname:Dock(TOP)

	local buttonfinish = vgui.Create( "DButton", scroll )
	buttonfinish:SetText("Finish")
	buttonfinish:Dock(TOP)
	buttonfinish.DoClick = function()
		net.Start("art_shipyard_finalize")
		net.WriteEntity(who)
		net.WriteString(textname:GetValue())
		net.SendToServer()
	end

	selectframe:MakePopup()
end)

--[[
	Display the bounds of shipyards
]]

hook.Add( "PostDrawOpaqueRenderables", "artery_draw_shipyards", function()
	local ztd = zones.FindByClass("artery_shipyard")
	for k,v in pairs(ztd) do
		local bounds = v.bounds
		cam.Start3D2D( bounds.mins, Angle(0,0,0), 1 )
			local x,y = bounds.maxs.x - bounds.mins.x, -(bounds.maxs.y - bounds.mins.y)
			surface.SetDrawColor( 238, 238, 255, 50 )
			surface.DrawRect( 0, 0, x, y )
			surface.SetDrawColor( 100,100,255,255)
			surface.DrawLine(0,0,x,0)
			surface.DrawLine(0,0,0,y)
			surface.DrawLine(x,y,x,0)
			surface.DrawLine(x,y,0,y)
		cam.End3D2D()
	end
end )

scripted_ents.Register(ENT,"art_shipyardcontrol")