Added name auto-formatting algorithm

master
AlmTech 5 years ago
parent 6de5fd861c
commit 1b3f84d534
  1. 17
      gamemode/engine/derma/menus/menu_character.lua

@ -49,6 +49,20 @@ local function getNextIndex( index, isNext, min, max )
end end
end end
local function checkNameString( name )
local strTbl = string.Explode( "", name )
for i, char in pairs( strTbl ) do
if( i == 1 || strTbl[ math.Clamp( i-1, 1, #strTbl ) ] == " " ) then -- if it is the first letter then make it a capital one
strTbl[i] = string.upper( char ) -- or if it is a space inbetween make it a capital one aswell
end
for n, char_ in pairs( strTbl ) do
if( n >= #strTbl && char == " " && strTbl[n-1] ~= " " ) then strTbl[i] = nil end -- remove the spaces at the end
end
end
PrintTable( strTbl )
print( #strTbl >= 3 )
end
local pages = { local pages = {
charCreate = function( parent ) charCreate = function( parent )
local pW, pH = parent:GetSize() local pW, pH = parent:GetSize()
@ -120,6 +134,9 @@ local pages = {
theme.blurpanel( self ) theme.blurpanel( self )
self:DrawTextEntryText( Color( 255, 255, 255, 255 ), Color( 150, 150, 150, 255 ), Color( 100, 100, 100, 255 ) ) self:DrawTextEntryText( Color( 255, 255, 255, 255 ), Color( 150, 150, 150, 255 ), Color( 100, 100, 100, 255 ) )
end end
name.OnEnter = function()
checkNameString( name:GetText() )
end
-- input panel contens -- -- input panel contens --

Loading…
Cancel
Save