Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- EDTIOR CLIENT SIDE
- -- || MATERIAL EDITOR || --
- function Fact_OpenEditorMaterials( data , selected )
- local W, H, Select, Valid, ActTab, Error, ErrorA, Logo = ScrW(), ScrH(), "", true, {}, "", 0, ""
- if (EditorFrame) then EditorFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- EditorFrame = vgui.Create( "DFrame" )
- EditorFrame:SetPos( 0, 0 )
- EditorFrame:SetSize( W, H )
- EditorFrame:SetTitle( "" )
- EditorFrame:SetDraggable( false )
- EditorFrame:ShowCloseButton( false )
- EditorFrame:MakePopup()
- EditorFrame.Paint = function()
- -- // ICON MANAGAMENT \\ --
- draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(255,127,0,255) )
- draw.RoundedBox( 0, 0, H*0.925, W, H*0.075, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.05, H*0.3, W*0.21, H*0.6, Color(255,127,0,255) )
- draw.RoundedBox( 0, W*0.05, H*0.25, W*0.21, H*0.05, Color(0,0,0,255) )
- draw.DrawText( "ICON : " .. string.upper(Select), "Fact_Medium_Strong", W*0.16, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- -- // THE PREVIEW ICON \\ --
- draw.RoundedBox( 0, W*0.28, H*0.25, W*0.1, H*0.05, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.28, H*0.3, W*0.1, H*0.17, Color(255,127,0,255) )
- draw.RoundedBox( 0, W*0.28, H*0.48, W*0.1, H*0.1, Color(0,0,0,255) )
- draw.DrawText( "PREVIEW", "Fact_Medium_Strong", W*0.33, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- if (Select ~= "") then
- surface.SetDrawColor( Mixer:GetColor() )
- surface.SetMaterial( Material(Logo) )
- surface.DrawTexturedRect( W*0.28, H*0.3, W*0.1, H*0.17 )
- end
- -- // MODEL 3D \\ --
- draw.RoundedBox( 0, W*0.4, H*0.3, W*0.425, H*0.6, Color(255,127,0,255) )
- draw.RoundedBox( 0, W*0.4, H*0.25, W*0.425, H*0.05, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.5, H*0.3, W*0.325, H*0.18, Color(140,140,150,255) )
- draw.RoundedBox( 0, W*0.4, H*0.3, W*0.1, H*0.18, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.7, H*0.3, W*0.1, H*0.18, Color(0,0,0,150) )
- draw.DrawText( "MODEL", "Fact_Medium_Strong", W*0.61, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- if (Valid) then draw.DrawText( FactLang.ModelValid, "Fact_Small_Strong", W*0.5 + 5, H*0.335, Color( 0, 255, 0, 255 ), 0 )
- else draw.DrawText( FactLang.ModelInvalid, "Fact_Small_Strong", W*0.51, H*0.335, Color( 255, 0, 0, 255 ), 0 )
- end
- draw.RoundedBox( 0, W*0.85, H*0.25, W*0.125, H*0.05, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.85, H*0.3, W*0.125, H*0.25, Color(130,130,130,255) )
- draw.RoundedBox( 0, W*0.86, H*0.32, W*0.1, H*0.025, Color(255,127,0,255) )
- draw.RoundedBox( 0, W*0.86, H*0.37, W*0.1, H*0.025, Color(255,127,0,255) )
- draw.RoundedBox( 0, W*0.86, H*0.42, W*0.1, H*0.025, Color(255,127,0,255) )
- draw.DrawText( "PROPERTIES", "Fact_Medium_Strong", W*0.91, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- -- draw.DrawText( "Is this fuel ?", "Fact_Small", W*0.895, H*0.47, Color( 0, 0, 0, 255 ), 1 )
- draw.DrawText( "MATERIAL EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( Error, "Fact_High_Strong", W*0.5, H*0.14, Color( 255, 0, 0, ErrorA ), 1 )
- end
- -- // MODEL 3D PREVIEW \\ --
- ModelIcon = vgui.Create( "ModelImage", EditorFrame )
- ModelIcon:SetPos( W*0.4, H*0.3 )
- ModelIcon:SetSize( W*0.1, H*0.18 )
- ModelIcon:SetModel( "models/props_debris/concrete_chunk04a.mdl" )
- -- // MODEL ENTRY \\ --
- ModelEntry = vgui.Create( "DTextEntry", EditorFrame )
- ModelEntry:SetPos( W*0.5, H*0.3 )
- ModelEntry:SetSize( W*0.2, H*0.03 )
- ModelEntry:SetText( "models/props_debris/concrete_chunk04a.mdl" )
- ModelEntry.OnEnter = function( self )
- ModelIcon:SetModel(self:GetValue())
- ModelPreview:SetModel(self:GetValue())
- net.Start("Fact_EditorSendCheck")
- net.WriteString(self:GetValue())
- net.SendToServer()
- end
- -- // RECEIVE THE CHECK REPORT FROM THE SERVER \\ --
- net.Receive("Fact_EditorReplyCheck", function(len)
- local NBool = net.ReadBool()
- Valid = NBool
- end)
- -- // THE NAME ENTRY OF THE ITEM \\ --
- NameEntry = vgui.Create( "DTextEntry", EditorFrame )
- NameEntry:SetPos( W*0.86, H*0.32 )
- NameEntry:SetSize( W*0.1, H*0.025 )
- NameEntry:SetText( FactLang.Name )
- NameEntry:SetDrawBackground(false)
- -- // INDEX OF THE MATERIAL \\ --
- IndexEntry = vgui.Create( "DTextEntry", EditorFrame )
- IndexEntry:SetPos( W*0.86, H*0.37 )
- IndexEntry:SetSize( W*0.1, H*0.025 )
- IndexEntry:SetText( "Index" )
- IndexEntry:SetDrawBackground(false)
- -- // WEIGHT OF THE MATERIAL \\ --
- WeightEntry = vgui.Create( "DTextEntry", EditorFrame )
- WeightEntry:SetPos( W*0.86, H*0.42 )
- WeightEntry:SetSize( W*0.1, H*0.025 )
- WeightEntry:SetText( FactLang.Weight )
- WeightEntry:SetDrawBackground(false)
- WeightEntry.OnLoseFocus = function(self)
- local Weight = tonumber(self:GetValue())
- if ( not isnumber(Weight, 10)) then
- WeightEntry:SetText( FactLang.Weight )
- surface.PlaySound("factory/error2.ogg")
- end
- end
- -- // CHECK IF ITEM IS FUEL \\ --
- -- FuelCheck = vgui.Create( "DCheckBox", EditorFrame )
- -- FuelCheck:SetPos( W*0.86, H*0.47 )
- -- FuelCheck:SetSize( W*0.01, H*0.017 )
- -- FuelCheck:SetValue( 0 )
- -- // THE SAVE BUTTON \\ --
- local SaveItemBool = false
- SaveItem = vgui.Create( "DButton", EditorFrame )
- SaveItem:SetPos( W*0.85, H*0.5 )
- SaveItem:SetText( "" )
- SaveItem:SetFont( "Trebuchet24" )
- SaveItem:SetSize( W*0.125, H*0.05 )
- SaveItem.DoClick = function( Panel )
- if (Select == "") then surface.PlaySound("factory/error2.ogg") Error = "The material have no icon !" ErrorA = 255 return end
- local Weight = tonumber(WeightEntry:GetValue())
- if (not isnumber(Weight, 10) ) then surface.PlaySound("factory/error2.ogg") Error = "The weight is incorrect !" ErrorA = 255 return end
- local Material =
- {
- Name = NameEntry:GetValue(),
- Color = GameMixer:GetColor(),
- Texture = MaterialEntry:GetValue(),
- Logo = Logo,
- LogoCol = Mixer:GetColor(),
- Model = ModelEntry:GetValue(),
- Stats = {},
- Weight = tonumber(WeightEntry:GetValue()),
- Index = string.lower(utf8.force(IndexEntry:GetValue())),
- }
- net.Start("Fact_EditorSaveMaterial")
- net.WriteTable(Material)
- net.SendToServer()
- EditorFrame:Remove()
- end
- SaveItem.Paint = function( Panel )
- if (SaveItemBool) then
- draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(50,200,50,255) )
- draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 255, 255, 255, 255 ), 1 )
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/save.png") )
- surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
- else
- draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 70, 70, 70, 255 ), 1 )
- surface.SetDrawColor( Color(80,80,80,255) )
- surface.SetMaterial( Material("factory/ui/save.png") )
- surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
- end
- end
- SaveItem.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") SaveItemBool = true end
- SaveItem.OnCursorExited = function() SaveItemBool = false end
- -- // THE CLOSE BUTTON \\ --
- local CloseMenuBool = false
- CloseMenu = vgui.Create( "DButton", EditorFrame )
- CloseMenu:SetPos( W*0.85, H*0.926)
- CloseMenu:SetText( "" )
- CloseMenu:SetFont( "Trebuchet24" )
- CloseMenu:SetSize( W*0.15, H*0.075 )
- CloseMenu.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- Fact_OpenEditor(data)
- end
- CloseMenu.Paint = function( Panel )
- if (CloseMenuBool) then
- draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(240,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseMenu.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseMenuBool = true end
- CloseMenu.OnCursorExited = function() CloseMenuBool = false end
- -- // COLOR MIXER ICON \\ --
- Mixer = vgui.Create( "DColorMixer", EditorFrame )
- Mixer:SetPos(W*0.28, H*0.48)
- Mixer:SetSize(W*0.1,H*0.1)
- Mixer:SetPalette( false )
- Mixer:SetAlphaBar( false )
- Mixer:SetWangs( false )
- Mixer:SetColor( Color( 255, 255, 255 ) )
- -- // COLOR MIXER MODEL \\ --
- GameMixer = vgui.Create( "DColorMixer", EditorFrame )
- GameMixer:SetPos(W*0.5, H*0.36)
- GameMixer:SetSize(W*0.2,H*0.12)
- GameMixer:SetPalette( false )
- GameMixer:SetAlphaBar( false )
- GameMixer:SetWangs( false )
- GameMixer:SetColor( Color( 255, 255, 255 ) )
- GameMixer.ValueChanged = function()
- ModelPreview.Entity:SetColor( GameMixer:GetColor() )
- end
- -- // 3D MODEL PREVIEW \\ --
- VFOV = 10
- ModelPreview = vgui.Create( "DModelPanel", EditorFrame )
- ModelPreview:SetPos( W*0.7, H*0.3 )
- ModelPreview:SetSize( W*0.1, H*0.18 )
- ModelPreview:SetModel( "models/props_debris/concrete_chunk04a.mdl" )
- ModelPreview:SetLookAt( ModelPreview.Entity:GetPos() )
- ModelPreview:SetFOV( VFOV )
- function ModelPreview:LayoutEntity( Entity )
- self:SetColor( GameMixer:GetColor() )
- Entity:SetAngles(Angle(0,RealTime()*50,0))
- return end
- ------------------
- -- ZOOM BUTTONS --
- ------------------
- -- // Zoom In \\ --
- ZoomIn = vgui.Create( "DButton", EditorFrame )
- ZoomIn:SetPos( W*0.8, H*0.3 )
- ZoomIn:SetText( "+" )
- ZoomIn:SetFont( "Trebuchet24" )
- ZoomIn:SetDrawBackground( 0 )
- ZoomIn:SetSize( W*0.025, H*0.05 )
- ZoomIn.DoClick = function( Panel )
- if VFOV > 10 then
- VFOV = VFOV - 10
- ModelPreview:SetFOV( VFOV )
- end
- end
- -- // Zoom Out \\ --
- ZoomOut = vgui.Create( "DButton", EditorFrame )
- ZoomOut:SetPos( W*0.8, H*0.36 )
- ZoomOut:SetText( "-" )
- ZoomOut:SetFont( "Trebuchet24" )
- ZoomOut:SetDrawBackground( 0 )
- ZoomOut:SetSize( W*0.025, H*0.05 )
- ZoomOut.DoClick = function( Panel )
- if VFOV < 120 then
- VFOV = VFOV + 10
- ModelPreview:SetFOV( VFOV )
- end
- end
- -- // Zoom Reset \\ --
- ZoomReset = vgui.Create( "DButton", EditorFrame )
- ZoomReset:SetPos( W*0.8, H*0.42 )
- ZoomReset:SetText( "X" )
- ZoomReset:SetFont( "Trebuchet24" )
- ZoomReset:SetDrawBackground( 0 )
- ZoomReset:SetSize( W*0.025, H*0.05 )
- ZoomReset.DoClick = function( Panel )
- VFOV = 10
- ModelPreview:SetFOV( VFOV )
- end
- -- [[ MATERIALS LIST ]] --
- local MatList = {
- "phoenix_storms/cube",
- "models/props_foliage/tree_deciduous_01a_trunk",
- "models/shiny",
- "phoenix_storms/gear",
- "models/props_debris/plasterwall034a",
- "models/props_combine/metal_combinebridge001",
- "models/props_wasteland/rockcliff02b",
- "models/props_wasteland/rockcliff02a",
- }
- -----------------------------
- -- // MATERIALS BUTTONS \\ --
- local MatButtons = {}
- local bx,by = W*0.4, H*0.475
- for k , v in pairs (MatList) do
- MatButtons[k] = vgui.Create( "DModelPanel", EditorFrame )
- MatButtons[k]:SetPos( bx, by )
- MatButtons[k]:SetSize( W*0.106, H*0.18 )
- MatButtons[k]:SetModel( "models/props_debris/concrete_chunk04a.mdl" )
- MatButtons[k]:SetLookAt( MatButtons[k].Entity:GetPos() )
- MatButtons[k]:SetFOV(10)
- MatButtons[k].Entity:SetMaterial(v)
- MatButtons[k].DoClick = function()
- surface.PlaySound("factory/click2.ogg")
- ModelPreview.Entity:SetMaterial(v)
- MaterialEntry:SetText(v)
- end
- bx = bx + W*0.106
- if bx > W*0.8 then
- bx = W*0.4
- by = by + H*0.18
- end
- end
- -- // MATERIAL ENTRY \\ --
- MaterialEntry = vgui.Create( "DTextEntry", EditorFrame )
- MaterialEntry:SetPos( W*0.4, H*0.87 )
- MaterialEntry:SetSize( W*0.425, H*0.03 )
- MaterialEntry:SetText( "" )
- MaterialEntry.OnEnter = function( self )
- ModelPreview.Entity:SetMaterial(self:GetValue())
- end
- -- // THE ICON SCROLL MENU \\ --
- local IconScroll = vgui.Create( "DScrollPanel",EditorFrame )
- IconScroll:SetPos( W*0.05, H*0.3 )
- IconScroll:SetSize( W*0.22 - 1, H*0.6 )
- local sbar = IconScroll:GetVBar() -- CHANGE THE BAR COLOR
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- -- // ICON MENU \\ --
- Icon = {}
- x , y = 0, 0
- for k , v in pairs (FactMod.Icon) do
- Icon[k] = vgui.Create( "DButton", IconScroll )
- Icon[k]:SetPos( x, y )
- Icon[k]:SetText( "" )
- Icon[k]:SetFont( "Trebuchet24" )
- Icon[k]:SetSize( W*0.07, H*0.11 )
- Icon[k].Paint = function( Panel )
- if ( Material(v) ~= nil ) then
- if (Select == k) then
- surface.SetDrawColor( 255, 255, 255, 255 )
- else
- surface.SetDrawColor( 255, 255, 255, 50 )
- end
- surface.SetMaterial( Material(v) )
- surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
- if (Select == k) then
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
- end
- end
- end
- Icon[k].DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- Select = k
- Logo = v
- end
- -- POSITION MANAGEMENT
- x = x + W*0.07
- if x > W*0.2 then x = 0 y = y + H*0.11 end
- end
- if (selected) then
- ModelPreview:SetModel( selected.Model )
- ModelIcon:SetModel( selected.Model )
- WeightEntry:SetText( selected.Weight )
- NameEntry:SetText( selected.Name )
- IndexEntry:SetText( selected.Index )
- GameMixer:SetColor( selected.Color )
- Mixer:SetColor( selected.LogoCol )
- MaterialEntry:SetText( selected.Texture )
- ModelPreview.Entity:SetMaterial( selected.Texture )
- Logo, Select = selected.Logo, selected.Index
- end
- -- \\ END // --
- end
- -- || ITEM EDITOR || --
- function Fact_OpenEditorItem( data )
- local W, H, Select, Valid, ActTab = ScrW(), ScrH(), "", true, {}
- if (EditorFrame) then EditorFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- EditorFrame = vgui.Create( "DFrame" )
- EditorFrame:SetPos( 0, 0 )
- EditorFrame:SetSize( W, H )
- EditorFrame:SetTitle( "" )
- EditorFrame:SetDraggable( false )
- EditorFrame:ShowCloseButton( false )
- EditorFrame:MakePopup()
- EditorFrame.Paint = function()
- draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(255,127,0,255) )
- draw.RoundedBox( 0, 0, H*0.925, W, H*0.075, Color(0,10,30,255) )
- draw.DrawText( "ITEM EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- -- // ICON \\ --
- draw.RoundedBox( 0, W*0.05, H*0.3, W*0.21, H*0.35, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.05, H*0.25, W*0.21, H*0.05, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.28, H*0.25, W*0.1, H*0.05, Color(0,0,0,255) )
- draw.RoundedBox( 0, W*0.28, H*0.3, W*0.1, H*0.17, Color(255,127,0,255) )
- draw.RoundedBox( 0, W*0.28, H*0.48, W*0.1, H*0.1, Color(0,0,0,255) )
- draw.DrawText( "ICON : " .. string.upper(Select), "Fact_Medium_Strong", W*0.16, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( "PREVIEW", "Fact_Medium_Strong", W*0.33, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- if (Select ~= "") then
- surface.SetDrawColor( Mixer:GetColor() )
- surface.SetMaterial( Material(FactMod.Icon[Select]) )
- surface.DrawTexturedRect( W*0.28, H*0.3, W*0.1, H*0.17 )
- end
- -- // MODEL 3D \\ --
- draw.RoundedBox( 0, W*0.05, H*0.7, W*0.1, H*0.2, Color(80,80,90,255) )
- draw.RoundedBox( 0, W*0.15, H*0.7, W*0.235, H*0.2, Color(140,140,150,255) )
- draw.RoundedBox( 0, W*0.05, H*0.675, W*0.335, H*0.025, Color(50,50,100,255) )
- draw.DrawText( "Model 3D [Choose a path]", "Fact_Small_Strong", W*0.06, H*0.678, Color( 255, 255, 255, 200 ), 0 )
- if (Valid) then
- 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 )
- else
- 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 )
- end
- -- // ACTION \\ --
- draw.RoundedBox( 0, W*0.4, H*0.3, W*0.425, H*0.6, Color(130,130,130,255) )
- draw.RoundedBox( 0, W*0.4, H*0.25, W*0.425, H*0.05, Color(80,80,110,255) )
- draw.DrawText( "ACTION", "Fact_Medium_Strong", W*0.61, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- -- // PARAMETERS \\ --
- draw.RoundedBox( 0, W*0.85, H*0.25, W*0.125, H*0.05, Color(80,80,110,255) )
- draw.RoundedBox( 0, W*0.85, H*0.3, W*0.125, H*0.25, Color(130,130,130,255) )
- draw.RoundedBox( 0, W*0.86, H*0.32, W*0.1, H*0.025, Color(240,240,240,255) )
- draw.RoundedBox( 0, W*0.86, H*0.37, W*0.1, H*0.025, Color(240,240,240,255) )
- draw.RoundedBox( 0, W*0.86, H*0.42, W*0.1, H*0.025, Color(240,240,240,255) )
- draw.DrawText( "PROPERTIES", "Fact_Medium_Strong", W*0.91, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( "Is this fuel ?", "Fact_Small", W*0.895, H*0.47, Color( 0, 0, 0, 255 ), 1 )
- end
- -- // PARAMETER BUTTONS \\ --
- -- // HEALTH \\ --
- Heal = vgui.Create( "DButton", EditorFrame )
- Heal:SetPos( W*0.41, H*0.31 )
- Heal:SetText( "" )
- Heal:SetFont( "Trebuchet24" )
- Heal:SetSize( W*0.1, H*0.05 )
- Heal.Paint = function( Panel )
- draw.DrawText( "Heal", "DermaLarge", W*0.05, 0, Color( 255, 255, 255, 255 ), 1 )
- end
- Heal.DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- ActionHealth()
- end
- ---------------------
- -- HEALTH SETTINGS --
- ---------------------
- function ActionHealth()
- if (HealthSettings) then HealthSettings:Remove() end
- HealthSettings = vgui.Create( "DFrame" )
- HealthSettings:SetPos( 0, 0 )
- HealthSettings:SetSize( W, H )
- HealthSettings:SetTitle( "" )
- HealthSettings:SetDraggable( 0 )
- HealthSettings:MakePopup()
- HealthSettings.Paint = function( Panel )
- draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,230) )
- draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.2, Color(180,180,180,255) )
- draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.04, Color(50,150,50,255) )
- draw.DrawText( "Action : Health", "DermaLarge", W*0.36, H*0.4, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "How many heal this is gonna give ?", "ChatFont", W*0.465, H*0.45, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "What's the maximum health it can give ?", "ChatFont", W*0.465, H*0.49, Color( 255, 255, 255, 255 ), 0 )
- end
- local HealthToAdd = vgui.Create( "DTextEntry", HealthSettings )
- HealthToAdd:SetPos( W*0.36, H*0.45 )
- HealthToAdd:SetSize( W*0.1, H*0.025 )
- HealthToAdd:SetText( "" )
- local HealthMax = vgui.Create( "DTextEntry", HealthSettings )
- HealthMax:SetPos( W*0.36, H*0.49 )
- HealthMax:SetSize( W*0.1, H*0.025 )
- HealthMax:SetText( "" )
- Add = vgui.Create( "DButton", HealthSettings )
- Add:SetPos( W*0.36, H*0.54 )
- Add:SetText( "Add" )
- Add:SetFont( "Trebuchet24" )
- Add:SetSize( W*0.075, H*0.05 )
- Add.DoClick = function( Panel )
- local HealthAdd = tonumber( HealthToAdd:GetValue(), 10 )
- local HealthMax = tonumber( HealthMax:GetValue(), 10 )
- if (HealthMax == nil) then HealthMax = 0 end
- if (isnumber(HealthAdd)) then
- ActTab[#ActTab + 1] =
- {
- Action = "Heal",
- AddHealth = HealthAdd,
- MaxHealth = HealthMax,
- }
- HealthSettings:Remove()
- AppList:AddLine( "Heal (" .. HealthAdd .. ") Max : " .. HealthMax )
- end
- end
- Cancel = vgui.Create( "DButton", HealthSettings )
- Cancel:SetPos( W*0.45, H*0.54 )
- Cancel:SetText( "Cancel" )
- Cancel:SetFont( "Trebuchet24" )
- Cancel:SetSize( W*0.075, H*0.05 )
- Cancel.DoClick = function( Panel )
- HealthSettings:Remove()
- end
- end
- -- // ARMOR \\ --
- Armor = vgui.Create( "DButton", EditorFrame )
- Armor:SetPos( W*0.41, H*0.36 )
- Armor:SetText( "" )
- Armor:SetFont( "Trebuchet24" )
- Armor:SetSize( W*0.1, H*0.05 )
- Armor.Paint = function( Panel )
- draw.DrawText( "Armor", "DermaLarge", W*0.05, 0, Color( 255, 255, 255, 255 ), 1 )
- end
- Armor.DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- ActionArmor()
- end
- --------------------
- -- ARMOR SETTINGS --
- --------------------
- function ActionArmor()
- if (ArmorSettings) then ArmorSettings:Remove() end
- ArmorSettings = vgui.Create( "DFrame" )
- ArmorSettings:SetPos( 0, 0 )
- ArmorSettings:SetSize( W, H )
- ArmorSettings:SetTitle( "" )
- ArmorSettings:SetDraggable( 0 )
- ArmorSettings:MakePopup()
- ArmorSettings.Paint = function( Panel )
- draw.RoundedBox( 0, 0, 0, W, H, Color(0,0,0,230) )
- draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.2, Color(180,180,180,255) )
- draw.RoundedBox( 0, W*0.35, H*0.4, W*0.3, H*0.04, Color(50,50,150,255) )
- draw.DrawText( "Action : Armor", "DermaLarge", W*0.36, H*0.4, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "How many armor this is gonna give ?", "ChatFont", W*0.465, H*0.45, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "What's the maximum armor it can give ?", "ChatFont", W*0.465, H*0.49, Color( 255, 255, 255, 255 ), 0 )
- end
- local ArmorToAdd = vgui.Create( "DTextEntry", ArmorSettings )
- ArmorToAdd:SetPos( W*0.36, H*0.45 )
- ArmorToAdd:SetSize( W*0.1, H*0.025 )
- ArmorToAdd:SetText( "" )
- local ArmorMax = vgui.Create( "DTextEntry", ArmorSettings )
- ArmorMax:SetPos( W*0.36, H*0.49 )
- ArmorMax:SetSize( W*0.1, H*0.025 )
- ArmorMax:SetText( "" )
- Add = vgui.Create( "DButton", ArmorSettings )
- Add:SetPos( W*0.36, H*0.54 )
- Add:SetText( "Add" )
- Add:SetFont( "Trebuchet24" )
- Add:SetSize( W*0.075, H*0.05 )
- Add.DoClick = function( Panel )
- local ArmorAdd = tonumber( ArmorToAdd:GetValue(), 10 )
- local ArmorMax = tonumber( ArmorMax:GetValue(), 10 )
- if (ArmorMax == nil) then ArmorMax = 0 end
- if (isnumber(ArmorAdd)) then
- ActTab[#ActTab + 1] =
- {
- Action = "Armor",
- AddArmor = ArmorAdd,
- MaxArmor = ArmorMax,
- }
- ArmorSettings:Remove()
- AppList:AddLine( "Armor (" .. ArmorAdd .. ") Max : " .. ArmorMax )
- end
- end
- Cancel = vgui.Create( "DButton", ArmorSettings )
- Cancel:SetPos( W*0.45, H*0.54 )
- Cancel:SetText( "Cancel" )
- Cancel:SetFont( "Trebuchet24" )
- Cancel:SetSize( W*0.075, H*0.05 )
- Cancel.DoClick = function( Panel )
- ArmorSettings:Remove()
- end
- end
- -- // ACTION LIST \\ --
- AppList = vgui.Create( "DListView", EditorFrame )
- AppList:SetPos( W*0.55, H*0.31 )
- AppList:SetSize( W*0.2, H*0.475 )
- AppList:SetMultiSelect( false )
- AppList:AddColumn( "Action" )
- -- // MODEL 3D PREVIEW \\ --
- ModelIcon = vgui.Create( "ModelImage", EditorFrame )
- ModelIcon:SetPos( W*0.05, H*0.7 )
- ModelIcon:SetSize( W*0.1, H*0.2 )
- ModelIcon:SetModel( "models/props_junk/cardboard_box001a.mdl" )
- -- // MODEL 3D ENTRY \\ --
- ModelEntry = vgui.Create( "DTextEntry", EditorFrame )
- ModelEntry:SetPos( W*0.155, H*0.73 )
- ModelEntry:SetSize( W*0.2, H*0.03 )
- ModelEntry:SetText( "models/props_junk/cardboard_box001a.mdl" )
- ModelEntry.OnEnter = function( self )
- ModelIcon:SetModel(self:GetValue())
- net.Start("Fact_EditorSendCheck")
- net.WriteString(self:GetValue())
- net.SendToServer()
- end
- net.Receive("Fact_EditorReplyCheck", function(len)
- local NBool = net.ReadBool()
- Valid = NBool
- end)
- -- // THE NAME ENTRY OF THE ITEM \\ --
- NameEntry = vgui.Create( "DTextEntry", EditorFrame )
- NameEntry:SetPos( W*0.86, H*0.32 )
- NameEntry:SetSize( W*0.1, H*0.025 )
- NameEntry:SetText( FactLang.Name )
- NameEntry:SetDrawBackground(false)
- -- // INDEX OF THE MATERIAL \\ --
- IndexEntry = vgui.Create( "DTextEntry", EditorFrame )
- IndexEntry:SetPos( W*0.86, H*0.37 )
- IndexEntry:SetSize( W*0.1, H*0.025 )
- IndexEntry:SetText( "Index" )
- IndexEntry:SetDrawBackground(false)
- -- // WEIGHT OF THE MATERIAL \\ --
- WeightEntry = vgui.Create( "DTextEntry", EditorFrame )
- WeightEntry:SetPos( W*0.86, H*0.42 )
- WeightEntry:SetSize( W*0.1, H*0.025 )
- WeightEntry:SetText( FactLang.Weight )
- WeightEntry:SetDrawBackground(false)
- WeightEntry.OnLoseFocus = function(self)
- local Weight = tonumber(self:GetValue())
- if ( not isnumber(Weight, 10)) then
- WeightEntry:SetText(FactLang.Weight)
- surface.PlaySound("factory/error2.ogg")
- end
- end
- -- // CHECK IF ITEM IS FUEL \\ --
- FuelCheck = vgui.Create( "DCheckBox", EditorFrame )
- FuelCheck:SetPos( W*0.86, H*0.47 )
- FuelCheck:SetSize( W*0.01, H*0.017 )
- FuelCheck:SetValue( 0 )
- -- COLOR MIXER
- Mixer = vgui.Create( "DColorMixer", EditorFrame )
- Mixer:SetPos(W*0.28, H*0.48)
- Mixer:SetSize(W*0.1,H*0.1)
- Mixer:SetPalette( false )
- Mixer:SetAlphaBar( false )
- Mixer:SetWangs( false )
- Mixer:SetColor( Color( 255, 255, 255 ) )
- -- COLOR MIXER
- GameMixer = vgui.Create( "DColorMixer", EditorFrame )
- GameMixer:SetPos(W*0.155, H*0.77)
- GameMixer:SetSize(W*0.2,H*0.12)
- GameMixer:SetPalette( false )
- GameMixer:SetAlphaBar( false )
- GameMixer:SetWangs( false )
- GameMixer:SetColor( Color( 255, 255, 255 ) )
- -- // ICON SCROLL LABEL \\ --
- IconScroll = vgui.Create( "DScrollPanel", EditorFrame )
- IconScroll:SetPos( W*0.05, H*0.3 )
- IconScroll:SetSize( W*0.22 - 1, H*0.35 )
- -- // THE SAVE BUTTON \\ --
- local SaveItemBool = false
- SaveItem = vgui.Create( "DButton", EditorFrame )
- SaveItem:SetPos( W*0.85, H*0.5 )
- SaveItem:SetText( "" )
- SaveItem:SetFont( "Trebuchet24" )
- SaveItem:SetSize( W*0.125, H*0.05 )
- SaveItem.DoClick = function( Panel )
- if (Select == "") then surface.PlaySound("factory/error2.ogg") Error = "The material have no icon !" ErrorA = 255 return end
- local Weight = tonumber(WeightEntry:GetValue())
- if (not isnumber(Weight, 10) ) then surface.PlaySound("factory/error2.ogg") Error = "The weight is incorrect !" ErrorA = 255 return end
- local Material =
- {
- Name = NameID:GetValue(),
- Model = ModelEntry:GetValue(),
- Texture = FactMod.Icon[Select],
- TextureCol = Mixer:GetColor(),
- ActList = ActTab,
- }
- net.Start("Fact_EditorSaveMaterial")
- net.WriteTable(Material)
- net.SendToServer()
- EditorFrame:Remove()
- end
- SaveItem.Paint = function( Panel )
- if (SaveItemBool) then
- draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(50,200,50,255) )
- draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 255, 255, 255, 255 ), 1 )
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/save.png") )
- surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
- else
- draw.DrawText( FactLang.Save, "Fact_Medium_Strong", W*0.05, H*0.01, Color( 70, 70, 70, 255 ), 1 )
- surface.SetDrawColor( Color(80,80,80,255) )
- surface.SetMaterial( Material("factory/ui/save.png") )
- surface.DrawTexturedRect( 0, 0, W*0.0275, H*0.05 )
- end
- end
- SaveItem.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") SaveItemBool = true end
- SaveItem.OnCursorExited = function() SaveItemBool = false end
- -- // THE CLOSE BUTTON \\ --
- local CloseMenuBool = false
- CloseMenu = vgui.Create( "DButton", EditorFrame )
- CloseMenu:SetPos( W*0.85, H*0.926)
- CloseMenu:SetText( "" )
- CloseMenu:SetFont( "Trebuchet24" )
- CloseMenu:SetSize( W*0.15, H*0.075 )
- CloseMenu.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- Fact_OpenEditor()
- end
- CloseMenu.Paint = function( Panel )
- if (CloseMenuBool) then
- draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(240,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.15, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.075, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseMenu.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseMenuBool = true end
- CloseMenu.OnCursorExited = function() CloseMenuBool = false end
- -- CHANGE THE BAR COLOR
- local sbar = IconScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- Icon = {}
- x , y = 0, 0
- for k , v in pairs (FactMod.Icon) do
- Icon[k] = vgui.Create( "DButton", IconScroll )
- Icon[k]:SetPos( x, y )
- Icon[k]:SetText( "" )
- Icon[k]:SetFont( "Trebuchet24" )
- Icon[k]:SetSize( W*0.07, H*0.11 )
- Icon[k].Paint = function( Panel )
- if ( Material(v) ~= nil ) then
- if Select == k then
- surface.SetDrawColor( 255, 255, 255, 255 )
- else
- surface.SetDrawColor( 255, 255, 255, 50 )
- end
- surface.SetMaterial( Material(v) )
- surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
- if Select == k then
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
- end
- end
- end
- Icon[k].DoClick = function( Panel )
- surface.PlaySound("factory/click2.ogg")
- Select = k
- end
- x = x + W*0.07
- if x > W*0.2 then
- x = 0
- y = y + H*0.11
- end
- end
- end
- -- || MATERIAL LIST EDITOR || --
- function Fact_OpenMaterialsList( data )
- local W, H, Selected = ScrW(), ScrH(), ""
- if (EditorFrame) then EditorFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- EditorFrame = vgui.Create( "DFrame" )
- EditorFrame:SetPos( 0, 0 )
- EditorFrame:SetSize( W, H )
- EditorFrame:SetTitle( "" )
- EditorFrame:SetDraggable( false )
- EditorFrame:ShowCloseButton( false )
- EditorFrame:MakePopup()
- EditorFrame.Paint = function()
- draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
- draw.RoundedBox( 0, 0, H*0.2, W*0.205, H*0.8, Color(20,20,20,255) )
- draw.RoundedBox( 0, W*0.205, H*0.924, W*0.795, H*0.75, Color(50,50,50,255) )
- draw.DrawText( "MATERIALS LIST", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- end
- -- // ICON SCROLL LABEL \\ --
- IconScroll = vgui.Create( "DScrollPanel", EditorFrame )
- IconScroll:SetPos( 0, H*0.2 )
- IconScroll:SetSize( W*0.21, H*0.8 )
- local sbar = IconScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- local x , y = 0,0
- Button = {}
- for k , v in pairs (data.Materials) do
- Button[k] = vgui.Create( "DButton", IconScroll )
- Button[k]:SetPos( x, y )
- Button[k]:SetText( "" )
- Button[k]:SetSize( W*0.2, H*0.1 )
- Button[k].Paint = function( Panel )
- draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(130,130,140,255) )
- draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
- draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "Index [" .. v.Index .. "]", "Fact_Medium", W*0.065, H*0.04, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( v.Weight .. "Kg", "Fact_Small_Strong", W*0.065, H*0.08, Color( 255, 255, 255, 255 ), 0 )
- surface.SetDrawColor( v.LogoCol )
- surface.SetMaterial( Material(v.Logo) )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- if (Selected == v.Index) then
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- end
- end
- Button[k].DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- Selected = v.Index
- end
- y = (y + H*0.1) + 1
- end
- --> EDIT THE MATERIAL BUTTON :
- Edit = vgui.Create( "DButton", EditorFrame )
- Edit:SetPos( W*0.35, H*0.3)
- Edit:SetText( "" )
- Edit:SetFont( "Trebuchet24" )
- Edit:SetSize( W*0.25, H*0.45 )
- Edit.DoClick = function( Panel )
- if (Selected ~= "") then
- surface.PlaySound("factory/move3.ogg")
- EditorFrame:Remove()
- Fact_OpenEditorMaterials(data , data.Materials[Selected])
- else
- surface.PlaySound("factory/error2.ogg")
- end
- end
- Edit.Paint = function( Panel )
- if (Selected ~= "") then
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,180,80,255) )
- draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/usable.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,80,80,255) )
- draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
- surface.SetDrawColor( Color(150,150,150,255) )
- surface.SetMaterial( Material("factory/ui/usable.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- end
- end
- --> REMOVE THE MATERIAL BUTTON :
- Remove = vgui.Create( "DButton", EditorFrame )
- Remove:SetPos( W*0.65, H*0.3)
- Remove:SetText( "" )
- Remove:SetFont( "Trebuchet24" )
- Remove:SetSize( W*0.25, H*0.45 )
- Remove.DoClick = function( Panel )
- if (Selected ~= "") then
- surface.PlaySound("factory/move3.ogg")
- EditorFrame:Remove()
- net.Start("Fact_EditorRemoveMaterial")
- net.WriteTable( data.Materials[Selected] )
- net.SendToServer()
- else
- surface.PlaySound("factory/error2.ogg")
- end
- end
- Remove.Paint = function( Panel )
- if (Selected ~= "") then
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(180,80,80,255) )
- draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/cancel.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45 , Color(80,80,80,255) )
- draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
- surface.SetDrawColor( Color(150,150,150,255) )
- surface.SetMaterial( Material("factory/ui/cancel.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- end
- end
- local CloseBBool = false
- CloseB = vgui.Create( "DButton", EditorFrame )
- CloseB:SetPos( W*0.9, H*0.925)
- CloseB:SetText( "" )
- CloseB:SetFont( "Trebuchet24" )
- CloseB:SetSize( W*0.1, H*0.075 )
- CloseB.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- Fact_OpenEditor(data)
- end
- CloseB.Paint = function( Panel )
- if (CloseBBool) then
- draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(180,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
- CloseB.OnCursorExited = function() CloseBBool = false end
- end
- -- || RECIPE LIST EDITOR || --
- function Fact_OpenRecipeList( data )
- local W, H, Selected = ScrW(), ScrH(), ""
- if (EditorFrame) then EditorFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- EditorFrame = vgui.Create( "DFrame" )
- EditorFrame:SetPos( 0, 0 )
- EditorFrame:SetSize( W, H )
- EditorFrame:SetTitle( "" )
- EditorFrame:SetDraggable( false )
- EditorFrame:ShowCloseButton( false )
- EditorFrame:MakePopup()
- EditorFrame.Paint = function()
- draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
- draw.RoundedBox( 0, 0, H*0.2, W*0.205, H*0.8, Color(20,20,20,255) )
- draw.RoundedBox( 0, W*0.205, H*0.924, W*0.795, H*0.75, Color(50,50,50,255) )
- draw.DrawText( "MATERIALS LIST", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- end
- -- // ICON SCROLL LABEL \\ --
- IconScroll = vgui.Create( "DScrollPanel", EditorFrame )
- IconScroll:SetPos( 0, H*0.2 )
- IconScroll:SetSize( W*0.21, H*0.8 )
- local sbar = IconScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- local x , y = 0,0
- Button = {}
- for k , v in pairs (data.Recipe) do
- Button[k] = vgui.Create( "DButton", IconScroll )
- Button[k]:SetPos( x, y )
- Button[k]:SetText( "" )
- Button[k]:SetSize( W*0.2, H*0.1 )
- Button[k].Paint = function( Panel )
- draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(130,130,140,255) )
- draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
- draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "[" .. v.Index .. "]", "Fact_Small_Strong", W*0.065, H*0.04, Color( 255, 255, 255, 255 ), 0 )
- surface.SetDrawColor( v.LogoCol )
- surface.SetMaterial( Material(v.Logo) )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- if (Selected == v.Index) then
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- end
- end
- Button[k].DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- Selected = v.Index
- RLOAD = v
- PrintTable(v)
- end
- y = (y + H*0.1) + 1
- end
- --> EDIT THE RECIPE BUTTON :
- Edit = vgui.Create( "DButton", EditorFrame )
- Edit:SetPos( W*0.35, H*0.3)
- Edit:SetText( "" )
- Edit:SetFont( "Trebuchet24" )
- Edit:SetSize( W*0.25, H*0.45 )
- Edit.DoClick = function( Panel )
- if (Selected ~= "") then
- surface.PlaySound("factory/move3.ogg")
- EditorFrame:Remove()
- Fact_OpenRecipeEditor(data , RLOAD)
- else
- surface.PlaySound("factory/error2.ogg")
- end
- end
- Edit.Paint = function( Panel )
- if (Selected ~= "") then
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,180,80,255) )
- draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/usable.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(80,80,80,255) )
- draw.DrawText( "Edit", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
- surface.SetDrawColor( Color(150,150,150,255) )
- surface.SetMaterial( Material("factory/ui/usable.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- end
- end
- --> REMOVE THE RECIPE BUTTON :
- Remove = vgui.Create( "DButton", EditorFrame )
- Remove:SetPos( W*0.65, H*0.3)
- Remove:SetText( "" )
- Remove:SetFont( "Trebuchet24" )
- Remove:SetSize( W*0.25, H*0.45 )
- Remove.DoClick = function( Panel )
- if (Selected ~= "") then
- surface.PlaySound("factory/move3.ogg")
- EditorFrame:Remove()
- net.Start("Fact_EditorRemoveRecipe")
- net.WriteTable( data.Recipe[Selected] )
- net.SendToServer()
- else
- surface.PlaySound("factory/error2.ogg")
- end
- end
- Remove.Paint = function( Panel )
- if (Selected ~= "") then
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45, Color(180,80,80,255) )
- draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/cancel.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.25, H*0.45 , Color(80,80,80,255) )
- draw.DrawText( "Remove", "Fact_High_Strong", W*0.125, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
- surface.SetDrawColor( Color(150,150,150,255) )
- surface.SetMaterial( Material("factory/ui/cancel.png") )
- surface.DrawTexturedRect( W*0.05, H*0.1, W*0.15, H*0.28 )
- end
- end
- local CloseBBool = false
- CloseB = vgui.Create( "DButton", EditorFrame )
- CloseB:SetPos( W*0.9, H*0.925)
- CloseB:SetText( "" )
- CloseB:SetFont( "Trebuchet24" )
- CloseB:SetSize( W*0.1, H*0.075 )
- CloseB.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- Fact_OpenEditor(data)
- end
- CloseB.Paint = function( Panel )
- if (CloseBBool) then
- draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(180,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.1, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.05, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
- CloseB.OnCursorExited = function() CloseBBool = false end
- end
- -- || RECIPE EDITOR || --
- function Fact_OpenRecipeEditor( data, loaded )
- local W, H = ScrW(), ScrH(), "", {}, {}, true, "", "", {txt = "", alpha = 0}
- local Selected, Ingredients, IngredientsB = "", {}, {}
- local Logo, IconName, Error = "", "", {txt = "", alpha = 0}
- if (EditorFrame) then EditorFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- EditorFrame = vgui.Create( "DFrame" )
- EditorFrame:SetPos( 0, 0 )
- EditorFrame:SetSize( W, H )
- EditorFrame:SetTitle( "" )
- EditorFrame:SetDraggable( false )
- EditorFrame:ShowCloseButton( false )
- EditorFrame:MakePopup()
- EditorFrame.Paint = function()
- draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
- draw.DrawText( "RECIPE EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- draw.RoundedBox( 0, W*0.05, H*0.3, W*0.2, H*0.65, Color(70,70,70,255) )
- draw.RoundedBox( 0, W*0.05, H*0.25, W*0.2, H*0.05, Color(80,80,150,255) )
- draw.DrawText( "MATERIALS", "Fact_Medium_Strong", W*0.15, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- draw.RoundedBox( 0, W*0.3, H*0.3, W*0.18 + 3, H*0.3, Color(110,110,110,255) )
- draw.RoundedBox( 0, W*0.3, H*0.25, W*0.18 + 3, H*0.05, Color(80,80,150,255) )
- draw.DrawText( "INGREDIENTS", "Fact_Medium_Strong", W*0.39, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- draw.RoundedBox( 0, W*0.55, H*0.3, W*0.21, H*0.41, Color(110,110,110,255) )
- draw.RoundedBox( 0, W*0.55, H*0.25, W*0.21, H*0.05, Color(80,80,150,255) )
- draw.DrawText( "ICON : " .. string.upper(IconName), "Fact_Medium_Strong", W*0.66, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- draw.RoundedBox( 0, W*0.8, H*0.3, W*0.15, H*0.25, Color(110,110,110,255) )
- draw.RoundedBox( 0, W*0.8, H*0.25, W*0.15, H*0.05, Color(80,80,150,255) )
- draw.RoundedBox( 0, W*0.8, H*0.56, W*0.15, H*0.15, Color(110,110,110,255) )
- draw.DrawText( "PREVIEW", "Fact_Medium_Strong", W*0.875, H*0.255, Color( 255, 255, 255, 255 ), 1 )
- if (Logo ~= "") then
- surface.SetDrawColor( Mixer:GetColor() )
- surface.SetMaterial( Material(Logo) )
- surface.DrawTexturedRect( W*0.8 , H*0.3, W*0.15, H*0.25 )
- end
- draw.RoundedBox( 0, W*0.3, H*0.7, W*0.18 + 3, H*0.25, Color(110,110,110,255) )
- draw.RoundedBox( 0, W*0.3, H*0.65, W*0.18 + 3, H*0.05, Color(80,80,150,255) )
- draw.RoundedBox( 0, W*0.32, H*0.725, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
- draw.RoundedBox( 0, W*0.32, H*0.775, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
- draw.RoundedBox( 0, W*0.32, H*0.825, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
- -- draw.RoundedBox( 0, W*0.32, H*0.875, W*0.14 + 3, H*0.025, Color(255,255,255,255) )
- draw.DrawText( "INFORMATION", "Fact_Medium_Strong", W*0.39, H*0.655, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( Error.txt, "Fact_High_Strong", W*0.5, H*0.14, Color( 255, 0, 0, Error.num ), 1 )
- end
- --> MATERIAL SCROLL DERMA :
- MaterialScroll = vgui.Create( "DScrollPanel", EditorFrame )
- MaterialScroll:SetPos( W*0.05, H*0.3 )
- MaterialScroll:SetSize( W*0.21, H*0.65 )
- local sbar = MaterialScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- --> THE MATERIALS TABLE :
- local x , y = 0,0
- MatB = {}
- for k , v in pairs (data.Materials) do
- MatB[k] = vgui.Create( "DButton", MaterialScroll )
- MatB[k]:SetPos( x, y )
- MatB[k]:SetText( "" )
- MatB[k]:SetSize( W*0.2, H*0.1 )
- MatB[k].Paint = function( Panel )
- draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(120,120,140,255) )
- draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
- draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "Index [" .. v.Index .. "]", "Fact_Medium", W*0.065, H*0.04, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( v.Weight .. "Kg", "Fact_Small_Strong", W*0.065, H*0.07, Color( 255, 255, 255, 255 ), 0 )
- surface.SetDrawColor( v.LogoCol )
- surface.SetMaterial( Material(v.Logo) )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- if (Selected == v.Index) then
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- end
- end
- MatB[k].DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- if (Ingredients[v.Index]) then
- Ingredients[v.Index]["Amount"] = Ingredients[v.Index]["Amount"] + 1
- else
- Ingredients[v.Index] = v
- Ingredients[v.Index]["Amount"] = 1
- ResetList()
- end
- end
- y = (y + H*0.1) + 1
- end
- --> COLOR MIXER ICON :
- Mixer = vgui.Create( "DColorMixer", EditorFrame )
- Mixer:SetPos( W*0.8, H*0.56 )
- Mixer:SetSize( W*0.15,H*0.15 )
- Mixer:SetPalette( false )
- Mixer:SetAlphaBar( false )
- Mixer:SetWangs( false )
- Mixer:SetColor( Color( 255, 255, 255 ) )
- --> THE ICON SCROLL MENU :
- local IconScroll = vgui.Create( "DScrollPanel",EditorFrame )
- IconScroll:SetPos( W*0.55, H*0.3 )
- IconScroll:SetSize( W*0.22 - 1, H*0.41 )
- local sbar = IconScroll:GetVBar() -- CHANGE THE BAR COLOR
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- --> ICON MENU :
- Icon, x , y = {}, 0, 0
- for k , v in pairs (FactMod.Icon) do
- Icon[k] = vgui.Create( "DButton", IconScroll )
- Icon[k]:SetPos( x, y )
- Icon[k]:SetText( "" )
- Icon[k]:SetFont( "Trebuchet24" )
- Icon[k]:SetSize( W*0.07, H*0.11 )
- Icon[k].Paint = function( Panel )
- if ( Material(v) ~= nil ) then
- if (Logo == v) then
- surface.SetDrawColor( 255, 255, 255, 255 )
- else
- surface.SetDrawColor( 255, 255, 255, 50 )
- end
- surface.SetMaterial( Material(v) )
- surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
- if (Logo == v) then
- surface.SetDrawColor( 255, 255, 255, 255 )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.07, H*0.11 )
- end
- end
- end
- Icon[k].DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- Logo = v
- IconName = k
- end
- -- POSITION MANAGEMENT
- x = x + W*0.07
- if x > W*0.2 then x = 0 y = y + H*0.11 end
- end
- --> THE RECIPE NAME :
- local NameEntry = vgui.Create( "DTextEntry", EditorFrame )
- NameEntry:SetPos( W*0.32, H*0.725 )
- NameEntry:SetSize( W*0.14 + 3, H*0.025 )
- NameEntry:SetText( FactLang.Name )
- NameEntry:SetFont( "Fact_Small_Strong" )
- NameEntry:SetDrawBorder(false)
- NameEntry:SetDrawBackground(false)
- NameEntry.OnGetFocus = function(self)
- self:SetText("")
- end
- NameEntry.OnLoseFocus = function(self)
- if (self:GetValue() == "") then
- self:SetText( FactLang.Name ) end
- end
- --> THE ENTITY CLASS :
- local EntityEntry = vgui.Create( "DTextEntry", EditorFrame )
- EntityEntry:SetPos( W*0.32, H*0.775 )
- EntityEntry:SetSize( W*0.14 + 3, H*0.025 )
- EntityEntry:SetText( "Class" )
- EntityEntry:SetFont( "Fact_Small_Strong" )
- EntityEntry:SetDrawBorder(false)
- EntityEntry:SetDrawBackground(false)
- EntityEntry.OnGetFocus = function(self)
- self:SetText("")
- end
- EntityEntry.OnLoseFocus = function(self)
- if (self:GetValue() == "") then
- self:SetText( "Class" ) end
- end
- --> INDEX OG THE ENTITY :
- local IndexEntry = vgui.Create( "DTextEntry", EditorFrame )
- IndexEntry:SetPos( W*0.32, H*0.825 )
- IndexEntry:SetSize( W*0.14 + 3, H*0.025 )
- IndexEntry:SetText( "Index" )
- IndexEntry:SetFont( "Fact_Small_Strong" )
- IndexEntry:SetDrawBorder(false)
- IndexEntry:SetDrawBackground(false)
- IndexEntry.OnGetFocus = function(self)
- self:SetText("")
- end
- IndexEntry.OnLoseFocus = function(self)
- if (self:GetValue() == "") then
- self:SetText( "Index" ) end
- end
- --> HOW MANY IT WILL CRAFT FOR 1 RECIPE :
- -- local AmountEntry = vgui.Create( "DTextEntry", EditorFrame )
- -- AmountEntry:SetPos( W*0.32, H*0.875 )
- -- AmountEntry:SetSize( W*0.14 - 3, H*0.025 )
- -- AmountEntry:SetText( FactLang.Amount )
- -- AmountEntry:SetFont( "Fact_Small_Strong" )
- -- AmountEntry:SetDrawBorder(false)
- -- AmountEntry:SetDrawBackground(false)
- -- AmountEntry.OnGetFocus = function(self)
- -- self:SetText("")
- -- end
- -- AmountEntry.OnLoseFocus = function(self)
- -- local TheAmount = tonumber(self:GetValue())
- -- if ( not isnumber(TheAmount, 10)) then
- -- AmountEntry:SetText(FactLang.Amount)
- -- surface.PlaySound("factory/error2.ogg")
- -- Error.txt = "The Amount is not a number !"
- -- Error.alpha = 255
- -- end
- -- end
- --> CLOSE BUTTON :
- local CloseBBool = false
- CloseB = vgui.Create( "DButton", EditorFrame )
- CloseB:SetPos( W*0.55, H*0.85 )
- CloseB:SetText( "" )
- CloseB:SetSize( W*0.4, H*0.075 )
- CloseB.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- Fact_OpenEditor(data)
- end
- CloseB.Paint = function( Panel )
- if (CloseBBool) then
- draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(180,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_High_Strong", W*0.2, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_High_Strong", W*0.2, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
- CloseB.OnCursorExited = function() CloseBBool = false end
- --> VALID BUTTON :
- local ValidBBool = false
- ValidB = vgui.Create( "DButton", EditorFrame )
- ValidB:SetPos( W*0.55, H*0.75 )
- ValidB:SetText( "" )
- ValidB:SetSize( W*0.4, H*0.075 )
- ValidB.DoClick = function( Panel )
- if (table.Count( Ingredients ) <= 0) then
- surface.PlaySound("factory/error2.ogg")
- Error.txt = "There's no ingredient !"
- Error.alpha = 255
- return end
- if (Logo == "") then
- surface.PlaySound("factory/error2.ogg")
- Error.txt = "There's no Logo !"
- Error.alpha = 255
- return end
- local ingredientTable = {}
- for k , v in pairs (Ingredients) do
- ingredientTable[v.Index] = Ingredients[v.Index]["Amount"]
- end
- PrintTable(ingredientTable)
- local Recipe =
- {
- Ingredient = ingredientTable,
- Result = {
- Class = EntityEntry:GetValue(),
- },
- Name = NameEntry:GetValue(),
- Index = IndexEntry:GetValue(),
- Logo = Logo,
- LogoCol = Mixer:GetColor(),
- }
- net.Start("Fact_EditorSaveRecipe")
- net.WriteTable(Recipe)
- net.SendToServer()
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- end
- ValidB.Paint = function( Panel )
- if (ValidBBool) then
- draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(80,180,80,255) )
- draw.DrawText( FactLang.Save, "Fact_High_Strong", W*0.2, H*0.01, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.4, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Save, "Fact_High_Strong", W*0.2, H*0.01, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- ValidB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") ValidBBool = true end
- ValidB.OnCursorExited = function() ValidBBool = false end
- -- // ICON SCROLL LABEL \\ --
- IngredientsS = vgui.Create( "DScrollPanel", EditorFrame )
- IngredientsS:SetPos( W*0.3, H*0.3 )
- IngredientsS:SetSize( W*0.19, H*0.3 )
- local sbar = IngredientsS:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- --> RESET THE LIST :
- function ResetList()
- for k,v in pairs (IngredientsB) do IngredientsB[k]:Remove() end
- local x , y = 0,0
- for k , v in pairs (Ingredients) do
- IngredientsB[k] = vgui.Create( "DButton", IngredientsS )
- IngredientsB[k]:SetPos( x, y )
- IngredientsB[k]:SetText( "" )
- IngredientsB[k]:SetSize( W*0.06, H*0.1 )
- IngredientsB[k].Paint = function( Panel )
- -- draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(120,120,120,255) )
- surface.SetDrawColor( Color(70,70,70,255))
- surface.SetMaterial( Material(v.Logo) )
- surface.DrawTexturedRect( 3, 3, W*0.06, H*0.1 )
- surface.SetDrawColor( v.LogoCol )
- surface.SetMaterial( Material(v.Logo) )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- draw.DrawText( v.Name, "Fact_Small_Strong", 5, H*0.01, Color( 255, 255, 255, 255 ), 0 )
- draw.DrawText( "x" .. v.Amount, "Fact_Medium_Strong", 7, H*0.06, Color( 80, 80, 80, 255 ), 0 )
- draw.DrawText( "x" .. v.Amount, "Fact_Medium_Strong", 5, H*0.06, Color( 255, 255, 255, 255 ), 0 )
- end
- IngredientsB[k].DoClick = function( Panel )
- surface.PlaySound("factory/move1.ogg")
- Ingredients[k]["Amount"] = Ingredients[k]["Amount"] - 1
- if (Ingredients[k]["Amount"] <= 0) then
- Ingredients[k] = nil
- end
- ResetList()
- end
- x = (x + W*0.06) + 1
- if (x > W*0.18) then
- y = (y + H*0.1) + 1
- x = 0
- end
- end
- end
- ResetList()
- if (loaded) then
- NameEntry:SetText(loaded.Name)
- IndexEntry:SetText(loaded.Index)
- EntityEntry:SetText(loaded.Result.Class)
- Logo = loaded.Logo
- Mixer:SetColor(loaded.LogoCol)
- end
- end
- --> THE MAIN MENU :
- function Fact_OpenEditor( data )
- local W, H = ScrW(), ScrH()
- if (EditorFrame) then EditorFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- EditorFrame = vgui.Create( "DFrame" )
- EditorFrame:SetPos( 0, 0 )
- EditorFrame:SetSize( W, H )
- EditorFrame:SetTitle( "" )
- EditorFrame:SetDraggable( false )
- EditorFrame:ShowCloseButton( false )
- EditorFrame:MakePopup()
- EditorFrame.Paint = function()
- draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
- draw.DrawText( "EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- end
- -- // MATERIAL BUTTON \\ --
- local Button1B = false
- Button1 = vgui.Create( "DButton", EditorFrame )
- Button1:SetPos( W*0.35, H*0.25)
- Button1:SetText( "" )
- Button1:SetFont( "Trebuchet24" )
- Button1:SetSize( W*0.3, H*0.075 )
- Button1.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- Fact_OpenEditorMaterials( data )
- end
- Button1.Paint = function( Panel )
- if (Button1B) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
- draw.DrawText( "Material Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( "Material Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- Button1.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button1B = true end
- Button1.OnCursorExited = function() Button1B = false end
- -- // MAT LIST BUTTON \\ --
- local Button2B = false
- Button2 = vgui.Create( "DButton", EditorFrame )
- Button2:SetPos( W*0.35, H*0.35)
- Button2:SetText( "" )
- Button2:SetFont( "Trebuchet24" )
- Button2:SetSize( W*0.3, H*0.075 )
- Button2.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- Fact_OpenMaterialsList(data)
- end
- Button2.Paint = function( Panel )
- if (Button2B) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
- draw.DrawText( "Edit Materials", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( "Edit Materials", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- Button2.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button2B = true end
- Button2.OnCursorExited = function() Button2B = false end
- -- // RECIPE BUTTON \\ --
- local Button3B = false
- Button3 = vgui.Create( "DButton", EditorFrame )
- Button3:SetPos( W*0.35, H*0.45)
- Button3:SetText( "" )
- Button3:SetFont( "Trebuchet24" )
- Button3:SetSize( W*0.3, H*0.075 )
- Button3.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- Fact_OpenRecipeEditor(data)
- end
- Button3.Paint = function( Panel )
- if (Button3B) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
- draw.DrawText( "Recipe Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( "Recipe Editor", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- Button3.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button3B = true end
- Button3.OnCursorExited = function() Button3B = false end
- -- // RECIPE BUTTON \\ --
- local Button4B = false
- Button4 = vgui.Create( "DButton", EditorFrame )
- Button4:SetPos( W*0.35, H*0.55)
- Button4:SetText( "" )
- Button4:SetFont( "Trebuchet24" )
- Button4:SetSize( W*0.3, H*0.075 )
- Button4.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- Fact_OpenRecipeList(data)
- end
- Button4.Paint = function( Panel )
- if (Button4B) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(70,150,130,255) )
- draw.DrawText( "Edit Recipe", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( "Edit Recipe", "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- Button4.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") Button4B = true end
- Button4.OnCursorExited = function() Button4B = false end
- -- // CLOSE BUTTON \\ --
- local CloseBBool = false
- CloseB = vgui.Create( "DButton", EditorFrame )
- CloseB:SetPos( W*0.35, H*0.65)
- CloseB:SetText( "" )
- CloseB:SetFont( "Trebuchet24" )
- CloseB:SetSize( W*0.3, H*0.075 )
- CloseB.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- EditorFrame:Remove()
- end
- CloseB.Paint = function( Panel )
- if (CloseBBool) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(180,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.15, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.15, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
- CloseB.OnCursorExited = function() CloseBBool = false end
- end
- --> CRAFT MENU :
- function Fact_OpenCraftMenu( data )
- local W, H = ScrW(), ScrH()
- local Selected = {}
- local data = data
- local CanCraft = false
- if (CraftFrame) then CraftFrame:Remove() end
- -- // CREATE THE MAIN LABEL \\ --
- CraftFrame = vgui.Create( "DFrame" )
- CraftFrame:SetPos( 0, 0 )
- CraftFrame:SetSize( W, H )
- CraftFrame:SetTitle( "" )
- CraftFrame:SetDraggable( false )
- CraftFrame:ShowCloseButton( false )
- CraftFrame:MakePopup()
- CraftFrame.Paint = function()
- draw.RoundedBox( 0, 0, 0, W, H, Color(60,80,150,255) )
- draw.RoundedBox( 0, 0, H*0.2, W, H*0.8, Color(220,220,220,255) )
- draw.RoundedBox( 0, 0, H*0.925, W, H*0.075, Color(60,60,60,255) )
- draw.RoundedBox( 0, W*0.025, H*0.225, W*0.2, H*0.675, Color(50,50,60,255) )
- draw.RoundedBox( 0, W*0.025, H*0.225, W*0.2, H*0.075, Color(80,80,180,255) )
- draw.RoundedBox( 0, W*0.25, H*0.225, W*0.2, H*0.675, Color(50,50,50,255) )
- draw.RoundedBox( 0, W*0.25, H*0.225, W*0.2, H*0.075, Color(80,80,180,255) )
- draw.RoundedBox( 0, W*0.475, H*0.225, W*0.2, H*0.675, Color(50,50,50,255) )
- draw.RoundedBox( 0, W*0.475, H*0.225, W*0.2, H*0.075, Color(80,80,180,255) )
- draw.DrawText( "EDITOR", "Fact_Giant_Strong", W*0.5, H*0.025, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( FactLang.Recipe, "Fact_High_Strong", W*0.125, H*0.235, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( "Ingredients", "Fact_High_Strong", W*0.35, H*0.235, Color( 255, 255, 255, 255 ), 1 )
- draw.DrawText( "Content", "Fact_High_Strong", W*0.575, H*0.235, Color( 255, 255, 255, 255 ), 1 )
- end
- RecipeScroll = vgui.Create( "DScrollPanel", CraftFrame )
- RecipeScroll:SetPos( W*0.025, H*0.3 + 5 )
- RecipeScroll:SetSize( W*0.2, H*0.675 - 10 )
- local sbar = RecipeScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- local x , y = 0,0
- RecipeList = {}
- for k , v in pairs (data.Recipe) do
- RecipeList[k] = vgui.Create( "DButton", RecipeScroll )
- RecipeList[k]:SetPos( x, y )
- RecipeList[k]:SetText( "" )
- RecipeList[k]:SetSize( W*0.2, H*0.1 )
- RecipeList[k].Paint = function( Panel )
- draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(130,130,140,255) )
- draw.RoundedBox( 0, 0, 0, W*0.06, H*0.1, Color(80,80,80,255) )
- draw.DrawText( v.Name, "Fact_Medium", W*0.065, H*0.01, Color( 255, 255, 255, 255 ), 0 )
- surface.SetDrawColor( v.LogoCol )
- surface.SetMaterial( Material(v.Logo) )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- if (Selected.Index == v.Index) then
- surface.SetDrawColor( Color(255,255,255,255) )
- surface.SetMaterial( Material("factory/ui/box.png") )
- surface.DrawTexturedRect( 0, 0, W*0.06, H*0.1 )
- end
- end
- RecipeList[k].DoClick = function( Panel )
- surface.PlaySound("factory/click1.ogg")
- Selected = v
- RefreshIngredient()
- for k , v in pairs (v.Ingredient) do
- if ( data.Content[k] ) then
- if ( data.Content[k]["Amount"] >= v ) then
- CanCraft = true
- else
- CanCraft = false break
- end
- else
- CanCraft = false break
- end
- end
- end
- y = (y + H*0.1) + 1
- end
- IngredientList = {}
- IngredientScroll = vgui.Create( "DScrollPanel", CraftFrame )
- IngredientScroll:SetPos( W*0.25, H*0.3 + 5 )
- IngredientScroll:SetSize( W*0.2, H*0.675 - 10 )
- local sbar = IngredientScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function RefreshIngredient()
- for k, p in pairs (IngredientList) do
- IngredientList[k] = nil
- p:Remove()
- end
- local x, y = 0, 0
- for k , v in pairs (Selected.Ingredient) do
- IngredientList[k] = vgui.Create( "DButton", IngredientScroll )
- IngredientList[k]:SetPos( x, y )
- IngredientList[k]:SetText( "" )
- IngredientList[k]:SetSize( W*0.2, H*0.05 )
- if ( data.Content[k] ) then
- if ( v <= data.Content[k]["Amount"] ) then
- IngredientList[k].TextColor = Color(100,255,100,255)
- else
- IngredientList[k].TextColor = Color(255,100,100,255)
- end
- else
- IngredientList[k].TextColor = Color(220,100,100,255)
- end
- IngredientList[k].Paint = function( self )
- draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(80,80,90,255) )
- draw.DrawText( k .. " : x" .. v, "Fact_Medium", 10, H*0.01, self.TextColor, 0 )
- end
- y = (y + H*0.05) + 1
- end
- end
- ContentList = {}
- ContentScroll = vgui.Create( "DScrollPanel", CraftFrame )
- ContentScroll:SetPos( W*0.475, H*0.3 + 5 )
- ContentScroll:SetSize( W*0.2, H*0.675 - 10 )
- local sbar = ContentScroll:GetVBar()
- function sbar:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnUp:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0) ) end
- function sbar.btnDown:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- function sbar.btnGrip:Paint( w, h ) draw.RoundedBox( 0, 0, 0, w, h, Color( 0, 0, 0, 0 ) ) end
- local x, y = 0, 0
- for k , v in pairs (data.Content) do
- ContentList[k] = vgui.Create( "DButton", ContentScroll )
- ContentList[k]:SetPos( x, y )
- ContentList[k]:SetText( "" )
- ContentList[k]:SetSize( W*0.2, H*0.05 )
- ContentList[k].Paint = function( self )
- draw.RoundedBox( 0, 0, 0, W*0.2, H*0.1, Color(80,80,90,255) )
- draw.DrawText( v.Name .. " (x" .. v.Amount ..")", "Fact_Medium", 10, H*0.01, Color(255,255,255,255), 0 )
- end
- y = (y + H*0.05) + 1
- end
- -- // CLOSE BUTTON \\ --
- local CloseBBool = false
- CloseB = vgui.Create( "DButton", CraftFrame )
- CloseB:SetPos( W*0.7, H*0.6 + 2)
- CloseB:SetText( "" )
- CloseB:SetFont( "Trebuchet24" )
- CloseB:SetSize( W*0.275, H*0.075 )
- CloseB.DoClick = function( Panel )
- surface.PlaySound("factory/move2.ogg")
- CraftFrame:Remove()
- end
- CloseB.Paint = function( Panel )
- if (CloseBBool) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(180,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.135, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( FactLang.Close, "Fact_Medium_Strong", W*0.135, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- CloseB.OnCursorEntered = function() surface.PlaySound("factory/move1.ogg") CloseBBool = true end
- CloseB.OnCursorExited = function() CloseBBool = false end
- -- // CRAFT BUTTON \\ --
- CraftB = vgui.Create( "DButton", CraftFrame )
- CraftB:SetPos( W*0.7, H*0.5 + 2)
- CraftB:SetText( "" )
- CraftB:SetFont( "Trebuchet24" )
- CraftB:SetSize( W*0.275, H*0.075 )
- CraftB.DoClick = function( Panel )
- if (CanCraft) then
- local NTab = {}
- NTab.ENT = data.ENT
- NTab.Price = Selected
- net.Start("Fact_CraftItem")
- net.WriteTable(NTab)
- net.SendToServer()
- CraftFrame:Remove()
- surface.PlaySound("factory/move2.ogg")
- end
- end
- CraftB.Paint = function( Panel )
- if (CanCraft) then
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,180,80,255) )
- draw.DrawText( "Fabriquer", "Fact_Medium_Strong", W*0.135, H*0.02, Color( 255, 255, 255, 255 ), 1, 1 )
- else
- draw.RoundedBox( 0, 0, 0, W*0.3, H*0.075, Color(80,80,80,255) )
- draw.DrawText( "Fabriquer", "Fact_Medium_Strong", W*0.135, H*0.02, Color( 150, 150, 150, 255 ), 1, 1 )
- end
- end
- end
- net.Receive("Fact_OpenCraftMenu", function()
- local NTab = net.ReadTable()
- Fact_OpenCraftMenu(NTab)
- end)
- net.Receive("Fact_OpenEditor", function()
- local NTab = net.ReadTable()
- Fact_OpenEditor(NTab)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement