groupmgr.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <precomp.h>
  2. #include <api/skin/groupmgr.h>
  3. #include <api/skin/skinparse.h>
  4. #include <api/skin/guitree.h>
  5. #include <api/config/items/attrint.h>
  6. #include <api/config/items/cfgitem.h>
  7. Group *GroupMgr::instantiate(const wchar_t *groupid, int grouptype, SkinItem *specific_item, int scripts_enabled)
  8. {
  9. InCriticalSection in_cs(&cs_grp);
  10. GuiObject *go = SkinParser::newDynamicGroup(groupid, grouptype, specific_item, 0, scripts_enabled);
  11. Group *g = static_cast<Group *>(go->guiobject_getScriptObject()->vcpu_getInterface(groupGuid));
  12. if (!g) return NULL;
  13. grouplist.addItem(g);
  14. return g;
  15. }
  16. #ifdef WASABI_COMPILE_CONFIG
  17. Group *GroupMgr::instantiate(const wchar_t *groupid, CfgItem *i, const wchar_t *name, int scripts_enabled) {
  18. InCriticalSection in_cs(&cs_grp);
  19. CfgGroup *g = static_cast<CfgGroup *>(instantiate(groupid, GROUP_CFGGROUP, NULL, scripts_enabled));
  20. ASSERTPR(g != NULL, StringPrintf("couldn't load groupid '%S'", groupid));
  21. g->setAttr(i, name);
  22. grouplist.addItem(g);
  23. return g;
  24. }
  25. #endif
  26. int GroupMgr::destroy(Group *group) {
  27. InCriticalSection in_cs(&cs_grp);
  28. if (!grouplist.haveItem(group)) {
  29. DebugStringW(L"you cannot destroy a group that you have not instatiated\n");
  30. return 0;
  31. }
  32. delete group;
  33. grouplist.removeItem(group);
  34. return 1;
  35. }
  36. int GroupMgr::exists(const wchar_t *groupid)
  37. {
  38. SkinItem *si = guiTree->getGroupDef(groupid);
  39. if (si) return 1;
  40. return 0;
  41. }
  42. PtrList<Group> GroupMgr::grouplist;
  43. CriticalSection GroupMgr::cs_grp;