mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 03:30:13 +01:00
add the majority of dan mode
This commit is contained in:
@@ -504,13 +504,13 @@ class DanBox:
|
||||
self.total_notes = 0
|
||||
for song, genre_index, difficulty in self.songs:
|
||||
notes, branch_m, branch_e, branch_n = song.notes_to_position(difficulty)
|
||||
self.total_notes += len(notes.play_notes)
|
||||
self.total_notes += sum(1 for note in notes.play_notes if note.type < 5)
|
||||
for branch in branch_m:
|
||||
self.total_notes += len(branch.play_notes)
|
||||
self.total_notes += sum(1 for note in branch.play_notes if note.type < 5)
|
||||
for branch in branch_e:
|
||||
self.total_notes += len(branch.play_notes)
|
||||
self.total_notes += sum(1 for note in branch.play_notes if note.type < 5)
|
||||
for branch in branch_n:
|
||||
self.total_notes += len(branch.play_notes)
|
||||
self.total_notes += sum(1 for note in branch.play_notes if note.type < 5)
|
||||
self.name = None
|
||||
self.hori_name = None
|
||||
self.yellow_box = None
|
||||
@@ -567,6 +567,36 @@ class DanBox:
|
||||
if self.yellow_box is not None:
|
||||
self.yellow_box.update(True)
|
||||
|
||||
def _draw_exam_box(self):
|
||||
tex.draw_texture('yellow_box', 'exam_box_bottom_right')
|
||||
tex.draw_texture('yellow_box', 'exam_box_bottom_left')
|
||||
tex.draw_texture('yellow_box', 'exam_box_top_right')
|
||||
tex.draw_texture('yellow_box', 'exam_box_top_left')
|
||||
tex.draw_texture('yellow_box', 'exam_box_bottom')
|
||||
tex.draw_texture('yellow_box', 'exam_box_right')
|
||||
tex.draw_texture('yellow_box', 'exam_box_left')
|
||||
tex.draw_texture('yellow_box', 'exam_box_top')
|
||||
tex.draw_texture('yellow_box', 'exam_box_center')
|
||||
tex.draw_texture('yellow_box', 'exam_header')
|
||||
|
||||
for i, exam in enumerate(self.exams):
|
||||
tex.draw_texture('yellow_box', 'judge_box', y=(i*83))
|
||||
tex.draw_texture('yellow_box', 'exam_' + self.exams[i].type, y=(i*83))
|
||||
counter = str(self.exams[i].red)
|
||||
margin = 20
|
||||
if self.exams[i].type == 'gauge':
|
||||
tex.draw_texture('yellow_box', 'exam_percent', y=(i*83))
|
||||
offset = -8
|
||||
else:
|
||||
offset = 0
|
||||
for j in range(len(counter)):
|
||||
tex.draw_texture('yellow_box', 'judge_num', frame=int(counter[j]), x=offset-(len(counter) - j) * margin, y=(i*83))
|
||||
|
||||
if self.exams[i].range == 'more':
|
||||
tex.draw_texture('yellow_box', 'exam_more', x=(offset*-1.7), y=(i*83))
|
||||
elif self.exams[i].range == 'less':
|
||||
tex.draw_texture('yellow_box', 'exam_less', x=(offset*-1.7), y=(i*83))
|
||||
|
||||
def _draw_closed(self, x: int, y: int):
|
||||
tex.draw_texture('box', 'folder', frame=self.color, x=x)
|
||||
if self.name is not None:
|
||||
@@ -601,6 +631,8 @@ class DanBox:
|
||||
if self.hori_name is not None:
|
||||
self.hori_name.draw(outline_color=ray.BLACK, x=434 - (self.hori_name.texture.width//2), y=84, x2=min(self.hori_name.texture.width, 275)-self.hori_name.texture.width)
|
||||
|
||||
self._draw_exam_box()
|
||||
|
||||
def draw(self, x: int, y: int, is_ura: bool):
|
||||
if self.is_open:
|
||||
self._draw_open(x, y, is_ura)
|
||||
@@ -858,27 +890,27 @@ class DanCourse(FileSystemItem):
|
||||
self.logging.error(f"Invalid dan course file: {path}")
|
||||
with open(path, 'r') as f:
|
||||
data = json.load(f)
|
||||
title = data["title"]
|
||||
color = data["color"]
|
||||
songs = []
|
||||
for song in data["songs"]:
|
||||
hash = song["hash"]
|
||||
song_title = song["title"]
|
||||
song_subtitle = song["subtitle"]
|
||||
difficulty = song["difficulty"]
|
||||
self.title = data["title"]
|
||||
self.color = data["color"]
|
||||
self.charts = []
|
||||
for chart in data["charts"]:
|
||||
hash = chart["hash"]
|
||||
chart_title = chart["title"]
|
||||
chart_subtitle = chart["subtitle"]
|
||||
difficulty = chart["difficulty"]
|
||||
if hash in global_data.song_hashes:
|
||||
path = Path(global_data.song_hashes[hash][0]["file_path"])
|
||||
if (path.parent.parent / "box.def").exists():
|
||||
_, genre_index, _ = parse_box_def(path.parent.parent)
|
||||
songs.append((TJAParser(path), genre_index, difficulty))
|
||||
self.charts.append((TJAParser(path), genre_index, difficulty))
|
||||
else:
|
||||
pass
|
||||
#do something with song_title, song_subtitle
|
||||
exams = []
|
||||
self.exams = []
|
||||
for exam in data["exams"]:
|
||||
exams.append(Exam(exam["type"], exam["red"], exam["gold"], exam["range"]))
|
||||
self.exams.append(Exam(exam["type"], exam["value"][0], exam["value"][1], exam["range"]))
|
||||
|
||||
self.box = DanBox(title, color, songs, exams)
|
||||
self.box = DanBox(self.title, self.color, self.charts, self.exams)
|
||||
|
||||
class FileNavigator:
|
||||
"""Manages navigation through pre-generated Directory and SongFile objects"""
|
||||
@@ -1251,6 +1283,7 @@ class FileNavigator:
|
||||
# Save current state to history
|
||||
self.history.append((self.current_dir, self.selected_index))
|
||||
self.current_dir = selected_item.path
|
||||
logger.info(f"Entered Directory {selected_item.path}")
|
||||
|
||||
self.load_current_directory(selected_item=selected_item)
|
||||
|
||||
@@ -1459,12 +1492,14 @@ class FileNavigator:
|
||||
if self.items:
|
||||
self.selected_index = (self.selected_index - 1) % len(self.items)
|
||||
self.calculate_box_positions()
|
||||
logger.info(f"Moved Left to {self.items[self.selected_index].path}")
|
||||
|
||||
def navigate_right(self):
|
||||
"""Move selection right with wrap-around"""
|
||||
if self.items:
|
||||
self.selected_index = (self.selected_index + 1) % len(self.items)
|
||||
self.calculate_box_positions()
|
||||
logger.info(f"Moved Right to {self.items[self.selected_index].path}")
|
||||
|
||||
def get_current_item(self):
|
||||
"""Get the currently selected item"""
|
||||
|
||||
@@ -16,6 +16,10 @@ class Modifiers:
|
||||
@dataclass
|
||||
class SessionData:
|
||||
"""Data class for storing session data. Wiped after the result screen.
|
||||
selected_song (Path): The currently selected song.
|
||||
selected_dan (list[tuple[Any, int, int]]): The currently selected dan songs (TJA). TJAParser, Genre Index, Difficulty
|
||||
selected_dan_exam: list[Exam]: list of dan requirements, contains Exam objects
|
||||
dan_color: int: The emblem color of the selected dan
|
||||
selected_difficulty: The difficulty level selected by the user.
|
||||
song_title: The title of the song being played.
|
||||
genre_index: The index of the genre being played.
|
||||
@@ -27,6 +31,10 @@ class SessionData:
|
||||
result_total_drumroll: The total drumroll achieved in the game.
|
||||
result_gauge_length: The length of the gauge achieved in the game.
|
||||
prev_score: The previous score pulled from the database."""
|
||||
selected_song: Path = Path()
|
||||
selected_dan: list[tuple[Any, int, int]] = field(default_factory=lambda: [])
|
||||
selected_dan_exam: list[Any] = field(default_factory=lambda: [])
|
||||
dan_color: int = 0
|
||||
selected_difficulty: int = 0
|
||||
song_title: str = ''
|
||||
genre_index: int = 0
|
||||
@@ -45,7 +53,6 @@ class GlobalData:
|
||||
Global data for the game. Should be accessed via the global_data variable.
|
||||
|
||||
Attributes:
|
||||
selected_song (Path): The currently selected song.
|
||||
songs_played (int): The number of songs played.
|
||||
config (dict): The configuration settings.
|
||||
song_hashes (dict[str, list[dict]]): A dictionary mapping song hashes to their metadata.
|
||||
@@ -58,7 +65,6 @@ class GlobalData:
|
||||
modifiers (list[Modifiers]): The modifiers for the game.
|
||||
session_data (list[SessionData]): Session data for both players.
|
||||
"""
|
||||
selected_song: Path = Path()
|
||||
songs_played: int = 0
|
||||
config: dict[str, Any] = field(default_factory=lambda: dict())
|
||||
song_hashes: dict[str, list[dict]] = field(default_factory=lambda: dict()) #Hash to path
|
||||
|
||||
@@ -16,8 +16,12 @@ class Transition:
|
||||
self.chara_down = global_tex.get_animation(2)
|
||||
self.song_info_fade = global_tex.get_animation(3)
|
||||
self.song_info_fade_out = global_tex.get_animation(4)
|
||||
self.title = OutlinedText(title, 40, ray.WHITE)
|
||||
self.subtitle = OutlinedText(subtitle, 30, ray.WHITE)
|
||||
if title == '' and subtitle == '':
|
||||
self.title = ''
|
||||
self.subtitle = ''
|
||||
else:
|
||||
self.title = OutlinedText(title, 40, ray.WHITE)
|
||||
self.subtitle = OutlinedText(subtitle, 30, ray.WHITE)
|
||||
self.is_second = is_second
|
||||
|
||||
def start(self):
|
||||
|
||||
Reference in New Issue
Block a user