add nameplates

This commit is contained in:
Yonokid
2025-08-29 11:00:02 -04:00
parent 1dd4e166b7
commit 4bc537bf6d
10 changed files with 78 additions and 7 deletions

View File

@@ -76,6 +76,7 @@ def main():
camera.projection = CAMERA_ORTHOGRAPHIC camera.projection = CAMERA_ORTHOGRAPHIC
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('transition') 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()

View File

@@ -5,6 +5,12 @@ visual_offset = 0
language = "ja" language = "ja"
hard_judge = 108 hard_judge = 108
[nameplate]
name = 'どんちゃん'
title = 'ドンだーデビュー!'
dan = -1
gold = false
[paths] [paths]
tja_path = ['Songs'] tja_path = ['Songs']
video_path = 'Videos' video_path = 'Videos'

View File

@@ -93,6 +93,8 @@ class DonBG3(DonBGBase):
super().__init__(tex, index, player_num) super().__init__(tex, index, player_num)
self.bounce_up = tex.get_animation(4) self.bounce_up = tex.get_animation(4)
self.bounce_down = tex.get_animation(5) self.bounce_down = tex.get_animation(5)
self.bounce_up.start()
self.bounce_down.start()
self.overlay_move = tex.get_animation(6) self.overlay_move = tex.get_animation(6)
self.overlay_move_2 = tex.get_animation(7) self.overlay_move_2 = tex.get_animation(7)
@@ -100,6 +102,9 @@ class DonBG3(DonBGBase):
super().update(current_time_ms, is_clear) super().update(current_time_ms, is_clear)
self.bounce_up.update(current_time_ms) self.bounce_up.update(current_time_ms)
self.bounce_down.update(current_time_ms) self.bounce_down.update(current_time_ms)
if self.bounce_up.is_finished:
self.bounce_up.restart()
self.bounce_down.restart()
self.overlay_move.update(current_time_ms) self.overlay_move.update(current_time_ms)
self.overlay_move_2.update(current_time_ms) self.overlay_move_2.update(current_time_ms)
@@ -137,12 +142,17 @@ class DonBG5(DonBGBase):
super().__init__(tex, index, player_num) super().__init__(tex, index, player_num)
self.bounce_up = tex.get_animation(4) self.bounce_up = tex.get_animation(4)
self.bounce_down = tex.get_animation(5) self.bounce_down = tex.get_animation(5)
self.bounce_up.start()
self.bounce_down.start()
self.adjust = tex.get_animation(8) self.adjust = tex.get_animation(8)
def update(self, current_time_ms: float, is_clear: bool): def update(self, current_time_ms: float, is_clear: bool):
super().update(current_time_ms, is_clear) super().update(current_time_ms, is_clear)
self.bounce_up.update(current_time_ms) self.bounce_up.update(current_time_ms)
self.bounce_down.update(current_time_ms) self.bounce_down.update(current_time_ms)
if self.bounce_up.is_finished:
self.bounce_up.restart()
self.bounce_down.restart()
self.adjust.update(current_time_ms) self.adjust.update(current_time_ms)
def draw(self, tex: TextureWrapper): def draw(self, tex: TextureWrapper):
@@ -321,7 +331,7 @@ class BGFever:
@staticmethod @staticmethod
def create(tex: TextureWrapper, index: int): def create(tex: TextureWrapper, index: int):
map = [None, None, None, BGFever4] map = [BGFever1, None, None, BGFever4]
selected_obj = map[index] selected_obj = map[index]
return selected_obj(tex, index) return selected_obj(tex, index)
@@ -331,6 +341,19 @@ class BGFeverBase:
tex.load_zip('background', f'bg_fever/{self.name}') tex.load_zip('background', f'bg_fever/{self.name}')
self.transitioned = False self.transitioned = False
class BGFever1(BGFeverBase):
def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index)
def start(self):
pass
def update(self, current_time_ms: float):
pass
def draw(self, tex: TextureWrapper):
pass
class BGFever4(BGFeverBase): class BGFever4(BGFeverBase):
def __init__(self, tex: TextureWrapper, index: int): def __init__(self, tex: TextureWrapper, index: int):
super().__init__(tex, index) super().__init__(tex, index)

