Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[-------------------------------------------------------------------------
- Init Code
- ---------------------------------------------------------------------------]]
- if !CI then CI = {} end
- if !CI.data then CI.data = {} end
- if !CI.menu then CI.menu = {} end
- function CI.Msg(msg)
- if Q_Lib then Q_Lib.Msg(CI.Q_LIBID,msg) end
- end
- CI.isEditting = false
- CI.selectedSceane = false
- CI.sel_Scene = nil // Currently selected scene
- CI.sel_Cam = nil // Currently selected cam
- CI.Q_LIBID = nil
- --[[-------------------------------------------------------------------------
- Init Library
- ---------------------------------------------------------------------------]]
- hook.Add("HUDPaint", "CI_Init_Load", function()
- if include('qlib/cl_q_lib.lua') then
- CI.Q_LIBID = Q_Lib.RegisterAddon({
- name = "Cinematic Intro",
- shrt_name = "CIntro",
- description = "Create a Cinematic Introduction for your server with fancy affects.",
- uid = 76561198339572056,
- error_report = [Error] Destination host down,
- })
- hook.Remove("HUDPaint", "CI_Init_Load")
- end
- end)
- --[[-------------------------------------------------------------------------
- Core Functions
- ---------------------------------------------------------------------------]]
- function CI.redrawCameras()
- CI.Msg("Redrawing cameras")
- end
- function CI.data_Save(data, map)
- if !data then data = CI.data end
- if !map then map = game.GetMap() end
- CI.Msg("Saved the current map data to server.")
- net.Start("ci:submit")
- net.WriteString(util.TableToJSON(data))
- net.SendToServer()
- --PrintTable(data)
- end
- function CI.global_Update(_d)
- table.Merge(CI.data.settings,_d)
- CI.Msg("Update made. Pushing content to server.")
- CI.data_Save()
- end
- --[[-------------------------------------------------------------------------
- Scene, Camera, Helper funcs.
- ---------------------------------------------------------------------------]]
- function CI.select_Scene(id)
- if !id then id = 1 end
- if CI.data.scenes and CI.data.scenes[id] then
- CI.sel_Scene = id
- CI.redrawCameras()
- CI.Msg("Selected scene: "..id.."/"..table.Count(CI.data.scenes).." ("..table.Count(CI.data.scenes[CI.sel_Scene].cams).." cams).")
- end
- end
- function CI.select_Cam(id)
- if !id then id = 1 end
- if CI.sel_Scene and CI.data.scenes[CI.sel_Scene] and CI.data.scenes[CI.sel_Scene].cams[id] then
- CI.sel_Cam = id
- CI.Msg("Selected cam: "..id.."/"..table.Count(CI.data.scenes[CI.sel_Scene].cams)..".")
- end
- end
- function CI.scene_Add(data)
- if !data then data = CI.data end
- if !data.scenes then data.scenes = {} end
- if !data.settings then data.settings = {entities = {}, pp = {}, only_once = false, loop = false, music = "" } end -- create the table xd
- local newScene = {cams = {}, settings = {title = "", subtitle = "", length = 1}}
- table.insert(data.scenes, newScene)
- CI.sel_Scene = table.Count(data.scenes)
- CI.menu.EMenu(true)
- CI.Msg("Inserting a new scene: "..CI.sel_Scene..".")
- end
- function CI.updateCam(data)
- if !data then data = CI.data end
- if !data.scenes or !CI.sel_Scene or !CI.sel_Cam or !data.scenes[CI.sel_Scene] or !data.scenes[CI.sel_Scene].cams[CI.sel_Cam] then return end
- local data_t = data.scenes[CI.sel_Scene].cams[CI.sel_Cam]
- data_t.pos = LocalPlayer():EyePos()
- data_t.ang = LocalPlayer():EyeAngles()
- CI.Msg("Updating Camera for SceneID "..CI.sel_Scene.." CameraID "..CI.sel_Cam)
- end
- function CI.cam_Add(data)
- if !data then data = CI.data end
- if !data.scenes or !CI.sel_Scene or !data.scenes[CI.sel_Scene] then CI.Msg("No scene selected") return end
- local newCam = {pos = LocalPlayer():EyePos(), ang = LocalPlayer():EyeAngles()}
- table.insert(data.scenes[CI.sel_Scene].cams, newCam)
- CI.sel_Cam = table.Count(data.scenes[CI.sel_Scene].cams)
- CI.menu.EMenu(true)
- CI.Msg("Inserting a new cam: "..CI.sel_Cam.." to scene: "..CI.sel_Scene..".")
- end
- function CI.scene_Update(_d,id)
- if isbool(_d) then
- table.remove(CI.data.scenes,id)
- CI.Msg("Data deleted for Scene ID"..id)
- CI.data_Save()
- return end
- table.Merge(CI.data.scenes[id].settings,_d)
- CI.Msg("Inserting data into SceneID: "..id.." make sure to save changes.")
- CI.data_Save()
- end
- --[[-------------------------------------------------------------------------
- Handle Keys
- ---------------------------------------------------------------------------]]
- local Keys = {}
- Keys.insert = {mouse = nil, key = KEY_INSERT, onPress = function() end, onRelease = function() CI.scene_Add() end}
- Keys.save = {mouse = nil, key = KEY_END, onPress = function() end, onRelease = function() CI.data_Save() end}
- Keys.page_down = {mouse = nil, key = KEY_PAGEUP, onPress = function() end, onRelease = function() CI.select_Scene((CI.sel_Scene or 1)-1) end}
- Keys.page_up = {mouse = nil, key = KEY_PAGEDOWN, onPress = function() end, onRelease = function() CI.select_Scene((CI.sel_Scene or 1)+1) end}
- Keys.mouse_r = {mouse = MOUSE_RIGHT, key = nil, onPress = function() end, onRelease = function() CI.cam_Add() end}
- Keys.cam_up = {mouse = nil, key = KEY_UP, onPress = function() end, onRelease = function() CI.select_Cam((CI.sel_Cam or 1)+1) end}
- Keys.cam_down = {mouse = nil, key = KEY_DOWN, onPress = function() end, onRelease = function() CI.select_Cam((CI.sel_Cam or 1)-1) end}
- Keys.update = {mouse = MOUSE_LEFT, key = nil, onPress = function() end, onRelease = function() CI.updateCam() end}
- hook.Add("Tick","Tick_ci",function ()
- if CI.isEditting and !vgui.CursorVisible() then
- for k,v in pairs(Keys) do
- local isDown = v.key and input.IsKeyDown(v.key) or v.mouse and input.IsMouseDown(v.mouse)
- if isDown and !v.isDown then
- if v.onPress then v.onPress() end
- v.isDown = true
- elseif !isDown and v.isDown then
- if v.onRelease then v.onRelease() end
- v.isDown = nil
- end
- end
- end
- end)
- --[[-------------------------------------------------------------------------
- Other
- ---------------------------------------------------------------------------]]
- -- hook.Add("PrePlayerDraw","PrePlayerDraw_CI",function (ply)
- -- if CI.isEditting then return true end
- -- end)
- net.Receive("ci:orbit",function() CI.isEditting = net.ReadBool() CI.menu.EMenu(CI.isEditting) end)
- concommand.Add("CI_Save", function(ply, cnt, arg) CI.data_Save() end)
- -- concommand.Add("CI_AddScene", function(ply, cnt, arg) CI.scene_Add() end)
- -- concommand.Add("CI_AddCam", function(ply, cnt, arg) CI.data_Save_CurMap() end)
- -- local function drawCamera()
- -- local cam = ClientsideModel( "models/dav0r/camera.mdl" )
- -- cam:SetPos(ply:GetPos())
- -- cam:SetAngles(ply:GetAngles())
- -- return cam
- -- end
- local rope = Material("cable/rope")
- hook.Add("PostDrawTranslucentRenderables", "PostDrawTranslucentRenderables_ci", function(_,skybox)
- -- if skybox then return end
- -- for k,v in pairs(markers) do
- -- render.SetMaterial(rope)
- -- render.DrawBeam( v["vector1"], v["vector2"], 1, 0, 0, Color(255,0,0,255) )
- -- render.SetMaterial(rope)
- -- render.DrawBeam( v["vector1"], v["lookingAt1"], 1, 0, 0, Color(0,255,0,255) )
- -- render.SetMaterial(rope)
- -- render.DrawBeam( v["vector2"], v["lookingAt2"], 1, 0, 0, Color(0,255,0,255) )
- -- render.DrawWireframeSphere( Vector(v["vector1"].x,v["vector1"].y,v["vector1"].z+25), 10, 20, 20, Color(255,50,50,255) )
- -- render.DrawWireframeSphere( Vector(v["vector2"].x,v["vector2"].y,v["vector2"].z+25), 10, 20, 20, Color(255,50,50,255) )
- -- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement