Panel/ResetAllFades

From Garry's Mod
Jump to: navigation, search
 Panel:ResetAllFades( )

Contents

Description

Resets all text fades in a RichText element made with Panel:InsertFade.

Arguments

boolean hold

True to reset fades, false otherwise.

Arguments

boolean expiredOnly

Any value equating to true will reset fades only on text segments that are completely faded out.

Arguments

number newSustain

The new sustain value of each faded text segment. Set to -1 to keep the old sustain value.

Examples

Example

Creates a RichText panel where two text segments slowly fade out and get reset to full alpha 5 seconds after being created.

-- Window frame
TextFrame = vgui.Create("DFrame")
TextFrame:SetSize(200, 100)
TextFrame:Center()
TextFrame:SetTitle("ResetAllFades")
TextFrame:MakePopup()

-- Rich Text panel
local richtext = vgui.Create("RichText", TextFrame)
richtext:Dock(FILL)

-- Append text and start fading a few frames after creation (won't work otherwise)
timer.Simple(0.05, function()

	richtext:SetBGColor(Color(32, 32, 32))
	richtext:SetFontInternal("GModNotify")

	richtext:AppendText("This is ")
	richtext:InsertFade(5, 2)
	
	richtext:AppendText("a test...")
	richtext:InsertFade(5, 1)
	
end)

-- 5 seconds after creation, reset all the fades
timer.Simple(5, function()

	richtext:ResetAllFades(true, false, -1)

end)

Output:



RichText ResetAllFades example1.gif
Personal tools
Navigation