import ui
import snd
import systemSetting
import net
import chat
import app
import localeInfo
import constInfo
import chrmgr
import player

#Evo2-Radio © passy305, 2011
#Special Thanks to Sourcetunes!!

class RadioDialog(ui.ScriptWindow):

	def __init__(self):
		ui.ScriptWindow.__init__(self)
		
		self.oldPos = None
		
		self.__Initialize()
		self.__Load()

	def __del__(self):
		ui.ScriptWindow.__del__(self)

	def __Initialize(self):
		self.heavymetal = 0

	def Destroy(self):
		self.heavymetal = 0
	
		self.ClearDictionary()

		self.__Initialize()
	
	def __Load_LoadScript(self, fileName):
		try:
			pyScriptLoader = ui.PythonScriptLoader()
			pyScriptLoader.LoadScriptFile(self, fileName)
		except:
			import exception
			exception.Abort("Evo2Board.__Load_LoadScript")

	def __Load_BindObject(self):
		try:
			self.darkmetal = self.GetChild("darkmetal_button")
			self.hardrock = self.GetChild("hardrock_button")
			self.classicrock = self.GetChild("classicrock_button")
			self.alternativerock = self.GetChild("alternativerock_button")
			self.hairvoltage = self.GetChild("hairvoltage_button")
			self.theelement = self.GetChild("theelement_button")
			self.tapestry = self.GetChild("tapestry_button")
			self.lovebites = self.GetChild("lovebites_button")
			self.classicnewwave = self.GetChild("classicnewwave_button")
			self.indiealley = self.GetChild("indiealley_button")
			self.caribbeanbreeze = self.GetChild("caribbeanbreeze_button")
			self.reggaeton = self.GetChild("reggaeton_button")
			self.salsa = self.GetChild("salsa_button")
			self.merengue = self.GetChild("merengue_button")
			self.latinocaliente = self.GetChild("latinocaliente_button")
			self.continued = self.GetChild("weiter_button")
			self.back = self.GetChild("zurück_button")
			self.electrohouse = self.GetChild("electrohouse_button")
			self.housechannelmiami = self.GetChild("housechannelmiami_button")
			self.housemixsets = self.GetChild("housemixsets_button")
			self.alteredstate = self.GetChild("alteredstate_button")
			self.breakbeats = self.GetChild("breakbeats_button")
			self.trance = self.GetChild("trance_button")
			self.eurodance = self.GetChild("eurodance_button")
			self.gothamradio = self.GetChild("gothamradio_button")
			self.realindustrialradio = self.GetChild("realindustrialradio_button")
			self.barrockinblues = self.GetChild("barrockinblues_button")
			self.classicblues = self.GetChild("classicblues_button")
			self.smoothjazz = self.GetChild("smoothjazz_button")
			self.continued2 = self.GetChild("weiter2_button")
			self.back2 = self.GetChild("zurück2_button")

		except:
			import exception
			exception.Abort("Evo2Board.__Load_BindObject")

	def __Load(self):
		self.__Load_LoadScript("uiscript/evo2radio.py")
		
		self.__Load_BindObject()

		self.SetCenterPosition()
		
		self.back.Hide()
		self.electrohouse.Hide()
		self.housechannelmiami.Hide()
		self.housemixsets.Hide()
		self.alteredstate.Hide()
		self.breakbeats.Hide()
		self.trance.Hide()
		self.eurodance.Hide()
		self.gothamradio.Hide()
		self.realindustrialradio.Hide()
		self.barrockinblues.Hide()
		self.classicblues.Hide()
		self.smoothjazz.Hide()
		self.continued2.Hide()
		self.back2.Hide()
		
		self.darkmetal.SetEvent(ui.__mem_func__(self.OnKlickDarkMetal))
		self.hardrock.SetEvent(ui.__mem_func__(self.OnKlickHardRock))
		self.classicrock.SetEvent(ui.__mem_func__(self.OnKlickClassicRock))
		self.alternativerock.SetEvent(ui.__mem_func__(self.OnKlickAlternativeRock))
		self.hairvoltage.SetEvent(ui.__mem_func__(self.OnKlickHairVoltage))
		self.theelement.SetEvent(ui.__mem_func__(self.OnKlickTheElement))
		self.tapestry.SetEvent(ui.__mem_func__(self.OnKlickTapestry))
		self.lovebites.SetEvent(ui.__mem_func__(self.OnKlickLoveBites))
		self.classicnewwave.SetEvent(ui.__mem_func__(self.OnKlickClassicNewWave))
		self.indiealley.SetEvent(ui.__mem_func__(self.OnKlickIndieAlley))
		self.caribbeanbreeze.SetEvent(ui.__mem_func__(self.OnKlickCaribbeanBreeze))
		self.reggaeton.SetEvent(ui.__mem_func__(self.OnKlickReggaeton))
		self.salsa.SetEvent(ui.__mem_func__(self.OnKlickSalsa))
		self.merengue.SetEvent(ui.__mem_func__(self.OnKlickMerengue))
		self.latinocaliente.SetEvent(ui.__mem_func__(self.OnKlickLatinoCaliente))
		self.continued.SetEvent(ui.__mem_func__(self.OnKlickContinued))
		self.back.SetEvent(ui.__mem_func__(self.OnKlickBack))
		self.electrohouse.SetEvent(ui.__mem_func__(self.OnKlickElectroHouse))
		self.housechannelmiami.SetEvent(ui.__mem_func__(self.OnKlickHouseChannelMiami))
		self.housemixsets.SetEvent(ui.__mem_func__(self.OnKlickHouseMixSets))
		self.alteredstate.SetEvent(ui.__mem_func__(self.OnKlickAlteredState))
		self.breakbeats.SetEvent(ui.__mem_func__(self.OnKlickBreakbeats))
		self.trance.SetEvent(ui.__mem_func__(self.OnKlickTrance))
		self.eurodance.SetEvent(ui.__mem_func__(self.OnKlickEuroDance))
		self.gothamradio.SetEvent(ui.__mem_func__(self.OnKlickGothamRadio))
		self.realindustrialradio.SetEvent(ui.__mem_func__(self.OnKlickRealIndustrialRadio))
		self.barrockinblues.SetEvent(ui.__mem_func__(self.OnKlickBarRockinBlues))
		self.classicblues.SetEvent(ui.__mem_func__(self.OnKlickClassicBlues))
		self.smoothjazz.SetEvent(ui.__mem_func__(self.OnKlickSmoothJazz))
		self.continued2.SetEvent(ui.__mem_func__(self.OnKlickContinued2))
		self.back2.SetEvent(ui.__mem_func__(self.OnKlickBack2))
		
	def OnKlickDarkMetal(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://mmo.metin2serenity.com/manele.php", (sx, sy, ex, ey))
		
	def OnKlickHardRock(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://mmo.metin2serenity.com/zufm.php", (sx, sy, ex, ey))
		
	def OnKlickClassicRock(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://mmo.metin2serenity.com/radio21.php", (sx, sy, ex, ey))
		
	def OnKlickAlternativeRock(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://mmo.metin2serenity.com/radiohot.php", (sx, sy, ex, ey))
		
	def OnKlickHairVoltage(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=65&title=Player", (sx, sy, ex, ey))
		
		#chat.AppendChat(chat.CHAT_TYPE_NOTICE, "Entschuldige, dieser Kanal funktioniert derzeit leider nicht.")
		
	def OnKlickTheElement(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://stream.profm.ro:8012/profm.mp3", (sx, sy, ex, ey))
		
	def OnKlickTapestry(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=66&title=Player", (sx, sy, ex, ey))
		
	def OnKlickLoveBites(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=67&title=Player", (sx, sy, ex, ey))
		
	def OnKlickClassicNewWave(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=69&title=Player", (sx, sy, ex, ey))
		
	def OnKlickIndieAlley(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=71&title=Player", (sx, sy, ex, ey))
		
	def OnKlickCaribbeanBreeze(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=22&title=Player", (sx, sy, ex, ey))
		
	def OnKlickReggaeton(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=92&title=Player", (sx, sy, ex, ey))
		
	def OnKlickSalsa(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=93&title=Player", (sx, sy, ex, ey))
		
	def OnKlickMerengue(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=94&title=Player", (sx, sy, ex, ey))
		
	def OnKlickLatinoCaliente(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=23&title=Player", (sx, sy, ex, ey))
		
	def OnKlickElectroHouse(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=9&title=Player", (sx, sy, ex, ey))
		
	def OnKlickHouseChannelMiami(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=43&title=Player", (sx, sy, ex, ey))
		
	def OnKlickHouseMixSets(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=44&title=Player", (sx, sy, ex, ey))
		
	def OnKlickAlteredState(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=46&title=Player", (sx, sy, ex, ey))
		
	def OnKlickBreakbeats(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=47&title=Player", (sx, sy, ex, ey))
		
	def OnKlickTrance(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=54&title=Player", (sx, sy, ex, ey))
		
	def OnKlickEuroDance(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=58&title=Player", (sx, sy, ex, ey))
		
	def OnKlickGothamRadio(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=100&title=Player", (sx, sy, ex, ey))
		
	def OnKlickRealIndustrialRadio(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=99&title=Player", (sx, sy, ex, ey))
		
	def OnKlickBarRockinBlues(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=16&title=Player", (sx, sy, ex, ey))
		
	def OnKlickClassicBlues(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=17&title=Player", (sx, sy, ex, ey))
		
	def OnKlickSmoothJazz(self):
		self.Show()
		self.SetCenterPosition()
		
		x, y = self.GetGlobalPosition()
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40

		app.ShowWebPage("http://www.sourcetunes.com/multiplayer/play.php?page=start&station_id=80&title=Player", (sx, sy, ex, ey))
		
	def OnKlickContinued(self):
		self.darkmetal.Hide()
		self.hardrock.Hide()
		self.classicrock.Hide()
		self.alternativerock.Hide()
		self.hairvoltage.Hide()
		self.theelement.Hide()
		self.tapestry.Hide()
		self.lovebites.Hide()
		self.classicnewwave.Hide()
		self.indiealley.Hide()
		self.caribbeanbreeze.Hide()
		self.reggaeton.Hide()
		self.salsa.Hide()
		self.merengue.Hide()
		self.latinocaliente.Hide()
		self.continued.Hide()
		self.back.Show()
		self.electrohouse.Show()
		self.housechannelmiami.Show()
		self.housemixsets.Show()
		self.alteredstate.Show()
		self.breakbeats.Show()
		self.trance.Show()
		self.eurodance.Show()
		self.gothamradio.Show()
		self.realindustrialradio.Show()
		self.barrockinblues.Show()
		self.classicblues.Show()
		self.smoothjazz.Show()
		self.continued2.Show()
		self.back2.Hide()
		
	def OnKlickBack(self):
		self.darkmetal.Show()
		self.hardrock.Show()
		self.classicrock.Show()
		self.alternativerock.Show()
		self.hairvoltage.Show()
		self.theelement.Show()
		self.tapestry.Show()
		self.lovebites.Show()
		self.classicnewwave.Show()
		self.indiealley.Show()
		self.caribbeanbreeze.Show()
		self.reggaeton.Show()
		self.salsa.Show()
		self.merengue.Show()
		self.latinocaliente.Show()
		self.continued.Show()
		self.back.Hide()
		self.electrohouse.Hide()
		self.housechannelmiami.Hide()
		self.housemixsets.Hide()
		self.alteredstate.Hide()
		self.breakbeats.Hide()
		self.trance.Hide()
		self.eurodance.Hide()
		self.gothamradio.Hide()
		self.realindustrialradio.Hide()
		self.barrockinblues.Hide()
		self.classicblues.Hide()
		self.smoothjazz.Hide()
		self.continued2.Hide()
		self.back2.Hide()
		
	def OnKlickContinued2(self):
		self.darkmetal.Hide()
		self.hardrock.Hide()
		self.classicrock.Hide()
		self.alternativerock.Hide()
		self.hairvoltage.Hide()
		self.theelement.Hide()
		self.tapestry.Hide()
		self.lovebites.Hide()
		self.classicnewwave.Hide()
		self.indiealley.Hide()
		self.caribbeanbreeze.Hide()
		self.reggaeton.Hide()
		self.salsa.Hide()
		self.merengue.Hide()
		self.latinocaliente.Hide()
		self.continued.Hide()
		self.back.Hide()
		self.electrohouse.Hide()
		self.housechannelmiami.Hide()
		self.housemixsets.Hide()
		self.alteredstate.Hide()
		self.breakbeats.Hide()
		self.trance.Hide()
		self.eurodance.Hide()
		self.gothamradio.Hide()
		self.realindustrialradio.Hide()
		self.barrockinblues.Hide()
		self.classicblues.Hide()
		self.smoothjazz.Hide()
		self.continued2.Hide()
		self.back2.Show()
		
	def OnKlickBack2(self):
		self.darkmetal.Hide()
		self.hardrock.Hide()
		self.classicrock.Hide()
		self.alternativerock.Hide()
		self.hairvoltage.Hide()
		self.theelement.Hide()
		self.tapestry.Hide()
		self.lovebites.Hide()
		self.classicnewwave.Hide()
		self.indiealley.Hide()
		self.caribbeanbreeze.Hide()
		self.reggaeton.Hide()
		self.salsa.Hide()
		self.merengue.Hide()
		self.latinocaliente.Hide()
		self.continued.Hide()
		self.back.Show()
		self.electrohouse.Show()
		self.housechannelmiami.Show()
		self.housemixsets.Show()
		self.alteredstate.Show()
		self.breakbeats.Show()
		self.trance.Show()
		self.eurodance.Show()
		self.gothamradio.Show()
		self.realindustrialradio.Show()
		self.barrockinblues.Show()
		self.classicblues.Show()
		self.smoothjazz.Show()
		self.continued2.Show()
		self.back2.Hide()

	def Show(self):
		ui.ScriptWindow.Show(self)
		
	def OnPressEscapeKey(self):
		app.HideWebPage()
		self.ClearDictionary()
		self.Close()
		return TRUE
		
	def __OnCloseButtonClick(self):
		app.HideWebPage()
		self.ClearDictionary()
		self.Close()
		return TRUE

	def Refresh(self):
		pass

	def Close(self):
		app.HideWebPage()
		self.ClearDictionary()
		self.Hide()
	
	def OnUpdate(self):
		newPos = self.GetGlobalPosition()
		if newPos == self.oldPos:
			return

		self.oldPos = newPos

		x, y = newPos
		sx, sy = x + 10, y + 30
		ex, ey = sx + self.GetWidth() - 20, sy + self.GetHeight() - 40
		app.MoveWebPage((sx, sy, ex, ey))
