mirror of
https://github.com/Faraphel/Atlas-Install.git
synced 2025-07-03 03:08:29 +02:00
reworked color system, you can now choose a version where track will be highlighted, only prefix and suffix will now be colored
This commit is contained in:
parent
ff98213786
commit
fd5a2a957e
6 changed files with 135 additions and 122 deletions
2
main.pyw
2
main.pyw
|
@ -29,7 +29,7 @@ class ClassApp():
|
|||
from source.patch_ct_icon import patch_ct_icon
|
||||
from source.log_error import log_error
|
||||
from source.get_github_file import get_github_file, check_track_sha1
|
||||
from source.patch_track import load_ct_config, patch_track, patch_autoadd
|
||||
from source.patch_track import load_ct_config, patch_track, patch_autoadd, get_trackctname, get_trackname
|
||||
from source.patch_image import patch_image
|
||||
from source.option import load_option, change_option
|
||||
|
||||
|
|
|
@ -5,29 +5,28 @@ from .definition import *
|
|||
def create_lecode_config(self):
|
||||
try:
|
||||
def get_star_text(track):
|
||||
if "warning" in track: warning = "!" * track["warning"]
|
||||
else: warning = ""
|
||||
|
||||
if "score" in track:
|
||||
if 0 < track["score"] <= 3:
|
||||
return "★" * track["score"] + "☆" * (3 - track["score"]) + warning + " "
|
||||
star_text = "★" * track["score"] + "☆" * (3 - track["score"])
|
||||
return trackname_color[star_text] + " "
|
||||
return ""
|
||||
|
||||
def get_ctfile_text(track, race=False):
|
||||
if race:
|
||||
return f' T {track["music"]}; ' + \
|
||||
f'{track["special"]}; ' + \
|
||||
f'{"0x01" if track["new"] else "0x00"}; ' + \
|
||||
f'"-"; ' + \
|
||||
f'"{get_star_text(track)}{get_trackctname(track=track)}\\n{track["author"]}"; ' + \
|
||||
f'"-"\n'
|
||||
return (f' T {track["music"]}; '
|
||||
f'{track["special"]}; '
|
||||
f'{"0x01" if track["new"] else "0x00"}; '
|
||||
f'"-"; '
|
||||
f'"{get_star_text(track)}{self.get_trackctname(track=track, color=True)}\\n{track["author"]}"; '
|
||||
f'"-"\n')
|
||||
else:
|
||||
return f' T {track["music"]}; ' + \
|
||||
f'{track["special"]}; ' + \
|
||||
f'{"0x01" if track["new"] else "0x00"}; ' + \
|
||||
f'"{get_trackctname(track=track)}"; ' + \
|
||||
f'"{get_star_text(track)}{get_trackctname(track=track)}"; ' + \
|
||||
f'"-"\n'
|
||||
return (f' T {track["music"]}; '
|
||||
f'{track["special"]}; '
|
||||
f'{"0x01" if track["new"] else "0x00"}; '
|
||||
f'"{self.get_trackctname(track=track)}"; '
|
||||
f'"{get_star_text(track)}{self.get_trackctname(track=track, color=True)}"; '
|
||||
f'"-"\n')
|
||||
|
||||
with open("./ct_config.json", encoding="utf-8") as f:
|
||||
ctconfig = json.load(f)
|
||||
|
@ -35,11 +34,11 @@ def create_lecode_config(self):
|
|||
with open("./file/CTFILE.txt", "w", encoding="utf-8") as ctfile, \
|
||||
open("./file/RCTFILE.txt", "w", encoding="utf-8") as rctfile:
|
||||
|
||||
header = "#CT-CODE\n" +\
|
||||
"[RACING-TRACK-LIST]\n" +\
|
||||
"%LE-FLAGS=1\n" +\
|
||||
"%WIIMM-CUP=1\n" +\
|
||||
"N N$SWAP | N$F_WII\n\n"
|
||||
header = ("#CT-CODE\n"
|
||||
"[RACING-TRACK-LIST]\n"
|
||||
"%LE-FLAGS=1\n"
|
||||
"%WIIMM-CUP=1\n"
|
||||
"N N$SWAP | N$F_WII\n\n")
|
||||
ctfile.write(header)
|
||||
rctfile.write(header)
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ get_track_szs = lambda track: f"./file/Track/{track}.szs"
|
|||
region_ID = {
|
||||
"J": "JAP",
|
||||
"P": "PAL",
|
||||
"K": "KOR",
|
||||
"K": "KO",
|
||||
"E": "USA"
|
||||
}
|
||||
|
||||
|
@ -24,19 +24,84 @@ EMPTY_TRACK = ' T T44; T44; 0x00; "_"; ""; "-"\n'
|
|||
with open("./translation.json", encoding="utf-8") as f:
|
||||
translation_dict = json.load(f)
|
||||
|
||||
bmgID_track_move = {
|
||||
"T11": 0x7008, "T12": 0x7001, "T13": 0x7002, "T14": 0x7004,
|
||||
"T21": 0x7000, "T22": 0x7005, "T23": 0x7006, "T24": 0x7007,
|
||||
"T31": 0x7009, "T32": 0x700f, "T33": 0x700b, "T34": 0x7003,
|
||||
"T41": 0x700e, "T42": 0x700a, "T43": 0x700c, "T44": 0x700d,
|
||||
|
||||
def get_trackname(name=None, prefix=None, suffix=None, track=None):
|
||||
if track:
|
||||
name = track["name"]
|
||||
if "prefix" in track: prefix = track["prefix"]
|
||||
if "suffix" in track: suffix = track["suffix"]
|
||||
if prefix: name = prefix + " " + name
|
||||
if suffix: name = name + " (" + suffix + ")"
|
||||
return name
|
||||
"T51": 0x7010, "T52": 0x7014, "T53": 0x7019, "T54": 0x701a,
|
||||
"T61": 0x701b, "T62": 0x701f, "T63": 0x7017, "T64": 0x7012,
|
||||
"T71": 0x7015, "T72": 0x701e, "T73": 0x701d, "T74": 0x7011,
|
||||
"T81": 0x7018, "T82": 0x7016, "T83": 0x7013, "T84": 0x701c,
|
||||
}
|
||||
trackname_color = {
|
||||
"MSRDS": "\\\\c{green}MSRDS\\\\c{off}",
|
||||
"CT": "\\\\c{YOR4}CTR\\\\c{off}",
|
||||
"CTT": "\\\\c{YOR5}CTTR\\\\c{off}",
|
||||
"CN": "\\\\c{YOR5}CNR\\\\c{off}",
|
||||
"DK": "\\\\c{YOR6}DKR\\\\c{off}",
|
||||
"LCP": "\\\\c{green}LCP\\\\c{off}",
|
||||
"LEGO-": "\\\\c{red2}LEGO-R\\\\c{off}",
|
||||
"MP9": "\\\\c{YOR0}MP9\\\\c{off}",
|
||||
"MSUSA": "\\\\c{green}MSUSA\\\\c{off}",
|
||||
"FZMV": "\\\\c{YOR2}FZMV\\\\c{off}",
|
||||
"KA": "\\\\c{green}KAR\\\\c{off}",
|
||||
"KO": "\\\\c{YOR5}KO\\\\c{off}",
|
||||
"FZ": "\\\\c{YOR2}FZ\\\\c{off}",
|
||||
"RV": "\\\\c{white}RV\\\\c{off}",
|
||||
"SADX": "\\\\c{blue2}SADX\\\\c{off}",
|
||||
"SC": "\\\\c{YOR2}SCR\\\\c{off}",
|
||||
"SH": "\\\\c{red}SH\\\\c{off}",
|
||||
"SM64": "\\\\c{red1}SM64\\\\c{off}",
|
||||
"SMB1": "\\\\c{red2}SMB1\\\\c{off}",
|
||||
"SMB2": "\\\\c{red3}SMB2\\\\c{off}",
|
||||
"SSBB": "\\\\c{red4}SSBB\\\\c{off}",
|
||||
"SMS": "\\\\c{YOR6}SMS\\\\c{off}",
|
||||
"SMO": "\\\\c{YOR7}SMO\\\\c{off}",
|
||||
"VVVVVV": "\\\\c{blue}VVVVVV\\\\c{off}",
|
||||
"WF": "\\\\c{green}WF\\\\c{off}",
|
||||
"WP": "\\\\c{yellow}WP\\\\c{off}",
|
||||
"Zelda OoT": "\\\\c{green}Zelda OoT\\\\c{off}",
|
||||
"Zelda TP": "\\\\c{green}Zelda TP\\\\c{off}",
|
||||
"Zelda WW": "\\\\c{green}Zelda WW\\\\c{off}",
|
||||
"PMW": "\\\\c{yellow}PMWR\\\\c{off}",
|
||||
"SH": "\\\\c{green}SHR\\\\c{off}",
|
||||
"SK64": "\\\\c{green}SK64\\\\c{off}",
|
||||
"SMG": "\\\\c{red2}SMG\\\\c{off}",
|
||||
"Spyro 1": "\\\\c{blue}Spyro 1\\\\c{off}",
|
||||
|
||||
"Aléatoire:": "\\\\c{white}Aléatoire:",
|
||||
"Random:": "\\\\c{white}Random:",
|
||||
"Zufällig:": "\\\\c{white}Zufällig:",
|
||||
"Casuale:": "\\\\c{white}Casuale:",
|
||||
"Aleatorio:": "\\\\c{white}Aleatorio:",
|
||||
|
||||
def get_trackctname(name=None, prefix=None, suffix=None, track=None):
|
||||
return get_trackname(name=name, prefix=prefix, suffix=suffix, track=track).replace("_", "")
|
||||
"Wii U": "\\\\c{red4}Wii U\\\\c{off}",
|
||||
"Wii": "\\\\c{blue}Wii\\\\c{off}",
|
||||
|
||||
"3DS": "\\\\c{YOR3}3DS\\\\c{off}",
|
||||
"DS": "\\\\c{white}DS\\\\c{off}",
|
||||
"GCN": "\\\\c{blue2}GCN\\\\c{off}",
|
||||
"GBA": "\\\\c{blue1}GBA\\\\c{off}",
|
||||
"N64": "\\\\c{red}N64\\\\c{off}",
|
||||
"SNES": "\\\\c{green}SNES\\\\c{off}",
|
||||
"RMX": "\\\\c{YOR4}RMX\\\\c{off}",
|
||||
"MKT": "\\\\c{YOR5}MKT\\\\c{off}",
|
||||
"GP": "\\\\c{YOR6}GP\\\\c{off}",
|
||||
|
||||
"Boost": "\\\\c{YOR3}Boost\\\\c{off}",
|
||||
|
||||
"★★★": "\\\\c{YOR2}★★★\\\\c{off}",
|
||||
"★★☆": "\\\\c{YOR2}★★☆\\\\c{off}",
|
||||
"★☆☆": "\\\\c{YOR2}★☆☆\\\\c{off}",
|
||||
"★★★!": "\\\\c{YOR4}★★★\\\\c{off}",
|
||||
"★★☆!": "\\\\c{YOR4}★★☆\\\\c{off}",
|
||||
"★☆☆!": "\\\\c{YOR4}★☆☆\\\\c{off}",
|
||||
"★★★!!": "\\\\c{YOR6}★★★\\\\c{off}",
|
||||
"★★☆!!": "\\\\c{YOR6}★★☆\\\\c{off}",
|
||||
"★☆☆!!": "\\\\c{YOR6}★☆☆\\\\c{off}",
|
||||
}
|
||||
|
||||
|
||||
def filecopy(src, dst):
|
||||
|
|
|
@ -7,86 +7,6 @@ from .definition import *
|
|||
|
||||
def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /files/Scene/UI/ du jeu
|
||||
try:
|
||||
|
||||
bmgID_track_move = {
|
||||
"T11": 0x7008, "T12": 0x7001, "T13": 0x7002, "T14": 0x7004,
|
||||
"T21": 0x7000, "T22": 0x7005, "T23": 0x7006, "T24": 0x7007,
|
||||
"T31": 0x7009, "T32": 0x700f, "T33": 0x700b, "T34": 0x7003,
|
||||
"T41": 0x700e, "T42": 0x700a, "T43": 0x700c, "T44": 0x700d,
|
||||
|
||||
"T51": 0x7010, "T52": 0x7014, "T53": 0x7019, "T54": 0x701a,
|
||||
"T61": 0x701b, "T62": 0x701f, "T63": 0x7017, "T64": 0x7012,
|
||||
"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} ",
|
||||
"CTTR ": "\c{YOR5}CTTR\c{off} ",
|
||||
"CNR ": "\c{YOR5}CNR\c{off} ",
|
||||
"DKR ": "\c{YOR6}DKR\c{off} ",
|
||||
"LCP ": "\c{green}LCP\c{off} ",
|
||||
"LEGO-R ": "\c{red2}LEGO-R\c{off} ",
|
||||
"MP9 ": "\c{YOR0}MP9\c{off} ",
|
||||
"MSUSA ": "\c{green}MSUSA\c{off} ",
|
||||
"FZMV ": "\c{YOR2}FZMV\c{off} ",
|
||||
"KAR ": "\c{green}KAR\c{off} ",
|
||||
"KO ": "\c{YOR5}KO\c{off} ",
|
||||
"FZ ": "\c{YOR2}FZ\c{off} ",
|
||||
"RV ": "\c{white}RV\c{off} ",
|
||||
"SADX ": "\c{blue2}SADX\c{off} ",
|
||||
"SCR ": "\c{YOR2}SCR\c{off} ",
|
||||
"SH ": "\c{red}SH\c{off} ",
|
||||
"SM64 ": "\c{red1}SM64\c{off} ",
|
||||
"SMB1 ": "\c{red2}SMB1\c{off} ",
|
||||
"SMB2 ": "\c{red3}SMB2\c{off} ",
|
||||
"SSBB ": "\c{red4}SSBB\c{off} ",
|
||||
"SMS ": "\c{YOR6}SMS\c{off} ",
|
||||
"SMO ": "\c{YOR7}SMO\c{off} ",
|
||||
"VVVVVV ": "\c{blue}VVVVVV\c{off} ",
|
||||
"WF ": "\c{green}WF\c{off} ",
|
||||
"WP ": "\c{yellow}WP\c{off} ",
|
||||
"Zelda OoT ": "\c{green}Zelda OoT\c{off} ",
|
||||
"Zelda TP ": "\c{green}Zelda TP\c{off} ",
|
||||
"Zelda WW ": "\c{green}Zelda WW\c{off} ",
|
||||
"PMWR ": "\c{yellow}PMWR\c{off} ",
|
||||
"SHR ": "\c{green}SHR\c{off} ",
|
||||
"SK64 ": "\c{green}SK64\c{off} ",
|
||||
"SMG ": "\c{red2}SMG\c{off} ",
|
||||
"Spyro 1 ": "\c{blue}Spyro 1\c{off} ",
|
||||
|
||||
"Aléatoire: ": "\c{white}Aléatoire: ",
|
||||
"Random: ": "\c{white}Random: ",
|
||||
"Zufällig: ": "\c{white}Zufällig: ",
|
||||
"Casuale: ": "\c{white}Casuale: ",
|
||||
"Aleatorio: ": "\c{white}Aleatorio: ",
|
||||
|
||||
"Wii U ": "WiiU ",
|
||||
"Wii ": "\c{blue}Wii\c{off} ",
|
||||
"WiiU ": "\c{red4}Wii U\c{off} ", # Permet d'éviter que Wii et Wii U se mélange
|
||||
|
||||
"3DS ": "\c{YOR3}3DS\c{off} ",
|
||||
"DS ": "\c{white}DS\c{off} ",
|
||||
"GCN ": "\c{blue2}GCN\c{off} ",
|
||||
"GBA ": "\c{blue1}GBA\c{off} ",
|
||||
"N64 ": "\c{red}N64\c{off} ",
|
||||
"SNES ": "\c{green}SNES\c{off} ",
|
||||
"RMX ": "\c{YOR4}RMX\c{off} ",
|
||||
"MKT ": "\c{YOR5}MKT\c{off} ",
|
||||
"GP ": "\c{YOR6}GP\c{off} ",
|
||||
|
||||
"(Boost)": "\c{YOR3}(Boost)\c{off}",
|
||||
|
||||
"★★★ ": "\c{YOR2}★★★\c{off} ",
|
||||
"★★☆ ": "\c{YOR2}★★☆\c{off} ",
|
||||
"★☆☆ ": "\c{YOR2}★☆☆\c{off} ",
|
||||
"★★★! ": "\c{YOR4}★★★\c{off} ",
|
||||
"★★☆! ": "\c{YOR4}★★☆\c{off} ",
|
||||
"★☆☆! ": "\c{YOR4}★☆☆\c{off} ",
|
||||
"★★★!! ": "\c{YOR6}★★★\c{off} ",
|
||||
"★★☆!! ": "\c{YOR6}★★☆\c{off} ",
|
||||
"★☆☆!! ": "\c{YOR6}★☆☆\c{off} ",
|
||||
}
|
||||
NINTENDO_CWF_REPLACE = "Wiimmfi"
|
||||
MAINMENU_REPLACE = f"MKWFaraphel {self.VERSION}"
|
||||
menu_replacement = {
|
||||
|
@ -138,7 +58,8 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
|
|||
if "T" in bmgtrack[:bmgtrack.find("=")]:
|
||||
sTid = bmgtrack.find("T")
|
||||
Tid = bmgtrack[sTid:sTid + 3]
|
||||
if Tid[1] in "1234": prefix = "Wii " # Si la course est original à la wii
|
||||
if Tid[1] in "1234":
|
||||
prefix = trackname_color["Wii"] + " " # Si la course est original à la wii
|
||||
Tid = hex(bmgID_track_move[Tid])[2:]
|
||||
|
||||
else: # Arena
|
||||
|
@ -165,16 +86,17 @@ def patch_bmg(self, gamefile): # gamefile est le fichier .szs trouvé dans le /
|
|||
os.remove("./file/tmp/Common.bmg")
|
||||
os.remove("./file/ExtraCommon.txt")
|
||||
|
||||
def finalise(file, bmgtext, replacement_list):
|
||||
for text, colored_text in replacement_list.items(): bmgtext = bmgtext.replace(text, colored_text)
|
||||
def finalise(file, bmgtext, replacement_list=None):
|
||||
if replacement_list:
|
||||
for text, colored_text in replacement_list.items(): bmgtext = bmgtext.replace(text, colored_text)
|
||||
with open(file, "w", encoding="utf-8") as f: f.write(bmgtext)
|
||||
subprocess.run(["./tools/szs/wbmgt", "ENCODE", get_nodir(file), "--overwrite"],
|
||||
creationflags=CREATE_NO_WINDOW, cwd=get_dir(file))
|
||||
os.remove(file)
|
||||
|
||||
finalise(f"./file/Menu_{bmglang}.txt", bmgmenu, menu_replacement)
|
||||
finalise(f"./file/Common_{bmglang}.txt", bmgcommon, trackname_color)
|
||||
finalise(f"./file/Common_R{bmglang}.txt", rbmgcommon, trackname_color)
|
||||
finalise(f"./file/Common_{bmglang}.txt", bmgcommon)
|
||||
finalise(f"./file/Common_R{bmglang}.txt", rbmgcommon)
|
||||
|
||||
except:
|
||||
self.log_error()
|
||||
|
|
|
@ -9,8 +9,7 @@ def patch_file(self):
|
|||
try:
|
||||
if not(os.path.exists("./file/Track-WU8/")): os.makedirs("./file/Track-WU8/")
|
||||
with open("./convert_file.json") as f: fc = json.load(f)
|
||||
tracks, total_track = self.count_track()
|
||||
max_step = len(fc["img"]) + total_track + 3 + len("EGFIS")
|
||||
max_step = len(fc["img"]) + self.TOTAL_TRACK + 3 + len("EGFIS")
|
||||
|
||||
self.Progress(show=True, indeter=False, statut=self.translate("Converting files"), max=max_step, step=0)
|
||||
self.Progress(statut=self.translate("Configurating LE-CODE"), add=1)
|
||||
|
@ -23,7 +22,7 @@ def patch_file(self):
|
|||
for file in glob.glob(self.path_mkwf+"/files/Scene/UI/MenuSingle_?.szs"): self.patch_bmg(file)
|
||||
# MenuSingle could be any other file, Common and Menu are all the same in all other files.
|
||||
self.patch_autoadd()
|
||||
if self.patch_track(tracks, total_track) != 0: return
|
||||
if self.patch_track() != 0: return
|
||||
|
||||
self.button_install_mod.grid(row=2, column=1, columnspan=2, sticky="NEWS")
|
||||
self.button_install_mod.config(text=self.translate("Install mod", " (v", self.VERSION, ")"))
|
||||
|
|
|
@ -6,6 +6,35 @@ import json
|
|||
import os
|
||||
|
||||
|
||||
def get_trackname(self, track, color=False):
|
||||
hl_prefix, hl_suffix = "", ""
|
||||
if color:
|
||||
if track.get("since_version") == self.stringvar_mark_track_from_version.get():
|
||||
hl_prefix, hl_suffix = "\\\\c{blue1}", "\\\\c{off}"
|
||||
|
||||
name = track["name"]
|
||||
name = hl_prefix + name + hl_suffix
|
||||
|
||||
if "prefix" in track:
|
||||
prefix = track["prefix"]
|
||||
if color:
|
||||
if prefix in trackname_color:
|
||||
prefix = trackname_color[prefix]
|
||||
name = prefix + " " + name
|
||||
if "suffix" in track:
|
||||
suffix = track["suffix"]
|
||||
if color:
|
||||
if suffix in trackname_color:
|
||||
suffix = trackname_color[suffix]
|
||||
name = name + " (" + suffix + ")"
|
||||
|
||||
return name
|
||||
|
||||
|
||||
def get_trackctname(self, *args, **kwargs):
|
||||
return self.get_trackname(*args, **kwargs).replace("_", "")
|
||||
|
||||
|
||||
def load_ct_config(self):
|
||||
tracks = []
|
||||
with open("./ct_config.json", encoding="utf-8") as f: ctconfig = json.load(f)
|
||||
|
@ -43,9 +72,8 @@ def patch_track(self):
|
|||
process_list = {}
|
||||
error_count, error_max = 0, 3
|
||||
|
||||
|
||||
def add_process(track):
|
||||
track_file = get_trackname(track=track)
|
||||
track_file = self.get_trackname(track=track)
|
||||
nonlocal error_count, error_max, process_list
|
||||
|
||||
process_list[track_file] = None # Used for
|
||||
|
|
Loading…
Reference in a new issue