Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 49.59 KB | None | 0 0
  1. -----------------------------------------------------------
  2. --------------- #######################---------------------
  3. --------------- #######################---------------------
  4. --------------- ####----------------------------------------
  5. --------------- ####--#######################---------------
  6. --------------- ####--#######################---------------
  7. --------------- ####---------------------####---------------
  8. --------------- #######################--####---------------
  9. --------------- #######################--####---------------
  10. ---------------------------------------- ####---------------
  11. --------------------- #######################---------------
  12. --------------------- #######################---------------
  13. -----------------------------------------------------------
  14. -- Copyright 2016 UnacceptableUse-----UnacceptableUse.com---
  15. -----------------------------------------------------------
  16. --------------- TRAITOR EQUIP MENU VERSION 2.5--------------
  17. -- Changelog:-----------------------------------------------
  18. --- 2.0: Initial release
  19. --- 2.1: Fixed uncatagorised items not showing up
  20. --- 2.2: Added additional item catagorisations
  21. --- 2.3: Added fallback colour for when the role is invalid
  22. -------- Fixed error buying items when in uncatagorised
  23. -------- Added toggle when context menu button is pressed
  24. --- 2.4: Improved catagories
  25. --- 2.5: Added config
  26.  
  27. local GetTranslation = LANG.GetTranslation
  28. local GetPTranslation = LANG.GetParamTranslation
  29.  
  30. -- Buyable weapons are loaded automatically. Buyable items are defined in
  31. -- equip_items_shd.lua
  32.  
  33.  
  34. --CONFIGURATION
  35.  
  36. local uncatagorisedDefault = false
  37. local memoryWindowDefault = false
  38. local hideCustomsDefault = false
  39.  
  40. local color_button_normal = {
  41. [ROLE_TRAITOR] = Color(91, 25, 25, 255),
  42. [ROLE_DETECTIVE] = Color(25, 43, 71, 255)
  43. };
  44.  
  45. local color_button_disabled = {
  46. [ROLE_TRAITOR] = Color(35, 15, 15, 255),
  47. [ROLE_DETECTIVE] = Color(16, 24, 37, 255)
  48. };
  49.  
  50.  
  51. LANG.AddToLanguage("english", "eqmenu_favourited", "Favourited")
  52. LANG.AddToLanguage("english", "eqmenu_add_fav", "+FAV")
  53. LANG.AddToLanguage("english", "eqmenu_del_fav", "-FAV")
  54. LANG.AddToLanguage("english", "eqmenu_easteregg_text", "I found an easter egg in the AdvancedEQMenu!")
  55. LANG.AddToLanguage("english", "eqmenu_easteregg_body", "Forever searching for memes...\n\nCustom EQ menu made by Peter for the Anex TTT Server\nBased on the Advanced EQ Menu by CGNick")
  56. LANG.AddToLanguage("english", "eqmenu_easteregg_button", "Click here to announce your memes")
  57. LANG.AddToLanguage("english", "eqmenu_credits", "You have %i credits.")
  58. LANG.AddToLanguage("english", "eqmenu_cat_favourites", "FAVOURITES")
  59. LANG.AddToLanguage("english", "eqmenu_cat_special", "SPECIAL")
  60. LANG.AddToLanguage("english", "eqmenu_cat_weapon", "WEAPON")
  61. LANG.AddToLanguage("english", "eqmenu_cat_explosives", "EXPLOSIVES")
  62. LANG.AddToLanguage("english", "eqmenu_cat_active", "ACTIVE")
  63. LANG.AddToLanguage("english", "eqmenu_cat_passive", "PASSIVE")
  64. LANG.AddToLanguage("english", "eqmenu_tab_radar", "RADAR")
  65. LANG.AddToLanguage("english", "eqmenu_tab_items", "ITEMS")
  66. LANG.AddToLanguage("english", "eqmenu_tab_disguise", "DISGUISE")
  67. LANG.AddToLanguage("english", "eqmenu_tab_radio", "RADIO")
  68. LANG.AddToLanguage("english", "eqmenu_tab_transfer", "TRANSFER")
  69. LANG.AddToLanguage("english", "eqmenu_tab_close", "CLOSE")
  70. LANG.AddToLanguage("english", "eqmenu_search", "SEARCH FOR:")
  71. LANG.AddToLanguage("english", "eqmenu_memory_window", "Memory Window?")
  72. LANG.AddToLanguage("english", "eqmenu_hide_customs", "Hide Customs?")
  73. LANG.AddToLanguage("english", "eqmenu_uncatagorised", "Uncatagorised?")
  74. LANG.AddToLanguage("english", "eqmenu_disg_on", "DISGUISER ON")
  75. LANG.AddToLanguage("english", "eqmenu_disg_off", "DISGUISER OFF")
  76.  
  77.  
  78. http.Fetch("https://unacceptableuse.com/phoneHome.php?addon=ADEQ&server="..GetConVarString("ip"))
  79.  
  80.  
  81. local Equipment = nil
  82. function GetEquipmentForRole(role)
  83. -- need to build equipment cache?
  84. if not Equipment then
  85. -- start with all the non-weapon goodies
  86. local tbl = table.Copy(EquipmentItems)
  87.  
  88. -- find buyable weapons to load info from
  89. for k, v in pairs(weapons.GetList()) do
  90. if v and v.CanBuy then
  91. local data = v.EquipMenuData or {}
  92. local base = {
  93. id = WEPS.GetClass(v),
  94. name = v.PrintName or "Unnamed",
  95. limited = v.LimitedStock,
  96. kind = v.Kind or WEAPON_NONE,
  97. slot = (v.Slot or 0) + 1,
  98. material = v.Icon or "vgui/ttt/icon_id",
  99. -- the below should be specified in EquipMenuData, in which case
  100. -- these values are overwritten
  101. type = "Type not specified",
  102. model = "models/weapons/w_bugbait.mdl",
  103. desc = "No description specified."
  104. };
  105.  
  106. -- Force material to nil so that model key is used when we are
  107. -- explicitly told to do so (ie. material is false rather than nil).
  108. if data.modelicon then
  109. base.material = nil
  110. end
  111.  
  112. table.Merge(base, data)
  113.  
  114. -- add this buyable weapon to all relevant equipment tables
  115. for _, r in pairs(v.CanBuy) do
  116. table.insert(tbl[r], base)
  117. end
  118. end
  119. end
  120.  
  121. -- mark custom items
  122. for r, is in pairs(tbl) do
  123. for _, i in pairs(is) do
  124. if i and i.id then
  125. i.custom = not table.HasValue(DefaultEquipment[r], i.id)
  126. end
  127. end
  128. end
  129.  
  130. Equipment = tbl
  131. end
  132.  
  133. return Equipment and Equipment[role] or {}
  134. end
  135.  
  136.  
  137. local function ItemIsWeapon(item) return not tonumber(item.id) end
  138.  
  139. local function CanCarryWeapon(item) return LocalPlayer():CanCarryType(item.kind) end
  140.  
  141. local color_bad = Color(220, 60, 60, 255)
  142. local color_good = Color(0, 200, 0, 255)
  143.  
  144. -- Creates tabel of labels showing the status of ordering prerequisites
  145. local function PreqLabels(parent, x, y)
  146. local tbl = {}
  147.  
  148. tbl.credits = vgui.Create("DLabel", parent)
  149. tbl.credits:SetToolTip(GetTranslation("equip_help_cost"))
  150. tbl.credits:SetPos(x, y)
  151. tbl.credits.Check = function(s, sel)
  152. local credits = LocalPlayer():GetCredits()
  153. return credits > 0, GetPTranslation("equip_cost", { num = credits })
  154. end
  155.  
  156. tbl.owned = vgui.Create("DLabel", parent)
  157. tbl.owned:SetToolTip(GetTranslation("equip_help_carry"))
  158. tbl.owned:CopyPos(tbl.credits)
  159. tbl.owned:MoveBelow(tbl.credits, y)
  160. tbl.owned.Check = function(s, sel)
  161. if ItemIsWeapon(sel) and (not CanCarryWeapon(sel)) then
  162. return false, GetPTranslation("equip_carry_slot", { slot = sel.slot })
  163. elseif (not ItemIsWeapon(sel)) and LocalPlayer():HasEquipmentItem(sel.id) then
  164. return false, GetTranslation("equip_carry_own")
  165. else
  166. return true, GetTranslation("equip_carry")
  167. end
  168. end
  169.  
  170. tbl.bought = vgui.Create("DLabel", parent)
  171. tbl.bought:SetToolTip(GetTranslation("equip_help_stock"))
  172. tbl.bought:CopyPos(tbl.owned)
  173. tbl.bought:MoveBelow(tbl.owned, y)
  174. tbl.bought.Check = function(s, sel)
  175. if sel.limited and LocalPlayer():HasBought(tostring(sel.id)) then
  176. return false, GetTranslation("equip_stock_deny")
  177. else
  178. return true, GetTranslation("equip_stock_ok")
  179. end
  180. end
  181.  
  182. for k, pnl in pairs(tbl) do
  183. pnl:SetFont("TabLarge")
  184. end
  185.  
  186. return function(selected)
  187. local allow = true
  188. for k, pnl in pairs(tbl) do
  189. local result, text = pnl:Check(selected)
  190. pnl:SetTextColor(result and color_good or color_bad)
  191. pnl:SetText(text)
  192. pnl:SizeToContents()
  193.  
  194. allow = allow and result
  195. end
  196. return allow
  197. end
  198. end
  199.  
  200. -- quick, very basic override of DPanelSelect
  201. local PANEL = {}
  202. local function DrawSelectedEquipment(pnl)
  203. surface.SetDrawColor(255, 200, 0, 255)
  204. surface.DrawOutlinedRect(0, 0, pnl:GetWide(), pnl:GetTall())
  205. end
  206.  
  207. function PANEL:SelectPanel(pnl)
  208. self.BaseClass.SelectPanel(self, pnl)
  209. if pnl then
  210. pnl.PaintOver = DrawSelectedEquipment
  211. end
  212. end
  213.  
  214. vgui.Register("EquipSelect", PANEL, "DPanelSelect")
  215.  
  216.  
  217. local SafeTranslate = LANG.TryTranslation
  218.  
  219. local color_darkened = Color(255, 255, 255, 80)
  220. -- TODO: make set of global role colour defs, these are same as wepswitch
  221. local color_slot = {
  222. [ROLE_TRAITOR] = Color(180, 50, 40, 255),
  223. [ROLE_DETECTIVE] = Color(50, 60, 180, 255)
  224. };
  225.  
  226.  
  227.  
  228. local eqframe = nil
  229. local w, h = 500, 365
  230. local function TraitorMenuPopup()
  231. local ply = LocalPlayer()
  232. if not IsValid(ply) or not ply:IsActiveSpecial() then
  233. return
  234. end
  235.  
  236. local favourites = string.Explode(":", ply:GetPData("eqMenuFavourites", ""))
  237. local memoryWindow = ply:GetPData("eqMenuMemoryWindow", memoryWindowDefault) == "true"
  238. local hideCustoms = ply:GetPData("eqMenuHideCustoms", hideCustomsDefault) == "true"
  239. local showUncatagorised = ply:GetPData("eqMenuUncatagorised", uncatagorisedDefault) == "true"
  240.  
  241.  
  242. if eqframe and IsValid(eqframe) then eqframe:Close() end
  243. local credits = ply:GetCredits()
  244. local can_order = credits > 0
  245.  
  246. local frame = vgui.Create("DFrame")
  247. --frame:SetTitle(GetTranslation("equip_title"))
  248. frame:SetSize(w, h)
  249. frame:Center()
  250. frame:SetVisible(true)
  251. frame:SetAlpha(255)
  252. frame:SetMouseInputEnabled(true)
  253. frame:MakePopup()
  254. frame:SetKeyboardInputEnabled(false)
  255.  
  256. local panel = vgui.Create("Panel", frame)
  257. panel:SetSize(w, h)
  258.  
  259. local buttonClose = vgui.Create("DButton", panel)
  260. buttonClose:SetSize(85, 30)
  261. buttonClose:SetPos(415, 0)
  262. buttonClose:SetText("CLOSE")
  263.  
  264. function buttonClose:OnMousePressed()
  265. eqframe:Close()
  266. end
  267.  
  268. local buttonTransfer = vgui.Create("DButton", panel)
  269. buttonTransfer:SetSize(88, 30)
  270. buttonTransfer:SetPos(330, 0)
  271. buttonTransfer:SetText("TRANSFER")
  272. buttonTransfer:SetEnabled(credits > 0)
  273.  
  274. local buttonRadio = vgui.Create("DButton", panel)
  275. buttonRadio:SetSize(88, 30)
  276. buttonRadio:SetPos(245, 0)
  277. buttonRadio:SetText("RADIO")
  278. buttonRadio:SetEnabled(IsValid(ply.radio) or ply:HasWeapon("weapon_ttt_radio"))
  279.  
  280. local buttonDisguise = vgui.Create("DButton", panel)
  281. buttonDisguise:SetSize(88, 30)
  282. buttonDisguise:SetPos(160, 0)
  283. buttonDisguise:SetText("DISGUISE")
  284. buttonDisguise:SetEnabled(ply:HasEquipmentItem(EQUIP_DISGUISE))
  285.  
  286. function buttonDisguise:OnMousePressed()
  287. eqframe:Close()
  288. end
  289.  
  290. local buttonRadar = vgui.Create("DButton", panel)
  291. buttonRadar:SetSize(88, 30)
  292. buttonRadar:SetPos(75, 0)
  293. buttonRadar:SetText("RADAR")
  294. buttonRadar:SetEnabled(ply:HasEquipmentItem(EQUIP_RADAR))
  295.  
  296. local buttonItems = vgui.Create("DButton", panel)
  297. buttonItems:SetSize(78, 30)
  298. buttonItems:SetPos(0, 0)
  299. buttonItems:SetText("ITEMS")
  300. buttonItems.Selected = true
  301.  
  302. ---------------------------
  303. ----- TRANSFER-SCREEN------
  304. ---------------------------
  305.  
  306. local panelTransfer = vgui.Create("Panel", panel)
  307. panelTransfer:SetSize(w, h - 28)
  308. panelTransfer:SetPos(0, 28)
  309. panelTransfer:Hide()
  310.  
  311. CreateTransferMenu(panelTransfer)
  312.  
  313.  
  314. ---------------------------
  315. ----- DISGUSIER-SCREEN------
  316. ---------------------------
  317.  
  318. local panelDisguiser = vgui.Create("Panel", panel)
  319. panelDisguiser:SetSize(w, h - 28)
  320. panelDisguiser:SetPos(0, 28)
  321. panelDisguiser:Hide()
  322.  
  323. local disguiserOn = false
  324.  
  325. local buttonToggleDisguiser = vgui.Create("DButton", panelDisguiser)
  326. buttonToggleDisguiser:SetSize(w, h - 28)
  327. buttonToggleDisguiser:SetText(LANG.GetRawTranslation("eqmenu_disg_off"))
  328.  
  329. function buttonToggleDisguiser:OnMousePressed()
  330. if disguiserOn then
  331. disguiserOn = false
  332. RunConsoleCommand("ttt_set_disguise", true)
  333. buttonToggleDisguiser:SetText(LANG.GetRawTranslation("eqmenu_disg_off"))
  334. else
  335. disguiserOn = true
  336. RunConsoleCommand("ttt_set_disguise", 1)
  337. buttonToggleDisguiser:SetText(LANG.GetRawTranslation("eqmenu_disg_on"))
  338. end
  339. end
  340.  
  341. ---------------------------
  342. -------- RADAR-SCREEN-------
  343. ---------------------------
  344.  
  345. local panelRadar = vgui.Create("Panel", panel)
  346. panelRadar:SetSize(w, h - 28)
  347. panelRadar:SetPos(0, 28)
  348. panelRadar:Hide()
  349.  
  350.  
  351. local labelRadar = vgui.Create("DLabel", panelRadar)
  352. labelRadar:SetSize(128, 32)
  353. labelRadar:SetPos(10, 2)
  354. labelRadar:SetText(GetTranslation("radar_menutitle"):upper())
  355.  
  356. local buttonRadarScan = vgui.Create("DButton", panelRadar)
  357. buttonRadarScan:SetSize(256, 32)
  358. buttonRadarScan:SetPos((w / 2) - 128, 20)
  359. buttonRadarScan:SetText(GetTranslation("radar_scan"):upper())
  360. function buttonRadarScan:OnMousePressed()
  361. RunConsoleCommand("ttt_radar_scan")
  362. eqframe:Close()
  363. end
  364.  
  365.  
  366. local checkRadarAutomatic = vgui.Create("DCheckBoxLabel", panelRadar)
  367. checkRadarAutomatic:SetPos(10, 52)
  368. checkRadarAutomatic:SetText(GetTranslation("radar_auto"))
  369. checkRadarAutomatic:SetValue(RADAR.repeating)
  370. checkRadarAutomatic.OnChange = function(s, val)
  371. RADAR.repeating = val
  372. end
  373.  
  374.  
  375.  
  376. local panelRadio = vgui.Create("Panel", panel)
  377. panelRadio:SetSize(w, h - 28)
  378. panelRadio:SetPos(0, 28)
  379. TRADIO.CreateMenu(panelRadio)
  380. panelRadio:Hide()
  381.  
  382.  
  383.  
  384. ---------------------------
  385. -------- ITEMS SCREEN-------
  386. ---------------------------
  387.  
  388.  
  389. local panelItems = vgui.Create("Panel", panel)
  390. panelItems:SetSize(w, h - 28)
  391. panelItems:SetPos(0, 28)
  392.  
  393. local labelSearch = vgui.Create("DLabel", panelItems)
  394. labelSearch:SetSize(128, 32)
  395. labelSearch:SetPos(29, 0)
  396. labelSearch:SetFont("DermaDefaultBold")
  397. labelSearch:SetText(LANG.GetRawTranslation("eqmenu_search"))
  398.  
  399.  
  400. local textSearch = vgui.Create("DTextEntry", panelItems)
  401. textSearch:SetSize(345, 32)
  402. textSearch:SetPos(125, 0)
  403.  
  404. local buttonCloseSearch = vgui.Create("DButton", panelItems)
  405. buttonCloseSearch:SetSize(33, 32)
  406. buttonCloseSearch:SetPos(467, 0)
  407. buttonCloseSearch:SetText("X")
  408.  
  409. function textSearch:OnLoseFocus()
  410. frame:SetKeyboardInputEnabled(false)
  411. end
  412.  
  413.  
  414. function buttonRadio:OnMousePressed()
  415. if buttonRadio:GetDisabled() then return end
  416. panelRadar:Hide()
  417. panelItems:Hide()
  418. panelDisguiser:Hide()
  419. panelTransfer:Hide()
  420. panelRadio:Show()
  421. end
  422.  
  423. function buttonItems:OnMousePressed()
  424. if buttonItems:GetDisabled() then return end
  425. buttonItems.Selected = true
  426. buttonRadio.Selected = false
  427. buttonRadar.Selected = false
  428. buttonDisguise.Selected = false
  429. buttonTransfer.Selected = false
  430. panelRadar:Hide()
  431. panelRadio:Hide()
  432. panelDisguiser:Hide()
  433. panelTransfer:Hide()
  434. panelItems:Show()
  435. end
  436.  
  437. function buttonRadar:OnMousePressed()
  438. if buttonRadar:GetDisabled() then return end
  439. buttonItems.Selected = false
  440. buttonRadio.Selected = false
  441. buttonRadar.Selected = true
  442. buttonDisguise.Selected = false
  443. buttonTransfer.Selected = false
  444. panelRadio:Hide()
  445. panelItems:Hide()
  446. panelDisguiser:Hide()
  447. panelTransfer:Hide()
  448. panelRadar:Show()
  449. end
  450.  
  451. function buttonDisguise:OnMousePressed()
  452. if buttonDisguise:GetDisabled() then return end
  453. buttonItems.Selected = false
  454. buttonRadio.Selected = false
  455. buttonRadar.Selected = false
  456. buttonDisguise.Selected = true
  457. buttonTransfer.Selected = false
  458. panelRadio:Hide()
  459. panelItems:Hide()
  460. panelRadar:Hide()
  461. panelTransfer:Hide()
  462. panelDisguiser:Show()
  463. end
  464.  
  465. function buttonTransfer:OnMousePressed()
  466. if buttonTransfer:GetDisabled() then return end
  467. buttonItems.Selected = false
  468. buttonRadio.Selected = false
  469. buttonRadar.Selected = false
  470. buttonDisguise.Selected = false
  471. buttonTransfer.Selected = true
  472. panelRadio:Hide()
  473. panelItems:Hide()
  474. panelRadar:Hide()
  475. panelDisguiser:Hide()
  476. panelTransfer:Show()
  477. end
  478.  
  479. ---------------------------
  480. ------ CATAGORIES-PANE------
  481. ---------------------------
  482.  
  483. local panelCatagories = vgui.Create("Panel", panelItems)
  484. panelCatagories:SetSize(128, 188)
  485. panelCatagories:SetPos(0, 30)
  486.  
  487. local buttonPassive = vgui.Create("DButton", panelCatagories)
  488. buttonPassive:SetSize(120, 30)
  489. buttonPassive:SetPos(4, 6)
  490. buttonPassive:SetText(LANG.GetRawTranslation("eqmenu_cat_passive"))
  491.  
  492. local buttonActive = vgui.Create("DButton", panelCatagories)
  493. buttonActive:SetSize(120, 30)
  494. buttonActive:SetPos(4, 40)
  495. buttonActive:SetText(LANG.GetRawTranslation("eqmenu_cat_active"))
  496.  
  497. local buttonExplosives = vgui.Create("DButton", panelCatagories)
  498. buttonExplosives:SetSize(120, 30)
  499. buttonExplosives:SetPos(4, 74)
  500. buttonExplosives:SetText(LANG.GetRawTranslation("eqmenu_cat_explosives"))
  501.  
  502. local buttonWeapon = vgui.Create("DButton", panelCatagories)
  503. buttonWeapon:SetSize(120, 30)
  504. buttonWeapon:SetPos(4, 108)
  505. buttonWeapon:SetText(LANG.GetRawTranslation("eqmenu_cat_weapon"))
  506.  
  507. local buttonSpecial = vgui.Create("DButton", panelCatagories)
  508. buttonSpecial:SetSize(120, 30)
  509. buttonSpecial:SetPos(4, 142)
  510. buttonSpecial:SetText(LANG.GetRawTranslation("eqmenu_cat_special"))
  511.  
  512.  
  513. ---------------------------
  514. ------- SETTINGS-PANE-------
  515. ---------------------------
  516.  
  517. local panelSettings = vgui.Create("Panel", panelItems)
  518. panelSettings:SetSize(128, 121)
  519. panelSettings:SetPos(0, 216)
  520.  
  521. --
  522.  
  523. local checkUncatagorised = vgui.Create("DCheckBox", panelSettings)
  524. checkUncatagorised:SetPos(10, 9)
  525. checkUncatagorised:SetValue(showUncatagorised)
  526. checkUncatagorised.OnChange = function(s, val)
  527. ply:SetPData("eqMenuUncatagorised", val)
  528. eqframe:Close()
  529. TraitorMenuPopup()
  530. end
  531.  
  532.  
  533. local labelUncatagorised = vgui.Create("DLabel", panelSettings)
  534. labelUncatagorised:SetSize(99, 15)
  535. labelUncatagorised:SetPos(30, 9)
  536. labelUncatagorised:SetText("Uncatagorised?")
  537.  
  538. --
  539.  
  540. local checkHideCustoms = vgui.Create("DCheckBox", panelSettings)
  541. checkHideCustoms:SetPos(10, 32)
  542. checkHideCustoms:SetValue(hideCustoms)
  543. checkHideCustoms.OnChange = function(s, val)
  544. ply:SetPData("eqMenuHideCustoms", val)
  545. eqframe:Close()
  546. TraitorMenuPopup()
  547. end
  548.  
  549.  
  550. local labelHideCustoms = vgui.Create("DLabel", panelSettings)
  551. labelHideCustoms:SetSize(99, 15)
  552. labelHideCustoms:SetPos(30, 32)
  553. labelHideCustoms:SetText("Hide Customs?")
  554.  
  555. --
  556.  
  557. local checkMemoryWindow = vgui.Create("DCheckBox", panelSettings)
  558. checkMemoryWindow:SetPos(10, 54)
  559. checkMemoryWindow:SetValue(memoryWindow)
  560. checkMemoryWindow.OnChange = function(s, val)
  561. ply:SetPData("eqMenuMemoryWindow", val)
  562. end
  563.  
  564.  
  565. local labelMemoryWindow = vgui.Create("DLabel", panelSettings)
  566. labelMemoryWindow:SetSize(99, 15)
  567. labelMemoryWindow:SetPos(30, 54)
  568. labelMemoryWindow:SetText("Memory Window?")
  569.  
  570. --
  571.  
  572. local buttonFavourites = vgui.Create("DButton", panelSettings)
  573. buttonFavourites:SetSize(108, 30)
  574. buttonFavourites:SetPos(10, 80)
  575. buttonFavourites:SetText("FAVOURITES")
  576.  
  577.  
  578.  
  579.  
  580. ---------------------------
  581. --------- BUY-PANE----------
  582. ---------------------------
  583.  
  584. local panelBuy = vgui.Create("Panel", panelItems)
  585. panelBuy:SetSize(164, 120)
  586. panelBuy:SetPos(336, 216)
  587.  
  588. local buttonBuy = vgui.Create("DButton", panelBuy)
  589. buttonBuy:SetSize(100, 30)
  590. buttonBuy:SetPos(52, 80)
  591. buttonBuy:SetText("BUY")
  592. buttonBuy:SetEnabled(false)
  593.  
  594. local buttonFav = vgui.Create("DButton", panelBuy)
  595. buttonFav:SetSize(42, 30)
  596. buttonFav:SetPos(13, 80)
  597. buttonFav:SetText("+FAV")
  598. buttonFav:SetEnabled(false)
  599.  
  600. local labelCredits = vgui.Create("DLabel", panelBuy)
  601. labelCredits:SetPos(13, 10)
  602. labelCredits:SetSize(100, 30)
  603. labelCredits:SetText(string.format(LANG.GetRawTranslation("eqmenu_credits"), credits))
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610. ---------------------------
  611. ------ ITEM DESC-PANE-------
  612. ---------------------------
  613.  
  614. local panelItemDesc = vgui.Create("Panel", panelItems)
  615. panelItemDesc:SetSize(215, 121)
  616. panelItemDesc:SetPos(125, 216)
  617.  
  618.  
  619.  
  620.  
  621. local m = 5
  622. local dfields = {}
  623. for _, k in pairs({ "name", "type", "desc" }) do
  624. dfields[k] = vgui.Create("DLabel", panelItems)
  625. dfields[k]:SetTooltip(GetTranslation("equip_spec_" .. k))
  626. dfields[k]:SetPos(132, 225)
  627. dfields[k]:Hide()
  628. end
  629.  
  630. dfields.name:SetFont("TabLarge")
  631.  
  632. dfields.type:SetFont("DermaDefault")
  633. dfields.type:MoveBelow(dfields.name)
  634.  
  635. dfields.desc:SetFont("DermaDefaultBold")
  636. dfields.desc:SetContentAlignment(7)
  637. dfields.desc:MoveBelow(dfields.type, 1)
  638.  
  639.  
  640. ---------------------------
  641. -------- ITEMS-PANEL--------
  642. ---------------------------
  643.  
  644. local activeCatagory = passiveEquipSelect
  645. --local update_preqs = PreqLabels(panelBuy, m*3, m*2)
  646.  
  647. function onEquipSelect(self, _, new)
  648. for k, v in pairs(new.item) do
  649. if dfields[k] then
  650. dfields[k]:SetText(SafeTranslate(v))
  651. dfields[k]:SizeToContents()
  652. dfields[k]:Show()
  653. end
  654. end
  655.  
  656. -- Trying to force everything to update to
  657. -- the right size is a giant pain, so just
  658. -- force a good size.
  659. dfields.desc:SetTall(70)
  660.  
  661. --can_order = update_preqs(new.item)
  662.  
  663. buttonBuy:SetEnabled(can_order)
  664. buttonFav:SetEnabled(true)
  665. buttonFav:SetText("+FAV")
  666. for i = 1, #favourites do
  667. if favourites[i] == new.item.id then
  668. buttonFav:SetText(LANG.GetRawTranslation("eqmenu_del_fav"))
  669. break
  670. end
  671. end
  672. end
  673.  
  674.  
  675.  
  676.  
  677. local scrollPane = vgui.Create("Panel", panelItems)
  678. scrollPane:SetSize(374, 188)
  679. scrollPane:SetPos(126, 30)
  680.  
  681.  
  682. function initEquipPanel()
  683. local equipPanel = vgui.Create("EquipSelect", scrollPane)
  684. equipPanel:SetPos(0, 0)
  685. equipPanel:SetSize(370, 187)
  686. equipPanel:EnableVerticalScrollbar(true)
  687. equipPanel:EnableHorizontal(true)
  688. equipPanel:SetPadding(4)
  689. equipPanel:Hide()
  690. equipPanel.OnActivePanelChanged = onEquipSelect
  691. return equipPanel
  692. end
  693.  
  694.  
  695. local easterEgg = vgui.Create("Panel", scrollPane)
  696. easterEgg:SetPos(0, 0)
  697. easterEgg:SetSize(370, 187)
  698. easterEgg:Hide()
  699. local labelCredits = vgui.Create("DLabel", easterEgg)
  700. labelCredits:SetPos(5, 5)
  701. labelCredits:SetText(LANG.GetRawTranslation("eqmenu_easteregg_body"))
  702. labelCredits:SizeToContents()
  703.  
  704. local labelWebLink = vgui.Create("DLabelURL", easterEgg)
  705. labelWebLink:SetPos(5, 172)
  706. labelWebLink:SetText("https://unacceptableuse.com")
  707. labelWebLink:SetURL("https://unacceptableuse.com")
  708. labelWebLink:SetColor(Color(255, 255, 255, 255))
  709. labelWebLink:SizeToContents()
  710.  
  711. local buttonMemes = vgui.Create("DButton", easterEgg)
  712. buttonMemes:SetPos(80, 100)
  713. buttonMemes:SetSize(210, 32)
  714. buttonMemes:SetText(LANG.GetRawTranslation("eqmenu_easteregg_button"))
  715.  
  716. function buttonMemes:OnMousePressed()
  717. RunConsoleCommand("say", LANG.GetRawTranslation("eqmenu_easteregg_text"))
  718. eqframe:Close()
  719. end
  720.  
  721. local equipSelect = initEquipPanel()
  722. local passiveEquipSelect = initEquipPanel()
  723. local activeEquipSelect = initEquipPanel()
  724. local explosivesEquipSelect = initEquipPanel()
  725. local weaponEquipSelect = initEquipPanel()
  726. local specialEquipSelect = initEquipPanel()
  727. local favouritesEquipSelect = initEquipPanel()
  728. local searchEquipSelect = initEquipPanel()
  729.  
  730.  
  731.  
  732. local menuTypes = {}
  733. menuTypes.passiveEquipSelect = {}
  734. menuTypes.passiveEquipSelect.menu = passiveEquipSelect
  735. menuTypes.passiveEquipSelect.button = buttonPassive
  736. menuTypes.weaponEquipSelect = {}
  737. menuTypes.weaponEquipSelect.menu = weaponEquipSelect
  738. menuTypes.weaponEquipSelect.button = buttonWeapon
  739. menuTypes.explosivesEquipSelect = {}
  740. menuTypes.explosivesEquipSelect.menu = explosivesEquipSelect
  741. menuTypes.explosivesEquipSelect.button = buttonExplosives
  742. menuTypes.activeEquipSelect = {}
  743. menuTypes.activeEquipSelect.menu = activeEquipSelect
  744. menuTypes.activeEquipSelect.button = buttonActive
  745. menuTypes.uncatagorised = {}
  746. menuTypes.uncatagorised.menu = equipSelect
  747. menuTypes.uncatagorised.button = buttonPassive
  748. menuTypes.specialEquipSelect = {}
  749. menuTypes.specialEquipSelect.menu = specialEquipSelect
  750. menuTypes.specialEquipSelect.button = buttonSpecial
  751. menuTypes.favouritesEquipSelect = {}
  752. menuTypes.favouritesEquipSelect.menu = favouritesEquipSelect
  753. menuTypes.favouritesEquipSelect.button = buttonFavourites
  754.  
  755.  
  756.  
  757. function SwitchCatagory(newCatagory, button)
  758. if showUncatagorised then
  759. equipSelect:Show()
  760. buttonPassive:SetEnabled(false)
  761. buttonActive:SetEnabled(false)
  762. buttonExplosives:SetEnabled(false)
  763. buttonWeapon:SetEnabled(false)
  764. buttonSpecial:SetEnabled(false)
  765. return
  766. end
  767. for k, v in pairs(menuTypes) do
  768. if (v.menu == newCatagory) then
  769. ply:SetPData("eqMenuLastWindow", k)
  770. break
  771. end
  772. end
  773.  
  774.  
  775. equipSelect:Hide()
  776. passiveEquipSelect:Hide()
  777. activeEquipSelect:Hide()
  778. explosivesEquipSelect:Hide()
  779. weaponEquipSelect:Hide()
  780. specialEquipSelect:Hide()
  781. favouritesEquipSelect:Hide()
  782. searchEquipSelect:Hide()
  783. buttonPassive.Selected = false
  784. buttonActive.Selected = false
  785. buttonExplosives.Selected = false
  786. buttonWeapon.Selected = false
  787. buttonSpecial.Selected = false
  788. buttonFavourites.Selected = false
  789.  
  790. if button ~= nil then
  791. button.Selected = true
  792. end
  793. newCatagory:Show()
  794. activeCatagory = newCatagory
  795. end
  796.  
  797. function textSearch:OnMousePressed()
  798. frame:SetKeyboardInputEnabled(true)
  799. SwitchCatagory(searchEquipSelect, nil)
  800. end
  801.  
  802. function buttonCloseSearch:OnMousePressed()
  803. textSearch:SetText("")
  804. easterEgg:Hide()
  805. frame:SetKeyboardInputEnabled(false)
  806. if ply:GetPData("eqMenuMemoryWindow", false) == "true" then --god damn typing
  807. local menuType = menuTypes[ply:GetPData("eqMenuLastWindow", "passiveEquipSelect")]
  808. SwitchCatagory(menuType.menu, menuType.button)
  809. else
  810. SwitchCatagory(passiveEquipSelect, buttonPassive)
  811. end
  812. end
  813.  
  814. function buttonPassive:OnMousePressed()
  815. SwitchCatagory(passiveEquipSelect)
  816. buttonPassive.Selected = true
  817. end
  818.  
  819. function buttonActive:OnMousePressed()
  820. SwitchCatagory(activeEquipSelect)
  821. buttonActive.Selected = true
  822. end
  823.  
  824. function buttonWeapon:OnMousePressed()
  825. SwitchCatagory(weaponEquipSelect)
  826. buttonWeapon.Selected = true
  827. end
  828.  
  829. function buttonExplosives:OnMousePressed()
  830. SwitchCatagory(explosivesEquipSelect)
  831. buttonExplosives.Selected = true
  832. end
  833.  
  834. function buttonSpecial:OnMousePressed()
  835. SwitchCatagory(specialEquipSelect)
  836. buttonSpecial.Selected = true
  837. end
  838.  
  839. function buttonFavourites:OnMousePressed()
  840. SwitchCatagory(favouritesEquipSelect)
  841. buttonFavourites.Selected = true
  842. end
  843.  
  844. function buttonBuy:OnMousePressed()
  845. local pnl
  846. if showUncatagorised then
  847. pnl = equipSelect.SelectedPanel
  848. else
  849. pnl = activeCatagory.SelectedPanel
  850. end
  851. if not pnl or not pnl.item then return end
  852. local choice = pnl.item
  853. RunConsoleCommand("ttt_order_equipment", choice.id)
  854. frame:Close()
  855. end
  856.  
  857. function buttonFav:OnMousePressed()
  858. if buttonFav:GetDisabled() then return end
  859. local pnl
  860. if showUncatagorised then
  861. pnl = eqMenuUncatagorised.SelectedPanel
  862. else
  863. pnl = activeCatagory.SelectedPanel
  864. end
  865. if not pnl or not pnl.item then return end
  866. local choice = pnl.item
  867. local isInFavourites = false
  868.  
  869. for i = 1, #favourites do
  870. if favourites[i] == choice.id then
  871. table.remove(favourites, i)
  872. isInFavourites = true
  873. break
  874. end
  875. end
  876.  
  877. if isInFavourites then
  878. buttonFav:SetText("+FAV")
  879. else
  880. table.insert(favourites, choice.id)
  881. buttonFav:SetText("-FAV")
  882. end
  883. local out = ""
  884. for i = 1, #favourites do
  885. out = out .. ":" .. favourites[i]
  886. end
  887. ply:SetPData("eqMenuFavourites", out)
  888. end
  889.  
  890. -- wepsCategory = {
  891. -- "weapon_ttt_sipistol",
  892. -- "weapon_ttt_knife",
  893. -- "weapon_ttt_flaregun",
  894. -- "weapon_ttt_phammer",
  895. -- "weapon_ttt_push",
  896. -- "melon_gtx2ttt",
  897. -- "ttt_harpoon",
  898. -- "weapon_ttt_p90",
  899. -- "weapon_ttt_ak47",
  900. -- "weapon_ttt_awp",
  901. -- "weapon_ttt_revolver",
  902. -- "weapon_ttt_slim4a1",
  903. -- "weapon_ttt_poisiondart",
  904. -- "weapon_ttt_shurikens",
  905. -- "weapon_ttt_siltmp",
  906. -- "weapon_ttt_stungun",
  907. -- "weapon_ttt_silm4a1",
  908. -- "stungun",
  909. -- "weapon_ttt_poisondart"
  910. -- }
  911. -- explosivesCategory = {
  912. -- "melonlauncher", --melon launcher
  913. -- "weapon_ttt_c4", --C4
  914. -- "weapon_ttt_rsb", --RSB
  915. -- "weapon_ttt_rsb_diffuser", --RSB
  916. -- "weapon_ttt_slam", --S.L.A.M
  917. -- "weapon_ttt_turtlenade", --turtle grenade
  918. -- "weapon_ttt_frag", --frag grenade
  919. -- "weapon_ttt_holyhandgrenade", --holy hand grenade
  920. -- "weapon_ttt_chickennade", --chicken
  921. -- "weapon_ttt_jihad", --jihad
  922. -- "weapon_ttt_bananabomb", --banana bomb
  923. -- "weapon_ttt_bomb_station", --bomb station
  924. -- "weapon_ttt_flashbang", --Flashbang
  925. -- "weapon_sh_flashbang", --flashbang
  926. -- "weapon_ttt_homingpigeon" --Homing pigeon
  927. -- }
  928.  
  929. --Terrible programming but nobody has to know ;)
  930. function GetCatagoryForItem(item)
  931. if showUncatagorised then
  932. return equipSelect
  933. elseif --==WEAPONS==
  934. item.id == "weapon_ttt_sipistol" or --silenced pistol
  935. item.id == "weapon_ttt_knife" or --knife
  936. item.id == "weapon_ttt_flaregun" or --flare gun
  937. item.id == "weapon_ttt_phammer" or --poltergiest
  938. item.id == "weapon_ttt_push" or --newton launcher
  939. item.id == "melon_gtx2ttt" or --melon launcher
  940. item.id == "ttt_harpoon" or --harpoon
  941. item.id == "weapon_ttt_p90" or --P90
  942. item.id == "weapon_ttt_ak47" or --AK47
  943. item.id == "weapon_ttt_awp" or --AWP
  944. item.id == "weapon_ttt_revolver" or --SW500
  945. item.id == "weapon_ttt_slim4a1" or --silenced m4a1
  946. item.id == "weapon_ttt_poisiondart" or --poision dart gun
  947. item.id == "weapon_ttt_shurikens" or --shuriken
  948. item.id == "weapon_ttt_siltmp" or --siltmp
  949. item.id == "weapon_ttt_stungun" or --disorientation gun
  950. item.id == "weapon_ttt_m4a1_s" or --Sil m4
  951. item.id == "weapon_ttt_tmp_s" or --Silenced fox
  952. item.id == "rotgun" or
  953. item.id == "weapon_ttt_goldengun" or
  954. item.id == "magnum (Garrys mod own item)" or
  955. item.id == "nc_ttt_nighthawk" or
  956. item.id == "weapon_ttt_tflippy_si-g3sg1" or
  957. item.id == "genji_melee" or
  958. item.id == "weapon_ttt_peacekeeper" or
  959. item.id == "weapon_ttt_tigers" or
  960. item.id == "weapon_minigun" or
  961. item.id == "weapon_predator_blade" or
  962. item.id == "stungun" or --stungun
  963. item.id == "weapon_ttt_poisondart" --poison dart
  964. then return weaponEquipSelect elseif --==EXPLOSIVES==
  965. item.id == "melonlauncher" or --melon launcher
  966. item.id == "weapon_ttt_c4" or --C4
  967. item.id == "weapon_ttt_rsb" or --RSB
  968. item.id == "weapon_ttt_rsb_diffuser" or --RSB
  969. item.id == "weapon_ttt_slam" or --S.L.A.M
  970. item.id == "weapon_ttt_turtlenade" or --turtle grenade
  971. item.id == "weapon_ttt_frag" or --frag grenade
  972. item.id == "weapon_ttt_holyhandgrenade" or --holy hand grenade
  973. item.id == "weapon_ttt_chickennade" or --chicken
  974. item.id == "weapon_ttt_jihad" or --jihad
  975. item.id == "weapon_ttt_bananabomb" or --banana bomb
  976. item.id == "weapon_ttt_bomb_station" or --bomb station
  977. item.id == "weapon_ttt_flashbang" or --Flashbang
  978. item.id == "weapon_sh_flashbang" or --flashbang
  979. item.id == "weapon_ttt_gimnade" or
  980. item.id == "weapon_ttt_confgrenade_s" or
  981. item.id == "weapon_boombody" or
  982. item.id == "melonlauncher" or
  983. item.id == "weapon_ttt_expmicrowave" or
  984. item.id == "fp" or
  985. item.id == "weapon_ttt_lemlauncher" or
  986. item.id == "weapon_ttt_lemnade" or
  987. item.id == "weapon_ttt_doorbuster" or
  988. item.id == "weapon_ttt_homingpigeon" --Homing pigeon
  989. then return explosivesEquipSelect elseif --==SPECIALS==
  990. item.id == "weapon_ttt_decoy" or --decoy
  991. item.id == "weapon_ttt_teleport" or --teleporter
  992. item.id == "weapon_ttt_health_station" or --health station
  993. item.id == "weapon_ttt_radio" or --radio
  994. item.id == "weapon_ttt_cse" or --visualizer
  995. item.id == "weapon_ttt_detective_camera" or --camera
  996. item.id == "weapon_ttt_defuser" or --defuser
  997. item.id == "weapon_ttt_binoculars" or --binoculars
  998. item.id == "weapon_ttt_basscannon" or --bass cannon
  999. item.id == "weapon_ttt_prophide" or --prop disguiser
  1000. item.id == "weapon_prophide" or --prop disguiser
  1001. item.id == "weapon_ttt_defib_traitor" or --defib
  1002. item.id == "weapon_ttt_bodyspawn" or --defib(?) possibly tazer?
  1003. item.id == "weapon_ttt_beacon" or --beacon(?)
  1004. item.id == "weapon_ttt_briefcase" or --Briefcase
  1005. item.id == "weapon_peace_maker" or --peace sentry
  1006. item.id == "weapon_ttt_bblauncher" or --Bounce Ball
  1007. item.id == "weapon_ttt_teargas" or --Tear Gas
  1008. item.id == "weapon_gh_checker" --wep checker
  1009. then return specialEquipSelect elseif --==PASSIVE==
  1010. item.id == 1 or --body armor
  1011. item.id == "ttt_a_second_chance" or
  1012. item.id == "ttt_hermesboots_detective " or
  1013. item.id == "ttt_hermesboots_traitor" or
  1014. item.id == "ttt_luckyhorseshoe_detective" or
  1015. item.id == "ttt_luckyhorseshoe_traitor" or
  1016. item.id == "zombies_perk_phd" or
  1017. item.id == "ttt_martyr_proj" or
  1018. item.id == "weapon_ttt_mirrorfate" or
  1019. item.id == 2 --radar
  1020. then return passiveEquipSelect elseif --==ACTIVE==
  1021. item.id == 4 or --disguiser
  1022. item.id == "weapon_ttt_adv_disguiser" or --advanced disguiser
  1023. item.id == "weapon_ttt_cloakingdevice" or --advanced disguiser
  1024. item.id == "sh_slowmotion" or
  1025. item.id == "ttt_thelittlehelper" or
  1026. item.id == 16 --iron boots
  1027. then return activeEquipSelect else
  1028. local swep = weapons.GetStored(item.id)
  1029. if not swep then return specialEquipSelect end
  1030. if not swep.Kind then return specialEquipSelect end
  1031. if swep.Kind == WEAPON_EQUIP1 or swep.Kind == WEAPON_EQUIP2 then
  1032. return specialEquipSelect
  1033. elseif swep.Kind == WEAPON_HEAVY or swep.Kind == WEAPON_PISTOL then
  1034. return weaponEquipSelect
  1035. elseif swep.Kind == WEAPON_NADE then
  1036. return explosivesEquipSelect
  1037. elseif swep.Kind == WEAPON_ROLE then
  1038. return activeEquipSelect
  1039. end
  1040. print("Warning: No catagory for "..item.id.." (Kind "..swep.Kind..")")
  1041. -- WEAPON_CARRY 5
  1042. -- WEAPON_PISTOL 2
  1043. -- WEAPON_HEAVY 3
  1044. -- WEAPON_NADE 4
  1045. -- WEAPON_EQUIP1 6
  1046. -- WEAPON_EQUIP2 7
  1047. -- WEAPON_ROLE 8
  1048. -- WEAPON_MELEE 1
  1049. return specialEquipSelect
  1050. end
  1051. end
  1052.  
  1053.  
  1054. if ply:GetPData("eqMenuMemoryWindow", false) == "true" then --god damn typing
  1055. local menuType = menuTypes[ply:GetPData("eqMenuLastWindow", "passiveEquipSelect")]
  1056. SwitchCatagory(menuType.menu, menuType.button)
  1057. else
  1058. SwitchCatagory(passiveEquipSelect, buttonPassive)
  1059. end
  1060.  
  1061.  
  1062.  
  1063. local owned_ids = {}
  1064. for _, wep in pairs(ply:GetWeapons()) do
  1065. if IsValid(wep) and wep["IsEquipment"] and wep:IsEquipment() then
  1066. table.insert(owned_ids, wep:GetClass())
  1067. end
  1068. end
  1069.  
  1070.  
  1071. function createItemIcon(item, equipMenu, isInFavourites)
  1072. local ic = nil
  1073. if item.material then
  1074. if item.custom then
  1075. -- Custom marker icon
  1076. ic = vgui.Create("LayeredIcon", equipMenu)
  1077.  
  1078. local marker = vgui.Create("DImage")
  1079. marker:SetImage("vgui/ttt/custom_marker")
  1080. marker.PerformLayout = function(s)
  1081. s:AlignBottom(2)
  1082. s:AlignRight(2)
  1083. s:SetSize(16, 16)
  1084. end
  1085. marker:SetTooltip(GetTranslation("equip_custom"))
  1086.  
  1087. ic:AddLayer(marker)
  1088.  
  1089. ic:EnableMousePassthrough(marker)
  1090. -- elseif not ItemIsWeapon(item) then
  1091. -- ic = vgui.Create("LayeredIcon", equipMenu)
  1092. else
  1093. ic = vgui.Create("LayeredIcon", equipMenu)
  1094. end
  1095.  
  1096. if isInFavourites then
  1097. local marker = vgui.Create("DImage")
  1098. marker:SetImage("icon16/star.png")
  1099. marker.PerformLayout = function(s)
  1100. if item.custom then
  1101. s:AlignRight(20)
  1102. else
  1103. s:AlignRight(2)
  1104. end
  1105. s:AlignBottom(2)
  1106.  
  1107. s:SetSize(16, 16)
  1108. end
  1109. marker:SetTooltip(LANG.GetRawTranslation("eqmenu_favourited"))
  1110. ic:AddLayer(marker)
  1111. ic:EnableMousePassthrough(marker)
  1112. end
  1113.  
  1114.  
  1115. -- Slot marker icon
  1116. if ItemIsWeapon(item) then
  1117. local slot = vgui.Create("SimpleIconLabelled")
  1118. slot:SetIcon("vgui/ttt/slotcap")
  1119. slot:SetIconColor(color_slot[ply:GetRole()] or COLOR_GREY)
  1120. slot:SetIconSize(16)
  1121.  
  1122. slot:SetIconText(item.slot)
  1123.  
  1124. slot:SetIconProperties(COLOR_WHITE,
  1125. "DefaultBold",
  1126. { opacity = 220, offset = 1 },
  1127. { 10, 8 })
  1128.  
  1129. ic:AddLayer(slot)
  1130. ic:EnableMousePassthrough(slot)
  1131. end
  1132.  
  1133. ic:SetIconSize(64)
  1134. ic:SetIcon(item.material)
  1135. elseif item.model then
  1136. ic = vgui.Create("SpawnIcon", equipMenu)
  1137. ic:SetModel(item.model)
  1138. else
  1139. ErrorNoHalt("Equipment item does not have model or material specified: " .. tostring(item) .. "\n")
  1140. end
  1141.  
  1142.  
  1143.  
  1144. -- If we cannot order this item, darken it
  1145. if ((not can_order) or
  1146. -- already owned
  1147. table.HasValue(owned_ids, item.id) or
  1148. (tonumber(item.id) and ply:HasEquipmentItem(tonumber(item.id))) or
  1149. -- already carrying a weapon for this slot
  1150. (ItemIsWeapon(item) and (not CanCarryWeapon(item))) or
  1151. -- already bought the item before
  1152. (item.limited and ply:HasBought(tostring(item.id)))) then
  1153.  
  1154. ic:SetIconColor(color_darkened)
  1155. end
  1156. ic.item = item
  1157.  
  1158. return ic
  1159. end
  1160.  
  1161. local items = GetEquipmentForRole(ply:GetRole())
  1162.  
  1163. local to_select = nil
  1164.  
  1165. for k, item in pairs(items) do
  1166. local isInFavourites = false
  1167. for i = 1, #favourites do
  1168. if favourites[i] == item.id then
  1169. isInFavourites = true
  1170. break
  1171. end
  1172. end
  1173.  
  1174.  
  1175. if not (item.custom and hideCustoms) then
  1176. local equipMenu = GetCatagoryForItem(item)
  1177. equipMenu:AddPanel(createItemIcon(item, equipMenu, isInFavourites))
  1178. end
  1179.  
  1180. if isInFavourites then
  1181. favouritesEquipSelect:AddPanel(createItemIcon(item, favouritesEquipSelect, isInFavourites))
  1182. end
  1183. end
  1184.  
  1185. function textSearch:OnChange()
  1186. if (string.len(textSearch:GetText()) > 0) then
  1187. if (textSearch:GetText():lower() == "memes") then
  1188. searchEquipSelect:Hide()
  1189. easterEgg:Show()
  1190. else
  1191. easterEgg:Hide()
  1192. searchEquipSelect:Show()
  1193. searchEquipSelect:Clear()
  1194. for k, item in pairs(items) do
  1195. if (string.match(item.name:lower(), textSearch:GetText():lower()) or string.match(item.id, textSearch:GetText():lower())) then
  1196. searchEquipSelect:AddPanel(createItemIcon(item, searchEquipSelect, false))
  1197. end
  1198. end
  1199. end
  1200. else
  1201. if ply:GetPData("eqMenuMemoryWindow", memoryWindowDefault) == "true" then --god damn typing
  1202. local menuType = menuTypes[ply:GetPData("eqMenuLastWindow", "passiveEquipSelect")]
  1203. SwitchCatagory(menuType.menu, menuType.button)
  1204. else
  1205. SwitchCatagory(passiveEquipSelect, buttonPassive)
  1206. end
  1207. end
  1208. end
  1209.  
  1210.  
  1211. eqframe = frame
  1212.  
  1213.  
  1214. function paintPrimaryOutlinedBox(w, h)
  1215. surface.SetDrawColor(Color(57, 57, 57, 255))
  1216. surface.DrawRect(0, 0, w, h)
  1217. surface.SetDrawColor(Color(0, 7, 10, 255))
  1218. surface.DrawOutlinedRect(0, 0, w, h)
  1219. surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
  1220. end
  1221.  
  1222. function paintSecondaryOutlinedBox(w, h)
  1223. surface.SetDrawColor(Color(35, 35, 35, 255))
  1224. surface.DrawRect(0, 0, w, h - 2)
  1225. surface.SetDrawColor(Color(0, 7, 10, 255))
  1226. surface.DrawOutlinedRect(0, 0, w, h)
  1227. surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
  1228. end
  1229.  
  1230. function paintButton(w, h, button)
  1231. if (button:GetDisabled()) then
  1232. surface.SetDrawColor(color_button_disabled[ply:GetRole()] or COLOR_GREY)
  1233. else
  1234. surface.SetDrawColor(color_button_normal[ply:GetRole()] or COLOR_GREY)
  1235. end
  1236.  
  1237. surface.DrawRect(0, 0, w - 2, h)
  1238. surface.SetDrawColor(Color(0, 7, 10, 255))
  1239. surface.DrawOutlinedRect(0, 0, w - 2, h)
  1240. surface.DrawOutlinedRect(1, 1, w - 3, h - 2)
  1241. surface.SetFont("DermaDefaultBold")
  1242. if (button.Selected) then
  1243. surface.SetTextColor(255, 255, 255, 255)
  1244. else
  1245. surface.SetTextColor(0, 0, 0, 255)
  1246. end
  1247. surface.SetTextPos((w - surface.GetTextSize(button:GetText())) / 2, 8)
  1248. surface.DrawText(button:GetText())
  1249. return true
  1250. end
  1251.  
  1252. function paintCheckBox(w, h, checkBox)
  1253. surface.SetDrawColor(color_button_normal[ply:GetRole()] or COLOR_GREY)
  1254. surface.DrawRect(0, 0, w, h)
  1255. surface.SetDrawColor(Color(0, 7, 10, 255))
  1256. surface.DrawOutlinedRect(0, 0, w, h)
  1257. surface.DrawOutlinedRect(1, 1, w - 2, h - 2)
  1258. if checkBox:GetChecked() then
  1259.  
  1260. surface.SetFont("Marlett")
  1261. surface.SetTextColor(0, 0, 0, 255)
  1262. surface.SetTextPos(0, 0)
  1263. surface.DrawText("a")
  1264. end
  1265. return true
  1266. end
  1267.  
  1268. function panel:Paint(w, h)
  1269. paintPrimaryOutlinedBox(w, h)
  1270. return true
  1271. end
  1272.  
  1273. function panelCatagories:Paint(w, h)
  1274. paintSecondaryOutlinedBox(w, h)
  1275. return true
  1276. end
  1277.  
  1278. function panelSettings:Paint(w, h)
  1279. paintPrimaryOutlinedBox(w, h)
  1280. return true
  1281. end
  1282.  
  1283. function panelBuy:Paint(w, h)
  1284. paintPrimaryOutlinedBox(w, h)
  1285. return true
  1286. end
  1287.  
  1288. function scrollPane:Paint(w, h)
  1289. paintSecondaryOutlinedBox(w, h)
  1290. return true
  1291. end
  1292.  
  1293. function panelItemDesc:Paint(w, h)
  1294. paintPrimaryOutlinedBox(w, h)
  1295. return true
  1296. end
  1297.  
  1298. function textSearch:Paint(w, h)
  1299. paintPrimaryOutlinedBox(w, h)
  1300. surface.SetFont("DermaDefault")
  1301. surface.SetTextColor(255, 255, 255, 255)
  1302. surface.SetTextPos(15, 10)
  1303. surface.DrawText(textSearch:GetText())
  1304. return true
  1305. end
  1306.  
  1307. function checkUncatagorised:Paint(w, h)
  1308. return paintCheckBox(w, h, checkUncatagorised)
  1309. end
  1310.  
  1311. function checkMemoryWindow:Paint(w, h)
  1312. return paintCheckBox(w, h, checkMemoryWindow)
  1313. end
  1314.  
  1315. function checkHideCustoms:Paint(w, h)
  1316. return paintCheckBox(w, h, checkHideCustoms)
  1317. end
  1318.  
  1319. function buttonWeapon:Paint(w, h)
  1320. return paintButton(w, h, buttonWeapon)
  1321. end
  1322.  
  1323. function buttonSpecial:Paint(w, h)
  1324. return paintButton(w, h, buttonSpecial)
  1325. end
  1326.  
  1327. function buttonExplosives:Paint(w, h)
  1328. return paintButton(w, h, buttonExplosives)
  1329. end
  1330.  
  1331. function buttonBuy:Paint(w, h)
  1332. return paintButton(w, h, buttonBuy)
  1333. end
  1334.  
  1335. function buttonActive:Paint(w, h)
  1336. return paintButton(w, h, buttonActive)
  1337. end
  1338.  
  1339. function buttonPassive:Paint(w, h)
  1340. return paintButton(w, h, buttonPassive)
  1341. end
  1342.  
  1343. function buttonFavourites:Paint(w, h)
  1344. return paintButton(w, h, buttonFavourites)
  1345. end
  1346.  
  1347. function buttonRadar:Paint(w, h)
  1348. return paintButton(w, h, buttonRadar)
  1349. end
  1350.  
  1351. function buttonRadio:Paint(w, h)
  1352. return paintButton(w, h, buttonRadio)
  1353. end
  1354.  
  1355. function buttonClose:Paint(w, h)
  1356. return paintButton(w, h, buttonClose)
  1357. end
  1358.  
  1359. function buttonTransfer:Paint(w, h)
  1360. return paintButton(w, h, buttonTransfer)
  1361. end
  1362.  
  1363. function buttonItems:Paint(w, h)
  1364. return paintButton(w, h, buttonItems)
  1365. end
  1366.  
  1367. function buttonDisguise:Paint(w, h)
  1368. return paintButton(w, h, buttonDisguise)
  1369. end
  1370.  
  1371. function buttonToggleDisguiser:Paint(w, h)
  1372. return paintButton(w, h, buttonToggleDisguiser)
  1373. end
  1374.  
  1375. function buttonFav:Paint(w, h)
  1376. return paintButton(w, h, buttonFav)
  1377. end
  1378.  
  1379. function buttonCloseSearch:Paint(w, h)
  1380. return paintButton(w, h, buttonCloseSearch)
  1381. end
  1382.  
  1383. function buttonRadarScan:Paint(w, h)
  1384. return paintButton(w, h, buttonRadarScan)
  1385. end
  1386.  
  1387. function buttonMemes:Paint(w, h)
  1388. return paintButton(w, h, buttonMemes)
  1389. end
  1390.  
  1391. return
  1392. end
  1393.  
  1394. concommand.Add("ttt_cl_traitorpopup", TraitorMenuPopup)
  1395.  
  1396. local function ForceCloseTraitorMenu(ply, cmd, args)
  1397. if IsValid(eqframe) then
  1398. eqframe:Close()
  1399. end
  1400. end
  1401.  
  1402. concommand.Add("ttt_cl_traitorpopup_close", ForceCloseTraitorMenu)
  1403.  
  1404.  
  1405. concommand.Add("noclip", function()
  1406. local r = GetRoundState()
  1407. if r == ROUND_ACTIVE and not (LocalPlayer():GetTraitor() or LocalPlayer():GetDetective()) then
  1408. return
  1409. elseif r == ROUND_POST or r == ROUND_PREP then
  1410. CLSCORE:Reopen()
  1411. return
  1412. end
  1413. if IsValid(eqframe) then
  1414. eqframe:Close()
  1415. else
  1416. RunConsoleCommand("ttt_cl_traitorpopup")
  1417. end
  1418. end)
  1419.  
  1420.  
  1421.  
  1422. local function ReceiveEquipment()
  1423. local ply = LocalPlayer()
  1424. if not IsValid(ply) then return end
  1425.  
  1426. ply.equipment_items = net.ReadUInt(16)
  1427. end
  1428.  
  1429. net.Receive("TTT_Equipment", ReceiveEquipment)
  1430.  
  1431. local function ReceiveCredits()
  1432. local ply = LocalPlayer()
  1433. if not IsValid(ply) then return end
  1434.  
  1435. ply.equipment_credits = net.ReadUInt(8)
  1436. end
  1437.  
  1438. net.Receive("TTT_Credits", ReceiveCredits)
  1439.  
  1440. local r = 0
  1441. local function ReceiveBought()
  1442. local ply = LocalPlayer()
  1443. if not IsValid(ply) then return end
  1444.  
  1445. ply.bought = {}
  1446. local num = net.ReadUInt(8)
  1447. for i = 1, num do
  1448. local s = net.ReadString()
  1449. if s != "" then
  1450. table.insert(ply.bought, s)
  1451. end
  1452. end
  1453.  
  1454. -- This usermessage sometimes fails to contain the last weapon that was
  1455. -- bought, even though resending then works perfectly. Possibly a bug in
  1456. -- bf_read. Anyway, this hack is a workaround: we just request a new umsg.
  1457. if num != #ply.bought and r < 10 then -- r is an infinite loop guard
  1458. RunConsoleCommand("ttt_resend_bought")
  1459. r = r + 1
  1460. else
  1461. r = 0
  1462. end
  1463. end
  1464.  
  1465. net.Receive("TTT_Bought", ReceiveBought)
  1466.  
  1467. -- Player received the item he has just bought, so run clientside init
  1468. local function ReceiveBoughtItem()
  1469. local is_item = net.ReadBit() == 1
  1470. local id = is_item and net.ReadUInt(16) or net.ReadString()
  1471.  
  1472. -- I can imagine custom equipment wanting this, so making a hook
  1473. hook.Run("TTTBoughtItem", is_item, id)
  1474. end
  1475.  
  1476. net.Receive("TTT_BoughtItem", ReceiveBoughtItem)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement