mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
update paths to pathlib for linux/mac support
This commit is contained in:
10
config.toml
10
config.toml
@@ -7,13 +7,13 @@ tja_path = 'Songs'
|
||||
video_path = 'Videos'
|
||||
|
||||
[keybinds]
|
||||
left_kat = ['E','R']
|
||||
left_don = ['F','K']
|
||||
right_don = ['J','D']
|
||||
right_kat = ['I','U']
|
||||
left_kat = ['D']
|
||||
left_don = ['F']
|
||||
right_don = ['J']
|
||||
right_kat = ['K']
|
||||
|
||||
[audio]
|
||||
device_type = 'ASIO'
|
||||
device_type = 'WASAPI'
|
||||
asio_buffer = 6
|
||||
|
||||
[video]
|
||||
|
||||
1
install.bat
Normal file
1
install.bat
Normal file
@@ -0,0 +1 @@
|
||||
pip install -r requirements.txt
|
||||
12
libs/tja.py
12
libs/tja.py
@@ -1,5 +1,6 @@
|
||||
import math
|
||||
from collections import deque
|
||||
from pathlib import Path
|
||||
|
||||
from libs.utils import get_pixels_per_frame, strip_comments
|
||||
|
||||
@@ -28,9 +29,9 @@ def calculate_base_score(play_note_list: deque[dict]) -> int:
|
||||
class TJAParser:
|
||||
def __init__(self, path: str):
|
||||
#Defined on startup
|
||||
self.folder_path = path
|
||||
self.folder_name = self.folder_path.split('\\')[-1]
|
||||
self.file_path = f'{self.folder_path}\\{self.folder_name}.tja'
|
||||
self.folder_path = Path(path)
|
||||
self.folder_name = self.folder_path.name
|
||||
self.file_path = self.folder_path / f"{self.folder_name}.tja"
|
||||
|
||||
#Defined on file_to_data()
|
||||
self.data = []
|
||||
@@ -40,7 +41,7 @@ class TJAParser:
|
||||
self.title_ja = ''
|
||||
self.subtitle = ''
|
||||
self.subtitle_ja = ''
|
||||
self.wave = f'{self.folder_path}\\'
|
||||
self.wave = self.folder_path / ""
|
||||
self.offset = 0
|
||||
self.demo_start = 0
|
||||
self.course_data = dict()
|
||||
@@ -81,7 +82,8 @@ class TJAParser:
|
||||
elif 'BPM' in item:
|
||||
self.bpm = float(item.split(':')[1])
|
||||
elif 'WAVE' in item:
|
||||
self.wave += str(item.split(':')[1])
|
||||
filename = item.split(':')[1].strip()
|
||||
self.wave = self.folder_path / filename
|
||||
elif 'OFFSET' in item:
|
||||
self.offset = float(item.split(':')[1])
|
||||
elif 'DEMOSTART' in item:
|
||||
|
||||
@@ -3,6 +3,7 @@ import tempfile
|
||||
import time
|
||||
import zipfile
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import pyray as ray
|
||||
@@ -12,14 +13,16 @@ import tomllib
|
||||
|
||||
def get_zip_filenames(zip_path: str) -> list[str]:
|
||||
result = []
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
new_path = Path(zip_path)
|
||||
with zipfile.ZipFile(new_path, 'r') as zip_ref:
|
||||
file_list = zip_ref.namelist()
|
||||
for file_name in file_list:
|
||||
result.append(file_name)
|
||||
return result
|
||||
|
||||
def load_image_from_zip(zip_path: str, filename: str) -> ray.Image:
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
new_path = Path(zip_path)
|
||||
with zipfile.ZipFile(new_path, 'r') as zip_ref:
|
||||
with zip_ref.open(filename) as image_file:
|
||||
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file:
|
||||
temp_file.write(image_file.read())
|
||||
@@ -29,7 +32,8 @@ def load_image_from_zip(zip_path: str, filename: str) -> ray.Image:
|
||||
return image
|
||||
|
||||
def load_texture_from_zip(zip_path: str, filename: str) -> ray.Texture:
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
new_path = Path(zip_path)
|
||||
with zipfile.ZipFile(new_path, 'r') as zip_ref:
|
||||
with zip_ref.open(filename) as image_file:
|
||||
with tempfile.NamedTemporaryFile(delete=False, suffix='.png') as temp_file:
|
||||
temp_file.write(image_file.read())
|
||||
@@ -40,7 +44,8 @@ def load_texture_from_zip(zip_path: str, filename: str) -> ray.Texture:
|
||||
|
||||
def load_all_textures_from_zip(zip_path: str) -> dict[str, list[ray.Texture]]:
|
||||
result_dict = dict()
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
new_path = Path(zip_path)
|
||||
with zipfile.ZipFile(new_path, 'r') as zip_ref:
|
||||
files = zip_ref.namelist()
|
||||
for file in files:
|
||||
with zip_ref.open(file) as image_file:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import bisect
|
||||
import math
|
||||
from collections import deque
|
||||
from pathlib import Path
|
||||
|
||||
import pyray as ray
|
||||
|
||||
@@ -139,11 +140,11 @@ class GameScreen:
|
||||
self.result_transition_2 = load_texture_from_zip('Graphics\\lumendata\\enso_result.zip', 'retry_game_img00126.png')
|
||||
|
||||
def load_sounds(self):
|
||||
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav')
|
||||
self.sound_kat = audio.load_sound('Sounds\\inst_00_katsu.wav')
|
||||
self.sound_balloon_pop = audio.load_sound('Sounds\\balloon_pop.wav')
|
||||
|
||||
self.sound_result_transition = audio.load_sound('Sounds\\result\\VO_RESULT [1].ogg')
|
||||
sounds_dir = Path("Sounds")
|
||||
self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
|
||||
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
|
||||
self.sound_balloon_pop = audio.load_sound(str(sounds_dir / "balloon_pop.wav"))
|
||||
self.sound_result_transition = audio.load_sound(str(sounds_dir / "result" / "VO_RESULT [1].ogg"))
|
||||
|
||||
def init_tja(self, song: str, difficulty: int):
|
||||
self.load_textures()
|
||||
@@ -170,7 +171,7 @@ class GameScreen:
|
||||
global_data.song_title = self.tja.title
|
||||
|
||||
self.player_1 = Player(self, 1, difficulty, get_config()["general"]["judge_offset"])
|
||||
self.song_music = audio.load_sound(self.tja.wave)
|
||||
self.song_music = audio.load_sound(str(Path(self.tja.wave)))
|
||||
self.start_ms = (get_current_ms() - self.tja.offset*1000) + self.start_delay
|
||||
|
||||
audio.play_sound(self.song_music)
|
||||
@@ -618,7 +619,7 @@ class Player:
|
||||
self.draw_balloon(game_screen, note, position, i)
|
||||
else:
|
||||
self.draw_note(game_screen, note_type, position, 255, note['se_note'])
|
||||
ray.draw_text(str(i), position+64, 192, 25, ray.GREEN)
|
||||
#ray.draw_text(str(i), position+64, 192, 25, ray.GREEN)
|
||||
|
||||
def draw_gauge(self, game_screen: GameScreen):
|
||||
ray.draw_texture(game_screen.textures['gage_don_1p_hard'][0], 327, 128, ray.WHITE)
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pyray as ray
|
||||
|
||||
from libs.animation import Animation
|
||||
@@ -21,8 +23,10 @@ class ResultScreen:
|
||||
def __init__(self, width: int, height: int):
|
||||
self.width = width
|
||||
self.height = height
|
||||
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav')
|
||||
self.bgm = audio.load_sound('Sounds\\result\\JINGLE_SEISEKI [1].ogg')
|
||||
sounds_dir = Path("Sounds")
|
||||
self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
|
||||
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
|
||||
self.bgm = audio.load_sound(str(sounds_dir / "result" / "JINGLE_SEISEKI [1].ogg"))
|
||||
|
||||
zip_file = 'Graphics\\lumendata\\enso_result.zip'
|
||||
self.textures = load_all_textures_from_zip(zip_file)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pyray as ray
|
||||
|
||||
@@ -17,8 +18,9 @@ class SongSelectScreen:
|
||||
self.selected_song = 0
|
||||
self.selected_difficulty = 0
|
||||
self.selected_index = 0
|
||||
self.sound_don = audio.load_sound('Sounds\\inst_00_don.wav')
|
||||
self.sound_kat = audio.load_sound('Sounds\\inst_00_katsu.wav')
|
||||
sounds_dir = Path("Sounds")
|
||||
self.sound_don = audio.load_sound(str(sounds_dir / "inst_00_don.wav"))
|
||||
self.sound_kat = audio.load_sound(str(sounds_dir / "inst_00_katsu.wav"))
|
||||
for dirpath, dirnames, filenames in os.walk(f'{get_config()["paths"]["tja_path"]}'):
|
||||
for filename in filenames:
|
||||
if filename.endswith(".tja"):
|
||||
|
||||
@@ -36,10 +36,13 @@ class TitleScreen:
|
||||
def load_textures(self):
|
||||
self.textures = load_all_textures_from_zip('Graphics\\lumendata\\attract\\keikoku.zip')
|
||||
|
||||
self.sound_bachi_swipe = audio.load_sound('Sounds\\title\\SE_ATTRACT_2.ogg')
|
||||
self.sound_bachi_hit = audio.load_sound('Sounds\\title\\SE_ATTRACT_3.ogg')
|
||||
self.sound_warning_message = audio.load_sound('Sounds\\title\\VO_ATTRACT_3.ogg')
|
||||
self.sound_warning_error = audio.load_sound('Sounds\\title\\SE_ATTRACT_1.ogg')
|
||||
sounds_dir = Path("Sounds")
|
||||
title_dir = sounds_dir / "title"
|
||||
|
||||
self.sound_bachi_swipe = audio.load_sound(str(title_dir / "SE_ATTRACT_2.ogg"))
|
||||
self.sound_bachi_hit = audio.load_sound(str(title_dir / "SE_ATTRACT_3.ogg"))
|
||||
self.sound_warning_message = audio.load_sound(str(title_dir / "VO_ATTRACT_3.ogg"))
|
||||
self.sound_warning_error = audio.load_sound(str(title_dir / "SE_ATTRACT_1.ogg"))
|
||||
|
||||
self.texture_black = load_texture_from_zip('Graphics\\lumendata\\attract\\movie.zip', 'movie_img00000.png')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user