From 903982e57a72c17b5de0e3aba6fe86feeb4605ed Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Thu, 28 May 2020 13:14:46 +0200 Subject: [PATCH] Dialogue stuff --- .../engine/derma/lib/cl_menu_dialogueBox.lua | 39 ++++++++++++++++++- gamemode/engine/derma/lib/cl_menu_theme.lua | 3 +- gamemode/engine/derma/menus/menu_dialogue.lua | 15 +++---- 3 files changed, 46 insertions(+), 11 deletions(-) diff --git a/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua b/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua index 39c3d5a..804329d 100644 --- a/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua +++ b/gamemode/engine/derma/lib/cl_menu_dialogueBox.lua @@ -14,6 +14,43 @@ local padding_s = 4 * scale local theme = Quantum.Client.Menu.GetAPI( "theme" ) +function log.createDialogueBox( logdata, parent ) + cinematic = cinematic || true + local fw, fh = parent:GetSize() + local logtext = logdata["init"].question + + local box = vgui.Create( "DPanel", parent ) + box:SetSize( 775 * scale, 80 * scale ) + box.Paint = theme.sharpblurpanel( self ) + box.w, box.h = box:GetSize() + box:SetPos( fw/2 - box.w/2, fh*0.7 - box.h/2 ) + box.x, box.y = box:GetPos() + + local scroll = vgui.Create( "DScrollPanel", box ) + scroll:SetSize( box:GetSize() ) + scroll.Paint = function( self ) end + local sb = scroll:GetVBar() + sb.Paint = function( self ) end + function sb.btnGrip:Paint() + theme.button( self, Color( 0, 0, 0, 0 ) ) + end + sb.btnUp:SetSize(0,0) + sb.btnDown:SetSize(0,0) + scroll.w, scroll.h = scroll:GetSize() + + local text = vgui.Create( "DLabel", scroll ) + text:SetText( logtext ) + text:SetFont( "q_dialogue_question" ) + text:SetTextColor( Color( 240, 240, 240, 255 ) ) + text:SetSize( scroll.w * 0.95, scroll.h * 0.95 ) + text:SetWrap( true ) + + text.w, text.h = text:GetSize() + + text:SetPos( scroll.w/2 - text.w/2, 0 ) + + return box +end function log.createinfobox( logdata, parent, cinematic ) cinematic = cinematic || true local fw, fh = parent:GetSize() @@ -85,4 +122,4 @@ function log.createinfobox( logdata, parent, cinematic ) return box end -return log \ No newline at end of file +return log diff --git a/gamemode/engine/derma/lib/cl_menu_theme.lua b/gamemode/engine/derma/lib/cl_menu_theme.lua index 4fa901f..a90ae86 100644 --- a/gamemode/engine/derma/lib/cl_menu_theme.lua +++ b/gamemode/engine/derma/lib/cl_menu_theme.lua @@ -260,6 +260,7 @@ function theme.fadebutton( b, dir, inColor, font, txtColor ) end + ---- Color Manipulation ---- theme.color = {} @@ -268,4 +269,4 @@ function theme.color.setalpha( color, alpha ) end -return theme \ No newline at end of file +return theme diff --git a/gamemode/engine/derma/menus/menu_dialogue.lua b/gamemode/engine/derma/menus/menu_dialogue.lua index 18c9d71..725fc27 100644 --- a/gamemode/engine/derma/menus/menu_dialogue.lua +++ b/gamemode/engine/derma/menus/menu_dialogue.lua @@ -10,6 +10,7 @@ local menu = {} local snm = Quantum.Client.Menu.GetAPI( "net" ) local theme = Quantum.Client.Menu.GetAPI( "theme" ) local fade = Quantum.Client.Menu.GetAPI( "fade" ) +local log = Quantum.Client.Menu.GetAPI( "dialogue" ) local resScale = Quantum.Client.ResolutionScale local sw, sh = ScrW(), ScrH() @@ -53,10 +54,12 @@ function menu.open( dt ) f:SetTitle( "" ) f:ShowCloseButton( false ) local borderHeight = 90 * resScale - f.Paint = function( self, w, h ) + f.Paint = function( self, w, h ) + --[[ surface.SetDrawColor( Color( 20, 20, 20, 255 ) ) surface.DrawRect( 0, 0, w, borderHeight ) surface.DrawRect( 0, h - borderHeight, w, borderHeight ) + --]] end f:SetDraggable( false ) f:MakePopup() @@ -78,7 +81,7 @@ function menu.open( dt ) f.w, f.h = f:GetSize() f.dialogue = {} - local textColor = Color(255, 255, 255, 120) + local textColor = Color(255, 255, 255, 220) -- Title is static, can't be changed mid dialogue. local title = vgui.Create( "DLabel", f ) -- dialogue title, useally the npcs name or something @@ -90,13 +93,7 @@ function menu.open( dt ) title:SetPos(padding*2, borderHeight/2 - title.h/2) -- Dialogue question - f.dialogue.q = vgui.Create("DLabel", f) - f.dialogue.q:SetText(dialogue["init"].question) - f.dialogue.q:SetFont("q_dialogue_question") - f.dialogue.q:SetTextColor(textColor) - f.dialogue.q:SizeToContents() - f.dialogue.q.w, f.dialogue.q.h = f.dialogue.q:GetSize() - f.dialogue.q:SetPos(padding*2, sh - borderHeight/2 - f.dialogue.q.h) + f.dialogue.q = log.createDialogueBox( dialogue, f ) return f end