Beispiel #1
0
    def on_btn_add_clicked(self, *args):
        from skytemple.module.sprite.module import GROUND_DIR, WAN_FILE_EXT
        response, name = self._show_generic_input(_('Sprite Name'),
                                                  _('Create Object Sprite'))
        if response != Gtk.ResponseType.OK:
            return
        name = name.lower()
        if len(name) < 1 or len(name) > 10:
            md = SkyTempleMessageDialog(
                SkyTempleMainController.window(), Gtk.DialogFlags.MODAL,
                Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
                _("The length of the sprite name must be between 1-10 characters."
                  ))
            md.run()
            md.destroy()
            return
        obj_name = f'{GROUND_DIR}/{name}.{WAN_FILE_EXT}'
        if self.module.project.file_exists(obj_name):
            md = SkyTempleMessageDialog(
                SkyTempleMainController.window(), Gtk.DialogFlags.MODAL,
                Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
                _("A sprite with this name already exists."))
            md.run()
            md.destroy()
            return

        with open(os.path.join(data_dir(), 'empty.wan'), 'rb') as f:
            empty_wan = f.read()

        # Write to ROM
        self.module.project.create_file_manually(obj_name, empty_wan)
        self.module.add_wan(f'{name}.{WAN_FILE_EXT}')

        md = SkyTempleMessageDialog(SkyTempleMainController.window(),
                                    Gtk.DialogFlags.MODAL,
                                    Gtk.MessageType.INFO,
                                    Gtk.ButtonsType.OK,
                                    _("Object sprite added successfully"),
                                    is_success=True)
        md.run()
        md.destroy()
Beispiel #2
0
    def on_import_full_activate(self, *args):
        md = SkyTempleMessageDialog(
            MainController.window(),
            Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO,
            Gtk.ButtonsType.OK,
            _("To import, select a folder containing all the image files that were created when exporting the full tileset."
              ),
            title=_("Import Full Tileset"))
        md.run()
        md.destroy()
        dialog = Gtk.FileChooserNative.new(
            _("Import full zmappat from folder..."), MainController.window(),
            Gtk.FileChooserAction.SELECT_FOLDER, None, None)

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            try:
                imgs: List[Image.Image] = [
                    None
                ] * ZMAPPAT_NB_VARIATIONS  # type: ignore
                masks: List[Image.Image] = [
                    None
                ] * ZMAPPAT_NB_VARIATIONS  # type: ignore
                for v in ZMappaTVariation:
                    fn_tiles = os.path.join(fn,
                                            f'zmappat-{v.filename}-tiles.png')
                    fn_masks = os.path.join(fn,
                                            f'zmappat-{v.filename}-masks.png')
                    imgs[v.value] = Image.open(fn_tiles, 'r')
                    masks[v.value] = Image.open(fn_masks, 'r')
                self.zmappat.from_pil(imgs, masks)
                self.module.mark_zmappat_as_modified(self.zmappat,
                                                     self.filename)
            except Exception as err:
                display_error(sys.exc_info(), str(err),
                              _("Error importing full zmappat."))
            self._reinit_image()
Beispiel #3
0
    def on_men_chunks_layer1_import_activate(self):
        dialog: Gtk.Dialog = self.parent.builder.get_object(
            'dialog_chunks_import')
        dialog.set_attached_to(MainController.window())
        dialog.set_transient_for(MainController.window())

        # Set dialog settings to map settings
        chunks_import_file: Gtk.FileChooserButton = self.parent.builder.get_object(
            'chunks_import_file')
        chunks_import_palettes: Gtk.Switch = self.parent.builder.get_object(
            'chunks_import_palettes')
        chunks_import_file.unselect_all()

        resp = dialog.run()
        dialog.hide()

        if resp == Gtk.ResponseType.OK:
            try:
                if chunks_import_file.get_filename() is None:
                    md = SkyTempleMessageDialog(
                        MainController.window(),
                        Gtk.DialogFlags.DESTROY_WITH_PARENT,
                        Gtk.MessageType.ERROR,
                        Gtk.ButtonsType.OK,
                        "An image must be selected.",
                        title="Error!")
                    md.set_position(Gtk.WindowPosition.CENTER)
                    md.run()
                    md.destroy()
                else:
                    with open(chunks_import_file.get_filename(), 'rb') as f:
                        tiles, palettes = self.parent.dpc.pil_to_chunks(
                            Image.open(f))
                        self.parent.dpci.tiles = tiles
                        if chunks_import_palettes.get_active():
                            self.parent.dpl.palettes = palettes
            except Exception as err:
                display_error(sys.exc_info(), str(err),
                              "Error importing the tileset.")
            self.parent.reload_all()
            self.parent.mark_as_modified()
