Anthr4x292

MindBlast Server Client Code: Billiards Game

Feb 11th, 2012
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 38.60 KB | None | 0 0
  1. ------------------------------------------------------------
  2. -- MBilliards by Athos Arantes Pereira
  3. -- Contact: [email protected]
  4. ------------------------------------------------------------
  5. language.Add("billiard_table", "Billiard Table")
  6. language.Add("billiard_cue", "Billiard Cue")
  7. language.Add("billiard_ball", " Billiard Ball")
  8.  
  9. b_MouseSensitivity = CreateClientConVar("billiard_cl_mouse_sensitivity", "2", true, true)
  10. b_InvCueMouseX = CreateClientConVar("billiard_cl_cue_invmouse_h", "0", true, true)
  11. b_InvCueMouseY = CreateClientConVar("billiard_cl_cue_invmouse_v", "0", true, true)
  12. b_InvMouseX = CreateClientConVar("billiard_cl_invmouse_h", "0", true, false)
  13. b_InvMouseY = CreateClientConVar("billiard_cl_invmouse_v", "0", true, false)
  14.  
  15. BILLIARD_GAMETYPE_8BALL = 0
  16. BILLIARD_GAMETYPE_9BALL = 1
  17. BILLIARD_GAMETYPE_SNOOKER = 2
  18. BILLIARD_GAMETYPE_ROTATION = 3
  19. BILLIARD_GAMETYPE_CARAMBOL = 4
  20.  
  21. RequestedPlayers = {}
  22. PocketedBalls_tmp = {}
  23. PocketedBalls = {}
  24.  
  25. b_GameType = 0
  26. b_SpecEnt = nil
  27. b_SpecBaseEnt = nil
  28. b_BilliardTime = nil
  29. b_LastAngles = nil
  30. b_FPerson = false
  31. b_RunTime = true
  32. b_CScore = nil
  33. b_OScore = nil
  34. b_ShotForce = 150
  35. b_Zoom = 30
  36.  
  37. constObjective = ""
  38. opponentName = nil
  39. b_FoulReason = nil
  40. b_Objective = ""
  41. b_scrTitle = nil
  42. b_scrText = nil
  43. b_BarInfo = nil
  44.  
  45. b_keyf7_pressed = nil
  46.  
  47. b_requests_panel = nil
  48. b_client_panel = nil
  49.  
  50. billiard_mainGUI_tex = surface.GetTextureID("vgui/panel/billiard_gui")
  51. billiard_mainSGUI_tex = surface.GetTextureID("vgui/panel/billiard_sgui")
  52. billiard_mainCRGUI_tex = surface.GetTextureID("vgui/panel/billiard_crgui")
  53. billiard_subGUI_tex = surface.GetTextureID("vgui/panel/billiard_subgui")
  54. billiard_needle_tex = surface.GetTextureID("vgui/panel/needle")
  55. billiard_meter_tex = surface.GetTextureID("vgui/panel/meter")
  56. billiard_ball_tex = {}
  57. for i = 1, 15 do
  58.     billiard_ball_tex[i] = surface.GetTextureID(string.format("vgui/panel/ball%02d", i))
  59. end
  60.  
  61. surface.CreateFont("default", 16, 700, true, false, "HUDPoolText")
  62.  
  63. --[[ concommand.Add("incbzoom", function(ply, cmd, args)
  64.     if(b_FPerson) then b_Zoom = math.Clamp(b_Zoom + 1, 15, 40)
  65.     else b_ShotForce = math.Clamp(b_ShotForce + 5, 1, 400) end
  66. end)
  67.  
  68. concommand.Add("decbzoom", function(ply, cmd, args)
  69.     if(b_FPerson) then b_Zoom = math.Clamp(b_Zoom - 1, 15, 40)
  70.     else b_ShotForce = math.Clamp(b_ShotForce - 5, 1, 400) end
  71. end) ]]
  72.  
  73. hook.Add("Think", "CBilliardThink", function()
  74.  
  75.     if(!b_FPerson and LocalPlayer():KeyDown(IN_ATTACK) and !LocalPlayer():KeyDown(IN_SPEED)) then
  76.         RunConsoleCommand("billiard_strike", b_ShotForce)
  77.     end
  78.     if(input.IsKeyDown(KEY_F7) and !b_keyf7_pressed) then
  79.         b_keyf7_pressed = true
  80.         guiBilliardClientConfig()
  81.     end
  82.    
  83.     // FUCKING AWFUL ALPHA FIX SO FAGGOTS DONT GET IN THE WAY OF THE GOD DAMN FUCKING CAMERA THOSE TWATS xD
  84.     if ( LocalPlayer().IsPlayingBilliards ) then
  85.  
  86.         if ( !LocalPlayer().BilliardsAlphaApplied ) then
  87.  
  88.             for _, ply in pairs( player.GetAll() ) do
  89.                 ply:SetColor( 255, 255, 255, 50 )
  90.             end
  91.             LocalPlayer().BilliardsAlphaApplied = true
  92.         end
  93.        
  94.         --[[ if ( LocalPlayer():KeyDown( IN_JUMP ) ) then
  95.             RunConsoleCommand( "billiard_strike_normal" )
  96.         end ]]
  97.        
  98.     else
  99.  
  100.         if ( LocalPlayer().BilliardsAlphaApplied ) then
  101.             for _, ply in pairs( player.GetAll() ) do
  102.                 ply:SetColor( 255, 255, 255, 255 )
  103.             end
  104.             LocalPlayer().BilliardsAlphaApplied = false
  105.         end
  106.  
  107.     end
  108. end)
  109.  
  110.  
  111. hook.Add("PlayerBindPress", "BilliardsAdjustPower", function( ply, bind, pressed )
  112.  
  113.     if ( bind == "invnext" ) then
  114.         b_ShotForce = math.Clamp( b_ShotForce - 5, 10, 400 )
  115.     elseif ( bind == "invprev" ) then
  116.         b_ShotForce = math.Clamp( b_ShotForce + 5, 10, 400 )
  117.     end
  118.  
  119. end )
  120.  
  121. -- I didn't want to use textures to do this effect, so I made this nice gradient function =P
  122. -- Thanks to all people at FacePunch forums that helped me to optimize it!
  123. local g_grds, g_wgrd, g_sz
  124. function draw.GradientBox(x, y, w, h, al, ...)
  125.     g_grds = {...}
  126.     al = math.Clamp(math.floor(al), 0, 1)
  127.     local n
  128.     if(al == 1) then
  129.         n = w
  130.         w, h = h, n
  131.     end
  132.     g_wgrd = w / (#g_grds - 1)
  133.     for i = 1, w do
  134.         for c = 1, #g_grds do
  135.             n = c
  136.             if(i <= g_wgrd * c) then break end
  137.         end
  138.         g_sz = i - (g_wgrd * (n - 1))
  139.         surface.SetDrawColor(
  140.             Lerp(g_sz/g_wgrd, g_grds[n].r, g_grds[n + 1].r),
  141.             Lerp(g_sz/g_wgrd, g_grds[n].g, g_grds[n + 1].g),
  142.             Lerp(g_sz/g_wgrd, g_grds[n].b, g_grds[n + 1].b),
  143.             Lerp(g_sz/g_wgrd, g_grds[n].a, g_grds[n + 1].a))
  144.         if(al == 1) then surface.DrawRect(x, y + i, h, 1)
  145.         else surface.DrawRect(x + i, y, 1, h) end
  146.     end
  147. end
  148.  
  149. function GetTimeLeft()
  150.     if(!b_RunTime) then return "--:--" end
  151.     local sec = b_BilliardTime - CurTime()
  152.     if(!sec or sec <= 0) then return "00:00" end
  153.     return string.format("%02d:%02d", math.floor(sec / 60), math.fmod(sec, 60))
  154. end
  155.  
  156. function BilliardSpectate(ply, pos, angles, fov)
  157.     local m_ent = ents.GetByIndex(b_SpecEnt)
  158.     local base = ents.GetByIndex(b_SpecBaseEnt)
  159.     if(m_ent and m_ent:IsValid()) then
  160.         local view = {}
  161.         local dist = 30 + b_Zoom
  162.         if(m_ent:GetClass() == "billiard_cue") then
  163.             local fwrd = m_ent:GetForward() * -1
  164.             view.origin = base:GetPos() + Vector(0, 0, 5) + (fwrd * dist * -1)
  165.             view.angles = fwrd:Angle() + Angle(0, -0.07, 0) -- We need an angle offset
  166.         else
  167.             local fwrd = LocalPlayer():GetAimVector()
  168.             view.origin = m_ent:GetPos() + (fwrd * dist * -1)
  169.             view.angles = angles
  170.         end
  171.         view.fov = 30
  172.         return view
  173.     end
  174. end
  175.  
  176. function BilliardInputMouseApply(cmd, x, y, angles)
  177.     if(!b_FPerson and LocalPlayer():KeyDown(IN_SPEED)) then return true
  178.     elseif(b_FPerson and LocalPlayer():KeyDown(IN_ATTACK2)) then return true end
  179.     local s = math.Clamp(b_MouseSensitivity:GetFloat(), 0.5, 10) / 100
  180.     x, y = x * -s, y * s
  181.     if(b_InvMouseX:GetBool()) then x = -x end
  182.     if(b_InvMouseY:GetBool()) then y = -y end
  183.     cmd:SetViewAngles(angles + Angle(y, x, 0))
  184.     return true
  185. end
  186.  
  187. local b_w, b_h, b_px, b_py, b_obj, b_c, b_nm, b_onm
  188. function BilliardHUDPaint()
  189.     b_nm = 128
  190.     surface.SetDrawColor(255, 255, 255, 255)
  191.     -- The main GUI Image
  192.     surface.SetTexture(billiard_mainGUI_tex)
  193.     if(b_GameType == BILLIARD_GAMETYPE_SNOOKER or b_GameType == BILLIARD_GAMETYPE_ROTATION) then
  194.         surface.SetTexture(billiard_mainSGUI_tex)
  195.     elseif(b_GameType == BILLIARD_GAMETYPE_CARAMBOL) then
  196.         surface.SetTexture(billiard_mainCRGUI_tex)
  197.         b_nm = 64
  198.     end
  199.     surface.DrawTexturedRect(ScrW() / 2 - 512, 0, 1024, b_nm)
  200.     -- The pocketed balls
  201.     if(b_GameType == BILLIARD_GAMETYPE_8BALL) then
  202.         if(b_Objective == "OpenTable" and PocketedBalls["OpenBalls"] ~= nil) then
  203.             surface.SetTexture(billiard_subGUI_tex)
  204.             surface.DrawTexturedRect(ScrW() / 2 - 256, 74, 512, 64)
  205.             draw.SimpleText("Open Balls", "HUDPoolText", ScrW() / 2 - 86, 92, white, 1, 1)
  206.             b_c = 0
  207.             for k,v in pairs(PocketedBalls["OpenBalls"]) do
  208.                 if(b_c >= 7) then break end
  209.                 b_c = b_c + 1
  210.                 surface.SetTexture(billiard_ball_tex[v])
  211.                 surface.DrawTexturedRect(ScrW() / 2 - 60 + (22 * k), 75, 32, 32)
  212.             end
  213.         end
  214.     end
  215.     for i,t in pairs(PocketedBalls) do
  216.         if(b_GameType == BILLIARD_GAMETYPE_8BALL and b_Objective == "OpenTable") then break end
  217.         if(!t or type(t) ~= "table") then continue end
  218.         b_c = 0
  219.         for k,v in pairs(t) do
  220.             if(b_c >= 8) then break end
  221.             b_px = ScrW() / 2 + 65 + (22 * k)
  222.             if(i == constObjective or i == "me") then
  223.                 b_px = ScrW() / 2 - 96 - (22 * k)
  224.             end
  225.             b_c = b_c + 1
  226.             surface.SetTexture(billiard_ball_tex[v])
  227.             surface.DrawTexturedRect(b_px, 2, 32, 32)
  228.         end
  229.     end
  230.     -- The infos, such as timeleft, objective, etc
  231.     b_obj = b_Objective
  232.     if(b_GameType == BILLIARD_GAMETYPE_9BALL or b_GameType == BILLIARD_GAMETYPE_ROTATION) then
  233.         tonumber(b_Objective)
  234.         if(b_GameType == BILLIARD_GAMETYPE_9BALL and b_Objective == 9) then b_obj = "9-Ball"
  235.         else b_obj = string.format("Ball: %d", b_Objective) end
  236.     end
  237.     b_px, b_py = ScrW() / 2 - 203, 55
  238.     local onmX, onmY = ScrW() / 2 + 203, 55
  239.     b_nm = LocalPlayer():GetRPName()
  240.     b_onm = opponentName or "N/A"
  241.     if(b_GameType == BILLIARD_GAMETYPE_SNOOKER or b_GameType == BILLIARD_GAMETYPE_ROTATION or
  242.         b_GameType == BILLIARD_GAMETYPE_CARAMBOL) then
  243.         b_px, b_py = ScrW() / 2 - 190, 18
  244.         onmX, onmY = ScrW() / 2 + 190, 18
  245.         if(b_GameType == BILLIARD_GAMETYPE_CARAMBOL) then
  246.             b_px = ScrW() / 2 - 169
  247.             onmX = ScrW() / 2 + 169
  248.         end
  249.         b_nm = string.format("%s :: %d", b_nm, b_CScore or 0)
  250.         b_onm = string.format("%d :: %s", b_OScore or 0, b_onm)
  251.     end
  252.     b_w, b_h = ScrW() / 2, ScrH() / 2
  253.     local tpos = b_w
  254.     if(b_GameType ~= BILLIARD_GAMETYPE_CARAMBOL) then
  255.         tpos = b_w + 42
  256.         draw.SimpleText(b_obj or "", "HUDPoolText", b_w - 42, 18, white, 1, 1)
  257.     end
  258.     draw.SimpleText(GetTimeLeft(), "HUDPoolText", tpos, 18, white, 1, 1)
  259.     draw.SimpleText(b_BarInfo or "", "HUDPoolText", b_w, 55, white, 1, 1)
  260.     draw.SimpleText(b_nm, "HUDPoolText", b_px, b_py, white, 1, 1)
  261.     draw.SimpleText(b_onm, "HUDPoolText", onmX, onmY, white, 1, 1)
  262.     if(b_FoulReason ~= nil) then
  263.         b_py = 75
  264.         if(b_Objective == "OpenTable" and PocketedBalls["OpenBalls"] ~= nil) then b_py = 111 end
  265.         draw.GradientBox(b_w - 160, b_py, 64 , 25, 0, Color(0,0,0,0), Color(0,0,0,160))
  266.         draw.GradientBox(b_w + 96, b_py, 64 , 25, 0, Color(0,0,0,160), Color(0,0,0,0))
  267.         surface.SetDrawColor(0, 0, 0, 160)
  268.         surface.DrawRect(b_w - 95, b_py, 192, 25)
  269.         draw.SimpleText(b_FoulReason, "HUDPoolText", b_w, b_py + 12, white, 1, 1)
  270.     end
  271.     if(!b_FPerson) then
  272.         b_c = (150 / 400) * -b_ShotForce
  273.         surface.SetDrawColor(255,255,255,255)
  274.         surface.SetTexture(billiard_meter_tex)
  275.         surface.DrawTexturedRect(b_w - 128, ScrH() - 183, 256, 128)
  276.         surface.SetTexture(billiard_needle_tex)
  277.         surface.DrawTexturedRectRotated(b_w, ScrH() - 58, 128, 64, math.Clamp(b_c, -150, 0))
  278.     end
  279. end
  280.  
  281. ------------------------------------------------------------
  282. -- USERMESSAGES FUNCTIONS
  283. ------------------------------------------------------------
  284. usermessage.Hook("billiard_toggleHUD", function(um)
  285.     local c_b = um:ReadBool()
  286.     b_GameType = um:ReadShort()
  287.     b_FPerson = um:ReadBool()
  288.     b_BarInfo = nil
  289.     b_FoulReason = nil
  290.     b_CScore = nil
  291.     b_OScore = nil
  292.     PocketedBalls = {}
  293.     PocketedBalls_tmp = {}
  294.     if(c_b) then
  295.         hook.Add("HUDPaint", "CBilliardHUD", BilliardHUDPaint)
  296.         return
  297.     end
  298.     hook.Remove( "HUDPaint", "CBilliardHUD" )
  299.     hook.Remove( "InputMouseApply", "CBilliardMouseLock" )
  300.     opponentName = nil
  301. end)
  302.  
  303. usermessage.Hook("billiard_setObjective", function(um)
  304.     b_Objective = um:ReadString()
  305.     PocketedBalls_tmp["OpenBalls"] = nil
  306.     PocketedBalls["OpenBalls"] = nil
  307.     if(b_Objective ~= "8-Ball" and b_Objective ~= "OpenTable") then
  308.         constObjective = b_Objective
  309.     end
  310. end)
  311.  
  312. usermessage.Hook("billiard_syncTime", function(um)
  313.     b_RunTime = um:ReadBool()
  314.     PocketedBalls = table.Copy(PocketedBalls_tmp)
  315.     if(!b_RunTime) then return end
  316.     b_BilliardTime = CurTime() + um:ReadShort() - (LocalPlayer():Ping() / 1000)
  317. end)
  318.  
  319. usermessage.Hook("billiard_sendSMsg", function(um)
  320.     local title = um:ReadString()
  321.     local fReason = um:ReadString()
  322.     if(!title) then
  323.         b_BarInfo = nil
  324.         b_FoulReason = nil
  325.         return
  326.     end
  327.     if(fReason == "") then fReason = nil end
  328.     b_BarInfo = title
  329.     b_FoulReason = fReason
  330. end)
  331.  
  332. usermessage.Hook("billiard_pocketBall", function(um)
  333.     local nBall = um:ReadShort()
  334.     local uID = um:ReadString()
  335.     if(b_GameType == BILLIARD_GAMETYPE_8BALL) then
  336.         local bType = nil
  337.         if(nBall <= 7) then bType = "Solids" else bType = "Stripes" end
  338.         if(b_Objective == "OpenTable") then
  339.             if(!PocketedBalls_tmp["OpenBalls"]) then
  340.                 PocketedBalls_tmp["OpenBalls"] = {}
  341.             end
  342.             table.insert(PocketedBalls_tmp["OpenBalls"], nBall)
  343.         end
  344.         if(!PocketedBalls_tmp[bType]) then
  345.             PocketedBalls_tmp[bType] = {}
  346.         end
  347.         table.insert(PocketedBalls_tmp[bType], nBall)
  348.     elseif(b_GameType == BILLIARD_GAMETYPE_9BALL) then
  349.         if(LocalPlayer():UniqueID() == uID) then
  350.             if(!PocketedBalls_tmp["me"]) then
  351.                 PocketedBalls_tmp["me"] = {}
  352.             end
  353.             table.insert(PocketedBalls_tmp["me"], nBall)
  354.         else
  355.             if(!PocketedBalls_tmp["opp"]) then
  356.                 PocketedBalls_tmp["opp"] = {}
  357.             end
  358.             table.insert(PocketedBalls_tmp["opp"], nBall)
  359.         end
  360.     end
  361. end)
  362.  
  363. usermessage.Hook("billiard_updateScore", function(um)
  364.     b_CScore = um:ReadShort()
  365.     b_OScore = um:ReadShort()
  366. end)
  367.  
  368. usermessage.Hook("billiard_sendRequest", function(um)
  369.     local plyid = um:ReadString()
  370.     local name = um:ReadString()
  371.     local player = {}
  372.     player.ID = plyid
  373.     player.Name = name --player.GetByUniqueID(plyid):GetName()
  374.     table.insert(RequestedPlayers, player)
  375.     if(type(b_requests_panel) == "Panel") then b_requests_panel:Remove() end
  376.     guiRequestPlayer()
  377. end)
  378.  
  379. usermessage.Hook("billiard_removeRequest", function(um)
  380.     local plyid = um:ReadString()
  381.     for i = 1, table.Count(RequestedPlayers) do
  382.         if(RequestedPlayers[i].ID ~= plyid) then continue end
  383.         RequestedPlayers[i] = nil
  384.     end
  385.     if(type(b_requests_panel) == "Panel") then
  386.         b_requests_panel:Remove()
  387.         if(table.Count(RequestedPlayers) >= 1) then guiRequestPlayer() end
  388.     end
  389. end)
  390.  
  391. usermessage.Hook("billiard_spectate", function(um)
  392.     local c_b = um:ReadBool()
  393.     local c_e = um:ReadShort()
  394.     local c_cb = um:ReadShort() or nil
  395.    
  396.     // to disable legs and do alpha test
  397.     LocalPlayer().IsPlayingBilliards = c_b
  398.     LocalPlayer().ShouldDisableLegs = c_b
  399.    
  400.     if(c_b) then
  401.         b_SpecEnt = c_e
  402.         b_SpecBaseEnt = c_cb
  403.         if(!b_LastAngles) then
  404.             b_LastAngles = LocalPlayer():GetAimVector()
  405.         end
  406.         hook.Add("CalcView", "CBilliardSpectate", BilliardSpectate)
  407.         return
  408.     end
  409.     hook.Remove( "CalcView", "CBilliardSpectate" )
  410.     if b_LastAngles then
  411.         LocalPlayer():SetEyeAngles( b_LastAngles:Angle() )
  412.         b_LastAngles = nil
  413.     end
  414. end)
  415.  
  416. usermessage.Hook("billiard_mouseLock", function(um)
  417.     local c_b = um:ReadBool()
  418.     if(c_b) then
  419.         hook.Add("InputMouseApply", "CBilliardMouseLock", BilliardInputMouseApply)
  420.         return
  421.     end
  422.     hook.Remove( "InputMouseApply", "CBIlliardMouseLock" )
  423. end)
  424.  
  425. usermessage.Hook("billiard_updateInfo", function(um)
  426.     local id = um:ReadString()
  427.     --if(!id or !player.GetByUniqueID(id)) then opponentName = nil return end
  428.     --opponentName = player.GetByUniqueID(id):GetName()
  429.     opponentName = id or nil
  430. end)
  431.  
  432. usermessage.Hook("billiard_resetInfos", function(um)
  433.     PocketedBalls = {}
  434.     PocketedBalls_tmp = {}
  435.     b_CScore = 0
  436.     b_OScore = 0
  437. end)
  438.  
  439. ------------------------------------------------------------
  440. --  BILLIARD TABLE CLIENT CONFIGURATION GUI
  441. ------------------------------------------------------------
  442. function guiBilliardClientConfig()
  443.     if(type(b_client_panel) == "Panel") then b_client_panel:Remove() end
  444.     b_client_panel = vgui.Create("DFrame")
  445.     b_client_panel:SetSize(200, 265)
  446.     b_client_panel:Center()
  447.     b_client_panel:SetTitle("MBilliard Client Configuration")
  448.     b_client_panel:SetVisible(true)
  449.     b_client_panel:SetDraggable(false)
  450.     b_client_panel:ShowCloseButton(false)
  451.     b_client_panel:MakePopup()
  452.    
  453.     ------------------------------------------------------------
  454.     local MSPanel = vgui.Create("DPanel", b_client_panel)
  455.     MSPanel:SetPos(10, 27)
  456.     MSPanel:SetSize(180, 50)
  457.    
  458.     local cfSen = math.Clamp(b_MouseSensitivity:GetFloat(), 0.5, 10)
  459.     local mSen = vgui.Create("DNumSlider", MSPanel)
  460.     mSen:SetText("Mouse Sensitivity")
  461.     mSen:SetPos(5, 5)
  462.     mSen:SetWide(170)
  463.     mSen:SetMin(0.5)
  464.     mSen:SetMax(10)
  465.     mSen:SetDecimals(1)
  466.     mSen:SetValue(math.Clamp(b_MouseSensitivity:GetFloat(), 0.5, 10))
  467.     mSen.ValueChanged = function(panel, val)
  468.         cfSen = val
  469.     end
  470.  
  471.     ------------------------------------------------------------
  472.     local CIHPanel = vgui.Create("DPanel", b_client_panel)
  473.     CIHPanel:SetPos(10, 85)
  474.     CIHPanel:SetSize(180, 25)
  475.    
  476.     local cfCIH = b_InvCueMouseX:GetInt()
  477.     local mCInvH = vgui.Create("DCheckBoxLabel", CIHPanel)
  478.     mCInvH:SetText("Cue Invert Mouse Horizontally")
  479.     mCInvH:SetPos(5, 5)
  480.     mCInvH:SetValue(cfCIH)
  481.     mCInvH:SizeToContents()
  482.     mCInvH.OnChange = function()
  483.         if(mCInvH:GetChecked()) then cfCIH = 1
  484.         else cfCIH = 0 end
  485.     end
  486.    
  487.     ------------------------------------------------------------
  488.     local CIVPanel = vgui.Create("DPanel", b_client_panel)
  489.     CIVPanel:SetPos(10, 115)
  490.     CIVPanel:SetSize(180, 25)
  491.    
  492.     local cfCIV = b_InvCueMouseY:GetInt()
  493.     local mCInvV = vgui.Create("DCheckBoxLabel", CIVPanel)
  494.     mCInvV:SetText("Cue Invert Mouse Vertically")
  495.     mCInvV:SetPos(5, 5)
  496.     mCInvV:SetValue(cfCIV)
  497.     mCInvV:SizeToContents()
  498.     mCInvV.OnChange = function()
  499.         if(mCInvV:GetChecked()) then cfCIV = 1
  500.         else cfCIV = 0 end
  501.     end
  502.    
  503.     ------------------------------------------------------------
  504.     local IHPanel = vgui.Create("DPanel", b_client_panel)
  505.     IHPanel:SetPos(10, 145)
  506.     IHPanel:SetSize(180, 25)
  507.  
  508.     local cfIH = b_InvMouseX:GetInt()
  509.     local mInvH = vgui.Create("DCheckBoxLabel", IHPanel)
  510.     mInvH:SetText("Invert Mouse Horizontally")
  511.     mInvH:SetPos(5, 5)
  512.     mInvH:SetValue(cfIH)
  513.     mInvH:SizeToContents()
  514.     mInvH.OnChange = function()
  515.         if(mInvH:GetChecked()) then cfIH = 1
  516.         else cfIH = 0 end
  517.     end
  518.    
  519.     ------------------------------------------------------------
  520.     local IVPanel = vgui.Create("DPanel", b_client_panel)
  521.     IVPanel:SetPos(10, 175)
  522.     IVPanel:SetSize(180, 25)
  523.    
  524.     local cfIV = b_InvMouseY:GetInt()
  525.     local mInvV = vgui.Create("DCheckBoxLabel", IVPanel)
  526.     mInvV:SetText("Invert Mouse Vertically")
  527.     mInvV:SetPos(5, 5)
  528.     mInvV:SetValue(cfIV)
  529.     mInvV:SizeToContents()
  530.     mInvV.OnChange = function()
  531.         if(mInvV:GetChecked()) then cfIV = 1
  532.         else cfIV = 0 end
  533.     end
  534.    
  535.     ------------------------------------------------------------
  536.     local OKBtn = vgui.Create("DButton", b_client_panel)
  537.     OKBtn:SetPos(10, 205)
  538.     OKBtn:SetSize(180, 25)
  539.     OKBtn:SetText("Save Settings")
  540.     OKBtn.DoClick = function()
  541.         RunConsoleCommand("billiard_cl_mouse_sensitivity", tostring(cfSen))
  542.         RunConsoleCommand("billiard_cl_cue_invmouse_h", tostring(cfCIH))
  543.         RunConsoleCommand("billiard_cl_cue_invmouse_v", tostring(cfCIV))
  544.         RunConsoleCommand("billiard_cl_invmouse_h", tostring(cfIH))
  545.         RunConsoleCommand("billiard_cl_invmouse_v", tostring(cfIV))
  546.         b_keyf7_pressed = nil
  547.         b_client_panel:Remove()
  548.     end
  549.    
  550.     ------------------------------------------------------------
  551.     local CancelBtn = vgui.Create("DButton", b_client_panel)
  552.     CancelBtn:SetPos(10, 235)
  553.     CancelBtn:SetSize(180, 25)
  554.     CancelBtn:SetText("Cancel")
  555.     CancelBtn.DoClick = function()
  556.         b_keyf7_pressed = nil
  557.         b_client_panel:Remove()
  558.     end
  559. end
  560.  
  561. ------------------------------------------------------------
  562. --  BILLIARD TABLE CONFIGURATION GUI
  563. ------------------------------------------------------------
  564. usermessage.Hook("billiard_setConfig", function(um)
  565.     local bid = um:ReadShort()
  566.     local gmtype = um:ReadShort()
  567.     local rdtime = um:ReadShort()
  568.     local abmet = um:ReadShort()
  569.     local skin = um:ReadShort()
  570.     local fpcue = um:ReadBool()
  571.     local trn = um:ReadBool()
  572.     local sc = um:ReadBool()
  573.     local mgp = um:ReadBool()
  574.     local MainFrame = vgui.Create("DFrame")
  575.     MainFrame:SetSize(424, 212)
  576.     MainFrame:Center()
  577.     MainFrame:SetTitle("Billiard Table Options")
  578.     MainFrame:SetVisible(true)
  579.     MainFrame:SetDraggable(false)
  580.     MainFrame:ShowCloseButton(false)
  581.     MainFrame:MakePopup()
  582.    
  583.     local BPanel = vgui.Create("DPanel", MainFrame)
  584.     BPanel:SetPos(148, 30)
  585.     BPanel:SetSize(266, 62)
  586.    
  587.     local BPanelTitle = vgui.Create("DLabel", BPanel)
  588.     BPanelTitle:SetPos(10, 5)
  589.     BPanelTitle:SetText("Advanced Options")
  590.     BPanelTitle:SetFont("TabLarge")
  591.     BPanelTitle:SizeToContents()
  592.    
  593.     local abkMethod = 0
  594.     local abkMultiChoice = vgui.Create("DMultiChoice", BPanel)
  595.     abkMultiChoice:SetPos(140, 33)
  596.     abkMultiChoice:SetSize(116, 20)
  597.     abkMultiChoice:AddChoice("Method 1")
  598.     abkMultiChoice:AddChoice("Method 2")
  599.     abkMultiChoice.OnSelect = function(panel, id, text)
  600.         abkMethod = id
  601.     end
  602.     if(abmet ~= 0) then
  603.         abkMultiChoice:ChooseOptionID(abmet)
  604.     end
  605.    
  606.     local AbModeBox = vgui.Create("DCheckBoxLabel", BPanel)
  607.     AbModeBox:SetPos(10, 35)
  608.     AbModeBox:SetText("Enable Anti BFH")
  609.     AbModeBox:SetTextColor(Color(230, 230, 230))
  610.     if(abmet == 0) then
  611.         AbModeBox:SetValue(0)
  612.     else
  613.         AbModeBox:SetValue(1)
  614.     end
  615.     AbModeBox:SizeToContents()
  616.     AbModeBox.OnChange = function()
  617.         if(AbModeBox:GetChecked()) then
  618.             abkMethod = 1
  619.             abkMultiChoice:SetVisible(true)
  620.             abkMultiChoice:ChooseOptionID(1)
  621.         else
  622.             abkMethod = 0
  623.             abkMultiChoice:SetVisible(false)
  624.         end
  625.     end
  626.    
  627.     -----------------------------------------------------
  628.     -- SKIN BUTTON
  629.     -----------------------------------------------------
  630.     if(skin > 2) then skin = skin - 3 end
  631.     local ImageSkin = vgui.Create("DImageButton", MainFrame)
  632.     ImageSkin:SetPos(10, 30)
  633.     ImageSkin:SetSize(128, 64)
  634.     ImageSkin:SetMaterial("VGUI/panel/skin"..skin)
  635.     ImageSkin.DoClick = function()
  636.         if(skin >= 2) then skin = 0 else skin = skin + 1 end
  637.         ImageSkin:SetMaterial(string.format("VGUI/panel/skin%d", skin))
  638.     end
  639.     ImageSkin.DoRightClick = function()
  640.         if(skin <= 0) then skin = 2 else skin = skin - 1 end
  641.         ImageSkin:SetMaterial(string.format("VGUI/panel/skin%d", skin))
  642.     end
  643.    
  644.     -----------------------------------------------------
  645.     -- GAME TYPE SELECTION BOX
  646.     -----------------------------------------------------
  647.     local gTPanel = vgui.Create("DPanel", MainFrame)
  648.     gTPanel:SetPos(10, 100)
  649.     gTPanel:SetSize(267, 24)
  650.    
  651.     local gTLabel = vgui.Create("DLabel", gTPanel)
  652.     gTLabel:SetPos(5, 4)
  653.     gTLabel:SetText("Game Type")
  654.     gTLabel:SetTextColor(Color(230, 230, 230))
  655.     --gTLabel:SetExpensiveShadow(1, Color(0, 0, 0, 150))
  656.     --gTLabel:SetFont("DefaultBold")
  657.     gTLabel:SizeToContents()
  658.    
  659.     local gtype = 0
  660.     local gTMultiChoice = vgui.Create("DMultiChoice", gTPanel)
  661.     gTMultiChoice:SetPos(140, 2)
  662.     gTMultiChoice:SetSize(120, 20)
  663.     gTMultiChoice:AddChoice("8 Ball")
  664.     gTMultiChoice:AddChoice("9 Ball")
  665.     gTMultiChoice:AddChoice("Snooker")
  666.     gTMultiChoice:AddChoice("Rotation")
  667.     gTMultiChoice:AddChoice("Carambol")
  668.     gTMultiChoice.OnSelect = function(panel, id, text)
  669.         gtype = id - 1
  670.     end
  671.     gTMultiChoice:ChooseOptionID(gmtype + 1)
  672.    
  673.     -----------------------------------------------------
  674.     -- ROUND TIME SELECTION BOX
  675.     -----------------------------------------------------
  676.     local bTPanel = vgui.Create("DPanel", MainFrame)
  677.     bTPanel:SetPos(10, 129)
  678.     bTPanel:SetSize(267, 24)
  679.    
  680.     local bTLabel = vgui.Create("DLabel", bTPanel)
  681.     bTLabel:SetPos(5, 4)
  682.     bTLabel:SetText("Round Time")
  683.     bTLabel:SetTextColor(Color(230, 230, 230))
  684.     --bTLabel:SetExpensiveShadow(1, Color(0, 0, 0, 150))
  685.     --bTLabel:SetFont("DefaultBold")
  686.     bTLabel:SizeToContents()
  687.    
  688.     local rTime = 0
  689.     local bTMultiChoice = vgui.Create("DMultiChoice", bTPanel)
  690.     bTMultiChoice:SetPos(140, 2)
  691.     bTMultiChoice:SetSize(120, 20)
  692.     bTMultiChoice:AddChoice("15 sec")
  693.     bTMultiChoice:AddChoice("30 sec")
  694.     bTMultiChoice:AddChoice("45 sec")
  695.     bTMultiChoice:AddChoice("60 sec")
  696.     bTMultiChoice.OnSelect = function(panel, id, text)
  697.         rTime = id
  698.     end
  699.     bTMultiChoice:ChooseOptionID(rdtime / 15)
  700.  
  701.     -----------------------------------------------------
  702.     -- CUE FIRST PERSON CHECKBOX
  703.     -----------------------------------------------------
  704.     local FpPanel = vgui.Create("DPanel", MainFrame)
  705.     FpPanel:SetPos(10, 158)
  706.     FpPanel:SetSize(131, 20)
  707.    
  708.     local FpBoxCh = "false"
  709.     if(fpcue) then FpBoxCh = "true" end
  710.     local FpModeBox = vgui.Create("DCheckBoxLabel", FpPanel)
  711.     FpModeBox:SetPos(5, 3)
  712.     FpModeBox:SetText("Cue First Person")
  713.     FpModeBox:SetTextColor(Color(230, 230, 230))
  714.     FpModeBox:SetValue(fpcue)
  715.     FpModeBox:SizeToContents()
  716.     FpModeBox.OnChange = function()
  717.         if(FpModeBox:GetChecked()) then
  718.             FpBoxCh = "true"
  719.         else
  720.             FpBoxCh = "false"
  721.         end
  722.     end
  723.    
  724.     -----------------------------------------------------
  725.     -- SMART CUE CHECKBOX
  726.     -----------------------------------------------------
  727.     local ScPanel = vgui.Create("DPanel", MainFrame)
  728.     ScPanel:SetPos(146, 158)
  729.     ScPanel:SetSize(131, 20)
  730.    
  731.     local scBoxCh = "true"
  732.     if(!sc) then scBoxCh = "false" end
  733.     ScModeBox = vgui.Create("DCheckBoxLabel", ScPanel)
  734.     ScModeBox:SetPos(5, 3)
  735.     ScModeBox:SetText("Enable SmartCue")
  736.     ScModeBox:SetTextColor(Color(230, 230, 230))
  737.     ScModeBox:SetValue(sc)
  738.     ScModeBox:SizeToContents()
  739.     ScModeBox.OnChange = function()
  740.         if(ScModeBox:GetChecked()) then
  741.             scBoxCh = "true"
  742.         else
  743.             scBoxCh = "false"
  744.         end
  745.     end
  746.    
  747.     -----------------------------------------------------
  748.     -- TRAINING MODE CHECKBOX
  749.     -----------------------------------------------------
  750.     local TrPanel = vgui.Create("DPanel", MainFrame)
  751.     TrPanel:SetPos(10, 183)
  752.     TrPanel:SetSize(131, 20)
  753.    
  754.     local trBoxCh = "false"
  755.     if(trn) then trBoxCh = "true" end
  756.     local TrModeBox = vgui.Create("DCheckBoxLabel", TrPanel)
  757.     TrModeBox:SetPos(5, 3)
  758.     TrModeBox:SetText("Training mode")
  759.     TrModeBox:SetTextColor(Color(230, 230, 230))
  760.     TrModeBox:SetValue(trn)
  761.     TrModeBox:SizeToContents()
  762.     TrModeBox.OnChange = function()
  763.         if(TrModeBox:GetChecked()) then
  764.             trBoxCh = "true"
  765.         else
  766.             trBoxCh = "false"
  767.         end
  768.     end
  769.    
  770.     -----------------------------------------------------
  771.     -- MINGEBAG PROTECTION CHECKBOX
  772.     -----------------------------------------------------
  773.     local MpPanel = vgui.Create("DPanel", MainFrame)
  774.     MpPanel:SetPos(282, 158)
  775.     MpPanel:SetSize(131, 20)
  776.    
  777.     local MpBoxCh = "true"
  778.     if(!mgp) then MpBoxCh = "false" end
  779.     local MpModeBox = vgui.Create("DCheckBoxLabel", MpPanel)
  780.     MpModeBox:SetPos(5, 3)
  781.     MpModeBox:SetText("MingeBag Protection")
  782.     MpModeBox:SetTextColor(Color(230, 230, 230))
  783.     MpModeBox:SetValue(mgp)
  784.     MpModeBox:SizeToContents()
  785.     MpModeBox.OnChange = function()
  786.         if(MpModeBox:GetChecked()) then
  787.             MpBoxCh = "true"
  788.         else
  789.             MpBoxCh = "false"
  790.         end
  791.     end
  792.    
  793.     local spButton = vgui.Create("DButton", MainFrame)
  794.     spButton:SetPos(282, 100)
  795.     spButton:SetSize(131, 24)
  796.     spButton:SetText("OK")
  797.     spButton.DoClick = function()
  798.         RunConsoleCommand("billiard_config", bid, skin, gtype, rTime, trBoxCh, scBoxCh, abkMethod, MpBoxCh, FpBoxCh)
  799.         MainFrame:Remove()
  800.     end
  801.    
  802.     local CancelBtn = vgui.Create("DButton", MainFrame)
  803.     CancelBtn:SetPos(282, 129)
  804.     CancelBtn:SetSize(131, 24)
  805.     CancelBtn:SetText("Cancel")
  806.     CancelBtn.DoClick = function()
  807.         MainFrame:Remove()
  808.     end
  809. end)
  810.  
  811. ------------------------------------------------------------
  812. --  BILLIARD TABLE REQUESTS LIST GUI
  813. ------------------------------------------------------------
  814. function guiRequestPlayer()
  815.     local width, height = ScrW() / 2, ScrH() / 2
  816.     b_requests_panel = vgui.Create("DFrame")
  817.     b_requests_panel:SetSize(width, height)
  818.     b_requests_panel:Center()
  819.     b_requests_panel:SetTitle("Billiard Requests")
  820.     b_requests_panel:SetVisible(true)
  821.     b_requests_panel:SetDraggable(false)
  822.     b_requests_panel:ShowCloseButton(false)
  823.     b_requests_panel:MakePopup()
  824.    
  825.     local offset = width * 0.05 -- 5% of margin
  826.     local GridList = vgui.Create("DListView", b_requests_panel)
  827.     GridList:SetSize(width * 0.7 - (offset * 3), height - 22 - (offset * 2))
  828.     GridList:SetPos(offset, 22 + offset)
  829.     GridList:AddColumn("Name")
  830.     for i = 1, table.Count(RequestedPlayers) do
  831.         GridList:AddLine(tostring(RequestedPlayers[i].Name))
  832.     end
  833.    
  834.     local BWidth, BHeight = width * 0.3, height * 0.1
  835.     local AccButn = vgui.Create("DButton", b_requests_panel)
  836.     AccButn:SetSize(BWidth, BHeight)
  837.     AccButn:SetPos(width - BWidth - offset, 22 + offset)
  838.     AccButn:SetText("Accept Selected")
  839.     AccButn.Think = function()
  840.         local id = GridList:GetSelectedLine()
  841.         if(GridList ~= nil and id ~= nil) then
  842.             AccButn:SetEnabled(true)
  843.             AccButn.DoClick = function()
  844.                 RunConsoleCommand("billiard_acc_ref", "true", RequestedPlayers[id].ID)
  845.                 RequestedPlayers = {}
  846.                 b_requests_panel:Remove()
  847.             end
  848.         else
  849.             AccButn:SetEnabled(false)
  850.             AccButn.DoClick = function() end
  851.         end
  852.     end
  853.    
  854.     local RefButn = vgui.Create("DButton", b_requests_panel)
  855.     local b_offset = offset * 0.5
  856.     RefButn:SetSize(BWidth, BHeight)
  857.     RefButn:SetPos(width - BWidth - offset, 22 + offset + b_offset + BHeight)
  858.     RefButn:SetText("Refuse Selected")
  859.     RefButn.Think = function()
  860.         local id = GridList:GetSelectedLine()
  861.         if(GridList ~= nil and id ~= nil) then
  862.             RefButn:SetEnabled(true)
  863.             RefButn.DoClick = function()
  864.                 RunConsoleCommand("billiard_acc_ref", "false", RequestedPlayers[id].ID)
  865.                 RequestedPlayers[id] = nil
  866.                 b_requests_panel:Remove()
  867.                 if(table.Count(RequestedPlayers) >= 1) then
  868.                     return guiRequestPlayer()
  869.                 end
  870.             end
  871.         else
  872.             RefButn:SetEnabled(false)
  873.             RefButn.DoClick = function() end
  874.         end
  875.     end
  876.    
  877.     local RandButn = vgui.Create("DButton", b_requests_panel)
  878.     RandButn:SetSize(BWidth, BHeight)
  879.     RandButn:SetPos(width - BWidth - offset, 22 + offset + b_offset * 2 + BHeight * 2)
  880.     RandButn:SetText("Random Accept")
  881.     RandButn.DoClick = function()
  882.         local num = math.Rand(1, table.Count(RequestedPlayers))
  883.         RunConsoleCommand("billiard_acc_ref", "true", RequestedPlayers[num].ID)
  884.         RequestedPlayers = {}
  885.         b_requests_panel:Remove()
  886.     end
  887.    
  888.     local RefAButn = vgui.Create("DButton", b_requests_panel)
  889.     RefAButn:SetSize(BWidth, BHeight)
  890.     RefAButn:SetPos(width - BWidth - offset, 22 + offset + b_offset * 3 + BHeight * 3)
  891.     RefAButn:SetText("Refuse All")
  892.     RefAButn.DoClick = function()
  893.         for i = 1, table.Count(RequestedPlayers) do
  894.             RunConsoleCommand("billiard_acc_ref", "false", RequestedPlayers[i].ID)
  895.         end
  896.         RequestedPlayers = {}
  897.         b_requests_panel:Remove()
  898.     end
  899.    
  900.     local ClButn = vgui.Create("DButton", b_requests_panel)
  901.     ClButn:SetSize(BWidth, BHeight)
  902.     ClButn:SetPos(width - BWidth - offset, 22 + offset + b_offset * 4 + BHeight * 4)
  903.     ClButn:SetText("Close")
  904.     ClButn.DoClick = function()
  905.         b_requests_panel:Remove()
  906.     end
  907. end
  908.  
  909. ------------------------------------------------------------
  910. --  BILLIARD TABLE CREATION GUI
  911. ------------------------------------------------------------
  912. usermessage.Hook("billiard_createMenu", function(um)
  913.     local SpawnPos = um:ReadVector()
  914.     local MainFrame = vgui.Create("DFrame")
  915.     MainFrame:SetSize(424, 242)
  916.     MainFrame:Center()
  917.     MainFrame:SetTitle("Billiard Table Options")
  918.     MainFrame:SetVisible(true)
  919.     MainFrame:SetDraggable(false)
  920.     MainFrame:ShowCloseButton(false)
  921.     MainFrame:MakePopup()
  922.    
  923.     local BPanel = vgui.Create("DPanel", MainFrame)
  924.     BPanel:SetPos(148, 30)
  925.     BPanel:SetSize(266, 62)
  926.    
  927.     local BPanelTitle = vgui.Create("DLabel", BPanel)
  928.     BPanelTitle:SetPos(10, 5)
  929.     BPanelTitle:SetText("Advanced Options")
  930.     BPanelTitle:SetFont("TabLarge")
  931.     BPanelTitle:SizeToContents()
  932.    
  933.     local abkMethod = 0
  934.     local abkMultiChoice = vgui.Create("DMultiChoice", BPanel)
  935.     abkMultiChoice:SetPos(140, 33)
  936.     abkMultiChoice:SetSize(116, 20)
  937.     abkMultiChoice:AddChoice("Method 1")
  938.     abkMultiChoice:AddChoice("Method 2")
  939.     abkMultiChoice.OnSelect = function(panel, id, text)
  940.         abkMethod = id
  941.     end
  942.     abkMultiChoice:ChooseOptionID(2)
  943.    
  944.     local AbModeBox = vgui.Create("DCheckBoxLabel", BPanel)
  945.     AbModeBox:SetPos(10, 35)
  946.     AbModeBox:SetText("Enable Anti BFH")
  947.     AbModeBox:SetTextColor(Color(230, 230, 230))
  948.     AbModeBox:SetValue(1)
  949.     AbModeBox:SizeToContents()
  950.     AbModeBox.OnChange = function()
  951.         if(AbModeBox:GetChecked()) then
  952.             abkMethod = 1
  953.             abkMultiChoice:SetVisible(true)
  954.             abkMultiChoice:ChooseOptionID(1)
  955.         else
  956.             abkMethod = 0
  957.             abkMultiChoice:SetVisible(false)
  958.         end
  959.     end
  960.    
  961.     -----------------------------------------------------
  962.     -- SKIN BUTTON
  963.     -----------------------------------------------------
  964.     local skin = 0
  965.     local ImageSkin = vgui.Create("DImageButton", MainFrame)
  966.     ImageSkin:SetPos(10, 30)
  967.     ImageSkin:SetSize(128, 64)
  968.     ImageSkin:SetMaterial("VGUI/panel/skin0")
  969.     ImageSkin.DoClick = function()
  970.         if(skin >= 2) then skin = 0 else skin = skin + 1 end
  971.         ImageSkin:SetMaterial(string.format("VGUI/panel/skin%d", skin))
  972.     end
  973.     ImageSkin.DoRightClick = function()
  974.         if(skin <= 0) then skin = 2 else skin = skin - 1 end
  975.         ImageSkin:SetMaterial(string.format("VGUI/panel/skin%d", skin))
  976.     end
  977.    
  978.     -----------------------------------------------------
  979.     -- GAME TYPE SELECTION BOX
  980.     -----------------------------------------------------
  981.     local gTPanel = vgui.Create("DPanel", MainFrame)
  982.     gTPanel:SetPos(10, 100)
  983.     gTPanel:SetSize(267, 24)
  984.    
  985.     local gTLabel = vgui.Create("DLabel", gTPanel)
  986.     gTLabel:SetPos(5, 4)
  987.     gTLabel:SetText("Game Type")
  988.     gTLabel:SetTextColor(Color(230, 230, 230))
  989.     --gTLabel:SetExpensiveShadow(1, Color(0, 0, 0, 150))
  990.     --gTLabel:SetFont("DefaultBold")
  991.     gTLabel:SizeToContents()
  992.    
  993.     local gtype = 0
  994.     local gTMultiChoice = vgui.Create("DMultiChoice", gTPanel)
  995.     gTMultiChoice:SetPos(140, 2)
  996.     gTMultiChoice:SetSize(120, 20)
  997.     gTMultiChoice:AddChoice("8 Ball")
  998.     gTMultiChoice:AddChoice("9 Ball")
  999.     gTMultiChoice:AddChoice("Snooker")
  1000.     gTMultiChoice:AddChoice("Rotation")
  1001.     gTMultiChoice:AddChoice("Carambol")
  1002.     gTMultiChoice.OnSelect = function(panel, id, text)
  1003.         gtype = id - 1
  1004.     end
  1005.     gTMultiChoice:ChooseOptionID(1)
  1006.    
  1007.     -----------------------------------------------------
  1008.     -- ROUND TIME SELECTION BOX
  1009.     -----------------------------------------------------
  1010.     local bTPanel = vgui.Create("DPanel", MainFrame)
  1011.     bTPanel:SetPos(10, 129)
  1012.     bTPanel:SetSize(267, 24)
  1013.    
  1014.     local bTLabel = vgui.Create("DLabel", bTPanel)
  1015.     bTLabel:SetPos(5, 4)
  1016.     bTLabel:SetText("Round Time")
  1017.     bTLabel:SetTextColor(Color(230, 230, 230))
  1018.     --bTLabel:SetExpensiveShadow(1, Color(0, 0, 0, 150))
  1019.     --bTLabel:SetFont("DefaultBold")
  1020.     bTLabel:SizeToContents()
  1021.    
  1022.     local rTime = 0
  1023.     local bTMultiChoice = vgui.Create("DMultiChoice", bTPanel)
  1024.     bTMultiChoice:SetPos(140, 2)
  1025.     bTMultiChoice:SetSize(120, 20)
  1026.     bTMultiChoice:AddChoice("15 sec")
  1027.     bTMultiChoice:AddChoice("30 sec")
  1028.     bTMultiChoice:AddChoice("45 sec")
  1029.     bTMultiChoice:AddChoice("60 sec")
  1030.     bTMultiChoice.OnSelect = function(panel, id, text)
  1031.         rTime = id
  1032.     end
  1033.     bTMultiChoice:ChooseOptionID(2)
  1034.    
  1035.     -----------------------------------------------------
  1036.     -- TABLE SIZE SELECTION BOX
  1037.     -----------------------------------------------------
  1038.     local szPanel = vgui.Create("DPanel", MainFrame)
  1039.     szPanel:SetPos(10, 158)
  1040.     szPanel:SetSize(267, 24)
  1041.    
  1042.     local szLabel = vgui.Create("DLabel", szPanel)
  1043.     szLabel:SetPos(5, 4)
  1044.     szLabel:SetText("Table Size")
  1045.     szLabel:SetTextColor(Color(230, 230, 230))
  1046.     --szLabel:SetExpensiveShadow(1, Color(0, 0, 0, 150))
  1047.     --szLabel:SetFont("DefaultBold")
  1048.     szLabel:SizeToContents()
  1049.    
  1050.     local size = 9
  1051.     local szMultiChoice = vgui.Create("DMultiChoice", szPanel)
  1052.     szMultiChoice:SetPos(140, 2)
  1053.     szMultiChoice:SetSize(120, 20)
  1054.     szMultiChoice:AddChoice("9 Feet")
  1055.     szMultiChoice:AddChoice("10 Feet")
  1056.     szMultiChoice:AddChoice("12 Feet")
  1057.     szMultiChoice.OnSelect = function(panel, id, text)
  1058.         local select = {}
  1059.         select[1] = 9
  1060.         select[2] = 10
  1061.         select[3] = 12
  1062.         size = select[id]
  1063.     end
  1064.     szMultiChoice:ChooseOptionID(1)
  1065.  
  1066.     -----------------------------------------------------
  1067.     -- TRAINING MODE CHECKBOX
  1068.     -----------------------------------------------------
  1069.     local TrPanel = vgui.Create("DPanel", MainFrame)
  1070.     TrPanel:SetPos(10, 187)
  1071.     TrPanel:SetSize(131, 20)
  1072.    
  1073.     local trBoxCh = "false"
  1074.     local TrModeBox = vgui.Create("DCheckBoxLabel", TrPanel)
  1075.     TrModeBox:SetPos(5, 3)
  1076.     TrModeBox:SetText("Training mode")
  1077.     TrModeBox:SetTextColor(Color(230, 230, 230))
  1078.     TrModeBox:SetValue(0)
  1079.     TrModeBox:SizeToContents()
  1080.     TrModeBox.OnChange = function()
  1081.         if(TrModeBox:GetChecked()) then
  1082.             trBoxCh = "true"
  1083.         else
  1084.             trBoxCh = "false"
  1085.         end
  1086.     end
  1087.    
  1088.     -----------------------------------------------------
  1089.     -- SMART CUE CHECKBOX
  1090.     -----------------------------------------------------
  1091.     local ScPanel = vgui.Create("DPanel", MainFrame)
  1092.     ScPanel:SetPos(146, 187)
  1093.     ScPanel:SetSize(131, 20)
  1094.    
  1095.     local scBoxCh = "true"
  1096.     ScModeBox = vgui.Create("DCheckBoxLabel", ScPanel)
  1097.     ScModeBox:SetPos(5, 3)
  1098.     ScModeBox:SetText("Enable SmartCue")
  1099.     ScModeBox:SetTextColor(Color(230, 230, 230))
  1100.     ScModeBox:SetValue(1)
  1101.     ScModeBox:SizeToContents()
  1102.     ScModeBox.OnChange = function()
  1103.         if(ScModeBox:GetChecked()) then
  1104.             scBoxCh = "true"
  1105.         else
  1106.             scBoxCh = "false"
  1107.         end
  1108.     end
  1109.    
  1110.     -----------------------------------------------------
  1111.     -- MINGEBAG PROTECTION CHECKBOX
  1112.     -----------------------------------------------------
  1113.     local MpPanel = vgui.Create("DPanel", MainFrame)
  1114.     MpPanel:SetPos(282, 187)
  1115.     MpPanel:SetSize(131, 20)
  1116.    
  1117.     local MpBoxCh = "true"
  1118.     local MpModeBox = vgui.Create("DCheckBoxLabel", MpPanel)
  1119.     MpModeBox:SetPos(5, 3)
  1120.     MpModeBox:SetText("MingeBag Protection")
  1121.     MpModeBox:SetTextColor(Color(230, 230, 230))
  1122.     MpModeBox:SetValue(1)
  1123.     MpModeBox:SizeToContents()
  1124.     MpModeBox.OnChange = function()
  1125.         if(MpModeBox:GetChecked()) then
  1126.             MpBoxCh = "true"
  1127.         else
  1128.             MpBoxCh = "false"
  1129.         end
  1130.     end
  1131.    
  1132.     -----------------------------------------------------
  1133.     -- CUE FIRST PERSON CHECKBOX
  1134.     -----------------------------------------------------
  1135.     local FpPanel = vgui.Create("DPanel", MainFrame)
  1136.     FpPanel:SetPos(10, 212)
  1137.     FpPanel:SetSize(131, 20)
  1138.    
  1139.     local FpBoxCh = "true"
  1140.     local FpModeBox = vgui.Create("DCheckBoxLabel", FpPanel)
  1141.     FpModeBox:SetPos(5, 3)
  1142.     FpModeBox:SetText("Cue First Person")
  1143.     FpModeBox:SetTextColor(Color(230, 230, 230))
  1144.     FpModeBox:SetValue(1)
  1145.     FpModeBox:SizeToContents()
  1146.     FpModeBox.OnChange = function()
  1147.         if(FpModeBox:GetChecked()) then
  1148.             FpBoxCh = "true"
  1149.         else
  1150.             FpBoxCh = "false"
  1151.         end
  1152.     end
  1153.    
  1154.     local dfButton = vgui.Create("DButton", MainFrame)
  1155.     dfButton:SetPos(282, 100)
  1156.     dfButton:SetSize(131, 24)
  1157.     dfButton:SetText("Default")
  1158.     dfButton.DoClick = function()
  1159.         AbModeBox:SetValue(1)
  1160.         abkMultiChoice:ChooseOptionID(2)
  1161.         ScModeBox:SetValue(1)
  1162.         TrModeBox:SetValue(0)
  1163.         MpModeBox:SetValue(1)
  1164.         FpModeBox:SetValue(1)
  1165.     end
  1166.    
  1167.     local spButton = vgui.Create("DButton", MainFrame)
  1168.     spButton:SetPos(282, 129)
  1169.     spButton:SetSize(131, 24)
  1170.     spButton:SetText("Create")
  1171.     spButton.DoClick = function()
  1172.         RunConsoleCommand("billiard_create", SpawnPos[1], SpawnPos[2], SpawnPos[3], size, skin, gtype, rTime, trBoxCh, scBoxCh, abkMethod, MpBoxCh, FpBoxCh)
  1173.         MainFrame:Remove()
  1174.     end
  1175.    
  1176.     local CancelBtn = vgui.Create("DButton", MainFrame)
  1177.     CancelBtn:SetPos(282, 158)
  1178.     CancelBtn:SetSize(131, 24)
  1179.     CancelBtn:SetText("Cancel")
  1180.     CancelBtn.DoClick = function()
  1181.         MainFrame:Remove()
  1182.     end
  1183. end)
  1184.  
  1185. ------------------------------------------------------------
  1186. --  BILLIARD TABLE EXIT QUESTION GUI
  1187. ------------------------------------------------------------
  1188. usermessage.Hook("billiard_promptExit", function(um)
  1189.     local width, height = ScrW() / 3, ScrH() / 4 -- 260, 150
  1190.     local MainFrame = vgui.Create("DFrame")
  1191.     MainFrame:SetSize(width, height)
  1192.     MainFrame:Center()
  1193.     MainFrame:SetTitle("Are you sure?")
  1194.     MainFrame:SetVisible(true)
  1195.     MainFrame:SetDraggable(false)
  1196.     MainFrame:ShowCloseButton(false)
  1197.     MainFrame:MakePopup()
  1198.     MainFrame:DoModal()
  1199.    
  1200.     local Woffset, Hoffset = width * 0.1, height * 0.1
  1201.     local Label = vgui.Create("DLabel", MainFrame)
  1202.     Label:SetSize(width - Woffset, height / 2)
  1203.     Label:SetPos(Woffset / 2, 22 + Hoffset / 2)
  1204.     Label:SetWrap(true)
  1205.     Label:SetText("Are you sure do you want to exit? You will lose the game.")
  1206.     Label:SetContentAlignment(7)
  1207.    
  1208.     local BWidth, BHeight = width / 2, height / 4
  1209.     BWidth = BWidth - Woffset * 1.5
  1210.     BHeight = BHeight - Hoffset
  1211.     local ExitButn = vgui.Create("DButton", MainFrame)
  1212.     ExitButn:SetSize(BWidth, BHeight)
  1213.     ExitButn:SetPos(Woffset, height - BHeight - Hoffset)
  1214.     ExitButn:SetText("Exit")
  1215.     ExitButn.DoClick = function()
  1216.         RunConsoleCommand("billiard_quit")
  1217.         MainFrame:Remove()
  1218.     end
  1219.    
  1220.     local CButn = vgui.Create("DButton", MainFrame)
  1221.     CButn:SetSize(BWidth, BHeight)
  1222.     CButn:SetPos(width - BWidth - Woffset, height - BHeight - Hoffset)
  1223.     CButn:SetText("Cancel")
  1224.     CButn.DoClick = function()
  1225.         MainFrame:Remove()
  1226.     end
  1227. end)
Advertisement
Add Comment
Please, Sign In to add comment