Package only quest journal classes and artwork for retained builds
This commit is contained in:
parent
2fff101b68
commit
c35522facd
1 changed files with 97 additions and 12 deletions
|
|
@ -10,6 +10,18 @@ NETWORK_SHA256 = "8a1bd9c2784be4231ffd2f29e9dbcb43a04eb69a5c14966077084a916769fd
|
|||
ASSETS = "assets/dunerealms/"
|
||||
CATALOG = "DuneRealmsGUI/src/main/resources/quest-categories.json"
|
||||
OVERLAY = "network/resource-pack/central/overlay"
|
||||
GUI_PREFIX = "com/dunerealms/gui/"
|
||||
GUI_CHANGED = ("QuestMenus.class", "QuestMenus$JournalView.class")
|
||||
GUI_ADDED = ("QuestCategories.class", "QuestCategories$Category.class", "QuestCategories$Group.class")
|
||||
GUI_CATALOG = "quest-categories.json"
|
||||
GUI_BASELINES = {
|
||||
"e015af5c7f063b4ec2be51ce586376cf3a350be4dfa832032a027e8d9513b429",
|
||||
"19157b96c1802ece522e0560020a93ec87ca78815c7a823406ac61650c999e5d",
|
||||
}
|
||||
MENU_BASELINES = {
|
||||
"75bf2b32df6f516079c8ef53c49e58db7fc415e7306043073ca378988a7c4838",
|
||||
"4f5a9f9c4ddb4f0c76e3d7565aa4ba58064b18ee6675ba9400f855a9329e81fd",
|
||||
}
|
||||
MENU_PREFIX = "menu-art/pack/"
|
||||
|
||||
|
||||
|
|
@ -42,22 +54,42 @@ def artwork(source):
|
|||
return paths
|
||||
|
||||
|
||||
def assemble(source, baseline, output, target, baseline_sha=None):
|
||||
def gui_entries():
|
||||
return [*(GUI_PREFIX + name for name in (*GUI_CHANGED, *GUI_ADDED)), GUI_CATALOG]
|
||||
|
||||
|
||||
def assemble(source, baseline, output, target, baseline_sha=None, donor=None, donor_sha=None):
|
||||
existing = baseline.read_bytes()
|
||||
if digest(existing) != (NETWORK_SHA256 if target == "network" else baseline_sha):
|
||||
accepted = {"network": {NETWORK_SHA256}, "menus": MENU_BASELINES, "gui": GUI_BASELINES}
|
||||
actual = digest(existing)
|
||||
if actual not in accepted[target] or baseline_sha is not None and actual != baseline_sha:
|
||||
raise ValueError("Unexpected retained archive checksum")
|
||||
base = read_archive(existing)
|
||||
added = artwork(source)
|
||||
if target == "menus":
|
||||
if "com/dunerealms/menus/MenuArt.class" not in base:
|
||||
raise ValueError("Expected the retained DuneMenus artwork resolver")
|
||||
added = {MENU_PREFIX + name: contents for name, contents in added.items()}
|
||||
if set(added) & set(base):
|
||||
raise ValueError("Quest artwork already exists in the retained archive")
|
||||
base.update(added)
|
||||
if target == "gui":
|
||||
compiled = donor.read_bytes()
|
||||
if digest(compiled) != donor_sha:
|
||||
raise ValueError("Unexpected quest journal donor checksum")
|
||||
payload = read_archive(compiled)
|
||||
if set(payload) != set(gui_entries()) or payload[GUI_CATALOG] != (source / CATALOG).read_bytes():
|
||||
raise ValueError("Unexpected quest journal donor entries")
|
||||
expected_overlap = {GUI_PREFIX + name for name in GUI_CHANGED}
|
||||
if set(payload) & set(base) != expected_overlap:
|
||||
raise ValueError("Unexpected existing quest journal entries")
|
||||
base.update(payload)
|
||||
count = len(payload)
|
||||
else:
|
||||
added = artwork(source)
|
||||
if target == "menus":
|
||||
if "com/dunerealms/menus/MenuArt.class" not in base:
|
||||
raise ValueError("Expected the retained DuneMenus artwork resolver")
|
||||
added = {MENU_PREFIX + name: contents for name, contents in added.items()}
|
||||
if set(added) & set(base):
|
||||
raise ValueError("Quest artwork already exists in the retained archive")
|
||||
base.update(added)
|
||||
count = len(added)
|
||||
with output.open("xb") as candidate:
|
||||
candidate.write(write_archive(base))
|
||||
print(f"{target}: added {len(added)} files, SHA256 {digest(output.read_bytes())}")
|
||||
print(f"{target}: applied {count} files, SHA256 {digest(output.read_bytes())}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
@ -65,6 +97,8 @@ if __name__ == "__main__":
|
|||
parser.add_argument("source", type=Path)
|
||||
parser.add_argument("baseline", type=Path)
|
||||
parser.add_argument("output", type=Path)
|
||||
parser.add_argument("target", choices=("network", "menus"))
|
||||
parser.add_argument("target", choices=("network", "menus", "gui"))
|
||||
parser.add_argument("--baseline-sha")
|
||||
parser.add_argument("--donor", type=Path)
|
||||
parser.add_argument("--donor-sha")
|
||||
assemble(**vars(parser.parse_args()))
|
||||
|
|
|
|||
Loading…
Reference in a new issue

Staff