Dialogue menu stuff

master
E. Almqvist 5 years ago
parent 5b8fdf5fc3
commit 5fe5be4a5f
  1. 95
      gamemode/engine/derma/lib/cl_menu_dialogueBox.lua
  2. 13
      gamemode/engine/derma/lib/cl_menu_theme.lua
  3. 15
      gamemode/engine/derma/menus/menu_dialogue.lua
  4. 5
      gamemode/settings/sh_dialogues.lua

@ -56,45 +56,89 @@ function log.setHeightToLines( p, lines, font, add )
add = add || 0 add = add || 0
surface.SetFont(font) surface.SetFont(font)
local _, h = surface.GetTextSize("Quantum") local _, h = surface.GetTextSize("Quantum")
print(#lines)
PrintTable(lines)
p:SetHeight((#lines * h) + (#lines * padding_s) + add) p:SetHeight((#lines * h) + (#lines * padding_s) + add)
end end
function log.createDialogueBox( logdata, parent ) local maxW, maxH = 775 * scale, 160 * scale
cinematic = cinematic || true
local fw, fh = parent:GetSize() function log.createOptionButton( parent, index, text, font )
local logtext = logdata["init"].question local btn = parent:Add("DButton")
btn:SetContentAlignment(4)
btn:SetText(text)
btn:SetFont(font)
btn:SetTextColor( Color( 255, 255, 255, 200 ) )
btn.index = index
btn.w, btn.h = maxW - padding*4, 40 * scale
btn:SetSize( btn.w, btn.h )
btn.Paint = function( self )
theme.renderblur( self, 2, 6 )
theme.sharpbutton( self, Color( 20, 20, 20, 220) )
end
function btn:UpdateSize( add )
local font, lines = self:GetFont(), log.genTextLinebreak( self:GetText(), font, btn.w )
self:SetText( log.appendLinesToStr(lines, " ") )
log.setHeightToLines(self, lines, font, add)
self.w, self.h = self:GetSize()
self:Dock(TOP)
self:DockMargin( padding_s*4, 0, padding_s*4, padding_s*2 )
return self
end
return btn
end
function log.createContainer( parent, hide )
local box = vgui.Create( "DPanel", parent ) local box = vgui.Create( "DPanel", parent )
local maxW, maxH = 775 * scale, 160 * scale
box:SetSize( maxW, maxH ) box:SetSize( maxW, maxH )
box.Paint = function( self, w, h ) box.Paint = function( self )
-- background blur if( !hide ) then
theme.renderblur( self, 2, 7 ) theme.dialogueBox(self)
end
end
box.w, box.h = maxW, maxH
-- background function box:UpdateSize( lines, font, add )
surface.SetDrawColor( 20, 20, 20, 220 ) log.setHeightToLines(self, lines, font, add)
surface.DrawRect( 0, 0, w, h )
self.w, self.h = self:GetSize()
if( self.h > maxH ) then
self:SetHeight(maxH)
end
self.w, self.h = self:GetSize()
-- outline return self
surface.SetDrawColor( 220, 220, 220, 100)
surface.DrawOutlinedRect( 0, 0, w, h )
end end
local scroll = vgui.Create( "DScrollPanel", box ) local scroll = vgui.Create( "DScrollPanel", box )
scroll:SetSize( box:GetSize() ) scroll:SetSize( box:GetSize() )
scroll.Paint = function( self ) end scroll.Paint = function( self ) end
local sb = scroll:GetVBar() local sb = scroll:GetVBar()
sb.Paint = function( self ) end sb.Paint = Quantum.EmptyFunction
function sb.btnGrip:Paint() function sb.btnGrip:Paint()
theme.button( self, Color( 0, 0, 0, 0 ) ) theme.blurpanel(self)
end end
sb:SetWidth(padding)
sb.btnUp:SetSize(0,0) sb.btnUp:SetSize(0,0)
sb.btnUp.Paint = function(self) end
sb.btnDown:SetSize(0,0) sb.btnDown:SetSize(0,0)
sb.btnDown.Paint = function(self) end
scroll:SetSize( box:GetSize() ) scroll:SetSize( box:GetSize() )
scroll.w, scroll.h = scroll:GetSize() scroll.w, scroll.h = scroll:GetSize()
return box, scroll
end
function log.createQBox( logdata, parent )
cinematic = cinematic || true
local fw, fh = parent:GetSize()
local logtext = logdata["init"].question
local box, scroll = log.createContainer( parent )
local text = vgui.Create( "DLabel", scroll ) local text = vgui.Create( "DLabel", scroll )
text:SetFont( "q_dialogue_question" ) text:SetFont( "q_dialogue_question" )
text.lines = log.genTextLinebreak( logtext, text:GetFont(), maxW - (padding) ) text.lines = log.genTextLinebreak( logtext, text:GetFont(), maxW - (padding) )
@ -106,16 +150,13 @@ function log.createDialogueBox( logdata, parent )
text.w, text.h = text:GetSize() text.w, text.h = text:GetSize()
text:SetPos(padding, padding) text:SetPos(padding, padding)
log.setHeightToLines(box, text.lines, text:GetFont(), padding*2) box:UpdateSize( text.lines, text:GetFont(), padding*2 )
box:SetPos( fw/2 - box.w/2, fh*0.65 )
box.w, box.h = box:GetSize()
if( box.h > maxH ) then
box:SetHeight(maxH)
end
box:SetPos( fw/2 - box.w/2, fh*0.7 )
return box return box, text
end end
function log.createinfobox( logdata, parent, cinematic ) function log.createinfobox( logdata, parent, cinematic )
cinematic = cinematic || true cinematic = cinematic || true
local fw, fh = parent:GetSize() local fw, fh = parent:GetSize()
@ -124,7 +165,7 @@ function log.createinfobox( logdata, parent, cinematic )
local box = vgui.Create( "DPanel", parent ) local box = vgui.Create( "DPanel", parent )
box:SetSize( 775 * scale, 200 * scale ) box:SetSize( 775 * scale, 200 * scale )
box.Paint = function( self ) theme.sharpblurpanel( self ) end box.Paint = function( self ) theme.dialogueBox( self ) end
box.w, box.h = box:GetSize() box.w, box.h = box:GetSize()
box:SetPos( fw/2 - box.w/2, fh*0.8 - box.h/2 ) box:SetPos( fw/2 - box.w/2, fh*0.8 - box.h/2 )
box.x, box.y = box:GetPos() box.x, box.y = box:GetPos()

@ -260,6 +260,19 @@ function theme.fadebutton( b, dir, inColor, font, txtColor )
end end
function theme.dialogueBox( p )
local w, h = p:GetSize()
-- background blur
theme.renderblur( p, 2, 7 )
-- background
surface.SetDrawColor( 20, 20, 20, 220 )
surface.DrawRect( 0, 0, w, h )
-- outline
surface.SetDrawColor( 220, 220, 220, 60)
surface.DrawOutlinedRect( 0, 0, w, h )
end
---- Color Manipulation ---- ---- Color Manipulation ----
theme.color = {} theme.color = {}

@ -92,8 +92,21 @@ function menu.open( dt )
title.w, title.h = title:GetSize() title.w, title.h = title:GetSize()
title:SetPos(padding*2, borderHeight/2 - title.h/2) title:SetPos(padding*2, borderHeight/2 - title.h/2)
-- Dialogue options
f.dialogue.cont, f.dialogue.contScroll = log.createContainer( f, true )
f.dialogue.cont.options = {}
local btnFont = "q_info"
for i, option in SortedPairs(dialogue["init"].response) do
f.dialogue.cont.options[i] = log.createOptionButton( f.dialogue.contScroll, i, option.text, btnFont )
f.dialogue.cont.options[i]:UpdateSize(padding_s)
end
f.dialogue.cont:SetPos( f.w/2 - f.dialogue.cont.w/2, f.h - f.dialogue.cont.h - padding )
f.dialogue.cont.x, f.dialogue.cont.y = f.dialogue.cont:GetPos()
-- Dialogue question -- Dialogue question
f.dialogue.q = log.createDialogueBox( dialogue, f ) f.dialogue.q, f.dialogue.qtext = log.createQBox( dialogue, f )
f.dialogue.q:SetPos( f.w/2 - f.dialogue.q.w/2, f.dialogue.cont.y - f.dialogue.q.h - padding*2 )
return f return f
end end

@ -19,6 +19,11 @@ Quantum.Dialogue.Create( "npc_generalvendor" )
end end
}, 1 ) }, 1 )
Quantum.Dialogue.AddResponse( "npc_generalvendor", "init", {
text = "To take all of your money! Aaaaa aaaa a aa a a a aa aa a aa a a a aa aa a a a a aaaaaaaaaaaaaaaaa a a a a aa a a a a aa a aa a aa a a a aaaa a a aa a aa aa aa!"
}, 2 )
Quantum.Dialogue.AddQuestion( "npc_generalvendor", "sellorbuy", "What do you have in mind?" ) Quantum.Dialogue.AddQuestion( "npc_generalvendor", "sellorbuy", "What do you have in mind?" )
Quantum.Dialogue.AddResponse( "npc_generalvendor", "sellorbuy", { Quantum.Dialogue.AddResponse( "npc_generalvendor", "sellorbuy", {

Loading…
Cancel
Save