startMenu.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 LUIFrame import LUIFrame
  22. from LUIButton import LUIButton
  23. class UI_StartMenu:
  24. def __init__(self, parent):
  25. self._container = LUIFrame(parent=parent, width=100, height=180, style=LUIFrame.FS_sunken, margin=30, center_vertical=True, center_horizontal=True)
  26. self.startButton = LUIButton(parent=self._container, text="Start", template="ButtonGreen", top=3, center_horizontal=True)
  27. self.loadButton = LUIButton(parent=self._container, text="Load", template="ButtonGreen", top=40, center_horizontal=True)
  28. self.saveButton = LUIButton(parent=self._container, text="Save", template="ButtonGreen", top=77, center_horizontal=True)
  29. self.exitButton = LUIButton(parent=self._container, text="Exit", template="ButtonGreen", bottom=3, center_horizontal=True)
  30. self.startButton.bind("click", self._startClicked)
  31. self.exitButton.bind("click", self._exitClicked)
  32. def _startClicked(self, event):
  33. messenger.send('UI_STARTMENU_START_PRESSED')
  34. def _exitClicked(self, event):
  35. messenger.send('UI_STARTMENU_EXIT_PRESSED')
  36. def hasMouse(self, args=[]):
  37. return self._container.hasMouse()
  38. def close(self):
  39. self._container.parent = None
  40. self._container = None
  41. def hide(self):
  42. self._container.hide()
  43. def show(self):
  44. self._container.show()
  45. def isVisible(self): return self._container.visible