h_container.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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_container.h"
  5. H_Container::H_Container(ScriptObject *o) : H_RootObject(o) {
  6. inited = 0;
  7. obj = NULL;
  8. H_hook(o);
  9. }
  10. H_Container::H_Container() {
  11. inited = 0;
  12. obj = NULL;
  13. }
  14. void H_Container::H_hook(ScriptObject *o) {
  15. ASSERT(!inited);
  16. ScriptObjectController *controller = o->vcpu_getController();
  17. obj = controller->cast(o, containerGuid);
  18. if (obj != o && obj != NULL)
  19. o = obj;
  20. else
  21. obj = NULL;
  22. addMonitorObject(o, &containerGuid);
  23. int iter = WASABI_API_APP->app_getInitCount();
  24. if (!loaded || loaded != iter) {
  25. onswitchtolayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onSwitchToLayout", this);
  26. onbeforeswitchtolayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onBeforeSwitchToLayout", this);
  27. onhidelayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onHideLayout", this);
  28. onshowlayout_id= WASABI_API_MAKI->maki_addDlfRef(o->vcpu_getController(), L"onShowLayout", this);
  29. loaded = 1;
  30. }
  31. inited=1;
  32. }
  33. H_Container::~H_Container() {
  34. if (!inited) return;
  35. WASABI_API_MAKI->maki_remDlfRef(this);
  36. }
  37. ScriptObject *H_Container::getHookedObject() {
  38. if (obj != NULL) return obj;
  39. return H_CONTAINER_PARENT::getHookedObject();
  40. }
  41. int H_Container::eventCallback(ScriptObject *object, int dlfid, scriptVar **params, int nparams) {
  42. if (object != getHookedObject()) return 0;
  43. if (H_CONTAINER_PARENT::eventCallback(object, dlfid, params, nparams)) return 1;
  44. if (dlfid == onswitchtolayout_id) { hook_onSwitchToLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  45. if (dlfid == onbeforeswitchtolayout_id) { hook_onBeforeSwitchToLayout(GET_SCRIPT_OBJECT(*params[0]), GET_SCRIPT_OBJECT(*params[1])); return 1; }
  46. if (dlfid == onhidelayout_id) { hook_onHideLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  47. if (dlfid == onshowlayout_id) { hook_onShowLayout(GET_SCRIPT_OBJECT(*params[0])); return 1; }
  48. return 0;
  49. }
  50. int H_Container::onswitchtolayout_id=0;
  51. int H_Container::onbeforeswitchtolayout_id=0;
  52. int H_Container::onhidelayout_id=0;
  53. int H_Container::onshowlayout_id=0;
  54. int H_Container::loaded=0;