add indicator

This commit is contained in:
Anthony Samms
2025-09-11 13:19:37 -04:00
parent 381d5c4332
commit 06075f8e49
6 changed files with 53 additions and 5 deletions

View File

@@ -79,7 +79,6 @@ def main():
ray.init_window(screen_width, screen_height, "PyTaiko") ray.init_window(screen_width, screen_height, "PyTaiko")
global_data.tex.load_screen_textures('global') global_data.tex.load_screen_textures('global')
global_data.tex.load_screen_textures('transition')
if global_data.config["video"]["borderless"]: if global_data.config["video"]["borderless"]:
ray.toggle_borderless_windowed() ray.toggle_borderless_windowed()
if global_data.config["video"]["fullscreen"]: if global_data.config["video"]["fullscreen"]:

View File

@@ -1,3 +1,4 @@
from enum import Enum
import pyray as ray import pyray as ray
from libs.utils import OutlinedText, global_data from libs.utils import OutlinedText, global_data
@@ -42,3 +43,37 @@ class Nameplate:
self.name.draw(self.name.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, fade)) self.name.draw(self.name.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, fade))
dest = ray.Rectangle(x+136 - (self.title.texture.width//2) + title_offset, y-3, self.title.texture.width, self.title.texture.height) dest = ray.Rectangle(x+136 - (self.title.texture.width//2) + title_offset, y-3, self.title.texture.width, self.title.texture.height)
self.title.draw(self.title.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, fade)) self.title.draw(self.title.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, fade))
class Indicator:
class State(Enum):
SKIP = 0
SIDE = 1
SELECT = 2
WAIT = 3
def __init__(self, state: State):
self.state = state
self.don_fade = global_data.tex.get_animation(6)
self.blue_arrow_move = global_data.tex.get_animation(7)
self.blue_arrow_fade = global_data.tex.get_animation(8)
def update(self, current_time_ms: float):
self.don_fade.update(current_time_ms)
self.blue_arrow_move.update(current_time_ms)
self.blue_arrow_fade.update(current_time_ms)
def draw(self, x: int, y: int, fade=1.0):
tex = global_data.tex
tex.draw_texture('indicator', 'background', x=x, y=y, fade=fade)
tex.draw_texture('indicator', 'text', frame=self.state.value, x=x, y=y, fade=fade)
tex.draw_texture('indicator', 'drum_face', index=self.state.value, x=x, y=y, fade=fade)
if self.state == Indicator.State.SELECT:
tex.draw_texture('indicator', 'drum_kat', fade=min(fade, self.don_fade.attribute), x=x, y=y)
tex.draw_texture('indicator', 'drum_kat', fade=min(fade, self.don_fade.attribute), x=x+23, y=y, mirror='horizontal')
tex.draw_texture('indicator', 'drum_face', x=x+175, y=y, fade=fade)
tex.draw_texture('indicator', 'drum_don', fade=min(fade, self.don_fade.attribute), index=self.state.value, x=x+214, y=y)
tex.draw_texture('indicator', 'blue_arrow', x=x-self.blue_arrow_move.attribute, y=y, fade=min(fade, self.blue_arrow_fade.attribute))
tex.draw_texture('indicator', 'blue_arrow', index=1, x=x+self.blue_arrow_move.attribute, y=y, mirror='horizontal', fade=min(fade, self.blue_arrow_fade.attribute))
else:
tex.draw_texture('indicator', 'drum_don', fade=min(fade, self.don_fade.attribute), index=self.state.value, x=x, y=y)

View File

@@ -1,5 +1,8 @@
import pyray as ray import pyray as ray
from libs.global_objects import Indicator
from libs.utils import get_current_ms
class DevScreen: class DevScreen:
def __init__(self): def __init__(self):
@@ -10,7 +13,7 @@ class DevScreen:
def on_screen_start(self): def on_screen_start(self):
if not self.screen_init: if not self.screen_init:
self.screen_init = True self.screen_init = True
self.indicator = Indicator(Indicator.State.SELECT)
def on_screen_end(self, next_screen: str): def on_screen_end(self, next_screen: str):
self.screen_init = False self.screen_init = False
@@ -18,11 +21,13 @@ class DevScreen:
def update(self): def update(self):
self.on_screen_start() self.on_screen_start()
self.indicator.update(get_current_ms())
if ray.is_key_pressed(ray.KeyboardKey.KEY_ENTER): if ray.is_key_pressed(ray.KeyboardKey.KEY_ENTER):
return self.on_screen_end('GAME') return self.on_screen_end('GAME')
def draw(self): def draw(self):
ray.draw_rectangle(0, 0, 1280, 720, ray.GREEN) ray.draw_rectangle(0, 0, 1280, 720, ray.GREEN)
self.indicator.draw(430, 575)
def draw_3d(self): def draw_3d(self):
pass pass

View File

