add progress bar to practice mode

This commit is contained in:
Anthony Samms
2025-11-11 13:47:31 -05:00
parent 897d98ae41
commit e16584da4b
3 changed files with 28 additions and 3 deletions

View File

@@ -199,7 +199,7 @@ class TextureWrapper:
def draw_texture(self, subset: str, texture: str, color: ray.Color=ray.WHITE, frame: int = 0, scale: float = 1.0, center: bool = False, def draw_texture(self, subset: str, texture: str, color: ray.Color=ray.WHITE, frame: int = 0, scale: float = 1.0, center: bool = False,
mirror: str = '', x: float = 0, y: float = 0, x2: float = 0, y2: float = 0, mirror: str = '', x: float = 0, y: float = 0, x2: float = 0, y2: float = 0,
origin: ray.Vector2 = ray.Vector2(0,0), rotation: float = 0, fade: float = 1.1, origin: ray.Vector2 = ray.Vector2(0,0), rotation: float = 0, fade: float = 1.1,
index: int = 0, src: Optional[ray.Rectangle] = None) -> None: index: int = 0, src: Optional[ray.Rectangle] = None, controllable: bool = False) -> None:
""" """
Wrapper function for raylib's draw_texture_pro(). Wrapper function for raylib's draw_texture_pro().
Parameters: Parameters:
@@ -219,6 +219,7 @@ class TextureWrapper:
fade (float): The fade factor to apply to the texture. fade (float): The fade factor to apply to the texture.
index (int): The index of the position data for the texture. Only used if the texture has multiple positions. index (int): The index of the position data for the texture. Only used if the texture has multiple positions.
src (Optional[ray.Rectangle]): The source rectangle of the texture. src (Optional[ray.Rectangle]): The source rectangle of the texture.
controllable (bool): Whether the texture is controllable.
""" """
mirror_x = -1 if mirror == 'horizontal' else 1 mirror_x = -1 if mirror == 'horizontal' else 1
mirror_y = -1 if mirror == 'vertical' else 1 mirror_y = -1 if mirror == 'vertical' else 1
@@ -246,7 +247,7 @@ class TextureWrapper:
if isinstance(tex_object.texture, list): if isinstance(tex_object.texture, list):
raise Exception("Texture is multiframe but was called as 1 texture") raise Exception("Texture is multiframe but was called as 1 texture")
ray.draw_texture_pro(tex_object.texture, source_rect, dest_rect, origin, rotation, final_color) ray.draw_texture_pro(tex_object.texture, source_rect, dest_rect, origin, rotation, final_color)
if tex_object.controllable[index]: if tex_object.controllable[index] or controllable:
self.control(tex_object) self.control(tex_object)
tex = TextureWrapper() tex = TextureWrapper()

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, TJAParser, apply_modifiers from libs.tja import Balloon, Drumroll, Note, 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 GameScreen, JudgeCounter, Player, SCREEN_WIDTH from scenes.game import GameScreen, JudgeCounter, Player, SCREEN_WIDTH
@@ -36,6 +36,18 @@ class PracticeGameScreen(GameScreen):
self.scrobble_time = self.bars[self.scrobble_index].hit_ms self.scrobble_time = self.bars[self.scrobble_index].hit_ms
self.scrobble_move = Animation.create_move(200, total_distance=0) self.scrobble_move = Animation.create_move(200, total_distance=0)
self.markers = self.get_gogotime_markers(self.scrobble_note_list)
def get_gogotime_markers(self, note_list: deque[Note | Drumroll | Balloon]):
marker_list = []
for i, note in enumerate(note_list):
if i == 0 and note.gogo_time:
marker_list.append(note.hit_ms)
elif i > 0 and note.gogo_time:
if not note_list[i-1].gogo_time:
marker_list.append(note.hit_ms)
return marker_list
def pause_song(self): def pause_song(self):
self.paused = not self.paused self.paused = not self.paused
self.player_1.paused = self.paused self.player_1.paused = self.paused
@@ -231,6 +243,14 @@ class PracticeGameScreen(GameScreen):
if self.paused: if self.paused:
self.draw_scrobble_list() self.draw_scrobble_list()
self.player_1.draw_overlays(self.mask_shader) self.player_1.draw_overlays(self.mask_shader)
tex.draw_texture('practice', 'progress_bar_bg')
if self.paused:
progress = (self.scrobble_time + self.scrobble_move.attribute - self.bars[0].hit_ms) / self.player_1.end_time
else:
progress = self.current_ms / self.player_1.end_time
tex.draw_texture('practice', 'progress_bar', x2=progress * 890)
for marker in self.markers:
tex.draw_texture('practice', 'gogo_marker', x=((marker - self.bars[0].hit_ms) / self.player_1.end_time) * 890)
self.draw_overlay() self.draw_overlay()

4
uv.lock generated
View File

@@ -1,6 +1,10 @@
version = 1 version = 1
revision = 3 revision = 3
requires-python = ">=3.11" requires-python = ">=3.11"
resolution-markers = [
"python_full_version >= '3.12'",
"python_full_version < '3.12'",
]
[[package]] [[package]]
name = "cffi" name = "cffi"