From 7e5db609550cca0d8b8a76c4bf78ba4658962167 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Sat, 16 Apr 2016 02:02:00 -0400 Subject: Initial commit --- gamemode/cl_deathmenu.lua | 366 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 366 insertions(+) create mode 100644 gamemode/cl_deathmenu.lua (limited to 'gamemode/cl_deathmenu.lua') diff --git a/gamemode/cl_deathmenu.lua b/gamemode/cl_deathmenu.lua new file mode 100644 index 0000000..0dffb59 --- /dev/null +++ b/gamemode/cl_deathmenu.lua @@ -0,0 +1,366 @@ + +surface.CreateFont( "Header", { + font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name + size = 16, + weight = 500, + blursize = 0, + scanlines = 0, + antialias = true, + underline = false, + italic = false, + strikeout = false, + symbol = false, + rotary = false, + shadow = false, + additive = false, + outline = false, +} ) + +surface.CreateFont( "Items", { + font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name + size = 14, + weight = 0, + blursize = 0, + scanlines = 0, + antialias = true, + underline = false, + italic = false, + strikeout = false, + symbol = false, + rotary = false, + shadow = false, + additive = false, + outline = false, +} ) + + + +active = 0 + +local res +local wep +local dmFrame + +local function receive_message(len) + +res = net.ReadTable() +wep = net.ReadTable() + +if (active == 0) then dmFrame = vgui.Create("dmFrame") active = 1 end + +end +net.Receive('deathmenu', receive_message) + + + +local PANEL = {} + +width = 100 +height = 100 + +function PANEL:Init() + + self:SetSize( 440, 400 ) + self:Center() + self:MakePopup() + self:SetTitle("") + + local pnl = vgui.Create( "DPanel", self ) + pnl:SetSize(self:GetWide()-10, self:GetTall()-25) + pnl:SetPos(5,25) + + local DScrollPanel = vgui.Create( "DScrollPanel", pnl ) + DScrollPanel:SetSize( pnl:GetWide(), pnl:GetTall() ) + DScrollPanel:SetPos( 0, 0 ) + + // Weapons + + local wepPnlHeader = vgui.Create("DPanel", DScrollPanel) + wepPnlHeader:SetSize( DScrollPanel:GetWide(), 25 ) + wepPnlHeader:SetPos(0,0) + wepPnlHeader.Paint = function() + + draw.RoundedBox( 0, 0, 0, wepPnlHeader:GetWide(), wepPnlHeader:GetTall(), Color( 48, 48, 48, 255 ) ) + draw.SimpleText( "Weapons", "Header", 30, 12, Color(255, 255, 255), 1, 1 ) + end + + column = 1 + row = 1 + XOffset = 12 + for k,v in pairs(wep) do + local wepPNL = vgui.Create( "DButton", DScrollPanel ) + wepPNL:SetSize( width, height ) + if (k/4 <= column) then + wepPNL:SetPos( (row-1)*(width+2) + XOffset,(column-1)*(height+2) + 25) + row=row+1 + else + column=column+1 + row=1 + wepPNL:SetPos( (row-1)*(width+2) + XOffset,(column-1)*(height+2) + 25) + row=row+1 + end + + wepPNL:SetDrawBackground( false ) + + wepPNL.Paint = function() + + draw.RoundedBox( 0, 0, 0, wepPNL:GetWide(), wepPNL:GetTall(), Color(69,69,69,125) ) + + surface.SetFont("Items") + surface.SetTextColor( 0,0,0 ) + surface.SetTextPos( (width/2)-(surface.GetTextSize(v)/2), height-20 ) + surface.DrawText(v) + end + + wepPNL.DoClick = function() + if (!LocalPlayer():HasWeapon(v)) then + + net.Start('givePlayerWeapon') + net.WriteString(v) + for i,o in pairs(wep) do + if (v == o) then + net.WriteInt(i, 32) + table.remove(wep,i) + end + end + wepPNL:Remove() + + net.SendToServer() + end + end + + local img = vgui.Create("DImage", wepPNL) + img:SetPos(0, 0) + img:SetSize(wepPNL:GetSize()) + img:SetImage("gms_icons/gms_weapon.png") + + + end + + // Resources + + local resPnlHeader = vgui.Create("DPanel", DScrollPanel) + resPnlHeader:SetSize( DScrollPanel:GetWide(), 25 ) + resPnlHeader:SetPos(0,column*height + 25) + resPnlHeader.Paint = function() + draw.RoundedBox( 0, 0, 0, resPnlHeader:GetWide(), resPnlHeader:GetTall(), Color( 48, 48, 48, 255 ) ) + draw.SimpleText( "Resources", "Header", 35, 12, Color(255, 255, 255), 1, 1 ) + end + + row2 = 1 + column2 = 1 + for k,v in pairs(res) do + local resPNL = vgui.Create( "DButton", DScrollPanel ) + resPNL:SetSize( width, height ) + if (k/4 <= column2) then + resPNL:SetPos( (row2-1)*(width+2) + XOffset,(column2-1)*(height+2) + (column*height + 50)) + row2=row2+1 + else + column2=column2+1 + row2=1 + resPNL:SetPos( (row2-1)*(width+2) + XOffset,(column2-1)*(height+2) + (column*height + 50)) + row2=row2+1 + end + + local tbl1 = string.Split(res[k], " ") + local tbl2 = string.Split(tbl1[2], "x") + local amount = tbl2[2] + + resPNL.DoClick = function() + local mb = DermaMenu() + + + mb:AddOption("Take x1", function() + + if (amount - 1 <= 0) then + amount = 0 + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], 1, i) + table.remove(res,i) + end + end + resPNL:Remove() + else + amount = amount - 1 + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], 1, i) + res[i] = tbl1[1] .. " x" .. amount + v = res[i] + end + end + + end + + end) + mb:AddOption("Take x5", function() + + if (amount - 5 <= 0) then + + if (amount - 5 == 0) then + amount = 0 + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], 5, i) + table.remove(res, i) + end + end + resPNL:Remove() + else + + num1 = amount - 5 + num2 = 5 + num1 + amount = 0 + + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], num2, i) + print(i) + table.remove(res,i) + end + end + resPNL:Remove() + end + else + amount = amount - 5 + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], 5, i) + res[i] = tbl1[1] .. " x" .. amount + v = res[i] + end + end + + end + + end) + mb:AddOption("Take x10", function() + + if (amount - 10 <= 0) then + + if (amount - 10 == 0) then + amount = 0 + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], 10, i) + table.remove(res, i) + end + end + resPNL:Remove() + else + + num1 = amount - 10 + num2 = 10 + num1 + amount = 0 + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], num2, i) + table.remove(res,i) + end + end + + resPNL:Remove() + + end + else + amount = amount - 10 + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], 10, i) + res[i] = tbl1[1] .. " x" .. amount + v = res[i] + end + end + + end + + end) + mb:AddOption("Take All", function() + + + for i,o in pairs(res) do + spl1 = string.Split(v, " ") + spl2 = string.Split(o, " ") + if (spl1[1] == spl2[1]) then + giveRes(tbl1[1], amount, i) + amount = 0 + table.remove(res,i) + end + end + + resPNL:Remove() + end) + mb:Open() + end + + resPNL.Paint = function() + draw.RoundedBox( 0, 0, 0, resPNL:GetWide(), resPNL:GetTall(), Color( 69, 69, 69, 125 ) ) + + + surface.SetFont("Items") + surface.SetTextColor( 0,0,0 ) + surface.SetTextPos( (width/2)-(surface.GetTextSize(v)/2), height-20 ) + surface.DrawText(v) + + end + + local img = vgui.Create("DImage", resPNL) + img:SetPos(0, 0) + img:SetSize(resPNL:GetSize()) + img:SetImage("gms_icons/gms_resourcepack.png") + end + +end + +function PANEL:Close() + active = 0 + self:Remove() +end + +function giveRes(res, amount, slot) + + net.Start('givePlayerResource') + + net.WriteString(res) + net.WriteInt(amount, 32) + net.WriteInt(slot, 32) + + net.SendToServer() + +end + +function PANEL:Paint( w, h ) + draw.RoundedBox( 0, 0, 0, w, h, Color( 69, 69, 69, 125 ) ) +end + +vgui.Register( "dmFrame", PANEL, "DFrame" ) \ No newline at end of file -- cgit v1.2.3-70-g09d2