diff options
Diffstat (limited to 'gamemode/hud')
| -rw-r--r-- | gamemode/hud/draw.lua | 31 | ||||
| -rw-r--r-- | gamemode/hud/draw_account.lua | 136 | ||||
| -rw-r--r-- | gamemode/hud/draw_circle.lua | 48 | ||||
| -rw-r--r-- | gamemode/hud/draw_editor.lua | 746 | ||||
| -rw-r--r-- | gamemode/hud/draw_help.lua | 106 | ||||
| -rw-r--r-- | gamemode/hud/draw_indicators.lua | 60 | ||||
| -rw-r--r-- | gamemode/hud/draw_lootventory.lua | 77 | ||||
| -rw-r--r-- | gamemode/hud/draw_qmenu.lua | 346 | ||||
| -rw-r--r-- | gamemode/hud/draw_scoreboard.lua | 40 | ||||
| -rw-r--r-- | gamemode/hud/draw_targets.lua | 11 | ||||
| -rw-r--r-- | gamemode/hud/draw_voicechat.lua | 33 | ||||
| -rw-r--r-- | gamemode/hud/draw_wepswap.lua | 64 |
12 files changed, 1698 insertions, 0 deletions
diff --git a/gamemode/hud/draw.lua b/gamemode/hud/draw.lua new file mode 100644 index 0000000..1d30d6a --- /dev/null +++ b/gamemode/hud/draw.lua @@ -0,0 +1,31 @@ +
+local MCO = Color(0,0,0,150)
+
+function GM:HUDPaint()
+ local CountDown = self.CountDown
+
+ if (CountDown and CountDown > CurTime()) then
+ DrawRect(5,5,100,20,MCO)
+ DrawText("Preround: "..math.ceil(CountDown-CurTime()), "Trebuchet18", 10, 6, MAIN_WHITECOLOR)
+ end
+
+ if (CountDown and CountDown < CurTime() and CountDown > CurTime()-MAIN_PVPTIMER) then
+ DrawRect(5,5,130,20,MCO)
+ DrawText("Anti PVP timer: "..math.ceil(CountDown-(CurTime()-MAIN_PVPTIMER)), "Trebuchet18", 10, 6, MAIN_WHITECOLOR)
+ end
+
+ if(#player.GetAll() == 1) then
+ local height = 20
+ local width = 65*6
+ local x = (ScrH()/2) - (height/2)
+ local y = (ScrW()/2) - (width/2)
+ DrawRect(x,y,width,height,MCO)
+ DrawText("Winter Survival requires at least 2 players to begin, Invite a friend!","Trebuchet18",x+3,y, MAIN_WHITECOLOR)
+ end
+
+ DrawAccountInventory()
+ DrawHelp()
+ DrawIndicators()
+ DrawWepSwap()
+ DrawTargets()
+end
diff --git a/gamemode/hud/draw_account.lua b/gamemode/hud/draw_account.lua new file mode 100644 index 0000000..861445c --- /dev/null +++ b/gamemode/hud/draw_account.lua @@ -0,0 +1,136 @@ +
+local SCO = Color(0,0,0,250)
+local MCO = Color(0,0,0,150)
+local x,y = ScrW()-200,30
+
+local AccountMenu = nil
+local Info = nil
+
+hook.Add("Tick","AccountInventory",function()
+ if (input.KeyPress(KEY_F2)) then
+ if IsAccountMenuOpen() then
+ AccountMenu:SetVisible(false)
+ else
+ OpenAccountMenu()
+ end
+ end
+end)
+
+
+function ReloadAccountMenu()
+ if (!IsAccountMenuOpen()) then return end
+ AccountMenu.List:Clear()
+
+ for k,v in pairs(LocalPlayer():GetAccountInventory()) do
+ local a = AccountMenu.List:Add("DPanel")
+ a:SetSize(64,64)
+ a.Item = GetItemByName(v.Name)
+ a.Quantity = v.Quantity
+ a:Droppable("ACCOUNT")
+ a.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,s.Item.Icon)
+
+ DrawText("x"..v.Quantity,"ChatFont",1,h-18,MAIN_TEXTCOLOR)
+ end
+
+ a.OnCursorEntered = function(s)
+ if (!Info) then
+ Info = vgui.Create("DPanel")
+ Info:SetPos(x-410,60)
+ Info:SetSize(195,100)
+ Info.Paint = function(s,w,h) DrawRect(0,0,w,h,SCO) end
+
+ Info.Label = vgui.Create("DLabel",Info)
+ Info.Label:SetPos(5,5)
+ Info.Label:SetSize(185,20)
+
+ Info.LabelDesc = vgui.Create("DLabel",Info)
+ Info.LabelDesc:SetPos(5,30)
+ Info.LabelDesc:SetSize(185,65)
+ Info.LabelDesc:SetWrap(true)
+ Info.LabelDesc:SetAutoStretchVertical(true)
+ end
+
+ Info.Label:SetText(v.Name)
+ Info.LabelDesc:SetText(s.Item.Desc)
+
+ Info:SetVisible(true)
+ end
+
+ a.OnCursorExited = function(s)
+ Info:SetVisible(false)
+ end
+
+ a.OnStopDragging = function(s,a,b,c)
+ end
+
+
+ local Ab = a.OnMousePressed
+ a.OnMousePressed = function(s,m)
+ if (m == MOUSE_RIGHT) then
+ local X,Y = gui.MousePos()
+
+ local menu = DermaMenu()
+ menu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ menu:AddOption( "Use", function() if (s.Item) then RequestUseItem(s.Item.Name,true) end end ):SetColor(MAIN_TEXTCOLOR)
+ menu:AddOption( "Destroy", function() if (s.Item) then RequestDropItem(s.Item.Name,true) end end ):SetColor(MAIN_TEXTCOLOR)
+
+ menu:Open()
+ menu:SetPos(X,Y)
+ end
+
+ Ab(s,m)
+ end
+ end
+end
+
+function OpenAccountMenu()
+ if (IsAccountMenuOpen()) then return end
+
+ surface.PlaySound("wintersurvival2/hud/itemopen.wav")
+
+ if (!AccountMenu) then
+ --Inventory
+ AccountMenu = vgui.Create("MBFrame")
+ AccountMenu:SetPos(x-205,y+25)
+ AccountMenu:SetSize(400,400)
+ AccountMenu:SetTitle("Account")
+ AccountMenu:SetDeleteOnClose(false)
+ AccountMenu:MakePopup()
+ AccountMenu.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ DrawRect(5,20,w-10,20,MCO)
+
+ DrawText("Time spent: "..math.SecondsToTime(LocalPlayer():GetTimeSpent()),"Trebuchet18",8,21,MAIN_WHITECOLOR)
+ end
+ AccountMenu.OnClose = function(s) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+
+ local Pane = vgui.Create( "DScrollPanel", AccountMenu )
+ Pane:SetPos(5,45)
+ Pane:SetSize(AccountMenu:GetWide()-10,AccountMenu:GetTall()-50)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ AccountMenu.List = l
+ AccountMenu:ShowCloseButton(false)
+ end
+
+ AccountMenu:SetVisible(true)
+
+ ReloadAccountMenu()
+end
+
+function IsAccountMenuOpen()
+ return (IsValid(AccountMenu) and AccountMenu:IsVisible())
+end
+
+function DrawAccountInventory()
+ DrawRect(x,y,200,20,MCO)
+ DrawText("F2 - Account","Trebuchet18",x+4,y+2,MAIN_TEXTCOLOR)
+end
diff --git a/gamemode/hud/draw_circle.lua b/gamemode/hud/draw_circle.lua new file mode 100644 index 0000000..9620a3d --- /dev/null +++ b/gamemode/hud/draw_circle.lua @@ -0,0 +1,48 @@ +local rad = math.rad
+local cos = math.cos
+local sin = math.sin
+local abs = math.abs
+
+function DrawOutlinedCircle(x,y,r,s,ang,dang,iter,color)
+ ang = rad(ang)
+ dang = rad(dang)
+ iter = iter or 8
+
+ local step = abs(dang)/iter
+
+ surface.SetDrawColor(color.r,color.g,color.b,color.a)
+
+ for i = 0, iter-1 do
+ local r2 = r + s
+ local Time1 = step*i+ang
+ local Time2 = Time1+step
+ local dat = {
+ {
+ x=cos(Time2)*r+x,
+ y=-sin(Time2)*r+y,
+ u=0,
+ v=0,
+ },
+ {
+ x=cos(Time2)*r2+x,
+ y=-sin(Time2)*r2+y,
+ u=1,
+ v=0,
+ },
+ {
+ x=cos(Time1)*r2+x,
+ y=-sin(Time1)*r2+y,
+ u=1,
+ v=1,
+ },
+ {
+ x=cos(Time1)*r+x,
+ y=-sin(Time1)*r+y,
+ u=0,
+ v=1,
+ },
+ }
+
+ surface.DrawPoly(dat)
+ end
+end
\ No newline at end of file diff --git a/gamemode/hud/draw_editor.lua b/gamemode/hud/draw_editor.lua new file mode 100644 index 0000000..9a058c4 --- /dev/null +++ b/gamemode/hud/draw_editor.lua @@ -0,0 +1,746 @@ +
+local Icons = {}
+local Folders = {
+ "wintersurvival2/hud/ws2_icons",
+ "wintersurvival2/hud/ws1_icons",
+ "settlement",
+}
+
+local insert = table.insert
+local cos = math.cos
+local sin = math.sin
+
+local Editor = nil
+local x,y = ScrW()/2,ScrH()/2
+local MCO = Color(0,0,0,150)
+local BCO = Color(0,50,100,150)
+local GCO = Color(0,100,0,150)
+local HCO = Color(30,30,30,150)
+
+local LimitS = 60
+local LimitScale = 5
+
+local ValidBones = {
+ "ValveBiped.Bip01_R_Hand",
+ "ValveBiped.Bip01_L_Hand",
+}
+
+local ValidModels = {
+ "models/props_junk/Rock001a.mdl",
+ "models/props_debris/wood_board02a.mdl",
+ "models/props_combine/breenlight.mdl",
+}
+
+local ValidHoldTypes = {
+ "normal",
+ "melee",
+ "melee2",
+ "fist",
+ "knife",
+ "smg",
+ "ar2",
+ "pistol",
+ "rpg",
+ "physgun",
+ "grenade",
+ "shotgun",
+ "crossbow",
+ "slam",
+ "passive",
+}
+
+
+hook.Add("Initialize","AddEditorIcons",function()
+ for k,v in pairs(Folders) do
+ local F = file.Find("materials/"..v.."/*","GAME")
+
+ for a,icon in pairs(F) do
+ if (!icon:find(".vtf")) then
+ if (icon:find(".vmt")) then icon = icon:gsub(".vmt","") end
+
+ local IM,loadtime = Material(v.."/"..icon)
+ insert(Icons,{Icon = IM,Path = v.."/"..icon,})
+ end
+ end
+ end
+end)
+
+function GetItemIcons()
+ return Icons
+end
+
+
+
+--Now the actual HUD
+
+local Offset = Vector(0,0,50)
+local Zero = Vector(0,0,0)
+local AngZ = Angle(0,0,0)
+local OneV = Vector(1,1,1)
+
+local function ReloadIcons()
+ if (!Editor or !Editor:IsVisible()) then return end
+ Editor.List:Clear()
+
+ for k,v in pairs(Icons) do
+ local a = Editor.List:Add("MBButton")
+ a:SetSize(64,64)
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,v.Icon)
+ end
+ a.DoClick = function(s)
+ Editor.Icon = v.Path
+ Editor.IconEntry:SetText("Icon: "..Editor.Icon)
+ end
+ end
+end
+
+local function ReloadModelList()
+ if (!Editor or !Editor:IsVisible()) then return end
+ Editor.ModelList:Clear()
+
+ for k,v in pairs(Editor.ModelManager.Items) do
+ local a = Editor.ModelList:Add("MBButton")
+ a:SetText("Model "..k)
+ a:SetSize(Editor.ModelList:GetWide()-5,23)
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawText(s.Text,"Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+ a.DoClick = function(s)
+ local X,Y = gui.MousePos()
+ local menu = DermaMenu()
+ menu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local Bones,op = menu:AddSubMenu( "Set bone" )
+ op:SetColor(MAIN_TEXTCOLOR)
+ Bones.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ for d,b in pairs(ValidBones) do
+ Bones:AddOption( b, function() if (v.Bone) then v.Bone = b end end ):SetColor(MAIN_TEXTCOLOR)
+ end
+
+ local Bones,op = menu:AddSubMenu( "Set model" )
+ op:SetColor(MAIN_TEXTCOLOR)
+ Bones.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ for d,b in pairs(ValidModels) do
+ Bones:AddOption( b, function() if (v.Model) then v.Model = b end end ):SetColor(MAIN_TEXTCOLOR)
+ end
+
+ menu:AddOption( "Select", function()
+ if (v.Bone) then
+ Editor.ModelManager.Selected = k
+
+ Editor.SliderX:SetSlideX(0.5+v.Pos.x/LimitS)
+ Editor.SliderX:TranslateValues(0.5+v.Pos.x/LimitS)
+
+ Editor.SliderY:SetSlideX(0.5+v.Pos.y/LimitS)
+ Editor.SliderY:TranslateValues(0.5+v.Pos.y/LimitS)
+
+ Editor.SliderZ:SetSlideX(0.5+v.Pos.z/LimitS)
+ Editor.SliderZ:TranslateValues(0.5+v.Pos.z/LimitS)
+
+ Editor.SliderPitch:SetSlideX(0.5+v.Ang.p/360)
+ Editor.SliderPitch:TranslateValues(0.5+v.Ang.p/360)
+
+ Editor.SliderYaw:SetSlideX(0.5+v.Ang.y/360)
+ Editor.SliderYaw:TranslateValues(0.5+v.Ang.y/360)
+
+ Editor.SliderRoll:SetSlideX(0.5+v.Ang.r/360)
+ Editor.SliderRoll:TranslateValues(0.5+v.Ang.r/360)
+
+ Editor.SliderXScale:SetSlideX(v.Size.x/LimitScale)
+ Editor.SliderXScale:TranslateValues(v.Size.x/LimitScale)
+
+ Editor.SliderYScale:SetSlideX(v.Size.y/LimitScale)
+ Editor.SliderYScale:TranslateValues(v.Size.y/LimitScale)
+
+ Editor.SliderZScale:SetSlideX(v.Size.z/LimitScale)
+ Editor.SliderZScale:TranslateValues(v.Size.z/LimitScale)
+ end
+ end):SetColor(MAIN_TEXTCOLOR)
+
+ menu:AddOption( "Delete", function() if (v.Model) then table.remove(Editor.ModelManager.Items,k) ReloadModelList() end end ):SetColor(MAIN_TEXTCOLOR)
+
+ menu:Open()
+ menu:SetPos(X,Y)
+ end
+ end
+end
+
+function OpenEditor()
+ if (!Editor) then
+ Editor = vgui.Create("MBFrame")
+ Editor:SetPos(x-400,y-300)
+ Editor:SetSize(800,600)
+ Editor:SetTitle("Editor")
+ Editor:SetDeleteOnClose(false)
+ Editor:MakePopup()
+ Editor.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) DrawRect(0,0,w,20,MCO) end
+ Editor.OnClose = function(s) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+ Editor.Icon = "wintersurvival2/hud/ws1_icons/icon_axe"
+
+ --Icon list
+ local Pane = vgui.Create( "DScrollPanel", Editor )
+ Pane:SetPos(600,25)
+ Pane:SetSize(195,390)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ Editor.List = l
+ --End
+
+
+ --Model list
+ local Pane = vgui.Create( "DScrollPanel", Editor )
+ Pane:SetPos(5,25)
+ Pane:SetSize(195,390)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DListLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+
+ Editor.ModelList = l
+ --End
+
+
+ --Model manager
+ local l = vgui.Create("DPanel",Editor)
+ l:SetPos(205,25)
+ l:SetSize(390,390)
+
+ l.Entity = ClientsideModel("models/player/Group03/male_07.mdl")
+ l.Entity:SetNoDraw(true)
+
+ l.EntityItem = ClientsideModel("models/player/Group03/male_07.mdl")
+ l.EntityItem:SetNoDraw(true)
+
+ l.Items = {}
+
+ l.CamDis = 200
+ l.CamPos = Vector(l.CamDis,0,0)
+ l.Origin = Offset
+
+ l.Selected = 0
+
+ l.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+
+ local x, y = s:LocalToScreen( 0, 0 )
+
+ cam.Start3D( s.Origin+s.CamPos, (-s.CamPos):Angle(), 90, x, y, w, h, 1, 4096 )
+ cam.IgnoreZ( true )
+ render.SuppressEngineLighting( true )
+ s.Entity:DrawModel()
+
+ local Mod = s.Entity:GetModel()
+ local Time = CurTime()*10
+
+ for k,v in pairs(s.Items) do
+ if (v.Bone and v.Model and v.Pos and v.Ang and v.Size) then
+ local ind = s.Entity:LookupBone(v.Bone)
+ local Pos,Ang = s.Entity:GetBonePosition(ind)
+
+ if (Pos and Ang) then
+ s.EntityItem:SetModel(v.Model)
+
+ local Rop = v.Pos*1
+ local Roa = Ang*1
+
+ Roa:RotateAroundAxis(Ang:Right(),v.Ang.p)
+ Roa:RotateAroundAxis(Ang:Forward(),v.Ang.r)
+ Roa:RotateAroundAxis(Ang:Up(),v.Ang.y)
+
+ Rop:Rotate(Ang)
+
+ local Org = Pos+Rop
+ local PAng = Roa
+
+ local mat = Matrix()
+ mat:Scale( v.Size or Zero )
+
+ s.EntityItem:EnableMatrix( "RenderMultiply", mat )
+ s.EntityItem:SetRenderOrigin(Org)
+ s.EntityItem:SetRenderAngles(PAng)
+ s.EntityItem:SetupBones()
+
+ if (s.Selected == k) then
+ local A = cos(Time)+2
+ render.SetColorModulation(A,A,A)
+ s.EntityItem:DrawModel()
+ render.SetColorModulation(1,1,1)
+
+ render.DrawLine( Org, Org+PAng:Forward()*20, MAIN_BLUECOLOR, false )
+ render.DrawLine( Org, Org+PAng:Right()*20, MAIN_REDCOLOR, false )
+ render.DrawLine( Org, Org+PAng:Up()*20, MAIN_GREENCOLOR, false )
+
+ s.Origin = Org
+ else
+ s.EntityItem:DrawModel()
+ end
+ end
+ end
+ end
+
+ render.SuppressEngineLighting( false )
+ cam.IgnoreZ( false )
+ cam.End3D()
+ end
+
+ l.Think = function(s)
+ if (s.LastCamDis) then
+ local mx,my = gui.MousePos()
+ local dx,dy = mx-s.LastClickPos.x,my-s.LastClickPos.y
+
+ s.CamDis = math.Clamp(s.LastCamDis + dy,10,200)
+ s.CamPos = s.CamPos:GetNormal()*s.CamDis
+ elseif (s.LastCamPos) then
+ local mx,my = gui.MousePos()
+ local dx,dy = mx-s.LastClickPos.x,my-s.LastClickPos.y
+
+ local Ab = s.LastCamPos:Angle()
+ Ab = Ab + Angle(-dy,-dx,0)
+
+ s.CamPos = Ab:Forward()*s.CamDis
+ end
+ end
+
+ l.OnMousePressed = function(s,m)
+ if (m == MOUSE_RIGHT) then
+ if (!s.LastClickPos) then
+ local x,y = gui.MousePos()
+ s.LastClickPos = {x=x,y=y}
+ s.LastCamDis = s.CamDis*1
+ end
+ elseif (m == MOUSE_LEFT) then
+ if (!s.LastClickPos) then
+ local x,y = gui.MousePos()
+ s.LastClickPos = {x=x,y=y}
+ s.LastCamPos = s.CamPos*1
+ end
+ end
+ end
+
+ l.OnMouseReleased = function(s,m)
+ if (s.LastClickPos) then
+ s.LastClickPos = nil
+ s.LastCamPos = nil
+ s.LastCamDis = nil
+ end
+ end
+
+ Editor.ModelManager = l
+ --End
+
+ --EditorPanels
+ local l = vgui.Create("DPanel",Editor)
+ l:SetPos(5,420)
+ l:SetSize(790,175)
+ l.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local a = vgui.Create("MBButton",l)
+ a:SetText("Add Model")
+ a:SetPos(5,5)
+ a:SetSize(185,20)
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawText(s.Text,"Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+ a.DoClick = function(s)
+ local id = insert(Editor.ModelManager.Items,{
+ Bone="ValveBiped.Bip01_R_Hand",
+ Model="models/props_debris/wood_board02a.mdl",
+ Size=Vector(1,1,1),
+ Pos=Vector(0,0,0),
+ Ang=Angle(0,0,0),
+ })
+
+ Editor.ModelManager.Selected = id
+
+ Editor.SliderX:SetSlideX(0.5)
+ Editor.SliderX:TranslateValues(0.5)
+
+ Editor.SliderY:SetSlideX(0.5)
+ Editor.SliderY:TranslateValues(0.5)
+
+ Editor.SliderZ:SetSlideX(0.5)
+ Editor.SliderZ:TranslateValues(0.5)
+
+ Editor.SliderPitch:SetSlideX(0.5)
+ Editor.SliderPitch:TranslateValues(0.5)
+
+ Editor.SliderYaw:SetSlideX(0.5)
+ Editor.SliderYaw:TranslateValues(0.5)
+
+ Editor.SliderRoll:SetSlideX(0.5)
+ Editor.SliderRoll:TranslateValues(0.5)
+
+ local S = 1/LimitScale
+
+ Editor.SliderXScale:SetSlideX(S)
+ Editor.SliderXScale:TranslateValues(S)
+
+ Editor.SliderYScale:SetSlideX(S)
+ Editor.SliderYScale:TranslateValues(S)
+
+ Editor.SliderZScale:SetSlideX(S)
+ Editor.SliderZScale:TranslateValues(S)
+
+ ReloadModelList()
+ end
+
+ local Title = vgui.Create("DTextEntry",l)
+ Title:SetText("Item Name")
+ Title:SetPos(5,55)
+ Title:SetSize(185,20)
+
+ local Icon = vgui.Create("DTextEntry",l)
+ Icon:SetText("Icon: "..Editor.Icon)
+ Icon:SetPos(205,145)
+ Icon:SetSize(380,20)
+ Icon:SetEditable(false)
+
+ local Desc = vgui.Create("DTextEntry",l)
+ Desc:SetText("Description")
+ Desc:SetPos(5,80)
+ Desc:SetSize(185,60)
+ Desc:SetMultiline(true)
+
+ local ModelP = vgui.Create("DComboBox",l)
+ ModelP:SetPos(5,145)
+ ModelP:SetSize(185,20)
+
+ for k,v in pairs(ValidModels) do
+ if (k==1) then ModelP:AddChoice(v,nil,true)
+ else ModelP:AddChoice(v) end
+ end
+
+ local HoldType = vgui.Create("DComboBox",l)
+ HoldType:SetPos(600,145)
+ HoldType:SetSize(185,20)
+
+ for k,v in pairs(ValidHoldTypes) do
+ if (k==1) then HoldType:AddChoice(v,nil,true)
+ else HoldType:AddChoice(v) end
+ end
+
+ Editor.IconEntry = Icon
+
+ --OffsetSliders... Gawd why does VGUI has to be so LOOONG!!!!
+ --SlideX
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(405,5)
+ B:SetText("x offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(490,5)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(410,25)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*LimitS-LimitS/2)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Pos.x = V
+ end
+ return x, y
+ end
+
+ Editor.SliderX = SlideOffset
+ --End
+
+ --SlideY
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(405,50)
+ B:SetText("y offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(490,50)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(410,70)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*LimitS-LimitS/2)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Pos.y = V
+ end
+ return x, y
+ end
+
+ Editor.SliderY = SlideOffset
+ --End
+
+ --SlideZ
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(405,95)
+ B:SetText("z offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(490,95)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(410,115)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*LimitS-LimitS/2)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Pos.z = V
+ end
+ return x, y
+ end
+
+ Editor.SliderZ = SlideOffset
+ --End
+ --End
+
+ --OffsetSliders Angles
+ --SlidePitch
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(605,5)
+ B:SetText("Pitch")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(690,5)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(610,25)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*360-180)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Ang.p = V
+ end
+ return x, y
+ end
+
+ Editor.SliderPitch = SlideOffset
+ --End
+
+ --SlideYaw
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(605,50)
+ B:SetText("Yaw")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(690,50)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(610,70)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*360-180)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Ang.y = V
+ end
+ return x, y
+ end
+
+ Editor.SliderYaw = SlideOffset
+ --End
+
+ --SlideRoll
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(605,95)
+ B:SetText("Roll")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(690,95)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(610,115)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil((x*360-180)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Ang.r = V
+ end
+ return x, y
+ end
+
+ Editor.SliderRoll = SlideOffset
+ --End
+ --End
+
+ --OffsetScale
+ --SlideX
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(205,5)
+ B:SetText("x offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(290,5)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(210,25)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil(math.max(0.01,x*LimitScale)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Size.x = V
+ end
+ return x, y
+ end
+
+ Editor.SliderXScale = SlideOffset
+ --End
+
+ --SlideY
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(205,50)
+ B:SetText("y offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(290,50)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(210,70)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil(math.max(0.01,x*LimitScale)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Size.y = V
+ end
+ return x, y
+ end
+
+ Editor.SliderYScale = SlideOffset
+ --End
+
+ --SlideZ
+ local B = vgui.Create("DLabel",l)
+ B:SetPos(205,95)
+ B:SetText("z offset")
+
+ local B2 = vgui.Create("DLabel",l)
+ B2:SetPos(290,95)
+ B2:SetText("0")
+
+ local SlideOffset = vgui.Create("DSlider",l)
+ SlideOffset:SetPos(210,115)
+ SlideOffset:SetSize(170,20)
+ SlideOffset.Label = B2
+ SlideOffset.Paint = function(s,w,h) DrawRect(0,h/2-2,w,2,MCO) end
+ SlideOffset.TranslateValues = function(s, x, y )
+ local V = math.ceil(math.max(0.01,x*LimitScale)*100)/100
+ B2:SetText(tostring(V))
+
+ if (Editor.ModelManager.Items[Editor.ModelManager.Selected]) then
+ Editor.ModelManager.Items[Editor.ModelManager.Selected].Size.z = V
+ end
+ return x, y
+ end
+
+ Editor.SliderZScale = SlideOffset
+ --End
+ --End
+
+ local Compile = vgui.Create("MBButton",l)
+ Compile:SetText("Compile")
+ Compile:SetPos(5,30)
+ Compile:SetSize(185,20)
+ Compile.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h,HCO)
+ else DrawRect(0,0,w,h,MCO) end
+
+ DrawText(s.Text,"Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+ Compile.DoClick = function(s)
+ local Text = ""
+
+ Text = Text.."ITEM.Name\t= [["..Title:GetValue().."]]\n"
+ Text = Text.."ITEM.Desc\t= [["..Desc:GetValue().."]]\n"
+ Text = Text.."ITEM.Model\t= [["..ModelP:GetValue().."]]\n"
+ Text = Text.."ITEM.Icon\t= Material([["..Editor.Icon.."]])\n"
+ Text = Text.."ITEM.HoldType\t= [["..HoldType:GetValue().."]]\n"
+ Text = Text.."ITEM.Structure\t= {\n"
+
+ for k,v in pairs(Editor.ModelManager.Items) do
+ Text = Text.."\t{\n"
+ Text = Text.."\t\tBone\t= \""..v.Bone.."\",\n"
+ Text = Text.."\t\tModel\t= \""..v.Model.."\",\n"
+ Text = Text.."\t\tSize\t= Vector("..v.Size.x..","..v.Size.y..","..v.Size.z.."),\n"
+ Text = Text.."\t\tPos \t= Vector("..v.Pos.x..","..v.Pos.y..","..v.Pos.z.."),\n"
+ Text = Text.."\t\tAng \t= Angle("..v.Ang.p..","..v.Ang.y..","..v.Ang.r.."),\n"
+ Text = Text.."\t},\n"
+ end
+
+ Text = Text.."}\n"
+
+ if (!file.Exists("wsitems","DATA")) then file.CreateDir("wsitems") end
+ file.Write("wsitems/"..Title:GetValue()..".txt",Text)
+
+ print("Item has been compiled and is located in garrysmod/data/wsitems folder.")
+ end
+ --End
+ end
+
+ Editor.ModelManager.CamDis = 200
+ Editor.ModelManager.CamPos = Vector(200,0,0)
+
+ Editor:SetVisible(true)
+
+ ReloadIcons()
+end
+
+
+
+concommand.Add("ws_openeditor",function(pl,com,arg) OpenEditor() end)
diff --git a/gamemode/hud/draw_help.lua b/gamemode/hud/draw_help.lua new file mode 100644 index 0000000..b1b9425 --- /dev/null +++ b/gamemode/hud/draw_help.lua @@ -0,0 +1,106 @@ +
+local MCO = Color(0,0,0,150)
+
+MAIN_HELP = false
+MAIN_HELP_PAGES = 5
+
+hook.Add("Tick","Help",function()
+ if (input.KeyPress(KEY_F1)) then
+ if (MAIN_HELP and MAIN_HELP < MAIN_HELP_PAGES) then
+ MAIN_HELP = MAIN_HELP + 1
+ elseif (MAIN_HELP) then MAIN_HELP = false
+ else MAIN_HELP = 1 end
+ end
+end)
+
+local function WrapString(str,width)
+ local dp = string.Explode(" ",str)
+ local dout = dp[1]
+ local curline = dout
+
+ for k,v in pairs(dp) do
+ if k ~= 1 then
+ local sz = surface.GetTextSize(curline)
+ local sza = surface.GetTextSize(" "..v)
+ if sz+sza < width then
+ dout = dout .. " " .. v
+ curline = curline .. " " .. v
+ else
+ dout = dout .. "\n" .. v
+ curline = v
+ end
+ end
+ end
+
+ return dout
+end
+
+function DrawHelp()
+ local gx,gy = 5,30
+
+ if (!MAIN_HELP) then
+ DrawRect(gx,gy,140,20,MCO)
+ DrawText("F1 - Help/Next Page","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR)
+ return
+ end
+
+ DrawRect(gx,gy,256,392,MCO)
+
+ gx = gx + 4
+ gy = gy + 4
+
+ if (MAIN_HELP == 1) then
+ draw.DrawText("Bird","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("Controls:\n\t[W] Fly/Move forward\n\t[Mouse] Steer the bird\n\t[Left Mouse] Taunt\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 72
+
+ draw.DrawText("Purpose:"..WrapString("\n You are a spectator. When you first join, you are assigned as a bird. To become a human you must wait until the round is over, which means you will have to wait til everyones dead.\n\nIn addition to this, the gamemode needs atleast 2 people in the server before the round can actually begin, invite a friend over!\n\nAlternativly, players can perform ritual resurrections to bring a player back to life.",240),"Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ elseif (MAIN_HELP == 2) then
+ draw.DrawText("Survivor","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("Controls:\n\t[WASD] Move around\n\t[Mouse] Aim\n\t[Left Mouse] Attack\n\t[Scroll] Select equipment\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 90
+
+ draw.DrawText("Halo:\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[GREEN] \t- Hunger","Trebuchet18",gx+4,gy,MAIN_GREENCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[BLUE] \t- Thirst","Trebuchet18",gx+4,gy,MAIN_BLUECOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[YELLOW] \t- Fatigue","Trebuchet18",gx+4,gy,MAIN_YELLOWCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[RED] \t- Heat","Trebuchet18",gx+4,gy,MAIN_REDCOLOR,0)
+ gy = gy + 18
+
+ draw.DrawText("\t[WHITE] \t- Health","Trebuchet18",gx+4,gy,MAIN_WHITECOLOR,0)
+ elseif (MAIN_HELP == 3) then
+ draw.DrawText("Inventory","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("While hovering:\n\t[Right Click] Open drop-down menu\n\t[Left Click] Start dragging item\n\t[Hover] Item info\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 72
+
+ draw.DrawText("While dragging:\n\tDrop in a slot to equip\n\tDrop outside inventory to drop it\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 54
+
+ draw.DrawText("Drop-down menu:\n\t[Drop] Drops the item\n\t[Use] Use/Eat the item\n","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ elseif (MAIN_HELP == 4) then
+ draw.DrawText("Recipes:","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ surface.SetFont("Trebuchet18")
+ draw.DrawText(WrapString("Combining:\n To create an item, you drag and drop an item into the bottom of your recipes menu and then press combine. If there is a recipe corresponding to the items you placed, then a recipe will be discovered and you can select it from your recipes list to create the item.",240),"Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ elseif (MAIN_HELP == 5) then
+ draw.DrawText("Credits:","Trebuchet24",gx+4,gy,MAIN_TEXTCOLOR,0)
+ gy = gy + 24
+
+ draw.DrawText("The Maw\nThirteen (Notes textures)\nApickx","Trebuchet18",gx+4,gy,MAIN_TEXTCOLOR,0)
+ end
+end
diff --git a/gamemode/hud/draw_indicators.lua b/gamemode/hud/draw_indicators.lua new file mode 100644 index 0000000..2daf925 --- /dev/null +++ b/gamemode/hud/draw_indicators.lua @@ -0,0 +1,60 @@ +
+local x,y = ScrW()-140,ScrH()-140
+local cos = math.cos
+
+function DrawIndicators()
+ local pl = LocalPlayer()
+ if (pl:IsPigeon()) then return end
+
+ local HP = pl:Health()
+ local HP_c = 1-math.max(0,HP/100)
+ local A = MAIN_WHITECOLOR.a*1
+
+ --1 == Hunger
+ --2 == Thirst
+ --3 == Heat
+ --4 == Fatigue
+
+ local Cur = UnPredictedCurTime()*0.1%1*360
+ local Time = (cos(Cur)+1)/2
+ local CUR = (cos(UnPredictedCurTime())+1)/2
+
+ for i = 1,4 do
+ local Col = MAIN_GREENCOLOR
+ local Siz = 4
+
+ if (i == 1) then Col = MAIN_GREENCOLOR Siz=Siz+30*math.Clamp(pl:GetHunger()/100,0,1)
+ elseif (i == 2) then Col = MAIN_BLUECOLOR Siz=Siz+30*math.Clamp(pl:GetWater()/100,0,1)
+ elseif (i == 3) then Col = MAIN_REDCOLOR Siz=Siz+30*math.Clamp(pl:GetHeat()/100,0,1)
+ else Col = MAIN_YELLOWCOLOR Siz=Siz+30*math.Clamp(pl:GetFatigue()/100,0,1)
+ end
+
+ local AB = Col.a*1
+ Col.a = 200+50*CUR
+
+ DrawOutlinedCircle(x,y,Siz,8,Cur+90*i,90,8,Col)
+
+ Col.a = AB
+ end
+
+ --HP
+ local Time = 255-(255*HP_c)*(cos(UnPredictedCurTime()*(1+10*HP_c))+1)/2
+ MAIN_WHITECOLOR.r = Time
+ MAIN_WHITECOLOR.g = Time
+ MAIN_WHITECOLOR.b = Time
+
+ DrawOutlinedCircle(x,y,40,8,Cur,360,32,MAIN_WHITECOLOR)
+
+ MAIN_WHITECOLOR.r = 255
+ MAIN_WHITECOLOR.g = 255
+ MAIN_WHITECOLOR.b = 255
+
+ local Time2 = (cos(UnPredictedCurTime()*2*(1+3*HP_c))+1)/2
+ local Alpha = math.max(0,50-90*Time2)
+
+ MAIN_WHITECOLOR.a = Alpha
+
+ DrawOutlinedCircle(x,y,40+200*Time2,8,Cur*30,360,32,MAIN_WHITECOLOR)
+
+ MAIN_WHITECOLOR.a = 255
+end
diff --git a/gamemode/hud/draw_lootventory.lua b/gamemode/hud/draw_lootventory.lua new file mode 100644 index 0000000..fc62280 --- /dev/null +++ b/gamemode/hud/draw_lootventory.lua @@ -0,0 +1,77 @@ +local Ventory = nil
+local MCO = Color(0,0,0,150)
+
+function ReloadLootventory()
+ if (!IsValid(Ventory)) then return end
+
+ Ventory.List:Clear()
+
+ for k,v in pairs(Ventory.DATA) do
+ local a = Ventory.List:Add("DPanel")
+ a:SetSize(64,64)
+ a.Item = GetItemByName(v.Name)
+ a.Par = Ventory
+ a.Quantity = v.Quantity
+ a:Droppable("LOOTVENTORY")
+ a.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ if (s.Item) then DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,s.Item.Icon) end
+
+ DrawText("x"..v.Quantity,"ChatFont",1,h-18,MAIN_TEXTCOLOR)
+ end
+ end
+end
+
+function IsLootventoryOpen()
+ return (Ventory and Ventory:IsVisible())
+end
+
+function CloseLootventory()
+ if (!IsLootventoryOpen()) then return end
+
+ Ventory:SetVisible(false)
+end
+
+function MakeLootventory(dat,ent)
+ if (!dat) then return end
+
+ if (!Ventory) then
+ Ventory = vgui.Create("MBFrame")
+ Ventory:SetPos(690,ScrH()-480)
+ Ventory:SetSize(200,200)
+ Ventory:SetTitle("Lootventory")
+ Ventory:SetDeleteOnClose(false)
+ --Ventory:MakePopup()
+ Ventory:ShowCloseButton(false)
+ Ventory.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ Ventory.OnClose = function(s) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+
+ local Pane = vgui.Create( "DScrollPanel", Ventory )
+ Pane:SetPos(5,25)
+ Pane:SetSize(Ventory:GetWide()-10,Ventory:GetTall()-30)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ Pane:Receiver("INVENTORY", function(s,a,b,c)
+ local p = a[1]
+
+ if (p.Item and IsValid(Ventory.Entity) and b) then
+ TransferItems(p.Item.Name,p.Quantity,Ventory.Entity)
+ DemandLootventoryUpdate(Ventory.Entity)
+ end
+ end)
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ Ventory.List = l
+ end
+
+ Ventory:SetVisible(true)
+
+ Ventory.Entity = ent
+ Ventory.DATA = dat
+
+ ReloadLootventory()
+end
diff --git a/gamemode/hud/draw_qmenu.lua b/gamemode/hud/draw_qmenu.lua new file mode 100644 index 0000000..1466704 --- /dev/null +++ b/gamemode/hud/draw_qmenu.lua @@ -0,0 +1,346 @@ +local Inventory = nil
+local RecipeMenu = nil
+local MCO = Color(0,0,0,150)
+local BCO = Color(0,50,100,150)
+local GCO = Color(0,100,0,150)
+local HCO = Color(30,30,30,150)
+
+--Garry... for the love of god, this fucking function is spamming the console with debug information.
+--I decided to override it so it shuts up!
+dragndrop.HandleDroppedInGame = function() end
+
+function ReloadInventory()
+ if (!IsInventoryOpen()) then return end
+ Inventory.List:Clear()
+
+ ReloadRecipes()
+
+ for k,v in pairs(LocalPlayer():GetInventory()) do
+ local a = Inventory.List:Add("DPanel")
+ a:SetSize(64,64)
+ a.Item = GetItemByName(v.Name)
+ a.Quantity = v.Quantity
+ a:Droppable("INVENTORY")
+ a.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+ DrawMaterialRect(0,0,w,h,MAIN_WHITECOLOR,s.Item.Icon)
+
+ DrawText("x"..v.Quantity,"ChatFont",1,h-18,MAIN_TEXTCOLOR)
+ end
+
+ a.OnStopDragging = function(s,a,b,c)
+ local ID = IsMouseInSlot()
+
+ if (!ID) then return end
+
+ RequestEquip(ID,s.Item.Name)
+ end
+
+ local Ab = a.OnMousePressed
+ a.OnMousePressed = function(s,m)
+ if (m == MOUSE_RIGHT) then
+ local X,Y = gui.MousePos()
+
+ local menu = DermaMenu()
+ menu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ menu:AddOption( "Use", function() if (s.Item) then RequestUseItem(s.Item.Name) end end ):SetColor(MAIN_TEXTCOLOR)
+ menu:AddOption( "Drop", function() if (s.Item) then RequestDropItem(s.Item.Name) end end ):SetColor(MAIN_TEXTCOLOR)
+
+ menu:Open()
+ menu:SetPos(X,Y)
+ end
+
+ Ab(s,m)
+ end
+
+ a.OnCursorEntered = function(s)
+ Inventory.Desc:SetVisible(true)
+ Inventory.Desc:SetText(s.Item.Name.."\n\n"..s.Item.Desc)
+ Inventory.CraftingButton:SetVisible(false)
+
+ s.Hover = true
+ end
+
+ a.OnCursorExited = function(s)
+ Inventory.Desc:SetVisible(false)
+
+ if (RecipeMenu.SelectedRecipe) then
+ Inventory.CraftingButton:SetVisible(true)
+ end
+
+ s.Hover = false
+ end
+ end
+end
+
+function ReloadRecipes()
+ if (!IsInventoryOpen()) then return end
+ RecipeMenu.List:Clear()
+ RecipeMenu.Combine.Items = {}
+
+ for k,v in pairs(GAMEMODE.KnownRecipes) do
+ local a = RecipeMenu.List:Add("MBButton")
+ a:SetText(v.Name)
+ a:SetSize(RecipeMenu.List:GetWide()-5,23)
+ a.Item = v
+ a.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h-3,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h-3,HCO)
+ else DrawRect(0,0,w,h-3,MCO) end
+
+ DrawText(s.Item.Name,"Trebuchet18",4,0,MAIN_TEXTCOLOR)
+ end
+ a.DoClick = function(s)
+ if (RecipeMenu.SelectedRecipe == a.Item) then RecipeMenu.SelectedRecipe = nil Inventory.CraftingButton:SetVisible(false)
+ else RecipeMenu.SelectedRecipe = a.Item Inventory.CraftingButton:SetVisible(true) end
+ end
+ end
+end
+
+function GM:OnSpawnMenuOpen()
+ if (LocalPlayer():IsPigeon()) then return end
+ if (IsInventoryOpen()) then return end
+
+ surface.PlaySound("wintersurvival2/hud/itemopen.wav")
+
+ if (!Inventory) then
+ --Recipes
+ RecipeMenu = vgui.Create("MBFrame")
+ RecipeMenu:SetPos(485,ScrH()-480)
+ RecipeMenu:SetSize(200,400)
+ RecipeMenu:SetTitle("Recipes")
+ RecipeMenu:ShowCloseButton(false)
+ RecipeMenu.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ RecipeMenu.SelectedRecipe = nil
+
+ local Pane = vgui.Create( "DScrollPanel", RecipeMenu )
+ Pane:SetPos(5,25)
+ Pane:SetSize(RecipeMenu:GetWide()-10,RecipeMenu:GetTall()-150)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+
+ local l = vgui.Create("DListLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+
+ RecipeMenu.List = l
+
+ local c = vgui.Create( "MBFrame", RecipeMenu )
+ c:SetPos(5,RecipeMenu:GetTall()-120)
+ c:SetSize(RecipeMenu:GetWide()-10,115)
+ c:SetTitle("")
+ c:ShowCloseButton(false)
+ c.Items = {}
+ c.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+
+ local Press = input.MousePress(MOUSE_LEFT,"MenuPress")
+
+ if (table.Count(s.Items) < 1) then
+ DrawText("Draw items here!","Trebuchet24",w/2,h/2-3,MAIN_WHITECOLOR,1)
+ else
+ for i = 1,4 do
+ local v = s.Items[i]
+
+ if (v and v.Name) then
+ local Item = GetItemByName(v.Name)
+ local y = -15+20*i
+ local x = 5
+
+ local X,Y = s:GetParent():GetPos()
+ local SX,SY = s:GetPos()
+ X = X+SX
+ Y = Y+SY
+
+ if (!input.IsMouseInBox(X+x,Y+y,w-10,18)) then DrawRect(x,y,w-10,18,MCO)
+ else
+ DrawRect(x,y,w-10,18,GCO)
+
+ if (Press) then
+ s.Items[i] = nil
+ break
+ end
+ end
+
+ if (Item.Icon) then
+ DrawMaterialRect(x+1,y+1,16,16,MAIN_WHITECOLOR,Item.Icon)
+ end
+
+ DrawText("x "..v.Quantity.." "..v.Name,"Trebuchet18",23,y,MAIN_WHITECOLOR)
+ end
+ end
+ end
+ end
+ c:Receiver("INVENTORY", function(s,a,b,c)
+ local p = a[1]
+
+ if (p.Item and b) then
+ local Find = false
+
+ for i = 1,4 do
+ if (s.Items[i] and s.Items[i].Name == p.Item.Name) then
+ if (LocalPlayer():HasItem(s.Items[i].Name,s.Items[i].Quantity+1)) then
+ s.Items[i].Quantity = s.Items[i].Quantity + 1
+ end
+
+ Find = true
+ break
+ end
+ end
+
+ if (!Find) then
+ for i = 1,4 do
+ if (!s.Items[i]) then
+ s.Items[i] = {Name = p.Item.Name,Quantity = 1}
+ break
+ end
+ end
+ end
+ end
+ end)
+
+ local B = vgui.Create("MBButton",c)
+ B:SetPos(5,c:GetTall()-25)
+ B:SetSize(c:GetWide()-10,20)
+ B:SetVisible(true)
+ B.DoClick = function(s)
+ local Items = RecipeMenu.Combine.Items
+
+ if (Items and table.Count(Items) > 0) then
+ DiscoverItems(Items)
+ end
+ end
+ B.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h-3,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h-3,HCO)
+ else DrawRect(0,0,w,h-3,MCO) end
+
+ DrawText("Combine","Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+
+ RecipeMenu.Combine = c
+
+ --Inventory
+ Inventory = vgui.Create("MBFrame")
+ Inventory:SetPos(80,ScrH()-480)
+ Inventory:SetSize(400,400)
+ Inventory:SetTitle("Inventory")
+ Inventory:SetDeleteOnClose(false)
+ Inventory:MakePopup()
+ Inventory:SetVisible(false)
+ Inventory:ShowCloseButton(false)
+ Inventory.OnKeyCodePressed = function(panel, key)
+ if(key == 27 or key == 15) then
+ if(Inventory and Inventory:IsVisible())then
+ Inventory:SetVisible(false)
+ RecipeMenu:SetVisible(false)
+ CloseLootventory()
+ surface.PlaySound("wintersurvival2/hud/itemequip.wav")
+ else
+ Inventory:SetVisible(true)
+ RecipeMenu:SetVisible(true)
+ end
+ end
+ end
+ Inventory.Paint = function(s,w,h)
+ DrawRect(0,0,w,h,MCO)
+
+ local X,Y,W,H = 5,h-120,w-10,115
+ DrawRect(X,Y,W,H,MCO)
+
+ local Rec = RecipeMenu.SelectedRecipe
+
+ if (Rec and Inventory.CraftingButton:IsVisible()) then
+ local Recipe = Rec.Recipe
+ local pl = LocalPlayer()
+ local C = 0
+ local Step = W/3
+
+ DrawText("Products:","Trebuchet18",X+5,Y,MAIN_TEXTCOLOR)
+ DrawText("Reagents:","Trebuchet18",X+Step+5,Y,MAIN_TEXTCOLOR)
+ DrawText("Tools:","Trebuchet18",X+Step*2+5,Y,MAIN_TEXTCOLOR)
+
+ for k,v in pairs(Recipe.Resources) do
+ C = C+1
+ if (pl:HasItem(k,v)) then DrawText(v.." x "..k,"Trebuchet18",X+Step+5,Y+16*C,MAIN_GREENCOLOR)
+ else DrawText(v.." x "..k,"Trebuchet18",X+Step+5,Y+16*C,MAIN_REDCOLOR) end
+ end
+
+ C = 0
+ for k,v in pairs(Recipe.Tools) do
+ C = C+1
+ if (pl:HasItem(k,v)) then DrawText(v.."x "..k,"Trebuchet18",X+5+Step*2,Y+16*C,MAIN_GREENCOLOR)
+ else DrawText(v.."x "..k,"Trebuchet18",X+5+Step*2,Y+16*C,MAIN_REDCOLOR) end
+ end
+
+ DrawText("1 x "..Rec.Name,"Trebuchet18",X+5,Y+16,MAIN_GREENCOLOR)
+ end
+ end
+ Inventory.OnClose = function(s) CloseLootventory() RecipeMenu:SetVisible(false) surface.PlaySound("wintersurvival2/hud/itemequip.wav") end
+
+ local Pane = vgui.Create( "DScrollPanel", Inventory )
+ Pane:SetPos(5,25)
+ Pane:SetSize(Inventory:GetWide()-10,Inventory:GetTall()-150)
+ Pane.Paint = function(s,w,h) DrawRect(0,0,w,h,MCO) end
+ Pane:Receiver("LOOTVENTORY", function(s,a,b,c)
+ local p = a[1]
+
+ if (p.Item and IsValid(p.Par.Entity) and b) then
+ DemandItems(p.Item.Name,p.Quantity,p.Par.Entity)
+ DemandLootventoryUpdate(p.Par.Entity)
+ end
+ end)
+
+ local l = vgui.Create("DIconLayout",Pane)
+ l:SetSize(Pane:GetWide()-10,Pane:GetTall()-10)
+ l:SetPos(5,5)
+ l:SetSpaceY(5)
+ l:SetSpaceX(5)
+
+ Inventory.List = l
+
+ local B = vgui.Create("MBButton",Inventory)
+ B:SetPos(Inventory:GetWide()-110,Inventory:GetTall()-25)
+ B:SetSize(100,20)
+ B:SetVisible(false)
+ B.DoClick = function(s)
+ if (RecipeMenu.SelectedRecipe) then RequestCreateRecipe(RecipeMenu.SelectedRecipe.Name) end
+ end
+ B.Paint = function(s,w,h)
+ if (s.Pressed) then DrawRect(0,0,w,h-3,BCO)
+ elseif (s.Hover) then DrawRect(0,0,w,h-3,HCO)
+ else DrawRect(0,0,w,h-3,MCO) end
+
+ DrawText("Craft!","Trebuchet18",w/2,h/2,MAIN_TEXTCOLOR,1)
+ end
+
+ Inventory.CraftingButton = B
+
+ local a = vgui.Create("DLabel",Inventory)
+ a:SetPos(10,Inventory:GetTall()-120)
+ a:SetSize(Inventory:GetWide()-2,1)
+ a:SetText("")
+ a:SetWrap(true)
+ a:SetVisible(false)
+ a:SetTextColor(MAIN_TEXTCOLOR)
+ a:SetFont("Trebuchet18")
+ a:SetAutoStretchVertical(true)
+
+ Inventory.Desc = a
+ end
+
+ --RecipeMenu:SetVisible(true)
+ --Inventory:SetVisible(true)
+ if(Inventory and Inventory:IsVisible())then
+ Inventory:SetVisible(false)
+ RecipeMenu:SetVisible(false)
+ else
+ Inventory:SetVisible(true)
+ RecipeMenu:SetVisible(true)
+ end
+
+ ReloadInventory()
+end
+
+function IsInventoryOpen()
+ return (Inventory and Inventory:IsVisible())
+end
diff --git a/gamemode/hud/draw_scoreboard.lua b/gamemode/hud/draw_scoreboard.lua new file mode 100644 index 0000000..8062c56 --- /dev/null +++ b/gamemode/hud/draw_scoreboard.lua @@ -0,0 +1,40 @@ +local SCOREBOARD_FADE = Color(20,20,20,70)
+
+local SCOREBOARD_OFF = 101
+local SCOREBOARD_WIDTH = 700
+local SCOREBOARD_X = ScrW() / 2 - SCOREBOARD_WIDTH / 2
+
+function GM:ScoreboardShow()
+ self.ShowSB = true
+end
+
+function GM:ScoreboardHide()
+ self.ShowSB = false
+end
+
+function GM:HUDDrawScoreBoard()
+ if (!self.ShowSB) then return end
+
+ local NPly = #player.GetAll()
+ local Tall = SCOREBOARD_OFF + 20 * NPly
+ local y = ScrH() / 2 - Tall / 2
+ local by = y + SCOREBOARD_OFF
+
+ DrawRect(SCOREBOARD_X, y, SCOREBOARD_WIDTH, Tall, MAIN_COLOR)
+ DrawRect(SCOREBOARD_X, by, SCOREBOARD_WIDTH, NPly*20, MAIN_COLORD)
+
+ DrawText(self.Name, "ScoreboardFont", ScrW()/2, y + 50, MAIN_TEXTCOLOR,1)
+ DrawText("By The Maw", "Trebuchet18", ScrW()/2-150, y + 80, MAIN_TEXTCOLOR,1)
+
+ for k,v in pairs( player.GetAll() ) do
+ local Y = by + 20 * (k-1)
+
+ if (v:IsPigeon()) then
+ DrawText(v:Nick(), "Trebuchet18", SCOREBOARD_X + 2, Y, MAIN_GREYCOLOR)
+ DrawText(v:Ping(), "Trebuchet18", SCOREBOARD_X + SCOREBOARD_WIDTH - 30, Y, MAIN_GREYCOLOR)
+ else
+ DrawText(v:Nick(), "Trebuchet18", SCOREBOARD_X + 2, Y, MAIN_TEXTCOLOR)
+ DrawText(v:Ping(), "Trebuchet18", SCOREBOARD_X + SCOREBOARD_WIDTH - 30, Y, MAIN_TEXTCOLOR)
+ end
+ end
+end
diff --git a/gamemode/hud/draw_targets.lua b/gamemode/hud/draw_targets.lua new file mode 100644 index 0000000..b5eadac --- /dev/null +++ b/gamemode/hud/draw_targets.lua @@ -0,0 +1,11 @@ +function DrawTargets()
+ local pl = LocalPlayer()
+
+ if (pl:IsPigeon()) then return end
+
+ local tr = pl:GetEyeTrace()
+
+ if (IsValid(tr.Entity) and tr.Entity:IsPlayer()) then
+ DrawText(tr.Entity:Nick(),"ChatFont",ScrW()/2,ScrH()/2,MAIN_YELLOWCOLOR,1)
+ end
+end
\ No newline at end of file diff --git a/gamemode/hud/draw_voicechat.lua b/gamemode/hud/draw_voicechat.lua new file mode 100644 index 0000000..f0c63c8 --- /dev/null +++ b/gamemode/hud/draw_voicechat.lua @@ -0,0 +1,33 @@ +local VoiceEna = true
+local VOCOL = table.Copy(MAIN_COLOR)
+local x,y = ScrW(),ScrH()
+
+function GM:PlayerStartVoice( ply )
+ ply.Talking = true
+end
+
+function GM:PlayerEndVoice( ply )
+ ply.Talking = nil
+end
+
+hook.Add("HUDPaint","_VoiceChatDraw",function()
+ local D = 0
+
+ for k,v in pairs( player.GetAll() ) do
+ if (v.Talking) then
+ local H = 45*D
+ D = D+1
+
+ local V = v:VoiceVolume()
+ local D = MAIN_COLOR
+
+ VOCOL.r = math.Clamp(D.r-100*V,0,255)
+ VOCOL.g = math.Clamp(D.g+200*V,0,255)
+ VOCOL.b = math.Clamp(D.b-100*V,0,255)
+
+ DrawRect( x-250, y-170-H, 200, 40, VOCOL )
+ DrawRect( x-246, y-166-H, 32, 32, MAIN_WHITECOLOR )
+ DrawText( v:Nick(), "Trebuchet18", x-206, y-159-H, MAIN_TEXTCOLOR )
+ end
+ end
+end)
\ No newline at end of file diff --git a/gamemode/hud/draw_wepswap.lua b/gamemode/hud/draw_wepswap.lua new file mode 100644 index 0000000..40c2310 --- /dev/null +++ b/gamemode/hud/draw_wepswap.lua @@ -0,0 +1,64 @@ +local Num = 0
+local MCO = Color(0,0,0,150)
+
+local max = math.max
+local min = math.min
+local cos = math.cos
+local sin = math.sin
+local rad = math.rad
+
+local h = ScrH()
+local s = 65
+local B = s+5
+
+function DrawWepSwap()
+ local pl = LocalPlayer()
+ if (pl:IsPigeon()) then return end
+ if (GetRecentSwapTime() < CurTime()-3 and !IsInventoryOpen()) then return end
+
+ local Slot = GetWeaponSlot()
+
+ Num = Num+math.Clamp((Slot-Num)/6,-1,1)
+
+ if (!IsInventoryOpen()) then MCO.a = 150*min(1,GetRecentSwapTime()-(CurTime()-3))
+ else MCO.a = 150 end
+
+ local Ib = input.MousePress(MOUSE_LEFT,"Unequip")
+
+ for i = 0,9 do
+ local r = Num-i
+ local x = max(0,B*r)
+ local y = max(0,B*-r)
+
+ if (Slot == i) then MCO.b = 150
+ else MCO.b = 0 end
+
+ DrawRect(x+10,h-s-y-10,s,s,MCO)
+
+ if (pl.Weapons and pl.Weapons[i]) then
+ if (pl.Weapons[i].Item.Icon) then DrawMaterialRect(x+10,h-s-y-10,s,s,MAIN_WHITECOLOR,pl.Weapons[i].Item.Icon) end
+
+ if (input.IsMouseInBox(x+10,h-s-y-10,s,s) and Ib) then
+ RequestUnEquip(i)
+ timer.Simple(0.05,function() ReloadInventory() end)
+ end
+ end
+ end
+end
+
+function IsMouseInSlot()
+ local mx,my = gui.MousePos()
+
+ for i = 0,9 do
+ local r = Num-i
+ local x = max(0,B*r)
+ local y = max(0,B*-r)
+
+ if (input.IsMouseInBox(x+10,h-s-y-10,s,s)) then
+ return i
+ end
+ end
+
+ return false
+end
+
\ No newline at end of file |
