Exemplo n.º 1
0
    def render_main(self):
        character = (self._character, models.Character)
        team_config = (self._team_config, models.TeamConfig)
        weapon = (self._current_weapon, models.Weapon)

        with Group("global", "全局", self._global):
            self.render_global()
        self.lazy_group(Group("character", "角色", character, cols=4),
                        self.render_character)
        self.lazy_group(Group("character_ext", "角色额外", character),
                        self.render_character_ext)
        self.lazy_group(Group("vehicle", "载具", self._global),
                        self.render_vehicle)
        self.lazy_group(Group("ammo", "弹药", self._global, cols=4),
                        self.render_ammo)
        self.lazy_group(Group("weapon", "武器", weapon, cols=4),
                        self.render_weapon)
        self.lazy_group(Group("team", "团队", team_config, cols=4),
                        self.render_team)
        self.lazy_group(
            Groups("技能", self.weak.onNotePageChange, addr=team_config),
            self.render_skill)
        self.lazy_group(Group("drop_rates", "掉落率", None),
                        self.render_drop_rates)
        self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
        self.lazy_group(
            Group("assembly_variable", "代码变量", self.variable_model),
            self.render_assembly_variable)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkeys)
Exemplo n.º 2
0
    def render_main(self):
        with Group("player", "角色", self.weak._player):
            self.render_player()

        self.lazy_group(Group("vehicle", "载具", self.weak._vehicle),
                        self.render_vehicle)
        self.lazy_group(Group("weapon", "武器槽", None), self.render_weapon)
        self.lazy_group(Group("global", "全局", 0, cols=4), self.render_global)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkey)
        self.lazy_group(StaticGroup("功能"), self.render_func)
        self.lazy_group(StaticGroup("工具"), self.render_tool)
Exemplo n.º 3
0
    def render_main(self):
        with Group("global", "全局", self._global, horizontal=False):
            self.render_global()

        self.lazy_group(Group("shop", "商店购物", self._global), self.render_shop)
        self.backpack_group = Group("store",
                                    "背包",
                                    self._global,
                                    hasheader=True,
                                    cols=4)
        self.lazy_group(self.backpack_group, self.render_backpack)
        self.pokemon_group = StaticGroup("宝可梦")
        self.lazy_group(self.pokemon_group, self.render_pokemon)
Exemplo n.º 4
0
    def render_main(self):
        with Group("player", "角色", self.weak._player):
            self.render_player()

        self.lazy_group(Group("vehicle", "载具", self.weak._vehicle),
                        self.render_vehicle)
        self.lazy_group(Group("weapon", "武器槽", None), self.render_weapon)
        self.lazy_group(Group("global", "全局", self), self.render_global)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkey)
        self.lazy_group(StaticGroup("载具模型"), self.render_vehicle_model)
        self.lazy_group(StaticGroup("功能"), self.render_func)

        with Group(None, "设置", None, hasfooter=False):
            self.render_config()
Exemplo n.º 5
0
    def render_main(self):
        with Group("player", "角色", self.weak._player):
            self.render_player()

        self.lazy_group(Group("vehicle", "载具", self.weak._vehicle),
                        self.render_vehicle)
        self.lazy_group(Group("weapon", "武器槽", None), self.render_weapon)
        self.lazy_group(Group("weapon_prop", "武器熟练度", None),
                        self.render_weapon_prop)
        self.lazy_group(Group("global", "全局", 0, cols=4), self.render_global)
        self.lazy_group(StaticGroup("作弊"), self.render_cheat)
        self.lazy_group(Group(None, "女友进度", 0), self.render_girl_friend)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkey)
        self.lazy_group(StaticGroup("功能"), self.render_func)
        self.lazy_group(StaticGroup("工具"), self.render_tool)
Exemplo n.º 6
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("growth_points", "成长点数")
            ModelInput("money_1p", "1p金钱")
            ModelInput("money_2p", "2p金钱")

        with Group("player", "我方角色", self.person, cols=4) as group:
            Choice("角色", ("1P", "2P"), self.on_person_change)

            for addr, name in models.PERSON_ATTRS:
                ModelInput(name)

        with group.footer:
            dialog_style = {'width': 1200, 'height': 900}
            with DialogGroup("items", "道具", self.itemholder, cols=4, dialog_style=dialog_style) as dialog_group:
                indexs = (0, 8, 1, 9, 2, 10, 3, 11, 4, 12, 5, 13, 6, 14, 7, 15)
                with ModelSelect.choices_cache:
                    for i in indexs:
                        ModelSelect("items.%d" % i, "道具%02d" % (i + 1), choices=datasets.ITEMS)
            with DialogGroup("skills", "技能", self.skillholder, dialog_style=dialog_style):
                values = [1 << i for i in range(7, -1, -1)]
                for i, labels in enumerate(datasets.SKILL_ITEMS):
                    ModelFlagWidget("have_%s" % (i + 1), "拥有", labels=labels, values=values, checkbtn=True, cols=4)
                    ModelFlagWidget("active_%s" % (i + 1), "激活", labels=labels, values=values, checkbtn=True, cols=4)

        with Group("enemy", "敌人", None, cols=4) as group:
            for addr, name in models.ENEMY_ATTRS:
                Input(name, None, addr, size=1)

        with StaticGroup("快捷键"):
            ui.Text("恢复HP: alt+h")
Exemplo n.º 7
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("hp")
            # ModelInput("tankhp")
            ModelCheckBox("invincible", enable=0x20, disable=0)
            ModelInput("ammo")
            ModelInput("bomb")
            ModelInput("shell")
            ModelSelect("weapon", choices=WEAPONS, values=WEAPON_VALUES)
            ModelSelect("bombtype", choices=BOMB_TYPES, values=BOMB_VALUES)

        with StaticGroup("功能"):
            self.render_functions(('max_ammo', 'fast_shoot'))

        with StaticGroup("快捷键"):
            ui.Text("恢复HP: alt+h")
Exemplo n.º 8
0
    def render_main(self):
        person = self.person
        chariot = self.chariot
        with Group("global", "全局", self._global):
            ModelInput("money", "金钱")
            ModelInput("battlein", "遇敌率")
            ModelCheckBox("battlein", "不遇敌", enable=0xFF, disable=0)

        with Group("player", "角色", person, cols=4):
            Choice("角色", datasets.PERSONS, self.on_person_change)
            ModelInput("level", "等级")
            ModelInput("hpmax", "HP上限")
            ModelInput("hp", "HP")
            ModelInput("atk", "攻击")
            ModelInput("defense", "守备")
            ModelInput("strength", "强度")
            ModelInput("intelli", "智力")
            ModelInput("stamina", "体力")
            ModelInput("speed", "速度")
            ModelInput("battle", "战斗")
            ModelInput("drive", "驾驶")
            ModelInput("fix", "修理")
            ModelInput("exp", "经验")

        self.lazy_group(Group("human_items", "角色装备/物品", person, cols=4), self.render_human_items)
        self.lazy_group(Group("chariot", "战车", chariot, cols=4), self.render_chariot)
        self.lazy_group(Group("chariot_items", "战车装备/物品", chariot, cols=4), self.render_chariot_items)

        with StaticGroup("快捷键"):
            ui.Text("左移: alt+left\n"
                "右移: alt+right\n"
                "上移: alt+up\n"
                "下移: alt+right\n"
                "恢复HP: alt+h")
Exemplo n.º 9
0
    def render_main(self):
        with Group("global", "全局", (self._global, models.Global)):
            ModelInput("energy")
            ModelInput("vigour")
            ModelInput("health")
            ModelInput("skill")
            ModelInput("atk").set_help("更换装备、升级、保存载入还原,下同")
            ModelInput("defense")
            ModelInput("critical_buff")
            ModelInput("critical")
            ModelInput("attr_wood")
            ModelInput("attr_fire")
            ModelInput("attr_earth")
            ModelInput("attr_metal")
            ModelInput("attr_water")
        self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)

        # with Group("movement", "移动", (self._movement, models.Movement)):
        #     ModelInput("air_time")
        #     ModelInput("jump_height")
        #     ModelInput("move_speed_mult")
        #     ModelCoordWidget('coord', savable=True)

        with Group("movement", "变量", self.variable_model):
            ModelInput("jump_height", "跳跃高度")
Exemplo n.º 10
0
    def render_main(self):
        person = (self._person, models.Character)

        with Group("player", "全局", self._global):
            ModelInput("money.money", "金钱")

        with Group("player", "角色", person):
            Choice("角色", tuple("play%d" % i for i in range(1, 5)),
                   self.weak.on_person_change)
            ModelInput("health")
            ModelInput("health_max")
            ModelCoordWidget("coord",
                             labels=('X坐标', 'Z坐标', 'Y坐标'),
                             savable=True)
            ModelCheckBox("invincible")

        self.lazy_group(
            Group("person_items", "角色物品", person, serializable=False, cols=4),
            self.render_person_items)
        self.lazy_group(
            Group("saved_items",
                  "整理界面物品",
                  self._saved_items,
                  serializable=False,
                  cols=6), self.render_saved_items)
        # self.lazy_group(StaticGroup("物品箱/宝物箱"), self.render_inventory_treasure_items)
        self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
Exemplo n.º 11
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("time", "时间")
            ModelInput("money", "金钱")
            ModelInput("get_money", "战后金钱")
            ModelInput("get_exp", "战后经验")
            ModelInput("battlein", "遇敌率")
            ModelCoordWidget("town_pos",
                             "城镇坐标",
                             length=2,
                             type=int,
                             savable=True,
                             preset=self.coords)
            ModelCoordWidget("map_pos",
                             "地图坐标",
                             length=2,
                             type=int,
                             savable=True,
                             preset=self.coords)

        self.lazy_group(Group("player", "角色", self.person, cols=4),
                        self.render_person)
        self.skills_group = Group("skills", "角色精神力", self.person)
        self.lazy_group(self.skills_group, self.render_skills)
        self.lazy_group(Group("skills", "角色物品", self.person, cols=4),
                        self.render_items)
        self.lazy_group(Group("djinnis", "角色精灵", self.person),
                        self.render_djinnis)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkeys)
Exemplo n.º 12
0
    def render_main(self):
        datasets = self.datasets
        weak = self.weak

        with Group("global", "全局", self._global, cols=4):
            ModelInput("money")
            ModelInput("stamp")
            self.render_global_ext()

        self.lazy_group(Group("person", "角色", self.person, cols=4),
                        self.render_person)
        self.lazy_group(Group("person_ext", "角色额外", self.person, cols=4),
                        self.render_person_ext)
        self.lazy_group(Group("chariot", "战车", self.chariot, cols=4),
                        self.render_chariot)
        self.lazy_group(
            Group("chariot_items",
                  "战车物品/装备",
                  self.chariot,
                  cols=2 if self.has_holes else 4), self.render_chariot_items)
        self.lazy_group(Group("chariot_special_bullets", "特殊炮弹", self.chariot),
                        self.render_chariot_special_bullets)
        self.lazy_group(Group("battle_status", "战斗状态", self._global, cols=4),
                        self.render_battle_status)
        self.lazy_group(Group("enemy", "敌人", self.enemy, cols=4),
                        self.render_enemy)
        self.lazy_group(Groups("包裹", self.weak.onNotePageChange),
                        self.render_package_group)
        self.render_ext()

        with StaticGroup("功能"):
            self.render_functions(('enemy_weak', ))
Exemplo n.º 13
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("money", "金钱")
            ModelInput("exp", "驾驶员经验")

        with Group("player", "我方角色", self.person, cols=4):
            Choice("角色", datasets.PARTNERS, self.on_person_change)
            ModelInput("ability", "机体类型(海陆空)及变身能力")
            ModelInput("spiritual_type", "精神类型")
            ModelSelect("robot", "机体图", choices=datasets.ROBOTS)
            ModelInput("map_y", "地图X坐标")
            ModelInput("map_x", "地图Y坐标")
            ModelInput("map_avatar", "地图头像")
            ModelSelect("weapon_1", "上武器", choices=datasets.WEAPONS)
            ModelSelect("weapon_2", "下武器", choices=datasets.WEAPONS)
            ModelInput("mobile", "机动")
            ModelInput("strength", "强度")
            ModelInput("defense", "防卫")
            ModelInput("speed", "速度")
            ModelInput("hp", "HP")
            ModelInput("hpmax", "HP上限")
            ModelInput("move", "行动次数")
            ModelInput("spiritual", "精神")
            ModelInput("spiritual_max", "精神上限")

        self.lazy_group(Group("items", "道具", None), self.render_items)
        # self.lazy_group(Group("weapons", "武器", self.weapon), self.render_weapons)

        # with Group("enemy", "敌人", None, cols=4):
        #     for addr, name in models.ENEMY_ATTRS:
        #         Input(name, None, addr, size=1)

        with StaticGroup("快捷键"):
            ui.Text("恢复HP: alt+h")
Exemplo n.º 14
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("turn").set_help('0~1,下面会一直累加(慎用)')
            ModelInput("minutes")
            ModelInput("seconds_1")
            ModelInput("seconds_0")
            ModelInput("our_points")
            ModelInput("enemy_points")
            ModelInput("basketry_left_top")
            ModelInput("basketry_left_middle")
            ModelInput("basketry_left_bottom")
            ModelInput("basketry_right_top")
            ModelInput("basketry_right_middle")
            ModelInput("basketry_right_bottom")
            ModelInput("ball_owner").set_help('球在人手里(0~3),地上或空中(6)')

        with Group("player", "我方角色", self.person) as group:
            Choice("角色", ("1P", "2P", "3P", "4P"), self.on_person_change)

            # ModelInput("jump")
            # ModelInput("power")
            ModelInput("character").set_help('0~3')
            with ModelSelect.choices_cache:
                ModelSelect("equip_1", instance=self.equip_holder, choices=datasets.ITEMS)
                ModelSelect("equip_2", instance=self.equip_holder, choices=datasets.ITEMS)
                ModelSelect("equip_3", instance=self.equip_holder, choices=datasets.ITEMS)

        with StaticGroup("快捷键"):
            ui.Text("B: 获得球")
            ui.Text("N: 左边耐久置0")
            ui.Text("M: 球筐耐久恢复")
Exemplo n.º 15
0
    def render_main(self):
        with Group("global", "全局", self._global):
            self.render_global()
        self.lazy_group(Group("person", "角色", self.person, cols=4),
                        self.render_person)
        self.lazy_group(Group("favors", "好感度", self._global),
                        self.render_favors)
        self.lazy_group(Group("items", "道具", self._global, cols=4),
                        self.render_items)
        self.lazy_group(Group("event_items", "事件道具", self._global),
                        self.render_event_items)
        self.lazy_group(Group("person_battles", "战斗中", self._global, cols=4),
                        self.render_person_battles)
        self.lazy_group(StaticGroup("功能"), self.render_functions)

        with StaticGroup("快捷键"):
            ui.Text("恢复HP: alt+h")
Exemplo n.º 16
0
    def render_main(self):
        self._global = Global(0, self.handler)

        with Group("global", "全局", self._global):
            ModelInput("hp", "HP")
            ModelInput("hpmax", "最大HP")
            ModelCheckBox("invincible", "无敌", enable=0xFF, disable=0)
            ModelSelect("dragon", "当前龙", choices=DRAGONS)

        with StaticGroup("功能"):
            self.render_functions(('hp_max', 'all_dragons', 'all_tools'))
Exemplo n.º 17
0
    def render_main(self):
        person = (self._person, models.Character)

        with Group("player", "全局", self._global):
            ModelInput("skill_points", instance=(self._skill_points, models.SkillPoints))

        with Group("player", "角色", person):
            self.char_choice = Choice("角色", datasets.PERSONS, self.weak.on_person_change)
            ModelInput("health")
            ModelInput("health_max")
            ModelInput("stamina")
            ModelInput("stamina_max")
            ModelInput("moving_speed")
            ModelInput("rapid_fire")
            ModelInput("is_wet")
            ModelCoordWidget("coord", labels=('X坐标', 'Z坐标', 'Y坐标'), savable=True)
            ModelCheckBox("invincible")

        self.lazy_group(Group("person_items", "角色物品", person, serializable=False, cols=4), self.render_person_items)
        self.lazy_group(Group("person_skills", "角色技能", self._global, cols=4), self.render_person_skills)
        self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
        self.lazy_group(StaticGroup("功能"), self.render_functions)
Exemplo n.º 18
0
    def render_main(self):
        character = (self._character, models.Character)
        weapon = (self._current_weapon, models.Weapon)

        with Group("global", "全局", self._global):
            self.render_global()
        self.lazy_group(Group("character", "角色", character, cols=4),
                        self.render_character)
        self.lazy_group(Group("character_ext", "角色额外", character),
                        self.render_character_ext)
        self.lazy_group(Group("vehicle", "载具", self._global),
                        self.render_vehicle)
        self.lazy_group(Group("ammo", "弹药", character, cols=4),
                        self.render_ammo)
        self.lazy_group(Group("weapon_prof", "武器熟练度", self._global, cols=4),
                        self.render_weapon_prof)
        self.lazy_group(Group("weapon", "武器", weapon, cols=4),
                        self.render_weapon)
        self.lazy_group(Group("drop_rates", "掉落率", None),
                        self.render_drop_rates)
        self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkeys)
Exemplo n.º 19
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("money")
            ModelInput("turn")
            ModelInput("after_money")
            ModelInput("after_exp")
            ModelSelect("chapter", choices=datasets.CHAPTERS)

        with Group("robot", "机体", self.robot, cols=4):
            self.render_robot()

        with Group("pilot", "机师", self.pilot, cols=4):
            self.render_pilot()

        with StaticGroup("功能"):
            self.render_functions(('all_intensified_parts', 'all_mini_games',
                                   'all_skill_chip', 'all_move_10'))
Exemplo n.º 20
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelSelect("enemy", "角色", choices=datasets.PLAYERS)
            ModelSelect("enemy",
                        "敌人模型",
                        choices=datasets.ENEMY_LABELS,
                        values=datasets.ENEMY_VALUES)
            ModelInput("level", "等级")
            ModelInput("lives", "命数")
            ModelInput("hp", "HP")
            ModelInput("exp", "总经验")
            ModelInput("tool_count", "手持物数量")
            ModelInput("play_level", "关卡")
            ModelCheckBox("invincible", "无伤", enable=0xffff, disable=0)

        with StaticGroup("快捷键"):
            ui.Text("恢复HP: alt+h\n" "敌人一击必杀: alt+空格")
Exemplo n.º 21
0
    def render_main(self):
        with Group("player", "角色", self._global):
            ModelInput("level", "等级(1+)")
            ModelInput("hp", "生命")
            ModelInput("max_hp", "最大生命")
            ModelInput("money", "金钱")
            ModelInput("power", "力")
            ModelInput("stamina", "体力")
            ModelInput("energy", "气力")
            ModelInput("soul", "魂")
            ModelInput("exp", "经验")

        for group in datasets.LISTS:
            if group['hascount']:
                self.count_data[group['name']] = [0] * len(group['items'])

            self.lazy_group(StaticGroup(group['caption']),
                            partial(self.render_one_list, group))
Exemplo n.º 22
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("hp")
            ModelInput("hpmax")
            ModelInput("lives")
            ModelInput("limit_time")
            ModelInput("money")
            ModelInput("weapon_level_1")
            ModelInput("weapon_level_2")
            ModelInput("weapon_level_3")
            ModelInput("weapon_level_4")
            ModelSelect("level", choices=LEVELS)
            ModelFlagWidget("weapon_flag", labels=WEAPONS)
            ModelCheckBox("invincible", enable=0xFF, disable=0)

        with StaticGroup("功能"):
            self.render_functions(
                ('max_weapon_level', 'all_weapon', 'all_element', 'all_fairy',
                 'fairy_use_count_infinite'))
Exemplo n.º 23
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("money")
            ModelInput("battlein")

        with Group("player", "角色", self.person, cols=4):
            self.render_player()

        self.lazy_group(Group("human_items", "角色装备/物品", self.person),
                        self.render_human_items)
        self.lazy_group(Group("chariot", "战车", self.chariot, cols=4),
                        self.render_chariot)
        self.lazy_group(Group("chariot_items", "战车装备/物品", self.chariot),
                        self.render_chariot_items)
        self.lazy_group(Group("special_bullets", "特殊炮弹", self.chariot, cols=4),
                        self.render_special_bullets)
        self.storage_group = Group("storage", "保管物品", self._global)
        self.lazy_group(self.storage_group, self.render_storage)
        self.lazy_group(StaticGroup("快捷键"), self.render_hotkeys)
Exemplo n.º 24
0
    def render_main(self):
        with Group("global", "全局", self._global):
            ModelInput("hp")
            ModelInput("hpmax")
            ModelInput("mp")
            ModelInput("mpmax")
            ModelInput("str")
            ModelInput("con")
            ModelInput("int")
            ModelInput("lck")
            ModelInput("level")
            ModelCheckBox("invincible1")
            ModelCheckBox("enemy_static")
            ModelCheckBox("invincible2")

        with StaticGroup("功能"):
            self.render_functions(
                ('set_monster_flag', 'set_skill_flag', 'set_soul_flag',
                 'set_equip_counts', 'set_tool_counts', 'set_enemy_flag',
                 'set_map_flag', 'set_extra_flag', 'set_boss_rush_flag'))
Exemplo n.º 25
0
 def render_main(self):
     # with Group("global", "全局", self._global):
     #     pass
     self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
Exemplo n.º 26
0
 def render_main(self):
     with Group("player", "全局", None):
         self.render_global()
     self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
     self.lazy_group(StaticGroup("快捷键"), self.render_hotkeys)
Exemplo n.º 27
0
 def render_main(self):
     Group("player", "全局", None)
     self.lazy_group(StaticGroup("代码插入"), self.render_assembly_functions)
Exemplo n.º 28
0
class PMHack(BaseGbaHack):
    BACKPACK_PAGE_LENGTH = 10

    def __init__(self):
        super().__init__()
        self._global_ins = None
        self._pokemon_ins = models.Pokemon(0, self.handler)
        self.active_pokemon_index = 0
        self.active_pokemon_ins = None

    def render_main(self):
        with Group("global", "全局", self._global, horizontal=False):
            self.render_global()

        self.lazy_group(Group("shop", "商店购物", self._global), self.render_shop)
        self.backpack_group = Group("store",
                                    "背包",
                                    self._global,
                                    hasheader=True,
                                    cols=4)
        self.lazy_group(self.backpack_group, self.render_backpack)
        self.pokemon_group = StaticGroup("宝可梦")
        self.lazy_group(self.pokemon_group, self.render_pokemon)

    def render_global(self):
        datasets = self.datasets

        ModelInput("money", "金钱", spin=True)
        ModelInput("coin", "游戏币", spin=True)
        ModelInput("dust", "宝石版火山灰", spin=True)
        ModelInput("spray_time", "喷雾剂剩余步数", spin=True)
        ModelInput("safari_time", "狩猎区剩余步数", spin=True)
        ModelInput("battle_points_current", "战斗点数(仅绿宝石)", spin=True)
        ModelInput("battle_points_trainer_card", "训练员卡上的战斗点数(仅绿宝石)", spin=True)

        ModelSelect("area",
                    "地点瞬移",
                    choices=datasets.AREA_LABELS,
                    values=datasets.AREA_VALUES)
        ModelSelect("furniture_purchase", "家具购买", choices=datasets.FURNITURES)
        ModelSelect("appearance", "性别外形", choices=datasets.APPEARANCE)
        # ModelSelect("wild_pokemon", "遇到精灵", choices=datasets.POKEMONS)

    def render_shop(self):
        datasets = self.datasets
        with ModelSelect.choices_cache:
            for i in range(8):
                ModelSelect("store.%d.item" % i,
                            "商品%d" % (i + 1),
                            choices=datasets.ITEMS)

    def render_backpack(self):
        datasets = self.datasets
        with self.backpack_group.header:
            ui.RadioBox("类型",
                        className="fill",
                        choices=datasets.BACKPACK_LABELS,
                        onselect=self.on_backpack_swith)
        for i in range(self.BACKPACK_PAGE_LENGTH):
            ModelSelect("backpack_items.%d+backpack_offset.item" % i,
                        "",
                        choices=datasets.ITEMS)
            ModelInput("backpack_items.%d+backpack_offset.quantity" % i, "数量")
        with self.backpack_group.footer:
            self.backpack_pageview = Pagination(self.on_backpack_page,
                                                self.BACKPACK_PAGE_LENGTH)

    def render_pokemon(self):
        # pokemon = self.weak._pokemon
        active_pokemon = self._active_pokemon

        ui.RadioBox("带着的宝可梦",
                    className="expand",
                    choices=tuple(str(i) for i in range(1, 7)),
                    onselect=self.on_active_pokemo_swith)

        with Groups(None, self.weak.onNotePageChange):
            with Group("basic", "基本", active_pokemon):
                ModelInput("breedInfo.bIntimate", "亲密度", spin=True, max=255)
                ModelSelect("breedInfo.wBreed",
                            "种族",
                            choices=self.datasets.BREED_NAMES)
                ModelInput("Header.dwChar", "性格值", hex=True)
                ModelInput("Header.dwID", "ID", hex=True)
                ModelSelect("personality",
                            "性格",
                            choices=self.datasets.PERSONALITYS,
                            onselect=self.on_personality_select)
                ui.Text("性格描述", className="vcenter")
                self.personality_desc = ui.Text("", className="vcenter")
                ModelSelect("breedInfo.wItem",
                            "手持道具",
                            choices=self.datasets.ITEMS)
                ModelInput("breedInfo.dwExp", "经验值")
            with Group("basic", "能力", active_pokemon):
                pass
            with Group("basic", "技能", active_pokemon):
                pass
            with Group("basic", "缎带", active_pokemon):
                pass
            with Group("basic", "其它", active_pokemon):
                pass

        with ui.Horizontal(className="expand"):
            ui.Button("读入",
                      className="btn_sm",
                      onclick=self.read_active_pokemon)
            ui.Button("写回",
                      className="btn_sm",
                      onclick=self.write_active_pokemon)

    def onattach(self):
        super().onattach()
        rom_title = self.handler.getRomTitle()

        item = models.GAME_VERSON.get(rom_title, None)
        if item is None and rom_title == "YJencrypted":
            szGameVersion = self.handler.read(0x08000108, bytes, 32).decode()
            item = models.GAME_ENCRYPTED.get(szGameVersion, None)

        if item:
            self._global_ins = item[0](0, self.handler)
            self.pm_version = item[1]
            self.lang = item[2]
            # 初始化一些背包参数
            self._global_ins.backpack_offset = 0

    def _global(self):
        return self._global_ins

    def read_active_pokemons(self):
        pokemons = self._global_ins.active_pokemon.tolocal()
        for pokemon in pokemons.content:
            pokemon.pmStruct.attach()
            pokemon.pmStruct.Decode()
        return pokemons

    def read_active_pokemon(self, _=None):
        active_pokemon = self._global_ins.active_pokemon.content[
            self.active_pokemon_index]
        self.active_pokemon_ins = pokemon = active_pokemon.pmStruct.tolocal()
        pokemon.attach()
        pokemon.Decode()
        return pokemon

    def write_active_pokemon(self, _=None):
        pokemon = self.active_pokemon_ins
        if pokemon:
            temp = pokemon.tolocal()
            temp.bEncoded = False
            temp.Encode()
            self._global_ins.active_pokemon.content[
                self.active_pokemon_index].pmStruct = temp

    def _active_pokemon(self):
        return self.active_pokemon_ins or self.read_active_pokemon()

    def _active_pokemon_breed(self):
        """选中的宝可梦的种族数据"""
        pokemon = self._active_pokemon()
        if pokemon:
            breed = pokemon.breedInfo.wBreed
            if breed < BREED_COUNT:
                return self._global_ins.breed_list[breed]

    def _active_pokemon_exp_list(self):
        """选中的宝可梦的种族EXP列表"""
        breed_entry = self._active_pokemon_breed()
        if breed_entry:
            exptype = breed_entry.bExpType
            return self._global_ins.exp_list[exptype]

    # pokemon = property(_pokemon)
    # active_pokemons = property(_active_pokemons)

    def on_backpack_page(self, page):
        """背包物品切换页"""
        self._global_ins.backpack_offset = (page -
                                            1) * self.BACKPACK_PAGE_LENGTH
        self.backpack_group.read()

    def on_backpack_swith(self, view):
        self._global_ins.backpack_type = self.datasets.BACKPACK_KEYS[
            view.index]
        self.backpack_pageview.asset_total(
            self._global_ins.backpack_items.length, self.BACKPACK_PAGE_LENGTH)
        self.backpack_group.read()

    def on_active_pokemo_swith(self, view):
        self.active_pokemon_index = view.index
        self.read_active_pokemon()
        self.pokemon_group.read()

    def on_personality_select(self, view):
        personality = view.index
        b = [1, 1, 1, 1, 1]
        b[personality // 5] += 1
        b[personality % 5] -= 1
        sz = ("-", " ", "+")
        desc = "攻击:{}防御:{}敏捷:{}特攻:{}特防:{}".format(*(sz[i] for i in b))
        self.personality_desc.label = desc