# THIS IS A SOURCE CODE FILE FROM I'M NOT EVEN HUMAN THE GAME.
# IT COULD BE USED IN A DIFFERENT PIECE OF SOFTWARE ( LIKE A
# DIFFERENT GAME ), BUT IT WAS ORIGINALLY WRITTEN FOR I'M NOT
# EVEN HUMAN THE GAME.

# THE DEVELOPERS OF THE GAME ARE : (C) J.Y.AMIHUD, AYYZEE AND 
# OTHER CONTRIBUTORS. THIS AND OTHER FILES IN THIS GAME,
# UNLESS SPECIFICALLY NOTED, COULD BE USED UNDER THE TERMS OF
# GNU GENERAL PUBLIC LICENSE VERSION 3 OR ANY LATER VERSION.

import os

# GTK module ( Graphical interface
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import cairo

from modules import ui

def layer(game):

    # Setting up a cairo layer
    surface = cairo.ImageSurface(cairo.FORMAT_ARGB32,
                                 game.current['w'],
                                 game.current['h'])
    layer = cairo.Context(surface)
    layer.set_antialias(cairo.ANTIALIAS_NONE)
    
    
    # Text settings
    layer.select_font_face("Monospace",
                           cairo.FONT_SLANT_NORMAL,
                           cairo.FONT_WEIGHT_NORMAL)
    current_fontoption = layer.get_font_options()
    current_fontoption.set_antialias(cairo.ANTIALIAS_NONE)
    layer.set_font_options(current_fontoption)

    # Background Image
    ui.image(game, layer,
             game.current["w"]-200,
             int(game.current["h"]/2)-75,
             "assets/menu-bg.png")
    
    # Title of the game
    ui.color(game, layer, "orange")
    ui.text(game, layer, "I'm Not Even Human", 10, 15 )
    ui.color(game, layer, "yellow")
    ui.text(game, layer, " T h e    G a m e", 10, 30 )

    ui.button(game, layer,
              15,                       # X
              game.current["h"] - 50 ,  # Y
              int(game.current["w"] / 3 ) - 30 ,  # Width
              13,
              menu="main",
              string="Play")

    def do():
        game.scene = "settings"
    
    ui.button(game, layer,
              15,                       # X
              game.current["h"] - 35 ,  # Y
              int(game.current["w"] / 3 ) - 30 ,  # Width
              13,
              menu="main",
              string="Settings",
              func=do)

    def do():
        game.destroy()
        
    ui.button(game, layer,
              15,                       # X
              game.current["h"] - 20 ,  # Y
              int(game.current["w"] / 3 ) - 30 ,  # Width
              13,
              menu="main",
              string="Quit",
              func=do)

    # Navigating the menus
    ui.button_navigate(game, "main")
    
    return surface
