add the timer and overlay and friends

This commit is contained in:
Anthony Samms
2025-10-14 02:59:17 -04:00
parent 0e668f991e
commit 2c82bc4aac
8 changed files with 135 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ visual_offset = 0
language = "ja" language = "ja"
hard_judge = 108 hard_judge = 108
touch_enabled = false touch_enabled = false
timer_frozen = true
[nameplate] [nameplate]
name = 'どんちゃん' name = 'どんちゃん'

View File

@@ -1,7 +1,7 @@
from enum import Enum from enum import Enum
import pyray as ray import pyray as ray
from libs.utils import OutlinedText, global_tex from libs.utils import OutlinedText, get_config, global_tex
class Nameplate: class Nameplate:
@@ -77,3 +77,78 @@ class Indicator:
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)) 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: else:
tex.draw_texture('indicator', 'drum_don', fade=min(fade, self.don_fade.attribute), index=self.state.value, x=x, y=y) tex.draw_texture('indicator', 'drum_don', fade=min(fade, self.don_fade.attribute), index=self.state.value, x=x, y=y)
class CoinOverlay:
def __init__(self):
pass
def update(self, current_time_ms: float):
pass
def draw(self, x: int = 0, y: int = 0):
tex = global_tex
tex.draw_texture('overlay', 'free_play', x=x, y=y)
class AllNetIcon:
def __init__(self):
pass
def update(self, current_time_ms: float):
pass
def draw(self, x: int = 0, y: int = 0):
tex = global_tex
tex.draw_texture('overlay', 'allnet_indicator', x=x, y=y, frame=0)
class EntryOverlay:
def __init__(self):
self.online = False
def update(self, current_time_ms: float):
pass
def draw(self, x: int = 0, y: int = 0):
tex = global_tex
tex.draw_texture('overlay', 'banapass_or', x=x, y=y, frame=self.online)
tex.draw_texture('overlay', 'banapass_card', x=x, y=y, frame=self.online)
tex.draw_texture('overlay', 'banapass_osaifu_keitai', x=x, y=y, frame=self.online)
if not self.online:
tex.draw_texture('overlay', 'banapass_no', x=x, y=y, frame=self.online)
tex.draw_texture('overlay', 'camera', x=x, y=y, frame=0)
class Timer:
def __init__(self, time: int, current_time_ms: float, confirm_func):
self.time = time
self.last_time = current_time_ms
self.counter = str(self.time)
self.num_resize = global_tex.get_animation(9)
self.highlight_resize = global_tex.get_animation(10)
self.highlight_fade = global_tex.get_animation(11)
self.confirm_func = confirm_func
self.is_finished = False
self.is_frozen = get_config()["general"]["timer_frozen"]
def update(self, current_time_ms: float):
if self.time == 0 and not self.is_finished:
self.is_finished = True
self.confirm_func()
self.num_resize.update(current_time_ms)
self.highlight_resize.update(current_time_ms)
self.highlight_fade.update(current_time_ms)
if self.is_frozen:
return
if current_time_ms >= self.last_time + 1000 and self.time > 0:
self.time -= 1
self.last_time = current_time_ms
self.counter = str(self.time)
if self.time < 10:
self.num_resize.start()
self.highlight_fade.start()
self.highlight_resize.start()
def draw(self, x: int = 0, y: int = 0):
tex = global_tex
if self.time < 10:
tex.draw_texture('timer', 'bg_red')
counter_name = 'counter_white'
tex.draw_texture('timer', 'highlight', fade=self.highlight_fade.attribute, scale=self.highlight_resize.attribute, center=True)
else:
tex.draw_texture('timer', 'bg')
counter_name = 'counter_black'
margin = 40
total_width = len(self.counter) * margin
for i, digit in enumerate(self.counter):
tex.draw_texture('timer', counter_name, frame=int(digit), x=-(total_width//2)+(i*margin), scale=self.num_resize.attribute, center=True)

View File

@@ -4,7 +4,7 @@ import pyray as ray
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 Nameplate, Indicator from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate, Indicator, EntryOverlay, Timer
from libs.texture import tex from libs.texture import tex
from libs.utils import ( from libs.utils import (
OutlinedText, OutlinedText,
@@ -44,6 +44,10 @@ class EntryScreen:
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.indicator = Indicator(Indicator.State.SELECT)
self.coin_overlay = CoinOverlay()
self.allnet_indicator = AllNetIcon()
self.entry_overlay = EntryOverlay()
self.timer = Timer(60, get_current_ms(), self.box_manager.select_box)
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)
@@ -125,6 +129,7 @@ class EntryScreen:
self.nameplate_fadein.update(current_time) self.nameplate_fadein.update(current_time)
self.nameplate.update(current_time) self.nameplate.update(current_time)
self.indicator.update(current_time) self.indicator.update(current_time)
self.timer.update(current_time)
self.chara.update(current_time, 100, False, False) self.chara.update(current_time, 100, False, False)
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())
@@ -224,6 +229,11 @@ class EntryScreen:
if self.box_manager.is_finished(): if self.box_manager.is_finished():
ray.draw_rectangle(0, 0, 1280, 720, ray.BLACK) ray.draw_rectangle(0, 0, 1280, 720, ray.BLACK)
self.timer.draw()
self.entry_overlay.draw(y=-10)
self.coin_overlay.draw()
self.allnet_indicator.draw()
def draw_3d(self): def draw_3d(self):
pass pass

View File

@@ -11,7 +11,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_objects import Nameplate from libs.global_objects import AllNetIcon, Nameplate
from libs.texture import tex from libs.texture import tex
from libs.tja import ( from libs.tja import (
Balloon, Balloon,
@@ -107,6 +107,7 @@ class GameScreen:
scene_preset = '' scene_preset = ''
self.background = Background(global_data.player_num, self.bpm, scene_preset=scene_preset) self.background = Background(global_data.player_num, self.bpm, scene_preset=scene_preset)
self.transition = Transition(session_data.song_title, subtitle, is_second=True) self.transition = Transition(session_data.song_title, subtitle, is_second=True)
self.allnet_indicator = AllNetIcon()
self.transition.start() self.transition.start()
def on_screen_end(self, next_screen): def on_screen_end(self, next_screen):
@@ -183,7 +184,7 @@ class GameScreen:
session_data.result_score, session_data.result_good, session_data.result_ok, session_data.result_bad, session_data.result_max_combo, session_data.result_total_drumroll = self.player_1.get_result_score() session_data.result_score, session_data.result_good, session_data.result_ok, session_data.result_bad, session_data.result_max_combo, session_data.result_total_drumroll = self.player_1.get_result_score()
session_data.result_gauge_length = self.player_1.gauge.gauge_length session_data.result_gauge_length = self.player_1.gauge.gauge_length
if self.end_ms != 0: if self.end_ms != 0:
if current_time >= self.end_ms + 500: if current_time >= self.end_ms + 1000:
if self.player_1.ending_anim is None: if self.player_1.ending_anim is None:
if session_data.result_bad == 0: if session_data.result_bad == 0:
self.player_1.ending_anim = FCAnimation() self.player_1.ending_anim = FCAnimation()
@@ -220,6 +221,7 @@ class GameScreen:
self.song_info.draw() self.song_info.draw()
self.transition.draw() self.transition.draw()
self.result_transition.draw() self.result_transition.draw()
self.allnet_indicator.draw()
def draw_3d(self): def draw_3d(self):
self.player_1.draw_3d() self.player_1.draw_3d()

View File

@@ -3,6 +3,7 @@ import threading
import pyray as ray import pyray as ray
from libs.animation import Animation from libs.animation import Animation
from libs.global_objects import AllNetIcon
from libs.song_hash import build_song_hashes from libs.song_hash import build_song_hashes
from libs.texture import tex from libs.texture import tex
from libs.utils import get_current_ms, global_data from libs.utils import get_current_ms, global_data
@@ -30,6 +31,7 @@ class LoadScreen:
self.navigator_thread = None self.navigator_thread = None
self.fade_in = None self.fade_in = None
self.allnet_indicator = AllNetIcon()
def _load_song_hashes(self): def _load_song_hashes(self):
"""Background thread function to load song hashes""" """Background thread function to load song hashes"""
@@ -104,5 +106,6 @@ class LoadScreen:
if self.fade_in is not None: if self.fade_in is not None:
ray.draw_rectangle(0, 0, self.width, self.height, ray.fade(ray.WHITE, self.fade_in.attribute)) ray.draw_rectangle(0, 0, self.width, self.height, ray.fade(ray.WHITE, self.fade_in.attribute))
self.allnet_indicator.draw()
def draw_3d(self): def draw_3d(self):
pass pass

View File

@@ -5,7 +5,7 @@ import pyray as ray
from libs import utils from libs import utils
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 Nameplate from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate
from libs.texture import tex from libs.texture import tex
from libs.utils import ( from libs.utils import (
OutlinedText, OutlinedText,
@@ -58,6 +58,8 @@ class ResultScreen:
self.nameplate = Nameplate(plate_info['name'], plate_info['title'], global_data.player_num, plate_info['dan'], plate_info['gold']) self.nameplate = Nameplate(plate_info['name'], plate_info['title'], global_data.player_num, plate_info['dan'], plate_info['gold'])
self.chara = Chara2D(global_data.player_num - 1, 100) self.chara = Chara2D(global_data.player_num - 1, 100)
self.score_animator = ScoreAnimator(session_data.result_score) self.score_animator = ScoreAnimator(session_data.result_score)
self.coin_overlay = CoinOverlay()
self.allnet_indicator = AllNetIcon()
self.score = '' self.score = ''
self.good = '' self.good = ''
self.ok = '' self.ok = ''
@@ -261,6 +263,8 @@ class ResultScreen:
self.fade_in.draw() self.fade_in.draw()
ray.draw_rectangle(0, 0, self.width, self.height, ray.fade(ray.BLACK, self.fade_out.attribute)) ray.draw_rectangle(0, 0, self.width, self.height, ray.fade(ray.BLACK, self.fade_out.attribute))
self.coin_overlay.draw()
self.allnet_indicator.draw()
def draw_3d(self): def draw_3d(self):
pass pass

View File

@@ -11,7 +11,7 @@ from libs.animation import Animation, MoveAnimation
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_data import Modifiers from libs.global_data import Modifiers
from libs.global_objects import Nameplate, Indicator from libs.global_objects import AllNetIcon, CoinOverlay, Nameplate, Indicator, Timer
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
@@ -86,9 +86,13 @@ class SongSelectScreen:
self.neiro_selector = None self.neiro_selector = None
self.modifier_selector = None self.modifier_selector = None
self.chara = Chara2D(global_data.player_num - 1, 100) self.chara = Chara2D(global_data.player_num - 1, 100)
self.coin_overlay = CoinOverlay()
self.allnet_indicator = AllNetIcon()
self.texture_index = SongBox.DEFAULT_INDEX self.texture_index = SongBox.DEFAULT_INDEX
self.last_texture_index = SongBox.DEFAULT_INDEX self.last_texture_index = SongBox.DEFAULT_INDEX
self.last_moved = get_current_ms() self.last_moved = get_current_ms()
self.timer_browsing = Timer(100, get_current_ms(), self.navigator.select_current_item)
self.timer_selected = Timer(40, get_current_ms(), self._confirm_selection)
self.ura_toggle = 0 self.ura_toggle = 0
self.is_ura = False self.is_ura = False
self.screen_init = True self.screen_init = True
@@ -278,6 +282,8 @@ class SongSelectScreen:
self.text_fade_out.reset() self.text_fade_out.reset()
self.text_fade_in.reset() self.text_fade_in.reset()
self.state = State.BROWSING self.state = State.BROWSING
self.timer_browsing = Timer(100, get_current_ms(), self.navigator.select_current_item)
self.timer_selected = Timer(40, get_current_ms(), self._confirm_selection)
self.navigator.reset_items() self.navigator.reset_items()
@@ -384,6 +390,11 @@ class SongSelectScreen:
self.blue_arrow_move.update(current_time) self.blue_arrow_move.update(current_time)
self.chara.update(current_time, 100, False, False) self.chara.update(current_time, 100, False, False)
if self.state == State.BROWSING or self.state == State.DIFF_SORTING:
self.timer_browsing.update(current_time)
elif self.state == State.SONG_SELECTED:
self.timer_selected.update(current_time)
if self.text_fade_out.is_finished: if self.text_fade_out.is_finished:
self.selected_song = True self.selected_song = True
@@ -561,9 +572,18 @@ class SongSelectScreen:
if self.modifier_selector is not None: if self.modifier_selector is not None:
self.modifier_selector.draw() self.modifier_selector.draw()
tex.draw_texture('global', 'song_num_bg', fade=0.75)
tex.draw_texture('global', 'song_num', frame=global_data.songs_played % 4)
if self.state == State.BROWSING or self.state == State.DIFF_SORTING:
self.timer_browsing.draw()
elif self.state == State.SONG_SELECTED:
self.timer_selected.draw()
self.coin_overlay.draw()
if self.game_transition is not None: if self.game_transition is not None:
self.game_transition.draw() self.game_transition.draw()
self.allnet_indicator.draw()
def draw_3d(self): def draw_3d(self):
pass pass

View File

@@ -2,10 +2,12 @@ import random
from pathlib import Path from pathlib import Path
from libs.audio import audio from libs.audio import audio
from libs.global_objects import AllNetIcon, CoinOverlay, EntryOverlay
from libs.texture import tex from libs.texture import tex
from libs.utils import ( from libs.utils import (
get_current_ms, get_current_ms,
global_data, global_data,
global_tex,
is_l_don_pressed, is_l_don_pressed,
is_r_don_pressed, is_r_don_pressed,
) )
@@ -24,6 +26,9 @@ class TitleScreen:
video_dir = Path(global_data.config["paths"]["video_path"]) / "attract_videos" video_dir = Path(global_data.config["paths"]["video_path"]) / "attract_videos"
self.attract_video_list = [file for file in video_dir.glob("**/*.mp4")] self.attract_video_list = [file for file in video_dir.glob("**/*.mp4")]
self.screen_init = False self.screen_init = False
self.coin_overlay = CoinOverlay()
self.allnet_indicator = AllNetIcon()
self.entry_overlay = EntryOverlay()
def load_sounds(self): def load_sounds(self):
sounds_dir = Path("Sounds") sounds_dir = Path("Sounds")
@@ -44,6 +49,7 @@ class TitleScreen:
self.attract_video = None self.attract_video = None
self.warning_board = None self.warning_board = None
self.fade_out = tex.get_animation(13) self.fade_out = tex.get_animation(13)
self.text_overlay_fade = tex.get_animation(14)
def on_screen_end(self) -> str: def on_screen_end(self) -> str:
if self.op_video is not None: if self.op_video is not None:
@@ -86,6 +92,7 @@ class TitleScreen:
def update(self): def update(self):
self.on_screen_start() self.on_screen_start()
self.text_overlay_fade.update(get_current_ms())
self.fade_out.update(get_current_ms()) self.fade_out.update(get_current_ms())
if self.fade_out.is_finished: if self.fade_out.is_finished:
self.fade_out.update(get_current_ms()) self.fade_out.update(get_current_ms())
@@ -106,6 +113,12 @@ class TitleScreen:
self.attract_video.draw() self.attract_video.draw()
tex.draw_texture('movie', 'background', fade=self.fade_out.attribute) tex.draw_texture('movie', 'background', fade=self.fade_out.attribute)
self.coin_overlay.draw()
self.allnet_indicator.draw()
self.entry_overlay.draw(x=155, y=-10)
global_tex.draw_texture('overlay', 'hit_taiko_to_start', index=0, fade=self.text_overlay_fade.attribute)
global_tex.draw_texture('overlay', 'hit_taiko_to_start', index=1, fade=self.text_overlay_fade.attribute)
def draw_3d(self): def draw_3d(self):
pass pass