Пример #1
0
 def addEditableTab(self, tabname, fmt, boundfile, getwidget=defaultWidget):
     boundnarc = narc.NARC(open(boundfile, "rb").read())
     tabscroller = QScrollArea(self.tabcontainer)
     container = QWidget(tabscroller)
     fields = []
     y = 10
     my = y
     ypadding = 0
     x = 5
     self.tabcontainer.addTab(tabscroller, tabname)
     halfguess = struct.calcsize(fmt[0][:len(fmt[0]) / 2])
     for i, f in enumerate(FormatIterator(fmt[0])):
         w = getwidget(fmt[i + 1][0], f, container)
         if i == halfguess:
             x = width + 10
             my = y
             y = 10
         if w.kind == EditWidget.TAB:
             scr = QScrollArea(self.tabcontainer)
             scr.setWidget(w)
             self.tabcontainer.addTab(scr, w.tabname)
             w.changed = self.changed
             fields.append(w)
             continue
         width, height = w.getGeometry()
         w.setGeometry(QRect(x, y, width, height))
         w.changed = self.changed
         fields.append(w)
         y += ypadding + height
     container.setGeometry(QRect(0, 0, width * 2 + 20, max(my, y)))
     tabscroller.setWidget(container)
     self.tabs.append([boundnarc, boundfile, fmt, fields, container])
Пример #2
0
 def openTextNarc(self, f):
     if not self.checkClean():
         return
     self.fname = config.project["directory"] + "fs" + files[
         config.project["versioninfo"][0]][f]
     self.narc = narc.NARC(open(self.fname, "rb").read())
     self.textfilelist.clear()
     for i in range(self.narc.btaf.getEntryNum()):
         self.textfilelist.addItem(str(i))
     self.openText(0)
Пример #3
0
 def __init__(self, parent=None):
     super(EditMoves, self).__init__(parent)
     game = config.project["versioninfo"][0]
     self.wazafname = config.project["directory"] + "fs" + files[game][
         "Moves"]
     self.textfname = config.project[
         "directory"] + "fs" + pokeversion.textfiles[game]["Main"]
     self.textnarc = narc.NARC(open(self.textfname, "rb").read())
     self.typenames = self.getTextEntry("Types")
     self.movenames = self.getTextEntry("Moves")
     self.chooser.addItems(self.movenames)
     self.addEditableTab("General", movedatafmt[game.lower()],
                         self.wazafname, self.getMoveWidget)
Пример #4
0
 def __init__(self, parent=None):
     super(EditDlg, self).__init__(parent)
     self.dirty = False
     self.currentchoice = 0
     game = config.project["versioninfo"][0]
     self.textfname = config.project[
         "directory"] + "fs" + pokeversion.textfiles[game]["Main"]
     self.textnarc = narc.NARC(open(self.textfname, "rb").read())
     if pokeversion.gens[game] == 4:
         self.gettext = txt.gen4get
         self.puttext = txt.gen4put
     elif pokeversion.gens[game] == 5:
         self.gettext = txt.gen5get
         self.puttext = txt.gen5put
     self.setupUi()
Пример #5
0
def recursefs(d):
    if os.path.isdir(C_DIR + d):
        for f in sorted(os.listdir(C_DIR + d)):
            recursefs(d + "/" + f)
    else:
        f = open(C_DIR + d, "rb")
        count = 0
        if f.read(4) == "NARC":
            f.seek(0)
            n = narc.NARC(f.read())
            f.close()
            pfile = None
            dirname = os.path.dirname(ODIR + d)
            for j, f in enumerate(n.gmif.files):
                if f[:4] == "RGCN":
                    count += 1
                    graphic = ncgr.NCGR(f)
                    if not pfile:
                        template.mkdir(dirname)
                        pfile = template.open(
                            ODIR + d + FEXT, "w",
                            "Pokemon %s NCGR - %s" % (game.title(), d))
                        pfile.write(
                            "<p><a href='%s%s'>RGCN list</a></p>\n" %
                            ("../" * len(d.strip("/").split("/")), FNAME))
                    pfile.write("<p>File %i: %ix%i</p>" %
                                (j, graphic.char.width, graphic.char.height))
                    pfile.write(
                        "<p><img src='%i.png' alt='%s %i RGCN'></p>\n" %
                        (j, d, j))
                    graphic.toImage().save("%s/%i.png" % (dirname, j))
                    del graphic
            if pfile:
                pfile.close()
        else:
            f.close()
        if count:
            ofile.write(
                "\t<tr><td><a href='ncgr%s'>%s</a></td><td>%i files</td></tr>\n"
                % (d + FEXT, d, count))
        else:
            ofile.write("\t<tr><td>%s</td><td>0 files</td></tr>\n" % d)
Пример #6
0
def recursefs(d):
    if os.path.isdir(C_DIR + d):
        for f in sorted(os.listdir(C_DIR + d)):
            recursefs(d + "/" + f)
    else:
        f = open(C_DIR + d, "rb")
        count = 0
        if f.read(4) == "NARC":
            f.seek(0)
            n = narc.NARC(f.read())
            f.close()
            pfile = None
            for j, f in enumerate(n.gmif.files):
                if f[:4] == "RLCN":
                    count += 1
                    clr = nclr.NCLR(f)
                    if not pfile:
                        template.mkdir(os.path.dirname(ODIR + d))
                        pfile = template.open(
                            ODIR + d + FEXT, "w",
                            "Pokemon %s NCLR - %s" % (game.title(), d))
                        pfile.write(
                            "<p><a href='%s%s'>RLCN list</a></p>" %
                            ("../" * len(d.strip("/").split("/")), FNAME))
                    pfile.write("<p>File %i: " % j)
                    for k, c in enumerate(clr.pltt.colors):
                        pfile.write(
                            "<span style='background-color: #%02X%02X%02X;'>%i</span>"
                            % (c[0], c[1], c[2], k))
                    pfile.write("</p>\n")
            if pfile:
                pfile.close()
        else:
            f.close()
        if count:
            ofile.write(
                "\t<tr><td><a href='nclr%s'>%s</a></td><td>%i files</td></tr>\n"
                % (d + FEXT, d, count))
        else:
            ofile.write("\t<tr><td>%s</td><td>0 files</td></tr>\n" % d)
Пример #7
0
 def addListableTab(self,
                    tabname,
                    fmt,
                    boundfile,
                    isterminator=defaultTerminator,
                    terminator=None,
                    getwidget=defaultWidget):
     boundnarc = narc.NARC(open(boundfile, "rb").read())
     tabscroller = QScrollArea(self.tabcontainer)
     container = QWidget(tabscroller)
     adder = QPushButton("Add Entry", container)
     fields = []
     self.tabcontainer.addTab(tabscroller, tabname)
     container.setGeometry(QRect(0, 0, 0, 0))
     tabscroller.setWidget(container)
     tab = [
         boundnarc, boundfile, fmt, fields, getwidget, isterminator,
         terminator, container, adder
     ]
     func = lambda x: (lambda: self.addToListTab(x))
     QObject.connect(adder, QtCore.SIGNAL("pressed()"), func(tab))
     self.listtabs.append(tab)
Пример #8
0
    fmtsize = struct.calcsize(fmt)
    ofile = template.open(STATIC_DIR+game+"/"+FORMAT_SUBDIR+FNAME, "w", "Pokemon %s Encounter Format"%game.title())
    ofile.write("""
<h2>Pokemon %s Encounter Format</h2>
<p>Structure Size: %d bytes</p>
<table>
<tr><td>Offset</td><td>Length</td><td>Name</td></tr>
"""%(game.title(), fmtsize))
    ofs = 0
    """for i, entry in enumerate(datafmt[game]):
        ofile.write("<tr><td>%d</td><td>%d</td><td>%s</td></tr>\n"%(ofs, struct.calcsize(fmt[i]), entry))
        ofs += struct.calcsize(fmt[i])"""
    writefmt(ofile, fmt, datafmt[game])
    ofile.write("</table>\n")
    ofile.close()
    ofile = template.open(STATIC_DIR+game+"/"+FNAME, "w", "Pokemon %s Encounter Data"%game.title())
    ofile.write("""
<h2>Pokemon %s Encounters</h2>
<h3>%s - NARC Container</h3>
<p><a href='./%s%s'>Format</a></p>
<table>\n"""%(game.title(), GAMEFILE[game], FORMAT_SUBDIR, FNAME))
    n = narc.NARC(open(DATA_DIR+game+"/fs/"+GAMEFILE[game], "rb").read())
    for j, f in enumerate(n.gmif.files):
        ofile.write("\t<tr><td><h4>Location Id #%d</h4></td></tr>\n"%j)
        data = struct.unpack(fmt, f[:fmtsize])
        for i, entry in enumerate(datafmt[game]):
            if entry == "pad" and data[i]:
                print(j, data[i])
            ofile.write("\t<tr><td>%s</td><td>%d</td></tr>\n"%(entry, data[i]))
    ofile.write("</table>")
    ofile.close()
Пример #9
0
FNAME = "exprate" + FEXT

