def startEmulator(self): '''Starts the loaded ROM in an emulator.''' print(self.config) if not 'emulator' in self.config: showInfo(self.mainview, "No emulator is set in the config file! Can not emulate the ROM.") return try: command = [x if x != "%u" else self.rom.filename for x in shlex.split(self.config['emulator'])] subprocess.Popen(command) except Exception as e: showError(self.mainview, "Could not start the emulator:\n"+repr(e))
def _compileandtest(self): try: sg = self._compile() except Exception as e: showError(self.mainview, "Compiling failed.\n\nDEBUG: "+str(e)) raise e return None try: self._validate(sg) except Exception as e: showError(self.mainview, "There are one or multiple error in script:\n"+str(e)) raise e return None return sg
def _compileandtest(self): try: sg = self._compile() except Exception as e: showError(self.mainview, "Compiling failed.\n\nDEBUG: " + str(e)) raise e return None try: self._validate(sg) except Exception as e: showError(self.mainview, "There are one or multiple error in script:\n" + str(e)) raise e return None return sg
def burnScript(self): '''Compiles the source, if succesful updates the in-game scripts.''' sg = self._compileandtest() if sg == None: return try: try: pointers = self.currentScriptgroup.getPointerlist() except: pointers = {} rom = self.rom #set pointers in new scriptgroup related to old scriptgroup for varname in sg.getPointerlist(): if varname in pointers: sg.setPointer(varname, pointers[varname]) print("______________________") print("Burning") b = ScriptBurner(rom) _ = b.burn(sg) #newpointers print("______________________") print("Update script pointers") pointerslist = sg.getPointerlist() for varname, resource in self.startvars.items(): try: resource.scriptpointer = pointerslist[varname] except: resource.scriptpointer = 0 self.rom.getRM().store(resource) print("") print("!! All done! Script injection was succesful!") self.currentScriptgroup = sg showInfo(self.mainview, "Script was succesfully written to the ROM.") except Exception as e: showError( self.mainview, "The script compiled succesfully, but writing the changes to the ROM failed.\n\nDEBUG: " + str(e)) raise e
def startEmulator(self): '''Starts the loaded ROM in an emulator.''' print(self.config) if not 'emulator' in self.config: showInfo( self.mainview, "No emulator is set in the config file! Can not emulate the ROM." ) return try: command = [ x if x != "%u" else self.rom.filename for x in shlex.split(self.config['emulator']) ] subprocess.Popen(command) except Exception as e: showError(self.mainview, "Could not start the emulator:\n" + repr(e))
def burnScript(self): '''Compiles the source, if succesful updates the in-game scripts.''' sg = self._compileandtest() if sg == None: return try: try: pointers = self.currentScriptgroup.getPointerlist() except: pointers = {} rom = self.rom #set pointers in new scriptgroup related to old scriptgroup for varname in sg.getPointerlist(): if varname in pointers: sg.setPointer(varname, pointers[varname]) print("______________________") print("Burning") b = ScriptBurner(rom) _ = b.burn(sg) #newpointers print("______________________") print("Update script pointers") pointerslist = sg.getPointerlist() for varname, resource in self.startvars.items(): try: resource.scriptpointer = pointerslist[varname] except: resource.scriptpointer = 0 self.rom.getRM().store(resource) print("") print("!! All done! Script injection was succesful!") self.currentScriptgroup = sg showInfo(self.mainview, "Script was succesfully written to the ROM.") except Exception as e: showError(self.mainview, "The script compiled succesfully, but writing the changes to the ROM failed.\n\nDEBUG: "+str(e)) raise e
def __init__(self, controller): config = readconfig("config.txt") app = QApplication(sys.argv) if len(sys.argv) > 1: filename = sys.argv[1] else: filename = QFileDialog.getOpenFileName(caption='Select ROM', filter='GBA (*.gba);;All Files (*.*)') if not filename: print("No file was selected.") return try: rom = ROM(filename) except Exception as e: showError(None, "There was an error opening the ROM "+filename+":\n"+str(e)) return controller(rom, config) sys.exit(app.exec_())
def __init__(self, rom, config): '''Set up and show the main view.''' self.rom = rom self.config = config self.currentScriptgroup = None self.startvars = {} try: self.mapmgr = PokeMapManager(self.rom) self.overworld = OverWorldSprites(self.rom) self.mainview = MainView(self) self.mapchange(4, 0) except Exception as e: print(e) showError(None, "There was an unexpected error, the program will quit.\n\n"+ "Possible cautions:\n1) the opened ROM is no GBA Pokemon Game, or\n2) the"+ "provided METADATA file is incomplete, or contains invalid values.\n\n"+ "DEBUG information:\n"+str(e), quitapp=False) raise e
def __init__(self, rom, config): '''Set up and show the main view.''' self.rom = rom self.config = config self.currentScriptgroup = None self.startvars = {} try: self.mapmgr = PokeMapManager(self.rom) self.overworld = OverWorldSprites(self.rom) self.mainview = MainView(self) self.mapchange(4, 0) except Exception as e: print(e) showError( None, "There was an unexpected error, the program will quit.\n\n" + "Possible cautions:\n1) the opened ROM is no GBA Pokemon Game, or\n2) the" + "provided METADATA file is incomplete, or contains invalid values.\n\n" + "DEBUG information:\n" + str(e), quitapp=False) raise e