~thestr4ng3r/mymcplus

18f2da774a4cd8bbc1221b7d8ada161062889769 — Florian Märkl 3 years ago fe5aad2
Fix GUI for Python 3
5 files changed, 25 insertions(+), 22 deletions(-)

M mymc/gui.py
M mymc/guires.py
M mymc/lzari.py
M mymc/mymc.py
M mymc/ps2save.py
M mymc/gui.py => mymc/gui.py +9 -9
@@ 106,11 106,11 @@ def single_title(title):
def _get_icon_resource_as_images(name):
    ico = guires.resources[name]
    images = []
    f = io.StringIO(ico)
    f = io.BytesIO(ico)
    count = struct.unpack("<HHH", ico[0:6])[2]
    # count = wx.Image_GetImageCount(f, wx.BITMAP_TYPE_ICO)
    for i in range(count):
        f.seek(0)
        #f.seek(0)
        images.append(wx.Image(f, wx.BITMAP_TYPE_ICO, i))
    return images
    


@@ 169,7 169,7 @@ class dirlist_control(wx.ListCtrl):
        for ent in dir:
            if not ps2mc.mode_is_dir(ent[0]):
                continue
            dirname = "/" + ent[8]
            dirname = "/" + ent[8].decode("ascii")
            s = mc.get_icon_sys(dirname)
            if s == None:
                continue


@@ 670,7 670,7 @@ class gui_frame(wx.Frame):
        
        f = None
        try:
            f = file(filename, "r+b")
            f = open(filename, "r+b")
            mc = ps2mc.ps2mc(f)
        except EnvironmentError as value:
            if f != None:


@@ 749,7 749,7 @@ class gui_frame(wx.Frame):
        dirtable = self.dirlist.dirtable
        sfiles = []
        for i in selected:
            dirname = dirtable[i][0][8]
            dirname = dirtable[i][0][8].decode("ascii")
            try:
                sf = mc.export_save_file("/" + dirname)
                longname = ps2save.make_longname(dirname, sf)


@@ 774,7 774,7 @@ class gui_frame(wx.Frame):
            if fn == "":
                return
            try:
                f = file(fn, "wb")
                f = open(fn, "wb")
                try:
                    if fn.endswith(".max"):
                        sf.save_max_drive(f)


@@ 800,7 800,7 @@ class gui_frame(wx.Frame):
        for (dirname, sf, longname) in sfiles:
            fn = os.path.join(dir, longname) + ".psu"
            try:
                f = file(fn, "wb")
                f = open(fn, "wb")
                sf.save_ems(f)
                f.close()
                count += 1


@@ 815,7 815,7 @@ class gui_frame(wx.Frame):

    def _do_import(self, fn):
        sf = ps2save.ps2_save_file()
        f = file(fn, "rb")
        f = open(fn, "rb")
        try:
            ft = ps2save.detect_file_type(f)
            f.seek(0)


