def _ui_metadata_gen(self): additional_information = self._get_additional_information() if additional_information and self.show_gardening_details(): additional_information.sort() object_info_names = [] object_info_descriptions = [] bullet_points = [] for (_, name, value) in additional_information: object_info_names.append(name) object_info_descriptions.append(value) bullet_point = LocalizationHelperTuning.get_name_value_pair(name, value) bullet_points.append(bullet_point) description = LocalizationHelperTuning.get_bulleted_list(None, *bullet_points) plant_name = LocalizationHelperTuning.get_object_name(self.owner.definition) else: object_info_names = None object_info_descriptions = None if GardeningTuning.is_spliced(self.owner): description = self._spliced_description plant_name = GardeningTuning.SPLICED_PLANT_NAME() else: if GardeningTuning.is_shoot(self.owner) and self.root_stock is not None: description = LocalizationHelperTuning.get_object_name(self.root_stock.main_spawner) else: description = LocalizationHelperTuning.get_object_description(self.owner.definition) plant_name = LocalizationHelperTuning.get_object_name(self.owner.definition) subtext = self.owner.get_state_strings() yield ('object_info_names', object_info_names) yield ('object_info_descriptions', object_info_descriptions) yield ('recipe_name', plant_name) yield ('recipe_description', description) if subtext is not None: yield ('subtext', subtext)
def _ui_metadata_gen(self): if GardeningTuning.is_spliced(self.owner): fruit_names = self.get_root_stock_names() description = LocalizationHelperTuning.get_comma_separated_list( *fruit_names) plant_name = GardeningTuning.SPLICED_PLANT_NAME() else: unidentified_overrides = self._unidentified_overrides if unidentified_overrides is not None and GardeningTuning.is_unidentified( self.owner): description = unidentified_overrides.unidentified_description plant_name = unidentified_overrides.unidentified_name else: if self.is_shoot and self.root_stock is not None: description = LocalizationHelperTuning.get_name_value_pair( GardeningTuning.SHOOT_DESCRIPTION_STRING, LocalizationHelperTuning.get_object_name( self.root_stock.main_spawner.definition)) else: description = LocalizationHelperTuning.get_object_description( self.owner.definition) plant_name = LocalizationHelperTuning.get_object_name( self.owner.definition) yield ('recipe_name', plant_name) yield ('recipe_description', description) subtext = self.owner.get_state_strings() if subtext is not None: yield ('subtext', subtext)
def add_aop(self, aop, user_pick_target=None, result_override=DEFAULT, do_test=True): result = ChoiceMenu.is_valid_aop(aop, self.context, self.make_pass, user_pick_target=user_pick_target, result_override=result_override, do_test=do_test) if aop.affordance.allow_user_directed is False: if _show_interaction_failure_reason: if result: failure_result = TestResult( False, tooltip=lambda *_, **__: LocalizationHelperTuning.get_name_value_pair( 'Failure', 'Not allowed user-directed')) else: failure_result = result self._add_menu_item(aop, failure_result) return result if not result and not result.tooltip: return result self._add_menu_item(aop, result) return result
def add_aop(self, aop, user_pick_target=None, result_override=DEFAULT, do_test=True): result = ChoiceMenu.is_valid_aop(aop, self.context, self.make_pass, user_pick_target=user_pick_target, result_override=result_override, do_test=do_test) if aop.affordance.allow_user_directed is False: if _show_interaction_failure_reason: if result: failure_result = TestResult(False, tooltip=lambda *_, **__: LocalizationHelperTuning.get_name_value_pair('Failure', 'Not allowed user-directed')) else: failure_result = result self._add_menu_item(aop, failure_result) return result if not result and not result.tooltip: return result self._add_menu_item(aop, result) return result
def _ui_metadata_gen(self): additional_information = self._get_additional_information() if additional_information and self.show_gardening_details(): additional_information.sort() object_info_names = [] object_info_descriptions = [] bullet_points = [] for (_, name, value) in additional_information: object_info_names.append(name) object_info_descriptions.append(value) bullet_point = LocalizationHelperTuning.get_name_value_pair( name, value) bullet_points.append(bullet_point) description = LocalizationHelperTuning.get_bulleted_list( None, *bullet_points) plant_name = LocalizationHelperTuning.get_object_name( self.owner.definition) else: object_info_names = None object_info_descriptions = None if GardeningTuning.is_spliced(self.owner): description = self._spliced_description plant_name = GardeningTuning.SPLICED_PLANT_NAME() else: if GardeningTuning.is_shoot( self.owner) and self.root_stock is not None: description = LocalizationHelperTuning.get_object_name( self.root_stock.main_spawner) else: description = LocalizationHelperTuning.get_object_description( self.owner.definition) plant_name = LocalizationHelperTuning.get_object_name( self.owner.definition) subtext = self.owner.get_state_strings() yield ('object_info_names', object_info_names) yield ('object_info_descriptions', object_info_descriptions) yield ('recipe_name', plant_name) yield ('recipe_description', description) if subtext is not None: yield ('subtext', subtext)
def is_valid_aop(aop, context, user_pick_target=None, result_override=DEFAULT, do_test=True): test_result = None result = TestResult.TRUE if result_override is not DEFAULT: result = result_override elif do_test: if user_pick_target is not None and user_pick_target.check_affordance_for_suppression(context.sim, aop, user_directed=True): result = TestResult(False, '{} failed, aop is being suppressed.', aop) else: result = aop.test(context) if gsi_handlers.sim_handlers_log.pie_menu_generation_archiver.enabled: test_result = str(result) if not result: logger.info('Test Failure: {}: {}', aop, result.reason) if not result: if _show_interaction_failure_reason: result = TestResult(result.result, tooltip=lambda *_, reason=result.reason, **__: LocalizationHelperTuning.get_name_value_pair('Failure', reason)) elif not result.tooltip: result = TestResult(False, '{} failed and has no tooltip', aop) if gsi_handlers.sim_handlers_log.pie_menu_generation_archiver.enabled: gsi_handlers.sim_handlers_log.log_aop_result(context.sim, aop, result, test_result) return result
def is_valid_aop(aop, context, make_pass, user_pick_target=None, result_override=DEFAULT, do_test=True): test_result = None result = TestResult.TRUE if result_override is not DEFAULT: result = result_override else: if not make_pass: if user_pick_target is not None and user_pick_target.check_affordance_for_suppression(context.sim, aop, user_directed=True): result = TestResult(False, '{} failed, aop is being suppressed.', aop) else: result = aop.test(context) test_result = str(result) else: result = aop.can_make_test_pass(context) if not result: logger.info('Test Failure: {}: {}', aop, result.reason) if not result: if _show_interaction_failure_reason: result = TestResult(result.result, tooltip=lambda *_, reason=result.reason, **__: LocalizationHelperTuning.get_name_value_pair('Failure', reason)) elif not result.tooltip: result = TestResult(False, '{} failed and has no tooltip', aop) if do_test and make_pass and aop.test(context): result = TestResult(False, '{} already passes', aop) if gsi_handlers.sim_handlers_log.pie_menu_generation_archiver.enabled: gsi_handlers.sim_handlers_log.log_aop_result(context.sim, aop, result, test_result) return result