View File

@@ -130,7 +130,6 @@ class TextureWrapper:
raise Exception(f"Texture {tex_name} was not found in {zip}") raise Exception(f"Texture {tex_name} was not found in {zip}")
def load_screen_textures(self, screen_name: str) -> None: def load_screen_textures(self, screen_name: str) -> None:
self.unload_textures()
screen_path = self.graphics_path / screen_name screen_path = self.graphics_path / screen_name
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

@@ -252,6 +252,7 @@ class OutlinedText:
def __init__(self, text: str, font_size: int, color: ray.Color, outline_color: ray.Color, outline_thickness=5.0, vertical=False): def __init__(self, text: str, font_size: int, color: ray.Color, outline_color: ray.Color, outline_thickness=5.0, vertical=False):
self.text = text self.text = text
self.hash = self._hash_text(text, font_size, color, vertical) self.hash = self._hash_text(text, font_size, color, vertical)
self.outline_thickness = outline_thickness
if self.hash in text_cache: if self.hash in text_cache:
self.texture = ray.load_texture(f'cache/image/{self.hash}.png') self.texture = ray.load_texture(f'cache/image/{self.hash}.png')
else: else:
@@ -260,7 +261,7 @@ class OutlinedText:
self.texture = self._create_text_vertical(text, font_size, color, ray.BLANK, self.font) self.texture = self._create_text_vertical(text, font_size, color, ray.BLANK, self.font)
else: else:
self.texture = self._create_text_horizontal(text, font_size, color, ray.BLANK, self.font) self.texture = self._create_text_horizontal(text, font_size, color, ray.BLANK, self.font)
outline_size = ray.ffi.new('float*', outline_thickness) outline_size = ray.ffi.new('float*', self.outline_thickness)
if isinstance(outline_color, tuple): if isinstance(outline_color, tuple):
outline_color_alloc = ray.ffi.new("float[4]", [ outline_color_alloc = ray.ffi.new("float[4]", [
outline_color[0] / 255.0, outline_color[0] / 255.0,
@@ -498,9 +499,11 @@ class OutlinedText:
else: else:
alpha_value = ray.ffi.new('float*', color.a / 255.0) alpha_value = ray.ffi.new('float*', color.a / 255.0)
ray.set_shader_value(self.shader, self.alpha_loc, alpha_value, SHADER_UNIFORM_FLOAT) ray.set_shader_value(self.shader, self.alpha_loc, alpha_value, SHADER_UNIFORM_FLOAT)
ray.begin_shader_mode(self.shader) if self.outline_thickness > 0:
ray.begin_shader_mode(self.shader)
ray.draw_texture_pro(self.texture, src, dest, origin, rotation, color) ray.draw_texture_pro(self.texture, src, dest, origin, rotation, color)
ray.end_shader_mode() if self.outline_thickness > 0:
ray.end_shader_mode()
def unload(self): def unload(self):
ray.unload_shader(self.shader) ray.unload_shader(self.shader)

View File

@@ -22,7 +22,7 @@ class DevScreen:
return self.on_screen_end('GAME') return self.on_screen_end('GAME')
def draw(self): def draw(self):
pass ray.draw_rectangle(0, 0, 1280, 720, ray.GREEN)
def draw_3d(self): def draw_3d(self):
pass pass

View File

@@ -3,6 +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.texture import tex from libs.texture import tex
from libs.utils import ( from libs.utils import (
OutlinedText, OutlinedText,
@@ -39,6 +40,8 @@ class EntryScreen:
self.side = 1 self.side = 1
self.box_manager = BoxManager() self.box_manager = BoxManager()
self.state = State.SELECT_SIDE self.state = State.SELECT_SIDE
plate_info = global_data.config['nameplate']
self.nameplate = Nameplate(plate_info['name'], plate_info['title'], -1, -1, False)
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)
@@ -49,6 +52,7 @@ class EntryScreen:
self.cloud_resize_loop = tex.get_animation(6) self.cloud_resize_loop = tex.get_animation(6)
self.cloud_texture_change = tex.get_animation(7) self.cloud_texture_change = tex.get_animation(7)
self.cloud_fade = tex.get_animation(8) self.cloud_fade = tex.get_animation(8)
self.nameplate_fadein = tex.get_animation(12)
self.side_select_fade.start() self.side_select_fade.start()
audio.play_sound(self.bgm) audio.play_sound(self.bgm)
@@ -56,6 +60,7 @@ class EntryScreen:
self.screen_init = False self.screen_init = False
global_data.player_num = round((self.side/3) + 1) global_data.player_num = round((self.side/3) + 1)
audio.stop_sound(self.bgm) audio.stop_sound(self.bgm)
self.nameplate.unload()
tex.unload_textures() tex.unload_textures()
audio.unload_all_sounds() audio.unload_all_sounds()
return next_screen return next_screen
@@ -74,6 +79,10 @@ class EntryScreen:
self.cloud_resize_loop.start() self.cloud_resize_loop.start()
self.cloud_texture_change.start() self.cloud_texture_change.start()
self.cloud_fade.start() self.cloud_fade.start()
plate_info = global_data.config['nameplate']
self.nameplate.unload()
self.nameplate = Nameplate(plate_info['name'], plate_info['title'], round((self.side/3) + 1), plate_info['dan'], plate_info['gold'])
self.nameplate_fadein.start()
self.state = State.SELECT_MODE self.state = State.SELECT_MODE
audio.play_sound(self.sound_don) audio.play_sound(self.sound_don)
if is_l_kat_pressed(): if is_l_kat_pressed():
@@ -105,6 +114,8 @@ class EntryScreen:
self.cloud_fade.update(get_current_ms()) self.cloud_fade.update(get_current_ms())
self.cloud_resize_loop.update(get_current_ms()) self.cloud_resize_loop.update(get_current_ms())
self.box_manager.update(get_current_ms()) self.box_manager.update(get_current_ms())
self.nameplate_fadein.update(get_current_ms())
self.nameplate.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()
@@ -152,6 +163,7 @@ class EntryScreen:
tex.draw_texture('side_select', '2P_highlight', fade=fade) tex.draw_texture('side_select', '2P_highlight', fade=fade)
tex.draw_texture('side_select', '1P2P_outline', index=1, fade=fade) tex.draw_texture('side_select', '1P2P_outline', index=1, fade=fade)
tex.draw_texture('side_select', 'cancel_text', fade=fade) tex.draw_texture('side_select', 'cancel_text', fade=fade)
self.nameplate.draw(500, 185)
def draw_player_drum(self): def draw_player_drum(self):
move_x = self.drum_move_3.attribute move_x = self.drum_move_3.attribute
@@ -183,6 +195,12 @@ class EntryScreen:
self.draw_mode_select() self.draw_mode_select()
self.draw_footer() self.draw_footer()
if self.state == State.SELECT_MODE:
if self.side == 0:
self.nameplate.draw(30, 640, fade=self.nameplate_fadein.attribute)
else:
self.nameplate.draw(950, 640, fade=self.nameplate_fadein.attribute)
tex.draw_texture('global', 'player_entry') tex.draw_texture('global', 'player_entry')
if self.box_manager.is_finished(): if self.box_manager.is_finished():

View File

@@ -10,6 +10,7 @@ import pyray as ray
from libs.animation import Animation from libs.animation import Animation
from libs.audio import audio from libs.audio import audio
from libs.backgrounds import Background from libs.backgrounds import Background
from libs.global_objects import Nameplate
from libs.texture import tex from libs.texture import tex
from libs.tja import ( from libs.tja import (
Balloon, Balloon,
@@ -246,6 +247,8 @@ class Player:
self.base_score_list: list[ScoreCounterAnimation] = [] self.base_score_list: list[ScoreCounterAnimation] = []
self.combo_display = Combo(self.combo, get_current_ms()) self.combo_display = Combo(self.combo, get_current_ms())
self.score_counter = ScoreCounter(self.score) self.score_counter = ScoreCounter(self.score)
plate_info = global_data.config['nameplate']
self.nameplate = Nameplate(plate_info['name'], plate_info['title'], global_data.player_num, plate_info['dan'], plate_info['gold'])
self.input_log: dict[float, tuple] = dict() self.input_log: dict[float, tuple] = dict()
@@ -573,7 +576,7 @@ class Player:
self.score_counter.update(get_current_ms(), self.score) self.score_counter.update(get_current_ms(), self.score)
self.autoplay_manager(game_screen) self.autoplay_manager(game_screen)
self.handle_input(game_screen) self.handle_input(game_screen)
self.nameplate.update(get_current_ms())
self.gauge.update(get_current_ms()) self.gauge.update(get_current_ms())
def draw_drumroll(self, game_screen: GameScreen, head: Drumroll, current_eighth: int): def draw_drumroll(self, game_screen: GameScreen, head: Drumroll, current_eighth: int):
@@ -694,6 +697,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)
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:
self.drumroll_counter.draw() self.drumroll_counter.draw()

View File

@@ -5,6 +5,7 @@ from raylib import SHADER_UNIFORM_FLOAT
from libs import utils from libs import utils
from libs.audio import audio from libs.audio import audio
from libs.global_objects import Nameplate
from libs.texture import tex from libs.texture import tex
from libs.utils import ( from libs.utils import (
OutlinedText, OutlinedText,
@@ -54,6 +55,8 @@ class ResultScreen:
self.crown = None self.crown = None
self.state = None self.state = None
self.high_score_indicator = None self.high_score_indicator = None
plate_info = global_data.config['nameplate']
self.nameplate = Nameplate(plate_info['name'], plate_info['title'], global_data.player_num, plate_info['dan'], plate_info['gold'])
self.score_animator = ScoreAnimator(session_data.result_score) self.score_animator = ScoreAnimator(session_data.result_score)
self.score = '' self.score = ''
self.good = '' self.good = ''
@@ -162,6 +165,8 @@ class ResultScreen:
if self.crown is not None: if self.crown is not None:
self.crown.update(get_current_ms()) self.crown.update(get_current_ms())
self.nameplate.update(get_current_ms())
def draw_score_info(self): def draw_score_info(self):
if self.good: if self.good:
for i in range(len(str(self.good))): for i in range(len(str(self.good))):
@@ -246,6 +251,8 @@ class ResultScreen:
if self.crown is not None: if self.crown is not None:
self.crown.draw(self.crown_type) self.crown.draw(self.crown_type)
self.nameplate.draw(265, 80)
self.draw_modifiers() self.draw_modifiers()
if self.high_score_indicator is not None: if self.high_score_indicator is not None:

View File

@@ -9,6 +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.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
@@ -80,6 +81,8 @@ class SongSelectScreen:
self.is_ura = False self.is_ura = False
self.screen_init = True self.screen_init = True
self.ura_switch_animation = UraSwitchAnimation() self.ura_switch_animation = UraSwitchAnimation()
plate_info = global_data.config['nameplate']
self.nameplate = self.nameplate = Nameplate(plate_info['name'], plate_info['title'], global_data.player_num, plate_info['dan'], plate_info['gold'])
if self.navigator.items == []: if self.navigator.items == []:
return self.on_screen_end("ENTRY") return self.on_screen_end("ENTRY")
@@ -101,6 +104,7 @@ class SongSelectScreen:
self.navigator.reset_items() self.navigator.reset_items()
audio.unload_all_sounds() audio.unload_all_sounds()
tex.unload_textures() tex.unload_textures()
self.nameplate.unload()
return next_screen return next_screen
def reset_demo_music(self): def reset_demo_music(self):
@@ -355,6 +359,7 @@ class SongSelectScreen:
self.ura_switch_animation.update(get_current_ms()) self.ura_switch_animation.update(get_current_ms())
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())
if self.text_fade_out.is_finished: if self.text_fade_out.is_finished:
self.selected_song = True self.selected_song = True
@@ -461,6 +466,11 @@ class SongSelectScreen:
tex.draw_texture('global', 'footer') tex.draw_texture('global', 'footer')
if self.nameplate.player_num == 1:
self.nameplate.draw(30, 640)
else:
self.nameplate.draw(950, 640)
self.ura_switch_animation.draw() self.ura_switch_animation.draw()
if self.state == State.BROWSING and self.navigator.items != []: if self.state == State.BROWSING and self.navigator.items != []: