Skip to content

Commit

Permalink
+ SpriteDraw: isFunctional(), toString() methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mtax-Development committed Jul 5, 2021
1 parent edf0ddb commit 49ecc42
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions scripts/SpriteDraw/SpriteDraw.gml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ function SpriteDraw() constructor
}
}

// @returns {bool}
// @description Check if this constructor is functional.
static isFunctional = function()
{
return ((instanceof(sprite) == "Sprite") and (sprite.isFunctional())
and (instanceof(location) == "Vector2") and (location.isFunctional())
and (is_real(frame)) and (instanceof(scale) == "Scale")
and (scale.isFunctional()) and (instanceof(angle) == "Angle")
and (angle.isFunctional()) and (is_real(color)) and (is_real(alpha)));
}

#endregion
#region <Execution>

Expand All @@ -72,6 +83,97 @@ function SpriteDraw() constructor
}

#endregion
#region <Conversion>

// @argument {bool} multiline?
// @argument {bool} full?
// @argument {bool} color_HSV?
// @returns {string}
// @description Create a string representing this constructor.
// Overrides the string() conversion.
// Content will be represented with the properties of this
// constructor.
static toString = function(_multiline, _full, _color_HSV)
{
if (self.isFunctional())
{
var _string = "";
var _mark_separator = ((_multiline) ? "\n" : ", ");

if (_full)
{
var _mark_separator_inline = ", ";

var _string_color;
switch (color)
{
case c_aqua: _string_color = "Aqua"; break;
case c_black: _string_color = "Black"; break;
case c_blue: _string_color = "Blue"; break;
case c_dkgray: _string_color = "Dark Gray"; break;
case c_fuchsia: _string_color = "Fuchsia"; break;
case c_gray: _string_color = "Gray"; break;
case c_green: _string_color = "Green"; break;
case c_lime: _string_color = "Lime"; break;
case c_ltgray: _string_color = "Light Gray"; break;
case c_maroon: _string_color = "Maroon"; break;
case c_navy: _string_color = "Navy"; break;
case c_olive: _string_color = "Olive"; break;
case c_orange: _string_color = "Orange"; break;
case c_purple: _string_color = "Purple"; break;
case c_red: _string_color = "Red"; break;
case c_teal: _string_color = "Teal"; break;
case c_white: _string_color = "White"; break;
case c_yellow: _string_color = "Yellow"; break;
default:
if (_color_HSV)
{
_string_color =
("(" +
"Hue: " + string(color_get_hue(color))
+ _mark_separator_inline +
"Saturation: " + string(color_get_saturation(color))
+ _mark_separator_inline +
"Value: " + string(color_get_value(color)) +
")");
}
else
{
_string_color =
("(" +
"Red: " + string(color_get_red(color))
+ _mark_separator_inline +
"Green: " + string(color_get_green(color))
+ _mark_separator_inline +
"Blue: " + string(color_get_blue(color)) +
")");
}
break;
}

_string = ("Sprite: " + string(sprite) + _mark_separator +
"Location: " + string(location) + _mark_separator +
"Frame: " + string(frame) + _mark_separator +
"Scale: " + string(scale) + _mark_separator +
"Angle: " + string(angle) + _mark_separator +
"Color: " + _string_color + _mark_separator +
"Alpha: " + string(alpha));
}
else
{
_string = ("Sprite: " + string(sprite) + _mark_separator +
"Location: " + string(location));
}

return ((_multiline) ? _string : (instanceof(self) + "(" + _string + ")"));
}
else
{
return (instanceof(self) + "<>");
}
}

#endregion
#endregion
#region [Constructor]

Expand Down

0 comments on commit 49ecc42

Please sign in to comment.