Beispiel #4
0
    def on_import_clicked(self, w: Gtk.MenuToolButton):
        md = SkyTempleMessageDialog(
            MainController.window(),
            Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
            Gtk.ButtonsType.OK,
            f"To import, select a folder containing all the files that were created when exporting the font.\n"
            f"IMPORTANT: All image files must be indexed PNGs!\n"
            f"For banner fonts, all images must have the same palette.",
            title="Import Font"
        )
        md.run()
        md.destroy()
        dialog = Gtk.FileChooserNative.new(
            "Import font from folder...",
            MainController.window(),
            Gtk.FileChooserAction.SELECT_FOLDER,
            None, None
        )

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()
        
        if response == Gtk.ResponseType.ACCEPT:
            try:
                xml = ElementTree().parse(os.path.join(fn, f'char_tables.xml'))
                tables = dict()
                for i in range(256):
                    path = os.path.join(fn, f'table-{i}.png')
                    if os.path.exists(path):
                        tables[i] = Image.open(path, 'r')
                        
                self.font.import_from_xml(xml, tables)
                self.module.mark_font_as_modified(self.spec)
            except Exception as err:
                display_error(
                    sys.exc_info(),
                    str(err),
                    "Error importing font."
                )
            self._init_font()
Beispiel #5
0
    def on_men_bg_import_activate(self, *args):
        dialog: Gtk.Dialog = self.builder.get_object('dialog_bg_import')
        dialog.set_attached_to(MainController.window())
        dialog.set_transient_for(MainController.window())

        file_chooser: Gtk.FileChooserButton = self.builder.get_object(
            'bg_import_file')

        resp = dialog.run()
        dialog.hide()

        if resp == ResponseType.OK:
            try:
                path = file_chooser.get_filename()
                with open(path, 'rb') as f:
                    self.bgp.from_pil(Image.open(f), True)
            except Exception as err:
                display_error(sys.exc_info(), str(err),
                              "Error importing the image.")
            self.module.mark_as_modified(self.item_id)
            self._reinit_image()
Beispiel #6
0
 def on_btn_help_hp_regeneration_clicked(self, w, *args):
     md = SkyTempleMessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         _("The % of HP that this Pokémon regenerates at the end of "
           "each turn is equal to 1/(value * 2), before applying any modifiers.\n"
           "The final value is capped between 1/30 and 1/500"),
         title=_("HP Regeneration")
     )
     md.run()
     md.destroy()
Beispiel #7
0
 def on_cart_removed_info_clicked(self, *args):
     md = SkyTempleMessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         _("This is what the game shows when the cartridge is removed while playing.\n"
           "IMPORTANT! The game stores this compressed in the ARM9, so this is limited in space.\n"
           "It is recommended to only edit this to change the text color/content."),
         title=_("Cartridge Removed Image Info")
     )
     md.run()
     md.destroy()
Beispiel #8
0
    def on_men_palettes_edit_activate(self):
        dict_pals = OrderedDict()
        for i, pal in enumerate(self.parent.dpl.palettes):
            dict_pals[f'{i}'] = pal.copy()

        cntrl = PaletteEditorController(MainController.window(), dict_pals)
        edited_palettes = cntrl.show()
        if edited_palettes:
            self.parent.dpl.palettes = edited_palettes
            self.parent.reload_all()
            self.parent.mark_as_modified()
        del cntrl
