Home Gallery Resources The Team Rules chat Login Register
Pages: [1]
Author Topic: BrawlBox plugins (v0.78) - updated 2017-03-23  (Read 530 times)
0 Members and 1 Guest are viewing this topic.
libertyernie
Lol Kitten
*********
Offline Offline

Posts: 916


Go for the gold

  • Awards >9000 Renowned Hacker King for a Day RAGE!! Featured

  • View Profile Awards
    « on: February 24, 2017, 01:36:36 PM »


    This is a thread for BrawlBox plugin scripts. v0.78 has a system that lets you write plugins in Python.

    Just copy the text into Notepad and save it as a file with a .py extension in the Plugins folder alongside BrawlBox. Then you'll see it in BrawlBox under Plugins in the menu bar.

    Batch convert files (pac <-> pcs)

    To .pcs
    Code:
    from BrawlBox.API import bboxapi
    from BrawlLib.SSBB.ResourceNodes import *

    import os

    dir = bboxapi.OpenFolderDialog()
    if dir is not "":
    include_subfolders = bboxapi.ShowYesNoPrompt("Include subfolders?", "Batch conversion")

    from_ext = ".pac"
    to_ext = ".pcs"

    if not from_ext.startswith("."):
    from_ext = "." + from_ext;

    if not to_ext.startswith("."):
    to_ext = "." + to_ext;

    for root, dirs, files in os.walk(dir):
    for file in files:
    if file.lower().endswith(from_ext):
    no_ext, ext = os.path.splitext(file)
    node = NodeFactory.FromFile(None, os.path.join(root, file))
    try:
    node.Export(os.path.join(root, no_ext + to_ext))
    node.Dispose()
    except:
    bboxapi.ShowMessage("Cannot export " + file + " as format " + to_ext, "Error")
    if not include_subfolders:
    break
    To .pac
    Code:
    from BrawlBox.API import bboxapi
    from BrawlLib.SSBB.ResourceNodes import *

    import os

    dir = bboxapi.OpenFolderDialog()
    if dir is not "":
    include_subfolders = bboxapi.ShowYesNoPrompt("Include subfolders?", "Batch conversion")

    from_ext = ".pcs"
    to_ext = ".pac"

    if not from_ext.startswith("."):
    from_ext = "." + from_ext;

    if not to_ext.startswith("."):
    to_ext = "." + to_ext;

    for root, dirs, files in os.walk(dir):
    for file in files:
    if file.lower().endswith(from_ext):
    no_ext, ext = os.path.splitext(file)
    node = NodeFactory.FromFile(None, os.path.join(root, file))
    try:
    node.Compression = "None"
    node.Export(os.path.join(root, no_ext + to_ext))
    node.Dispose()
    except:
    bboxapi.ShowMessage("Cannot export " + file + " as format " + to_ext, "Error")
    if not include_subfolders:
    break

    LZ77 to ExtendedLZ77 (2017-3-23 - now supports subnodes)
    Code:
    from BrawlBox.API import bboxapi
    from BrawlLib.SSBB.ResourceNodes import *

    import os
    import shutil

    def haslz77(node):
    if node.Compression == "LZ77":
    return True
    if node.GetType().Name == "ARCNode":
    for child in node.Children:
    if haslz77(child):
    return True
    return False

    def modifylz77(node):
    if node.Compression == "LZ77":
    node.Compression = "ExtendedLZ77"
    if node.GetType().Name == "ARCNode":
    for child in node.Children:
    modifylz77(child)
    return

    dir = bboxapi.OpenFolderDialog()
    if dir is not "":
    include_subfolders = bboxapi.ShowYesNoPrompt("Include subfolders?", "Batch conversion")

    ignore_ext = ".original-lz77"

    for root, dirs, files in os.walk(dir):
    for file in files:
    if not file.lower().endswith(ignore_ext):
    try:
    node = NodeFactory.FromFile(None, os.path.join(root, file))
    if node is None:
    continue

    if haslz77(node):
    shutil.copyfile(os.path.join(root, file), os.path.join(root, file + ignore_ext))
    node.Dispose()

    node = NodeFactory.FromFile(None, os.path.join(root, file + ignore_ext));
    modifylz77(node)
    node.Export(os.path.join(root, file))
    node.Dispose()
    except:
    bboxapi.ShowMessage("Cannot export " + file, "Error")
    if not include_subfolders:
    break
    « Last Edit: March 23, 2017, 10:10:43 AM by libertyernie » Logged


    E-scope12
    Extreme Kitten
    *******
    Offline Offline

    Posts: 464


    Turnabout Storm

  • Awards Famous Hacker RAGE!! Hyperactive Contributor

  • View Profile WWW Awards
    « Reply #1 on: February 24, 2017, 02:15:10 PM »


    Nice
    Logged

    E-scope

    [PICTURE REMOVED. Reason: All signature pics must fit a 695x200 frame.]
    [/url]

    Pages: [1]
    Print
    Jump to: