Added next, prev. model buttons

master
AlmTech 5 years ago
parent 082acef67b
commit 6de5fd861c
  1. 6
      gamemode/engine/core/client/cl_fonts.lua
  2. 64
      gamemode/engine/derma/menus/menu_character.lua

@ -30,6 +30,12 @@ surface.CreateFont( "q_button", {
antialias = true antialias = true
}) })
surface.CreateFont( "q_button_m", {
font = "Arial",
size = 30 * Quantum.Client.ResolutionScale,
antialias = true
})
surface.CreateFont( "q_button2", { surface.CreateFont( "q_button2", {
font = "Arial", font = "Arial",
size = 35 * Quantum.Client.ResolutionScale, size = 35 * Quantum.Client.ResolutionScale,

@ -33,27 +33,18 @@ local function renderSelectedButton( b, sel )
end end
end end
local function renderModelIcons( modelsButtons, parent ) local function getNextIndex( index, isNext, min, max )
local modelCount = 0 if( isNext ) then
for id, model in pairs( getClassModels( inputs.class )[inputs.gender] ) do if( index + 1 > max ) then
modelCount = modelCount + 1 return min -- integer overflow LUL
modelsButtons[modelCount] = vgui.Create( "SpawnIcon", parent ) else
modelsButtons[modelCount].index = modelCount return index + 1
modelsButtons[modelCount]:SetSize( 100 * resScale, 100 * resScale ) end
modelsButtons[modelCount].w, modelsButtons[modelCount].h = modelsButtons[modelCount]:GetSize() else
modelsButtons[modelCount]:SetPos( 0, modelsButtons[modelCount].h * (modelCount-1) ) if( index - 1 < min ) then -- integer underflow
modelsButtons[modelCount]:SetModel( model ) return max
modelsButtons[modelCount].model = model else
-- modelsButtons[modelCount].Paint = function( self ) return index - 1
-- theme.sharpbutton( self, Color( 0, 0, 0, 0 ) )
-- end
modelsButtons[modelCount].Think = function( self ) -- a bit inefficient but it works
print( getClassModels( inputs.class )[inputs.gender][self.index], self.model )
-- set the new models
if( getClassModels( inputs.class )[inputs.gender][self.index] ~= self.model ) then
print( "###:" ,getClassModels( inputs.class )[inputs.gender][modelCount] )
self:SetModel( getClassModels( inputs.class )[inputs.gender][modelCount] || errorMdl )
end
end end
end end
end end
@ -106,6 +97,7 @@ local pages = {
mdl:SetSize( 600 * resScale, 1000 * resScale ) mdl:SetSize( 600 * resScale, 1000 * resScale )
mdl.w, mdl.h = mdl:GetSize() mdl.w, mdl.h = mdl:GetSize()
mdl:SetPos( p.w/2 - mdl.w/2, p.h/2 - mdl.h/2 ) mdl:SetPos( p.w/2 - mdl.w/2, p.h/2 - mdl.h/2 )
mdl.x, mdl.y = mdl:GetPos()
mdl:SetFOV( 55 ) mdl:SetFOV( 55 )
function mdl:LayoutEntity( ent ) return end function mdl:LayoutEntity( ent ) return end
@ -117,7 +109,8 @@ local pages = {
} }
local name = vgui.Create( "DTextEntry", p ) local name = vgui.Create( "DTextEntry", p )
name:SetText( "" ) name:SetPlaceholderText( "Character Name" )
name:SetPlaceholderColor( Color( 100, 100, 100, 100 ) )
name:SetFont( "q_button2" ) name:SetFont( "q_button2" )
name:SetTextColor( Color( 255, 255, 255, 255 ) ) name:SetTextColor( Color( 255, 255, 255, 255 ) )
name:SetSize( 300 * resScale, 40 * resScale ) name:SetSize( 300 * resScale, 40 * resScale )
@ -218,6 +211,33 @@ local pages = {
end end
--- Model selector --- --- Model selector ---
local pmodel = vgui.Create( "DButton", p ) -- previous model
pmodel:SetText( "< Prev. Model" )
pmodel:SetFont( "q_button_m" )
pmodel:SetTextColor( Color( 255, 255, 255, 255 ) )
pmodel:SizeToContents()
pmodel.w, pmodel.h = pmodel:GetSize()
pmodel:SetPos( (mdl.x - pmodel.w) + padding*10, (mdl.y + mdl.h/2) - pmodel.h/2 )
pmodel.Paint = function( self ) theme.sharpbutton( self, Color( 0, 0, 0, 100 ) ) end
pmodel.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" )
inputs.modelIndex = getNextIndex( inputs.modelIndex, false, 1, #getClassModels( inputs.class )[inputs.gender] )
end
local nmodel = vgui.Create( "DButton", p ) -- next model
nmodel:SetText( "Next Model >" )
nmodel:SetFont( "q_button_m" )
nmodel:SetTextColor( Color( 255, 255, 255, 255 ) )
nmodel:SetSize( pmodel.w, pmodel.h )
nmodel.w, nmodel.h = nmodel:GetSize()
nmodel:SetPos( (mdl.x + mdl.w) - padding*10, (mdl.y + mdl.h/2) - nmodel.h/2 )
nmodel.Paint = function( self ) theme.sharpbutton( self, Color( 0, 0, 0, 100 ) ) end
nmodel.DoClick = function( self )
surface.PlaySound( "UI/buttonclick.wav" )
inputs.modelIndex = getNextIndex( inputs.modelIndex, true, 1, #getClassModels( inputs.class )[inputs.gender] )
end
-- Class info --
local mscroll = vgui.Create( "DScrollPanel", ip ) local mscroll = vgui.Create( "DScrollPanel", ip )
mscroll:SetSize( ip.w, ip.h/1.6 ) mscroll:SetSize( ip.w, ip.h/1.6 )
mscroll.w, mscroll.h = mscroll:GetSize() mscroll.w, mscroll.h = mscroll:GetSize()

Loading…
Cancel
Save