diff --git a/PyTaiko.py b/PyTaiko.py index 0908094..a0dc86a 100644 --- a/PyTaiko.py +++ b/PyTaiko.py @@ -79,7 +79,6 @@ def main(): ray.init_window(screen_width, screen_height, "PyTaiko") global_data.tex.load_screen_textures('global') - global_data.tex.load_screen_textures('transition') if global_data.config["video"]["borderless"]: ray.toggle_borderless_windowed() if global_data.config["video"]["fullscreen"]: diff --git a/libs/global_objects.py b/libs/global_objects.py index 5e9101b..6d8da28 100644 --- a/libs/global_objects.py +++ b/libs/global_objects.py @@ -1,3 +1,4 @@ +from enum import Enum import pyray as ray 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)) 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)) + +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) diff --git a/scenes/devtest.py b/scenes/devtest.py index 688d3d1..83626a7 100644 --- a/scenes/devtest.py +++ b/scenes/devtest.py @@ -1,5 +1,8 @@ import pyray as ray +from libs.global_objects import Indicator +from libs.utils import get_current_ms + class DevScreen: def __init__(self): @@ -10,7 +13,7 @@ class DevScreen: def on_screen_start(self): if not self.screen_init: self.screen_init = True - + self.indicator = Indicator(Indicator.State.SELECT) def on_screen_end(self, next_screen: str): self.screen_init = False @@ -18,11 +21,13 @@ class DevScreen: def update(self): self.on_screen_start() + self.indicator.update(get_current_ms()) if ray.is_key_pressed(ray.KeyboardKey.KEY_ENTER): return self.on_screen_end('GAME') def draw(self): ray.draw_rectangle(0, 0, 1280, 720, ray.GREEN) + self.indicator.draw(430, 575) def draw_3d(self): pass diff --git a/scenes/entry.py b/scenes/entry.py index 5cb7f63..6fb127a 100644 --- a/scenes/entry.py +++ b/scenes/entry.py @@ -3,7 +3,7 @@ from pathlib import Path import pyray as ray 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.utils import ( OutlinedText, @@ -42,6 +42,7 @@ class EntryScreen: self.state = State.SELECT_SIDE plate_info = global_data.config['nameplate'] self.nameplate = Nameplate(plate_info['name'], plate_info['title'], -1, -1, False) + self.indicator = Indicator(Indicator.State.SELECT) self.screen_init = True self.side_select_fade = tex.get_animation(0) self.bg_flicker = tex.get_animation(1) @@ -116,6 +117,7 @@ class EntryScreen: self.box_manager.update(get_current_ms()) self.nameplate_fadein.update(get_current_ms()) self.nameplate.update(get_current_ms()) + self.indicator.update(get_current_ms()) if self.box_manager.is_finished(): return self.on_screen_end(self.box_manager.selected_box()) return self.handle_input() @@ -198,8 +200,10 @@ class EntryScreen: if self.state == State.SELECT_MODE: if self.side == 0: self.nameplate.draw(30, 640, fade=self.nameplate_fadein.attribute) + self.indicator.draw(50, 575, fade=self.nameplate_fadein.attribute) else: 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') diff --git a/scenes/game.py b/scenes/game.py index e636c4d..22197ff 100644 --- a/scenes/game.py +++ b/scenes/game.py @@ -709,7 +709,8 @@ class Player: tex.draw_texture('lane', 'lane_score_cover') tex.draw_texture('lane', f'{self.player_number}p_icon') tex.draw_texture('lane', 'lane_difficulty', frame=self.difficulty) - self.nameplate.draw(-62, 285) + if not global_data.modifiers.auto: + self.nameplate.draw(-62, 285) self.draw_modifiers() if self.drumroll_counter is not None: self.drumroll_counter.draw() diff --git a/scenes/song_select.py b/scenes/song_select.py index cad6289..06880eb 100644 --- a/scenes/song_select.py +++ b/scenes/song_select.py @@ -9,7 +9,7 @@ import pyray as ray from libs.animation import Animation, MoveAnimation 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.tja import TJAParser, test_encodings from libs.transition import Transition @@ -37,6 +37,7 @@ class SongSelectScreen: self.screen_init = False self.root_dir = global_data.config["paths"]["tja_path"] self.screen_width = screen_width + self.indicator = Indicator(Indicator.State.SELECT) def load_navigator(self): 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_2.update(get_current_ms()) self.nameplate.update(get_current_ms()) + self.indicator.update(get_current_ms()) if self.text_fade_out.is_finished: self.selected_song = True @@ -495,6 +497,8 @@ class SongSelectScreen: if self.game_transition is not None: self.game_transition.draw() + self.indicator.draw(410, 575) + def draw_3d(self): pass