diff options
| author | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
|---|---|---|
| committer | Apickx <Apickx@cogarr.org> | 2015-12-28 19:18:30 -0500 |
| commit | 868e729d68b5913716bfe5ddb512f4099851e9a2 (patch) | |
| tree | 6441108754145dfd68a6e23bea382b5cb1ab63d5 /gamemode/cl_hud/vgui | |
| download | gearfox-master.tar.gz gearfox-master.tar.bz2 gearfox-master.zip | |
Diffstat (limited to 'gamemode/cl_hud/vgui')
| -rw-r--r-- | gamemode/cl_hud/vgui/mbbrowser.lua | 43 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbbutton.lua | 66 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbframe.lua | 84 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mblabel.lua | 108 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbmodel.lua | 53 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbpanellist.lua | 67 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbtab.lua | 106 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbtree.lua | 92 | ||||
| -rw-r--r-- | gamemode/cl_hud/vgui/mbuserbrowser.lua | 76 |
9 files changed, 695 insertions, 0 deletions
diff --git a/gamemode/cl_hud/vgui/mbbrowser.lua b/gamemode/cl_hud/vgui/mbbrowser.lua new file mode 100644 index 0000000..738c8ed --- /dev/null +++ b/gamemode/cl_hud/vgui/mbbrowser.lua @@ -0,0 +1,43 @@ +local PANEL = {} + +function PANEL:Init() + self.bgcol = MAIN_COLOR + self.fgcol = MAIN_COLOR2 + + self.HTML = vgui.Create( "HTML" , self ) + self.HTML:OpenURL("www.google.com") + self.HTML.StatusChanged = function( s , str ) self.Status = str end + + self.Status = "Ready." + + self:SetPaintBackgroundEnabled( false ) + self:SetPaintBorderEnabled( false ) +end + +function PANEL:OpenURL(url) + self.HTML:OpenURL(url) +end + +function PANEL:SetFGColor( col ) + self.fgcol = col +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:Paint(w,h) + DrawBoxy( 0 , 0 , w , h , self.bgcol ) + DrawLine( 0 , 20 , w , 20 , self.fgcol ) + + DrawText( self.Status , "Trebuchet18" , 5 , self:GetTall()-20 , MAIN_WHITECOLOR ) + + return true +end + +function PANEL:PerformLayout() + self.HTML:SetPos(1,22) + self.HTML:SetSize(self:GetWide()-2,self:GetTall()-44) +end + +vgui.Register( "MBBrowser", PANEL , "MBFrame" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbbutton.lua b/gamemode/cl_hud/vgui/mbbutton.lua new file mode 100644 index 0000000..a5c0363 --- /dev/null +++ b/gamemode/cl_hud/vgui/mbbutton.lua @@ -0,0 +1,66 @@ +local PANEL = {} + +function PANEL:Init() + self.Hover = false + self.Pressed = false + self.Text = "No-Title Button" + self.ClickSound = "buttons/lightswitch2.wav" + self.ClickEnable = true + + self.HoverSound = "common/bugreporter_succeeded.wav" + self.HoverEnable = false + + + self:SetText("") + self.SetText = function(s,txt) self.Text = txt end +end + +function PANEL:OnCursorEntered() + self.Hover = true + if (self.HoverEnable) then surface.PlaySound(self.HoverSound) end +end + +function PANEL:EnableHoverSound(bool) + self.HoverEnable = bool +end + +function PANEL:SetHoverSound(sound) + self.HoverSound = sound +end + +function PANEL:EnableClickSound(bool) + self.ClickEnable = bool +end + +function PANEL:SetClickSound(sound) + self.ClickSound = sound +end + +function PANEL:OnMousePressed() + self.Pressed = true + self:MouseCapture( true ) +end + +function PANEL:OnMouseReleased() + if (self.Pressed) then surface.PlaySound(self.ClickSound) self:DoClick() end + + self.Pressed = false + self:MouseCapture( false ) +end + +function PANEL:OnCursorExited() + self.Hover = false +end + +function PANEL:Paint(w,h) + if (self.Pressed) then DrawRect( 0 , 0 , w , h , MAIN_GREENCOLOR ) + elseif (self.Hover) then DrawRect( 0 , 0 , w , h , MAIN_COLOR2 ) + else DrawRect( 0 , 0 , w , h , MAIN_COLORD ) end + + DrawText( self.Text, "Trebuchet18", w/2, h/2, MAIN_TEXTCOLOR, 1 ) +end + +function PANEL:PerformLayout() +end + +vgui.Register( "MBButton", PANEL , "Button" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbframe.lua b/gamemode/cl_hud/vgui/mbframe.lua new file mode 100644 index 0000000..ab99fd7 --- /dev/null +++ b/gamemode/cl_hud/vgui/mbframe.lua @@ -0,0 +1,84 @@ +local PANEL = {} +local Close = surface.GetTextureID("gearfox/vgui/close") + +function PANEL:Init() + self.bgcol = MAIN_COLOR + self.fgcol = MAIN_COLOR2 + + self.Font = "Trebuchet18" + self.Text = "No-Title MBFrame" + self.TextCol = MAIN_TEXTCOLOR + self.BrigCol = MAIN_WHITECOLOR + self.CloseRem = false + self.ShowClose = true + + self:SetPaintBackgroundEnabled( false ) + self:SetPaintBorderEnabled( false ) +end + +function PANEL:OnClose() +end + +function PANEL:SetDeleteOnClose( bool ) + self.CloseRem = bool +end + +function PANEL:SetTitle( name ) + self.Text = name +end + +function PANEL:SetFGColor( col ) + self.fgcol = col +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:SetTextColor( col ) + self.TextCol = col +end + +function PANEL:SetTextFont( font ) + self.Font = font +end + +function PANEL:ShowCloseButton( bool ) + self.ShowClose = bool +end + +function PANEL:OnMousePressed() + if (!self.ShowClose) then return end + + local x,y = self:LocalToScreen( self:GetWide()-17 , 3 ) + + if (input.IsMouseInBox( x , y , 14 , 14 )) then + self:OnClose() + + if (self.CloseRem) then self:Remove() + else self:SetVisible(false) end + end +end + +function PANEL:Paint(w,h) + DrawBoxy( 0 , 0 , w , h , self.bgcol ) + DrawLine( 0 , 20 , w , 20 , self.fgcol ) +end + +function PANEL:PaintOver(w,h) + DrawText( self.Text , self.Font , 2 , 2 , self.TextCol ) + + if (self.ShowClose) then + local x,y = self:GetPos() + + if (input.IsMouseInBox(x+w-17 , y+3 , 14 , 14)) then DrawTexturedRect( w-17 , 3 , 14 , 14 , self.BrigCol , Close ) + else DrawTexturedRect( w-17 , 3 , 14 , 14 , self.TextCol , Close ) end + end + + return true +end + +function PANEL:PerformLayout() +end + +vgui.Register( "MBFrame", PANEL, "EditablePanel" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mblabel.lua b/gamemode/cl_hud/vgui/mblabel.lua new file mode 100644 index 0000000..1f1e3bb --- /dev/null +++ b/gamemode/cl_hud/vgui/mblabel.lua @@ -0,0 +1,108 @@ +local PANEL = {} + +function PANEL:Init() + self.Lines = {} + self.Texts = {} + + self.LineHeight = 20 +end + +function PANEL:AddText(text,font,color) + if (!font) then font = "Trebuchet18" end + if (!color) then color = MAIN_TEXTCOLOR end + + text = " "..text + + table.insert(self.Texts,{text,font,color,}) +end + +function PANEL:ClearText() + self.Lines = {} + self.Texts = {} +end + +function PANEL:SetupLines() + local w = 0 + local dat = {} + local Tal = 20 + + for k,v in pairs( self.Texts ) do + surface.SetFont(v[2]) + local a,b = surface.GetTextSize(v[1]) + + if (b > Tal) then Tal = b end + + if (w+a > self:GetWide()) then + local Exp = string.Explode(" ",v[1]) + local Dat = "" + local Tab = {} + local wi = 0 + + for p,d in pairs( Exp ) do + local si,so = surface.GetTextSize(" "..d) + + wi = wi + si + + if (w+wi < self:GetWide()) then + Dat = Dat.." "..d + else + table.insert(dat,{Dat,v[2],v[3],}) + table.insert(self.Lines,dat) + + dat = {} + Dat = " "..d + wi = 0 + w = 0 + end + end + + table.insert(dat,{Dat,v[2],v[3],}) + else + w = w + a + table.insert(dat,v) + end + end + + table.insert(self.Lines,dat) + + Tal = Tal*#self.Lines + self:SetTall(Tal) + + self.Texts = nil --Since this function is called to setup a wrapped text, we no longer need the table with shit on. +end + +function PANEL:SetTextColor( col ) +end + +function PANEL:SetTextFont( font ) +end + +function PANEL:Paint() + if (self.Lines) then + for k,v in pairs(self.Lines) do + local w = 0 + for c,j in pairs(v) do + local Text = j[1] + local Font = j[2] + local Col = j[3] + + surface.SetFont(Font) + + local wid,hei = surface.GetTextSize(Text) + + surface.SetTextColor(Col) + surface.SetTextPos(w,self.LineHeight*(k-1)) + surface.DrawText(Text) + + w = w+wid + end + end + end + + return true +end + +function PANEL:PerformLayout() +end + +vgui.Register( "MBLabel", PANEL , "DLabel" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbmodel.lua b/gamemode/cl_hud/vgui/mbmodel.lua new file mode 100644 index 0000000..373c98a --- /dev/null +++ b/gamemode/cl_hud/vgui/mbmodel.lua @@ -0,0 +1,53 @@ +local PANEL = {} +local Zero = Vector(0,0,0) +local One = Vector(1,1,1) + +function PANEL:Init() + self.bgcol = MAIN_COLOR2 + + self.Model = vgui.Create( "DModelPanel" , self ) + self.Model:SetCamPos( Vector( 30, 30, 30 ) ) + self.Model:SetLookAt( Zero ) + self.Model:SetSize( self:GetWide() , self:GetTall() ) + self.Model:SetPos( 0 , 0 ) + + self.Model.DoRightClick = function(s) self:DoRightClick() end + self.Model.DoClick = function(s) self:DoLeftClick() end +end + +function PANEL:DoRightClick() +end + +function PANEL:DoLeftClick() +end + +function PANEL:SetModel( name , Texture ) + self.Model:SetModel( name ) + + local MSize,SSize = self.Model.Entity:GetRenderBounds() + SSize = SSize:Length() + + self.Model:SetCamPos( One * SSize ) + self.Model:SetLookAt( Zero ) + + if (Texture) then self.Model.Entity:SetMaterial(Texture) end +end + +function PANEL:GetModel() + return self.Model.Entity:GetModel() +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:Paint(w,h) + DrawRect( 0 , 0 , w , h , self.bgcol ) +end + +function PANEL:PerformLayout() + self.Model:SetSize( self:GetWide() , self:GetTall() ) + self.Model:SetPos( 0 , 0 ) +end + +vgui.Register( "MBModel", PANEL , "Panel" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbpanellist.lua b/gamemode/cl_hud/vgui/mbpanellist.lua new file mode 100644 index 0000000..3e9666a --- /dev/null +++ b/gamemode/cl_hud/vgui/mbpanellist.lua @@ -0,0 +1,67 @@ +local PANEL = {} + +function PANEL:Init() + self.bgcol = MAIN_COLORD + self.Limit = 100 + + self:SetPadding( 1 ) + self:SetSpacing( 1 ) + self:SetAutoSize(false) + self:EnableHorizontal( false ) + self:EnableVerticalScrollbar( true ) + self.VBar.Paint = function(s) end + self.VBar.btnGrip.Paint = function(s,w,h) DrawRect( 2 , 0 , w-4 , h , self.bgcol ) end + self.VBar.btnDown.Paint = function(s,w,h) DrawRect( 2 , 2 , w-4 , h-4 , self.bgcol ) end + self.VBar.btnUp.Paint = function(s,w,h) DrawRect( 2 , 2 , w-4 , h-4 , self.bgcol ) end + + self.Delta = 0 + self.Smooth = 0 +end + +function PANEL:OnMouseWheeled(Delta) + self.Delta = self.Delta+Delta +end + +function PANEL:SetVScroll(num) + self.VBar:SetScroll(num) +end + +function PANEL:AddVScroll(num) + self.VBar:AddScroll(num) +end + +function PANEL:SetFGColor( col ) + self.fgcol = col +end + +function PANEL:SetLimit(l) + self.Limit = l +end + +function PANEL:RemoveItem( item ) + for k, v in pairs( self.Items ) do + if ( v == item ) then + table.remove(self.Items,k) + v:Remove() + + self:InvalidateLayout() + break + end + end +end + +function PANEL:Think() + local It = self:GetItems() + if (#It > self.Limit) then self:RemoveItem(It[#It-self.Limit]) end + + if (self.Delta > 0.01 or self.Delta < -0.01 or self.Smooth > 0.01 or self.Smooth < -0.01) then + self.Delta = self.Delta - self.Delta/8 + self.Smooth = self.Smooth + (self.Delta-self.Smooth)/32 + self:AddVScroll(-self.Smooth/2) + end +end + +function PANEL:Paint() +end + +vgui.Register( "MBPanelList", PANEL , "DPanelList" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbtab.lua b/gamemode/cl_hud/vgui/mbtab.lua new file mode 100644 index 0000000..3899f69 --- /dev/null +++ b/gamemode/cl_hud/vgui/mbtab.lua @@ -0,0 +1,106 @@ +local PANEL = {} + +function PANEL:Init() + self.bgcol = MAIN_COLOR + self.fgcol = MAIN_COLOR2 + + self.TabsBut = {} + self.Tabs = {} + self.TabSel = "" + self.VertTabs = false + + self.Slide = 0 +end + +function PANEL:OnClose() +end + +function PANEL:SetVerticalTabs( bool ) + self.VertTabs = bool +end + +function PANEL:SetTitle( name ) +end + +function PANEL:SetFGColor( col ) + self.fgcol = col +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:AddTab(Text) + local A = vgui.Create("MBFrame",self) + A:SetTitle("") + A:SetVisible(false) + A:ShowCloseButton(false) + A:SetPos(0,20) + A:SetSize(self:GetWide(),self:GetTall()-25) + A.Paint = function(s,w,h) DrawRect(0,0,w,h,self.bgcol) end + + local D = vgui.Create("MBButton",self) + D:SetText(Text) + D.T = #self.TabsBut*1 + + if (D.T < 1) then A:SetVisible(true) self.TabSel = D.T end + + D.Paint = function(s,w,h) + if (self.TabSel == s.T) then DrawRect(0,0,w,h,self.bgcol) + else DrawRect(0,0,w,h,self.fgcol) end + + DrawText( s.Text, "Trebuchet18", w/2, h/2, MAIN_TEXTCOLOR, 1 ) + end + + D.DoClick = function() + for k,v in pairs(self.Tabs) do + v:SetVisible(false) + end + + self.Tabs[D.T]:SetVisible(true) + self.TabSel = D.T + end + + table.insert(self.TabsBut,D) + self.Tabs[D.T] = A + + return self.Tabs[D.T] +end + + +function PANEL:Paint() + return true +end + +function PANEL:Think() + local Num = #self.TabsBut + local W = self:GetWide() + local SW = 100*Num + local X,Y = self:LocalToScreen() + + if (SW > self:GetWide()) then + if (input.IsMouseInBox(X,Y,20,20) and self.Slide > 0) then + self.Slide = self.Slide-1 + + self:PerformLayout() + elseif (input.IsMouseInBox(X+W-20,Y,20,20) and self.Slide < SW-W) then + self.Slide = self.Slide+1 + + self:PerformLayout() + end + end +end + +function PANEL:PerformLayout() + for k,v in pairs(self.TabsBut) do + v:SetPos(100*(k-1)-self.Slide,0) + v:SetSize(97,20) + end + + if (self.Tabs[self.TabSel]) then + self.Tabs[self.TabSel]:SetPos(0,20) + self.Tabs[self.TabSel]:SetSize(self:GetWide(),self:GetTall()-25) + end +end + +vgui.Register( "MBTab", PANEL )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbtree.lua b/gamemode/cl_hud/vgui/mbtree.lua new file mode 100644 index 0000000..e2be877 --- /dev/null +++ b/gamemode/cl_hud/vgui/mbtree.lua @@ -0,0 +1,92 @@ +local PANEL = {} + +function PANEL:Init() + self.bgcol = MAIN_COLOR2 + self.hovercol = MAIN_COLORD + self.foldecol = MAIN_COLORD2 + self.selecCol = MAIN_GREENCOLOR + + self.VBar.Paint = function(s) end + self.VBar.btnGrip.Paint = function(s) DrawRect( 2 , 0 , s:GetWide()-4 , s:GetTall() , self.bgcol ) end + self.VBar.btnDown.Paint = function(s) DrawRect( 2 , 2 , s:GetWide()-4 , s:GetTall()-4 , self.bgcol ) end + self.VBar.btnUp.Paint = function(s) DrawRect( 2 , 2 , s:GetWide()-4 , s:GetTall()-4 , self.bgcol ) end + + self.Delta = 0 + self.Smooth = 0 + self.BGEnabled = true +end + +function PANEL:OnMouseWheeled(Delta) + self.Delta = self.Delta+Delta +end + +function PANEL:SetVScroll(num) + self.VBar:SetScroll(num) +end + +function PANEL:AddVScroll(num) + self.VBar:AddScroll(num) +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:EnableNodeBG( bool ) + self.BGEnabled = bool +end + +function PANEL:AddNode( text ) + local V = self.BaseClass.AddNode( self, text ) + + V.BGEnabled = self.BGEnabled + + V.FolCol = self.foldecol + V.HovCol = self.hovercol + V.SelCol = self.selecCol + V.OAddNode = V.AddNode + + V.Label:SetFont("Trebuchet18") + V.Label.Paint = function(s,w,h) + if (V:HasChildren() and V.BGEnabled) then DrawRect( 0 , 1 , w , h-2 , V.FolCol ) + elseif (!V:HasChildren() and self:GetSelectedItem()==V) then DrawRect( 0 , 1 , w , h-2 , V.SelCol ) + elseif (V.Hovered) then DrawRect( 0 , 1 , w , h-2 , V.HovCol ) end + end + + V.AddNode = function(s,txt) + local D = s.OAddNode(s,txt) + + D.FolCol = s.FolCol + D.HovCol = s.HovCol + D.SelCol = s.SelCol + D.BGEnabled = s.BGEnabled + + D.Label:SetFont("Trebuchet18") + + D.Label.Paint = function(p,w,h) + if (D:HasChildren() and D.BGEnabled) then DrawRect( 0 , 1 , w , h-2 , D.FolCol ) + elseif (!D:HasChildren() and self:GetSelectedItem()==D) then DrawRect( 0 , 1 , w , h-2 , D.SelCol ) + elseif (D.Hovered) then DrawRect( 0 , 1 , w , h-2 , D.HovCol ) end + end + + D.OAddNode = D.AddNode + D.AddNode = s.AddNode + + return D + end + + return V +end + +function PANEL:Think() + if (self.Delta > 0.01 or self.Delta < -0.01 or self.Smooth > 0.01 or self.Smooth < -0.01) then + self.Delta = self.Delta - self.Delta/8 + self.Smooth = self.Smooth + (self.Delta-self.Smooth)/32 + self:AddVScroll(-self.Smooth/2) + end +end + +function PANEL:Paint() +end + +vgui.Register( "MBTree", PANEL , "DTree" )
\ No newline at end of file diff --git a/gamemode/cl_hud/vgui/mbuserbrowser.lua b/gamemode/cl_hud/vgui/mbuserbrowser.lua new file mode 100644 index 0000000..8249662 --- /dev/null +++ b/gamemode/cl_hud/vgui/mbuserbrowser.lua @@ -0,0 +1,76 @@ +local PANEL = {} + +function PANEL:Init() + self.bgcol = MAIN_COLOR + self.fgcol = MAIN_COLOR2 + + self:SetTitle( "UserBrowser" ) + + self.HTML = vgui.Create( "HTML" , self ) + self.HTML:OpenURL( "www.google.com" ) + + self.HTML.StatusChanged = function( s , str ) self.Status = str end + self.HTML.PageTitleChanged = function( s , title ) self:SetTitle(title) end + self.HTML.FinishedURL = function( s , url ) self.URLBar:SetText(url) end + + self.Status = "Ready." + + self.BackB = vgui.Create( "MBButton" , self ) + self.BackB:SetText("<") + self.BackB:EnableHoverSound(false) + self.BackB.DoClick = function() self.HTML:HTMLBack() end + + self.RefreshB = vgui.Create( "MBButton" , self ) + self.RefreshB:SetText("Refresh") + self.RefreshB:EnableHoverSound(false) + self.RefreshB.DoClick = function() self.HTML:Refresh() end + + self.ForwardB = vgui.Create( "MBButton" , self ) + self.ForwardB:SetText(">") + self.ForwardB:EnableHoverSound(false) + self.ForwardB.DoClick = function() self.HTML:HTMLForward() end + + self.URLBar = vgui.Create( "DTextEntry" , self ) + self.URLBar:SetText("www.google.com") + self.URLBar.OnEnter = function(s) self.HTML:OpenURL(s:GetValue()) end +end + +function PANEL:OpenURL(url) + self.HTML:OpenURL(url) +end + +function PANEL:SetFGColor( col ) + self.fgcol = col +end + +function PANEL:SetBGColor( col ) + self.bgcol = col +end + +function PANEL:Paint(w,h) + DrawBoxy( 0 , 0 , w , h , self.bgcol ) + DrawLine( 0 , 20 , w , 20 , self.fgcol ) + + DrawText( self.Status , "Trebuchet18" , 5 , h-20 , MAIN_WHITECOLOR ) + + return true +end + +function PANEL:PerformLayout() + self.HTML:SetPos(1,42) + self.HTML:SetSize(self:GetWide()-2,self:GetTall()-64) + + self.BackB:SetPos(10,22) + self.BackB:SetSize(20,20) + + self.RefreshB:SetPos(60,22) + self.RefreshB:SetSize(80,20) + + self.ForwardB:SetPos(35,22) + self.ForwardB:SetSize(20,20) + + self.URLBar:SetPos(145,22) + self.URLBar:SetSize(self:GetWide()-150,20) +end + +vgui.Register( "MBUserBrowser", PANEL , "MBFrame" )
\ No newline at end of file |
