More good stuff. Captions, debug inv, italics.
This commit is contained in:
parent
e1b2c35fb7
commit
57b50709bb
|
@ -0,0 +1,58 @@
|
||||||
|
|
||||||
|
-- Audio & caption system
|
||||||
|
|
||||||
|
CAPTIONS = {}
|
||||||
|
CAPTIONS["en-us"] = {}
|
||||||
|
|
||||||
|
CAPTIONS["en-us"]["1911.Fire"] = {
|
||||||
|
Name = "Cobra .45",
|
||||||
|
Color = color_white,
|
||||||
|
Text = "[fire]",
|
||||||
|
Bold = false,
|
||||||
|
Italic = true,
|
||||||
|
TypeTime = 0.1,
|
||||||
|
LifeTime = 0.5,
|
||||||
|
}
|
||||||
|
CAPTIONS["en-us"]["1911.Reload"] = {
|
||||||
|
Name = "Cobra .45",
|
||||||
|
Color = color_white,
|
||||||
|
Text = "[reload]",
|
||||||
|
Bold = false,
|
||||||
|
Italic = true,
|
||||||
|
TypeTime = 0.1,
|
||||||
|
LifeTime = 0.5,
|
||||||
|
}
|
||||||
|
|
||||||
|
CAPTIONS = CAPTIONS["en-us"]
|
||||||
|
|
||||||
|
SOUNDS = {}
|
||||||
|
|
||||||
|
function AddSound( name, path, sndlevel, pitch, volume, channel )
|
||||||
|
SOUNDS[name] = {
|
||||||
|
path = path,
|
||||||
|
sndlevel = sndlevel or 70,
|
||||||
|
pitch = pitch or 100,
|
||||||
|
volume = volume or 1,
|
||||||
|
channel = channel or CHAN_STATIC,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
local screwup = SERVER and Color(150, 255, 255) or Color(255, 200, 150)
|
||||||
|
|
||||||
|
function B_Sound( ent, tag )
|
||||||
|
local tagt = SOUNDS[tag]
|
||||||
|
if !tagt then MsgC( screwup, "Invalid sound " .. tag .. "\n" ) return end
|
||||||
|
local path, sndlevel, pitch, volume, channel = tagt.path, tagt.sndlevel, tagt.pitch, tagt.volume, tagt.channel
|
||||||
|
if istable( path ) then
|
||||||
|
path = path[math.Round(util.SharedRandom( "B_Sound", 1, #path ))]
|
||||||
|
end
|
||||||
|
ent:EmitSound( path, sndlevel, pitch, volume, channel )
|
||||||
|
if CLIENT and IsFirstTimePredicted() then
|
||||||
|
if CAPTIONS[tag] then
|
||||||
|
local capt = CAPTIONS[tag]
|
||||||
|
AddCaption( capt.Name, capt.Color, capt.Text, capt.TypeTime, capt.LifeTime )
|
||||||
|
else
|
||||||
|
MsgC( screwup, "No caption defined for " .. tag .. "\n" )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -5,9 +5,6 @@ function UUID_generate()
|
||||||
local str = ""
|
local str = ""
|
||||||
for i=1, 8 do
|
for i=1, 8 do
|
||||||
str = str .. UUID_chars[ math.random( 1, #UUID_chars ) ]
|
str = str .. UUID_chars[ math.random( 1, #UUID_chars ) ]
|
||||||
-- if (i%4==0 and i!=8) then
|
|
||||||
-- str = str .. "-"
|
|
||||||
-- end
|
|
||||||
end
|
end
|
||||||
return str
|
return str
|
||||||
end
|
end
|
|
@ -50,11 +50,15 @@ local function genfonts()
|
||||||
12,
|
12,
|
||||||
}
|
}
|
||||||
for _, size in pairs(sizes) do
|
for _, size in pairs(sizes) do
|
||||||
surface.CreateFont( "Benny_Caption_" .. size, {
|
for i=1, 4 do
|
||||||
font = "Roboto",
|
local add = i==1 and "" or i==2 and "B" or i==3 and "I" or i==4 and "BI"
|
||||||
size = ss(size),
|
local mode = i==1 and "" or i==2 and " Bold" or i==3 and " Italic" or i==4 and " Bold Italic"
|
||||||
weight = 0
|
surface.CreateFont( "Benny_Caption_" .. size .. add, {
|
||||||
} )
|
font = "Roboto" .. mode,
|
||||||
|
size = ss(size),
|
||||||
|
weight = 0,
|
||||||
|
} )
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
genfonts()
|
genfonts()
|
||||||
|
@ -285,8 +289,9 @@ hook.Add( "HUDPaint", "Benny_HUDPaint", function()
|
||||||
surface.SetDrawColor( color_caption )
|
surface.SetDrawColor( color_caption )
|
||||||
surface.DrawRect( (sw/2) - (ss(8)+tw)/2, sh - space - ss(0), ss(8)+tw, ss(22)+ss(8*(#caption.lines-1)) )
|
surface.DrawRect( (sw/2) - (ss(8)+tw)/2, sh - space - ss(0), ss(8)+tw, ss(22)+ss(8*(#caption.lines-1)) )
|
||||||
|
|
||||||
|
-- PROTO: Would be nice to be able to change italics or bold inline.
|
||||||
for i, v in SortedPairsByMemberValue( caption.lines, "starttime" ) do
|
for i, v in SortedPairsByMemberValue( caption.lines, "starttime" ) do
|
||||||
surface.SetFont("Benny_Caption_9")
|
surface.SetFont("Benny_Caption_9I")
|
||||||
surface.SetTextColor( color_white )
|
surface.SetTextColor( color_white )
|
||||||
surface.SetTextPos( (sw/2) - (tw/2), sh - space + ss(10) + (ss(8)*(i-1)) )
|
surface.SetTextPos( (sw/2) - (tw/2), sh - space + ss(10) + (ss(8)*(i-1)) )
|
||||||
local waah = ""
|
local waah = ""
|
||||||
|
|
|
@ -20,6 +20,8 @@ concommand.Add("benny_debug_give", function(ply, cmd, args)
|
||||||
|
|
||||||
local class = WEAPONS[args[3]]
|
local class = WEAPONS[args[3]]
|
||||||
|
|
||||||
|
assert(class, "Invalid Class.")
|
||||||
|
|
||||||
local item = {
|
local item = {
|
||||||
Class = args[3],
|
Class = args[3],
|
||||||
Ammo = class.Ammo,
|
Ammo = class.Ammo,
|
||||||
|
@ -55,54 +57,61 @@ if CLIENT then
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
CAPTIONS = {
|
if CLIENT then
|
||||||
["1911.Fire"] = {
|
local function regen_items( itemlist )
|
||||||
Name = "Cobra .45",
|
local ply = LocalPlayer()
|
||||||
Color = color_white,
|
itemlist:Clear()
|
||||||
Text = "[Cobra .45 fire]",
|
|
||||||
TypeTime = 0.1,
|
|
||||||
LifeTime = 0.5,
|
|
||||||
},
|
|
||||||
["1911.Reload"] = {
|
|
||||||
Name = "Cobra .45",
|
|
||||||
Color = color_white,
|
|
||||||
Text = "[Cobra .45 reload]",
|
|
||||||
TypeTime = 0.1,
|
|
||||||
LifeTime = 0.5,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
-- CAPTIONS["en-us"] = {}
|
for i, v in pairs( ply:INV_Get() ) do
|
||||||
-- CAPTIONS = CAPTIONS["en-us"]
|
local button = vgui.Create( "DButton" )
|
||||||
|
itemlist:AddItem( button )
|
||||||
|
button:SetSize( 1, ss(36) )
|
||||||
|
button:Dock( TOP )
|
||||||
|
button:DockMargin( 0, 0, 0, ss(4) )
|
||||||
|
|
||||||
SOUNDS = {}
|
button.Text_ID = i
|
||||||
|
local Class = WEAPONS[v.Class]
|
||||||
|
button.Text_Name = Class.Name
|
||||||
|
button.Text_Desc = Class.Description
|
||||||
|
|
||||||
function AddSound( name, path, sndlevel, pitch, volume, channel )
|
-- PROTO: This paint function doesn't need to be remade over and over like this.
|
||||||
SOUNDS[name] = {
|
function button:Paint( w, h )
|
||||||
path = path,
|
surface.SetDrawColor( schemes["benny"]["fg"] )
|
||||||
sndlevel = sndlevel or 70,
|
surface.DrawRect( 0, 0, w, h )
|
||||||
pitch = pitch or 100,
|
|
||||||
volume = volume or 1,
|
surface.SetTextColor( schemes["benny"]["bg"] )
|
||||||
channel = channel or CHAN_STATIC,
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
local screwup = SERVER and Color(150, 255, 255) or Color(255, 200, 150)
|
surface.SetFont( "Benny_16" )
|
||||||
|
surface.SetTextPos( ss(4), ss(4) )
|
||||||
|
surface.DrawText( self.Text_Name )
|
||||||
|
|
||||||
function B_Sound( ent, tag )
|
surface.SetFont( "Benny_10" )
|
||||||
local tagt = SOUNDS[tag]
|
surface.SetTextPos( ss(4), ss(4 + 12) )
|
||||||
if !tagt then MsgC( screwup, "Invalid sound " .. tag .. "\n" ) return end
|
surface.DrawText( self.Text_Desc )
|
||||||
local path, sndlevel, pitch, volume, channel = tagt.path, tagt.sndlevel, tagt.pitch, tagt.volume, tagt.channel
|
|
||||||
if istable( path ) then
|
surface.SetFont( "Benny_10" )
|
||||||
path = path[math.Round(util.SharedRandom( "B_Sound", 1, #path ))]
|
surface.SetTextPos( ss(4), ss(4 + 20) )
|
||||||
end
|
surface.DrawText( self.Text_ID )
|
||||||
ent:EmitSound( path, sndlevel, pitch, volume, channel )
|
return true
|
||||||
if CLIENT then
|
end
|
||||||
if CAPTIONS[tag] then
|
|
||||||
local capt = CAPTIONS[tag]
|
|
||||||
AddCaption( capt.Name, capt.Color, capt.Text, capt.TypeTime, capt.LifeTime )
|
|
||||||
else
|
|
||||||
MsgC( screwup, "No caption defined for " .. tag .. "\n" )
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
concommand.Add("benny_debug_inv", function()
|
||||||
|
if IsValid( base ) then base:Remove() end
|
||||||
|
base = vgui.Create("DFrame")
|
||||||
|
base:SetSize( ss(340), ss(240) )
|
||||||
|
base:MakePopup()
|
||||||
|
base:Center()
|
||||||
|
|
||||||
|
function base:Paint( w, h )
|
||||||
|
surface.SetDrawColor( schemes["benny"]["bg"] )
|
||||||
|
surface.DrawRect( 0, 0, w, h )
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
local itemlist = base:Add("DScrollPanel")
|
||||||
|
itemlist:Dock( FILL )
|
||||||
|
|
||||||
|
regen_items( itemlist )
|
||||||
|
end)
|
||||||
end
|
end
|
Loading…
Reference in New Issue