c_button.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* This file was generated by Maki Compiler, do not edit manually */
  2. #include <precomp.h>
  3. #include "c_button.h"
  4. #include <api/script/objcontroller.h>
  5. C_Button::C_Button(ScriptObject *object) : C_GuiObject(object) {
  6. inited = 0;
  7. C_hook(object);
  8. }
  9. C_Button::C_Button() {
  10. inited = 0;
  11. obj = NULL;
  12. }
  13. void C_Button::C_hook(ScriptObject *object) {
  14. ASSERT(!inited);
  15. ScriptObjectController *controller = object->vcpu_getController();
  16. obj = controller->cast(object, buttonGuid);
  17. if (obj != object && obj != NULL)
  18. controller = obj->vcpu_getController();
  19. else
  20. obj = NULL;
  21. int iter = WASABI_API_APP->app_getInitCount();
  22. if (!loaded || loaded != iter) {
  23. loaded = iter;
  24. onactivate_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onActivate", this);
  25. onleftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onLeftClick", this);
  26. onrightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"onRightClick", this);
  27. setactivated_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setActivated", this);
  28. setactivatednocallback_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"setActivatedNoCallback", this);
  29. getactivated_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"getActivated", this);
  30. leftclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"leftClick", this);
  31. rightclick_id = WASABI_API_MAKI->maki_addDlfRef(controller, L"rightClick", this);
  32. }
  33. inited = 1;
  34. }
  35. C_Button::~C_Button() {
  36. }
  37. ScriptObject *C_Button::getScriptObject() {
  38. if (obj != NULL) return obj;
  39. return C_BUTTON_PARENT::getScriptObject();
  40. }
  41. void C_Button::onActivate(int activated) {
  42. ASSERT(inited);
  43. scriptVar a = MAKE_SCRIPT_INT(activated);
  44. scriptVar *params[1] = {&a};
  45. WASABI_API_MAKI->maki_callFunction(getScriptObject(), onactivate_id, params);
  46. }
  47. void C_Button::onLeftClick() {
  48. ASSERT(inited);
  49. WASABI_API_MAKI->maki_callFunction(getScriptObject(), onleftclick_id, NULL);
  50. }
  51. void C_Button::onRightClick() {
  52. ASSERT(inited);
  53. WASABI_API_MAKI->maki_callFunction(getScriptObject(), onrightclick_id, NULL);
  54. }
  55. void C_Button::setActivated(int onoff) {
  56. ASSERT(inited);
  57. scriptVar a = MAKE_SCRIPT_INT(onoff);
  58. scriptVar *params[1] = {&a};
  59. WASABI_API_MAKI->maki_callFunction(getScriptObject(), setactivated_id, params);
  60. }
  61. void C_Button::setActivatedNoCallback(int onoff) {
  62. ASSERT(inited);
  63. scriptVar a = MAKE_SCRIPT_INT(onoff);
  64. scriptVar *params[1] = {&a};
  65. WASABI_API_MAKI->maki_callFunction(getScriptObject(), setactivatednocallback_id, params);
  66. }
  67. int C_Button::getActivated() {
  68. ASSERT(inited);
  69. return GET_SCRIPT_INT(WASABI_API_MAKI->maki_callFunction(getScriptObject(), getactivated_id, NULL));
  70. }
  71. void C_Button::leftClick() {
  72. ASSERT(inited);
  73. WASABI_API_MAKI->maki_callFunction(getScriptObject(), leftclick_id, NULL);
  74. }
  75. void C_Button::rightClick() {
  76. ASSERT(inited);
  77. WASABI_API_MAKI->maki_callFunction(getScriptObject(), rightclick_id, NULL);
  78. }
  79. int C_Button::loaded=0;
  80. int C_Button::onactivate_id=0;
  81. int C_Button::onleftclick_id=0;
  82. int C_Button::onrightclick_id=0;
  83. int C_Button::setactivated_id=0;
  84. int C_Button::setactivatednocallback_id=0;
  85. int C_Button::getactivated_id=0;
  86. int C_Button::leftclick_id=0;
  87. int C_Button::rightclick_id=0;