Beispiel #9
0
 def on_import_clicked(self, w: Gtk.MenuToolButton):
     md = SkyTempleMessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT,
         Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         "To import select the directory of the spritesheets. If it "
         "is still zipped, unzip it first.",
         title="SkyTemple")
     md.run()
     md.destroy()
     self.do_import(self.item_id)
Beispiel #10
0
 def on_btn_help_accuracy_clicked(self, w, *args):
     md = SkyTempleMessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT,
         Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         _("The percentage indicating the chances the move will succeed. "
           "100 is perfect accuracy. Anything higher than 100 is a never-miss move."
           ),
         title=_("Accuracy:")[:-1])
     md.run()
     md.destroy()
Beispiel #11
0
 def on_btn_help_miss_accuracy_clicked(self, w, *args):
     md = SkyTempleMessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT,
         Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         _("Seems to be a second sort of accuracy check. "
           "A different message will be shown if this accuracy test fails."
           ),
         title=_("Miss Accuracy:")[:-1])
     md.run()
     md.destroy()
Beispiel #12
0
    def do_import(self, item_id: int, cb=lambda: None):
        dialog = Gtk.FileChooserNative.new(
            _("Import spritesheet..."),
            MainController.window(),
            Gtk.FileChooserAction.SELECT_FOLDER,
            None, None
        )

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            try:
                wan = FileType.WAN.CHARA.import_sheets(fn)
                monster, ground, attack = FileType.WAN.CHARA.split_wan(wan)

                md = SkyTempleMessageDialog(MainController.window(),
                                            Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
                                            Gtk.ButtonsType.OK, _("The spritesheet was successfully imported."),
                                            title=_("Success!"), is_success=True)
                md.run()
                md.destroy()
                self.module.save_monster_monster_sprite(item_id, monster)
                self.module.save_monster_ground_sprite(item_id, ground)
                self.module.save_monster_attack_sprite(item_id, attack)

                # Shadow size
                tree = ElementTree.parse(os.path.join(fn, 'AnimData.xml'))
                self._set_shadow_size_cb(int(tree.getroot().find('ShadowSize').text))

                cb()
                self._mark_as_modified_cb()
                MainController.reload_view()
            except BaseException as e:
                display_error(
                    sys.exc_info(),
                    str(e),
                    _("Error importing the spritesheet.")
                )
Beispiel #13
0
    def on_export_clicked(self, w: Gtk.MenuToolButton):
        dialog = Gtk.FileChooserNative.new(
            _("Export spritesheet..."),
            MainController.window(),
            Gtk.FileChooserAction.SELECT_FOLDER,
            _('_Save'), None
        )

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            try:
                monster = self.module.get_monster_monster_sprite_chara(self.item_id)
                ground = self.module.get_monster_ground_sprite_chara(self.item_id)
                attack = self.module.get_monster_attack_sprite_chara(self.item_id)
                merged = FileType.WAN.CHARA.merge_wan(monster, ground, attack)
                merged.sdwSize = self._get_shadow_size_cb()
                try:
                    animation_names = self.module.project.get_rom_module().get_static_data().animation_names[self.item_id]
                except KeyError:
                    # Fall back to Bulbasaur
                    animation_names = self.module.project.get_rom_module().get_static_data().animation_names[0]
                FileType.WAN.CHARA.export_sheets(
                    fn, merged, animation_names
                )

                md = SkyTempleMessageDialog(MainController.window(),
                                            Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
                                            Gtk.ButtonsType.OK, _("The spritesheet was successfully exported."),
                                            title=_("Success!"), is_success=True)
                md.run()
                md.destroy()
            except BaseException as e:
                display_error(
                    sys.exc_info(),
                    str(e),
                    _("Error exporting the spritesheet.")
                )
