manager.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ########################################################################
  2. # Hello Worlds - Libre 3D RPG game.
  3. # Copyright (C) 2020 CYBERDEViL
  4. #
  5. # This file is part of Hello Worlds.
  6. #
  7. # Hello Worlds is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # Hello Worlds is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. #
  20. ########################################################################
  21. from ui.startMenu import UI_StartMenu
  22. from ui.game import UI_CreatureInfoBox, UI_SpellBar, UI_PlayerInfoBox, UI_ItemInfo
  23. class UI_Manager:
  24. def __init__(self):
  25. self._startMenu = UI_StartMenu(base.luiRegion.root)
  26. self._npcInfoBox = None
  27. self._spellBar = None
  28. self._playerInfoBox = None
  29. self._spellInfoFrame = None
  30. @property
  31. def npcInfoBox(self): return self._npcInfoBox
  32. @property
  33. def spellInfoFrame(self): return self._spellInfoFrame
  34. @property
  35. def startMenu(self): return self._startMenu
  36. def destroyGameUI(self):
  37. self._npcInfoBox.close()
  38. self._spellBar.close()
  39. self._playerInfoBox.close()
  40. self._spellInfoFrame.close()
  41. self._npcInfoBox = None
  42. self._spellBar = None
  43. self._playerInfoBox = None
  44. self._spellInfoFrame = None
  45. def loadGameUI(self):
  46. self._npcInfoBox = UI_CreatureInfoBox()
  47. self._spellBar = UI_SpellBar(parent=base.luiRegion.root)
  48. self._playerInfoBox = UI_PlayerInfoBox(parent=base.luiRegion.root)
  49. self._spellInfoFrame = UI_ItemInfo(parent=base.luiRegion.root)
  50. def hasMouse(self):
  51. if (self._startMenu.hasMouse()
  52. or self._npcInfoBox.hasMouse()
  53. or self._spellBar.hasMouse()
  54. or self._playerInfoBox.hasMouse()):
  55. return True
  56. return False
  57. def close(self):
  58. self._startMenu.close()
  59. self._startMenu = None