mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 19:28:25 +02:00
config tracks_list is now supported
This commit is contained in:
parent
c04bb01e06
commit
93ffdf2b52
3 changed files with 46 additions and 20 deletions
|
@ -2,8 +2,33 @@ import json
|
||||||
|
|
||||||
|
|
||||||
def create_lecode_config(self):
|
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:
|
with open("./ct_config.json", encoding="utf-8") as f:
|
||||||
ctconfig = json.load(f)
|
ctconfig = json.load(f)
|
||||||
|
|
||||||
with open("./file/CTFILE.txt", "w", encoding="utf-8") as ctfile, \
|
with open("./file/CTFILE.txt", "w", encoding="utf-8") as ctfile, \
|
||||||
open("./file/RCTFILE.txt", "w", encoding="utf-8") as rctfile:
|
open("./file/RCTFILE.txt", "w", encoding="utf-8") as rctfile:
|
||||||
|
|
||||||
|
@ -15,7 +40,7 @@ def create_lecode_config(self):
|
||||||
ctfile.write(header)
|
ctfile.write(header)
|
||||||
rctfile.write(header)
|
rctfile.write(header)
|
||||||
|
|
||||||
for cup in ctconfig["cup"]:
|
for cup in ctconfig["cup"]: # defined cup section
|
||||||
_cup_config = ctconfig["cup"][cup]
|
_cup_config = ctconfig["cup"][cup]
|
||||||
if int(cup) >= 9: # Course qui ne sont ni les originales, ni les courses aléatoires.
|
if int(cup) >= 9: # Course qui ne sont ni les originales, ni les courses aléatoires.
|
||||||
cup = f'\nC "{_cup_config["name"]}"\n'
|
cup = f'\nC "{_cup_config["name"]}"\n'
|
||||||
|
@ -24,21 +49,18 @@ def create_lecode_config(self):
|
||||||
|
|
||||||
for course in _cup_config["courses"]:
|
for course in _cup_config["courses"]:
|
||||||
_course_config = _cup_config["courses"][course]
|
_course_config = _cup_config["courses"][course]
|
||||||
star = ""
|
ctfile.write(get_ctfile_text(_course_config))
|
||||||
if "score" in _course_config:
|
rctfile.write(get_rctfile_text(_course_config))
|
||||||
if _course_config["score"] > 0:
|
|
||||||
star = "★"*_course_config["score"]+"☆"*(3-_course_config["score"])+" "
|
|
||||||
|
|
||||||
ctfile.write(f' T {_course_config["music"]}; ' +
|
for i, _course_config in enumerate(ctconfig["tracks_list"]): # undefined cup section
|
||||||
f'{_course_config["special"]}; ' +
|
if i % 4 == 0:
|
||||||
f'{"0x01" if _course_config["new"] else "0x00"}; ' +
|
cup = f'\nC "TL{i//4}"\n'
|
||||||
f'"{_course_config["name"]}"; ' +
|
ctfile.write(cup)
|
||||||
f'"{star}{_course_config["name"]}"; ' +
|
rctfile.write(cup)
|
||||||
f'"-"\n')
|
|
||||||
|
|
||||||
rctfile.write(f' T {_course_config["music"]}; ' +
|
ctfile.write(get_ctfile_text(_course_config))
|
||||||
f'{_course_config["special"]}; ' +
|
rctfile.write(get_rctfile_text(_course_config))
|
||||||
f'{"0x01" if _course_config["new"] else "0x00"}; ' +
|
|
||||||
f'"-"; ' +
|
for _ in range(1, 4-(i%4)): # Complete cup if track are missing
|
||||||
f'"{star}{_course_config["name"]}\\n{_course_config["author"]}"; ' +
|
ctfile.write(f' T 13; 147; 0x00; "_"; ""; "-"\n')
|
||||||
f'"-"\n')
|
rctfile.write(f' T 13; 147; 0x00; "_"; ""; "-"\n')
|
||||||
|
|
|
@ -15,7 +15,6 @@ bmgID_track_move = {
|
||||||
"T71": 0x7015, "T72": 0x701e, "T73": 0x701d, "T74": 0x7011,
|
"T71": 0x7015, "T72": 0x701e, "T73": 0x701d, "T74": 0x7011,
|
||||||
"T81": 0x7018, "T82": 0x7016, "T83": 0x7013, "T84": 0x701c,
|
"T81": 0x7018, "T82": 0x7016, "T83": 0x7013, "T84": 0x701c,
|
||||||
}
|
}
|
||||||
|
|
||||||
trackname_color = {
|
trackname_color = {
|
||||||
"MSRDS ": "\c{green}MSRDS\c{off} ",
|
"MSRDS ": "\c{green}MSRDS\c{off} ",
|
||||||
"CTR ": "\c{YOR4}CTR\c{off} ",
|
"CTR ": "\c{YOR4}CTR\c{off} ",
|
||||||
|
@ -82,7 +81,6 @@ trackname_color = {
|
||||||
"★☆☆ ": "\c{YOR2}★☆☆ \c{off}",
|
"★☆☆ ": "\c{YOR2}★☆☆ \c{off}",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu
|
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
|
bmglang = gamefile[-len("E.txt"):-len(".txt")] # Langue du fichier
|
||||||
self.Progress(statut=self.translate("Patch des textes " + bmglang), add=1)
|
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"]
|
subprocess.call(["./tools/szs/wszst", "EXTRACT", gamefile, "-d", gamefile + ".d", "--overwrite"]
|
||||||
, creationflags=CREATE_NO_WINDOW)
|
, creationflags=CREATE_NO_WINDOW)
|
||||||
|
|
||||||
|
# Common.bmg
|
||||||
bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", gamefile + ".d/message/Common.bmg"],
|
bmgtracks = subprocess.check_output(["./tools/szs/wbmgt", "CAT", gamefile + ".d/message/Common.bmg"],
|
||||||
creationflags=CREATE_NO_WINDOW)
|
creationflags=CREATE_NO_WINDOW)
|
||||||
bmgtracks = bmgtracks.decode()
|
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=" + gamefile + ".d/message/Common.bmg",
|
||||||
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
"--patch-bmg", "OVERWRITE=./file/ExtraCommon.txt"],
|
||||||
creationflags=CREATE_NO_WINDOW).decode()
|
creationflags=CREATE_NO_WINDOW).decode()
|
||||||
|
|
||||||
shutil.rmtree(gamefile + ".d")
|
shutil.rmtree(gamefile + ".d")
|
||||||
os.remove("./file/ExtraCommon.txt")
|
os.remove("./file/ExtraCommon.txt")
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,18 @@
|
||||||
from PIL import Image, ImageFont, ImageDraw
|
from PIL import Image, ImageFont, ImageDraw
|
||||||
import json
|
import json
|
||||||
|
import math
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
def patch_ct_icon(self):
|
def patch_ct_icon(self):
|
||||||
with open("./ct_config.json", encoding="utf8") as f: config = json.load(f)
|
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 = ["left", "right"]
|
||||||
files.extend(config["cup"].keys())
|
files.extend(config["cup"].keys())
|
||||||
|
files.extend(["_"] * ((len(config["tracks_list"]) // 4) + 1))
|
||||||
|
|
||||||
for i, id in enumerate(files):
|
for i, id in enumerate(files):
|
||||||
if os.path.exists(f"./file/cup_icon/{id}.png"):
|
if os.path.exists(f"./file/cup_icon/{id}.png"):
|
||||||
|
|
Loading…
Reference in a new issue