Globals.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #define variable
  2. #include <Text.h>
  3. #include "Globals.h"
  4. #include "ServerSelection.h"
  5. #include "AddServerMenu.h"
  6. #include "Game.h"
  7. #include "Load.h"
  8. void initVariables()
  9. {
  10. dlls = new DLLRegister();
  11. menuRegister = new HashMap<Framework::Text, Framework::RCPointer<Menu>>(10, [](Text txt)
  12. {
  13. return txt.hashCode();
  14. });
  15. fontRegister = new HashMap<Framework::Text, Framework::RCPointer<Schrift>>(10, [](Text txt)
  16. {
  17. return txt.hashCode();
  18. });
  19. window = 0;
  20. itemIcons = new RCArray<Bild>();
  21. blockTypes = 0;
  22. blockTypeCount = 0;
  23. itemTypes = 0;
  24. itemTypeCount = 0;
  25. entityTypes = 0;
  26. entityTypeCount = 0;
  27. }
  28. void initMenus()
  29. {
  30. menuRegister->put("load", RCPointer<Menu>::of(new LoadMenu(uiFactory.initParam.bildschirm)));
  31. menuRegister->put("serverSelection", RCPointer<Menu>::of(new ServerSelectionMenu(uiFactory.initParam.bildschirm)));
  32. menuRegister->put("addServer", RCPointer<Menu>::of(new AddServerMenu(uiFactory.initParam.bildschirm)));
  33. menuRegister->put("game", RCPointer<Menu>::of(new Game(uiFactory.initParam.bildschirm)));
  34. menuRegister->get("load")->show();
  35. }
  36. void releaseVariables()
  37. {
  38. if (World::INSTANCE)
  39. World::INSTANCE->release();
  40. menuRegister->release();
  41. fontRegister->release();
  42. dlls->release();
  43. itemIcons->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. }