make some enums

This commit is contained in:
Anthony Samms
2025-11-14 07:54:22 -05:00
parent d0cdb7b866
commit d06e5276b6
12 changed files with 138 additions and 105 deletions

View File

@@ -245,7 +245,7 @@ class AudioEngine:
"""Load sounds for a given screen""" """Load sounds for a given screen"""
path = self.sounds_path / screen_name path = self.sounds_path / screen_name
if not path.exists(): if not path.exists():
logger.warning(f"Sounds for {screen_name} not found") logger.warning(f"Sounds for screen {screen_name} not found")
return return
for sound in path.iterdir(): for sound in path.iterdir():
if sound.is_dir(): if sound.is_dir():

View File

@@ -10,6 +10,7 @@ from libs.bg_objects.don_bg import DonBG
from libs.bg_objects.fever import Fever from libs.bg_objects.fever import Fever
from libs.bg_objects.footer import Footer from libs.bg_objects.footer import Footer
from libs.bg_objects.renda import RendaController from libs.bg_objects.renda import RendaController
from libs.global_data import Difficulty
from libs.texture import TextureWrapper from libs.texture import TextureWrapper
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -124,7 +125,7 @@ class Background:
gauge_2p (Gauge): The gauge object for player 2. gauge_2p (Gauge): The gauge object for player 2.
""" """
if self.dancer is not None and gauge_1p is not None: if self.dancer is not None and gauge_1p is not None:
clear_threshold = gauge_1p.clear_start[min(gauge_1p.difficulty, 3)] clear_threshold = gauge_1p.clear_start[min(gauge_1p.difficulty, Difficulty.ONI)]
if gauge_1p.gauge_length < clear_threshold: if gauge_1p.gauge_length < clear_threshold:
current_milestone = min(self.max_dancers - 1, int(gauge_1p.gauge_length / (clear_threshold / self.max_dancers))) current_milestone = min(self.max_dancers - 1, int(gauge_1p.gauge_length / (clear_threshold / self.max_dancers)))
else: else:

View File

