1
0

sgammaset.cpp 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. #include <precomp.h>
  2. #include "SGammaset.h"
  3. #include <api.h>
  4. #include <api/script/script.h>
  5. #include <api/script/scriptmgr.h>
  6. #include <api/script/objecttable.h>
  7. // {0D024DB9-9574-42d0-B8C7-26B553F1F987}
  8. static const GUID gammasetSoGuid =
  9. { 0xd024db9, 0x9574, 0x42d0, { 0xb8, 0xc7, 0x26, 0xb5, 0x53, 0xf1, 0xf9, 0x87 } };
  10. GammasetScriptController _gammasetController;
  11. GammasetScriptController *gammasetController=&_gammasetController;
  12. // -- Functions table -------------------------------------
  13. function_descriptor_struct GammasetScriptController::exportedFunction[] = {
  14. {L"apply", 0, (void*)SGammaset::script_vcpu_apply },
  15. {L"getID", 0, (void*)SGammaset::script_vcpu_getID },
  16. {L"rename", 1, (void*)SGammaset::script_vcpu_rename },
  17. {L"remove", 0, (void*)SGammaset::script_vcpu_update },
  18. {L"delete", 0, (void*)SGammaset::script_vcpu_delete },
  19. {L"getGeneralGroup", 0, (void*)SGammaset::script_vcpu_getDefaultGammaGroup },
  20. {L"getGammaGroup", 1, (void*)SGammaset::script_vcpu_getGammaGroup },
  21. {L"getNumGammaGroups", 0, (void*)SGammaset::script_vcpu_getNumGammaGroups },
  22. {L"enumGammaGroup", 0, (void*)SGammaset::script_vcpu_enumGammaGroup },
  23. };
  24. // --------------------------------------------------------
  25. const wchar_t *GammasetScriptController::getClassName() {
  26. return L"Gammaset";
  27. }
  28. const wchar_t *GammasetScriptController::getAncestorClassName() {
  29. return L"Object";
  30. }
  31. ScriptObjectController *GammasetScriptController::getAncestorController() { return rootScriptObjectController; }
  32. ScriptObject *GammasetScriptController::instantiate() {
  33. SGammaset *xd = new SGammaset;
  34. ASSERT(xd != NULL);
  35. return xd->getScriptObject();
  36. }
  37. void GammasetScriptController::destroy(ScriptObject *o) {
  38. SGammaset *xd = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  39. ASSERT(xd != NULL);
  40. delete xd;
  41. }
  42. void *GammasetScriptController::encapsulate(ScriptObject *o) {
  43. return NULL; // no encapsulation for now
  44. }
  45. void GammasetScriptController::deencapsulate(void *o) {
  46. }
  47. int GammasetScriptController::getNumFunctions() {
  48. return sizeof(exportedFunction) / sizeof(function_descriptor_struct);
  49. }
  50. const function_descriptor_struct *GammasetScriptController::getExportedFunctions() {
  51. return exportedFunction;
  52. }
  53. GUID GammasetScriptController::getClassGuid() {
  54. return gammasetSoGuid;
  55. }
  56. void SGammaset::__construct()
  57. {
  58. getScriptObject()->vcpu_setInterface(gammasetSoGuid, (void *)static_cast<SGammaset *>(this));
  59. getScriptObject()->vcpu_setClassName(L"Gammaset");
  60. getScriptObject()->vcpu_setController(gammasetController);
  61. this->gammasetID = NULL;
  62. }
  63. SGammaset::SGammaset()
  64. {
  65. this->__construct();
  66. }
  67. SGammaset::SGammaset(const wchar_t * gammaSetID)
  68. {
  69. this->__construct();
  70. this->gammasetID = gammaSetID;
  71. }
  72. SGammaset::SGammaset(int n)
  73. {
  74. this->__construct();
  75. this->gammasetID = WASABI_API_COLORTHEMES->enumGammaSet(n);
  76. }
  77. SGammaset::~SGammaset()
  78. {
  79. }
  80. // VCPU
  81. scriptVar SGammaset::script_vcpu_apply(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  82. SCRIPT_FUNCTION_INIT;
  83. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  84. if (m)
  85. {
  86. WASABI_API_SKIN->colortheme_setColorSet(m->gammasetID);
  87. //WASABI_API_COLORTHEMES->setGammaSet(m->gammasetID);
  88. }
  89. RETURN_SCRIPT_VOID;
  90. }
  91. scriptVar SGammaset::script_vcpu_update(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  92. SCRIPT_FUNCTION_INIT;
  93. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  94. if (m)
  95. {
  96. WASABI_API_COLORTHEMES->updateGammaSet(m->gammasetID);
  97. }
  98. RETURN_SCRIPT_VOID;
  99. }
  100. scriptVar SGammaset::script_vcpu_delete(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  101. SCRIPT_FUNCTION_INIT;
  102. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  103. if (m)
  104. {
  105. WASABI_API_COLORTHEMES->deleteGammaSet(m->gammasetID);
  106. }
  107. RETURN_SCRIPT_VOID;
  108. }
  109. scriptVar SGammaset::script_vcpu_rename(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) {
  110. SCRIPT_FUNCTION_INIT;
  111. ASSERT(name.type == SCRIPT_STRING);
  112. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  113. if (m)
  114. {
  115. WASABI_API_COLORTHEMES->renameGammaSet(m->gammasetID, name.data.sdata);
  116. }
  117. RETURN_SCRIPT_VOID;
  118. }
  119. scriptVar SGammaset::script_vcpu_getID(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  120. SCRIPT_FUNCTION_INIT;
  121. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  122. if (m)
  123. {
  124. return MAKE_SCRIPT_STRING(m->gammasetID);
  125. }
  126. return MAKE_SCRIPT_STRING(L"");
  127. }
  128. scriptVar SGammaset::script_vcpu_getDefaultGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  129. SCRIPT_FUNCTION_INIT;
  130. ScriptObject *s = NULL;
  131. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  132. if (m)
  133. {
  134. SGammagroup *gg = new SGammagroup(m->gammasetID, -1);
  135. if (gg != NULL && gg->grp != NULL) s = gg->getScriptObject();
  136. }
  137. return MAKE_SCRIPT_OBJECT(s);
  138. }
  139. scriptVar SGammaset::script_vcpu_getGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar name) {
  140. SCRIPT_FUNCTION_INIT;
  141. ASSERT(name.type == SCRIPT_STRING);
  142. ScriptObject *s = NULL;
  143. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  144. if (m)
  145. {
  146. SGammagroup *gg = new SGammagroup(m->gammasetID, GET_SCRIPT_STRING(name));
  147. if (gg != NULL) s = gg->getScriptObject();
  148. }
  149. return MAKE_SCRIPT_OBJECT(s);
  150. }
  151. scriptVar SGammaset::script_vcpu_enumGammaGroup(SCRIPT_FUNCTION_PARAMS, ScriptObject *o, scriptVar n) {
  152. SCRIPT_FUNCTION_INIT;
  153. ASSERT(n.type == SCRIPT_INT);
  154. ScriptObject *s = NULL;
  155. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  156. if (m)
  157. {
  158. SGammagroup *gg = new SGammagroup(m->gammasetID, GET_SCRIPT_INT(n));
  159. if (gg != NULL) s = gg->getScriptObject();
  160. }
  161. return MAKE_SCRIPT_OBJECT(s);
  162. }
  163. scriptVar SGammaset::script_vcpu_getNumGammaGroups(SCRIPT_FUNCTION_PARAMS, ScriptObject *o) {
  164. SCRIPT_FUNCTION_INIT;
  165. int n = 0;
  166. SGammaset *m = static_cast<SGammaset *>(o->vcpu_getInterface(gammasetSoGuid));
  167. if (m)
  168. {
  169. n = WASABI_API_COLORTHEMES->getNumGammaGroups(m->gammasetID);
  170. }
  171. return MAKE_SCRIPT_INT(n);
  172. }