def Core_Install_Response(self, FileChooser, Response): CoreSettingsTree = { ("", 1, ("name", "system"), SettingsCheck.CoreNameSanityCheck): None } if Response == Gtk.ResponseType.ACCEPT: filename = FileChooser.get_filename() SystemArchive = Archive(filename, 'r') try: settingsstring = SystemArchive.read("core.xml") CoreXML = ET.XML(settingsstring) ValidSettings = SettingsCheck.check_settings( CoreSettingsTree, CoreXML) if not ValidSettings: raise Exception("Invalid Core Settings") systemname = CoreXML.get("system") corename = CoreXML.get("name") if os.path.isdir(Globals.DataDir + "Systems/System_" + systemname): if not os.path.isdir(Globals.DataDir + "Systems/System_" + systemname + "/" + corename): os.mkdir(Globals.DataDir + "Systems/System_" + systemname + "/Core_" + corename) SystemArchive.extractall( path=Globals.DataDir + "Systems/System_" + systemname + "/Core_" + corename) Globals.Cores.append(systemname + "/" + corename) popup = ErrorPopupWindow( "Core Installed", "Core installed successfully!") popup.set_transient_for(self) popup.show_all() else: popup = ErrorPopupWindow( "Core already exists", "Core already exists, uninstall the core first.") popup.set_transient_for(self) popup.show_all() else: popup = ErrorPopupWindow( "System not found", "System: " + systemname + " not found, please install the system before the core" ) popup.set_transient_for(self) popup.show_all() except Exception as e: print e popup = ErrorPopupWindow( "Malformed Core", "Archive containing the core is malformed, try redownloading the archive" ) popup.set_transient_for(self) popup.show_all() FileChooser.destroy() Globals.OpenWindows &= ~Globals.WINDOWTYPE_FILECHOOSER
def System_Install_Response(self, FileChooser, Response): SystemSettingsTree = { ("", 1, ("name", ), SettingsCheck.SystemNameSanityCheck): None } if Response == Gtk.ResponseType.ACCEPT: filename = FileChooser.get_filename() SystemArchive = Archive(filename, 'r') try: settingsstring = SystemArchive.read("system.xml") SystemXML = ET.XML(settingsstring) ValidSettings = SettingsCheck.check_settings( SystemSettingsTree, SystemXML) if not ValidSettings: raise Exception systemname = SystemXML.get("name") if not os.path.isdir(Globals.DataDir + "Systems/System_" + systemname): os.mkdir(Globals.DataDir + "Systems/System_" + systemname) if not os.path.isdir(Globals.DataDir + "Games/" + systemname): os.mkdir(Globals.DataDir + "Games/" + systemname) SystemArchive.extractall(path=Globals.DataDir + "Systems/System_" + systemname) Globals.Systems.append(systemname) popup = ErrorPopupWindow("System Installed", "System installed successfully!") popup.set_transient_for(self) popup.show_all() else: popup = ErrorPopupWindow( "System already exists", "System already exists, uninstall the system first.") popup.set_transient_for(self) popup.show_all() except: popup = ErrorPopupWindow( "Malformed System", "Archive containing the system is malformed, try redownloading the archive" ) popup.set_transient_for(self) popup.show_all() FileChooser.destroy() Globals.OpenWindows &= ~Globals.WINDOWTYPE_FILECHOOSER
def on_menu_make_game(self, widget): if not len(Globals.Systems) or not len(Globals.Cores): popup = ErrorPopupWindow( "No Systems or Core", "A game cannot be created without at least one system and one core" ) popup.set_transient_for(self) popup.show_all() elif not Globals.OpenWindows & Globals.WINDOWTYPE_MAKEGAME: GameMakerWindow = MakeGameWindow() GameMakerWindow.set_transient_for(self) GameMakerWindow.show_all()
def on_button_make_clicked(self,Button,NameEntry,syscombobox,corecombobox, filechooserbutton, CheckBox): domake = True gamename = NameEntry.get_text() if gamename != "": if not filechooserbutton.get_filenames(): popup = ErrorPopupWindow("Choose File", "You must have a game file") popup.set_transient_for(self) popup.show_all() domake = False else: filename = filechooserbutton.get_filenames()[0] try: active = syscombobox.get_active() model = syscombobox.get_model() siter = model.get_iter(active) systext = model.get(siter,0)[0] try: active = corecombobox.get_active() model = corecombobox.get_model() siter = model.get_iter(active) coretext = model.get(siter,0)[0] except: popup = ErrorPopupWindow("Choose Core", "You must choose a core") popup.set_transient_for(self) popup.show_all() domake = False except: popup = ErrorPopupWindow("Choose File", "You must choose a system") popup.set_transient_for(self) popup.show_all() domake = False if domake: gamedir = Globals.DataDir+"Games/"+systext+"/"+gamename if os.path.isdir(gamedir): popup = ErrorPopupWindow("Game already exists", "A game of that name already exists, remove it first") popup.set_transient_for(self) popup.show_all() domake = False else: popup = ErrorPopupWindow("Game Name Empty", "Your game name cannot be empty") popup.set_transient_for(self) popup.show_all() domake = False if domake: os.makedirs(gamedir) #print gamename #print systext #print coretext gamefilename = filename.split("/")[-1] gameelem = ET.Element("Game",attrib={"name":gamename, "core":coretext, "filename":gamefilename, "system":systext}) found = False for system in Globals.GamesXML.findall("System"): if system.get("name") == systext: found = True system.append(ET.Element("Game",attrib={"name":gamename, "core":coretext})) if not found: system = ET.Element("System",attrib={"name",systext}) system.append(ET.Element("Game",attrib={"name":gamename, "core":coretext})) Globals.GamesXML.append(system) Globals.Update_Games() with open(Globals.DataDir+"Systems/System_"+systext+"/system.xml",'r') as sysfile: sysxml = ET.XML(sysfile.read()) syscontrols = sysxml.find("Controls") syscontrols.set("inherit","True") gameelem.append(syscontrols) with open(gamedir+"/game.xml",'w') as gamefile: gamefile.write(ET.tostring(gameelem)) shutil.copy(filename, gamedir+"/"+gamefilename) os.makedirs(gamedir+"/savestates") os.makedirs(gamedir+"/patches") os.makedirs(gamedir+"/screenshots") self.Destroy_Window(self)