# -*- coding: utf-8 -*-
"""
UTc! module: src.sounds

Purpose
=======
 Provides access to sound effect resources for use in games of Ultra Tank-chan!.
 
Legal
=====
 All code, unless otherwise indicated, is original, and subject to the
 terms of the GPLv3, which is provided in COPYING.
 
 (C) Neil Tallim, 2009
"""
import os
import random
import pygame

import path_utils

USE_SOUNDS = False #: True if sounds are to be used.

SND_UTC_STARTUP = None #: The sound to play when launching UTc!

SND_BOLT = None #: A pygame.mixer.Sound played when a bolt is launched.
SND_ECM = None #: A pygame.mixer.Sound played when an ECM is launched.
SND_MISSILE = None #: A pygame.mixer.Sound played when a missile is launched.

SND_IMPACT_BOLT_HULL = None #: A pygame.mixer.Sound played when a bolt hits the player's hull.
SND_IMPACT_BOLT_SHIELD = None #: A pygame.mixer.Sound played when a bolt hits the player's shields.
SND_IMPACT_MISSILE = None #: A pygame.mixer.Sound played when a bolt hits the player.

SND_NEW_EVENT = None #: A pygame.mixer.Sound played when a new event is displayed.
SND_NEW_MESSAGE = None #: A pygame.mixer.Sound played when a new message is displayed.

def init():
	"""
	Loads all sounds needed for gameplay.
	
	This function must be invoked before any sounds may be played.
	"""
	global USE_SOUNDS
	USE_SOUNDS = True
	
	sounds_path = path_utils.getSoundsPath()
	
	global SND_UTC_STARTUP
	SND_UTC_STARTUP = pygame.mixer.Sound(sounds_path + random.choice(("launch-1.ogg", "launch-2.ogg")))
	
	global SND_BOLT
	global SND_ECM
	global SND_MISSILE
	SND_BOLT = pygame.mixer.Sound(sounds_path + "bolt.ogg")
	SND_ECM = pygame.mixer.Sound(sounds_path + "ecm.ogg")
	SND_MISSILE = pygame.mixer.Sound(sounds_path + "missile.ogg")
	
	global SND_IMPACT_BOLT_HULL
	global SND_IMPACT_BOLT_SHIELD
	global SND_IMPACT_MISSILE
	SND_IMPACT_BOLT_HULL = pygame.mixer.Sound(sounds_path + "impact-bolt-hull.ogg")
	SND_IMPACT_BOLT_SHIELD = pygame.mixer.Sound(sounds_path + "impact-bolt-shield.ogg")
	SND_IMPACT_MISSILE = pygame.mixer.Sound(sounds_path + "impact-missile.ogg")
	
	global SND_NEW_EVENT
	global SND_NEW_MESSAGE
	SND_NEW_EVENT = pygame.mixer.Sound(sounds_path + "new-event.ogg")
	SND_NEW_MESSAGE = pygame.mixer.Sound(sounds_path + "new-message.ogg")
	