Skip to content

Commit

Permalink
Added fonts into localizable files; added some useful
Browse files Browse the repository at this point in the history
  • Loading branch information
caiiiycuk committed Nov 10, 2023
1 parent 57277a1 commit 98ad043
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 8 deletions.
5 changes: 4 additions & 1 deletion MechoSoma/XTool/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace localization {
"resource/m3d/a_red.3ds",
"resource/m3d/t.3ds",
"resource/m3d.scb",
"resource/m3d_font_add.scb",
};
std::string langDir = "/lang/ru/";

Expand All @@ -61,7 +62,9 @@ namespace localization {
std::transform(lower.begin(), lower.end(), lower.begin(), [](unsigned char c){
return std::tolower(c == '\\' ? '/' : c);
});
if (localizedFiles.find(lower) != localizedFiles.end()) {
if (localizedFiles.find(lower) != localizedFiles.end() ||
lower.find("resource/iscreen/fonts/") == 0 ||
lower.find("resource/m3d/font/local") == 0) {
return langDir + input;
}
return input;
Expand Down
39 changes: 39 additions & 0 deletions scripts/compare-dirs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/python3

from sys import argv
from glob import glob
from subprocess import check_output
from os.path import join, isfile

def scan_dir(dir):
files = {}
for file in glob("**/*", recursive=True, root_dir=dir):
path = join(dir, file)
if isfile(path):
md5 = check_output(["md5sum", path]).decode("utf-8").replace("\n", "").split(" ")[0].strip()
files[file.lower()] = md5
return files

missed_files = []
not_mached_files = []
src = scan_dir(argv[1])
dst = scan_dir(argv[2])

for next in src:
if not next in dst:
missed_files.append(next)
elif src[next] != dst[next]:
not_mached_files.append(next + " " + src[next] + " " + dst[next])

for next in dst:
if not next in src:
missed_files.append(next)

print("Missed files:")
for next in missed_files:
print(next)

print("Not matched:")
for next in not_mached_files:
print(next)

40 changes: 33 additions & 7 deletions scripts/copy-2-lang.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

#!/usr/bin/python3

from sys import argv
from os import unlink, makedirs
from os.path import exists, join, dirname
from shutil import copyfile
from os import makedirs
from os.path import exists, join, dirname, isfile
from shutil import copyfile, rmtree
from re import sub, IGNORECASE
from glob import glob

land_deps = [
lang_deps = [
# "./Resource/intro.mpg",
"./Resource/iScreen/iText.scb",
"./Resource/iScreen/iscreen.scb",
Expand Down Expand Up @@ -49,22 +50,47 @@
"./Resource/M3D/a_red.3ds",
"./Resource/M3D/t.3ds",
"./Resource/M3d.scb",

"./Resource/m3d_font_add.scb",
]

fonts_dir = ["./Resource/iScreen/FONTS/", "./Resource/M3D/Font/Local"]

src = argv[1]
dst = argv[2]

if exists(dst):
rmtree(dst)

for file in land_deps:
for file in lang_deps:
src_file = join(src, file)
if not exists(src_file):
src_file = src_file[:-3] + src_file[len(src_file)-3:].upper()

if not exists(src_file):
src_file = sub("iscreen", "iSCREEN", src_file, flags=IGNORECASE)

if not exists(src_file):
src_file = src_file[:-3] + src_file[len(src_file)-3:].lower()

if not exists(src_file):
raise Exception("File " + src_file + " does not exists")

dst_file = join(dst, file)
if not exists(dirname(dst_file)):
makedirs(dirname(dst_file))
copyfile(src_file, dst_file)
unlink(src_file)

for font_dir in fonts_dir:
src_fonts_dir = join(src, font_dir)
if not exists(src_fonts_dir):
src_fonts_dir = sub("iscreen", "iSCREEN", src_fonts_dir, flags=IGNORECASE)
if not exists(src_fonts_dir):
raise Exception("Local fonts dir not found", src_fonts_dir)
for next in glob("**/*", root_dir=src_fonts_dir, recursive=True):
src_file = join(src_fonts_dir, next)
if isfile(src_file):
dst_file = join(dst, font_dir, next)
if not exists(dirname(dst_file)):
makedirs(dirname(dst_file))
copyfile(src_file, dst_file)
10 changes: 10 additions & 0 deletions scripts/unpack-pak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/python3

from glob import glob
from os import unlink
from subprocess import check_call;

for file in glob("**/*.pak", recursive=True):
print("Extracting", file)
check_call(["unzip", "-q", file, "-d", "./"])
unlink(file)

0 comments on commit 98ad043

Please sign in to comment.