h_button.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* This file was generated by Maki Compiler, do not edit manually */
  2. #include <precomp.h>
  3. #include <api/script/objcontroller.h>
  4. #include "h_button.h"
  5. H_Button::H_Button(ScriptObject *o) : H_GuiObject(o) {
  6. inited = 0;
  7. obj = NULL;
  8. H_hook(o);
  9. }
  10. H_Button::H_Button() {
  11. inited = 0;
  12. obj = NULL;
  13. }
  14. void H_Button::H_hook(ScriptObject *o) {
  15. ASSERT(!inited);
  16. ScriptObjectController *controller = o->vcpu_getController();
  17. obj = controller->cast(o, buttonGuid);
  18. if (obj != o && obj != NULL)
  19. o = obj;
  20. else
  21. obj = NULL;
  22. addMonitorObject(o, &buttonGuid);
  23. int iter = WASABI_API_APP->app_getInitCount();
  24. if (!loaded || loaded != iter) {
  25. onactivate_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onActivate", this);
  26. onleftclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onLeftClick", this);
  27. onrightclick_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onRightClick", this);
  28. loaded = 1;
  29. }
  30. inited=1;
  31. }
  32. H_Button::~H_Button() {
  33. if (!inited) return;
  34. WASABI_API_MAKI->maki_remDlfRef(this);
  35. }
  36. ScriptObject *H_Button::getHookedObject() {
  37. if (obj != NULL) return obj;
  38. return H_BUTTON_PARENT::getHookedObject();
  39. }
  40. int H_Button::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  41. if (object != getHookedObject()) return 0;
  42. if (H_BUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  43. if (dlfid == onactivate_id) { hook_onActivate(GET_SCRIPT_INT(*params[0])); return 1; }
  44. if (dlfid == onleftclick_id) { hook_onLeftClick(); return 1; }
  45. if (dlfid == onrightclick_id) { hook_onRightClick(); return 1; }
  46. return 0;
  47. }
  48. int H_Button::onactivate_id=0;
  49. int H_Button::onleftclick_id=0;
  50. int H_Button::onrightclick_id=0;
  51. int H_Button::loaded=0;