@@ 881,7 881,7 @@ class gui_frame(wx.Frame):
        selected = self.dirlist.selected
        dirtable = self.dirlist.dirtable

        dirnames = [dirtable[i][0][8]
        dirnames = [dirtable[i][0][8].decode("ascii")
                for i in selected]
        if len(selected) == 1:
            title = dirtable[list(selected)[0]][3]

M mymc/guires.py => mymc/guires.py +11 -8
@@ 1,5 1,8 @@

import base64

resources = {
    "mc4.ico": (
    "mc4.ico": base64.b64decode(
        "AAABAAIAICAQAAAAAADoAgAAJgAAADAwAAEAAAAAqA4AAA4DAAAoAAAAIAAAAEAAAAABAAQAAAAA\n"
        "AIACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAgAAAAICAAIAAAACAAIAAgIAAAICAgADAwMAA\n"
        "AAD/AAD/AAAA//8A/wAAAP8A/wD//wAA////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"


@@ 80,8 83,8 @@ resources = {
        "AP4AAAAAAwAA/gAAAAADAAD+AAAAAAMAAP4AAAAAAwAA/gAAAAADAAD+AAAAAAMAAP4AAAAAAwAA\n"
        "/gAAAAADAAD+AAAAAAMAAP4AAAAAAwAA/gAAAAADAAD+AAAAAAMAAP4AAAAAAwAA/gAAAAADAAD+\n"
        "AAAAAAMAAP///////wAA////////AAD///////8AAA==\n"
    ).decode("base64_codec"),
    "mc5b.ico": (
    ),
    "mc5b.ico": base64.b64decode(
        "AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAA\n"
        "AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA\n"
        "/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"


@@ 96,8 99,8 @@ resources = {
        "AAAAAAAAAAAAAAD///////////////////////8H///+B////AP///gB///QAH//wAA//8AAH/+A\n"
        "AA+AAAAHgAAAA4AAAAGAAAAAgAAAAIAAAACAAAAAgAAAAP/AAAH/wAAD/8wAB//eAA///wAf//+A\n"
        "P///wH///+D////x/////////////////w==\n"
    ).decode("base64_codec"),
    "mc2.ico": (
    ),
    "mc2.ico": base64.b64decode(
        "AAABAAEAMDAAAQAAAACoDgAAFgAAACgAAAAwAAAAYAAAAAEACAAAAAAAgAoAAAAAAAAAAAAAAAAA\n"
        "AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAwMDAAMDcwADwyqYAACBAAAAgYAAAIIAA\n"
        "ACCgAAAgwAAAIOAAAEAAAABAIAAAQEAAAEBgAABAgAAAQKAAAEDAAABA4AAAYAAAAGAgAABgQAAA\n"


@@ 165,8 168,8 @@ resources = {
        "AAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAAcAAP4AAAAABwAA/gAA\n"
        "AAAHAAD+AAAAAAcAAP4AAAAABwAA/gAAAAAHAAD+AAAAAA8AAP4AAAAAGwAA/wAAAAA/AAD/////\n"
        "//sAAP///////wAA\n"
    ).decode("base64_codec"),
    "mc6a.ico": (
    ),
    "mc6a.ico": base64.b64decode(
        "AAABAAEAICAQAAAAAADoAgAAFgAAACgAAAAgAAAAQAAAAAEABAAAAAAAgAIAAAAAAAAAAAAAAAAA\n"
        "AAAAAAAAAAAAAACAAACAAAAAgIAAgAAAAIAAgACAgAAAgICAAMDAwAAAAP8AAP8AAAD//wD/AAAA\n"
        "/wD/AP//AAD///8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"


@@ 181,5 184,5 @@ resources = {
        "AAAAAAAAAAAAAAD//////////////////////wf///4H///8A///+AH///AAf3/gAD8/wAAfH4AA\n"
        "Dw8AAAAHAAAAAwAAAAEAAAAAAAAAAMAAAAHgAAAD8AAAB/AAAQ/4AAMf/AAHP/4AD3//AB///4A/\n"
        "///Af///4P////H//////////////////w==\n"
    ).decode("base64_codec"),
    ),
}

M mymc/lzari.py => mymc/lzari.py +3 -3
@@ 667,9 667,9 @@ def main2(args):
    import struct
    import os
    
    src = file(args[2], "rb").read()
    src = open(args[2], "rb").read()
    lzari = lzari_codec()
    out = file(args[3], "wb")
    out = open(args[3], "wb")
    start = os.times()
    if args[1] == "c":
        dest = lzari.encode(src)


@@ 724,7 724,7 @@ def _dump_hotshot_lineinfo2(log):
                    print(line[:-1])
                f.close()
            try:
                f = file(filename, "r")
                f = open(filename, "r")
            except OSError:
                f = None
            cur = filename

M mymc/mymc.py => mymc/mymc.py +1 -1
@@ 173,7 173,7 @@ def do_extract(cmd, mc, opts, args, opterr):
                    _copy(out, f)
                    continue
                a = filename.split("/")
                o = file(a[-1], "wb")
                o = open(a[-1], "wb")
                try:
                    _copy(o, f)
                finally:

M mymc/ps2save.py => mymc/ps2save.py +1 -1
@@ 618,7 618,7 @@ def make_longname(dirname, sf):
        title = icon_sys_title(icon_sys, "ascii")
        title = title[0] + " " + title[1]
        title = " ".join(title.split())
    crc = binascii.crc32("")
    crc = binascii.crc32(b"")
    for (ent, data) in sf:
        crc = binascii.crc32(data, crc)
    if len(dirname) >= 12 and (dirname[0:2] in ("BA", "BJ", "BE", "BK")):