"""
pause menu screen
"""


import sys

from OpenGL.GL import *
from OpenGL.GLU import *
import pygame, pygame.image
from pygame.locals import *

import texMgr
import draw_util
import gui_widgets as gw

import fsm_mgr as fsm
import tubeMgr

import levels

import voiceover
import state_key_help

def func_play(level_name):
    fsm.popState()

def func_quit_mission(name):
    fsm.popState()
    fsm.popState()

def func_quit_game(name):
    fsm.popAll()

def func_key_help(name):
    fsm.pushState(state_key_help.StateKeyHelp())
    

bsz=80
bc1=100
bc2=300
bc3=500
bc4=700


br1 = 300

buttons=[gw.Button("button_play",        bc1-bsz, br1+bsz, bc1+bsz, br1-bsz, func_play, "tutorial_1"),
         gw.Button("pb_help",        bc2-bsz, br1+bsz, bc2+bsz, br1-bsz, func_key_help, "tutorial_4"),
         gw.Button("pb_quitmission", bc3-bsz, br1+bsz, bc3+bsz, br1-bsz, func_quit_mission, "tutorial_2"),
         gw.Button("pb_quitgame",    bc4-bsz, br1+bsz, bc4+bsz, br1-bsz, func_quit_game, "tutorial_3"),
         ]


class StatePauseMenu(fsm.State):
    def __init__(self):
        fsm.State.__init__(self)

    def init(self, unused_args):
        texMgr.loadTexture("data/buttons/help.png", "pb_help")
        texMgr.loadTexture("data/buttons/quit_level.png", "pb_quitmission")
        texMgr.loadTexture("data/buttons/quit_game.png", "pb_quitgame")

    def draw(self):
        glColor3f(1.0, 1.0, 1.0)
        self.parent.draw()
        glColor4f(0.0, 0.0, 0.0, 0.7)
        
        draw_util.draw_quad(None, 0, 600, 800, 0)
        glColor3f(1.0, 1.0, 1.0)

        for b in buttons:
            b.draw()

    def handleMouseButton(self, bDown, buttonIndex):
        if not bDown:
            return True
        
        for b in buttons:
            if b.handleMouseButton(bDown, buttonIndex):
                return True

        return True
        
    def update(self, dt):
        return True
        
        
