config tracks_list is now supported

This commit is contained in:
raphael60650 2021-06-04 11:11:05 +02:00
parent c04bb01e06
commit 93ffdf2b52
3 changed files with 46 additions and 20 deletions

View file

@ -2,8 +2,33 @@ import json
def create_lecode_config(self):
def get_star_text(track):
if "score" in track:
if track["score"] > 0:
return "" * track["score"] + "" * (3 - track["score"]) + " "
return ""
def get_ctfile_text(track):
track_name = track["name"].replace("_", "")
return f' T {track["music"]}; ' + \
f'{track["special"]}; ' + \
f'{"0x01" if track["new"] else "0x00"}; ' + \
f'"{track["name"]}"; ' + \
f'"{get_star_text(track)}{track_name}"; ' + \
f'"-"\n'
def get_rctfile_text(track):
track_name = track["name"].replace("_", "")
return f' T {track["music"]}; ' + \
f'{track["special"]}; ' + \
f'{"0x01" if track["new"] else "0x00"}; ' + \
f'"-"; ' + \
f'"{get_star_text(track)}{track_name}\\n{track["author"]}"; ' + \
f'"-"\n'
with open("./ct_config.json", encoding="utf-8") as f:
ctconfig = json.load(f)
with open("./file/CTFILE.txt", "w", encoding="utf-8") as ctfile, \
open("./file/RCTFILE.txt", "w", encoding="utf-8") as rctfile:
@ -15,7 +40,7 @@ def create_lecode_config(self):
ctfile.write(header)
rctfile.write(header)
for cup in ctconfig["cup"]:
for cup in ctconfig["cup"]: # defined cup section
_cup_config = ctconfig["cup"][cup]
if int(cup) >= 9: # Course qui ne sont ni les originales, ni les courses aléatoires.
cup = f'\nC "{_cup_config["name"]}"\n'
@ -24,21 +49,18 @@ def create_lecode_config(self):
for course in _cup_config["courses"]:
_course_config = _cup_config["courses"][course]
star = ""
if "score" in _course_config:
if _course_config["score"] > 0:
star = ""*_course_config["score"]+""*(3-_course_config["score"])+" "
ctfile.write(get_ctfile_text(_course_config))
rctfile.write(get_rctfile_text(_course_config))
ctfile.write(f' T {_course_config["music"]}; ' +
f'{_course_config["special"]}; ' +
f'{"0x01" if _course_config["new"] else "0x00"}; ' +
f'"{_course_config["name"]}"; ' +
f'"{star}{_course_config["name"]}"; ' +
f'"-"\n')
for i, _course_config in enumerate(ctconfig["tracks_list"]): # undefined cup section
if i % 4 == 0:
cup = f'\nC "TL{i//4}"\n'
ctfile.write(cup)
rctfile.write(cup)
rctfile.write(f' T {_course_config["music"]}; ' +
f'{_course_config["special"]}; ' +
f'{"0x01" if _course_config["new"] else "0x00"}; ' +
f'"-"; ' +
f'"{star}{_course_config["name"]}\\n{_course_config["author"]}"; ' +
f'"-"\n')
ctfile.write(get_ctfile_text(_course_config))
rctfile.write(get_rctfile_text(_course_config))
for _ in range(1, 4-(i%4)): # Complete cup if track are missing
ctfile.write(f' T 13; 147; 0x00; "_"; ""; "-"\n')
rctfile.write(f' T 13; 147; 0x00; "_"; ""; "-"\n')

View file

@ -15,7 +15,6 @@ bmgID_track_move = {
"T71": 0x7015, "T72": 0x701e, "T73": 0x701d, "T74": 0x7011,
"T81": 0x7018, "T82": 0x7016, "T83": 0x7013, "T84": 0x701c,
}
trackname_color = {
"MSRDS ": "\c{green}MSRDS\c{off} ",
"CTR ": "\c{YOR4}CTR\c{off} ",
@ -82,7 +81,6 @@ trackname_color = {
"★☆☆ ": "\c{YOR2}★☆☆ \c{off}",
}
def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1)
@ -90,6 +88,7 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"]
, creationflags=CREATE_NO_WINDOW)
# Common.bmg
bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", gamefile + ".d/message/Common.bmg"],
creationflags=CREATE_NO_WINDOW)
bmgtracks = bmgtracks.decode()
@ -130,6 +129,7 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
"--patch-bmg", "OVERWRITE=" + gamefile + ".d/message/Common.bmg",
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
creationflags=CREATE_NO_WINDOW).decode()
shutil.rmtree(gamefile + ".d")
os.remove("./file/ExtraCommon.txt")

View file

@ -1,14 +1,18 @@
from PIL import Image, ImageFont, ImageDraw
import json
import math
import os
def patch_ct_icon(self):
with open("./ct_config.json", encoding="utf8") as f: config = json.load(f)
ct_icon = Image.new("RGBA", (128, 128 * (len(config["cup"]) + 2)))
cup_number = len(config["cup"]) + math.ceil(len(config["tracks_list"]) / 4)
ct_icon = Image.new("RGBA", (128, 128 * (cup_number + 2)))
files = ["left", "right"]
files.extend(config["cup"].keys())
files.extend(["_"] * ((len(config["tracks_list"]) // 4) + 1))
for i, id in enumerate(files):
if os.path.exists(f"./file/cup_icon/{id}.png"):