예제 #1
0
	def __init__(self,ini,profile):
		
		self.ini = ini
		self.profile = profile
		self.platform = sys.platform
		self.map_index = Config.get_option(self.ini, self.profile, 'MAP_INDEX', None)
		self.mod_index = Config.get_option(self.ini, self.profile, 'MOD_INDEX', None)

		# Add code to os.chdir  into datadir  IF USER IS USING ADVANCED SETUP
		# Get Datadirs from unitsync
		unitsync.Init(True,1)
		self.datadirs = []
		datadirs = unitsync.GetDataDirectories(False)
		for i in range(0,len(datadirs)):
			if os.path.isdir(datadirs[i]) == True:
				self.datadirs.append(datadirs[i])


		# Make Temp Config File
		self.conf = Config.get_option(self.ini, self.profile, 'SPRING_CONF', '')
		self.conf_temp = Config.get_option(self.ini, self.profile, 'SPRING_CONF_TEMP', '')
		if os.path.isfile(self.conf_temp) == False:
			Config.temp_config(self.conf, self.conf_temp, 'No')

		# Player Name
		self.my_player_name = Config.get_option(Config.get_option(self.ini, self.profile, 'SPRING_CONF_TEMP', ''), 'GAME', 'name', 'Player')

		# Map Index
		if os.path.isfile(self.map_index) == False:
			Index_Map.create_index(self)
			Index_Map.update_index(self)

		# Mod Index
		if os.path.isfile(self.mod_index) == False:
			Index_Mod.create_index(self)
			Index_Mod.update_index(self)


		# Main Window
		self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
		self.window.set_title("Spring GUI")
		self.window.set_resizable(True)
		self.window.connect("delete-event", gtk.main_quit)
		self.window.add_events(gtk.gdk.BUTTON_PRESS_MASK)

		# BackGround
		background = gtk.Image()
		background.set_from_file(Config.get_option(self.ini,self.profile,'BACKGROUND', ''))
		background.show()

		# Vertical Box Part 1/2
		vbox = gtk.VBox(False, 0)
		vbox.show()
		self.window.add(vbox)

		# Menu Part 1/2
		menu_bar = gtk.MenuBar()
		menu_bar.show()

		# Battle & Options Notebook
		battle_notebook = gtk.Notebook()
	        battle_notebook.set_tab_pos(gtk.POS_TOP)

	        options_notebook = gtk.Notebook()
		options_notebook.set_tab_pos(gtk.POS_RIGHT)


		# Notebooks
		GUI_Battle.create(self,battle_notebook)
		GUI_Config.create(self,options_notebook)

		#Vertical Box Part 2/2
		vbox.pack_start(menu_bar, False, False, 2)
		vbox.pack_end(background, True, True, 2)
		vbox.pack_start(battle_notebook, True, True, 2)
		vbox.pack_start(options_notebook, True, True, 2)

		self.window.show()

		# Menu Part 2/2
			#Menu Items
		battle_item = gtk.MenuItem("Battle")
		lobby_item = gtk.MenuItem("Lobby")
		config_item = gtk.MenuItem("Options")
		start_item = gtk.MenuItem("Start")
		menu_bar.append(battle_item)
		menu_bar.append(lobby_item)
		menu_bar.append(config_item)
		menu_bar.append(start_item)

		battle_item.show()
		lobby_item.show()
		start_item.set_right_justified(1)
		config_item.show()

			#Menu-Connect
		battle_item.connect("button_press_event", self.battle, background, battle_notebook, options_notebook, start_item)
		config_item.connect("button_press_event", self.config, background, battle_notebook, options_notebook, start_item)
		start_item.connect("button_press_event", Battle.script_create, self)

		# Main Window destory event
		self.window.connect("delete-event", self.destroy, battle_notebook, options_notebook)