def game_mode_change(self, response: dict): logger.info("the landscapelab tries to change the game mode") if "projection_epsg" in response: epsg = int(response["projection_epsg"]) else: epsg = self.config.get("map_settings", "coordinate_reference_system") # calculate the main map extent based on the starting location start_position = Vector(float(response["start_position_x"]), float(response["start_position_y"])) width = float(response["start_extent_x"]) height = float(response["start_extent_y"]) start_extent = Extent.around_center(start_position, width, height/width) self.extent_tracker.map_extent = start_extent # setup the minimap extent mm_min_x = float(response["minimap_min_x"]) mm_min_y = float(response["minimap_min_y"]) mm_max_x = float(response["minimap_max_x"]) mm_max_y = float(response["minimap_max_y"]) minimap_extent = Extent(mm_min_x, mm_min_y, mm_max_x, mm_max_y) # change the maps self.mini_map.initialize_map(epsg, minimap_extent) self.main_map.initialize_map(epsg, start_extent) # reset the tracker and feed him the allowed brick combinations allowed_bricks = [] for token_dict in response["used_tokens"]: shape = BrickShape[token_dict["shape"]] color = BrickColor[token_dict["color"]] icon_id = token_dict["icon_name"] brick_config.icon_config[(token_dict["shape"], token_dict["color"])] = icon_id disappear = float(token_dict["disappear_after_seconds"]) # FIXME: to be implemented token = Token(shape, color, icon_id) # FIXME: currently the svg is not implemented (coded via icon names) allowed_bricks.append(token) self.tracker.change_game_mode(allowed_bricks) # add new tokens for brick in response["existing_tokens"]: self.create_local_brick(brick) # create the scores for the new game mode scores = [] for score_dict in response["scores"]: score_id = int(score_dict["score_id"]) initial_value = float(score_dict["initial_value"]) target_value = float(score_dict["target_value"]) name = "" if score_dict["name"]: name = score_dict["name"] score = Score(score_id, target_value, initial_value, name) scores.append(score) UISetup.add_progressbars_to_ui(self.progressbars_ui, self.config, scores) # finally set to EXTERNAL ProgramStage self.program_stage.next()
def render_callback(response: dict): extent = Extent(float(response["extent"]["x_min"]), float(response["extent"]["y_min"]), float(response["extent"]["x_max"]), float(response["extent"]["y_max"]), True) # convert response to the bytebuffer base64_bytes = response["image"].encode("ascii") buffer = base64.standard_b64decode(base64_bytes) self.callbacks[response["target"]].refresh(extent, buffer)
def set_screen_config_info(config): monitors = screeninfo.get_monitors() config.set("screen_resolution", "width", monitors[0].width) config.set("screen_resolution", "height", monitors[0].height) config.set("screen_resolution", "pos_x", monitors[0].x - 1) config.set("screen_resolution", "pos_y", monitors[0].y - 1) beamer_id = config.get("beamer_resolution", "screen_id") if beamer_id >= 0: # if beamer-id out of bounds use last screen beamer_id = min(beamer_id, len(monitors) - 1) beamer = monitors[beamer_id] config.set("beamer_resolution", "width", beamer.width) config.set("beamer_resolution", "height", beamer.height) config.set("beamer_resolution", "pos_x", beamer.x - 1) config.set("beamer_resolution", "pos_y", beamer.y - 1) ExtentTracker.get_instance().beamer = Extent(0, 0, beamer.width, beamer.height)
def set_size(self, size: Vector): self.area = Extent(self.area.get_upper_left(), self.position + size) self.size = size