def load_preferences(self): self.processing_le.setText( str(config.get('error', 'processing_length'))) self.undo_count_le.setText( str(config.get('error', 'minimum_undo_count'))) self.undo_threshold_le.setText( str(config.get('error', 'undo_threshold')))
def load_preferences(self): self.prob_le.setText( str(config.get('thresholds', 'probability_threshold'))) self.reset_le.setText(str(config.get('thresholds', 'reset_threshold'))) self.confirmation_le.setText( str(config.get('thresholds', 'confirmation_threshold'))) self.black_le.setText(str(config.get('thresholds', 'black_threshold'))) self.white_le.setText(str(config.get('thresholds', 'white_threshold')))
def load_preferences(self): self.override_ver_cb.setChecked(config.get("game", "override_version")) self.mid_run_cb.setChecked( config.get("general", "mid_run_start_enabled")) if config.get("game", "version") == "US": self.override_ver_combo.setCurrentIndex(1) else: self.override_ver_combo.setCurrentIndex(0) self.override_ver_combo.setDisabled( not self.override_ver_cb.isChecked())
def open_route(self): self._stop() if config.get("route", "path") == "": return try: route = route_loader.load(config.get("route", "path")) except KeyError: self.display_error_message("Key Error", "Route Error") return False if not route: self.display_error_message("Could not load route", "Route Error") self._load_route_dir() config.set_key("route", "path", "") config.save_config() return False error = route_loader.validate_route(route) if error: self.display_error_message(error, "Route Error") return False self.route = route self.split_list.clear() self.star_count.star_count = route.initial_star self.star_count.split_star = route.splits[0].star_count for split in route.splits: split_icon_path = split.icon_path if split_icon_path: split_icon_path = rel_to_abs(split_icon_path) icon = QtGui.QPixmap(split_icon_path) else: icon = None self.split_list.add_split(split.title, icon) self.split_list.repaint() return True
def run(self): self._running = True reset_occurred = False frame = 0 generated_frames = [] while self._running: c_time = time.time() try: self._game_capture.capture() except: self.error.emit("Unable to capture " + config.get("game", "process_name")) self.stop() break reset_region = self._game_capture.get_region(RESET_REGION) fadeout_region = self._game_capture.get_region(FADEOUT_REGION) if is_black(fadeout_region, 0.1, 0.97): reset_occurred = True if reset_occurred: if not is_black(fadeout_region, config.get("thresholds", "black_threshold"), 0.99): frame += 1 if frame <= self.CAPTURE_COUNT: generated_frames.append(reset_region) else: self._running = False try: time.sleep((1 / 29.97) - (time.time() - c_time)) except ValueError: pass for i, frame in enumerate(generated_frames): cv2.imwrite( "resources/images/generated_temp_" + str(i + 1) + ".jpg", frame) self.generated.emit()
def show(self): # Load game_region from preferences game_region = config.get('game', 'game_region') self.game_region_selector.resize(game_region[2], game_region[3]) self.game_region_selector.setPos(game_region[0], game_region[1]) self.game_region_panel.update_text(*[str(v) for v in game_region]) self._refresh_process_list() p_name = config.get("game", "process_name") for i in range(len(self._process_list)): if self._process_list[i][0].name() == p_name: self.process_combo.setCurrentIndex(i) self.refresh_graphics_scene() config.create_rollback() super().show()
def _save_open_route(self, file_path): prev_route = config.get("route", "path") config.set_key("route", "path", file_path) config.save_config() success = self.open_route() if success: return else: config.set_key("route", "path", prev_route) config.save_config() self.open_route()
def load_preferences(self): self.restart_delay_le.setText( str(config.get('advanced', 'restart_split_delay'))) self.reset_one_le.setText( str(config.get('advanced', 'reset_frame_one'))) self.reset_two_le.setText( str(config.get('advanced', 'reset_frame_two'))) self.star_delay_le.setText( str(config.get('advanced', 'star_process_frame_rate'))) self.fadeout_delay_le.setText( str(config.get('advanced', 'fadeout_process_frame_rate'))) self.model_le.setText(config.get('model', 'path')) self.model_width_le.setText(str(config.get('model', 'width'))) self.model_height_le.setText(str(config.get('model', 'height')))
def load_route(self, route_path=None): """ Loads route from path specified in preferences :return: """ if not route_path: _route_path = config.get("route", "path") else: _route_path = route_path try: route = route_loader.load(_route_path) if route: route_error = route_loader.validate_route(route) else: self.new() return if route_error: self.display_error_message(route_error, "Route Error") except FileNotFoundError: route = None self.display_error_message( "Route file not found.", "Invalid route: {}".format(path.basename(_route_path))) except KeyError: route = None self.display_error_message( "Invalid or missing Key", "Invalid route: {}".format(path.basename(_route_path))) except JSONDecodeError: route = None self.display_error_message( "Invalid JSON formatting", "Invalid route: {}".format(path.basename(_route_path))) except PermissionError: route = None if route: self.route = route self.route_path = self.route.file_path config.set_key("route", "path", resource_utils.abs_to_rel(_route_path)) config.save_config() self.display_route()
def contextMenuEvent(self, event): context_menu = QtWidgets.QMenu(self) route_menu = QtWidgets.QMenu("Open Route") route_actions = {} category_menus = {} # SRL MODE Action srl_action = QtWidgets.QAction("SRL Mode", self, checkable=True) context_menu.addAction(srl_action) srl_action.setChecked(config.get("general", "srl_mode")) context_menu.addSeparator() for category in sorted(self._routes, key=lambda text:[int(c) if c.isdigit() else c for c in re.split(r'(\d+)', text)]): if len(self._routes[category]) == 1 or category == "": for route in self._routes[category]: route_menu.addAction(route[0]) route_actions[route[0]] = partial(self._save_open_route, route[1]) else: category_menus[category] = QtWidgets.QMenu(str(category)) route_menu.addMenu(category_menus[category]) for route in self._routes[category]: category_menus[category].addAction(route[0]) route_actions[route[0]] = partial(self._save_open_route, route[1]) route_menu.addSeparator() file_action = route_menu.addAction("From File") # Actions edit_route = context_menu.addAction("Edit Route") context_menu.addMenu(route_menu) context_menu.addSeparator() cords_action = context_menu.addAction("Edit Coordinates") context_menu.addSeparator() advanced_action = context_menu.addAction("Settings") context_menu.addSeparator() reset_gen_action = context_menu.addAction("Generate Reset Templates") context_menu.addSeparator() about_action = context_menu.addAction("About") exit_action = context_menu.addAction("Exit") action = context_menu.exec_(self.mapToGlobal(event.pos())) # Connections if action == srl_action: checked = srl_action.isChecked() config.set_key("general", "srl_mode", checked) config.save_config() elif action == edit_route: self.dialogs["route_editor"].show() elif action == file_action: self.open_route_browser() elif action == cords_action: self.dialogs["capture_editor"].show() elif action == advanced_action: self.dialogs["settings_dialog"].show() elif action == reset_gen_action: self.dialogs["reset_dialog"].show() elif action == about_action: self.dialogs["about_dialog"].show() elif action == exit_action: self.close() else: try: route_actions[action.text()]() except (KeyError, AttributeError): pass
def load_preferences(self): self.host_le.setText(str(config.get('connection', 'ls_host'))) self.port_le.setText(str(config.get('connection', 'ls_port')))
def load_config(self): val = config.get(self._config_section, self._config_key) self.red.setText(str(val[2])) self.green.setText(str(val[1])) self.blue.setText(str(val[0]))
def __init__(self): super().__init__() self._running = False self._game_capture = GameCapture(config.get("game", "process_name"), config.get("game", "game_region"), GAME_JP)