#####################################################
#													#
#	MultiLanguage System by .Eugen @ TheWarez.net	#
#                                                   #
#####################################################

import net
import snd
import localeInfo
import ui
import uiTip
import dbg
import os
import app

class MultiLanguage(ui.BoardWithTitleBar):
	def __init__(self):
		ui.BoardWithTitleBar.__init__(self)
		self.LoadMultiLanguage()
		
	def __del__(self):
		ui.BoardWithTitleBar.__del__(self)
		
	def Destroy(self):
		self.Hide()
		return TRUE
		
	def LoadMultiLanguage(self):
		self.SetSize(127, 185)
		self.Show()
		self.AddFlag('movable')
		self.AddFlag("float")
		self.SetTitleName('Language')
		self.SetCenterPosition()
		self.SetCloseEvent(self.Close)
				
		self.LoadButtons()
		
	def LoadButtons(self):
	
		self.EnButton = ui.Button()
		self.EnButton.SetParent(self)
		self.EnButton.SetPosition(20, 50)
		self.EnButton.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
		self.EnButton.SetOverVisual("d:/ymir work/ui/public/Large_Button_02.sub")
		self.EnButton.SetDownVisual("d:/ymir work/ui/public/Large_Button_03.sub")
		self.EnButton.SetText("English")
		self.EnButton.SetEvent(self.__Language_1)
		self.EnButton.Show()
	
		self.RoButton = ui.Button()
		self.RoButton.SetParent(self)
		self.RoButton.SetPosition(20, 80)
		self.RoButton.SetUpVisual("d:/ymir work/ui/public/Large_Button_01.sub")
		self.RoButton.SetOverVisual("d:/ymir work/ui/public/Large_Button_02.sub")
		self.RoButton.SetDownVisual("d:/ymir work/ui/public/Large_Button_03.sub")
		self.RoButton.SetText("Românã")
		self.RoButton.SetEvent(self.__Language_2)
		self.RoButton.Show()
		
				
	def __Language_1(self):
		file = open("locale.cfg", "w")
 		file.write("10002 1252 en") 
		file.close()
		dbg.LogBox("The laguage of client was changed to English!")
		dbg.LogBox("Client will restart.")
		os.system('start Start.bat')
		app.Exit()
		self.Close()
	
	def __Language_2(self):
		file = open("locale.cfg", "w")
 		file.write("10022 1250 tr") 
		file.close()
		dbg.LogBox("Traducerea clientului se va schimba!")
		dbg.LogBox("Clientul se va restarta!")
		os.system('start Start.bat')
		app.Exit()
			
		
	def Close(self):
		self.Hide()

	def OnPressEscapeKey(self):
		self.Close()
		return TRUE
		