Beispiel #14
0
def collect_state_context() -> Dict[str, 'Captured']:
    from skytemple.controller.main import MainController
    from skytemple.core.rom_project import RomProject
    from skytemple_files.common.util import capture_any
    rom_project = RomProject.get_current()
    try:
        view_state = MainController._instance._current_view_module.collect_debugging_info(  # type: ignore
            MainController._instance._current_view_controller  # type: ignore
        )
        if "models" in view_state:  # type: ignore
            view_state["models"] = {
                k: capture_any(v)
                for k, v in view_state["models"].items()
            }  # type: ignore
    except Exception as ex:
        view_state = {"error_collecting": str(ex)}
    w, h = MainController.window().get_size()
    dw = if_not_none(MainController.debugger_manager()._opened_main_window,
                     lambda w: w.get_size()[0])
    dh = if_not_none(MainController.debugger_manager()._opened_main_window,
                     lambda w: w.get_size()[1])
    return {
        "skytemple": {
            "window": {
                "width": w,
                "height": h,
            },
            "rom": {
                "filename":
                if_not_none(rom_project, lambda p: p.get_rom_name()),
                "edition":
                if_not_none(rom_project,
                            lambda p: p.get_rom_module().get_static_data()),
            },
            "module":
            type(MainController._instance._current_view_module).__qualname__,
            "view": MainController._instance._current_view_controller_class.
            __qualname__,  # type: ignore
            "view_state": view_state
        },
        "ssb_debugger": {
            "window": {
                "width": dw,
                "height": dh,
            },
            "open_scripts":
            debugger_open_scripts(MainController.debugger_manager()),
            "focused_script":
            debugger_focused_script(MainController.debugger_manager()),
            #"emulator_state": debugger_emulator_state(MainController.debugger_manager())
        }
    }
Beispiel #15
0
    def on_btn_export_clicked(self, *args):
        dialog = Gtk.FileChooserNative.new(
            _("Export dungeon tileset..."),
            MainController.window(),
            Gtk.FileChooserAction.SELECT_FOLDER,
            None, None
        )

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()
        assert self.dtef is not None

        if response == Gtk.ResponseType.ACCEPT:
            try:
                # Write XML
                with open(os.path.join(fn, 'tileset.dtef.xml'), 'w') as f:
                    f.write(prettify(self.dtef.get_xml()))
                # Write Tiles
                var0, var1, var2, rest = self.dtef.get_tiles()
                var0fn, var1fn, var2fn, restfn = self.dtef.get_filenames()
                var0.save(os.path.join(fn, var0fn))
                var1.save(os.path.join(fn, var1fn))
                var2.save(os.path.join(fn, var2fn))
                rest.save(os.path.join(fn, restfn))
                shutil.copy(get_template_file(), os.path.join(fn, 'template.png'))

                md = SkyTempleMessageDialog(MainController.window(),
                                            Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
                                            Gtk.ButtonsType.OK, _("The tileset was successfully exported."),
                                            title=_("Success!"), is_success=True)
                md.run()
                md.destroy()
            except BaseException as e:
                display_error(
                    sys.exc_info(),
                    str(e),
                    _("Error exporting the tileset.")
                )
Beispiel #16
0
 def on_btn_help_settings_range_ai_clicked(self, w, *args):
     md = SkyTempleMessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         _("When deciding what move to use, the AI will treat the move like it actually has the range settings "
           "configured here.") + _('\nDue to a bug, if the values are "straight line", "In front; cuts corners" or '
                                   '"Two tiles away; cuts corners" are chosen here, the AI range is used as the '
                                   'ACTUAL range of the move.'),
         title=_("Values used for AI calculation:")[:-1]
     )
     md.run()
     md.destroy()
