mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
fix skin loading
This commit is contained in:
@@ -29,9 +29,7 @@ rainbow = false
|
|||||||
|
|
||||||
[paths]
|
[paths]
|
||||||
tja_path = ['Songs']
|
tja_path = ['Songs']
|
||||||
video_path = ['Videos']
|
skin = 'PyTaikoGreen'
|
||||||
#You can change this path to Graphics/GreenVer1080 for the 1080p skin
|
|
||||||
graphics_path = 'Graphics/GreenVer'
|
|
||||||
|
|
||||||
[keys]
|
[keys]
|
||||||
exit_key = 'Q'
|
exit_key = 'Q'
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ class AudioEngine:
|
|||||||
self.audio_device_ready = False
|
self.audio_device_ready = False
|
||||||
self.volume_presets = volume_presets
|
self.volume_presets = volume_presets
|
||||||
|
|
||||||
self.sounds_path = Path("Sounds")
|
self.sounds_path = Path(f"Skins/{get_config()["paths"]["skin"]}/Sounds")
|
||||||
|
|
||||||
def set_log_level(self, level: int):
|
def set_log_level(self, level: int):
|
||||||
lib.set_log_level(level) # type: ignore
|
lib.set_log_level(level) # type: ignore
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ class NameplateConfig(TypedDict):
|
|||||||
|
|
||||||
class PathsConfig(TypedDict):
|
class PathsConfig(TypedDict):
|
||||||
tja_path: list[Path]
|
tja_path: list[Path]
|
||||||
video_path: list[Path]
|
skin: Path
|
||||||
graphics_path: Path
|
|
||||||
|
|
||||||
class KeysConfig(TypedDict):
|
class KeysConfig(TypedDict):
|
||||||
exit_key: int
|
exit_key: int
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import os
|
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
|
|
||||||
@@ -73,8 +71,8 @@ class TextureWrapper:
|
|||||||
self.textures: dict[str, dict[str, Texture | FramedTexture]] = dict()
|
self.textures: dict[str, dict[str, Texture | FramedTexture]] = dict()
|
||||||
self.animations: dict[int, BaseAnimation] = dict()
|
self.animations: dict[int, BaseAnimation] = dict()
|
||||||
self.skin_config: dict[str, SkinInfo] = dict()
|
self.skin_config: dict[str, SkinInfo] = dict()
|
||||||
self.graphics_path = Path(get_config()['paths']['graphics_path'])
|
self.graphics_path = Path(f'Skins/{get_config()['paths']['skin']}/Graphics')
|
||||||
self.parent_graphics_path = Path(get_config()['paths']['graphics_path'])
|
self.parent_graphics_path = Path(f'Skins/{get_config()['paths']['skin']}/Graphics')
|
||||||
if not (self.graphics_path / "skin_config.json").exists():
|
if not (self.graphics_path / "skin_config.json").exists():
|
||||||
raise Exception("skin is missing a skin_config.json")
|
raise Exception("skin is missing a skin_config.json")
|
||||||
|
|
||||||
@@ -87,7 +85,7 @@ class TextureWrapper:
|
|||||||
self.screen_scale = self.screen_width / 1280
|
self.screen_scale = self.screen_width / 1280
|
||||||
if "parent" in data["screen"]:
|
if "parent" in data["screen"]:
|
||||||
parent = data["screen"]["parent"]
|
parent = data["screen"]["parent"]
|
||||||
self.parent_graphics_path = Path("Graphics") / parent
|
self.parent_graphics_path = Path("Skins") / parent
|
||||||
parent_data = json.loads((self.parent_graphics_path / "skin_config.json").read_text())
|
parent_data = json.loads((self.parent_graphics_path / "skin_config.json").read_text())
|
||||||
for k, v in parent_data.items():
|
for k, v in parent_data.items():
|
||||||
self.skin_config[k] = SkinInfo(v.get('x', 0) * self.screen_scale, v.get('y', 0) * self.screen_scale, v.get('font_size', 0) * self.screen_scale, v.get('width', 0) * self.screen_scale, v.get('height', 0) * self.screen_scale)
|
self.skin_config[k] = SkinInfo(v.get('x', 0) * self.screen_scale, v.get('y', 0) * self.screen_scale, v.get('font_size', 0) * self.screen_scale, v.get('width', 0) * self.screen_scale, v.get('height', 0) * self.screen_scale)
|
||||||
@@ -189,7 +187,7 @@ class TextureWrapper:
|
|||||||
if screen_name in self.textures and subset in self.textures[screen_name]:
|
if screen_name in self.textures and subset in self.textures[screen_name]:
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
if not os.path.isfile(folder / 'texture.json'):
|
if not (folder / 'texture.json').exists():
|
||||||
raise Exception(f"texture.json file missing from {folder}")
|
raise Exception(f"texture.json file missing from {folder}")
|
||||||
|
|
||||||
with open(folder / 'texture.json') as json_file:
|
with open(folder / 'texture.json') as json_file:
|
||||||
@@ -205,7 +203,7 @@ class TextureWrapper:
|
|||||||
if tex_dir.is_dir():
|
if tex_dir.is_dir():
|
||||||
frames = [ray.LoadTexture(str(frame).encode(encoding)) for frame in sorted(tex_dir.iterdir(),
|
frames = [ray.LoadTexture(str(frame).encode(encoding)) for frame in sorted(tex_dir.iterdir(),
|
||||||
key=lambda x: int(x.stem)) if frame.is_file()]
|
key=lambda x: int(x.stem)) if frame.is_file()]
|
||||||
self.textures[folder.stem][tex_name] = Texture(tex_name, frames, tex_mapping)
|
self.textures[folder.stem][tex_name] = FramedTexture(tex_name, frames, tex_mapping)
|
||||||
self._read_tex_obj_data(tex_mapping, self.textures[folder.stem][tex_name])
|
self._read_tex_obj_data(tex_mapping, self.textures[folder.stem][tex_name])
|
||||||
elif tex_file.is_file():
|
elif tex_file.is_file():
|
||||||
tex = ray.LoadTexture(str(tex_file).encode(encoding))
|
tex = ray.LoadTexture(str(tex_file).encode(encoding))
|
||||||
@@ -230,7 +228,7 @@ class TextureWrapper:
|
|||||||
|
|
||||||
# Load zip files from child screen path only
|
# Load zip files from child screen path only
|
||||||
for zip_file in screen_path.iterdir():
|
for zip_file in screen_path.iterdir():
|
||||||
if zip_file.is_file() and zip_file.suffix == ".zip":
|
if zip_file.is_dir():
|
||||||
self.load_zip(screen_name, zip_file.stem)
|
self.load_zip(screen_name, zip_file.stem)
|
||||||
|
|
||||||
logger.info(f"Screen textures loaded for: {screen_name}")
|
logger.info(f"Screen textures loaded for: {screen_name}")
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ class OutlinedText:
|
|||||||
if reload_font:
|
if reload_font:
|
||||||
codepoint_count = ray.ffi.new('int *', 0)
|
codepoint_count = ray.ffi.new('int *', 0)
|
||||||
codepoints = ray.load_codepoints(''.join(global_data.font_codepoints), codepoint_count)
|
codepoints = ray.load_codepoints(''.join(global_data.font_codepoints), codepoint_count)
|
||||||
global_data.font = ray.load_font_ex(str(Path('Graphics/Modified-DFPKanteiryu-XB.ttf')), 40, codepoints, len(global_data.font_codepoints))
|
global_data.font = ray.load_font_ex(str(Path(f'Skins/{global_data.config["paths"]["skin"]}/Modified-DFPKanteiryu-XB.ttf')), 40, codepoints, len(global_data.font_codepoints))
|
||||||
logger.info(f"Reloaded font with {len(global_data.font_codepoints)} codepoints")
|
logger.info(f"Reloaded font with {len(global_data.font_codepoints)} codepoints")
|
||||||
return global_data.font
|
return global_data.font
|
||||||
|
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class GameScreen(Screen):
|
|||||||
|
|
||||||
def load_hitsounds(self):
|
def load_hitsounds(self):
|
||||||
"""Load the hit sounds"""
|
"""Load the hit sounds"""
|
||||||
sounds_dir = Path("Sounds")
|
sounds_dir = Path(f"Skins/{global_data.config["paths"]["skin"]}/Sounds")
|
||||||
if global_data.hit_sound == -1:
|
if global_data.hit_sound == -1:
|
||||||
audio.load_sound(Path('none.wav'), 'hitsound_don_1p')
|
audio.load_sound(Path('none.wav'), 'hitsound_don_1p')
|
||||||
audio.load_sound(Path('none.wav'), 'hitsound_kat_1p')
|
audio.load_sound(Path('none.wav'), 'hitsound_kat_1p')
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class LoadScreen(Screen):
|
|||||||
global_data.font_codepoints.add(character)
|
global_data.font_codepoints.add(character)
|
||||||
codepoint_count = ray.ffi.new('int *', 0)
|
codepoint_count = ray.ffi.new('int *', 0)
|
||||||
codepoints = ray.load_codepoints(''.join(global_data.font_codepoints), codepoint_count)
|
codepoints = ray.load_codepoints(''.join(global_data.font_codepoints), codepoint_count)
|
||||||
global_data.font = ray.load_font_ex(str(Path('Graphics/Modified-DFPKanteiryu-XB.ttf')), 40, codepoints, len(global_data.font_codepoints))
|
global_data.font = ray.load_font_ex(str(Path(f'Skins/{global_data.config["paths"]["skin"]}/Graphics/Modified-DFPKanteiryu-XB.ttf')), 40, codepoints, len(global_data.font_codepoints))
|
||||||
|
|
||||||
def _load_navigator(self):
|
def _load_navigator(self):
|
||||||
"""Background thread function to load navigator"""
|
"""Background thread function to load navigator"""
|
||||||
|
|||||||
@@ -25,16 +25,11 @@ class State:
|
|||||||
class TitleScreen(Screen):
|
class TitleScreen(Screen):
|
||||||
def __init__(self, name: str):
|
def __init__(self, name: str):
|
||||||
super().__init__(name)
|
super().__init__(name)
|
||||||
#normalize to accept both stings and lists in toml
|
|
||||||
#maybe normalize centrally? but it's used only here
|
|
||||||
vp = global_data.config["paths"]["video_path"]
|
|
||||||
video_paths = [vp] if isinstance(vp, str) else vp
|
|
||||||
self.op_video_list = []
|
self.op_video_list = []
|
||||||
self.attract_video_list = []
|
self.attract_video_list = []
|
||||||
for base in video_paths:
|
base = Path(f"Skins/{global_data.config["paths"]["skin"]}/Videos")
|
||||||
base = Path(base)
|
self.op_video_list += list((base/"op_videos").glob("**/*.mp4"))
|
||||||
self.op_video_list += list((base/"op_videos").glob("**/*.mp4"))
|
self.attract_video_list += list((base/"attract_videos").glob("**/*.mp4"))
|
||||||
self.attract_video_list += list((base/"attract_videos").glob("**/*.mp4"))
|
|
||||||
self.coin_overlay = CoinOverlay()
|
self.coin_overlay = CoinOverlay()
|
||||||
self.allnet_indicator = AllNetIcon()
|
self.allnet_indicator = AllNetIcon()
|
||||||
self.entry_overlay = EntryOverlay()
|
self.entry_overlay = EntryOverlay()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class TwoPlayerGameScreen(GameScreen):
|
|||||||
|
|
||||||
def load_hitsounds(self):
|
def load_hitsounds(self):
|
||||||
"""Load the hit sounds"""
|
"""Load the hit sounds"""
|
||||||
sounds_dir = Path("Sounds")
|
sounds_dir = Path(f"Skins/{global_data.config["paths"]["skin"]}/Sounds")
|
||||||
|
|
||||||
# Load hitsounds for 1P
|
# Load hitsounds for 1P
|
||||||
if global_data.hit_sound[PlayerNum.P1] == -1:
|
if global_data.hit_sound[PlayerNum.P1] == -1:
|
||||||
|
|||||||
Reference in New Issue
Block a user