sgammagroup.cpp 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #include <precomp.h>
  2. #include "SGammagroup.h"
  3. #include <api/script/script.h>
  4. #include <api/script/scriptmgr.h>
  5. #include <api/script/objecttable.h>
  6. // {B81F004D-ACBA-453d-A06B-30192A1DA17D}
  7. static const GUID gammagroupSoGuid =
  8. { 0xb81f004d, 0xacba, 0x453d, { 0xa0, 0x6b, 0x30, 0x19, 0x2a, 0x1d, 0xa1, 0x7d } };
  9. GammagroupScriptController _gammagroupController;
  10. GammagroupScriptController *gammagroupController=&_gammagroupController;
  11. // -- Functions table -------------------------------------
  12. function_descriptor_struct GammagroupScriptController::exportedFunction[] = {
  13. {L"getRed", 0, (void*)SGammagroup::script_vcpu_getRed },
  14. {L"getGreen", 0, (void*)SGammagroup::script_vcpu_getGreen },
  15. {L"getBlue", 0, (void*)SGammagroup::script_vcpu_getBlue },
  16. {L"getBoost", 0, (void*)SGammagroup::script_vcpu_getBoost },
  17. {L"getGray", 0, (void*)SGammagroup::script_vcpu_getGray },
  18. {L"setRed", 1, (void*)SGammagroup::script_vcpu_setRed },
  19. {L"setGreen", 1, (void*)SGammagroup::script_vcpu_setGreen },
  20. {L"setBlue", 1, (void*)SGammagroup::script_vcpu_setBlue },
  21. {L"setBoost", 1, (void*)SGammagroup::script_vcpu_setBoost },
  22. {L"setGray", 1, (void*)SGammagroup::script_vcpu_setGray },
  23. {L"getID", 0, (void*)SGammagroup::script_vcpu_getID },
  24. {L"setID", 1, (void*)SGammagroup::script_vcpu_setID },
  25. };
  26. // --------------------------------------------------------
  27. const wchar_t *GammagroupScriptController::getClassName() {
  28. return L"Gammagroup";
  29. }
  30. const wchar_t *GammagroupScriptController::getAncestorClassName() {
  31. return L"Object";
  32. }
  33. ScriptObjectController *GammagroupScriptController::getAncestorController() { return rootScriptObjectController; }
  34. ScriptObject *GammagroupScriptController::instantiate() {
  35. SGammagroup *xd = new SGammagroup;
  36. ASSERT(xd != NULL);
  37. return xd->getScriptObject();
  38. }
  39. void GammagroupScriptController::destroy(ScriptObject *o) {
  40. SGammagroup *xd = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  41. ASSERT(xd != NULL);
  42. delete xd;
  43. }
  44. void *GammagroupScriptController::encapsulate(ScriptObject *o) {
  45. return NULL; // no encapsulation for now
  46. }
  47. void GammagroupScriptController::deencapsulate(void *o) {
  48. }
  49. int GammagroupScriptController::getNumFunctions() {
  50. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  51. }
  52. const function_descriptor_struct *GammagroupScriptController::getExportedFunctions() {
  53. return exportedFunction;
  54. }
  55. GUID GammagroupScriptController::getClassGuid() {
  56. return gammagroupSoGuid;
  57. }
  58. void SGammagroup::__construct()
  59. {
  60. getScriptObject()->vcpu_setInterface(gammagroupSoGuid, (void *)static_cast<SGammagroup *>(this));
  61. getScriptObject()->vcpu_setClassName(L"Gammagroup");
  62. getScriptObject()->vcpu_setController(gammagroupController);
  63. this->grp = NULL;
  64. }
  65. SGammagroup::SGammagroup()
  66. {
  67. this->__construct();
  68. }
  69. SGammagroup::SGammagroup(const wchar_t * parentSet, const wchar_t * grp)
  70. {
  71. this->__construct();
  72. this->parentSet = parentSet;
  73. this->grp = WASABI_API_COLORTHEMES->getColorThemeGroup(parentSet, grp);
  74. }
  75. SGammagroup::SGammagroup(const wchar_t * parentSet, int n)
  76. {
  77. this->__construct();
  78. this->parentSet = parentSet;
  79. for (int i = 0; i < (int)WASABI_API_COLORTHEMES->getNumGammaSets(); i++)
  80. {
  81. if(WCSICMPSAFE(parentSet, WASABI_API_COLORTHEMES->enumGammaSet(i)))
  82. {
  83. continue;
  84. }
  85. this->grp = WASABI_API_COLORTHEMES->enumColorThemeGroup(i, n);
  86. break;
  87. }
  88. }
  89. SGammagroup::~SGammagroup()
  90. {
  91. }
  92. // VCPU
  93. scriptVar SGammagroup::script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  94. SCRIPT_FUNCTION_INIT;
  95. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  96. if (m)
  97. {
  98. return MAKE_SCRIPT_STRING(m->grp->getName());
  99. }
  100. return MAKE_SCRIPT_STRING(L"");
  101. }
  102. scriptVar SGammagroup::script_vcpu_getBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  103. SCRIPT_FUNCTION_INIT;
  104. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  105. if (m)
  106. {
  107. return MAKE_SCRIPT_INT(m->grp->getBlue());
  108. }
  109. RETURN_SCRIPT_ZERO;
  110. }
  111. scriptVar SGammagroup::script_vcpu_getGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  112. SCRIPT_FUNCTION_INIT;
  113. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  114. if (m)
  115. {
  116. return MAKE_SCRIPT_INT(m->grp->getGreen());
  117. }
  118. RETURN_SCRIPT_ZERO;
  119. }
  120. scriptVar SGammagroup::script_vcpu_getRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  121. SCRIPT_FUNCTION_INIT;
  122. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  123. if (m)
  124. {
  125. return MAKE_SCRIPT_INT(m->grp->getRed());
  126. }
  127. RETURN_SCRIPT_ZERO;
  128. }
  129. scriptVar SGammagroup::script_vcpu_getBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  130. SCRIPT_FUNCTION_INIT;
  131. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  132. if (m)
  133. {
  134. return MAKE_SCRIPT_INT(m->grp->getBoost());
  135. }
  136. RETURN_SCRIPT_ZERO;
  137. }
  138. scriptVar SGammagroup::script_vcpu_getGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  139. SCRIPT_FUNCTION_INIT;
  140. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  141. if (m)
  142. {
  143. return MAKE_SCRIPT_INT(m->grp->getGray());
  144. }
  145. RETURN_SCRIPT_ZERO;
  146. }
  147. scriptVar SGammagroup::script_vcpu_setID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) {
  148. SCRIPT_FUNCTION_INIT;
  149. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  150. if (m)
  151. {
  152. (m->grp->setName(color.data.sdata));
  153. }
  154. RETURN_SCRIPT_VOID;
  155. }
  156. scriptVar SGammagroup::script_vcpu_setBlue(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) {
  157. SCRIPT_FUNCTION_INIT;
  158. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  159. if (m)
  160. {
  161. (m->grp->setBlue(color.data.idata));
  162. }
  163. RETURN_SCRIPT_VOID;
  164. }
  165. scriptVar SGammagroup::script_vcpu_setGreen(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) {
  166. SCRIPT_FUNCTION_INIT;
  167. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  168. if (m)
  169. {
  170. (m->grp->setGreen(color.data.idata));
  171. }
  172. RETURN_SCRIPT_VOID;
  173. }
  174. scriptVar SGammagroup::script_vcpu_setRed(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) {
  175. SCRIPT_FUNCTION_INIT;
  176. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  177. if (m)
  178. {
  179. (m->grp->setRed(color.data.idata));
  180. }
  181. RETURN_SCRIPT_VOID;
  182. }
  183. scriptVar SGammagroup::script_vcpu_setBoost(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) {
  184. SCRIPT_FUNCTION_INIT;
  185. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  186. if (m)
  187. {
  188. (m->grp->setBoost(color.data.idata));
  189. }
  190. RETURN_SCRIPT_VOID;
  191. }
  192. scriptVar SGammagroup::script_vcpu_setGray(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar color) {
  193. SCRIPT_FUNCTION_INIT;
  194. SGammagroup *m = static_cast<SGammagroup *>(o->vcpu_getInterface(gammagroupSoGuid));
  195. if (m)
  196. {
  197. (m->grp->setGray(color.data.idata));
  198. }
  199. RETURN_SCRIPT_VOID;
  200. }