Dialogue menu stuff

master
E. Almqvist 5 years ago
parent 8a5f40c9a2
commit 9a09d1d678
  1. 7
      entities/entities/q_npc/init.lua
  2. 1
      gamemode/cl_init.lua
  3. 5
      gamemode/engine/derma/lib/cl_menu_dialogueBox.lua
  4. 54
      gamemode/engine/derma/menus/menu_dialogue.lua
  5. 7
      gamemode/engine/lib/client/cl_cinematic.lua
  6. 11
      gamemode/engine/lib/sh_dialogue.lua
  7. 3
      gamemode/engine/lib/sh_node.lua
  8. 2
      gamemode/init.lua
  9. 1
      gamemode/settings/sh_nodes.lua

@ -27,11 +27,14 @@ function ENT:Initialize()
self:DropToFloor()
end
function ENT:Use()
function ENT:Use( activator, caller )
if( self.node != nil ) then
if( self.node.dialogueID ) then
-- open up dialogue menu
Quantum.Net.OpenMenu(activator, "dialogue", { ent = self, dialogueID = self.node.dialogueID })
end
if( #self.node.voiceLines > 0 ) then
self:EmitSound(self.node.voiceLines[math.random(1, #self.node.voiceLines)])
self:EmitSound(self.node.voiceLines[math.random(1, #self.node.voiceLines)]) -- emit a voiceline
end
end
end

@ -53,6 +53,7 @@ if CLIENT then
include( "settings/sh_recipes.lua" )
include( "settings/sh_nodes.lua" )
include( "settings/sh_properties.lua" )
include( "settings/sh_dialogues.lua" )
end
local function loadPlugins()

@ -14,7 +14,8 @@ local padding_s = 4 * scale
local theme = Quantum.Client.Menu.GetAPI( "theme" )
function log.createinfobox( logdata, parent )
function log.createinfobox( logdata, parent, cinematic )
cinematic = cinematic || true
local fw, fh = parent:GetSize()
local logtitle = logdata[1].title
local logtext = logdata[1].text
@ -74,7 +75,7 @@ function log.createinfobox( logdata, parent )
text:SetPos( scroll.w/2 - text.w/2, 0 )
text.Think = function( self )
if( Quantum.Client.Cam.Temp != nil ) then
if( Quantum.Client.Cam.Temp != nil && cinematic ) then
if( logdata[Quantum.Client.Cam.Temp.scene_index] != nil ) then
self:SetText( logdata[Quantum.Client.Cam.Temp.scene_index].text )
end

@ -9,14 +9,68 @@ local menu = {}
local snm = Quantum.Client.Menu.GetAPI( "net" )
local theme = Quantum.Client.Menu.GetAPI( "theme" )
local fade = Quantum.Client.Menu.GetAPI( "fade" )
local resScale = Quantum.Client.ResolutionScale
local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
local padding_s = 4 * resScale
local scenes = {
[1] = {
fov = 60,
velocity = 1,
}
}
function menu.open( dt )
if( dt.cont.dialogueID == nil ) then return end
if( !f ) then
Quantum.Client.IsInMenu = true -- hide the hud
-- make the cinematic start from the players pov
scenes[1].pos1 = LocalPlayer():GetBonePosition(LocalPlayer():LookupBone("ValveBiped.Bip01_Head1")) || Vector()
scenes[1].ang1 = LocalPlayer():GetAngles()
local npc = dt.cont.ent
scenes[1].ang2 = Quantum.Client.Cam.InvertAngle(npc:GetAngles()) || Angle() -- make the camera look at the NPC
scenes[1].pos2 = npc:GetBonePosition(npc:LookupBone("ValveBiped.Bip01_Head1")) + scenes[1].ang2:Forward() * -28 || Vector() -- Move the camera forward
Quantum.Client.Cam.Start( scenes, true, false )
local dialogue = Quantum.Dialogue.Get( dt.cont.dialogueID )
local f = vgui.Create( "DFrame" )
f:SetSize( sw, sh )
f:SetTitle( "" )
f:ShowCloseButton( false )
f.Paint = function( self, w, h )
surface.SetDrawColor( Color( 20, 20, 20, 255 ) )
local height = 90 * resScale
surface.DrawRect( 0, 0, w, height )
surface.DrawRect( 0, h - height, w, height )
end
f:SetDraggable( false )
f:MakePopup()
function f:OnClose()
Quantum.Client.IsInMenu = false
Quantum.Client.Cam.Stop() -- stop the cinematic
end
local keycodesClose = {
[KEY_ESCAPE] = true,
[KEY_TAB] = true
}
function f:OnKeyCodeReleased( keyCode )
if( keycodesClose[keyCode] ) then
self:Close()
end
end
f.w, f.h = f:GetSize()
local q = vgui.Create( "DLabel", f )
end
end

@ -7,14 +7,15 @@
Quantum.Client.Cam = {}
function Quantum.Client.Cam.InvertAngle( ang ) return Angle( -ang.x, ang.y, -ang.z ) end -- Flip the camera 180* relative to target
function Quantum.Client.Cam.InvertAngle( ang ) return Angle( ang.x, -ang.y, ang.z ) end -- Flip the camera 180* relative to target
function Quantum.Client.Cam.Stop()
hook.Remove( "CalcView", "Quantum_Cinematic" )
Quantum.Client.Cam.Temp = nil -- remove the var becuase it is unneeded
end
function Quantum.Client.Cam.Start( scene, loop )
function Quantum.Client.Cam.Start( scene, loop, drawviewer )
drawviewer = drawviewer || false
if( scene == nil ) then
Quantum.Error( "Scene does not exist! Aborting..." )
return
@ -43,7 +44,7 @@ function Quantum.Client.Cam.Start( scene, loop )
view.origin = LerpVector( frac, scene[Quantum.Client.Cam.Temp.scene_index].pos1, scene[Quantum.Client.Cam.Temp.scene_index].pos2 )
view.angles = LerpAngle( frac, scene[Quantum.Client.Cam.Temp.scene_index].ang1, scene[Quantum.Client.Cam.Temp.scene_index].ang2 )
view.fov = fov
view.drawviewer = true
view.drawviewer = drawviewer
if( view.origin:IsEqualTol( scene[Quantum.Client.Cam.Temp.scene_index].pos2, 1 ) ) then
if( Quantum.Client.Cam.Temp.scene_index + 1 <= #scene ) then

@ -44,3 +44,14 @@ function Quantum.Dialogue.AddResponse( id, qid, tbl, order )
})
end
end
function Quantum.Dialogue.Get( id )
if CLIENT then
Quantum.Debug("Dialogue fetch:")
PrintTable(Quantum.DialogueTbl)
return Quantum.DialogueTbl[id]
else
Quantum.Error("Can not fetch dialogue table from serverside!")
end
end

@ -25,7 +25,8 @@ function Quantum.Node.Create( nodeid, tbl )
health = tbl.health || Quantum.DefaultNodeHealth,
respawn = tbl.respawn || Quantum.DefaultNodeRespawnTimer,
voiceLines = tbl.voiceLines || {},
damageSounds = tbl.damageSounds || {}
damageSounds = tbl.damageSounds || {},
dialogueID = tbl.dialogueID
}
node.id = nodeid

@ -18,6 +18,7 @@ if SERVER then
AddCSLuaFile( "settings/sh_crafting_stations.lua" )
AddCSLuaFile( "settings/sh_nodes.lua" )
AddCSLuaFile( "settings/sh_properties.lua" )
AddCSLuaFile( "settings/sh_dialogues.lua" )
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
@ -125,6 +126,7 @@ if SERVER then
include( "settings/sh_nodes.lua" )
include( "settings/sv_nodes_locations.lua" )
include( "settings/sh_properties.lua" )
include( "settings/sh_dialogues.lua" )
Quantum.Server.Station.UpdateAll()
end

@ -10,6 +10,7 @@ Quantum.Node.Create( "generalvendor", {
name = "General Goods Vendor",
model = "models/kleiner.mdl",
type = Quantum.NodeType.npc,
dialogueID = "npc_generalvendor",
voiceLines = {
"vo/coast/odessa/nlo_cub_hello.wav",

Loading…
Cancel
Save