Added dialogue backend, began work on menu

master
E. Almqvist 5 years ago
parent 59c3686242
commit 8a5f40c9a2
  1. 2
      gamemode/engine/derma/lib/cl_menu_dialogueBox.lua
  2. 24
      gamemode/engine/derma/menus/menu_dialogue.lua
  3. 16
      gamemode/engine/lib/sh_dialogue.lua
  4. 36
      gamemode/settings/sh_dialogues.lua
  5. 3
      gamemode/settings/sv_nodes_locations.lua
  6. 2
      gamemode/shared.lua

@ -5,6 +5,8 @@
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
-- This is mainly used for cinematic, do not confuse it with NPC dialogue
local log = {}
local scale = Quantum.Client.ResolutionScale
local padding = 10 * scale

@ -0,0 +1,24 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
local menu = {}
local snm = Quantum.Client.Menu.GetAPI( "net" )
local theme = Quantum.Client.Menu.GetAPI( "theme" )
local resScale = Quantum.Client.ResolutionScale
local sw, sh = ScrW(), ScrH()
local padding = 10 * resScale
local padding_s = 4 * resScale
function menu.open( dt )
if( !f ) then
end
end
return menu

@ -10,27 +10,37 @@ Quantum.Dialogue = {}
Quantum.DialogueTbl = {}
function Quantum.Dialogue.Create( id, tbl )
tbl = tbl || {}
local dialogue = {
bye = tbl.bye || "Nevermind, goodbye.",
options = tbl.options || {}
}
Quantum.DialogueTbl[id] = dialogue
return dialogue
end
function Quantum.Dialogue.AddQuestion( id, qid, q )
if CLIENT then
if( Quantum.DialogueTbl[id] == nil ) then
Quantum.Error("Dialogue '" .. tostring(id) .. "' does not exist! Can not add question to it.")
return
else
Quantum.DialogueTbl[id][qid] = {
question = q || "...",
response = {}
}
return qid
end
end
end
function Quantum.Dialogue.AddResponse( id, qid, tbl, order )
if CLIENT then
table.insert(Quantum.DialogueTbl[id][qid].response, order, {
text = tbl.text || "...",
func = tbl.func,
newqID = tbl.newqID
func = tbl.func, -- function to be ran on the client side
newqID = tbl.newqID -- if it leads to a new question, then forward it to its id, if nil then terminate conversation
})
end
end

@ -0,0 +1,36 @@
-- __ _ _______ _ __
-- / / /\ | | |__ __| | | \ \
-- / / / \ | |_ __ ___ | | ___ ___| |__ \ \
-- < < / /\ \ | | '_ ` _ \| |/ _ \/ __| '_ \ > >
-- \ \ / ____ \| | | | | | | | __/ (__| | | | / /
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
---- CREATE DIALOGUE INSTANCES UNDER THIS LINE ----
Quantum.Dialogue.Create( "npc_generalvendor" )
Quantum.Dialogue.AddQuestion( "npc_generalvendor", "init", "What do you want?" )
Quantum.Dialogue.AddResponse( "npc_generalvendor", "init", {
text = "To do business.",
newqID = "sellorbuy",
func = function()
print("You pressed this response!")
end
}, 1 )
Quantum.Dialogue.AddQuestion( "npc_generalvendor", "sellorbuy", "What do you have in mind?" )
Quantum.Dialogue.AddResponse( "npc_generalvendor", "sellorbuy", {
text = "What do you have for sale?",
func = function()
print("You pressed this response! BUY")
end
}, 1 )
Quantum.Dialogue.AddResponse( "npc_generalvendor", "sellorbuy", {
text = "I would like to sell some things.",
func = function()
print("You pressed this response! SELL")
end
}, 2 )

@ -6,7 +6,8 @@
-- \_\ /_/ \_\_|_| |_| |_|_|\___|\___|_| |_| /_/
-- NPC nodes --
Quantum.Node.Register( "generalvendor", Vector( 12737.1484375, -12749.354492188, -287 ), Angle( 0, 90, 0 ) )
Quantum.Node.Register( "generalvendor", Vector( 12737.1484375, -12749.354492188, -287 ), Angle( 0, 90, 0 ) ) -- Boat vendor
Quantum.Node.Register( "generalvendor", Vector( 3930.3623046875, 6764.8793945313, 16.03125 ), Angle( 0, -90, 0 ) ) -- Vendor at spawn
-- Resource nodes --
Quantum.Node.Register( "stone", Vector( 14877.728515625, -916.02612304688, 768 ), Angle( 0, -139.03350830078, 0 ) )

@ -8,7 +8,7 @@
GM.Name = "Quantum Framework"
GM.Author = "AlmTech"
GM.Email = "elias@almtech.se"
GM.Website = "N/A"
GM.Website = "www.almtech.se"
Quantum = {}
Quantum.Version = "v0.5-beta"

Loading…
Cancel
Save