def prepare_emulator_skin(self, env=None, paths=None): if self._emulator_skin_prepared: return self._emulator_skin_prepared if paths is None: paths = self.emulator_skin_paths() with open(paths["left"], "wb") as f: f.write(Resources("fsgs").stream("res/emu/left.png").read()) if env is not None: env["FSGS_BEZEL_LEFT"] = paths["left"] env["FSGS_SKIN_LEFT"] = paths["left"] if "left-overlay" in paths: with open(paths["left-overlay"], "wb") as f: f.write( Resources("fsgs").stream( "res/emu/left-overlay.png").read()) if env is not None: env["FSGS_BEZEL_LEFT_OVERLAY"] = paths["left-overlay"] with open(paths["right"], "wb") as f: f.write(Resources("fsgs").stream("res/emu/right.png").read()) if env is not None: env["FSGS_BEZEL_RIGHT"] = paths["right"] env["FSGS_SKIN_RIGHT"] = paths["right"] if "right-overlay" in paths: with open(paths["right-overlay"], "wb") as f: f.write( Resources("fsgs").stream( "res/emu/right-overlay.png").read()) if env is not None: env["FSGS_BEZEL_RIGHT_OVERLAY"] = paths["right-overlay"] self._emulator_skin_prepared = paths return self._emulator_skin_prepared
def create_extended_adf(self, f): # Workbench 3.1 does not like the adf_extended file, created by # WinUAE (must check why) s = Resources("fsgs").stream("res/amiga/adf_save_disk.dat") data = s.read() data = zlib.decompress(data) f.write(data)
def get_config_files(): print("get_config_files") configs = {} input_stream = Resources("fsgs").stream("res/input/manifest.txt") print("opened input manifest") for line in input_stream.read().split(b"\n"): line = line.decode("UTF-8") path = line.strip() if not path: continue _, ext = os.path.splitext(path) if ext in [".ini", ".conf"]: parts = path.split("/") file_name = parts[-1] name, _ = os.path.splitext(file_name) if len(parts) > 1: configs[parts[-2] + '_' + name] = "fsgs:res/input/" + path # print(" -", path) configs[name] = "fsgs:res/input/" + path # FIXME: fix dependency controllers_dir = fsgs.amiga.get_controllers_dir() print("read configs from controllers_dir at", controllers_dir) if os.path.exists(controllers_dir): for file_name in os.listdir(controllers_dir): if file_name.endswith(".conf"): name, ext = os.path.splitext(file_name) path = os.path.join(controllers_dir, file_name) print(" -", path) configs[name] = path # print("input config files:", configs) return configs
def stream_for_size(self, size): # package, file_ = name.split(":", 1) assert self.path.startswith("pkg:") package = self.path[4:] try: name = "res/{0}x{0}/{1}.png".format(size, self.name) stream = Resources(package).stream(name) except LookupError: name = "res/{0}/{1}.png".format(size, self.name) stream = Resources(package).stream(name) return stream
def get_config_files(): print("get_config_files") configs = {} input_stream = Resources("fsgs").stream("res/input/manifest.txt") print("opened input manifest") for line in input_stream.read().split(b"\n"): line = line.decode("UTF-8") path = line.strip() if not path: continue _, ext = os.path.splitext(path) if ext in [".ini", ".conf"]: parts = path.split("/") file_name = parts[-1] name, _ = os.path.splitext(file_name) if len(parts) > 1: configs[parts[-2] + "_" + name] = "fsgs:res/input/" + path # print(" -", path) configs[name] = "fsgs:res/input/" + path # FIXME: fix dependency controllers_dir = fsgs.amiga.get_controllers_dir() print("read configs from controllers_dir at", controllers_dir) if os.path.exists(controllers_dir): for file_name in os.listdir(controllers_dir): if file_name.endswith(".conf"): name, ext = os.path.splitext(file_name) path = os.path.join(controllers_dir, file_name) print(" -", path) configs[name] = path keyboards_dir = os.path.join(FSGSDirectories.get_data_dir(), "Devs", "Keyboards") print("read configs from controllers_dir at", keyboards_dir) if os.path.exists(keyboards_dir): for file_name in os.listdir(keyboards_dir): if file_name.endswith(".ini"): name, ext = os.path.splitext(file_name) path = os.path.join(keyboards_dir, file_name) print(" -", path) configs[name] = path # print("input config files:", configs) return configs
def __init__(self, name="", object=None): if object: self.qimage = object else: self.qimage = QImage() if hasattr(name, "read"): self.qimage.loadFromData(name.read()) elif name.startswith("pkg://"): parts = name.split("/", 3) stream = Resources(parts[2]).stream(parts[3]) self.qimage.loadFromData(stream.read()) else: index = name.find(":") if index > 1: package, file_ = name.split(":", 1) stream = Resources(package).stream(file_) self.qimage.loadFromData(stream.read()) else: print("loading image from", name) self.qimage.load(name)
def prepare_floppies(self): print("LaunchHandler.copy_floppies") current_task.set_progress(gettext("Preparing floppy images...")) # self.on_progress(gettext("Preparing floppy images...")) floppies = [] for i in range(Amiga.MAX_FLOPPY_DRIVES): key = "floppy_drive_{0}".format(i) if self.config.get(key, ""): floppies.append(self.config[key]) self.prepare_floppy(key) for i in range(Amiga.MAX_FLOPPY_IMAGES): key = "floppy_image_{0}".format(i) if self.config.get(key, ""): break else: print("floppy image list is empty") for j, floppy in enumerate(floppies): self.config["floppy_image_{0}".format(j)] = floppy max_image = -1 for i in range(Amiga.MAX_FLOPPY_IMAGES): key = "floppy_image_{0}".format(i) self.prepare_floppy(key) if self.config.get(key, ""): max_image = i save_image = max_image + 1 if self.config.get("save_disk", "") != "0": s = Resources("fsgs", "res").stream("amiga/adf_save_disk.dat") data = s.read() data = zlib.decompress(data) save_disk = os.path.join(self.temp_dir, "Save Disk.adf") with open(save_disk, "wb") as f: f.write(data) key = "floppy_image_{0}".format(save_image) self.config[key] = "Save Disk.adf"
def read_config(self, config_name, config, platform, multiple): print("read_config", config_name) configs = self.get_config_files() print(config_name in configs) try: path = configs[config_name] except KeyError: # traceback.print_stack() print( "no config file found for", repr(self.sdl_name), "=", config_name, ) # raise InputDeviceNotFoundException( # "no config found for " + repr(self.sdl_name)) if platform: raise MissingPlatformSupportException("no config found for " + repr(self.sdl_name)) else: return cp = ConfigParser() print(path, os.path.exists(path)) if path.startswith("fsgs:"): print("reading config from stream", path) input_stream = Resources("fsgs").stream(path.split(":", 1)[1]) input_stream = io.TextIOWrapper(input_stream, "UTF-8") cp.read_file(input_stream) else: cp.read(path) if cp.has_option("device", "type"): self.type = cp.get("device", "type") if cp.has_option("device", "name"): # print("HAD NAME", self.name, self.sdl_name) self.name = cp.get("device", "name") self.decorate_name_with_number() # print("HAS NAME", self.name, self.sdl_name) # try: # dummy, num = self.name.rsplit('#', 1) # except ValueError: # self.name = name # else: # self.name = "{0} #{1}".format(name, num) if cp.has_section(platform): section = platform elif cp.has_section("default"): # print("has default section") section = "default" else: if platform: raise MissingPlatformSupportException( "no config found for platform " + repr(platform)) else: return # config = {} # if section == 'gamepad': # # for option in cp.options('gamepad'): # value = cp.get('gamepad', option) # print("gamepad", option, value) if cp.has_option(section, "include"): include_config = cp.get(section, "include") include_config = include_config.replace("/", "_") self.read_config(include_config, config, platform, multiple) # iconfig = {} # for key, value in config.items(): # iconfig[value] = key # for key in cp.options(section): # value = cp.get(section, key) for key, value in cp.items(section): value = value.strip() if value.startswith("("): if not multiple: continue assert value.endswith(")") value = value[1:-1] # print(key, "===>", value) # print("key, value is", key, value) # if value in iconfig: try: # config[key] = iconfig[value] # config[key] = config[value] # del config[value] # config[config[value]] = value # if key in iconfig: config[key] = config[value] # del iconfig[key] # iconfig[config[value]] = key # if not config[value] in iconfig: # iconfig[config[value]] = key del config[value] except KeyError: config[key] = value
def get_builtin_config_for_device_guid(cls, guid): return Resources("fsgs").stream("res/input/" + guid + ".fs-uae-controller")
def create_adf(self, f): s = Resources("fsgs").stream("res/amiga/adf.dat") data = s.read() data = zlib.decompress(data) f.write(data)
def __init__(self, package): BaseResources.__init__(self, package, "res") self.req = package