Globals.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #define variable
  2. #include "Globals.h"
  3. #include <Text.h>
  4. #include "AddServerMenu.h"
  5. #include "Game.h"
  6. #include "Load.h"
  7. #include "ServerSelection.h"
  8. void initVariables()
  9. {
  10. dlls = new DLLRegister();
  11. menuRegister = new HashMap<Framework::Text, Framework::RCPointer<Menu>>(
  12. 10, [](Text txt) { return txt.hashCode(); });
  13. fontRegister = new HashMap<Framework::Text, Framework::RCPointer<Schrift>>(
  14. 10, [](Text txt) { return txt.hashCode(); });
  15. window = 0;
  16. blockTypes = 0;
  17. blockTypeCount = 0;
  18. itemTypes = 0;
  19. itemTypeCount = 0;
  20. entityTypes = 0;
  21. entityTypeCount = 0;
  22. }
  23. void initMenus()
  24. {
  25. LoadMenu *load = new LoadMenu(uiFactory.initParam.bildschirm);
  26. menuRegister->put("load",
  27. RCPointer<Menu>::of(load));
  28. menuRegister->put("serverSelection",
  29. RCPointer<Menu>::of(
  30. new ServerSelectionMenu(uiFactory.initParam.bildschirm)));
  31. menuRegister->put("addServer",
  32. RCPointer<Menu>::of(new AddServerMenu(uiFactory.initParam.bildschirm)));
  33. menuRegister->put(
  34. "game", RCPointer<Menu>::of(new Game(uiFactory.initParam.bildschirm)));
  35. menuRegister->get("load")->show();
  36. load->load();
  37. }
  38. void releaseVariables()
  39. {
  40. if (World::INSTANCE) World::INSTANCE->release();
  41. menuRegister->release();
  42. fontRegister->release();
  43. dlls->release();
  44. for (int i = 0; i < blockTypeCount; i++)
  45. blockTypes[i]->release();
  46. delete[] blockTypes;
  47. for (int i = 0; i < itemTypeCount; i++)
  48. itemTypes[i]->release();
  49. delete[] itemTypes;
  50. for (int i = 0; i < entityTypeCount; i++)
  51. entityTypes[i]->release();
  52. delete[] entityTypes;
  53. blockTypes = 0;
  54. blockTypeCount = 0;
  55. itemTypes = 0;
  56. itemTypeCount = 0;
  57. entityTypes = 0;
  58. entityTypeCount = 0;
  59. }
  60. const ItemType* zItemType(int id)
  61. {
  62. for (int i = 0; i < itemTypeCount; i++)
  63. if (itemTypes[i]->getId() == id) return itemTypes[i];
  64. return 0;
  65. }