/* * Author: Needles * https://steamcommunity.com/profiles/76561198026257137/ */ ::Debug.Print("*** GUI"); ::Gui <- {}; ::Gui.GuiSprite <- class { isHidden = null; self = null; constructor(_self) { isHidden = false; self = _self; self.ValidateScriptScope(); self.GetScriptScope().guiSprite <- this; } function Show() { if (isHidden == false) return; self.EnableDraw(); isHidden = false; } function Hide() { if (isHidden == true) return; self.DisableDraw(); isHidden = true; } function SetSprite(path) { self.SetModel(path); } function SetColor(color) { EntFireByHandle(self, "ColorRedValue", color.r.tostring(), 0.0, null, null); EntFireByHandle(self, "ColorGreenValue", color.g.tostring(), 0.0, null, null); EntFireByHandle(self, "ColorBlueValue", color.b.tostring(), 0.0, null, null); } function SetScale(scale) { NetProps.SetPropFloat(self, "m_flSpriteScale", scale); } function SetFrameIndex(frame) { NetProps.SetPropFloat(self, "m_flFrame", frame); } function GetFrameIndex() { return NetProps.GetPropFloat(self, "m_flFrame").tointeger(); } } /* * Requires that the target entity has a gui sprite component in order to function properly */ ::Gui.GuiProgressBar <- class { percentage = null; self = null; animationData = null; constructor(_self, _animationData, _startingPercentage) { self = _self; percentage = _startingPercentage; animationData = _animationData; self.ValidateScriptScope(); self.GetScriptScope().guiProgressBar <- this; } function SetPercentage(newPercentage) { percentage = ::MathN.Clamp(newPercentage, 0.0, 1.0); //self.GetScriptScope().guiSprite.SetFrameIndex(animationData.GetFrameIndex(ceil(percentage * (animationData.GetLength()-1)))); self.GetScriptScope().guiSprite.SetFrameIndex(ceil(percentage * (animationData.GetLength()-1))); } function GetPercentage() { return percentage; } }