Globals.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #define variable
  2. #include <Text.h>
  3. #include "Globals.h"
  4. #include "Login.h"
  5. #include "DirectConnect.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. network = new NetworkHandler();
  20. currentGame = 0;
  21. window = 0;
  22. itemIcons = new RCArray<Bild>();
  23. blockTypes = 0;
  24. blockTypeCount = 0;
  25. itemTypes = 0;
  26. itemTypeCount = 0;
  27. entityTypes = 0;
  28. entityTypeCount = 0;
  29. }
  30. void initMenus()
  31. {
  32. menuRegister->put("load", RCPointer<Menu>::of(new LoadMenu(uiFactory.initParam.bildschirm)));
  33. menuRegister->put("login", RCPointer<Menu>::of(new LoginMenu(uiFactory.initParam.bildschirm)));
  34. menuRegister->put("directConnect", RCPointer<Menu>::of(new DirectConnect(uiFactory.initParam.bildschirm)));
  35. menuRegister->put("game", RCPointer<Menu>::of(new Game(uiFactory.initParam.bildschirm)));
  36. menuRegister->get("load")->show();
  37. }
  38. void releaseVariables()
  39. {
  40. if (currentGame)
  41. currentGame->release();
  42. menuRegister->release();
  43. fontRegister->release();
  44. network->release();
  45. dlls->release();
  46. itemIcons->release();
  47. for (int i = 0; i < blockTypeCount; i++)
  48. blockTypes[i]->release();
  49. delete[] blockTypes;
  50. for (int i = 0; i < itemTypeCount; i++)
  51. itemTypes[i]->release();
  52. delete[] itemTypes;
  53. for (int i = 0; i < entityTypeCount; i++)
  54. entityTypes[i]->release();
  55. delete[] entityTypes;
  56. blockTypes = 0;
  57. blockTypeCount = 0;
  58. itemTypes = 0;
  59. itemTypeCount = 0;
  60. entityTypes = 0;
  61. entityTypeCount = 0;
  62. }