Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.00 KB | None | 0 0
  1. --Build Shop Menu
  2.  
  3. function buy_shop()
  4. shop_frame = PNRP.PNRP_Frame()
  5. if not shop_frame then return end
  6.  
  7. PNRP.RMDerma()
  8. shop_frame:SetSize( 710, 720 ) --Set the size Extra 40 must be from the top bar
  9. --Set the window in the middle of the players screen/game window
  10. shop_frame:SetPos(ScrW() / 2 - shop_frame:GetWide() / 2, ScrH() / 2 - shop_frame:GetTall() / 2)
  11. shop_frame:SetTitle( "Shop Menu" ) --Set title
  12. shop_frame:SetVisible( true )
  13. shop_frame:SetDraggable( true )
  14. shop_frame:ShowCloseButton( true )
  15. shop_frame:MakePopup()
  16. shop_frame.Paint = function()
  17. surface.SetDrawColor( 50, 50, 50, 0 )
  18. end
  19. PNRP.AddMenu(menu)
  20.  
  21. local screenBG = vgui.Create("DImage", shop_frame)
  22. screenBG:SetImage( "VGUI/gfx/pnrp_screen_1b.png" )
  23. screenBG:SetSize(shop_frame:GetWide(), shop_frame:GetTall())
  24. PNRP.buildMenu(shop_frame)
  25.  
  26. local PropertySheet = vgui.Create( "DPropertySheet" )
  27. PropertySheet:SetParent( shop_frame )
  28. PropertySheet:SetPos( 40, 60 )
  29. PropertySheet:SetSize( shop_frame:GetWide() - 85 , shop_frame:GetTall() - 105 )
  30. PropertySheet:SetFadeTime( 0.5 )
  31. PropertySheet.Paint = function()
  32. surface.SetDrawColor( 50, 50, 50, 0 )
  33. end
  34.  
  35.  
  36. local weaponPanel = PNRP.build_List("weapon", shop_frame, PropertySheet)
  37. local ammoPanel = PNRP.build_List("ammo", shop_frame, PropertySheet)
  38. local medicalPanel = PNRP.build_List("medical", shop_frame, PropertySheet)
  39. local foodPanel = PNRP.build_List("food", shop_frame, PropertySheet)
  40. local builtitemsPanel = PNRP.build_List("build", shop_frame, PropertySheet)
  41. local junkPanel = PNRP.build_List("junk", shop_frame, PropertySheet)
  42. local vehiclePanel = PNRP.build_List("vehicle", shop_frame, PropertySheet)
  43. local toolsPanel = PNRP.build_List("tool", shop_frame, PropertySheet)
  44. local partsPanel = PNRP.build_List("part", shop_frame, PropertySheet)
  45. local miscPanel = PNRP.build_List("misc", shop_frame, PropertySheet)
  46.  
  47. PropertySheet:AddSheet( "Weapons", weaponPanel, "gui/icons/bomb.png", false, false, "Build Weapons" )
  48. PropertySheet:AddSheet( "Ammo", ammoPanel, "gui/icons/box.png", false, false, "Create Ammo" )
  49. PropertySheet:AddSheet( "Medical", medicalPanel, "gui/icons/heart.png", false, false, "Medical Items" )
  50. PropertySheet:AddSheet( "Food and Drink", foodPanel, "gui/icons/cup_add.png", false, false, "Food and Drink Items" )
  51. PropertySheet:AddSheet( "Build Items", builtitemsPanel, "gui/icons/palette", false, false, "Building Materials" )
  52. PropertySheet:AddSheet( "Junk", junkPanel, "gui/icons/anchor.png", false, false, "More Building Materials" )
  53. PropertySheet:AddSheet( "Vehicles", vehiclePanel, "gui/icons/car.png", false, false, "Create Vehicles" )
  54. PropertySheet:AddSheet( "Tools", toolsPanel, "gui/icons/wrench.png", false, false, "Make Tools - Still in Development" )
  55. PropertySheet:AddSheet( "Parts", partsPanel, "gui/icons/cog.png", false, false, "Got to find them all." )
  56. PropertySheet:AddSheet( "Misc", miscPanel, "gui/icons/bug.png", false, false, "Pets, paper, etc..." )
  57.  
  58. end
  59.  
  60. function PNRP.build_List(itemtype, parent_frame, PropertySheet)
  61.  
  62. local ply = LocalPlayer()
  63. local sc = 0
  64. local sp = 0
  65. local ch = 0
  66.  
  67. local textColor = Color(200,200,200,255)
  68. local dListBKColor = Color(50,50,50,255)
  69.  
  70. local pnlList = vgui.Create("DPanelList", PropertySheet)
  71. pnlList:SetPos(20, 80)
  72. pnlList:SetSize(parent_frame:GetWide() - 60, parent_frame:GetTall() - 120)
  73. pnlList:EnableVerticalScrollbar(true)
  74. pnlList:EnableHorizontal(false)
  75. pnlList:SetSpacing(1)
  76. pnlList:SetPadding(10)
  77.  
  78. for itemname, item in pairs(PNRP.Items) do
  79. if item.ShopHide == true and not (ply:IsAdmin() and GetConVarNumber("pnrp_adminCreateAll") == 1)then
  80. --Do nothing
  81. else
  82. if item.Type == tostring( itemtype ) then
  83.  
  84. local pnlPanel = vgui.Create("DPanel")
  85. pnlPanel:SetTall(75)
  86. pnlPanel.Paint = function()
  87. draw.RoundedBox( 6, 0, 0, pnlPanel:GetWide(), pnlPanel:GetTall(), Color( 180, 180, 180, 80 ) )
  88. draw.RoundedBox( 1, 0, 0, pnlPanel:GetWide(), 1, Color( 0, 255, 0, 80 ) )
  89. draw.RoundedBox( 1, 0, pnlPanel:GetTall()-1, pnlPanel:GetWide(), 1, Color( 0, 255, 0, 80 ) )
  90. end
  91. pnlList:AddItem(pnlPanel)
  92.  
  93. if ply:Team() == TEAM_ENGINEER then
  94. if item.Scrap != nil then sc = math.ceil( item.Scrap * (1 - (0.02 * ply:GetSkill("Construction")))) else sc = 0 end
  95. if item.SmallParts != nil then sp = math.ceil(item.SmallParts * (1 - (0.02 * ply:GetSkill("Construction")))) else sp = 0 end
  96. if item.Chemicals != nil then ch = math.ceil(item.Chemicals * (1 - (0.02 * ply:GetSkill("Construction")))) else ch = 0 end
  97. else
  98. if item.Scrap != nil then sc = item.Scrap else sc = 0 end
  99. if item.SmallParts != nil then sp = item.SmallParts else sp = 0 end
  100. if item.Chemicals != nil then ch = item.Chemicals else ch = 0 end
  101. end
  102.  
  103. local neededParts = item.ToolCheck( )
  104. local partsText = nil
  105. if type(neededParts) == "table" then
  106. partsText = "Needed Parts: \n--------------------"
  107. for p, n in pairs(neededParts) do
  108. if PNRP.Items[p] then
  109. partsText = partsText.."\n"..PNRP.Items[p].Name.." : "..tostring(n)
  110. end
  111. end
  112. end
  113.  
  114. if ply:Team() == TEAM_ENGINEER then
  115. if partsText == nil then
  116. partsText = ""
  117. else
  118. partsText = partsText.."\n \n"
  119. end
  120. partsText = partsText.."Skill Discount: \n-------------------- \n"
  121. partsText = partsText.."Scrap: "..tostring(sc).." | "..item.Scrap.."\n"
  122. partsText = partsText.."Small Parts: "..tostring(sp).." | "..item.SmallParts.."\n"
  123. partsText = partsText.."Chemicals: "..tostring(ch).." | "..item.Chemicals.."\n"
  124. end
  125.  
  126. pnlPanel.Icon = vgui.Create("SpawnIcon", pnlPanel)
  127. pnlPanel.Icon:SetModel(item.Model)
  128. pnlPanel.Icon:SetPos(3, 5)
  129. pnlPanel.Icon:SetToolTip( partsText )
  130. pnlPanel.Icon.DoClick = function()
  131. RunConsoleCommand("pnrp_buildItem", itemname)
  132. parent_frame:Close()
  133. end
  134.  
  135. pnlPanel.Title = vgui.Create("DLabel", pnlPanel)
  136. pnlPanel.Title:SetPos(90, 5)
  137. pnlPanel.Title:SetText(item.Name)
  138. pnlPanel.Title:SetColor(Color( 0, 255, 0, 255 ))
  139. pnlPanel.Title:SizeToContents()
  140. pnlPanel.Title:SetContentAlignment( 5 )
  141.  
  142. pnlPanel.Cost = vgui.Create("DLabel", pnlPanel)
  143. pnlPanel.Cost:SetPos(90, 55)
  144. pnlPanel.Cost:SetText("Cost: Scrap "..tostring(sc).." | Small Parts "..tostring(sp).." | Chemicals "..tostring(ch))
  145. pnlPanel.Cost:SetColor(Color( 0, 255, 0, 255 ))
  146. pnlPanel.Cost:SizeToContents()
  147. pnlPanel.Cost:SetContentAlignment( 5 )
  148.  
  149. pnlPanel.ClassBuild = vgui.Create("DLabel", pnlPanel)
  150. pnlPanel.ClassBuild:SetPos(340, 5)
  151. pnlPanel.ClassBuild:SetText("Required Class for Creation: "..item.ClassSpawn)
  152. pnlPanel.ClassBuild:SetColor(Color( 0, 200, 0, 255 ))
  153. pnlPanel.ClassBuild:SizeToContents()
  154. pnlPanel.ClassBuild:SetContentAlignment( 5 )
  155.  
  156. pnlPanel.ItmInfo = vgui.Create("DLabel", pnlPanel)
  157. pnlPanel.ItmInfo:SetPos(90, 25)
  158. pnlPanel.ItmInfo:SetText(item.Info)
  159. pnlPanel.ItmInfo:SetColor(Color( 0, 200, 0, 255 ))
  160. pnlPanel.ItmInfo:SetWide(300)
  161. pnlPanel.ItmInfo:SetTall(25)
  162. pnlPanel.ItmInfo:SetWrap(true)
  163. pnlPanel.ItmInfo:SetContentAlignment( 5 )
  164.  
  165. local weightTXT = "Weight: "..item.Weight
  166. if item.Capacity then
  167. weightTXT = weightTXT.." | Capacity: "..item.Capacity
  168. end
  169. pnlPanel.ItemWeight = vgui.Create("DLabel", pnlPanel)
  170. pnlPanel.ItemWeight:SetPos(340, 55)
  171. pnlPanel.ItemWeight:SetText(weightTXT)
  172. pnlPanel.ItemWeight:SetColor(Color( 0, 255, 0, 255 ))
  173. pnlPanel.ItemWeight:SizeToContents()
  174. pnlPanel.ItemWeight:SetContentAlignment( 5 )
  175.  
  176. if item.Type == "vehicle" or item.Type == "tool" or item.Type == "junk" or item.Type == "misc" then
  177. --Since GMod does not like Not or's
  178. else
  179. pnlPanel.bulkSlider = vgui.Create( "DNumSlider", pnlPanel )
  180. pnlPanel.bulkSlider:SetPos(300, 45)
  181. pnlPanel.bulkSlider:SetWide( 280 )
  182. pnlPanel.bulkSlider:SetText( "" )
  183. pnlPanel.bulkSlider:SetMin( 1 )
  184. pnlPanel.bulkSlider:SetMax( 100 )
  185. pnlPanel.bulkSlider:SetDecimals( 0 )
  186. pnlPanel.bulkSlider:SetValue( 1 )
  187. pnlPanel.bulkSlider.Label:SetColor(textColor)
  188. pnlPanel.bulkSlider:SetBGColor(textColor)
  189.  
  190. pnlPanel.BulkBtn = vgui.Create("DButton", pnlPanel )
  191. pnlPanel.BulkBtn:SetPos(485, 30)
  192. pnlPanel.BulkBtn:SetSize(80,17)
  193. pnlPanel.BulkBtn:SetText( "Create Bulk" )
  194. pnlPanel.BulkBtn.DoClick = function()
  195. net.Start("SpawnBulkCrate")
  196. net.WriteEntity(ply)
  197. net.WriteString(itemname)
  198. net.WriteDouble(math.Round(tonumber(pnlPanel.bulkSlider:GetValue())))
  199. net.SendToServer()
  200. parent_frame:Close()
  201. end
  202. end
  203. end
  204. end
  205. end
  206.  
  207. return pnlList
  208.  
  209. end
  210.  
  211. concommand.Add( "pnrp_buy_shop", buy_shop )
  212.  
  213. --EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement