Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 68.29 KB | None | 0 0
  1. -- EDTIOR CLIENT SIDE
  2.  
  3.  
  4. -- || MATERIAL EDITOR || --
  5. function Fact_OpenEditorMaterials( data , selected )
  6. local W, H, Select, Valid, ActTab, Error, ErrorA, Logo = ScrW(), ScrH(), "", true, {}, "", 0, ""
  7. if (EditorFrame) then EditorFrame:Remove() end
  8.  
  9. -- // CREATE THE MAIN LABEL \\ --
  10. EditorFrame = vgui.Create( "DFrame" )
  11. EditorFrame:SetPos( 0, 0 )
  12. EditorFrame:SetSize( W, H )
  13. EditorFrame:SetTitle( "" )
  14. EditorFrame:SetDraggable( false )
  15. EditorFrame:ShowCloseButton( false )
  16. EditorFrame:MakePopup()
  17. EditorFrame.Paint = function()
  18. -- // ICON MANAGAMENT \\ --
  19. draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,255) )
  20. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(255,127,0,255) )
  21. draw.RoundedBox( 0, 0, H*0.925, W, H*0.075, Color(0,0,0,255) )
  22. draw.RoundedBox( 0, W*0.05, H*0.3, W*0.21, H*0.6, Color(255,127,0,255) )
  23. draw.RoundedBox( 0, W*0.05, H*0.25, W*0.21, H*0.05, Color(0,0,0,255) )
  24. draw.DrawText( "ICON : " .. string.upper(Select), "Fact_Medium_Strong", W*0.16, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  25.  
  26. -- // THE PREVIEW ICON \\ --
  27. draw.RoundedBox( 0, W*0.28, H*0.25, W*0.1, H*0.05, Color(0,0,0,255) )
  28. draw.RoundedBox( 0, W*0.28, H*0.3, W*0.1, H*0.17, Color(255,127,0,255) )
  29. draw.RoundedBox( 0, W*0.28, H*0.48, W*0.1, H*0.1, Color(0,0,0,255) )
  30. draw.DrawText( "PREVIEW", "Fact_Medium_Strong", W*0.33, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  31. if (Select ~= "") then
  32. surface.SetDrawColor( Mixer:GetColor() )
  33. surface.SetMaterial( Material(Logo) )
  34. surface.DrawTexturedRect( W*0.28, H*0.3, W*0.1, H*0.17 )
  35. end
  36.  
  37. -- // MODEL 3D \\ --
  38. draw.RoundedBox( 0, W*0.4, H*0.3, W*0.425, H*0.6, Color(255,127,0,255) )
  39. draw.RoundedBox( 0, W*0.4, H*0.25, W*0.425, H*0.05, Color(0,0,0,255) )
  40. draw.RoundedBox( 0, W*0.5, H*0.3, W*0.325, H*0.18, Color(140,140,150,255) )
  41. draw.RoundedBox( 0, W*0.4, H*0.3, W*0.1, H*0.18, Color(0,0,0,255) )
  42. draw.RoundedBox( 0, W*0.7, H*0.3, W*0.1, H*0.18, Color(0,0,0,150) )
  43. draw.DrawText( "MODEL", "Fact_Medium_Strong", W*0.61, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  44. if (Valid) then draw.DrawText( FactLang.ModelValid, "Fact_Small_Strong", W*0.5 + 5, H*0.335, Color( 0, 255, 0, 255 ), 0 )
  45. else draw.DrawText( FactLang.ModelInvalid, "Fact_Small_Strong", W*0.51, H*0.335, Color( 255, 0, 0, 255 ), 0 )
  46. end
  47.  
  48. draw.RoundedBox( 0, W*0.85, H*0.25, W*0.125, H*0.05, Color(0,0,0,255) )
  49. draw.RoundedBox( 0, W*0.85, H*0.3, W*0.125, H*0.25, Color(130,130,130,255) )
  50.  
  51. draw.RoundedBox( 0, W*0.86, H*0.32, W*0.1, H*0.025, Color(255,127,0,255) )
  52. draw.RoundedBox( 0, W*0.86, H*0.37, W*0.1, H*0.025, Color(255,127,0,255) )
  53. draw.RoundedBox( 0, W*0.86, H*0.42, W*0.1, H*0.025, Color(255,127,0,255) )
  54. draw.DrawText( "PROPERTIES", "Fact_Medium_Strong", W*0.91, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  55. -- draw.DrawText( "Is this fuel ?", "Fact_Small", W*0.895, H*0.47, Color( 0, 0, 0, 255 ), 1 )
  56. draw.DrawText( "MATERIAL EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  57. draw.DrawText( Error, "Fact_High_Strong", W*0.5, H*0.14, Color( 255, 0, 0, ErrorA ), 1 )
  58. end
  59.  
  60. -- // MODEL 3D PREVIEW \\ --
  61. ModelIcon = vgui.Create( "ModelImage", EditorFrame )
  62. ModelIcon:SetPos( W*0.4, H*0.3 )
  63. ModelIcon:SetSize( W*0.1, H*0.18 )
  64. ModelIcon:SetModel( "models/props_debris/concrete_chunk04a.mdl" )
  65.  
  66. -- // MODEL ENTRY \\ --
  67. ModelEntry = vgui.Create( "DTextEntry", EditorFrame )
  68. ModelEntry:SetPos( W*0.5, H*0.3 )
  69. ModelEntry:SetSize( W*0.2, H*0.03 )
  70. ModelEntry:SetText( "models/props_debris/concrete_chunk04a.mdl" )
  71. ModelEntry.OnEnter = function( self )
  72. ModelIcon:SetModel(self:GetValue())
  73. ModelPreview:SetModel(self:GetValue())
  74. net.Start("Fact_EditorSendCheck")
  75. net.WriteString(self:GetValue())
  76. net.SendToServer()
  77. end
  78.  
  79. -- // RECEIVE THE CHECK REPORT FROM THE SERVER \\ --
  80. net.Receive("Fact_EditorReplyCheck", function(len)
  81. local NBool = net.ReadBool()
  82. Valid = NBool
  83. end)
  84.  
  85. -- // THE NAME ENTRY OF THE ITEM \\ --
  86. NameEntry = vgui.Create( "DTextEntry", EditorFrame )
  87. NameEntry:SetPos( W*0.86, H*0.32 )
  88. NameEntry:SetSize( W*0.1, H*0.025 )
  89. NameEntry:SetText( FactLang.Name )
  90. NameEntry:SetDrawBackground(false)
  91.  
  92. -- // INDEX OF THE MATERIAL \\ --
  93. IndexEntry = vgui.Create( "DTextEntry", EditorFrame )
  94. IndexEntry:SetPos( W*0.86, H*0.37 )
  95. IndexEntry:SetSize( W*0.1, H*0.025 )
  96. IndexEntry:SetText( "Index" )
  97. IndexEntry:SetDrawBackground(false)
  98.  
  99. -- // WEIGHT OF THE MATERIAL \\ --
  100. WeightEntry = vgui.Create( "DTextEntry", EditorFrame )
  101. WeightEntry:SetPos( W*0.86, H*0.42 )
  102. WeightEntry:SetSize( W*0.1, H*0.025 )
  103. WeightEntry:SetText( FactLang.Weight )
  104. WeightEntry:SetDrawBackground(false)
  105. WeightEntry.OnLoseFocus = function(self)
  106. local Weight = tonumber(self:GetValue())
  107. if ( not isnumber(Weight, 10)) then
  108. WeightEntry:SetText( FactLang.Weight )
  109. surface.PlaySound("factory/error2.ogg")
  110. end
  111. end
  112.  
  113. -- // CHECK IF ITEM IS FUEL \\ --
  114. -- FuelCheck = vgui.Create( "DCheckBox", EditorFrame )
  115. -- FuelCheck:SetPos( W*0.86, H*0.47 )
  116. -- FuelCheck:SetSize( W*0.01, H*0.017 )
  117. -- FuelCheck:SetValue( 0 )
  118.  
  119. -- // THE SAVE BUTTON \\ --
  120. local SaveItemBool = false
  121. SaveItem = vgui.Create( "DButton", EditorFrame )
  122. SaveItem:SetPos( W*0.85, H*0.5 )
  123. SaveItem:SetText( "" )
  124. SaveItem:SetFont( "Trebuchet24" )
  125. SaveItem:SetSize( W*0.125, H*0.05 )
  126. SaveItem.DoClick = function( Panel )
  127. if (Select == "") then surface.PlaySound("factory/error2.ogg") Error = "The material have no icon !" ErrorA = 255 return end
  128. local Weight = tonumber(WeightEntry:GetValue())
  129. if (not isnumber(Weight, 10) ) then surface.PlaySound("factory/error2.ogg") Error = "The weight is incorrect !" ErrorA = 255 return end
  130.  
  131. local Material =
  132. {
  133. Name = NameEntry:GetValue(),
  134. Color = GameMixer:GetColor(),
  135. Texture = MaterialEntry:GetValue(),
  136. Logo = Logo,
  137. LogoCol = Mixer:GetColor(),
  138. Model = ModelEntry:GetValue(),
  139. Stats = {},
  140. Weight = tonumber(WeightEntry:GetValue()),
  141. Index = string.lower(utf8.force(IndexEntry:GetValue())),
  142. }
  143. net.Start("Fact_EditorSaveMaterial")
  144. net.WriteTable(Material)
  145. net.SendToServer()
  146. EditorFrame:Remove()
  147. end
  148. SaveItem.Paint = function( Panel )
  149. if (SaveItemBool) then
  150. draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(50,200,50,255) )
  151. draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 255, 255, 255, 255 ), 1 )
  152. surface.SetDrawColor( Color(255,255,255,255) )
  153. surface.SetMaterial( Material("factory/ui/save.png") )
  154. surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
  155. else
  156. draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 70, 70, 70, 255 ), 1 )
  157. surface.SetDrawColor( Color(80,80,80,255) )
  158. surface.SetMaterial( Material("factory/ui/save.png") )
  159. surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
  160. end
  161. end
  162. SaveItem.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") SaveItemBool = true end
  163. SaveItem.OnCursorExited = function() SaveItemBool = false end
  164.  
  165. -- // THE CLOSE BUTTON \\ --
  166. local CloseMenuBool = false
  167. CloseMenu = vgui.Create( "DButton", EditorFrame )
  168. CloseMenu:SetPos( W*0.85, H*0.926)
  169. CloseMenu:SetText( "" )
  170. CloseMenu:SetFont( "Trebuchet24" )
  171. CloseMenu:SetSize( W*0.15, H*0.075 )
  172. CloseMenu.DoClick = function( Panel )
  173. surface.PlaySound("factory/move2.ogg")
  174. Fact_OpenEditor(data)
  175. end
  176. CloseMenu.Paint = function( Panel )
  177. if (CloseMenuBool) then
  178. draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(240,80,80,255) )
  179. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  180. else
  181. draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(80,80,80,255) )
  182. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  183. end
  184. end
  185. CloseMenu.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseMenuBool = true end
  186. CloseMenu.OnCursorExited = function() CloseMenuBool = false end
  187.  
  188. -- // COLOR MIXER ICON \\ --
  189. Mixer = vgui.Create( "DColorMixer", EditorFrame )
  190. Mixer:SetPos(W*0.28, H*0.48)
  191. Mixer:SetSize(W*0.1,H*0.1)
  192. Mixer:SetPalette( false )
  193. Mixer:SetAlphaBar( false )
  194. Mixer:SetWangs( false )
  195. Mixer:SetColor( Color( 255, 255, 255 ) )
  196.  
  197. -- // COLOR MIXER MODEL \\ --
  198. GameMixer = vgui.Create( "DColorMixer", EditorFrame )
  199. GameMixer:SetPos(W*0.5, H*0.36)
  200. GameMixer:SetSize(W*0.2,H*0.12)
  201. GameMixer:SetPalette( false )
  202. GameMixer:SetAlphaBar( false )
  203. GameMixer:SetWangs( false )
  204. GameMixer:SetColor( Color( 255, 255, 255 ) )
  205. GameMixer.ValueChanged = function()
  206. ModelPreview.Entity:SetColor( GameMixer:GetColor() )
  207. end
  208.  
  209. -- // 3D MODEL PREVIEW \\ --
  210. VFOV = 10
  211. ModelPreview = vgui.Create( "DModelPanel", EditorFrame )
  212. ModelPreview:SetPos( W*0.7, H*0.3 )
  213. ModelPreview:SetSize( W*0.1, H*0.18 )
  214. ModelPreview:SetModel( "models/props_debris/concrete_chunk04a.mdl" )
  215. ModelPreview:SetLookAt( ModelPreview.Entity:GetPos() )
  216. ModelPreview:SetFOV( VFOV )
  217. function ModelPreview:LayoutEntity( Entity )
  218. self:SetColor( GameMixer:GetColor() )
  219. Entity:SetAngles(Angle(0,RealTime()*50,0))
  220. return end
  221.  
  222. ------------------
  223. -- ZOOM BUTTONS --
  224. ------------------
  225.  
  226. -- // Zoom In \\ --
  227. ZoomIn = vgui.Create( "DButton", EditorFrame )
  228. ZoomIn:SetPos( W*0.8, H*0.3 )
  229. ZoomIn:SetText( "+" )
  230. ZoomIn:SetFont( "Trebuchet24" )
  231. ZoomIn:SetDrawBackground( 0 )
  232. ZoomIn:SetSize( W*0.025, H*0.05 )
  233. ZoomIn.DoClick = function( Panel )
  234. if VFOV > 10 then
  235. VFOV = VFOV - 10
  236. ModelPreview:SetFOV( VFOV )
  237. end
  238. end
  239.  
  240.  
  241. -- // Zoom Out \\ --
  242. ZoomOut = vgui.Create( "DButton", EditorFrame )
  243. ZoomOut:SetPos( W*0.8, H*0.36 )
  244. ZoomOut:SetText( "-" )
  245. ZoomOut:SetFont( "Trebuchet24" )
  246. ZoomOut:SetDrawBackground( 0 )
  247. ZoomOut:SetSize( W*0.025, H*0.05 )
  248. ZoomOut.DoClick = function( Panel )
  249. if VFOV < 120 then
  250. VFOV = VFOV + 10
  251. ModelPreview:SetFOV( VFOV )
  252. end
  253. end
  254.  
  255. -- // Zoom Reset \\ --
  256. ZoomReset = vgui.Create( "DButton", EditorFrame )
  257. ZoomReset:SetPos( W*0.8, H*0.42 )
  258. ZoomReset:SetText( "X" )
  259. ZoomReset:SetFont( "Trebuchet24" )
  260. ZoomReset:SetDrawBackground( 0 )
  261. ZoomReset:SetSize( W*0.025, H*0.05 )
  262. ZoomReset.DoClick = function( Panel )
  263. VFOV = 10
  264. ModelPreview:SetFOV( VFOV )
  265. end
  266.  
  267.  
  268. -- [[ MATERIALS LIST ]] --
  269. local MatList = {
  270. "phoenix_storms/cube",
  271. "models/props_foliage/tree_deciduous_01a_trunk",
  272. "models/shiny",
  273. "phoenix_storms/gear",
  274. "models/props_debris/plasterwall034a",
  275. "models/props_combine/metal_combinebridge001",
  276. "models/props_wasteland/rockcliff02b",
  277. "models/props_wasteland/rockcliff02a",
  278. }
  279. -----------------------------
  280. -- // MATERIALS BUTTONS \\ --
  281. local MatButtons = {}
  282. local bx,by = W*0.4, H*0.475
  283. for k , v in pairs (MatList) do
  284. MatButtons[k] = vgui.Create( "DModelPanel", EditorFrame )
  285. MatButtons[k]:SetPos( bx, by )
  286. MatButtons[k]:SetSize( W*0.106, H*0.18 )
  287. MatButtons[k]:SetModel( "models/props_debris/concrete_chunk04a.mdl" )
  288. MatButtons[k]:SetLookAt( MatButtons[k].Entity:GetPos() )
  289. MatButtons[k]:SetFOV(10)
  290. MatButtons[k].Entity:SetMaterial(v)
  291. MatButtons[k].DoClick = function()
  292. surface.PlaySound("factory/click2.ogg")
  293. ModelPreview.Entity:SetMaterial(v)
  294. MaterialEntry:SetText(v)
  295. end
  296.  
  297. bx = bx + W*0.106
  298. if bx > W*0.8 then
  299. bx = W*0.4
  300. by = by + H*0.18
  301. end
  302. end
  303.  
  304.  
  305. -- // MATERIAL ENTRY \\ --
  306. MaterialEntry = vgui.Create( "DTextEntry", EditorFrame )
  307. MaterialEntry:SetPos( W*0.4, H*0.87 )
  308. MaterialEntry:SetSize( W*0.425, H*0.03 )
  309. MaterialEntry:SetText( "" )
  310. MaterialEntry.OnEnter = function( self )
  311. ModelPreview.Entity:SetMaterial(self:GetValue())
  312. end
  313.  
  314. -- // THE ICON SCROLL MENU \\ --
  315. local IconScroll = vgui.Create( "DScrollPanel",EditorFrame )
  316. IconScroll:SetPos( W*0.05, H*0.3 )
  317. IconScroll:SetSize( W*0.22 - 1, H*0.6 )
  318. local sbar = IconScroll:GetVBar() -- CHANGE THE BAR COLOR
  319. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  320. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  321. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  322. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  323.  
  324. -- // ICON MENU \\ --
  325. Icon = {}
  326. x , y = 0, 0
  327. for k , v in pairs (FactMod.Icon) do
  328. Icon[k] = vgui.Create( "DButton", IconScroll )
  329. Icon[k]:SetPos( x, y )
  330. Icon[k]:SetText( "" )
  331. Icon[k]:SetFont( "Trebuchet24" )
  332. Icon[k]:SetSize( W*0.07, H*0.11 )
  333. Icon[k].Paint = function( Panel )
  334. if ( Material(v) ~= nil ) then
  335. if (Select == k) then
  336. surface.SetDrawColor( 255, 255, 255, 255 )
  337. else
  338. surface.SetDrawColor( 255, 255, 255, 50 )
  339. end
  340. surface.SetMaterial( Material(v) )
  341. surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
  342. if (Select == k) then
  343. surface.SetDrawColor( 255, 255, 255, 255 )
  344. surface.SetMaterial( Material("factory/ui/box.png") )
  345. surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
  346. end
  347. end
  348. end
  349. Icon[k].DoClick = function( Panel )
  350. surface.PlaySound("factory/click1.ogg")
  351. Select = k
  352. Logo = v
  353. end
  354. -- POSITION MANAGEMENT
  355. x = x + W*0.07
  356. if x > W*0.2 then x = 0 y = y + H*0.11 end
  357. end
  358.  
  359. if (selected) then
  360. ModelPreview:SetModel( selected.Model )
  361. ModelIcon:SetModel( selected.Model )
  362. WeightEntry:SetText( selected.Weight )
  363. NameEntry:SetText( selected.Name )
  364. IndexEntry:SetText( selected.Index )
  365. GameMixer:SetColor( selected.Color )
  366. Mixer:SetColor( selected.LogoCol )
  367. MaterialEntry:SetText( selected.Texture )
  368. ModelPreview.Entity:SetMaterial( selected.Texture )
  369. Logo, Select = selected.Logo, selected.Index
  370. end
  371.  
  372. -- \\ END // --
  373. end
  374.  
  375.  
  376. -- || ITEM EDITOR || --
  377. function Fact_OpenEditorItem( data )
  378. local W, H, Select, Valid, ActTab = ScrW(), ScrH(), "", true, {}
  379. if (EditorFrame) then EditorFrame:Remove() end
  380.  
  381. -- // CREATE THE MAIN LABEL \\ --
  382. EditorFrame = vgui.Create( "DFrame" )
  383. EditorFrame:SetPos( 0, 0 )
  384. EditorFrame:SetSize( W, H )
  385. EditorFrame:SetTitle( "" )
  386. EditorFrame:SetDraggable( false )
  387. EditorFrame:ShowCloseButton( false )
  388. EditorFrame:MakePopup()
  389. EditorFrame.Paint = function()
  390. draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,255) )
  391. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(255,127,0,255) )
  392. draw.RoundedBox( 0, 0, H*0.925, W, H*0.075, Color(0,10,30,255) )
  393. draw.DrawText( "ITEM EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  394.  
  395. -- // ICON \\ --
  396. draw.RoundedBox( 0, W*0.05, H*0.3, W*0.21, H*0.35, Color(0,0,0,255) )
  397. draw.RoundedBox( 0, W*0.05, H*0.25, W*0.21, H*0.05, Color(0,0,0,255) )
  398. draw.RoundedBox( 0, W*0.28, H*0.25, W*0.1, H*0.05, Color(0,0,0,255) )
  399. draw.RoundedBox( 0, W*0.28, H*0.3, W*0.1, H*0.17, Color(255,127,0,255) )
  400. draw.RoundedBox( 0, W*0.28, H*0.48, W*0.1, H*0.1, Color(0,0,0,255) )
  401. draw.DrawText( "ICON : " .. string.upper(Select), "Fact_Medium_Strong", W*0.16, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  402. draw.DrawText( "PREVIEW", "Fact_Medium_Strong", W*0.33, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  403. if (Select ~= "") then
  404. surface.SetDrawColor( Mixer:GetColor() )
  405. surface.SetMaterial( Material(FactMod.Icon[Select]) )
  406. surface.DrawTexturedRect( W*0.28, H*0.3, W*0.1, H*0.17 )
  407. end
  408.  
  409. -- // MODEL 3D \\ --
  410. draw.RoundedBox( 0, W*0.05, H*0.7, W*0.1, H*0.2, Color(80,80,90,255) )
  411. draw.RoundedBox( 0, W*0.15, H*0.7, W*0.235, H*0.2, Color(140,140,150,255) )
  412. draw.RoundedBox( 0, W*0.05, H*0.675, W*0.335, H*0.025, Color(50,50,100,255) )
  413. draw.DrawText( "Model 3D [Choose a path]", "Fact_Small_Strong", W*0.06, H*0.678, Color( 255, 255, 255, 200 ), 0 )
  414. if (Valid) then
  415. draw.DrawText( "This model is valid in the server side", "Fact_Small_Strong", W*0.155, H*0.71, Color( 0, 255, 0, 255 ), 0 )
  416. else
  417. draw.DrawText( "This model don't exist in the server side", "Fact_Small_Strong", W*0.155, H*0.71, Color( 255, 0, 0, 255 ), 0 )
  418. end
  419.  
  420. -- // ACTION \\ --
  421. draw.RoundedBox( 0, W*0.4, H*0.3, W*0.425, H*0.6, Color(130,130,130,255) )
  422. draw.RoundedBox( 0, W*0.4, H*0.25, W*0.425, H*0.05, Color(80,80,110,255) )
  423. draw.DrawText( "ACTION", "Fact_Medium_Strong", W*0.61, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  424.  
  425. -- // PARAMETERS \\ --
  426. draw.RoundedBox( 0, W*0.85, H*0.25, W*0.125, H*0.05, Color(80,80,110,255) )
  427. draw.RoundedBox( 0, W*0.85, H*0.3, W*0.125, H*0.25, Color(130,130,130,255) )
  428. draw.RoundedBox( 0, W*0.86, H*0.32, W*0.1, H*0.025, Color(240,240,240,255) )
  429. draw.RoundedBox( 0, W*0.86, H*0.37, W*0.1, H*0.025, Color(240,240,240,255) )
  430. draw.RoundedBox( 0, W*0.86, H*0.42, W*0.1, H*0.025, Color(240,240,240,255) )
  431. draw.DrawText( "PROPERTIES", "Fact_Medium_Strong", W*0.91, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  432. draw.DrawText( "Is this fuel ?", "Fact_Small", W*0.895, H*0.47, Color( 0, 0, 0, 255 ), 1 )
  433.  
  434. end
  435.  
  436. -- // PARAMETER BUTTONS \\ --
  437.  
  438. -- // HEALTH \\ --
  439. Heal = vgui.Create( "DButton", EditorFrame )
  440. Heal:SetPos( W*0.41, H*0.31 )
  441. Heal:SetText( "" )
  442. Heal:SetFont( "Trebuchet24" )
  443. Heal:SetSize( W*0.1, H*0.05 )
  444. Heal.Paint = function( Panel )
  445. draw.DrawText( "Heal", "DermaLarge", W*0.05, 0, Color( 255, 255, 255, 255 ), 1 )
  446. end
  447. Heal.DoClick = function( Panel )
  448. surface.PlaySound("factory/click1.ogg")
  449. ActionHealth()
  450. end
  451.  
  452. ---------------------
  453. -- HEALTH SETTINGS --
  454. ---------------------
  455. function ActionHealth()
  456. if (HealthSettings) then HealthSettings:Remove() end
  457. HealthSettings = vgui.Create( "DFrame" )
  458. HealthSettings:SetPos( 0, 0 )
  459. HealthSettings:SetSize( W, H )
  460. HealthSettings:SetTitle( "" )
  461. HealthSettings:SetDraggable( 0 )
  462. HealthSettings:MakePopup()
  463. HealthSettings.Paint = function( Panel )
  464. draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,230) )
  465. draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.2, Color(180,180,180,255) )
  466. draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.04, Color(50,150,50,255) )
  467. draw.DrawText( "Action : Health", "DermaLarge", W*0.36, H*0.4, Color( 255, 255, 255, 255 ), 0 )
  468. draw.DrawText( "How many heal this is gonna give ?", "ChatFont", W*0.465, H*0.45, Color( 255, 255, 255, 255 ), 0 )
  469. draw.DrawText( "What's the maximum health it can give ?", "ChatFont", W*0.465, H*0.49, Color( 255, 255, 255, 255 ), 0 )
  470. end
  471.  
  472. local HealthToAdd = vgui.Create( "DTextEntry", HealthSettings )
  473. HealthToAdd:SetPos( W*0.36, H*0.45 )
  474. HealthToAdd:SetSize( W*0.1, H*0.025 )
  475. HealthToAdd:SetText( "" )
  476.  
  477. local HealthMax = vgui.Create( "DTextEntry", HealthSettings )
  478. HealthMax:SetPos( W*0.36, H*0.49 )
  479. HealthMax:SetSize( W*0.1, H*0.025 )
  480. HealthMax:SetText( "" )
  481.  
  482. Add = vgui.Create( "DButton", HealthSettings )
  483. Add:SetPos( W*0.36, H*0.54 )
  484. Add:SetText( "Add" )
  485. Add:SetFont( "Trebuchet24" )
  486. Add:SetSize( W*0.075, H*0.05 )
  487. Add.DoClick = function( Panel )
  488. local HealthAdd = tonumber( HealthToAdd:GetValue(), 10 )
  489. local HealthMax = tonumber( HealthMax:GetValue(), 10 )
  490. if (HealthMax == nil) then HealthMax = 0 end
  491. if (isnumber(HealthAdd)) then
  492. ActTab[#ActTab + 1] =
  493. {
  494. Action = "Heal",
  495. AddHealth = HealthAdd,
  496. MaxHealth = HealthMax,
  497. }
  498. HealthSettings:Remove()
  499. AppList:AddLine( "Heal (" .. HealthAdd .. ") Max : " .. HealthMax )
  500. end
  501. end
  502.  
  503. Cancel = vgui.Create( "DButton", HealthSettings )
  504. Cancel:SetPos( W*0.45, H*0.54 )
  505. Cancel:SetText( "Cancel" )
  506. Cancel:SetFont( "Trebuchet24" )
  507. Cancel:SetSize( W*0.075, H*0.05 )
  508. Cancel.DoClick = function( Panel )
  509. HealthSettings:Remove()
  510. end
  511. end
  512.  
  513. -- // ARMOR \\ --
  514. Armor = vgui.Create( "DButton", EditorFrame )
  515. Armor:SetPos( W*0.41, H*0.36 )
  516. Armor:SetText( "" )
  517. Armor:SetFont( "Trebuchet24" )
  518. Armor:SetSize( W*0.1, H*0.05 )
  519. Armor.Paint = function( Panel )
  520. draw.DrawText( "Armor", "DermaLarge", W*0.05, 0, Color( 255, 255, 255, 255 ), 1 )
  521. end
  522. Armor.DoClick = function( Panel )
  523. surface.PlaySound("factory/click1.ogg")
  524. ActionArmor()
  525. end
  526.  
  527. --------------------
  528. -- ARMOR SETTINGS --
  529. --------------------
  530. function ActionArmor()
  531. if (ArmorSettings) then ArmorSettings:Remove() end
  532. ArmorSettings = vgui.Create( "DFrame" )
  533. ArmorSettings:SetPos( 0, 0 )
  534. ArmorSettings:SetSize( W, H )
  535. ArmorSettings:SetTitle( "" )
  536. ArmorSettings:SetDraggable( 0 )
  537. ArmorSettings:MakePopup()
  538. ArmorSettings.Paint = function( Panel )
  539. draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,230) )
  540. draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.2, Color(180,180,180,255) )
  541. draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.04, Color(50,50,150,255) )
  542. draw.DrawText( "Action : Armor", "DermaLarge", W*0.36, H*0.4, Color( 255, 255, 255, 255 ), 0 )
  543. draw.DrawText( "How many armor this is gonna give ?", "ChatFont", W*0.465, H*0.45, Color( 255, 255, 255, 255 ), 0 )
  544. draw.DrawText( "What's the maximum armor it can give ?", "ChatFont", W*0.465, H*0.49, Color( 255, 255, 255, 255 ), 0 )
  545. end
  546.  
  547. local ArmorToAdd = vgui.Create( "DTextEntry", ArmorSettings )
  548. ArmorToAdd:SetPos( W*0.36, H*0.45 )
  549. ArmorToAdd:SetSize( W*0.1, H*0.025 )
  550. ArmorToAdd:SetText( "" )
  551.  
  552. local ArmorMax = vgui.Create( "DTextEntry", ArmorSettings )
  553. ArmorMax:SetPos( W*0.36, H*0.49 )
  554. ArmorMax:SetSize( W*0.1, H*0.025 )
  555. ArmorMax:SetText( "" )
  556.  
  557. Add = vgui.Create( "DButton", ArmorSettings )
  558. Add:SetPos( W*0.36, H*0.54 )
  559. Add:SetText( "Add" )
  560. Add:SetFont( "Trebuchet24" )
  561. Add:SetSize( W*0.075, H*0.05 )
  562. Add.DoClick = function( Panel )
  563. local ArmorAdd = tonumber( ArmorToAdd:GetValue(), 10 )
  564. local ArmorMax = tonumber( ArmorMax:GetValue(), 10 )
  565. if (ArmorMax == nil) then ArmorMax = 0 end
  566. if (isnumber(ArmorAdd)) then
  567. ActTab[#ActTab + 1] =
  568. {
  569. Action = "Armor",
  570. AddArmor = ArmorAdd,
  571. MaxArmor = ArmorMax,
  572. }
  573. ArmorSettings:Remove()
  574. AppList:AddLine( "Armor (" .. ArmorAdd .. ") Max : " .. ArmorMax )
  575. end
  576. end
  577.  
  578. Cancel = vgui.Create( "DButton", ArmorSettings )
  579. Cancel:SetPos( W*0.45, H*0.54 )
  580. Cancel:SetText( "Cancel" )
  581. Cancel:SetFont( "Trebuchet24" )
  582. Cancel:SetSize( W*0.075, H*0.05 )
  583. Cancel.DoClick = function( Panel )
  584. ArmorSettings:Remove()
  585. end
  586. end
  587.  
  588.  
  589. -- // ACTION LIST \\ --
  590. AppList = vgui.Create( "DListView", EditorFrame )
  591. AppList:SetPos( W*0.55, H*0.31 )
  592. AppList:SetSize( W*0.2, H*0.475 )
  593. AppList:SetMultiSelect( false )
  594. AppList:AddColumn( "Action" )
  595.  
  596. -- // MODEL 3D PREVIEW \\ --
  597. ModelIcon = vgui.Create( "ModelImage", EditorFrame )
  598. ModelIcon:SetPos( W*0.05, H*0.7 )
  599. ModelIcon:SetSize( W*0.1, H*0.2 )
  600. ModelIcon:SetModel( "models/props_junk/cardboard_box001a.mdl" )
  601.  
  602. -- // MODEL 3D ENTRY \\ --
  603. ModelEntry = vgui.Create( "DTextEntry", EditorFrame )
  604. ModelEntry:SetPos( W*0.155, H*0.73 )
  605. ModelEntry:SetSize( W*0.2, H*0.03 )
  606. ModelEntry:SetText( "models/props_junk/cardboard_box001a.mdl" )
  607. ModelEntry.OnEnter = function( self )
  608. ModelIcon:SetModel(self:GetValue())
  609. net.Start("Fact_EditorSendCheck")
  610. net.WriteString(self:GetValue())
  611. net.SendToServer()
  612. end
  613.  
  614. net.Receive("Fact_EditorReplyCheck", function(len)
  615. local NBool = net.ReadBool()
  616. Valid = NBool
  617. end)
  618.  
  619.  
  620. -- // THE NAME ENTRY OF THE ITEM \\ --
  621. NameEntry = vgui.Create( "DTextEntry", EditorFrame )
  622. NameEntry:SetPos( W*0.86, H*0.32 )
  623. NameEntry:SetSize( W*0.1, H*0.025 )
  624. NameEntry:SetText( FactLang.Name )
  625. NameEntry:SetDrawBackground(false)
  626.  
  627. -- // INDEX OF THE MATERIAL \\ --
  628. IndexEntry = vgui.Create( "DTextEntry", EditorFrame )
  629. IndexEntry:SetPos( W*0.86, H*0.37 )
  630. IndexEntry:SetSize( W*0.1, H*0.025 )
  631. IndexEntry:SetText( "Index" )
  632. IndexEntry:SetDrawBackground(false)
  633.  
  634. -- // WEIGHT OF THE MATERIAL \\ --
  635. WeightEntry = vgui.Create( "DTextEntry", EditorFrame )
  636. WeightEntry:SetPos( W*0.86, H*0.42 )
  637. WeightEntry:SetSize( W*0.1, H*0.025 )
  638. WeightEntry:SetText( FactLang.Weight )
  639. WeightEntry:SetDrawBackground(false)
  640. WeightEntry.OnLoseFocus = function(self)
  641. local Weight = tonumber(self:GetValue())
  642. if ( not isnumber(Weight, 10)) then
  643. WeightEntry:SetText(FactLang.Weight)
  644. surface.PlaySound("factory/error2.ogg")
  645. end
  646. end
  647.  
  648. -- // CHECK IF ITEM IS FUEL \\ --
  649. FuelCheck = vgui.Create( "DCheckBox", EditorFrame )
  650. FuelCheck:SetPos( W*0.86, H*0.47 )
  651. FuelCheck:SetSize( W*0.01, H*0.017 )
  652. FuelCheck:SetValue( 0 )
  653.  
  654. -- COLOR MIXER
  655. Mixer = vgui.Create( "DColorMixer", EditorFrame )
  656. Mixer:SetPos(W*0.28, H*0.48)
  657. Mixer:SetSize(W*0.1,H*0.1)
  658. Mixer:SetPalette( false )
  659. Mixer:SetAlphaBar( false )
  660. Mixer:SetWangs( false )
  661. Mixer:SetColor( Color( 255, 255, 255 ) )
  662.  
  663. -- COLOR MIXER
  664. GameMixer = vgui.Create( "DColorMixer", EditorFrame )
  665. GameMixer:SetPos(W*0.155, H*0.77)
  666. GameMixer:SetSize(W*0.2,H*0.12)
  667. GameMixer:SetPalette( false )
  668. GameMixer:SetAlphaBar( false )
  669. GameMixer:SetWangs( false )
  670. GameMixer:SetColor( Color( 255, 255, 255 ) )
  671.  
  672. -- // ICON SCROLL LABEL \\ --
  673. IconScroll = vgui.Create( "DScrollPanel", EditorFrame )
  674. IconScroll:SetPos( W*0.05, H*0.3 )
  675. IconScroll:SetSize( W*0.22 - 1, H*0.35 )
  676.  
  677. -- // THE SAVE BUTTON \\ --
  678. local SaveItemBool = false
  679. SaveItem = vgui.Create( "DButton", EditorFrame )
  680. SaveItem:SetPos( W*0.85, H*0.5 )
  681. SaveItem:SetText( "" )
  682. SaveItem:SetFont( "Trebuchet24" )
  683. SaveItem:SetSize( W*0.125, H*0.05 )
  684. SaveItem.DoClick = function( Panel )
  685. if (Select == "") then surface.PlaySound("factory/error2.ogg") Error = "The material have no icon !" ErrorA = 255 return end
  686. local Weight = tonumber(WeightEntry:GetValue())
  687. if (not isnumber(Weight, 10) ) then surface.PlaySound("factory/error2.ogg") Error = "The weight is incorrect !" ErrorA = 255 return end
  688. local Material =
  689. {
  690. Name = NameID:GetValue(),
  691. Model = ModelEntry:GetValue(),
  692. Texture = FactMod.Icon[Select],
  693. TextureCol = Mixer:GetColor(),
  694. ActList = ActTab,
  695. }
  696. net.Start("Fact_EditorSaveMaterial")
  697. net.WriteTable(Material)
  698. net.SendToServer()
  699. EditorFrame:Remove()
  700. end
  701. SaveItem.Paint = function( Panel )
  702. if (SaveItemBool) then
  703. draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(50,200,50,255) )
  704. draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 255, 255, 255, 255 ), 1 )
  705. surface.SetDrawColor( Color(255,255,255,255) )
  706. surface.SetMaterial( Material("factory/ui/save.png") )
  707. surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
  708. else
  709. draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 70, 70, 70, 255 ), 1 )
  710. surface.SetDrawColor( Color(80,80,80,255) )
  711. surface.SetMaterial( Material("factory/ui/save.png") )
  712. surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
  713. end
  714. end
  715. SaveItem.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") SaveItemBool = true end
  716. SaveItem.OnCursorExited = function() SaveItemBool = false end
  717.  
  718. -- // THE CLOSE BUTTON \\ --
  719. local CloseMenuBool = false
  720. CloseMenu = vgui.Create( "DButton", EditorFrame )
  721. CloseMenu:SetPos( W*0.85, H*0.926)
  722. CloseMenu:SetText( "" )
  723. CloseMenu:SetFont( "Trebuchet24" )
  724. CloseMenu:SetSize( W*0.15, H*0.075 )
  725. CloseMenu.DoClick = function( Panel )
  726. surface.PlaySound("factory/move2.ogg")
  727. Fact_OpenEditor()
  728. end
  729. CloseMenu.Paint = function( Panel )
  730. if (CloseMenuBool) then
  731. draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(240,80,80,255) )
  732. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  733. else
  734. draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(80,80,80,255) )
  735. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  736. end
  737. end
  738. CloseMenu.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseMenuBool = true end
  739. CloseMenu.OnCursorExited = function() CloseMenuBool = false end
  740.  
  741.  
  742. -- CHANGE THE BAR COLOR
  743. local sbar = IconScroll:GetVBar()
  744. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  745. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  746. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  747. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  748.  
  749. Icon = {}
  750. x , y = 0, 0
  751. for k , v in pairs (FactMod.Icon) do
  752. Icon[k] = vgui.Create( "DButton", IconScroll )
  753. Icon[k]:SetPos( x, y )
  754. Icon[k]:SetText( "" )
  755. Icon[k]:SetFont( "Trebuchet24" )
  756. Icon[k]:SetSize( W*0.07, H*0.11 )
  757. Icon[k].Paint = function( Panel )
  758. if ( Material(v) ~= nil ) then
  759. if Select == k then
  760. surface.SetDrawColor( 255, 255, 255, 255 )
  761. else
  762. surface.SetDrawColor( 255, 255, 255, 50 )
  763. end
  764. surface.SetMaterial( Material(v) )
  765. surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
  766. if Select == k then
  767. surface.SetDrawColor( 255, 255, 255, 255 )
  768. surface.SetMaterial( Material("factory/ui/box.png") )
  769. surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
  770. end
  771. end
  772. end
  773. Icon[k].DoClick = function( Panel )
  774. surface.PlaySound("factory/click2.ogg")
  775. Select = k
  776. end
  777. x = x + W*0.07
  778. if x > W*0.2 then
  779. x = 0
  780. y = y + H*0.11
  781. end
  782. end
  783. end
  784.  
  785.  
  786. -- || MATERIAL LIST EDITOR || --
  787. function Fact_OpenMaterialsList( data )
  788. local W, H, Selected = ScrW(), ScrH(), ""
  789. if (EditorFrame) then EditorFrame:Remove() end
  790.  
  791. -- // CREATE THE MAIN LABEL \\ --
  792. EditorFrame = vgui.Create( "DFrame" )
  793. EditorFrame:SetPos( 0, 0 )
  794. EditorFrame:SetSize( W, H )
  795. EditorFrame:SetTitle( "" )
  796. EditorFrame:SetDraggable( false )
  797. EditorFrame:ShowCloseButton( false )
  798. EditorFrame:MakePopup()
  799. EditorFrame.Paint = function()
  800. draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
  801. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
  802. draw.RoundedBox( 0, 0, H*0.2, W*0.205, H*0.8, Color(20,20,20,255) )
  803. draw.RoundedBox( 0, W*0.205, H*0.924, W*0.795, H*0.75, Color(50,50,50,255) )
  804. draw.DrawText( "MATERIALS LIST", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  805. end
  806.  
  807. -- // ICON SCROLL LABEL \\ --
  808. IconScroll = vgui.Create( "DScrollPanel", EditorFrame )
  809. IconScroll:SetPos( 0, H*0.2 )
  810. IconScroll:SetSize( W*0.21, H*0.8 )
  811. local sbar = IconScroll:GetVBar()
  812. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  813. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  814. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  815. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  816.  
  817.  
  818. local x , y = 0,0
  819. Button = {}
  820. for k , v in pairs (data.Materials) do
  821. Button[k] = vgui.Create( "DButton", IconScroll )
  822. Button[k]:SetPos( x, y )
  823. Button[k]:SetText( "" )
  824. Button[k]:SetSize( W*0.2, H*0.1 )
  825. Button[k].Paint = function( Panel )
  826. draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(130,130,140,255) )
  827. draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
  828. draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
  829. draw.DrawText( "Index [" .. v.Index .. "]", "Fact_Medium", W*0.065, H*0.04, Color( 255, 255, 255, 255 ), 0 )
  830. draw.DrawText( v.Weight .. "Kg", "Fact_Small_Strong", W*0.065, H*0.08, Color( 255, 255, 255, 255 ), 0 )
  831. surface.SetDrawColor( v.LogoCol )
  832. surface.SetMaterial( Material(v.Logo) )
  833. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  834.  
  835. if (Selected == v.Index) then
  836. surface.SetDrawColor( Color(255,255,255,255) )
  837. surface.SetMaterial( Material("factory/ui/box.png") )
  838. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  839. end
  840. end
  841. Button[k].DoClick = function( Panel )
  842. surface.PlaySound("factory/click1.ogg")
  843. Selected = v.Index
  844. end
  845. y = (y + H*0.1) + 1
  846. end
  847.  
  848. --> EDIT THE MATERIAL BUTTON :
  849. Edit = vgui.Create( "DButton", EditorFrame )
  850. Edit:SetPos( W*0.35, H*0.3)
  851. Edit:SetText( "" )
  852. Edit:SetFont( "Trebuchet24" )
  853. Edit:SetSize( W*0.25, H*0.45 )
  854. Edit.DoClick = function( Panel )
  855. if (Selected ~= "") then
  856. surface.PlaySound("factory/move3.ogg")
  857. EditorFrame:Remove()
  858. Fact_OpenEditorMaterials(data , data.Materials[Selected])
  859. else
  860. surface.PlaySound("factory/error2.ogg")
  861. end
  862. end
  863. Edit.Paint = function( Panel )
  864. if (Selected ~= "") then
  865. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,180,80,255) )
  866. draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
  867. surface.SetDrawColor( Color(255,255,255,255) )
  868. surface.SetMaterial( Material("factory/ui/usable.png") )
  869. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  870. else
  871. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,80,80,255) )
  872. draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
  873. surface.SetDrawColor( Color(150,150,150,255) )
  874. surface.SetMaterial( Material("factory/ui/usable.png") )
  875. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  876. end
  877. end
  878.  
  879.  
  880.  
  881. --> REMOVE THE MATERIAL BUTTON :
  882. Remove = vgui.Create( "DButton", EditorFrame )
  883. Remove:SetPos( W*0.65, H*0.3)
  884. Remove:SetText( "" )
  885. Remove:SetFont( "Trebuchet24" )
  886. Remove:SetSize( W*0.25, H*0.45 )
  887. Remove.DoClick = function( Panel )
  888. if (Selected ~= "") then
  889. surface.PlaySound("factory/move3.ogg")
  890. EditorFrame:Remove()
  891. net.Start("Fact_EditorRemoveMaterial")
  892. net.WriteTable( data.Materials[Selected] )
  893. net.SendToServer()
  894. else
  895. surface.PlaySound("factory/error2.ogg")
  896. end
  897. end
  898. Remove.Paint = function( Panel )
  899. if (Selected ~= "") then
  900. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(180,80,80,255) )
  901. draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
  902. surface.SetDrawColor( Color(255,255,255,255) )
  903. surface.SetMaterial( Material("factory/ui/cancel.png") )
  904. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  905. else
  906. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45 , Color(80,80,80,255) )
  907. draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
  908. surface.SetDrawColor( Color(150,150,150,255) )
  909. surface.SetMaterial( Material("factory/ui/cancel.png") )
  910. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  911. end
  912. end
  913.  
  914. local CloseBBool = false
  915. CloseB = vgui.Create( "DButton", EditorFrame )
  916. CloseB:SetPos( W*0.9, H*0.925)
  917. CloseB:SetText( "" )
  918. CloseB:SetFont( "Trebuchet24" )
  919. CloseB:SetSize( W*0.1, H*0.075 )
  920. CloseB.DoClick = function( Panel )
  921. surface.PlaySound("factory/move2.ogg")
  922. EditorFrame:Remove()
  923. Fact_OpenEditor(data)
  924. end
  925. CloseB.Paint = function( Panel )
  926. if (CloseBBool) then
  927. draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(180,80,80,255) )
  928. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  929. else
  930. draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(80,80,80,255) )
  931. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  932. end
  933. end
  934. CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
  935. CloseB.OnCursorExited = function() CloseBBool = false end
  936.  
  937. end
  938.  
  939.  
  940. -- || RECIPE LIST EDITOR || --
  941. function Fact_OpenRecipeList( data )
  942. local W, H, Selected = ScrW(), ScrH(), ""
  943. if (EditorFrame) then EditorFrame:Remove() end
  944.  
  945. -- // CREATE THE MAIN LABEL \\ --
  946. EditorFrame = vgui.Create( "DFrame" )
  947. EditorFrame:SetPos( 0, 0 )
  948. EditorFrame:SetSize( W, H )
  949. EditorFrame:SetTitle( "" )
  950. EditorFrame:SetDraggable( false )
  951. EditorFrame:ShowCloseButton( false )
  952. EditorFrame:MakePopup()
  953. EditorFrame.Paint = function()
  954. draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
  955. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
  956. draw.RoundedBox( 0, 0, H*0.2, W*0.205, H*0.8, Color(20,20,20,255) )
  957. draw.RoundedBox( 0, W*0.205, H*0.924, W*0.795, H*0.75, Color(50,50,50,255) )
  958. draw.DrawText( "MATERIALS LIST", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  959. end
  960.  
  961. -- // ICON SCROLL LABEL \\ --
  962. IconScroll = vgui.Create( "DScrollPanel", EditorFrame )
  963. IconScroll:SetPos( 0, H*0.2 )
  964. IconScroll:SetSize( W*0.21, H*0.8 )
  965. local sbar = IconScroll:GetVBar()
  966. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  967. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  968. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  969. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  970.  
  971. local x , y = 0,0
  972. Button = {}
  973. for k , v in pairs (data.Recipe) do
  974. Button[k] = vgui.Create( "DButton", IconScroll )
  975. Button[k]:SetPos( x, y )
  976. Button[k]:SetText( "" )
  977. Button[k]:SetSize( W*0.2, H*0.1 )
  978. Button[k].Paint = function( Panel )
  979. draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(130,130,140,255) )
  980. draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
  981. draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
  982. draw.DrawText( "[" .. v.Index .. "]", "Fact_Small_Strong", W*0.065, H*0.04, Color( 255, 255, 255, 255 ), 0 )
  983. surface.SetDrawColor( v.LogoCol )
  984. surface.SetMaterial( Material(v.Logo) )
  985. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  986.  
  987. if (Selected == v.Index) then
  988. surface.SetDrawColor( Color(255,255,255,255) )
  989. surface.SetMaterial( Material("factory/ui/box.png") )
  990. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  991. end
  992. end
  993. Button[k].DoClick = function( Panel )
  994. surface.PlaySound("factory/click1.ogg")
  995. Selected = v.Index
  996. RLOAD = v
  997. PrintTable(v)
  998. end
  999. y = (y + H*0.1) + 1
  1000. end
  1001.  
  1002. --> EDIT THE RECIPE BUTTON :
  1003. Edit = vgui.Create( "DButton", EditorFrame )
  1004. Edit:SetPos( W*0.35, H*0.3)
  1005. Edit:SetText( "" )
  1006. Edit:SetFont( "Trebuchet24" )
  1007. Edit:SetSize( W*0.25, H*0.45 )
  1008. Edit.DoClick = function( Panel )
  1009. if (Selected ~= "") then
  1010. surface.PlaySound("factory/move3.ogg")
  1011. EditorFrame:Remove()
  1012. Fact_OpenRecipeEditor(data , RLOAD)
  1013. else
  1014. surface.PlaySound("factory/error2.ogg")
  1015. end
  1016. end
  1017. Edit.Paint = function( Panel )
  1018. if (Selected ~= "") then
  1019. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,180,80,255) )
  1020. draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
  1021. surface.SetDrawColor( Color(255,255,255,255) )
  1022. surface.SetMaterial( Material("factory/ui/usable.png") )
  1023. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  1024. else
  1025. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,80,80,255) )
  1026. draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
  1027. surface.SetDrawColor( Color(150,150,150,255) )
  1028. surface.SetMaterial( Material("factory/ui/usable.png") )
  1029. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  1030. end
  1031. end
  1032.  
  1033.  
  1034.  
  1035. --> REMOVE THE RECIPE BUTTON :
  1036. Remove = vgui.Create( "DButton", EditorFrame )
  1037. Remove:SetPos( W*0.65, H*0.3)
  1038. Remove:SetText( "" )
  1039. Remove:SetFont( "Trebuchet24" )
  1040. Remove:SetSize( W*0.25, H*0.45 )
  1041. Remove.DoClick = function( Panel )
  1042. if (Selected ~= "") then
  1043. surface.PlaySound("factory/move3.ogg")
  1044. EditorFrame:Remove()
  1045. net.Start("Fact_EditorRemoveRecipe")
  1046. net.WriteTable( data.Recipe[Selected] )
  1047. net.SendToServer()
  1048. else
  1049. surface.PlaySound("factory/error2.ogg")
  1050. end
  1051. end
  1052. Remove.Paint = function( Panel )
  1053. if (Selected ~= "") then
  1054. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(180,80,80,255) )
  1055. draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
  1056. surface.SetDrawColor( Color(255,255,255,255) )
  1057. surface.SetMaterial( Material("factory/ui/cancel.png") )
  1058. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  1059. else
  1060. draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45 , Color(80,80,80,255) )
  1061. draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
  1062. surface.SetDrawColor( Color(150,150,150,255) )
  1063. surface.SetMaterial( Material("factory/ui/cancel.png") )
  1064. surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
  1065. end
  1066. end
  1067.  
  1068. local CloseBBool = false
  1069. CloseB = vgui.Create( "DButton", EditorFrame )
  1070. CloseB:SetPos( W*0.9, H*0.925)
  1071. CloseB:SetText( "" )
  1072. CloseB:SetFont( "Trebuchet24" )
  1073. CloseB:SetSize( W*0.1, H*0.075 )
  1074. CloseB.DoClick = function( Panel )
  1075. surface.PlaySound("factory/move2.ogg")
  1076. EditorFrame:Remove()
  1077. Fact_OpenEditor(data)
  1078. end
  1079. CloseB.Paint = function( Panel )
  1080. if (CloseBBool) then
  1081. draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(180,80,80,255) )
  1082. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1083. else
  1084. draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(80,80,80,255) )
  1085. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1086. end
  1087. end
  1088. CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
  1089. CloseB.OnCursorExited = function() CloseBBool = false end
  1090.  
  1091. end
  1092.  
  1093.  
  1094. -- || RECIPE EDITOR || --
  1095. function Fact_OpenRecipeEditor( data, loaded )
  1096. local W, H = ScrW(), ScrH(), "", {}, {}, true, "", "", {txt = "", alpha = 0}
  1097. local Selected, Ingredients, IngredientsB = "", {}, {}
  1098. local Logo, IconName, Error = "", "", {txt = "", alpha = 0}
  1099.  
  1100. if (EditorFrame) then EditorFrame:Remove() end
  1101.  
  1102. -- // CREATE THE MAIN LABEL \\ --
  1103. EditorFrame = vgui.Create( "DFrame" )
  1104. EditorFrame:SetPos( 0, 0 )
  1105. EditorFrame:SetSize( W, H )
  1106. EditorFrame:SetTitle( "" )
  1107. EditorFrame:SetDraggable( false )
  1108. EditorFrame:ShowCloseButton( false )
  1109. EditorFrame:MakePopup()
  1110. EditorFrame.Paint = function()
  1111. draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
  1112. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
  1113. draw.DrawText( "RECIPE EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  1114.  
  1115. draw.RoundedBox( 0, W*0.05, H*0.3, W*0.2, H*0.65, Color(70,70,70,255) )
  1116. draw.RoundedBox( 0, W*0.05, H*0.25, W*0.2, H*0.05, Color(80,80,150,255) )
  1117. draw.DrawText( "MATERIALS", "Fact_Medium_Strong", W*0.15, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  1118.  
  1119. draw.RoundedBox( 0, W*0.3, H*0.3, W*0.18 + 3, H*0.3, Color(110,110,110,255) )
  1120. draw.RoundedBox( 0, W*0.3, H*0.25, W*0.18 + 3, H*0.05, Color(80,80,150,255) )
  1121. draw.DrawText( "INGREDIENTS", "Fact_Medium_Strong", W*0.39, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  1122.  
  1123. draw.RoundedBox( 0, W*0.55, H*0.3, W*0.21, H*0.41, Color(110,110,110,255) )
  1124. draw.RoundedBox( 0, W*0.55, H*0.25, W*0.21, H*0.05, Color(80,80,150,255) )
  1125. draw.DrawText( "ICON : " .. string.upper(IconName), "Fact_Medium_Strong", W*0.66, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  1126.  
  1127. draw.RoundedBox( 0, W*0.8, H*0.3, W*0.15, H*0.25, Color(110,110,110,255) )
  1128. draw.RoundedBox( 0, W*0.8, H*0.25, W*0.15, H*0.05, Color(80,80,150,255) )
  1129. draw.RoundedBox( 0, W*0.8, H*0.56, W*0.15, H*0.15, Color(110,110,110,255) )
  1130. draw.DrawText( "PREVIEW", "Fact_Medium_Strong", W*0.875, H*0.255, Color( 255, 255, 255, 255 ), 1 )
  1131. if (Logo ~= "") then
  1132. surface.SetDrawColor( Mixer:GetColor() )
  1133. surface.SetMaterial( Material(Logo) )
  1134. surface.DrawTexturedRect( W*0.8 , H*0.3, W*0.15, H*0.25 )
  1135. end
  1136.  
  1137. draw.RoundedBox( 0, W*0.3, H*0.7, W*0.18 + 3, H*0.25, Color(110,110,110,255) )
  1138. draw.RoundedBox( 0, W*0.3, H*0.65, W*0.18 + 3, H*0.05, Color(80,80,150,255) )
  1139. draw.RoundedBox( 0, W*0.32, H*0.725, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
  1140. draw.RoundedBox( 0, W*0.32, H*0.775, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
  1141. draw.RoundedBox( 0, W*0.32, H*0.825, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
  1142. -- draw.RoundedBox( 0, W*0.32, H*0.875, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
  1143. draw.DrawText( "INFORMATION", "Fact_Medium_Strong", W*0.39, H*0.655, Color( 255, 255, 255, 255 ), 1 )
  1144. draw.DrawText( Error.txt, "Fact_High_Strong", W*0.5, H*0.14, Color( 255, 0, 0, Error.num ), 1 )
  1145. end
  1146.  
  1147. --> MATERIAL SCROLL DERMA :
  1148. MaterialScroll = vgui.Create( "DScrollPanel", EditorFrame )
  1149. MaterialScroll:SetPos( W*0.05, H*0.3 )
  1150. MaterialScroll:SetSize( W*0.21, H*0.65 )
  1151. local sbar = MaterialScroll:GetVBar()
  1152. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1153. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  1154. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1155. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1156.  
  1157. --> THE MATERIALS TABLE :
  1158. local x , y = 0,0
  1159. MatB = {}
  1160. for k , v in pairs (data.Materials) do
  1161. MatB[k] = vgui.Create( "DButton", MaterialScroll )
  1162. MatB[k]:SetPos( x, y )
  1163. MatB[k]:SetText( "" )
  1164. MatB[k]:SetSize( W*0.2, H*0.1 )
  1165. MatB[k].Paint = function( Panel )
  1166. draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(120,120,140,255) )
  1167. draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
  1168. draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
  1169. draw.DrawText( "Index [" .. v.Index .. "]", "Fact_Medium", W*0.065, H*0.04, Color( 255, 255, 255, 255 ), 0 )
  1170. draw.DrawText( v.Weight .. "Kg", "Fact_Small_Strong", W*0.065, H*0.07, Color( 255, 255, 255, 255 ), 0 )
  1171. surface.SetDrawColor( v.LogoCol )
  1172. surface.SetMaterial( Material(v.Logo) )
  1173. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  1174.  
  1175. if (Selected == v.Index) then
  1176. surface.SetDrawColor( Color(255,255,255,255) )
  1177. surface.SetMaterial( Material("factory/ui/box.png") )
  1178. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  1179. end
  1180. end
  1181. MatB[k].DoClick = function( Panel )
  1182. surface.PlaySound("factory/click1.ogg")
  1183. if (Ingredients[v.Index]) then
  1184. Ingredients[v.Index]["Amount"] = Ingredients[v.Index]["Amount"] + 1
  1185. else
  1186. Ingredients[v.Index] = v
  1187. Ingredients[v.Index]["Amount"] = 1
  1188. ResetList()
  1189. end
  1190. end
  1191. y = (y + H*0.1) + 1
  1192. end
  1193.  
  1194. --> COLOR MIXER ICON :
  1195. Mixer = vgui.Create( "DColorMixer", EditorFrame )
  1196. Mixer:SetPos( W*0.8, H*0.56 )
  1197. Mixer:SetSize( W*0.15,H*0.15 )
  1198. Mixer:SetPalette( false )
  1199. Mixer:SetAlphaBar( false )
  1200. Mixer:SetWangs( false )
  1201. Mixer:SetColor( Color( 255, 255, 255 ) )
  1202.  
  1203. --> THE ICON SCROLL MENU :
  1204. local IconScroll = vgui.Create( "DScrollPanel",EditorFrame )
  1205. IconScroll:SetPos( W*0.55, H*0.3 )
  1206. IconScroll:SetSize( W*0.22 - 1, H*0.41 )
  1207. local sbar = IconScroll:GetVBar() -- CHANGE THE BAR COLOR
  1208. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1209. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  1210. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1211. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1212.  
  1213. --> ICON MENU :
  1214. Icon, x , y = {}, 0, 0
  1215. for k , v in pairs (FactMod.Icon) do
  1216. Icon[k] = vgui.Create( "DButton", IconScroll )
  1217. Icon[k]:SetPos( x, y )
  1218. Icon[k]:SetText( "" )
  1219. Icon[k]:SetFont( "Trebuchet24" )
  1220. Icon[k]:SetSize( W*0.07, H*0.11 )
  1221. Icon[k].Paint = function( Panel )
  1222. if ( Material(v) ~= nil ) then
  1223. if (Logo == v) then
  1224. surface.SetDrawColor( 255, 255, 255, 255 )
  1225. else
  1226. surface.SetDrawColor( 255, 255, 255, 50 )
  1227. end
  1228. surface.SetMaterial( Material(v) )
  1229. surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
  1230. if (Logo == v) then
  1231. surface.SetDrawColor( 255, 255, 255, 255 )
  1232. surface.SetMaterial( Material("factory/ui/box.png") )
  1233. surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
  1234. end
  1235. end
  1236. end
  1237. Icon[k].DoClick = function( Panel )
  1238. surface.PlaySound("factory/click1.ogg")
  1239. Logo = v
  1240. IconName = k
  1241. end
  1242. -- POSITION MANAGEMENT
  1243. x = x + W*0.07
  1244. if x > W*0.2 then x = 0 y = y + H*0.11 end
  1245. end
  1246.  
  1247. --> THE RECIPE NAME :
  1248. local NameEntry = vgui.Create( "DTextEntry", EditorFrame )
  1249. NameEntry:SetPos( W*0.32, H*0.725 )
  1250. NameEntry:SetSize( W*0.14 + 3, H*0.025 )
  1251. NameEntry:SetText( FactLang.Name )
  1252. NameEntry:SetFont( "Fact_Small_Strong" )
  1253. NameEntry:SetDrawBorder(false)
  1254. NameEntry:SetDrawBackground(false)
  1255. NameEntry.OnGetFocus = function(self)
  1256. self:SetText("")
  1257. end
  1258. NameEntry.OnLoseFocus = function(self)
  1259. if (self:GetValue() == "") then
  1260. self:SetText( FactLang.Name ) end
  1261. end
  1262.  
  1263. --> THE ENTITY CLASS :
  1264. local EntityEntry = vgui.Create( "DTextEntry", EditorFrame )
  1265. EntityEntry:SetPos( W*0.32, H*0.775 )
  1266. EntityEntry:SetSize( W*0.14 + 3, H*0.025 )
  1267. EntityEntry:SetText( "Class" )
  1268. EntityEntry:SetFont( "Fact_Small_Strong" )
  1269. EntityEntry:SetDrawBorder(false)
  1270. EntityEntry:SetDrawBackground(false)
  1271. EntityEntry.OnGetFocus = function(self)
  1272. self:SetText("")
  1273. end
  1274. EntityEntry.OnLoseFocus = function(self)
  1275. if (self:GetValue() == "") then
  1276. self:SetText( "Class" ) end
  1277. end
  1278.  
  1279. --> INDEX OG THE ENTITY :
  1280. local IndexEntry = vgui.Create( "DTextEntry", EditorFrame )
  1281. IndexEntry:SetPos( W*0.32, H*0.825 )
  1282. IndexEntry:SetSize( W*0.14 + 3, H*0.025 )
  1283. IndexEntry:SetText( "Index" )
  1284. IndexEntry:SetFont( "Fact_Small_Strong" )
  1285. IndexEntry:SetDrawBorder(false)
  1286. IndexEntry:SetDrawBackground(false)
  1287. IndexEntry.OnGetFocus = function(self)
  1288. self:SetText("")
  1289. end
  1290. IndexEntry.OnLoseFocus = function(self)
  1291. if (self:GetValue() == "") then
  1292. self:SetText( "Index" ) end
  1293. end
  1294.  
  1295. --> HOW MANY IT WILL CRAFT FOR 1 RECIPE :
  1296. -- local AmountEntry = vgui.Create( "DTextEntry", EditorFrame )
  1297. -- AmountEntry:SetPos( W*0.32, H*0.875 )
  1298. -- AmountEntry:SetSize( W*0.14 - 3, H*0.025 )
  1299. -- AmountEntry:SetText( FactLang.Amount )
  1300. -- AmountEntry:SetFont( "Fact_Small_Strong" )
  1301. -- AmountEntry:SetDrawBorder(false)
  1302. -- AmountEntry:SetDrawBackground(false)
  1303. -- AmountEntry.OnGetFocus = function(self)
  1304. -- self:SetText("")
  1305. -- end
  1306. -- AmountEntry.OnLoseFocus = function(self)
  1307. -- local TheAmount = tonumber(self:GetValue())
  1308. -- if ( not isnumber(TheAmount, 10)) then
  1309. -- AmountEntry:SetText(FactLang.Amount)
  1310. -- surface.PlaySound("factory/error2.ogg")
  1311. -- Error.txt = "The Amount is not a number !"
  1312. -- Error.alpha = 255
  1313. -- end
  1314. -- end
  1315.  
  1316. --> CLOSE BUTTON :
  1317. local CloseBBool = false
  1318. CloseB = vgui.Create( "DButton", EditorFrame )
  1319. CloseB:SetPos( W*0.55, H*0.85 )
  1320. CloseB:SetText( "" )
  1321. CloseB:SetSize( W*0.4, H*0.075 )
  1322. CloseB.DoClick = function( Panel )
  1323. surface.PlaySound("factory/move2.ogg")
  1324. Fact_OpenEditor(data)
  1325. end
  1326. CloseB.Paint = function( Panel )
  1327. if (CloseBBool) then
  1328. draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(180,80,80,255) )
  1329. draw.DrawText( FactLang.Close, "Fact_High_Strong", W*0.2, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
  1330. else
  1331. draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(80,80,80,255) )
  1332. draw.DrawText( FactLang.Close, "Fact_High_Strong", W*0.2, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
  1333. end
  1334. end
  1335. CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
  1336. CloseB.OnCursorExited = function() CloseBBool = false end
  1337.  
  1338. --> VALID BUTTON :
  1339. local ValidBBool = false
  1340. ValidB = vgui.Create( "DButton", EditorFrame )
  1341. ValidB:SetPos( W*0.55, H*0.75 )
  1342. ValidB:SetText( "" )
  1343. ValidB:SetSize( W*0.4, H*0.075 )
  1344. ValidB.DoClick = function( Panel )
  1345. if (table.Count( Ingredients ) <= 0) then
  1346. surface.PlaySound("factory/error2.ogg")
  1347. Error.txt = "There's no ingredient !"
  1348. Error.alpha = 255
  1349. return end
  1350. if (Logo == "") then
  1351. surface.PlaySound("factory/error2.ogg")
  1352. Error.txt = "There's no Logo !"
  1353. Error.alpha = 255
  1354. return end
  1355.  
  1356. local ingredientTable = {}
  1357. for k , v in pairs (Ingredients) do
  1358. ingredientTable[v.Index] = Ingredients[v.Index]["Amount"]
  1359. end
  1360. PrintTable(ingredientTable)
  1361. local Recipe =
  1362. {
  1363. Ingredient = ingredientTable,
  1364. Result = {
  1365. Class = EntityEntry:GetValue(),
  1366. },
  1367. Name = NameEntry:GetValue(),
  1368. Index = IndexEntry:GetValue(),
  1369. Logo = Logo,
  1370. LogoCol = Mixer:GetColor(),
  1371. }
  1372.  
  1373. net.Start("Fact_EditorSaveRecipe")
  1374. net.WriteTable(Recipe)
  1375. net.SendToServer()
  1376.  
  1377. surface.PlaySound("factory/move2.ogg")
  1378. EditorFrame:Remove()
  1379. end
  1380. ValidB.Paint = function( Panel )
  1381. if (ValidBBool) then
  1382. draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(80,180,80,255) )
  1383. draw.DrawText( FactLang.Save, "Fact_High_Strong", W*0.2, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
  1384. else
  1385. draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(80,80,80,255) )
  1386. draw.DrawText( FactLang.Save, "Fact_High_Strong", W*0.2, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
  1387. end
  1388. end
  1389. ValidB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") ValidBBool = true end
  1390. ValidB.OnCursorExited = function() ValidBBool = false end
  1391.  
  1392. -- // ICON SCROLL LABEL \\ --
  1393. IngredientsS = vgui.Create( "DScrollPanel", EditorFrame )
  1394. IngredientsS:SetPos( W*0.3, H*0.3 )
  1395. IngredientsS:SetSize( W*0.19, H*0.3 )
  1396. local sbar = IngredientsS:GetVBar()
  1397. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1398. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  1399. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1400. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1401.  
  1402. --> RESET THE LIST :
  1403. function ResetList()
  1404. for k,v in pairs (IngredientsB) do IngredientsB[k]:Remove() end
  1405. local x , y = 0,0
  1406. for k , v in pairs (Ingredients) do
  1407. IngredientsB[k] = vgui.Create( "DButton", IngredientsS )
  1408. IngredientsB[k]:SetPos( x, y )
  1409. IngredientsB[k]:SetText( "" )
  1410. IngredientsB[k]:SetSize( W*0.06, H*0.1 )
  1411. IngredientsB[k].Paint = function( Panel )
  1412. -- draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(120,120,120,255) )
  1413. surface.SetDrawColor( Color(70,70,70,255))
  1414. surface.SetMaterial( Material(v.Logo) )
  1415. surface.DrawTexturedRect( 3, 3, W*0.06, H*0.1 )
  1416.  
  1417. surface.SetDrawColor( v.LogoCol )
  1418. surface.SetMaterial( Material(v.Logo) )
  1419. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  1420. draw.DrawText( v.Name, "Fact_Small_Strong", 5, H*0.01, Color( 255, 255, 255, 255 ), 0 )
  1421. draw.DrawText( "x" .. v.Amount, "Fact_Medium_Strong", 7, H*0.06, Color( 80, 80, 80, 255 ), 0 )
  1422. draw.DrawText( "x" .. v.Amount, "Fact_Medium_Strong", 5, H*0.06, Color( 255, 255, 255, 255 ), 0 )
  1423. end
  1424. IngredientsB[k].DoClick = function( Panel )
  1425. surface.PlaySound("factory/move1.ogg")
  1426. Ingredients[k]["Amount"] = Ingredients[k]["Amount"] - 1
  1427. if (Ingredients[k]["Amount"] <= 0) then
  1428. Ingredients[k] = nil
  1429. end
  1430. ResetList()
  1431. end
  1432. x = (x + W*0.06) + 1
  1433. if (x > W*0.18) then
  1434. y = (y + H*0.1) + 1
  1435. x = 0
  1436. end
  1437. end
  1438. end
  1439. ResetList()
  1440.  
  1441. if (loaded) then
  1442. NameEntry:SetText(loaded.Name)
  1443. IndexEntry:SetText(loaded.Index)
  1444. EntityEntry:SetText(loaded.Result.Class)
  1445. Logo = loaded.Logo
  1446. Mixer:SetColor(loaded.LogoCol)
  1447. end
  1448.  
  1449. end
  1450.  
  1451.  
  1452. --> THE MAIN MENU :
  1453. function Fact_OpenEditor( data )
  1454. local W, H = ScrW(), ScrH()
  1455. if (EditorFrame) then EditorFrame:Remove() end
  1456.  
  1457. -- // CREATE THE MAIN LABEL \\ --
  1458. EditorFrame = vgui.Create( "DFrame" )
  1459. EditorFrame:SetPos( 0, 0 )
  1460. EditorFrame:SetSize( W, H )
  1461. EditorFrame:SetTitle( "" )
  1462. EditorFrame:SetDraggable( false )
  1463. EditorFrame:ShowCloseButton( false )
  1464. EditorFrame:MakePopup()
  1465. EditorFrame.Paint = function()
  1466. draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
  1467. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
  1468. draw.DrawText( "EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  1469. end
  1470.  
  1471. -- // MATERIAL BUTTON \\ --
  1472. local Button1B = false
  1473. Button1 = vgui.Create( "DButton", EditorFrame )
  1474. Button1:SetPos( W*0.35, H*0.25)
  1475. Button1:SetText( "" )
  1476. Button1:SetFont( "Trebuchet24" )
  1477. Button1:SetSize( W*0.3, H*0.075 )
  1478. Button1.DoClick = function( Panel )
  1479. surface.PlaySound("factory/move2.ogg")
  1480. EditorFrame:Remove()
  1481. Fact_OpenEditorMaterials( data )
  1482. end
  1483. Button1.Paint = function( Panel )
  1484. if (Button1B) then
  1485. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
  1486. draw.DrawText( "Material Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1487. else
  1488. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1489. draw.DrawText( "Material Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1490. end
  1491. end
  1492. Button1.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button1B = true end
  1493. Button1.OnCursorExited = function() Button1B = false end
  1494.  
  1495. -- // MAT LIST BUTTON \\ --
  1496. local Button2B = false
  1497. Button2 = vgui.Create( "DButton", EditorFrame )
  1498. Button2:SetPos( W*0.35, H*0.35)
  1499. Button2:SetText( "" )
  1500. Button2:SetFont( "Trebuchet24" )
  1501. Button2:SetSize( W*0.3, H*0.075 )
  1502. Button2.DoClick = function( Panel )
  1503. surface.PlaySound("factory/move2.ogg")
  1504. EditorFrame:Remove()
  1505. Fact_OpenMaterialsList(data)
  1506. end
  1507. Button2.Paint = function( Panel )
  1508. if (Button2B) then
  1509. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
  1510. draw.DrawText( "Edit Materials", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1511. else
  1512. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1513. draw.DrawText( "Edit Materials", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1514. end
  1515. end
  1516. Button2.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button2B = true end
  1517. Button2.OnCursorExited = function() Button2B = false end
  1518.  
  1519. -- // RECIPE BUTTON \\ --
  1520. local Button3B = false
  1521. Button3 = vgui.Create( "DButton", EditorFrame )
  1522. Button3:SetPos( W*0.35, H*0.45)
  1523. Button3:SetText( "" )
  1524. Button3:SetFont( "Trebuchet24" )
  1525. Button3:SetSize( W*0.3, H*0.075 )
  1526. Button3.DoClick = function( Panel )
  1527. surface.PlaySound("factory/move2.ogg")
  1528. EditorFrame:Remove()
  1529. Fact_OpenRecipeEditor(data)
  1530. end
  1531. Button3.Paint = function( Panel )
  1532. if (Button3B) then
  1533. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
  1534. draw.DrawText( "Recipe Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1535. else
  1536. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1537. draw.DrawText( "Recipe Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1538. end
  1539. end
  1540. Button3.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button3B = true end
  1541. Button3.OnCursorExited = function() Button3B = false end
  1542.  
  1543. -- // RECIPE BUTTON \\ --
  1544. local Button4B = false
  1545. Button4 = vgui.Create( "DButton", EditorFrame )
  1546. Button4:SetPos( W*0.35, H*0.55)
  1547. Button4:SetText( "" )
  1548. Button4:SetFont( "Trebuchet24" )
  1549. Button4:SetSize( W*0.3, H*0.075 )
  1550. Button4.DoClick = function( Panel )
  1551. surface.PlaySound("factory/move2.ogg")
  1552. EditorFrame:Remove()
  1553. Fact_OpenRecipeList(data)
  1554. end
  1555. Button4.Paint = function( Panel )
  1556. if (Button4B) then
  1557. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
  1558. draw.DrawText( "Edit Recipe", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1559. else
  1560. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1561. draw.DrawText( "Edit Recipe", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1562. end
  1563. end
  1564. Button4.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button4B = true end
  1565. Button4.OnCursorExited = function() Button4B = false end
  1566.  
  1567. -- // CLOSE BUTTON \\ --
  1568. local CloseBBool = false
  1569. CloseB = vgui.Create( "DButton", EditorFrame )
  1570. CloseB:SetPos( W*0.35, H*0.65)
  1571. CloseB:SetText( "" )
  1572. CloseB:SetFont( "Trebuchet24" )
  1573. CloseB:SetSize( W*0.3, H*0.075 )
  1574. CloseB.DoClick = function( Panel )
  1575. surface.PlaySound("factory/move2.ogg")
  1576. EditorFrame:Remove()
  1577. end
  1578. CloseB.Paint = function( Panel )
  1579. if (CloseBBool) then
  1580. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(180,80,80,255) )
  1581. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1582. else
  1583. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1584. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1585. end
  1586. end
  1587. CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
  1588. CloseB.OnCursorExited = function() CloseBBool = false end
  1589.  
  1590. end
  1591.  
  1592.  
  1593. --> CRAFT MENU :
  1594. function Fact_OpenCraftMenu( data )
  1595. local W, H = ScrW(), ScrH()
  1596. local Selected = {}
  1597. local data = data
  1598. local CanCraft = false
  1599. if (CraftFrame) then CraftFrame:Remove() end
  1600.  
  1601. -- // CREATE THE MAIN LABEL \\ --
  1602. CraftFrame = vgui.Create( "DFrame" )
  1603. CraftFrame:SetPos( 0, 0 )
  1604. CraftFrame:SetSize( W, H )
  1605. CraftFrame:SetTitle( "" )
  1606. CraftFrame:SetDraggable( false )
  1607. CraftFrame:ShowCloseButton( false )
  1608. CraftFrame:MakePopup()
  1609. CraftFrame.Paint = function()
  1610. draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
  1611. draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
  1612. draw.RoundedBox( 0, 0, H*0.925, W, H*0.075, Color(60,60,60,255) )
  1613. draw.RoundedBox( 0, W*0.025, H*0.225, W*0.2, H*0.675, Color(50,50,60,255) )
  1614. draw.RoundedBox( 0, W*0.025, H*0.225, W*0.2, H*0.075, Color(80,80,180,255) )
  1615. draw.RoundedBox( 0, W*0.25, H*0.225, W*0.2, H*0.675, Color(50,50,50,255) )
  1616. draw.RoundedBox( 0, W*0.25, H*0.225, W*0.2, H*0.075, Color(80,80,180,255) )
  1617. draw.RoundedBox( 0, W*0.475, H*0.225, W*0.2, H*0.675, Color(50,50,50,255) )
  1618. draw.RoundedBox( 0, W*0.475, H*0.225, W*0.2, H*0.075, Color(80,80,180,255) )
  1619. draw.DrawText( "EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
  1620. draw.DrawText( FactLang.Recipe, "Fact_High_Strong", W*0.125, H*0.235, Color( 255, 255, 255, 255 ), 1 )
  1621. draw.DrawText( "Ingredients", "Fact_High_Strong", W*0.35, H*0.235, Color( 255, 255, 255, 255 ), 1 )
  1622. draw.DrawText( "Content", "Fact_High_Strong", W*0.575, H*0.235, Color( 255, 255, 255, 255 ), 1 )
  1623. end
  1624.  
  1625. RecipeScroll = vgui.Create( "DScrollPanel", CraftFrame )
  1626. RecipeScroll:SetPos( W*0.025, H*0.3 + 5 )
  1627. RecipeScroll:SetSize( W*0.2, H*0.675 - 10 )
  1628. local sbar = RecipeScroll:GetVBar()
  1629. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1630. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  1631. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1632. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1633.  
  1634. local x , y = 0,0
  1635. RecipeList = {}
  1636. for k , v in pairs (data.Recipe) do
  1637. RecipeList[k] = vgui.Create( "DButton", RecipeScroll )
  1638. RecipeList[k]:SetPos( x, y )
  1639. RecipeList[k]:SetText( "" )
  1640. RecipeList[k]:SetSize( W*0.2, H*0.1 )
  1641. RecipeList[k].Paint = function( Panel )
  1642. draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(130,130,140,255) )
  1643. draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
  1644. draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
  1645. surface.SetDrawColor( v.LogoCol )
  1646. surface.SetMaterial( Material(v.Logo) )
  1647. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  1648. if (Selected.Index == v.Index) then
  1649. surface.SetDrawColor( Color(255,255,255,255) )
  1650. surface.SetMaterial( Material("factory/ui/box.png") )
  1651. surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
  1652. end
  1653. end
  1654. RecipeList[k].DoClick = function( Panel )
  1655. surface.PlaySound("factory/click1.ogg")
  1656. Selected = v
  1657. RefreshIngredient()
  1658.  
  1659. for k , v in pairs (v.Ingredient) do
  1660. if ( data.Content[k] ) then
  1661. if ( data.Content[k]["Amount"] >= v ) then
  1662. CanCraft = true
  1663. else
  1664. CanCraft = false break
  1665. end
  1666. else
  1667. CanCraft = false break
  1668. end
  1669. end
  1670.  
  1671. end
  1672. y = (y + H*0.1) + 1
  1673. end
  1674.  
  1675. IngredientList = {}
  1676. IngredientScroll = vgui.Create( "DScrollPanel", CraftFrame )
  1677. IngredientScroll:SetPos( W*0.25, H*0.3 + 5 )
  1678. IngredientScroll:SetSize( W*0.2, H*0.675 - 10 )
  1679. local sbar = IngredientScroll:GetVBar()
  1680. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1681. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  1682. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1683. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1684.  
  1685. function RefreshIngredient()
  1686. for k, p in pairs (IngredientList) do
  1687. IngredientList[k] = nil
  1688. p:Remove()
  1689. end
  1690. local x, y = 0, 0
  1691. for k , v in pairs (Selected.Ingredient) do
  1692. IngredientList[k] = vgui.Create( "DButton", IngredientScroll )
  1693. IngredientList[k]:SetPos( x, y )
  1694. IngredientList[k]:SetText( "" )
  1695. IngredientList[k]:SetSize( W*0.2, H*0.05 )
  1696. if ( data.Content[k] ) then
  1697. if ( v <= data.Content[k]["Amount"] ) then
  1698. IngredientList[k].TextColor = Color(100,255,100,255)
  1699. else
  1700. IngredientList[k].TextColor = Color(255,100,100,255)
  1701. end
  1702. else
  1703. IngredientList[k].TextColor = Color(220,100,100,255)
  1704. end
  1705. IngredientList[k].Paint = function( self )
  1706. draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(80,80,90,255) )
  1707. draw.DrawText( k .. " : x" .. v, "Fact_Medium", 10, H*0.01, self.TextColor, 0 )
  1708. end
  1709. y = (y + H*0.05) + 1
  1710. end
  1711. end
  1712.  
  1713. ContentList = {}
  1714. ContentScroll = vgui.Create( "DScrollPanel", CraftFrame )
  1715. ContentScroll:SetPos( W*0.475, H*0.3 + 5 )
  1716. ContentScroll:SetSize( W*0.2, H*0.675 - 10 )
  1717. local sbar = ContentScroll:GetVBar()
  1718. function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1719. function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
  1720. function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1721. function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
  1722.  
  1723. local x, y = 0, 0
  1724. for k , v in pairs (data.Content) do
  1725. ContentList[k] = vgui.Create( "DButton", ContentScroll )
  1726. ContentList[k]:SetPos( x, y )
  1727. ContentList[k]:SetText( "" )
  1728. ContentList[k]:SetSize( W*0.2, H*0.05 )
  1729. ContentList[k].Paint = function( self )
  1730. draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(80,80,90,255) )
  1731. draw.DrawText( v.Name .. " (x" .. v.Amount ..")", "Fact_Medium", 10, H*0.01, Color(255,255,255,255), 0 )
  1732. end
  1733. y = (y + H*0.05) + 1
  1734. end
  1735.  
  1736.  
  1737. -- // CLOSE BUTTON \\ --
  1738. local CloseBBool = false
  1739. CloseB = vgui.Create( "DButton", CraftFrame )
  1740. CloseB:SetPos( W*0.7, H*0.6 + 2)
  1741. CloseB:SetText( "" )
  1742. CloseB:SetFont( "Trebuchet24" )
  1743. CloseB:SetSize( W*0.275, H*0.075 )
  1744. CloseB.DoClick = function( Panel )
  1745. surface.PlaySound("factory/move2.ogg")
  1746. CraftFrame:Remove()
  1747. end
  1748. CloseB.Paint = function( Panel )
  1749. if (CloseBBool) then
  1750. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(180,80,80,255) )
  1751. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.135, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1752. else
  1753. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1754. draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.135, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1755. end
  1756. end
  1757. CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
  1758. CloseB.OnCursorExited = function() CloseBBool = false end
  1759.  
  1760. -- // CRAFT BUTTON \\ --
  1761. CraftB = vgui.Create( "DButton", CraftFrame )
  1762. CraftB:SetPos( W*0.7, H*0.5 + 2)
  1763. CraftB:SetText( "" )
  1764. CraftB:SetFont( "Trebuchet24" )
  1765. CraftB:SetSize( W*0.275, H*0.075 )
  1766. CraftB.DoClick = function( Panel )
  1767. if (CanCraft) then
  1768. local NTab = {}
  1769. NTab.ENT = data.ENT
  1770. NTab.Price = Selected
  1771. net.Start("Fact_CraftItem")
  1772. net.WriteTable(NTab)
  1773. net.SendToServer()
  1774. CraftFrame:Remove()
  1775. surface.PlaySound("factory/move2.ogg")
  1776. end
  1777. end
  1778. CraftB.Paint = function( Panel )
  1779. if (CanCraft) then
  1780. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,180,80,255) )
  1781. draw.DrawText( "Fabriquer", "Fact_Medium_Strong", W*0.135, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
  1782. else
  1783. draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
  1784. draw.DrawText( "Fabriquer", "Fact_Medium_Strong", W*0.135, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
  1785. end
  1786. end
  1787.  
  1788. end
  1789.  
  1790. net.Receive("Fact_OpenCraftMenu", function()
  1791. local NTab = net.ReadTable()
  1792. Fact_OpenCraftMenu(NTab)
  1793. end)
  1794.  
  1795. net.Receive("Fact_OpenEditor", function()
  1796. local NTab = net.ReadTable()
  1797. Fact_OpenEditor(NTab)
  1798. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement