예제 #1
0
파일: iq.py 프로젝트: SkyTemple/skytemple
    def on_cr_other_iq_gain_edited(self, widget, path, text):
        store: Gtk.ListStore = self.builder.get_object('iq_gain_other_items')
        static_data = self.module.project.get_rom_module().get_static_data()
        try:
            val = u8_checked(int(text))
        except ValueError:
            return
        typ: IqGainOtherItem = store[path][0]
        store[path][2] = text

        if typ == IqGainOtherItem.NECTAR:
            self.module.project.modify_binary(
                BinaryName.OVERLAY_29, lambda bin: HardcodedIq.set_nectar_gain(val, bin, static_data)
            )
            self.module.mark_iq_as_modified()
        elif typ == IqGainOtherItem.WONDER_GUMMI:
            self.module.project.modify_binary(
                BinaryName.ARM9, lambda bin: HardcodedIq.set_wonder_gummi_gain(val, bin, static_data)
            )
            self.module.mark_iq_as_modified()
        elif typ == IqGainOtherItem.JUICE_BAR_NECTAR:
            self.module.project.modify_binary(
                BinaryName.ARM9, lambda bin: HardcodedIq.set_juice_bar_nectar_gain(val, bin, static_data)
            )
            self.module.mark_iq_as_modified()
예제 #2
0
파일: iq.py 프로젝트: SkyTemple/skytemple
    def _init_misc_settings(self):
        arm9 = self.module.project.get_binary(BinaryName.ARM9)
        ov10 = self.module.project.get_binary(BinaryName.OVERLAY_10)
        static_data = self.module.project.get_rom_module().get_static_data()

        self.builder.get_object('entry_min_iq_exclusive_move_user').set_text(str(HardcodedIq.get_min_iq_for_exclusive_move_user(arm9, static_data)))
        self.builder.get_object('entry_min_iq_item_master').set_text(str(HardcodedIq.get_min_iq_for_item_master(arm9, static_data)))
        self.builder.get_object('intimidator_activation_chance').set_text(str(HardcodedIq.get_intimidator_chance(ov10, static_data)))
예제 #3
0
파일: iq.py 프로젝트: SkyTemple/skytemple
 def on_intimidator_activation_chance_changed(self, widget, *args):
     try:
         val = u16_checked(int(widget.get_text()))
     except ValueError:
         return
     static_data = self.module.project.get_rom_module().get_static_data()
     self.module.project.modify_binary(BinaryName.OVERLAY_10, lambda bin: HardcodedIq.set_intimidator_chance(val, bin, static_data))
     self.module.mark_misc_settings_as_modified()
예제 #4
0
파일: iq.py 프로젝트: SkyTemple/skytemple
 def on_entry_min_iq_item_master_changed(self, widget, *args):
     try:
         val = u16_checked(int(widget.get_text()))
     except ValueError:
         return
     static_data = self.module.project.get_rom_module().get_static_data()
     self.module.project.modify_binary(BinaryName.ARM9, lambda bin: HardcodedIq.set_min_iq_for_item_master(val, bin, static_data))
     self.module.mark_iq_as_modified()
예제 #5
0
파일: iq.py 프로젝트: SkyTemple/skytemple
    def on_cr_iq_restrictions_edited(self, widget, path, text):
        store: Gtk.ListStore = self.builder.get_object('tree_iq_skills').get_model()
        try:
            val = i16_checked(int(text))
        except ValueError:
            return
        store[path][3] = text

        arm9 = self.module.project.get_binary(BinaryName.ARM9)
        static_data = self.module.project.get_rom_module().get_static_data()
        iq_skills = HardcodedIq.get_iq_skills(arm9, static_data)
        iq_skills[int(store[path][0])].restriction_group = val
        self.module.project.modify_binary(
            BinaryName.ARM9, lambda bin: HardcodedIq.set_iq_skills(iq_skills, bin, static_data)
        )

        self.module.mark_iq_as_modified()
예제 #6
0
파일: iq.py 프로젝트: SkyTemple/skytemple
    def on_cr_belly_heal_edited(self, widget, path, text, *, type_id):
        store: Gtk.ListStore = self.builder.get_object('tree_belly_gain').get_model()
        try:
            val = u8_checked(int(text))
        except ValueError:
            return
        store[path][type_id + 2] = text
        gummi_id = store[path][0]

        arm9 = self.module.project.get_binary(BinaryName.ARM9)
        patch_applied = self.module.project.is_patch_applied("AddTypes")
        static_data = self.module.project.get_rom_module().get_static_data()
        gains = HardcodedIq.get_gummi_belly_heal(arm9, static_data, patch_applied)
        gains[type_id][gummi_id] = val
        self.module.project.modify_binary(
            BinaryName.ARM9, lambda bin: HardcodedIq.set_gummi_belly_heal(gains, bin, static_data, patch_applied)
        )

        self.module.mark_iq_as_modified()
예제 #7
0
    def _init_iq_skills(self):
        arm9 = self.module.project.get_binary(BinaryName.ARM9)
        static_data = self.module.project.get_rom_module().get_static_data()
        iq_skills = HardcodedIq.get_iq_skills(arm9, static_data)
        if self.module.project.is_patch_applied(PATCH_IQ_SKILL_GROUPS):
            restrictions = IqGroupsSkills.read_compressed(arm9, static_data)
        else:
            restrictions = IqGroupsSkills.read_uncompressed(arm9, static_data)
        assert len(restrictions) == len(IQGroup)
        # Ignore invalid
        restrictions.pop()

        # noinspection PyTypeChecker
        store: Gtk.ListStore = Gtk.ListStore(*([str, str, str, str] + [bool] *
                                               (len(IQGroup) - 1)))
        tree: Gtk.TreeView = self.builder.get_object('tree_iq_skills')
        tree.set_model(store)

        for i, skill in enumerate(iq_skills):
            if i == 0:
                # Add columns and cell renderers for IQ groups
                for entry_i, entry in enumerate(IQGroup):
                    if entry == IQGroup.INVALID:
                        continue
                    renderer: Gtk.CellRendererToggle = Gtk.CellRendererToggle(
                        activatable=self.module.project.is_patch_applied(
                            PATCH_IQ_SKILL_GROUPS))
                    renderer.connect(
                        'toggled',
                        partial(self.on_cr_skill_to_group, group_id=entry_i))
                    column = Gtk.TreeViewColumn(title=entry.print_name,
                                                cell_renderer=renderer,
                                                active=entry_i + 4)
                    tree.append_column(column)
                continue

            iq_group_assignments = []
            for group in restrictions:
                iq_group_assignments.append(i in group)

            # noinspection PyTypeChecker
            store.append([
                str(i),
                self._string_provider.get_value(StringType.IQ_SKILL_NAMES, i -
                                                1),
                str(skill.iq_required),
                str(skill.restriction_group)
            ] + iq_group_assignments)
예제 #8
0
파일: iq.py 프로젝트: SkyTemple/skytemple
    def _init_iq_gains(self):
        """
        Store format:
        - int: id
        - str: gummi name
        For each gummi:
        - str: (type name)
        Tree is the same layout. Name column already exists.
        """
        arm9 = self.module.project.get_binary(BinaryName.ARM9)
        ov29 = self.module.project.get_binary(BinaryName.OVERLAY_29)
        static_data = self.module.project.get_rom_module().get_static_data()
        patch_applied = self.module.project.is_patch_applied("AddTypes")
        type_strings = self._string_provider.get_all(StringType.TYPE_NAMES)
        gummi_iq_gain_table = HardcodedIq.get_gummi_iq_gains(arm9, static_data, patch_applied)
        gummi_belly_gain_table = HardcodedIq.get_gummi_belly_heal(arm9, static_data, patch_applied)
        num_types = min(len(gummi_iq_gain_table), len(type_strings))

        # Normal Gummis
        store: Gtk.ListStore = Gtk.ListStore(*([int, str] + [str] * num_types))
        tree: Gtk.TreeView = self.builder.get_object('tree_iq_gain')
        store_belly: Gtk.ListStore = Gtk.ListStore(*([int, str] + [str] * num_types))
        tree_belly: Gtk.TreeView = self.builder.get_object('tree_belly_gain')
        tree.set_model(store)
        tree_belly.set_model(store_belly)
        for i in range(0, num_types):
            if i == 0:
                continue
            gummi_item_id = FIRST_GUMMI_ITEM_ID + i - 1
            if i == 18:
                gummi_item_id = FAIRY_GUMMI_ITEM_ID
            gummi_name = self._string_provider.get_value(StringType.ITEM_NAMES, gummi_item_id)
            data = [i, gummi_name]
            data_belly = [i, gummi_name]
            for j in range(0, num_types):
                data.append(str(gummi_iq_gain_table[j][i]))
                data_belly.append(str(gummi_belly_gain_table[j][i]))
            store.append(data)
            store_belly.append(data_belly)

            # column and cell renderer
            renderer: Gtk.CellRendererText = Gtk.CellRendererText(editable=True)
            renderer.connect('edited', partial(self.on_cr_iq_gain_edited, type_id=i))
            column = Gtk.TreeViewColumn(title=type_strings[i], cell_renderer=renderer, text=i + 2)
            tree.append_column(column)
            renderer = Gtk.CellRendererText(editable=True)
            renderer.connect('edited', partial(self.on_cr_belly_heal_edited, type_id=i))
            column = Gtk.TreeViewColumn(title=type_strings[i], cell_renderer=renderer, text=i + 2)
            tree_belly.append_column(column)

        # Other items
        store_other_items: Gtk.Store = self.builder.get_object('iq_gain_other_items')
        store_other_items.append([
            IqGainOtherItem.WONDER_GUMMI,
            self._string_provider.get_value(StringType.ITEM_NAMES, WONDER_GUMMI_ITEM_ID),
            str(HardcodedIq.get_wonder_gummi_gain(arm9, static_data))
        ])
        store_other_items.append([
            IqGainOtherItem.NECTAR,
            self._string_provider.get_value(StringType.ITEM_NAMES, NECTAR_ITEM_ID),
            str(HardcodedIq.get_nectar_gain(ov29, static_data))
        ])
        store_other_items.append([
            IqGainOtherItem.JUICE_BAR_NECTAR,
            _("Juice Bar Nectar"),
            str(HardcodedIq.get_juice_bar_nectar_gain(arm9, static_data))
        ])