Add Register function and documentation for GameScriptColor, since it will be used in GameScriptMeshInfo.

This commit is contained in:
hispidence 2021-07-20 17:48:39 +01:00
parent ffa8791c03
commit 12b28a38c6
2 changed files with 54 additions and 0 deletions

View file

@ -1,13 +1,60 @@
#include "framework.h" #include "framework.h"
#include "GameScriptColor.h" #include "GameScriptColor.h"
/***
An RGBA or RGB color. Components are set in bytes, with 0 being
the minimum amount of that component, and 255 being the maximum.
@classmod Color
@pragma nostrip
*/
void GameScriptColor::Register(sol::state* state)
{
state->new_usertype<GameScriptColor>("Color",
sol::constructors<GameScriptColor(int, int, int)>(),
/// (int) red component
//@mem R
"R", sol::property(&GameScriptColor::GetR, &GameScriptColor::SetR),
/// (int) green component
//@mem G
"G", sol::property(&GameScriptColor::GetG, &GameScriptColor::SetG),
/// (int) blue component
//@mem B
"B", sol::property(&GameScriptColor::GetB, &GameScriptColor::SetB),
/// (int) alpha component (255 is opaque, 0 is invisible)
//@mem A
"A", sol::property(&GameScriptColor::GetA, &GameScriptColor::SetA)
);
}
/***
@int R red component
@int G green component
@int B blue component
@return A Color object.
@function Color.new
*/
GameScriptColor::GameScriptColor(byte r, byte g, byte b) GameScriptColor::GameScriptColor(byte r, byte g, byte b)
{ {
SetR(r); SetR(r);
SetG(g); SetG(g);
SetB(b); SetB(b);
SetA(255);
} }
/***
@int R red component
@int G green component
@int B blue component
@int A alpha component (255 is opaque, 0 is invisible)
@return A Color object.
@function Color.new
*/
GameScriptColor::GameScriptColor(byte r, byte g, byte b, byte a) GameScriptColor::GameScriptColor(byte r, byte g, byte b, byte a)
{ {
SetR(r); SetR(r);

View file

@ -2,6 +2,11 @@
#include "framework.h" #include "framework.h"
namespace sol {
class state;
template <typename T> struct as_table_t;
}
class GameScriptColor { class GameScriptColor {
public: public:
byte r; byte r;
@ -20,4 +25,6 @@ public:
void SetB(byte v); void SetB(byte v);
byte GetA(); byte GetA();
void SetA(byte v); void SetA(byte v);
void Register(sol::state* state);
}; };