@@ -3,7 +3,7 @@ from pathlib import Path
import pyray as ray import pyray as ray
from libs.audio import audio from libs.audio import audio
from libs.global_objects import Nameplate from libs.global_objects import Nameplate, Indicator
from libs.texture import tex from libs.texture import tex
from libs.utils import ( from libs.utils import (
OutlinedText, OutlinedText,
@@ -42,6 +42,7 @@ class EntryScreen:
self.state = State.SELECT_SIDE self.state = State.SELECT_SIDE
plate_info = global_data.config['nameplate'] plate_info = global_data.config['nameplate']
self.nameplate = Nameplate(plate_info['name'], plate_info['title'], -1, -1, False) self.nameplate = Nameplate(plate_info['name'], plate_info['title'], -1, -1, False)
self.indicator = Indicator(Indicator.State.SELECT)
self.screen_init = True self.screen_init = True
self.side_select_fade = tex.get_animation(0) self.side_select_fade = tex.get_animation(0)
self.bg_flicker = tex.get_animation(1) self.bg_flicker = tex.get_animation(1)
@@ -116,6 +117,7 @@ class EntryScreen:
self.box_manager.update(get_current_ms()) self.box_manager.update(get_current_ms())
self.nameplate_fadein.update(get_current_ms()) self.nameplate_fadein.update(get_current_ms())
self.nameplate.update(get_current_ms()) self.nameplate.update(get_current_ms())
self.indicator.update(get_current_ms())
if self.box_manager.is_finished(): if self.box_manager.is_finished():
return self.on_screen_end(self.box_manager.selected_box()) return self.on_screen_end(self.box_manager.selected_box())
return self.handle_input() return self.handle_input()
@@ -198,8 +200,10 @@ class EntryScreen:
if self.state == State.SELECT_MODE: if self.state == State.SELECT_MODE:
if self.side == 0: if self.side == 0:
self.nameplate.draw(30, 640, fade=self.nameplate_fadein.attribute) self.nameplate.draw(30, 640, fade=self.nameplate_fadein.attribute)
self.indicator.draw(50, 575, fade=self.nameplate_fadein.attribute)
else: else:
self.nameplate.draw(950, 640, fade=self.nameplate_fadein.attribute) self.nameplate.draw(950, 640, fade=self.nameplate_fadein.attribute)
self.indicator.draw(770, 575, fade=self.nameplate_fadein.attribute)
tex.draw_texture('global', 'player_entry') tex.draw_texture('global', 'player_entry')

View File

@@ -709,6 +709,7 @@ class Player:
tex.draw_texture('lane', 'lane_score_cover') tex.draw_texture('lane', 'lane_score_cover')
tex.draw_texture('lane', f'{self.player_number}p_icon') tex.draw_texture('lane', f'{self.player_number}p_icon')
tex.draw_texture('lane', 'lane_difficulty', frame=self.difficulty) tex.draw_texture('lane', 'lane_difficulty', frame=self.difficulty)
if not global_data.modifiers.auto:
self.nameplate.draw(-62, 285) self.nameplate.draw(-62, 285)
self.draw_modifiers() self.draw_modifiers()
if self.drumroll_counter is not None: if self.drumroll_counter is not None:

View File

@@ -9,7 +9,7 @@ import pyray as ray
from libs.animation import Animation, MoveAnimation from libs.animation import Animation, MoveAnimation
from libs.audio import audio from libs.audio import audio
from libs.global_objects import Nameplate from libs.global_objects import Nameplate, Indicator
from libs.texture import tex from libs.texture import tex
from libs.tja import TJAParser, test_encodings from libs.tja import TJAParser, test_encodings
from libs.transition import Transition from libs.transition import Transition
@@ -37,6 +37,7 @@ class SongSelectScreen:
self.screen_init = False self.screen_init = False
self.root_dir = global_data.config["paths"]["tja_path"] self.root_dir = global_data.config["paths"]["tja_path"]
self.screen_width = screen_width self.screen_width = screen_width
self.indicator = Indicator(Indicator.State.SELECT)
def load_navigator(self): def load_navigator(self):
self.navigator = FileNavigator(self.root_dir) self.navigator = FileNavigator(self.root_dir)
@@ -360,6 +361,7 @@ class SongSelectScreen:
self.diff_selector_move_1.update(get_current_ms()) self.diff_selector_move_1.update(get_current_ms())
self.diff_selector_move_2.update(get_current_ms()) self.diff_selector_move_2.update(get_current_ms())
self.nameplate.update(get_current_ms()) self.nameplate.update(get_current_ms())
self.indicator.update(get_current_ms())
if self.text_fade_out.is_finished: if self.text_fade_out.is_finished:
self.selected_song = True self.selected_song = True
@@ -495,6 +497,8 @@ class SongSelectScreen:
if self.game_transition is not None: if self.game_transition is not None:
self.game_transition.draw() self.game_transition.draw()
self.indicator.draw(410, 575)
def draw_3d(self): def draw_3d(self):
pass pass