h_menubutton.cpp 1.8 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_menubutton.h"
  5. H_MenuButton::H_MenuButton(ScriptObject *o) : H_GuiObject(o) {
  6. inited = 0;
  7. obj = NULL;
  8. H_hook(o);
  9. }
  10. H_MenuButton::H_MenuButton() {
  11. inited = 0;
  12. obj = NULL;
  13. }
  14. void H_MenuButton::H_hook(ScriptObject *o) {
  15. ASSERT(!inited);
  16. ScriptObjectController *controller = o->vcpu_getController();
  17. obj = controller->cast(o, menuButtonGuid);
  18. if (obj != o && obj != NULL)
  19. o = obj;
  20. else
  21. obj = NULL;
  22. addMonitorObject(o, &menuButtonGuid);
  23. int iter = WASABI_API_APP->app_getInitCount();
  24. if (!loaded || loaded != iter) {
  25. onopenmenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onOpenMenu", this);
  26. onclosemenu_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onCloseMenu", this);
  27. onselectitem_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSelectItem", this);
  28. loaded = 1;
  29. }
  30. inited=1;
  31. }
  32. H_MenuButton::~H_MenuButton() {
  33. if (!inited) return;
  34. WASABI_API_MAKI->maki_remDlfRef(this);
  35. }
  36. ScriptObject *H_MenuButton::getHookedObject() {
  37. if (obj != NULL) return obj;
  38. return H_MENUBUTTON_PARENT::getHookedObject();
  39. }
  40. int H_MenuButton::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  41. if (object != getHookedObject()) return 0;
  42. if (H_MENUBUTTON_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  43. if (dlfid == onopenmenu_id) { hook_onOpenMenu(); return 1; }
  44. if (dlfid == onclosemenu_id) { hook_onCloseMenu(); return 1; }
  45. if (dlfid == onselectitem_id) { hook_onSelectItem(GET_SCRIPT_STRING(*params[0])); return 1; }
  46. return 0;
  47. }
  48. int H_MenuButton::onopenmenu_id=0;
  49. int H_MenuButton::onclosemenu_id=0;
  50. int H_MenuButton::onselectitem_id=0;
  51. int H_MenuButton::loaded=0;