Esempio n. 1
0
    def open_rom(self, rom: Union[NintendoDSRom, BinaryIO, bytes, str,
                                  ndspy.rom.NintendoDSRom]):
        rom_last_filename = self.rom_last_filename
        if isinstance(rom, str):  # Filename
            rom_last_filename = rom
            rom = NintendoDSRom.fromFile(rom)
        elif isinstance(rom, BinaryIO):  # File
            rom = NintendoDSRom(rom.read())
        elif isinstance(rom, bytes):  # Raw bytes
            rom = NintendoDSRom(rom)
        elif isinstance(rom, ndspy.rom.NintendoDSRom):
            rom = NintendoDSRom(rom.save())
        elif isinstance(rom, NintendoDSRom):
            rom = rom

        # Load language from arm9
        if rom.name == b"LAYTON2":
            arm9 = rom.loadArm9()
            lang_address = 0x02000d3c - arm9.ramAddress
            lang_id = rom.arm9[lang_address]
            lang_table = ["jp", "en", "sp", "fr", "it", "ge", "du", "ko", "ch"]
            try:
                conf.LANG = lang_table[lang_id]
            except IndexError:  # US version?
                # TODO: Figure out how to read it properly
                conf.LANG = "en"
            print(f"Game language: {conf.LANG}")
            if conf.LANG == "jp":
                error_dialog = wx.MessageDialog(
                    self,
                    "Japanese is not currently supported",
                    style=wx.ICON_ERROR | wx.OK)
                error_dialog.ShowModal()
                return
        else:
            warning_game_dialog = wx.MessageDialog(
                self, "Warning: LaytonEditor is specifically made to edit "
                "Layton 2, and support with other games is not guaranteed.",
                style=wx.ICON_WARNING | wx.OK)
            warning_game_dialog.ShowModal()
            conf.LANG = "en"

        # After checking language
        self.rom = rom
        self.rom_last_filename = rom_last_filename

        RomSingleton(rom=self.rom)

        # Only open the main filesystem page.
        self.le_editor_pages.DeleteAllPages()
        menus_to_remove = []
        for menu in self.le_menu.Menus:
            if menu[1] != "File":
                menus_to_remove.append(menu[1])
        for menu_to_remove in menus_to_remove:
            self.remove_menu(menu_to_remove)
        self.open_filesystem_page("Rom FS")
Esempio n. 2
0
    def open_rom(self, rom: Union[NintendoDSRom, BinaryIO, bytes, str, ndspy.rom.NintendoDSRom]):
        if isinstance(rom, str):  # Filename
            self.rom_last_filename = rom
            self.rom = NintendoDSRom.fromFile(rom)
        elif isinstance(rom, BinaryIO):  # File
            self.rom = NintendoDSRom(rom.read())
        elif isinstance(rom, bytes):  # Raw bytes
            self.rom = NintendoDSRom(rom)
        elif isinstance(rom, ndspy.rom.NintendoDSRom):
            self.rom = NintendoDSRom(rom.save())
        elif isinstance(rom, NintendoDSRom):
            self.rom = rom

        RomSingleton(rom=self.rom)

        # Only open the main filesystem page.
        self.le_editor_pages.DeleteAllPages()
        menus_to_remove = []
        for menu in self.le_menu.Menus:
            if menu[1] != "File":
                menus_to_remove.append(menu[1])
        for menu_to_remove in menus_to_remove:
            self.remove_menu(menu_to_remove)
        self.open_filesystem_page("Rom FS")
Esempio n. 3
0
 def setUpClass(cls) -> None:
     rom_path = os.path.dirname(__file__)
     cls.rom = NintendoDSRom.fromFile(rom_path + "/../../test_rom.nds")
            clicked_time = time.time()
            if clicked_time - self._last_click < 0.5:
                self._nearest = not self._nearest
                self.Refresh()
                self._last_click = 0
            else:
                self._last_click = clicked_time


class HelloFrame(wx.Frame):
    image_viewer: ScaledImage
    """
    A Frame that says Hello World
    """
    def __init__(self, *args, **kw):
        super(HelloFrame, self).__init__(*args, **kw)
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.image_viewer = ScaledImage(self)
        sizer.Add(self.image_viewer, 1, wx.EXPAND | wx.ALL, 0)
        self.SetSizer(sizer)


if __name__ == '__main__':
    rom = NintendoDSRom.fromFile("../../../Base File.nds")
    app = wx.App()
    frm = HelloFrame(None, title='Hello World', size=(800, 600))
    img = BGImage("data_lt2/bg/name/name_bg1.arc", rom=rom)
    frm.image_viewer.load_bitmap(img.extract_image_wx_bitmap())
    frm.Show()
    app.MainLoop()