Beispiel #17
0
    def on_men_palettes_edit_activate(self):
        # This is controlled by a separate controller
        dict_pals = OrderedDict()
        for i, pal in enumerate(self.parent.bpl.get_real_palettes()):
            dict_pals[f'{i}'] = pal.copy()

        cntrl = PaletteEditorController(MainController.window(), dict_pals)
        edited_palettes = cntrl.show()
        if edited_palettes:
            self.parent.bpl.set_palettes(edited_palettes)
            self.parent.reload_all()
            self.parent.mark_as_modified()
        del cntrl
Beispiel #18
0
    def on_import_minimized_activate(self, *args):
        md = SkyTempleMessageDialog(
            MainController.window(),
            Gtk.DialogFlags.DESTROY_WITH_PARENT,
            Gtk.MessageType.INFO,
            Gtk.ButtonsType.OK,
            _("To import, select a folder containing all the image files that were created when exporting the minimized version.\n"
              "IMPORTANT: All image files must be indexed PNGs and use the same palette!"
              ),
            title=_("Import Minimized Version"))
        md.run()
        md.destroy()
        dialog = Gtk.FileChooserNative.new(
            _("Import zmappat minimized from folder..."),
            MainController.window(), Gtk.FileChooserAction.SELECT_FOLDER, None,
            None)

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            try:
                imgs = [None] * ZMAPPAT_NB_VARIATIONS
                masks = [None] * ZMAPPAT_NB_VARIATIONS
                for v in ZMappaTVariation:
                    fn_tiles = os.path.join(
                        fn, f'zmappat-{v.filename}-tiles.min.png')
                    fn_masks = os.path.join(
                        fn, f'zmappat-{v.filename}-masks.min.png')
                    imgs[v.value] = Image.open(fn_tiles, 'r')
                    masks[v.value] = Image.open(fn_masks, 'r')
                self.zmappat.from_pil_minimized(imgs, masks)
                self.module.mark_zmappat_as_modified(self.zmappat,
                                                     self.filename)
            except Exception as err:
                display_error(sys.exc_info(), str(err),
                              _("Error importing minimized zmappat."))
            self._reinit_image()
Beispiel #19
0
    def on_btn_import_clicked(self, *args):
        md = SkyTempleMessageDialog(
            MainController.window(), Gtk.DialogFlags.MODAL,
            Gtk.MessageType.INFO, Gtk.ButtonsType.OK,
            _("Import is done from a CSV file with the following specifications:\n"
              "- Has to contain all strings in order, one per row\n"
              "- Strings may be quoted with: \" and escaped with doube-quotes."
              ))
        md.run()
        md.destroy()
        save_diag = Gtk.FileChooserNative.new(_("Import strings from..."),
                                              MainController.window(),
                                              Gtk.FileChooserAction.OPEN, None,
                                              None)

        add_dialog_csv_filter(save_diag)
        response = save_diag.run()
        fn = save_diag.get_filename()
        save_diag.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            try:
                with open_utf8(fn) as csv_file:
                    csv_reader = csv.reader(csv_file)
                    strings = []
                    for row in csv_reader:
                        if len(row) > 0:
                            strings.append(row[0])
                    if len(self._str.strings) != len(strings):
                        raise ValueError(
                            f(
                                _("The CSV file must contain exactly {len(self._str.strings)} strings, "
                                  "has {len(strings)}.")))
                    self._str.strings = strings
                self.module.mark_as_modified(self.filename)
                MainController.reload_view()
            except BaseException as err:
                display_error(sys.exc_info(), str(err),
                              _("Error exporting the strings."))
Beispiel #20
0
 def _error(self, msg, type=Gtk.MessageType.ERROR, exc_info=None, is_success=False):
     if type == Gtk.MessageType.ERROR:
         display_error(
             exc_info,
             msg
         )
     else:
         md = SkyTempleMessageDialog(MainAppController.window(),
                                     Gtk.DialogFlags.DESTROY_WITH_PARENT, type,
                                     Gtk.ButtonsType.OK, msg, is_success=is_success)
         md.set_position(Gtk.WindowPosition.CENTER)
         md.run()
         md.destroy()
Beispiel #21
0
 def _show_generic_input(self, label_text, ok_text, sublabel_text=''):
     dialog: Gtk.Dialog = self.builder.get_object('generic_input_dialog')
     entry: Gtk.Entry = self.builder.get_object(
         'generic_input_dialog_entry')
     label: Gtk.Label = self.builder.get_object(
         'generic_input_dialog_label')
     sublabel: Gtk.Label = self.builder.get_object(
         'generic_input_dialog_sublabel')
     label.set_text(label_text)
     sublabel.set_text(sublabel_text)
     btn_cancel = dialog.add_button(_("Cancel"), Gtk.ResponseType.CANCEL)
     btn = dialog.add_button(ok_text, Gtk.ResponseType.OK)
     btn.set_can_default(True)
     btn.grab_default()
     entry.set_activates_default(True)
     dialog.set_attached_to(SkyTempleMainController.window())
     dialog.set_transient_for(SkyTempleMainController.window())
     response = dialog.run()
     dialog.hide()
     btn.get_parent().remove(btn)
     btn_cancel.get_parent().remove(btn_cancel)
     return response, entry.get_text()
Beispiel #22
0
    def on_import_clicked(self, w: Gtk.MenuToolButton):
        dialog = Gtk.FileChooserNative.new(_("Import image..."),
                                           MainController.window(),
                                           Gtk.FileChooserAction.OPEN, None,
                                           None)
        add_dialog_png_filter(dialog)

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            dialog: Gtk.Dialog = self.builder.get_object('dialog_import')

            dialog.set_attached_to(MainController.window())
            dialog.set_transient_for(MainController.window())

            resp = dialog.run()
            dialog.hide()
            if resp == Gtk.ResponseType.OK:
                import_palette = self.builder.get_object(
                    'switch_import_palette').get_active()
                import_new = self.builder.get_object(
                    'switch_import_new').get_active()
                img = Image.open(fn)
                if import_new:
                    idx = len(self.img.sprites)
                    self.img.sprites.append(None)
                else:
                    idx = self.image_idx
                try:
                    self.img.from_pil(idx, img, import_palette)
                    self.module.mark_icons_as_modified(self.img_type, self.img)
                    self.module.project.get_sprite_provider().reset()
                except Exception as err:
                    display_error(sys.exc_info(), str(err),
                                  "Error importing sprite.")
                self._init_sprites(idx, self.palette_idx)
Beispiel #23
0
    def on_edit_floor_count_clicked(self, *args):
        dialog: Gtk.Dialog = self.builder.get_object(
            'dialog_adjust_floor_count')
        dialog.set_attached_to(MainController.window())
        dialog.set_transient_for(MainController.window())

        current_floor_count = self.module.get_number_floors(
            self.dungeon_info.dungeon_id)

        label_floor_count_in_dialog: Gtk.Label = self.builder.get_object(
            'label_floor_count_in_dialog')
        spin_floor_count: Gtk.SpinButton = self.builder.get_object(
            'spin_floor_count')

        label_floor_count_in_dialog.set_text(
            f'This dungeon currently has {current_floor_count} floors.')
        spin_floor_count.set_value(current_floor_count)

        resp = dialog.run()
        dialog.hide()
        if resp == ResponseType.APPLY:
            self.module.change_floor_count(self.dungeon_info.dungeon_id,
                                           int(spin_floor_count.get_value()))
Beispiel #24
0
    def on_btn_export_code_clicked(self, *args):
        dialog = Gtk.FileChooserNative.new(
            _("Export Special Process Effect ASM Code..."),
            MainController.window(), Gtk.FileChooserAction.SAVE, None, None)

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            with open(fn, 'wb') as file:
                file.write(
                    self.sp_effects.get_effect_code(
                        self._get_current_effect()))
