Skip to content

Commit

Permalink
updated scripts to create minimap and map image
Browse files Browse the repository at this point in the history
  • Loading branch information
Faraphel committed May 24, 2022
1 parent d327f03 commit 1ef62c5
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 274 deletions.
17 changes: 0 additions & 17 deletions scripts/add_my_score_to_old_notation.py

This file was deleted.

166 changes: 0 additions & 166 deletions scripts/discord_add_track.py

This file was deleted.

34 changes: 34 additions & 0 deletions scripts/generate_track_minimap.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Note : use this script from the ../scripts/ directory
"""
import glob
import subprocess
import os
import shutil

from source.wszst import szs
from scripts import obj_to_png


def get_track_minimap(directory: str, sha1: str):
os.makedirs(tmp_dir := f"./scripts/tmp/{sha1}/", exist_ok=True)

szs.extract(f"{directory}{sha1}.szs", tmp_dir + "track.szs")
subprocess.run(["abmatt", "convert", tmp_dir + "track.szs.d/map_model.brres", "to", tmp_dir + "map_model.obj"])

try: img = obj_to_png.render_top_view(obj_file=tmp_dir + "map_model.obj")
except Exception as e:
print(e)
return None
finally:
shutil.rmtree(tmp_dir, ignore_errors=True)

return img


directory = "./file/Track/"

for track in glob.glob("*.szs", root_dir=directory):
sha1 = track.replace(".szs", "")
if (image := get_track_minimap(directory, sha1)) is not None:
image.save(f"./scripts/minimap/{sha1}.png")
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@
driver.fullscreen_window()
time.sleep(5)

driver.execute_script("var element = arguments[0]; element.parentNode.removeChild(element);",
driver.find_element_by_id("Panel"))
driver.execute_script(
"var element = arguments[0]; element.parentNode.removeChild(element);",
driver.find_element_by_id("Panel")
)

tracks = glob.iglob("../file/Track/*.szs")
track = "none.png"
Expand Down
Binary file modified scripts/map preview/chromedriver.exe
Binary file not shown.
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
discord.py
pygame
PyOpenGL
pywavefront
numpy

selenium
keyboard
10 changes: 0 additions & 10 deletions scripts/sort_tracks_abc.py

This file was deleted.

25 changes: 0 additions & 25 deletions scripts/update_discord_track_sha1.py

This file was deleted.

50 changes: 0 additions & 50 deletions scripts/update_track_score_from_discord.py

This file was deleted.

5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"./version",
"./translation.json",

"./assets",
"./tools",
"./source",

sys.exec_prefix + "\\DLLs\\tcl86t.dll",
sys.exec_prefix + "\\DLLs\\tk86t.dll",
Expand All @@ -22,7 +22,6 @@
"includes": ["tkinter", "requests", "PIL", "distutils"],
"include_msvcr": True,
"packages": ["tkinter", "distutils"],
"excludes": ["source"],
}
}

Expand All @@ -37,7 +36,7 @@
license='Apache-2.0',
author='Faraphel',
author_email='[email protected]',
description='Installateur pour Mario Kart Wii Faraphel.',
description='Mario Kart Wii Mod Installer.',
executables=[
Executable(
"./main.pyw",
Expand Down
1 change: 1 addition & 0 deletions source/Game.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ def patch_file(self):
Prepare all files to install the mod (track, bmg text, descriptive image, ...)
"""
try:
os.makedirs(f"./file/", exist_ok=True)
os.makedirs(f"{self.common.ct_config.pack_path}/file/Track-WU8/", exist_ok=True)

max_step = (
Expand Down
2 changes: 2 additions & 0 deletions source/wszst/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
from source.wszst import bmg, ctc, img, lec, wstrt, szs, wit

__all__ = ["bmg", "ctc", "img", "lec", "wstrt", "szs", "wit"]

0 comments on commit 1ef62c5

Please sign in to comment.