mirror of
https://github.com/TwilitRealm/dusklight
synced 2026-06-02 01:30:00 -04:00
@@ -3,6 +3,7 @@ import sys
|
||||
import libarc
|
||||
from pathlib import Path
|
||||
import libyaz0
|
||||
import libstage
|
||||
|
||||
"""
|
||||
Extracts the game assets and stores them in the game folder
|
||||
@@ -133,14 +134,18 @@ def writeFolder(parsedFstBin, i):
|
||||
Use the parsed fst.bin contents to write assets to file
|
||||
"""
|
||||
|
||||
convertDefinitions = [
|
||||
{
|
||||
"extension": ".arc",
|
||||
convertDefinitions = {
|
||||
".arc": {
|
||||
"function": libarc.extract_to_directory,
|
||||
"exceptions": ["archive/dat/speakerse.arc"],
|
||||
},
|
||||
".dzs": {
|
||||
"function": libstage.extract_to_json
|
||||
},
|
||||
".dzr": {
|
||||
"function": libstage.extract_to_json
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
||||
def writeFile(name, data):
|
||||
if data[0:4] == bytes("Yaz0", "ascii"):
|
||||
@@ -151,14 +156,10 @@ def writeFile(name, data):
|
||||
extractDef = None
|
||||
splitName = os.path.splitext(name)
|
||||
ext = splitName[1]
|
||||
for extractData in convertDefinitions:
|
||||
if ext == extractData["extension"]:
|
||||
extractDef = extractData
|
||||
if extractData["exceptions"] != None:
|
||||
for exception in extractData["exceptions"]:
|
||||
if str(name) == exception:
|
||||
extractDef = None
|
||||
break
|
||||
if ext in convertDefinitions:
|
||||
extractDef = convertDefinitions[ext]
|
||||
if "exceptions" in extractDef and str(name) in extractDef["exceptions"]:
|
||||
extractDef = None
|
||||
|
||||
if extractDef == None:
|
||||
file = open(name, "wb")
|
||||
|
||||
@@ -431,6 +431,8 @@ def convert_dir_to_arc(sourceDir, convertFunction):
|
||||
dirOffset = dirOffset + dirOffsetPadding
|
||||
stringTableOffset = dirOffset + (len(dirs) * 20)
|
||||
stringTablePadding = 0x20 - (stringTableOffset % 0x20)
|
||||
if stringTablePadding == 0x20:
|
||||
stringTablePadding = 0
|
||||
stringTableOffset = stringTableOffset + stringTablePadding
|
||||
stringTableLen = len(bytearray(stringTable, "shift-jis"))
|
||||
fileOffset = stringTableOffset + stringTableLen
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .libstage import *
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,6 +5,7 @@ import extract_game_assets
|
||||
from pathlib import Path
|
||||
import libyaz0
|
||||
import libarc
|
||||
import libstage
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@@ -20,37 +21,48 @@ def getMaxDateFromDir(path):
|
||||
|
||||
convertDefinitions = [
|
||||
{
|
||||
"sourceExtension": ".arc",
|
||||
"sourceExtension": "arc",
|
||||
"destExtension": ".arc",
|
||||
"convertFunction": libarc.convert_dir_to_arc,
|
||||
"exceptions": ["game/files/res/Object/HomeBtn.c.arc/archive/dat/speakerse.arc"],
|
||||
},
|
||||
{
|
||||
"sourceExtension": "dzs.json",
|
||||
"destExtension": ".dzs",
|
||||
"convertFunction": libstage.package_from_json,
|
||||
},
|
||||
{
|
||||
"sourceExtension": "dzr.json",
|
||||
"destExtension": ".dzr",
|
||||
"convertFunction": libstage.package_from_json,
|
||||
}
|
||||
]
|
||||
|
||||
yaz0CompressFunction = libyaz0.compress
|
||||
|
||||
def convertEntry(file, path, destPath, returnData):
|
||||
split = os.path.splitext(file)
|
||||
split = str(file).split(".")
|
||||
mustBeCompressed = False
|
||||
destFileName = file
|
||||
if split[0].split(".")[-1] == "c":
|
||||
destFileName = split[0][0:-2] + split[-1]
|
||||
destFileName = str(file)
|
||||
if len(split)>1 and split[1] == "c":
|
||||
destFileName = ".".join([split[0]] + split[2:])
|
||||
mustBeCompressed = True
|
||||
sourceExtension = split[-1]
|
||||
# print(destFileName)
|
||||
sourceExtension = ".".join(destFileName.split(".")[1:])
|
||||
data = None
|
||||
|
||||
extractDef = None
|
||||
for extractData in convertDefinitions:
|
||||
if sourceExtension == extractData["sourceExtension"]:
|
||||
extractDef = extractData
|
||||
if extractData["exceptions"] != None:
|
||||
if "exceptions" in extractData:
|
||||
for exception in extractData["exceptions"]:
|
||||
if str(path / file) == exception:
|
||||
extractDef = None
|
||||
break
|
||||
|
||||
if extractDef != None:
|
||||
destFileName = os.path.splitext(destFileName)[0] + extractDef["destExtension"]
|
||||
destFileName = destFileName.split(".")[0] + extractDef["destExtension"]
|
||||
|
||||
targetTime = 0
|
||||
if destPath != None and os.path.exists(destPath / destFileName):
|
||||
|
||||
Reference in New Issue
Block a user