Beispiel #25
0
    def on_men_bg_export_activate(self, *args):
        dialog: Gtk.Dialog = self.builder.get_object('dialog_bg_export')
        dialog.set_attached_to(MainController.window())
        dialog.set_transient_for(MainController.window())

        resp = dialog.run()
        dialog.hide()
        if resp == ResponseType.OK:
            dialog = Gtk.FileChooserNative.new("Export as PNG...",
                                               MainController.window(),
                                               Gtk.FileChooserAction.SAVE,
                                               None, None)

            add_dialog_png_filter(dialog)

            response = dialog.run()
            fn = dialog.get_filename()
            if '.' not in fn:
                fn += '.png'
            dialog.destroy()

            if response == Gtk.ResponseType.ACCEPT:
                self.bgp.to_pil().save(fn)
Beispiel #26
0
 def on_btn_about_palettes_clicked(self, w, *args):
     md = Gtk.MessageDialog(
         MainController.window(),
         Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
         Gtk.ButtonsType.OK,
         f"Map backgrounds can be used as primary or secondary.\n"
         f"When used as primary, the background can have up to 14 palettes, using slots from 0 to 13.\n"
         f"When used as secondary, the background can only have 1 palette, using slot 14, and every palette value will have a new value of (old_value{chr(0xA0)}+{chr(0xA0)}14){chr(0xA0)}mod{chr(0xA0)}16.\n"
         f"It is still possible to use palette values above those limits, but this is only in cases where a background needs to reference a palette from the other background.\n"
         f"Note: in the original game, almost every background is used as primary, the exceptions being mainly the weather (W) backgrounds.\n",
         title="Background Palettes"
     )
     md.run()
     md.destroy()
Beispiel #27
0
 def on_btn_help_excl_parameter_clicked(self, w, *args):
     text = _(
         "Either the ID of a type or of a Pokémon, depending on the type of the exclusive item.\n\n"
         "IDs for Types:\n")
     for typ in PokeType:
         text += f'{typ.value}: {str(typ)}\n'
     md = SkyTempleMessageDialog(MainController.window(),
                                 Gtk.DialogFlags.DESTROY_WITH_PARENT,
                                 Gtk.MessageType.INFO,
                                 Gtk.ButtonsType.OK,
                                 text,
                                 title=_("Exclusive Item Parameter"))
     md.run()
     md.destroy()
Beispiel #28
0
    def on_spritebot_export_activate(self, *args):
        dialog = Gtk.FileChooserNative.new(
            _("Export portrait as PNG sheet..."), MainController.window(),
            Gtk.FileChooserAction.SAVE, None, None)

        add_dialog_png_filter(dialog)

        response = dialog.run()
        dialog.destroy()

        if response == Gtk.ResponseType.ACCEPT:
            fn = dialog.get_filename()
            fn = add_extension_if_missing(fn, 'png')
            SpriteBotSheet.create(self.kao, self.item_id).save(fn)
Beispiel #29
0
    def on_export_icon_clicked(self, *args):
        dialog = FileChooserNative.new(_("Export game icon as PNG..."),
                                       SkyTempleMainController.window(),
                                       FileChooserAction.SAVE, None, None)

        add_dialog_png_filter(dialog)

        response = dialog.run()
        fn = dialog.get_filename()
        dialog.destroy()

        if response == ResponseType.ACCEPT:
            fn = add_extension_if_missing(fn, 'png')
            self.icon_banner.icon.to_pil().save(fn)
Beispiel #30
0
 def on_cr_name_edited(self, widget, path, text):
     store: Gtk.ListStore = self.builder.get_object('level_list_tree_store')
     if len(text) < 1 or len(text) > 8:
         md = SkyTempleMessageDialog(
             SkyTempleMainController.window(), Gtk.DialogFlags.MODAL,
             Gtk.MessageType.ERROR, Gtk.ButtonsType.OK,
             _("The length of the level name must be between 1-8 characters."
               ))
         md.run()
         md.destroy()
         return
     text = text.upper()
     store[path][1] = text
     self._save()