def _on_yes_selected(_: Any):
            from sims4controlmenu.dialogs.modify_sim_data.modify_skills.operations.set_skill_level import \
                S4CMSetSkillLevelsSimOp
            skill_manager = CommonResourceUtils.get_instance_manager(Types.STATISTIC)
            sim = CommonSimUtils.get_sim_instance(sim_info)
            for skill in skill_manager.get_ordered_types(only_subclasses_of=Skill):
                skill: Skill = skill
                if not S4CMSetSkillLevelsSimOp()._is_skill_allowed_for_modification(sim_info, skill):
                    continue
                if not skill.can_add(sim):
                    self.verbose_log.format_with_message('Failed, Skill is not allowed for Sim.', skill=skill, sim=sim_info)
                    continue
                skill_levels = tuple(range(0, skill.max_level + 1))
                chosen_skill_level = random.choice(skill_levels)
                if chosen_skill_level == 0:
                    if CommonSimSkillUtils.has_skill(sim_info, skill):
                        CommonSimSkillUtils.remove_skill(sim_info, skill)
                else:
                    CommonSimSkillUtils.set_current_skill_level(sim_info, skill, int(chosen_skill_level))

            CommonBasicNotification(
                S4CMSimModifySkillsStringId.RANDOMIZED_SKILL_LEVELS_OF_SIM_TITLE,
                S4CMSimModifySkillsStringId.RANDOMIZED_SKILL_LEVELS_OF_SIM_DESCRIPTION,
                title_tokens=(sim,),
                description_tokens=(sim,)
            ).show(icon=IconInfoData(obj_instance=sim))
            _on_close()
        def _on_yes_selected(_: Any):
            skill_manager = CommonResourceUtils.get_instance_manager(
                Types.STATISTIC)
            sim = CommonSimUtils.get_sim_instance(sim_info)
            for skill in skill_manager.get_ordered_types(
                    only_subclasses_of=Skill):
                skill: Skill = skill
                if not CommonSimSkillUtils.has_skill(sim_info, skill):
                    continue
                CommonSimSkillUtils.remove_skill(sim_info, skill)

            CommonBasicNotification(
                S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_TITLE,
                S4CMSimModifySkillsStringId.REMOVED_ALL_SKILLS_DESCRIPTION,
                title_tokens=(sim, ),
                description_tokens=(sim, )).show(icon=IconInfoData(
                    obj_instance=sim))
            _on_close()
    def run(
        self,
        sim_info: SimInfo,
        on_completed: Callable[[bool],
                               None] = CommonFunctionUtils.noop) -> bool:
        def _reopen() -> None:
            self.run(sim_info, on_completed=on_completed)

        def _on_close() -> None:
            on_completed(False)

        option_dialog = CommonChooseObjectOptionDialog(
            S4CMSimModifySkillsStringId.SET_SKILL_LEVELS,
            0,
            on_close=_on_close,
            mod_identity=self.mod_identity,
            per_page=20000)

        def _on_input_setting_changed(_skill: Skill, new_skill_level: int,
                                      outcome: CommonChoiceOutcome):
            if new_skill_level is None or CommonChoiceOutcome.is_error_or_cancel(
                    outcome):
                _reopen()
                return
            self.log.format_with_message('Setting skill level for Sim.',
                                         _skill=_skill,
                                         new_skill_level=new_skill_level)
            CommonSimSkillUtils.set_current_skill_level(
                sim_info, _skill, new_skill_level)
            if new_skill_level == 0:
                CommonSimSkillUtils.remove_skill(sim_info, _skill)
            _reopen()

        skill_manager = CommonResourceUtils.get_instance_manager(
            Types.STATISTIC)
        sim = CommonSimUtils.get_sim_instance(sim_info)
        for skill in skill_manager.get_ordered_types(only_subclasses_of=Skill):
            skill: Skill = skill
            skill_id = CommonSkillUtils.get_skill_id(skill)
            if skill_id is None:
                self.log.format_with_message('Missing skill id for Skill.',
                                             skill=skill)
                continue
            try:
                self.verbose_log.format_with_message(
                    'Attempting to display skill',
                    skill=skill,
                    skill_id=skill_id,
                    sim=sim_info)
                if not skill.can_add(sim):
                    self.verbose_log.format_with_message(
                        'Failed, Skill is not allowed for Sim.',
                        skill=skill,
                        skill_id=skill_id,
                        sim=sim_info)
                    continue
                if not CommonSimSkillUtils.has_skill(sim_info, skill_id):
                    current_skill_level = 0
                else:
                    current_skill_level = int(
                        CommonSimSkillUtils.get_current_skill_level(
                            sim_info,
                            skill_id,
                            use_effective_skill_level=False))
                stat_name = getattr(skill, 'stat_name', None)
                # noinspection PyUnresolvedReferences
                if stat_name and skill.stat_name.hash is not 0:
                    # noinspection PyUnresolvedReferences
                    display_name = skill.stat_name
                else:
                    skill_name = skill.__name__ or 'Unknown Skill Name'
                    skill_name = skill_name[0].upper() + skill_name[1:]
                    display_name = LocalizationHelperTuning.get_raw_text(
                        skill_name)

                # noinspection PyUnresolvedReferences
                if skill.hidden:
                    display_name = CommonLocalizationUtils.create_localized_string(
                        S4CMSimControlMenuStringId.STRING_SPACE_PAREN_STRING,
                        tokens=(display_name,
                                S4CMSimControlMenuStringId.HIDDEN))

                display_name = CommonLocalizationUtils.create_localized_string(
                    S4CMSimControlMenuStringId.STRING_COLON_SPACE_STRING,
                    tokens=(display_name, str(current_skill_level)))
                # noinspection PyUnresolvedReferences
                description = CommonLocalizationUtils.create_localized_string(
                    skill.skill_description, tokens=(sim_info, ))
                # noinspection PyUnresolvedReferences
                icon = skill.icon or CommonIconUtils.load_question_mark_icon()
                # MISSING ICON Identifier
                _MISSING_IMAGE_ICON_ID = 3526464109639239417
                if icon.instance == 0 or icon.instance == _MISSING_IMAGE_ICON_ID:
                    icon = CommonIconUtils.load_question_mark_icon()
                option_dialog.add_option(
                    CommonDialogInputIntegerOption(
                        self.mod_identity,
                        skill,
                        current_skill_level,
                        CommonDialogOptionContext(
                            display_name,
                            description,
                            icon=icon,
                            is_enabled=self._is_skill_allowed_for_modification(
                                sim_info, skill)),
                        dialog_description_identifier=S4CMSimModifySkillsStringId
                        .ENTER_A_VALE_BETWEEN_MIN_AND_MAX_FOR_SKILL,
                        dialog_description_tokens=(str(0),
                                                   str(int(skill.max_level)),
                                                   str(current_skill_level)),
                        min_value=0,
                        max_value=int(skill.max_level),
                        on_chosen=_on_input_setting_changed))
            except Exception as ex:
                self.log.format_error_with_message('Failed to display skill.',
                                                   skill=skill,
                                                   skill_name=skill.__name__,
                                                   skill_id=skill_id,
                                                   exception=ex)

        if not option_dialog.has_options():
            self.log.format_with_message('No skills available for the Sim!')
            on_completed(False)
            return False
        option_dialog.show(sim_info=sim_info, sort_options=True)
        return True