main_menu.py 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. # THIS IS A SOURCE CODE FILE FROM I'M NOT EVEN HUMAN THE GAME.
  2. # IT COULD BE USED IN A DIFFERENT PIECE OF SOFTWARE ( LIKE A
  3. # DIFFERENT GAME ), BUT IT WAS ORIGINALLY WRITTEN FOR I'M NOT
  4. # EVEN HUMAN THE GAME.
  5. # THE DEVELOPERS OF THE GAME ARE : (C) J.Y.AMIHUD, AYYZEE AND
  6. # OTHER CONTRIBUTORS. THIS AND OTHER FILES IN THIS GAME,
  7. # UNLESS SPECIFICALLY NOTED, COULD BE USED UNDER THE TERMS OF
  8. # GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER VERSION.
  9. import os
  10. # GTK module ( Graphical interface
  11. import gi
  12. gi.require_version('Gtk', '3.0')
  13. from gi.repository import Gtk
  14. import cairo
  15. from modules import ui
  16. def layer(game):
  17. # Setting up a cairo layer
  18. surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
  19. game.current['w'],
  20. game.current['h'])
  21. layer = cairo.Context(surface)
  22. layer.set_antialias(cairo.ANTIALIAS_NONE)
  23. # Text settings
  24. layer.select_font_face("Monospace",
  25. cairo.FONT_SLANT_NORMAL,
  26. cairo.FONT_WEIGHT_NORMAL)
  27. current_fontoption = layer.get_font_options()
  28. current_fontoption.set_antialias(cairo.ANTIALIAS_NONE)
  29. layer.set_font_options(current_fontoption)
  30. # Background Image
  31. ui.image(game, layer,
  32. game.current["w"]-200,
  33. int(game.current["h"]/2)-75,
  34. "assets/menu-bg.png")
  35. # Title of the game
  36. # Graphical game title
  37. ui.image(game, layer, 10, 15, "assets/game-title.png")
  38. def do():
  39. game.scene = "gameplay"
  40. ui.button(game, layer,
  41. 15, # X
  42. game.current["h"] - 50 , # Y
  43. int(game.current["w"] / 3 ) - 14 , # Width
  44. 13,
  45. icon="dpad",
  46. menu="main",
  47. string="Play",
  48. func=do)
  49. def do():
  50. game.scene = "settings"
  51. ui.button(game, layer,
  52. 15, # X
  53. game.current["h"] - 35 , # Y
  54. int(game.current["w"] / 3 ) - 14 , # Width
  55. 13,
  56. icon="settings",
  57. menu="main",
  58. string="Settings",
  59. func=do)
  60. def do():
  61. game.destroy()
  62. ui.button(game, layer,
  63. 15, # X
  64. game.current["h"] - 20 , # Y
  65. int(game.current["w"] / 3 ) - 14 , # Width
  66. 13,
  67. icon="cross_inverted",
  68. menu="main",
  69. string="Quit",
  70. func=do)
  71. # Navigating the menus
  72. ui.button_navigate(game, "main")
  73. return surface