@@ -6,6 +6,7 @@ import random
from typing import Optional, Union from typing import Optional, Union
from libs.audio import audio from libs.audio import audio
from libs.animation import Animation, MoveAnimation from libs.animation import Animation, MoveAnimation
from libs.global_data import Crown, Difficulty
from libs.tja import TJAParser, test_encodings from libs.tja import TJAParser, test_encodings
from libs.texture import tex from libs.texture import tex
from libs.utils import OutlinedText, get_current_ms, global_data from libs.utils import OutlinedText, get_current_ms, global_data
@@ -55,7 +56,7 @@ class SongBox:
self.is_open = False self.is_open = False
self.is_back = self.texture_index == SongBox.BACK_INDEX self.is_back = self.texture_index == SongBox.BACK_INDEX
if self.is_back: if self.is_back:
for i in range(1, 16): for i in range(1, SongBox.BACK_INDEX-1):
if audio.is_sound_playing(f'genre_voice_{i}'): if audio.is_sound_playing(f'genre_voice_{i}'):
audio.stop_sound(f'genre_voice_{i}') audio.stop_sound(f'genre_voice_{i}')
self.name = None self.name = None
@@ -209,20 +210,20 @@ class SongBox:
if valid_scores: if valid_scores:
highest_key = max(valid_scores.keys()) highest_key = max(valid_scores.keys())
score = self.scores[highest_key] score = self.scores[highest_key]
if score and ((score[5] == 2 and score[2] == 0) or (score[2] == 0 and score[3] == 0)): if score and score[5] == Crown.DFC:
tex.draw_texture('yellow_box', 'crown_dfc', x=x, y=y, frame=min(4, highest_key)) tex.draw_texture('yellow_box', 'crown_dfc', x=x, y=y, frame=min(Difficulty.URA, highest_key))
elif score and ((score[5] == 2) or (score[3] == 0)): elif score and score[5] == Crown.FC:
tex.draw_texture('yellow_box', 'crown_fc', x=x, y=y, frame=min(4, highest_key)) tex.draw_texture('yellow_box', 'crown_fc', x=x, y=y, frame=min(Difficulty.URA, highest_key))
elif score and score[5] >= 1: elif score and score[5] >= Crown.CLEAR:
tex.draw_texture('yellow_box', 'crown_clear', x=x, y=y, frame=min(4, highest_key)) tex.draw_texture('yellow_box', 'crown_clear', x=x, y=y, frame=min(Difficulty.URA, highest_key))
if self.crown: #Folder lamp if self.crown: #Folder lamp
highest_crown = max(self.crown) highest_crown = max(self.crown)
if self.crown[highest_crown] == 'DFC': if self.crown[highest_crown] == 'DFC':
tex.draw_texture('yellow_box', 'crown_dfc', x=x, y=y, frame=min(4, highest_crown)) tex.draw_texture('yellow_box', 'crown_dfc', x=x, y=y, frame=min(Difficulty.URA, highest_crown))
elif self.crown[highest_crown] == 'FC': elif self.crown[highest_crown] == 'FC':
tex.draw_texture('yellow_box', 'crown_fc', x=x, y=y, frame=min(4, highest_crown)) tex.draw_texture('yellow_box', 'crown_fc', x=x, y=y, frame=min(Difficulty.URA, highest_crown))
else: else:
tex.draw_texture('yellow_box', 'crown_clear', x=x, y=y, frame=min(4, highest_crown)) tex.draw_texture('yellow_box', 'crown_clear', x=x, y=y, frame=min(Difficulty.URA, highest_crown))
def _draw_open(self, x: int, y: int, fade_override: Optional[float]): def _draw_open(self, x: int, y: int, fade_override: Optional[float]):
color = ray.WHITE color = ray.WHITE
@@ -371,13 +372,13 @@ class YellowBox:
if self.tja is None: if self.tja is None:
return return
for diff in self.tja.metadata.course_data: for diff in self.tja.metadata.course_data:
if diff >= 4: if diff >= Difficulty.URA:
continue continue
elif diff in song_box.scores and song_box.scores[diff] is not None and ((song_box.scores[diff][4] == 2 and song_box.scores[diff][2] == 0) or (song_box.scores[diff][2] == 0 and song_box.scores[diff][3] == 0)): elif diff in song_box.scores and song_box.scores[diff] is not None and song_box.scores[diff][4] == Crown.DFC:
tex.draw_texture('yellow_box', 's_crown_dfc', x=(diff*60), color=color) tex.draw_texture('yellow_box', 's_crown_dfc', x=(diff*60), color=color)
elif diff in song_box.scores and song_box.scores[diff] is not None and ((song_box.scores[diff][4] == 2) or (song_box.scores[diff][3] == 0)): elif diff in song_box.scores and song_box.scores[diff] is not None and song_box.scores[diff][4] == Crown.FC:
tex.draw_texture('yellow_box', 's_crown_fc', x=(diff*60), color=color) tex.draw_texture('yellow_box', 's_crown_fc', x=(diff*60), color=color)
elif diff in song_box.scores and song_box.scores[diff] is not None and song_box.scores[diff][4] >= 1: elif diff in song_box.scores and song_box.scores[diff] is not None and song_box.scores[diff][4] >= Crown.CLEAR:
tex.draw_texture('yellow_box', 's_crown_clear', x=(diff*60), color=color) tex.draw_texture('yellow_box', 's_crown_clear', x=(diff*60), color=color)
tex.draw_texture('yellow_box', 's_crown_outline', x=(diff*60), fade=min(fade, 0.25)) tex.draw_texture('yellow_box', 's_crown_outline', x=(diff*60), fade=min(fade, 0.25))
@@ -398,7 +399,7 @@ class YellowBox:
tex.draw_texture('yellow_box', 'difficulty_bar_shadow', frame=i, x=(i*60), fade=min(fade, 0.25)) tex.draw_texture('yellow_box', 'difficulty_bar_shadow', frame=i, x=(i*60), fade=min(fade, 0.25))
for diff in self.tja.metadata.course_data: for diff in self.tja.metadata.course_data:
if diff >= 4: if diff >= Difficulty.URA:
continue continue
for j in range(self.tja.metadata.course_data[diff].level): for j in range(self.tja.metadata.course_data[diff].level):
tex.draw_texture('yellow_box', 'star', x=(diff*60), y=(j*-17), color=color) tex.draw_texture('yellow_box', 'star', x=(diff*60), y=(j*-17), color=color)
@@ -415,7 +416,7 @@ class YellowBox:
for diff in self.tja.metadata.course_data: for diff in self.tja.metadata.course_data:
if song_box is None: if song_box is None:
continue continue
if diff >= 4: if diff >= Difficulty.URA:
continue continue
elif diff in song_box.scores and song_box.scores[diff] is not None and ((song_box.scores[diff][4] == 2 and song_box.scores[diff][2] == 0) or (song_box.scores[diff][2] == 0 and song_box.scores[diff][3] == 0)): elif diff in song_box.scores and song_box.scores[diff] is not None and ((song_box.scores[diff][4] == 2 and song_box.scores[diff][2] == 0) or (song_box.scores[diff][2] == 0 and song_box.scores[diff][3] == 0)):
tex.draw_texture('yellow_box', 's_crown_dfc', x=(diff*115)+8, y=-120, fade=self.fade_in.attribute) tex.draw_texture('yellow_box', 's_crown_dfc', x=(diff*115)+8, y=-120, fade=self.fade_in.attribute)
@@ -426,7 +427,7 @@ class YellowBox:
tex.draw_texture('yellow_box', 's_crown_outline', x=(diff*115)+8, y=-120, fade=min(self.fade_in.attribute, 0.25)) tex.draw_texture('yellow_box', 's_crown_outline', x=(diff*115)+8, y=-120, fade=min(self.fade_in.attribute, 0.25))
for i in range(4): for i in range(4):
if i == 3 and is_ura: if i == Difficulty.ONI and is_ura:
tex.draw_texture('diff_select', 'diff_tower', frame=4, x=(i*115), fade=self.fade_in.attribute) tex.draw_texture('diff_select', 'diff_tower', frame=4, x=(i*115), fade=self.fade_in.attribute)
tex.draw_texture('diff_select', 'ura_oni_plate', fade=self.fade_in.attribute) tex.draw_texture('diff_select', 'ura_oni_plate', fade=self.fade_in.attribute)
else: else:
@@ -435,16 +436,16 @@ class YellowBox:
tex.draw_texture('diff_select', 'diff_tower_shadow', frame=i, x=(i*115), fade=min(self.fade_in.attribute, 0.25)) tex.draw_texture('diff_select', 'diff_tower_shadow', frame=i, x=(i*115), fade=min(self.fade_in.attribute, 0.25))
for course in self.tja.metadata.course_data: for course in self.tja.metadata.course_data:
if (course == 4 and not is_ura) or (course == 3 and is_ura): if (course == Difficulty.URA and not is_ura) or (course == Difficulty.ONI and is_ura):
continue continue
for j in range(self.tja.metadata.course_data[course].level): for j in range(self.tja.metadata.course_data[course].level):
tex.draw_texture('yellow_box', 'star_ura', x=min(course, 3)*115, y=(j*-20), fade=self.fade_in.attribute) tex.draw_texture('yellow_box', 'star_ura', x=min(course, Difficulty.ONI)*115, y=(j*-20), fade=self.fade_in.attribute)
if self.tja.metadata.course_data[course].is_branching and (get_current_ms() // 1000) % 2 == 0: if self.tja.metadata.course_data[course].is_branching and (get_current_ms() // 1000) % 2 == 0:
if course == 4: if course == Difficulty.URA:
name = 'branch_indicator_ura' name = 'branch_indicator_ura'
else: else:
name = 'branch_indicator_diff' name = 'branch_indicator_diff'
tex.draw_texture('yellow_box', name, x=min(course, 3)*115, fade=self.fade_in.attribute) tex.draw_texture('yellow_box', name, x=min(course, Difficulty.ONI)*115, fade=self.fade_in.attribute)
def _draw_text(self, song_box): def _draw_text(self, song_box):
if not isinstance(self.right_out, MoveAnimation): if not isinstance(self.right_out, MoveAnimation):
@@ -726,7 +727,7 @@ class ScoreHistory:
def draw_long(self): def draw_long(self):
tex.draw_texture('leaderboard','background_2') tex.draw_texture('leaderboard','background_2')
tex.draw_texture('leaderboard','title', index=self.long) tex.draw_texture('leaderboard','title', index=self.long)
if self.curr_difficulty == 4: if self.curr_difficulty == Difficulty.URA:
tex.draw_texture('leaderboard', 'shinuchi_ura', index=self.long) tex.draw_texture('leaderboard', 'shinuchi_ura', index=self.long)
else: else:
tex.draw_texture('leaderboard', 'shinuchi', index=self.long) tex.draw_texture('leaderboard', 'shinuchi', index=self.long)
@@ -743,7 +744,7 @@ class ScoreHistory:
tex.draw_texture('leaderboard', 'judge_drumroll') tex.draw_texture('leaderboard', 'judge_drumroll')
for j, counter in enumerate(self.scores[self.curr_difficulty]): for j, counter in enumerate(self.scores[self.curr_difficulty]):
if j == 5: if j == Difficulty.TOWER:
continue continue
counter = str(counter) counter = str(counter)
margin = 24 margin = 24
@@ -760,7 +761,7 @@ class ScoreHistory:
tex.draw_texture('leaderboard','background') tex.draw_texture('leaderboard','background')
tex.draw_texture('leaderboard','title') tex.draw_texture('leaderboard','title')
if self.curr_difficulty == 4: if self.curr_difficulty == Difficulty.URA:
tex.draw_texture('leaderboard', 'normal_ura') tex.draw_texture('leaderboard', 'normal_ura')
tex.draw_texture('leaderboard', 'shinuchi_ura') tex.draw_texture('leaderboard', 'shinuchi_ura')
else: else:
@@ -768,7 +769,7 @@ class ScoreHistory:
tex.draw_texture('leaderboard', 'shinuchi') tex.draw_texture('leaderboard', 'shinuchi')
color = ray.BLACK color = ray.BLACK
if self.curr_difficulty == 4: if self.curr_difficulty == Difficulty.URA:
color = ray.WHITE color = ray.WHITE
tex.draw_texture('leaderboard','ura') tex.draw_texture('leaderboard','ura')
@@ -944,7 +945,7 @@ class FileNavigator:
self.favorite_folder: Optional[Directory] = None self.favorite_folder: Optional[Directory] = None
self.recent_folder: Optional[Directory] = None self.recent_folder: Optional[Directory] = None
self.selected_index = 0 self.selected_index = 0
self.diff_sort_diff = 4 self.diff_sort_diff = Difficulty.URA
self.diff_sort_level = 10 self.diff_sort_level = 10
self.diff_sort_statistics = dict() self.diff_sort_statistics = dict()
self.history = [] self.history = []
@@ -1105,8 +1106,8 @@ class FileNavigator:
scores = song_obj.box.scores.get(course) scores = song_obj.box.scores.get(course)
if scores is not None: if scores is not None:
is_cleared = scores[4] >= 1 is_cleared = scores[4] >= Crown.CLEAR
is_full_combo = (scores[4] == 2) or (scores[3] == 0) is_full_combo = scores[4] == Crown.FC
else: else:
is_cleared = False is_cleared = False
is_full_combo = False is_full_combo = False
@@ -1281,7 +1282,7 @@ class FileNavigator:
if selected_item.collection == Directory.COLLECTIONS[3]: if selected_item.collection == Directory.COLLECTIONS[3]:
diff_sort = self.diff_sort_level diff_sort = self.diff_sort_level
diffs = ['かんたん', 'ふつう', 'むずかしい', 'おに'] diffs = ['かんたん', 'ふつう', 'むずかしい', 'おに']
hori_name = OutlinedText(diffs[min(3, self.diff_sort_diff)], 40, ray.WHITE, outline_thickness=5) hori_name = OutlinedText(diffs[min(Difficulty.ONI, self.diff_sort_diff)], 40, ray.WHITE, outline_thickness=5)
self.genre_bg = GenreBG(start_box, end_box, hori_name, diff_sort) self.genre_bg = GenreBG(start_box, end_box, hori_name, diff_sort)
def select_current_item(self): def select_current_item(self):
@@ -1367,11 +1368,11 @@ class FileNavigator:
all_scores[diff].append(song_obj.box.scores[diff]) all_scores[diff].append(song_obj.box.scores[diff])
for diff in all_scores: for diff in all_scores:
if all(score is not None and ((score[5] == 2 and score[2] == 0) or (score[2] == 0 and score[3] == 0)) for score in all_scores[diff]): if all(score is not None and score[5] == Crown.DFC for score in all_scores[diff]):
crowns[diff] = 'DFC' crowns[diff] = 'DFC'
elif all(score is not None and ((score[5] == 2) or (score[3] == 0)) for score in all_scores[diff]): elif all(score is not None and score[5] == Crown.FC for score in all_scores[diff]):
crowns[diff] = 'FC' crowns[diff] = 'FC'
elif all(score is not None and score[5] >= 1 for score in all_scores[diff]): elif all(score is not None and score[5] >= Crown.CLEAR for score in all_scores[diff]):
crowns[diff] = 'CLEAR' crowns[diff] = 'CLEAR'
self.directory_crowns[dir_key] = crowns self.directory_crowns[dir_key] = crowns

View File

@@ -1,7 +1,23 @@
from dataclasses import dataclass, field from dataclasses import dataclass, field
from enum import IntEnum
from pathlib import Path from pathlib import Path
from typing import Any, TypedDict from typing import Any, TypedDict
class Difficulty(IntEnum):
EASY = 0
NORMAL = 1
HARD = 2
ONI = 3
URA = 4
TOWER = 5
DAN = 6
class Crown(IntEnum):
NONE = 0
CLEAR = 1
FC = 2
DFC = 3
class GeneralConfig(TypedDict): class GeneralConfig(TypedDict):
fps_counter: bool fps_counter: bool
audio_offset: int audio_offset: int

View File

@@ -7,6 +7,7 @@ import sys
import time import time
from pathlib import Path from pathlib import Path
from libs.global_data import Crown
from libs.tja import NoteList, TJAParser, test_encodings from libs.tja import NoteList, TJAParser, test_encodings
from libs.utils import get_config, global_data from libs.utils import get_config, global_data
@@ -179,13 +180,13 @@ def build_song_hashes(output_dir=Path("cache")):
continue continue
if imported_clears[i] == 2: if imported_clears[i] == 2:
bads = 0 bads = 0
clear = 2 clear = Crown.FC
elif imported_clears[i] == 1: elif imported_clears[i] == 1:
bads = None bads = None
clear = 1 clear = Crown.CLEAR
else: else:
bads = None bads = None
clear = 0 clear = Crown.NONE
cursor.execute(""" cursor.execute("""
INSERT OR REPLACE INTO scores (hash, en_name, jp_name, diff, score, clear, bad) INSERT OR REPLACE INTO scores (hash, en_name, jp_name, diff, score, clear, bad)
VALUES (?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?)

View File

@@ -166,7 +166,7 @@ class TextureWrapper:
"""Load textures for a screen.""" """Load textures for a screen."""
screen_path = self.graphics_path / screen_name screen_path = self.graphics_path / screen_name
if not screen_path.exists(): if not screen_path.exists():
logger.warning(f"Screen {screen_name} does not exist") logger.warning(f"Textures for Screen {screen_name} do not exist")
return return
if (screen_path / 'animation.json').exists(): if (screen_path / 'animation.json').exists():
with open(screen_path / 'animation.json') as json_file: with open(screen_path / 'animation.json') as json_file:

View File

@@ -1,4 +1,5 @@
import bisect import bisect
from enum import IntEnum
import hashlib import hashlib
import math import math
import logging import logging
@@ -26,6 +27,18 @@ def get_pixels_per_ms(pixels_per_frame: float):
"""Calculate the number of pixels per millisecond.""" """Calculate the number of pixels per millisecond."""
return pixels_per_frame / (1000 / 60) return pixels_per_frame / (1000 / 60)
class NoteType(IntEnum):
NONE = 0
DON = 1
KAT = 2
DON_L = 3
KAT_L = 4
ROLL_HEAD = 5
ROLL_HEAD_L = 6
BALLOON_HEAD = 7
TAIL = 8
KUSUDAMA = 9
@dataclass() @dataclass()
class Note: class Note:
"""A note in a TJA file. """A note in a TJA file.

View File

@@ -12,7 +12,7 @@ from libs.animation import Animation
from libs.audio import audio from libs.audio import audio
from libs.background import Background from libs.background import Background
from libs.chara_2d import Chara2D from libs.chara_2d import Chara2D
from libs.global_data import Modifiers from libs.global_data import Crown, Difficulty, Modifiers
from libs.global_objects import AllNetIcon, Nameplate from libs.global_objects import AllNetIcon, Nameplate
from libs.screen import Screen from libs.screen import Screen
from libs.texture import tex from libs.texture import tex
@@ -21,6 +21,7 @@ from libs.tja import (
Drumroll, Drumroll,
Note, Note,
NoteList, NoteList,
NoteType,
TJAParser, TJAParser,
apply_modifiers, apply_modifiers,
calculate_base_score, calculate_base_score,
@@ -168,13 +169,13 @@ class GameScreen(Screen):
result = cursor.fetchone() result = cursor.fetchone()
existing_score = result[0] if result is not None else None existing_score = result[0] if result is not None else None
existing_crown = result[1] if result is not None and len(result) > 1 and result[1] is not None else 0 existing_crown = result[1] if result is not None and len(result) > 1 and result[1] is not None else 0
crown = 0 crown = Crown.NONE
if session_data.result_data.bad and session_data.result_data.ok == 0: if session_data.result_data.bad and session_data.result_data.ok == 0:
crown = 3 crown = Crown.DFC
elif session_data.result_data.bad == 0: elif session_data.result_data.bad == 0:
crown = 2 crown = Crown.FC
elif self.player_1.gauge.is_clear: elif self.player_1.gauge.is_clear:
crown = 1 crown = Crown.CLEAR
logger.info(f"Existing score: {existing_score}, Existing crown: {existing_crown}, New score: {session_data.result_data.score}, New crown: {crown}") logger.info(f"Existing score: {existing_score}, Existing crown: {existing_crown}, New score: {session_data.result_data.score}, New crown: {crown}")
if result is None or (existing_score is not None and session_data.result_data.score > existing_score): if result is None or (existing_score is not None and session_data.result_data.score > existing_score):
insert_query = ''' insert_query = '''
@@ -383,9 +384,9 @@ class Player:
if section.play_notes: if section.play_notes:
self.end_time = max(self.end_time, section.play_notes[-1].hit_ms) self.end_time = max(self.end_time, section.play_notes[-1].hit_ms)
self.don_notes = deque([note for note in self.play_notes if note.type in {1, 3}]) self.don_notes = deque([note for note in self.play_notes if note.type in {NoteType.DON, NoteType.DON_L}])
self.kat_notes = deque([note for note in self.play_notes if note.type in {2, 4}]) self.kat_notes = deque([note for note in self.play_notes if note.type in {NoteType.KAT, NoteType.KAT_L}])
self.other_notes = deque([note for note in self.play_notes if note.type not in {1, 2, 3, 4}]) self.other_notes = deque([note for note in self.play_notes if note.type not in {NoteType.DON, NoteType.DON_L, NoteType.KAT, NoteType.KAT_L}])
self.total_notes = len([note for note in self.play_notes if 0 < note.type < 5]) self.total_notes = len([note for note in self.play_notes if 0 < note.type < 5])
total_notes = notes total_notes = notes
if self.branch_m: if self.branch_m:
@@ -416,9 +417,9 @@ class Player:
self.play_notes = deque(sorted(self.play_notes)) self.play_notes = deque(sorted(self.play_notes))
self.draw_note_list = deque(sorted(self.draw_note_list, key=lambda x: x.load_ms)) self.draw_note_list = deque(sorted(self.draw_note_list, key=lambda x: x.load_ms))
self.draw_bar_list = deque(sorted(self.draw_bar_list, key=lambda x: x.load_ms)) self.draw_bar_list = deque(sorted(self.draw_bar_list, key=lambda x: x.load_ms))
total_don = [note for note in self.play_notes if note.type in {1, 3}] total_don = [note for note in self.play_notes if note.type in {NoteType.DON, NoteType.DON_L}]
total_kat = [note for note in self.play_notes if note.type in {2, 4}] total_kat = [note for note in self.play_notes if note.type in {NoteType.KAT, NoteType.KAT_L}]
total_other = [note for note in self.play_notes if note.type not in {1, 2, 3, 4}] total_other = [note for note in self.play_notes if note.type not in {NoteType.DON, NoteType.DON_L, NoteType.KAT, NoteType.KAT_L}]
self.don_notes = deque([note for note in total_don if note.hit_ms > current_ms]) self.don_notes = deque([note for note in total_don if note.hit_ms > current_ms])
self.kat_notes = deque([note for note in total_kat if note.hit_ms > current_ms]) self.kat_notes = deque([note for note in total_kat if note.hit_ms > current_ms])
@@ -493,7 +494,7 @@ class Player:
end_roll = -1 end_roll = -1
for notes in note_lists: for notes in note_lists:
for i in range(len(notes)-1, -1, -1): for i in range(len(notes)-1, -1, -1):
if notes[i].type == 8 and notes[i].hit_ms <= end_time: if notes[i].type == NoteType.TAIL and notes[i].hit_ms <= end_time:
end_roll = notes[i].hit_ms end_roll = notes[i].hit_ms
break break
if end_roll != -1: if end_roll != -1:
@@ -555,11 +556,11 @@ class Player:
note = self.other_notes[0] note = self.other_notes[0]
if (note.hit_ms <= current_ms): if (note.hit_ms <= current_ms):
if note.type == 5 or note.type == 6: if note.type == NoteType.ROLL_HEAD or note.type == NoteType.ROLL_HEAD_L:
self.is_drumroll = True self.is_drumroll = True
elif note.type == 7 or note.type == 9: elif note.type == NoteType.BALLOON_HEAD or note.type == NoteType.KUSUDAMA:
self.is_balloon = True self.is_balloon = True
elif note.type == 8: elif note.type == NoteType.TAIL:
self.other_notes.popleft() self.other_notes.popleft()
self.is_drumroll = False self.is_drumroll = False
self.is_balloon = False self.is_balloon = False
@@ -582,7 +583,7 @@ class Player:
if 5 <= current_note.type <= 7: if 5 <= current_note.type <= 7:
bisect.insort_left(self.current_notes_draw, current_note, key=lambda x: x.index) bisect.insort_left(self.current_notes_draw, current_note, key=lambda x: x.index)
try: try:
tail_note = next((note for note in self.draw_note_list if note.type == 8)) tail_note = next((note for note in self.draw_note_list if note.type == NoteType.TAIL))
bisect.insort_left(self.current_notes_draw, tail_note, key=lambda x: x.index) bisect.insort_left(self.current_notes_draw, tail_note, key=lambda x: x.index)
self.draw_note_list.remove(tail_note) self.draw_note_list.remove(tail_note)
except Exception as e: except Exception as e:
@@ -597,7 +598,7 @@ class Player:
self.current_notes_draw[0].color += 1 self.current_notes_draw[0].color += 1
note = self.current_notes_draw[0] note = self.current_notes_draw[0]
if note.type in {5, 6, 7, 9} and len(self.current_notes_draw) > 1: if note.type in {NoteType.ROLL_HEAD, NoteType.ROLL_HEAD_L, NoteType.BALLOON_HEAD, NoteType.KUSUDAMA} and len(self.current_notes_draw) > 1:
note = self.current_notes_draw[1] note = self.current_notes_draw[1]
position = self.get_position_x(SCREEN_WIDTH, current_ms, note.hit_ms, note.pixels_per_frame_x) position = self.get_position_x(SCREEN_WIDTH, current_ms, note.hit_ms, note.pixels_per_frame_x)
if position < GameScreen.JUDGE_X + 650: if position < GameScreen.JUDGE_X + 650:
@@ -610,15 +611,15 @@ class Player:
def note_correct(self, note: Note, current_time: float): def note_correct(self, note: Note, current_time: float):
"""Removes a note from the appropriate separated list""" """Removes a note from the appropriate separated list"""
if note.type in {1, 3} and self.don_notes and self.don_notes[0] == note: if note.type in {NoteType.DON, NoteType.DON_L} and self.don_notes and self.don_notes[0] == note:
self.don_notes.popleft() self.don_notes.popleft()
elif note.type in {2, 4} and self.kat_notes and self.kat_notes[0] == note: elif note.type in {NoteType.KAT, NoteType.KAT_L} and self.kat_notes and self.kat_notes[0] == note:
self.kat_notes.popleft() self.kat_notes.popleft()
elif note.type not in {1, 2, 3, 4} and self.other_notes and self.other_notes[0] == note: elif note.type not in {NoteType.DON, NoteType.DON_L, NoteType.KAT, NoteType.KAT_L} and self.other_notes and self.other_notes[0] == note:
self.other_notes.popleft() self.other_notes.popleft()
index = note.index index = note.index
if note.type == 7: if note.type == NoteType.BALLOON_HEAD:
if self.other_notes: if self.other_notes:
self.other_notes.popleft() self.other_notes.popleft()
@@ -631,8 +632,8 @@ class Player:
if self.combo > self.max_combo: if self.combo > self.max_combo:
self.max_combo = self.combo self.max_combo = self.combo
if note.type != 9: if note.type != NoteType.KUSUDAMA:
self.draw_arc_list.append(NoteArc(note.type, current_time, self.is_2p + 1, note.type == 3 or note.type == 4 or note.type == 7, note.type == 7)) self.draw_arc_list.append(NoteArc(note.type, current_time, self.is_2p + 1, note.type == NoteType.DON_L or note.type == NoteType.KAT_L or note.type == NoteType.BALLOON_HEAD, note.type == NoteType.BALLOON_HEAD))
if note in self.current_notes_draw: if note in self.current_notes_draw:
index = self.current_notes_draw.index(note) index = self.current_notes_draw.index(note)
@@ -693,7 +694,7 @@ class Player:
if len(self.don_notes) == 0 and len(self.kat_notes) == 0 and len(self.other_notes) == 0: if len(self.don_notes) == 0 and len(self.kat_notes) == 0 and len(self.other_notes) == 0:
return return
if self.difficulty < 2: if self.difficulty < Difficulty.NORMAL:
good_window_ms = Player.TIMING_GOOD_EASY good_window_ms = Player.TIMING_GOOD_EASY
ok_window_ms = Player.TIMING_OK_EASY ok_window_ms = Player.TIMING_OK_EASY
bad_window_ms = Player.TIMING_BAD_EASY bad_window_ms = Player.TIMING_BAD_EASY
@@ -727,7 +728,7 @@ class Player:
if ms_from_start > (curr_note.hit_ms + bad_window_ms): if ms_from_start > (curr_note.hit_ms + bad_window_ms):
return return
big = curr_note.type == 3 or curr_note.type == 4 big = curr_note.type == NoteType.DON_L or curr_note.type == NoteType.KAT_L
if (curr_note.hit_ms - good_window_ms) <= ms_from_start <= (curr_note.hit_ms + good_window_ms): if (curr_note.hit_ms - good_window_ms) <= ms_from_start <= (curr_note.hit_ms + good_window_ms):
self.draw_judge_list.append(Judgement('GOOD', big, self.is_2p)) self.draw_judge_list.append(Judgement('GOOD', big, self.is_2p))
self.lane_hit_effect = LaneHitEffect('GOOD', self.is_2p) self.lane_hit_effect = LaneHitEffect('GOOD', self.is_2p)
@@ -846,7 +847,7 @@ class Player:
self.autoplay_hit_side = 'R' if self.autoplay_hit_side == 'L' else 'L' self.autoplay_hit_side = 'R' if self.autoplay_hit_side == 'L' else 'L'
self.spawn_hit_effects(hit_type, self.autoplay_hit_side) self.spawn_hit_effects(hit_type, self.autoplay_hit_side)
audio.play_sound(f'hitsound_don_{self.player_number}p', 'hitsound') audio.play_sound(f'hitsound_don_{self.player_number}p', 'hitsound')
note_type = 3 if note.type == 6 else 1 note_type = NoteType.DON_L if note.type == NoteType.ROLL_HEAD_L else NoteType.DON
self.check_note(ms_from_start, note_type, current_time, background) self.check_note(ms_from_start, note_type, current_time, background)
else: else:
# Handle DON notes # Handle DON notes
@@ -971,8 +972,8 @@ class Player:
def draw_drumroll(self, current_ms: float, head: Drumroll, current_eighth: int): def draw_drumroll(self, current_ms: float, head: Drumroll, current_eighth: int):
"""Draws a drumroll in the player's lane""" """Draws a drumroll in the player's lane"""
start_position = self.get_position_x(SCREEN_WIDTH, current_ms, head.load_ms, head.pixels_per_frame_x) start_position = self.get_position_x(SCREEN_WIDTH, current_ms, head.load_ms, head.pixels_per_frame_x)
tail = next((note for note in self.current_notes_draw[1:] if note.type == 8 and note.index > head.index), self.current_notes_draw[1]) tail = next((note for note in self.current_notes_draw[1:] if note.type == NoteType.TAIL and note.index > head.index), self.current_notes_draw[1])
is_big = int(head.type == 6) is_big = int(head.type == NoteType.ROLL_HEAD_L)
end_position = self.get_position_x(SCREEN_WIDTH, current_ms, tail.load_ms, tail.pixels_per_frame_x) end_position = self.get_position_x(SCREEN_WIDTH, current_ms, tail.load_ms, tail.pixels_per_frame_x)
length = end_position - start_position length = end_position - start_position
color = ray.Color(255, head.color, head.color, 255) color = ray.Color(255, head.color, head.color, 255)
@@ -993,7 +994,7 @@ class Player:
"""Draws a balloon in the player's lane""" """Draws a balloon in the player's lane"""
offset = 12 offset = 12
start_position = self.get_position_x(SCREEN_WIDTH, current_ms, head.load_ms, head.pixels_per_frame_x) start_position = self.get_position_x(SCREEN_WIDTH, current_ms, head.load_ms, head.pixels_per_frame_x)
tail = next((note for note in self.current_notes_draw[1:] if note.type == 8 and note.index > head.index), self.current_notes_draw[1]) tail = next((note for note in self.current_notes_draw[1:] if note.type == NoteType.TAIL and note.index > head.index), self.current_notes_draw[1])
end_position = self.get_position_x(SCREEN_WIDTH, current_ms, tail.load_ms, tail.pixels_per_frame_x) end_position = self.get_position_x(SCREEN_WIDTH, current_ms, tail.load_ms, tail.pixels_per_frame_x)
pause_position = 349 pause_position = 349
if current_ms >= tail.hit_ms: if current_ms >= tail.hit_ms:
@@ -1041,7 +1042,7 @@ class Player:
for note in reversed(self.current_notes_draw): for note in reversed(self.current_notes_draw):
if self.balloon_anim is not None and note == self.current_notes_draw[0]: if self.balloon_anim is not None and note == self.current_notes_draw[0]:
continue continue
if note.type == 8: if note.type == NoteType.TAIL:
continue continue
if isinstance(note, Drumroll): if isinstance(note, Drumroll):
@@ -2193,16 +2194,16 @@ class Gauge:
self.gauge_length = 0 self.gauge_length = 0
self.previous_length = 0 self.previous_length = 0
self.total_notes = total_notes self.total_notes = total_notes
self.difficulty = min(3, difficulty) self.difficulty = min(Difficulty.ONI, difficulty)
self.clear_start = [52, 60, 69, 69] self.clear_start = [52, 60, 69, 69]
self.gauge_max = 87 self.gauge_max = 87
self.level = min(10, level) self.level = min(10, level)
self.tamashii_fire_change = tex.get_animation(25) self.tamashii_fire_change = tex.get_animation(25)
if self.difficulty == 2: if self.difficulty == Difficulty.HARD:
self.string_diff = "_hard" self.string_diff = "_hard"
elif self.difficulty == 1: elif self.difficulty == Difficulty.NORMAL:
self.string_diff = "_normal" self.string_diff = "_normal"
elif self.difficulty == 0: elif self.difficulty == Difficulty.EASY:
self.string_diff = "_easy" self.string_diff = "_easy"
self.is_clear = False self.is_clear = False
self.is_rainbow = False self.is_rainbow = False
@@ -2274,7 +2275,7 @@ class Gauge:
self.gauge_length = 0 self.gauge_length = 0
def update(self, current_ms: float): def update(self, current_ms: float):
self.is_clear = self.gauge_length > self.clear_start[min(self.difficulty, 2)]-1 self.is_clear = self.gauge_length > self.clear_start[min(self.difficulty, Difficulty.HARD)]-1
self.is_rainbow = self.gauge_length == self.gauge_max self.is_rainbow = self.gauge_length == self.gauge_max
if self.gauge_length == self.gauge_max and self.rainbow_fade_in is None: if self.gauge_length == self.gauge_max and self.rainbow_fade_in is None:
self.rainbow_fade_in = Animation.create_fade(450, initial_opacity=0.0, final_opacity=1.0) self.rainbow_fade_in = Animation.create_fade(450, initial_opacity=0.0, final_opacity=1.0)

View File

@@ -9,7 +9,7 @@ from libs.animation import Animation
from libs.audio import audio from libs.audio import audio
from libs.background import Background from libs.background import Background
from libs.global_data import Modifiers, global_data from libs.global_data import Modifiers, global_data
from libs.tja import Balloon, Drumroll, Note, TJAParser, apply_modifiers from libs.tja import Balloon, Drumroll, Note, NoteType, TJAParser, apply_modifiers
from libs.utils import get_current_ms, get_key_code from libs.utils import get_current_ms, get_key_code
from libs.texture import tex from libs.texture import tex
from scenes.game import DrumHitEffect, GameScreen, JudgeCounter, LaneHitEffect, Player, SCREEN_WIDTH from scenes.game import DrumHitEffect, GameScreen, JudgeCounter, LaneHitEffect, Player, SCREEN_WIDTH
@@ -163,7 +163,7 @@ class PracticeGameScreen(GameScreen):
"""Draws a drumroll in the player's lane""" """Draws a drumroll in the player's lane"""
start_position = self.get_position_x(SCREEN_WIDTH, current_ms, head.load_ms, head.pixels_per_frame_x) start_position = self.get_position_x(SCREEN_WIDTH, current_ms, head.load_ms, head.pixels_per_frame_x)
tail = next((note for note in self.scrobble_note_list if note.index == index+1), self.scrobble_note_list[index+1]) tail = next((note for note in self.scrobble_note_list if note.index == index+1), self.scrobble_note_list[index+1])
is_big = int(head.type == 6) is_big = int(head.type == NoteType.ROLL_HEAD_L)
end_position = self.get_position_x(SCREEN_WIDTH, current_ms, tail.load_ms, tail.pixels_per_frame_x) end_position = self.get_position_x(SCREEN_WIDTH, current_ms, tail.load_ms, tail.pixels_per_frame_x)
length = end_position - start_position length = end_position - start_position
color = ray.Color(255, head.color, head.color, 255) color = ray.Color(255, head.color, head.color, 255)
@@ -216,7 +216,7 @@ class PracticeGameScreen(GameScreen):
tex.draw_texture('notes', bar_type, frame=frame, x=x, y=y) tex.draw_texture('notes', bar_type, frame=frame, x=x, y=y)
for note in reversed(self.scrobble_note_list): for note in reversed(self.scrobble_note_list):
if note.type == 8: if note.type == NoteType.TAIL:
continue continue
if isinstance(note, Drumroll): if isinstance(note, Drumroll):

View File

@@ -1,7 +1,7 @@
import logging import logging
import pyray as ray import pyray as ray
from libs.global_data import reset_session from libs.global_data import Difficulty, reset_session
from libs.audio import audio from libs.audio import audio
from libs.chara_2d import Chara2D from libs.chara_2d import Chara2D
from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate
@@ -469,15 +469,15 @@ class Gauge:
def __init__(self, player_num: str, gauge_length: float, is_2p: bool): def __init__(self, player_num: str, gauge_length: float, is_2p: bool):
self.is_2p = is_2p self.is_2p = is_2p
self.player_num = player_num self.player_num = player_num
self.difficulty = min(2, global_data.session_data[int(player_num)-1].selected_difficulty) self.difficulty = min(Difficulty.HARD, global_data.session_data[int(player_num)-1].selected_difficulty)
self.gauge_length = gauge_length self.gauge_length = gauge_length
self.clear_start = [69, 69, 69] self.clear_start = [69, 69, 69]
self.gauge_max = 87 self.gauge_max = 87
if self.difficulty >= 2: if self.difficulty >= Difficulty.HARD:
self.string_diff = "_hard" self.string_diff = "_hard"
elif self.difficulty == 1: elif self.difficulty == Difficulty.NORMAL:
self.string_diff = "_normal" self.string_diff = "_normal"
elif self.difficulty == 0: elif self.difficulty == Difficulty.EASY:
self.string_diff = "_easy" self.string_diff = "_easy"
self.rainbow_animation = tex.get_animation(16) self.rainbow_animation = tex.get_animation(16)
self.gauge_fade_in = tex.get_animation(17) self.gauge_fade_in = tex.get_animation(17)

View File

@@ -9,7 +9,7 @@ from libs.file_navigator import DanCourse, navigator
from libs.audio import audio from libs.audio import audio
from libs.chara_2d import Chara2D from libs.chara_2d import Chara2D
from libs.file_navigator import Directory, SongBox, SongFile from libs.file_navigator import Directory, SongBox, SongFile
from libs.global_data import Modifiers from libs.global_data import Difficulty, Modifiers
from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate, Indicator, Timer from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate, Indicator, Timer
from libs.screen import Screen from libs.screen import Screen
from libs.texture import tex from libs.texture import tex
@@ -559,7 +559,7 @@ class SongSelectPlayer:
elif is_r_kat_pressed(self.player_num): elif is_r_kat_pressed(self.player_num):
ret_val = self._navigate_difficulty_right(diffs) ret_val = self._navigate_difficulty_right(diffs)
if 0 <= self.selected_difficulty <= 4 and self.selected_difficulty != prev_diff: if Difficulty.EASY <= self.selected_difficulty <= Difficulty.URA and self.selected_difficulty != prev_diff:
self.selected_diff_bounce.start() self.selected_diff_bounce.start()
self.selected_diff_fadein.start() self.selected_diff_fadein.start()
@@ -567,7 +567,7 @@ class SongSelectPlayer:
return ret_val return ret_val
if (ray.is_key_pressed(ray.KeyboardKey.KEY_TAB) and if (ray.is_key_pressed(ray.KeyboardKey.KEY_TAB) and
self.selected_difficulty in [3, 4]): self.selected_difficulty in [Difficulty.ONI, Difficulty.URA]):
return self._toggle_ura_mode() return self._toggle_ura_mode()
return None return None
@@ -575,7 +575,7 @@ class SongSelectPlayer:
def _navigate_difficulty_left(self, diffs): def _navigate_difficulty_left(self, diffs):
"""Navigate difficulty selection leftward""" """Navigate difficulty selection leftward"""
self.diff_select_move_right = False self.diff_select_move_right = False
if self.is_ura and self.selected_difficulty == 4: if self.is_ura and self.selected_difficulty == Difficulty.URA:
self.diff_selector_move_1.start() self.diff_selector_move_1.start()
self.prev_diff = self.selected_difficulty self.prev_diff = self.selected_difficulty
if len(diffs) == 1: if len(diffs) == 1:
@@ -604,12 +604,12 @@ class SongSelectPlayer:
def _navigate_difficulty_right(self, diffs): def _navigate_difficulty_right(self, diffs):
"""Navigate difficulty selection rightward""" """Navigate difficulty selection rightward"""
self.diff_select_move_right = True self.diff_select_move_right = True
if self.is_ura and self.selected_difficulty == 2: if self.is_ura and self.selected_difficulty == Difficulty.HARD:
self.prev_diff = self.selected_difficulty self.prev_diff = self.selected_difficulty
self.selected_difficulty = 4 self.selected_difficulty = Difficulty.URA
self.diff_selector_move_1.start() self.diff_selector_move_1.start()
if (self.selected_difficulty in [3, 4] and 4 in diffs and 3 in diffs): if (self.selected_difficulty in [Difficulty.ONI, Difficulty.URA] and Difficulty.URA in diffs and Difficulty.ONI in diffs):
self.ura_toggle = (self.ura_toggle + 1) % 10 self.ura_toggle = (self.ura_toggle + 1) % 10
if self.ura_toggle == 0: if self.ura_toggle == 0:
return self._toggle_ura_mode() return self._toggle_ura_mode()
@@ -646,7 +646,7 @@ class SongSelectPlayer:
name = f'{self.player_num}p_outline_back_half' if is_half else f'{self.player_num}p_outline_back' name = f'{self.player_num}p_outline_back_half' if is_half else f'{self.player_num}p_outline_back'
tex.draw_texture('diff_select', name, x=((self.prev_diff+3) * 70) + (self.diff_selector_move_2.attribute * direction)) tex.draw_texture('diff_select', name, x=((self.prev_diff+3) * 70) + (self.diff_selector_move_2.attribute * direction))
else: else:
difficulty = min(3, self.selected_difficulty) difficulty = min(Difficulty.ONI, self.selected_difficulty)
name = f'{self.player_num}p_balloon_half' if is_half else f'{self.player_num}p_balloon' name = f'{self.player_num}p_balloon_half' if is_half else f'{self.player_num}p_balloon'
tex.draw_texture('diff_select', name, x=(difficulty * 115), fade=fade) tex.draw_texture('diff_select', name, x=(difficulty * 115), fade=fade)
name = f'{self.player_num}p_outline_half' if is_half else f'{self.player_num}p_outline' name = f'{self.player_num}p_outline_half' if is_half else f'{self.player_num}p_outline'
@@ -667,34 +667,34 @@ class SongSelectPlayer:
if self.prev_diff == -1: if self.prev_diff == -1:
return return
if not self.diff_selector_move_1.is_finished: if not self.diff_selector_move_1.is_finished:
difficulty = min(3, self.prev_diff) difficulty = min(Difficulty.ONI, self.prev_diff)
name = f'{self.player_num}p_balloon_half' if is_half else f'{self.player_num}p_balloon' name = f'{self.player_num}p_balloon_half' if is_half else f'{self.player_num}p_balloon'
tex.draw_texture('diff_select', name, x=(difficulty * 115) + (self.diff_selector_move_1.attribute * direction), fade=fade) tex.draw_texture('diff_select', name, x=(difficulty * 115) + (self.diff_selector_move_1.attribute * direction), fade=fade)
name = f'{self.player_num}p_outline_half' if is_half else f'{self.player_num}p_outline' name = f'{self.player_num}p_outline_half' if is_half else f'{self.player_num}p_outline'
tex.draw_texture('diff_select', name, x=(difficulty * 115) + (self.diff_selector_move_1.attribute * direction)) tex.draw_texture('diff_select', name, x=(difficulty * 115) + (self.diff_selector_move_1.attribute * direction))
else: else:
difficulty = min(3, self.selected_difficulty) difficulty = min(Difficulty.ONI, self.selected_difficulty)
name = f'{self.player_num}p_balloon_half' if is_half else f'{self.player_num}p_balloon' name = f'{self.player_num}p_balloon_half' if is_half else f'{self.player_num}p_balloon'
tex.draw_texture('diff_select', name, x=(difficulty * 115), fade=fade) tex.draw_texture('diff_select', name, x=(difficulty * 115), fade=fade)
name = f'{self.player_num}p_outline_half' if is_half else f'{self.player_num}p_outline' name = f'{self.player_num}p_outline_half' if is_half else f'{self.player_num}p_outline'
tex.draw_texture('diff_select', name, x=(difficulty * 115)) tex.draw_texture('diff_select', name, x=(difficulty * 115))
def draw_background_diffs(self, state: int): def draw_background_diffs(self, state: int):
if (self.selected_song and state == State.SONG_SELECTED and self.selected_difficulty >= 0): if (self.selected_song and state == State.SONG_SELECTED and self.selected_difficulty >= Difficulty.EASY):
if self.player_num == '2': if self.player_num == '2':
tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, fade=min(0.5, self.selected_diff_fadein.attribute), x=1025, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute) tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, fade=min(0.5, self.selected_diff_fadein.attribute), x=1025, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute)
if self.selected_diff_highlight_fade.is_reversing or self.selected_diff_highlight_fade.is_finished: if self.selected_diff_highlight_fade.is_reversing or self.selected_diff_highlight_fade.is_finished:
tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, x=1025, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute) tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, x=1025, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute)
tex.draw_texture('global', 'background_diff_highlight', frame=min(3, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute, x=1025) tex.draw_texture('global', 'background_diff_highlight', frame=min(Difficulty.ONI, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute, x=1025)
tex.draw_texture('global', 'bg_diff_text_bg', x=1025, fade=min(0.5, self.selected_diff_text_fadein.attribute), scale=self.selected_diff_text_resize.attribute, center=True) tex.draw_texture('global', 'bg_diff_text_bg', x=1025, fade=min(0.5, self.selected_diff_text_fadein.attribute), scale=self.selected_diff_text_resize.attribute, center=True)
tex.draw_texture('global', 'bg_diff_text', frame=min(3, self.selected_difficulty), x=1025, fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True) tex.draw_texture('global', 'bg_diff_text', frame=min(Difficulty.ONI, self.selected_difficulty), x=1025, fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True)
else: else:
tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, fade=min(0.5, self.selected_diff_fadein.attribute), y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute) tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, fade=min(0.5, self.selected_diff_fadein.attribute), y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute)
if self.selected_diff_highlight_fade.is_reversing or self.selected_diff_highlight_fade.is_finished: if self.selected_diff_highlight_fade.is_reversing or self.selected_diff_highlight_fade.is_finished:
tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute) tex.draw_texture('global', 'background_diff', frame=self.selected_difficulty, y=-self.selected_diff_bounce.attribute, y2=self.selected_diff_bounce.attribute)
tex.draw_texture('global', 'background_diff_highlight', frame=min(3, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute) tex.draw_texture('global', 'background_diff_highlight', frame=min(Difficulty.ONI, self.selected_difficulty), fade=self.selected_diff_highlight_fade.attribute)
tex.draw_texture('global', 'bg_diff_text_bg', fade=min(0.5, self.selected_diff_text_fadein.attribute), scale=self.selected_diff_text_resize.attribute, center=True) tex.draw_texture('global', 'bg_diff_text_bg', fade=min(0.5, self.selected_diff_text_fadein.attribute), scale=self.selected_diff_text_resize.attribute, center=True)
tex.draw_texture('global', 'bg_diff_text', frame=min(3, self.selected_difficulty), fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True) tex.draw_texture('global', 'bg_diff_text', frame=min(Difficulty.ONI, self.selected_difficulty), fade=self.selected_diff_text_fadein.attribute, scale=self.selected_diff_text_resize.attribute, center=True)
def draw(self, state: int, is_half: bool = False): def draw(self, state: int, is_half: bool = False):
if (self.selected_song and state == State.SONG_SELECTED): if (self.selected_song and state == State.SONG_SELECTED):
@@ -792,13 +792,13 @@ class DiffSortSelect:
def get_random_sort(self): def get_random_sort(self):
diff = random.randint(0, 4) diff = random.randint(0, 4)
if diff == 0: if diff == Difficulty.EASY:
level = random.randint(1, 5) level = random.randint(1, 5)
elif diff == 1: elif diff == Difficulty.NORMAL:
level = random.randint(1, 7) level = random.randint(1, 7)
elif diff == 2: elif diff == Difficulty.HARD:
level = random.randint(1, 8) level = random.randint(1, 8)
elif diff == 3: elif diff == Difficulty.ONI:
level = random.randint(1, 10) level = random.randint(1, 10)
else: else:
level = random.choice([1, 5, 6, 7, 8, 9, 10]) level = random.choice([1, 5, 6, 7, 8, 9, 10])
@@ -936,7 +936,7 @@ class DiffSortSelect:
if i < 4: if i < 4:
tex.draw_texture('diff_sort', 'box_diff', x=(100*i), frame=i) tex.draw_texture('diff_sort', 'box_diff', x=(100*i), frame=i)
if 0 <= self.selected_box <= 3 or self.selected_box == 5: if Difficulty.EASY <= self.selected_box <= Difficulty.ONI or self.selected_box == 5:
self.draw_statistics() self.draw_statistics()
def draw_level_select(self): def draw_level_select(self):

View File

@@ -37,8 +37,8 @@ class TwoPlayerGameScreen(GameScreen):
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[0]) / "don.ogg", 'hitsound_don_1p') audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[0]) / "don.ogg", 'hitsound_don_1p')
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[0]) / "ka.ogg", 'hitsound_kat_1p') audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[0]) / "ka.ogg", 'hitsound_kat_1p')
logger.info("Loaded ogg hit sounds for 1P") logger.info("Loaded ogg hit sounds for 1P")
audio.set_sound_pan('hitsound_don_1p', 1.0) audio.set_sound_pan('hitsound_don_1p', 0.0)
audio.set_sound_pan('hitsound_kat_1p', 1.0) audio.set_sound_pan('hitsound_kat_1p', 0.0)
# Load hitsounds for 2P # Load hitsounds for 2P
if global_data.hit_sound[1] == -1: if global_data.hit_sound[1] == -1:
@@ -53,8 +53,8 @@ class TwoPlayerGameScreen(GameScreen):
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[1]) / "don.ogg", 'hitsound_don_2p') audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[1]) / "don.ogg", 'hitsound_don_2p')
audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[1]) / "ka.ogg", 'hitsound_kat_2p') audio.load_sound(sounds_dir / "hit_sounds" / str(global_data.hit_sound[1]) / "ka.ogg", 'hitsound_kat_2p')
logger.info("Loaded ogg hit sounds for 2P") logger.info("Loaded ogg hit sounds for 2P")
audio.set_sound_pan('hitsound_don_2p', 0.0) audio.set_sound_pan('hitsound_don_2p', 1.0)
audio.set_sound_pan('hitsound_kat_2p', 0.0) audio.set_sound_pan('hitsound_kat_2p', 1.0)
def global_keys(self): def global_keys(self):
if ray.is_key_pressed(ray.KeyboardKey.KEY_F1): if ray.is_key_pressed(ray.KeyboardKey.KEY_F1):