for game in games:
    fmt = "I" * 101
    ofile = template.open(
        STATIC_DIR + game + "/" + FORMAT_SUBDIR + FNAME, "w",
        "Pokemon %s Experience/Growth Table Format" % game.title())
    ofile.write("""
<h2>Pokemon %s Experience/Growth Table Format</h2>
<p>Structure Size: %d bytes</p>\n<p>4 bytes * 101 entries</p>\n""" %
                (game.title(), struct.calcsize(fmt)))
    ofile.close()
    ofile = template.open(
        STATIC_DIR + game + "/" + FNAME, "w",
        "Pokemon %s Experience/Growth Table Data" % game.title())
    ofile.write("""
<h2>Pokemon %s Experience Table</h2>
<h3>%s - NARC Container</h3>
<p><a href='./%s%s'>Format</a></p>
<table>\n""" % (game.title(), EXPRATE_FILE[game], FORMAT_SUBDIR, FNAME))
    n = narc.NARC(
        open(DATA_DIR + game + "/fs/" + EXPRATE_FILE[game], "rb").read())
    for j, f in enumerate(n.gmif.files):
        ofile.write("\t<tr><td><h4>Growth Id #%d</h4></td></tr>\n" % j)
        expdata = struct.unpack(fmt, f)
        for i, entry in enumerate(expdata):
            ofile.write("\t<tr><td>Level %s</td><td>%d Exp</td></tr>\n" %
                        (i, entry))
    ofile.write("</table>")
    ofile.close()
Пример #10
0
    FNAME = msg[0] + FEXT
    for game in games:
        if game not in msg[1]:
            continue
        gettext = textfmt[game][0]
        alg = textfmt[game][1]
        getlen = textfmt[game][2]
        ofile = template.open(STATIC_DIR + game + "/" + FORMAT_SUBDIR + FNAME,
                              "w",
                              "Pokemon %s %s Format" % (game.title(), msg[2]))
        ofile.write("<code style='white-space:pre;'>\n")
        for line in alg.split("\n"):
            ofile.write("%s\n" % line)
        ofile.write("</code>\n")
        ofile.close()
        n = narc.NARC(
            open(DATA_DIR + game + "/fs/" + msg[1][game], "rb").read())
        ofile = template.open(STATIC_DIR + game + "/" + FNAME, "w",
                              "Pokemon %s %s Format" % (game.title(), msg[2]))
        ofile.write("""
<h2>Pokemon %s Message Data</h2>
<h3>%s - NARC Container</h3>
<p><a href='./%s%s'>Format/Algorithm</a></p>
<table>
<tr>
    <td>Index</td><td>Contents</td><td>Entries</td>
</tr>\n""" % (game.title(), msg[1][game], FORMAT_SUBDIR, FNAME))
        ODIR = STATIC_DIR + game + "/" + msg[0] + "/"
        if not os.path.exists(ODIR):
            os.mkdir(ODIR)
        for j, f in enumerate(n.gmif.files):
            texts = gettext(f)  # [[num, text], [num, text]]
Пример #11
0
<p>Structures continue until 0xFFFF is reached (Maximum of 20 entries per file).</p>
<table>
<tr><td>Bits</td><td>Name</td></tr>
""" % (game.title(), struct.calcsize(fmt)))
    for i, entry in enumerate(movefmt[game]):
        ofile.write("<tr><td>%d-%d</td><td>%s</td></tr>" %
                    (entry[1], entry[2], entry[0]))
    ofile.write("</table>\n")
    ofile.close()
    ofile = template.open(STATIC_DIR + game + "/" + FNAME, "w",
                          "Pokemon %s Level-Up Move Data" % game.title())
    ofile.write("""
<h2>Pokemon %s Level-Up Moves</h2>
<h3>%s - NARC Container</h3>
<p><a href='./%s%s'>Format</a></p>
<table>\n""" % (game.title(), LEVELMOVE_FILE[game], FORMAT_SUBDIR, FNAME))
    n = narc.NARC(
        open(DATA_DIR + game + "/fs/" + LEVELMOVE_FILE[game], "rb").read())
    for j, f in enumerate(n.gmif.files):
        ofile.write("\t<tr><td><h4>Pokemon Id #%d</h4></td></tr>\n" % j)
        while 1:
            data = struct.unpack(fmt, f[:struct.calcsize(fmt)])
            if data[0] & 0xFFFF == 0xffff:
                ofile.write("\t<tr><td colspan='2'>%d</td></tr>\n" % (data[0]))
                break
            for i, entry in enumerate(movefmt[game]):
                ofile.write("\t<tr><td>%s</td><td>%d</td></tr>\n" %
                            (entry[0], (data[0] >> entry[1]) & entry[3]))
            f = f[struct.calcsize(fmt):]
    ofile.write("</table>")
    ofile.close()