main_menu.py 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. ui.color(game, layer, "orange")
  37. ui.text(game, layer, "I'm Not Even Human", 10, 15 )
  38. ui.color(game, layer, "yellow")
  39. ui.text(game, layer, " T h e G a m e", 10, 30 )
  40. ui.button(game, layer,
  41. 15, # X
  42. game.current["h"] - 50 , # Y
  43. int(game.current["w"] / 3 ) - 30 , # Width
  44. 13,
  45. menu="main",
  46. string="Play")
  47. def do():
  48. game.scene = "settings"
  49. ui.button(game, layer,
  50. 15, # X
  51. game.current["h"] - 35 , # Y
  52. int(game.current["w"] / 3 ) - 30 , # Width
  53. 13,
  54. menu="main",
  55. string="Settings",
  56. func=do)
  57. def do():
  58. game.destroy()
  59. ui.button(game, layer,
  60. 15, # X
  61. game.current["h"] - 20 , # Y
  62. int(game.current["w"] / 3 ) - 30 , # Width
  63. 13,
  64. menu="main",
  65. string="Quit",
  66. func=do)
  67. # Navigating the menus
  68. ui.button_navigate(game, "main")
  69. return surface