diff --git a/TR5Main/Scripting/GameScriptColor.cpp b/TR5Main/Scripting/GameScriptColor.cpp index 1eaa9a63a..4cf1be4b1 100644 --- a/TR5Main/Scripting/GameScriptColor.cpp +++ b/TR5Main/Scripting/GameScriptColor.cpp @@ -1,13 +1,60 @@ #include "framework.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("Color", + sol::constructors(), + +/// (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) { SetR(r); SetG(g); 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) { SetR(r); diff --git a/TR5Main/Scripting/GameScriptColor.h b/TR5Main/Scripting/GameScriptColor.h index dd50c541b..830c454e6 100644 --- a/TR5Main/Scripting/GameScriptColor.h +++ b/TR5Main/Scripting/GameScriptColor.h @@ -2,6 +2,11 @@ #include "framework.h" +namespace sol { + class state; + template struct as_table_t; +} + class GameScriptColor { public: byte r; @@ -20,4 +25,6 @@ public: void SetB(byte v); byte GetA(); void SetA(byte v); + + void Register(sol::state* state); }; \ No newline at end of file