From 8c2447c912bb98016be2cbb41caf4fdf1d1e3150 Mon Sep 17 00:00:00 2001 From: Anthony Samms Date: Wed, 29 Oct 2025 12:26:52 -0400 Subject: [PATCH] modify outlinedtext drawing --- libs/background.py | 2 +- libs/bg_objects/fever.py | 2 +- libs/file_navigator.py | 37 ++++++++------------- libs/global_objects.py | 10 +++--- libs/tja.py | 6 ++-- libs/transition.py | 14 ++++---- libs/utils.py | 72 +++++++++++++++++++++++----------------- scenes/devtest.py | 4 +-- scenes/entry.py | 17 ++++------ scenes/game.py | 5 ++- scenes/result.py | 5 ++- scenes/song_select.py | 52 ++++++++++++----------------- 12 files changed, 105 insertions(+), 121 deletions(-) diff --git a/libs/background.py b/libs/background.py index 810720f..ca5fc45 100644 --- a/libs/background.py +++ b/libs/background.py @@ -141,7 +141,7 @@ class Background: self.is_clear = gauge_1p.is_clear self.is_rainbow = gauge_1p.is_rainbow self.don_bg.update(current_time_ms, self.is_clear) - if self.don_bg_2 is not None: + if self.don_bg_2 is not None and gauge_2p is not None: self.don_bg_2.update(current_time_ms, gauge_2p.is_clear) if self.bg_normal is not None: self.bg_normal.update(current_time_ms) diff --git a/libs/bg_objects/fever.py b/libs/bg_objects/fever.py index 97b43af..d8e04fc 100644 --- a/libs/bg_objects/fever.py +++ b/libs/bg_objects/fever.py @@ -20,7 +20,7 @@ class BaseFever: self.bounce_down.start() self.bounce_up.start() - def update(self, current_time_ms: int, bpm: float): + def update(self, current_time_ms: float, bpm: float): self.bounce_up.update(current_time_ms) self.bounce_down.update(current_time_ms) if self.bounce_down.is_finished: diff --git a/libs/file_navigator.py b/libs/file_navigator.py index a695678..a0ebb2d 100644 --- a/libs/file_navigator.py +++ b/libs/file_navigator.py @@ -57,7 +57,6 @@ class SongBox: if audio.is_sound_playing(f'genre_voice_{i}'): audio.stop_sound(f'genre_voice_{i}') self.name = None - self.black_name = None self.hori_name = None self.yellow_box = None self.open_anim = Animation.create_move(133, start_position=0, total_distance=150, delay=83.33) @@ -83,9 +82,6 @@ class SongBox: if self.box_texture is not None: ray.unload_texture(self.box_texture) self.box_texture = None - if self.black_name is not None: - self.black_name.unload() - self.black_name = None if self.hori_name is not None: self.hori_name.unload() self.hori_name = None @@ -156,13 +152,11 @@ class SongBox: self.score_history = ScoreHistory(self.scores, get_current_ms()) if not is_open_prev and self.is_open: - if self.black_name is None: - self.black_name = OutlinedText(self.text_name, 40, ray.WHITE, ray.BLACK, outline_thickness=5, vertical=True) if self.tja is not None or self.is_back: - self.yellow_box = YellowBox(self.black_name, self.is_back, tja=self.tja) + self.yellow_box = YellowBox(self.name, self.is_back, tja=self.tja) self.yellow_box.create_anim() else: - self.hori_name = OutlinedText(self.text_name, 40, ray.WHITE, ray.BLACK, outline_thickness=5) + self.hori_name = OutlinedText(self.text_name, 40, ray.WHITE, outline_thickness=5) self.open_anim.start() self.open_fade.start() self.wait = get_current_ms() @@ -173,7 +167,7 @@ class SongBox: elif not self.is_open and is_open_prev and audio.is_sound_playing(f'genre_voice_{self.texture_index}'): audio.stop_sound(f'genre_voice_{self.texture_index}') if self.tja_count is not None and self.tja_count > 0 and self.tja_count_text is None: - self.tja_count_text = OutlinedText(str(self.tja_count), 35, ray.WHITE, ray.BLACK, outline_thickness=5)#, horizontal_spacing=1.2) + self.tja_count_text = OutlinedText(str(self.tja_count), 35, ray.WHITE, outline_thickness=5)#, horizontal_spacing=1.2) if self.box_texture is None and self.box_texture_path is not None: self.box_texture = ray.load_texture(self.box_texture_path) @@ -181,7 +175,7 @@ class SongBox: self.open_fade.update(get_current_ms()) if self.name is None: - self.name = OutlinedText(self.text_name, 40, ray.WHITE, SongBox.OUTLINE_MAP.get(self.name_texture_index, ray.Color(101, 0, 82, 255)), outline_thickness=5, vertical=True) + self.name = OutlinedText(self.text_name, 40, ray.WHITE, outline_thickness=5, vertical=True) if self.score_history is not None: self.score_history.update(get_current_ms()) @@ -202,8 +196,7 @@ class SongBox: if self.is_back: tex.draw_texture('box', 'back_text', x=x, y=y) elif self.name is not None: - dest = ray.Rectangle(x + 47 - int(self.name.texture.width / 2), y+35, self.name.texture.width, min(self.name.texture.height, 417)) - self.name.draw(self.name.default_src, dest, ray.Vector2(0, 0), 0, ray.WHITE) + self.name.draw(outline_color=SongBox.OUTLINE_MAP.get(self.name_texture_index, ray.Color(101, 0, 82, 255)), x=x + 47 - int(self.name.texture.width / 2), y=y+35, y2=min(self.name.texture.height, 417)-self.name.texture.height) if self.tja is not None and self.tja.ex_data.new: tex.draw_texture('yellow_box', 'ex_data_new_song_balloon', x=x, y=y) @@ -235,8 +228,7 @@ class SongBox: tex.draw_texture('box', 'folder_top', x=x, y=y - self.open_anim.attribute, color=color, frame=self.texture_index) tex.draw_texture('box', 'folder_top_edge', x=x+268, y=y - self.open_anim.attribute, color=color, frame=self.texture_index) dest_width = min(300, self.hori_name.texture.width) - dest = ray.Rectangle((x + 48) - (dest_width//2), y + 107 - self.open_anim.attribute, dest_width, self.hori_name.texture.height) - self.hori_name.draw(self.hori_name.default_src, dest, ray.Vector2(0, 0), 0, color) + self.hori_name.draw(outline_color=ray.BLACK, x=(x + 48) - (dest_width//2), y=y + 107 - self.open_anim.attribute, x2=dest_width-self.hori_name.texture.width, color=color) tex.draw_texture('box', 'folder_texture_left', frame=self.texture_index, x=x - self.open_anim.attribute) offset = 1 if self.texture_index == 3 or self.texture_index >= 9 and self.texture_index not in {10,11,12} else 0 @@ -256,8 +248,7 @@ class SongBox: tex.draw_texture('yellow_box', 'song_count_num', color=color) tex.draw_texture('yellow_box', 'song_count_songs', color=color) dest_width = min(124, self.tja_count_text.texture.width) - dest = ray.Rectangle(560 - (dest_width//2), 126, dest_width, self.tja_count_text.texture.height) - self.tja_count_text.draw(self.tja_count_text.default_src, dest, ray.Vector2(0, 0), 0, color) + self.tja_count_text.draw(outline_color=ray.BLACK, x=560 - (dest_width//2), y=126, x2=dest_width-self.tja_count_text.texture.width, color=color) if self.texture_index != 9: tex.draw_texture('box', 'folder_graphic', color=color, frame=self.texture_index) tex.draw_texture('box', 'folder_text', color=color, frame=self.texture_index) @@ -268,6 +259,7 @@ class SongBox: if self.is_open and get_current_ms() >= self.wait + 83.33: if self.score_history is not None and get_current_ms() >= self.history_wait + 3000: self.score_history.draw() + def draw(self, x: int, y: int, is_ura: bool, fade_override=None): if self.is_open and get_current_ms() >= self.wait + 83.33: if self.yellow_box is not None: @@ -288,7 +280,7 @@ class YellowBox: if self.tja is not None: subtitle_text = self.tja.metadata.subtitle.get(global_data.config['general']['language'], '') font_size = 30 if len(subtitle_text) < 30 else 20 - self.subtitle = OutlinedText(subtitle_text, font_size, ray.WHITE, ray.BLACK, outline_thickness=5, vertical=True) + self.subtitle = OutlinedText(subtitle_text, font_size, ray.WHITE, outline_thickness=5, vertical=True) self.left_out = tex.get_animation(9) self.right_out = tex.get_animation(10) @@ -458,13 +450,11 @@ class YellowBox: tex.draw_texture('box', 'back_text_highlight', x=x) elif self.name is not None: texture = self.name.texture - dest = ray.Rectangle(x + 30, 35 + self.top_y_out.attribute, texture.width, min(texture.height, 417)) - self.name.draw(self.name.default_src, dest, ray.Vector2(0, 0), 0, ray.WHITE) + self.name.draw(outline_color=ray.BLACK, x=x + 30, y=35 + self.top_y_out.attribute, y2=min(texture.height, 417)-texture.height, color=ray.WHITE) if self.subtitle is not None: texture = self.subtitle.texture y = self.bottom_y - min(texture.height, 410) + 10 + self.top_y_out.attribute - self.top_y_out.start_position - dest = ray.Rectangle(x - 15, y, texture.width, min(texture.height, 410)) - self.subtitle.draw(self.subtitle.default_src, dest, ray.Vector2(0, 0), 0, ray.WHITE) + self.subtitle.draw(outline_color=ray.BLACK, x=x-15, y=y, y2=min(texture.height, 410)-texture.height) def _draw_yellow_box(self): tex.draw_texture('yellow_box', 'yellow_box_bottom_right', x=self.right_x) @@ -542,8 +532,7 @@ class GenreBG: tex.draw_texture('box', 'folder_background_folder_edge', x=((offset+dest_width)//2)+20, y=y-2, fade=self.fade_in.attribute, frame=self.end_box.texture_index) if self.diff_num is not None: tex.draw_texture('diff_sort', 'star_num', frame=self.diff_num, x=-150 + (dest_width//2), y=-143) - dest = ray.Rectangle((1280//2) - (dest_width//2)-(offset//2), y-60, dest_width, self.title.texture.height) - self.title.draw(self.title.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, self.fade_in.attribute)) + self.title.draw(outline_color=ray.BLACK, x=(1280//2) - (dest_width//2)-(offset//2), y=y-60, x2=dest_width - self.title.texture.width, color=ray.fade(ray.WHITE, self.fade_in.attribute)) class ScoreHistory: """The score information that appears while hovering over a song""" @@ -1042,7 +1031,7 @@ class FileNavigator: if selected_item.collection == Directory.COLLECTIONS[3]: diff_sort = self.diff_sort_level diffs = ['かんたん', 'ふつう', 'むずかしい', 'おに'] - hori_name = OutlinedText(diffs[min(3, self.diff_sort_diff)], 40, ray.WHITE, ray.BLACK, outline_thickness=5) + hori_name = OutlinedText(diffs[min(3, self.diff_sort_diff)], 40, ray.WHITE, outline_thickness=5) self.genre_bg = GenreBG(start_box, end_box, hori_name, diff_sort) def select_current_item(self): diff --git a/libs/global_objects.py b/libs/global_objects.py index dc580f5..85bbbe3 100644 --- a/libs/global_objects.py +++ b/libs/global_objects.py @@ -17,8 +17,8 @@ class Nameplate: dan (int): The player's dan level. is_gold (bool): Whether the player's dan is gold. """ - self.name = OutlinedText(name, 22, ray.WHITE, ray.BLACK, outline_thickness=3.0) - self.title = OutlinedText(title, 20, ray.BLACK, ray.WHITE, outline_thickness=0) + self.name = OutlinedText(name, 22, ray.WHITE, outline_thickness=3.0) + self.title = OutlinedText(title, 20, ray.BLACK, outline_thickness=0) self.dan_index = dan self.player_num = player_num self.is_gold = is_gold @@ -64,10 +64,8 @@ class Nameplate: if self.player_num != -1: tex.draw_texture('nameplate', f'{self.player_num}p', x=x, y=y, fade=fade) - dest = ray.Rectangle(x+136 - (min(255 - offset*4, self.name.texture.width)//2) + offset, y+24, min(255 - offset*4, self.name.texture.width), self.name.texture.height) - self.name.draw(self.name.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, fade)) - dest = ray.Rectangle(x+136 - (min(255 - offset*2, self.title.texture.width)//2) + title_offset, y-3, min(255 - offset*2, 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.name.draw(outline_color=ray.BLACK, x=x+136 - (min(255 - offset*4, self.name.texture.width)//2) + offset, y=y+24, x2=min(255 - offset*4, self.name.texture.width)-self.name.texture.width, color=ray.fade(ray.WHITE, fade)) + self.title.draw(x=x+136 - (min(255 - offset*2, self.title.texture.width)//2) + title_offset, y=y-3, x2=min(255 - offset*2, self.title.texture.width)-self.title.texture.width, color=ray.fade(ray.WHITE, fade)) class Indicator: """Indicator class for displaying drum navigation.""" diff --git a/libs/tja.py b/libs/tja.py index b21dc44..1d0dee1 100644 --- a/libs/tja.py +++ b/libs/tja.py @@ -519,8 +519,10 @@ class TJAParser: return current_note = play_note_list[-1] - if current_note.type in {1, 2}: - current_note.moji = se_notes[current_note.type][0] + if current_note.type == 1: + current_note.moji = 0 + elif current_note.type == 2: + current_note.moji = 3 else: current_note.moji = se_notes[current_note.type] diff --git a/libs/transition.py b/libs/transition.py index 6725d4f..90e9b2d 100644 --- a/libs/transition.py +++ b/libs/transition.py @@ -16,8 +16,8 @@ class Transition: self.chara_down = global_tex.get_animation(2) self.song_info_fade = global_tex.get_animation(3) self.song_info_fade_out = global_tex.get_animation(4) - self.title = OutlinedText(title, 40, ray.WHITE, ray.BLACK, outline_thickness=5) - self.subtitle = OutlinedText(subtitle, 30, ray.WHITE, ray.BLACK, outline_thickness=5) + self.title = OutlinedText(title, 40, ray.WHITE) + self.subtitle = OutlinedText(subtitle, 30, ray.WHITE) self.is_second = is_second def start(self): @@ -48,13 +48,13 @@ class Transition: global_tex.draw_texture('rainbow_transition', 'text_bg', y=-self.rainbow_up.attribute - offset, color=color_2) texture = self.title.texture - y = 1176 - texture.height//2 - int(self.rainbow_up.attribute) - offset - dest = ray.Rectangle(1280//2 - texture.width//2, y - 20, texture.width, texture.height) - self.title.draw(self.title.default_src, dest, ray.Vector2(0, 0), 0, color_1) + x = 1280//2 - texture.width//2 + y = 1176 - texture.height//2 - int(self.rainbow_up.attribute) - offset - 20 + self.title.draw(outline_color=ray.BLACK, x=x, y=y, color=color_1) texture = self.subtitle.texture - dest = ray.Rectangle(1280//2 - texture.width//2, y + 30, texture.width, texture.height) - self.subtitle.draw(self.subtitle.default_src, dest, ray.Vector2(0, 0), 0, color_1) + x = 1280//2 - texture.width//2 + self.subtitle.draw(outline_color=ray.BLACK, x=x, y=y + 30, color=color_1) def draw(self): """Draw the transition effect.""" diff --git a/libs/utils.py b/libs/utils.py index 06d9c69..a834534 100644 --- a/libs/utils.py +++ b/libs/utils.py @@ -262,7 +262,7 @@ for file in Path('cache/image').iterdir(): class OutlinedText: """Create an outlined text object.""" - 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_thickness=5.0, vertical=False): """ Create an outlined text object. @@ -286,30 +286,15 @@ class OutlinedText: else: self.texture = self._create_text_horizontal(text, font_size, color, ray.BLANK, self.font) outline_size = ray.ffi.new('float*', self.outline_thickness) - if isinstance(outline_color, tuple): - outline_color_alloc = ray.ffi.new("float[4]", [ - outline_color[0] / 255.0, - outline_color[1] / 255.0, - outline_color[2] / 255.0, - outline_color[3] / 255.0 - ]) - else: - outline_color_alloc = ray.ffi.new("float[4]", [ - outline_color.r / 255.0, - outline_color.g / 255.0, - outline_color.b / 255.0, - outline_color.a / 255.0 - ]) texture_size = ray.ffi.new("float[2]", [self.texture.width, self.texture.height]) self.shader = ray.load_shader('shader/outline.vs', 'shader/outline.fs') - outline_size_loc = ray.get_shader_location(self.shader, "outlineSize") - outline_color_loc = ray.get_shader_location(self.shader, "outlineColor") - texture_size_loc = ray.get_shader_location(self.shader, "textureSize") + self.outline_size_loc = ray.get_shader_location(self.shader, "outlineSize") + self.outline_color_loc = ray.get_shader_location(self.shader, "outlineColor") + self.texture_size_loc = ray.get_shader_location(self.shader, "textureSize") self.alpha_loc = ray.get_shader_location(self.shader, "alpha") - ray.set_shader_value(self.shader, outline_size_loc, outline_size, SHADER_UNIFORM_FLOAT) - ray.set_shader_value(self.shader, outline_color_loc, outline_color_alloc, SHADER_UNIFORM_VEC4) - ray.set_shader_value(self.shader, texture_size_loc, texture_size, SHADER_UNIFORM_VEC2) + ray.set_shader_value(self.shader, self.outline_size_loc, outline_size, SHADER_UNIFORM_FLOAT) + ray.set_shader_value(self.shader, self.texture_size_loc, texture_size, SHADER_UNIFORM_VEC2) self.default_src = ray.Rectangle(0, 0, self.texture.width, self.texture.height) @@ -517,25 +502,50 @@ class OutlinedText: ray.unload_image(image) return texture - def draw(self, src: ray.Rectangle, dest: ray.Rectangle, origin: ray.Vector2, rotation: float, color: ray.Color): + def draw(self, outline_color: ray.Color=ray.BLANK, color: ray.Color=ray.WHITE, scale: float = 1.0, center: bool = False, + 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) -> None: """ - Draw the outlined text object. - - Args: - src (ray.Rectangle): The source rectangle of the texture. - dest (ray.Rectangle): The destination rectangle of the texture. - origin (ray.Vector2): The origin of the texture. - rotation (float): The rotation of the texture. - color (ray.Color): The color of the text. + Wrapper function for raylib's draw_texture_pro(). + Parameters: + outline_color (ray.Color): The color to outline the text. + color (ray.Color): The color to tint the text. + x (float): An x-value added to the top-left corner of the text. + y (float): The y-value added to the top-left corner of the text. + x2 (float): The x-value added to the bottom-right corner of the text. + y2 (float): The y-value added to the bottom-right corner of the text. + origin (ray.Vector2): The origin point of the text. + rotation (float): The rotation angle of the text. + fade (float): The fade factor to apply to the text. """ + if isinstance(outline_color, tuple): + outline_color_alloc = ray.ffi.new("float[4]", [ + outline_color[0] / 255.0, + outline_color[1] / 255.0, + outline_color[2] / 255.0, + outline_color[3] / 255.0 + ]) + else: + outline_color_alloc = ray.ffi.new("float[4]", [ + outline_color.r / 255.0, + outline_color.g / 255.0, + outline_color.b / 255.0, + outline_color.a / 255.0 + ]) + ray.set_shader_value(self.shader, self.outline_color_loc, outline_color_alloc, SHADER_UNIFORM_VEC4) if isinstance(color, tuple): alpha_value = ray.ffi.new('float*', color[3] / 255.0) else: alpha_value = ray.ffi.new('float*', color.a / 255.0) ray.set_shader_value(self.shader, self.alpha_loc, alpha_value, SHADER_UNIFORM_FLOAT) + if fade != 1.1: + final_color = ray.fade(color, fade) + else: + final_color = color + dest_rect = ray.Rectangle(x, y, self.texture.width+x2, self.texture.height+y2) 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, self.default_src, dest_rect, origin, rotation, final_color) if self.outline_thickness > 0: ray.end_shader_mode() diff --git a/scenes/devtest.py b/scenes/devtest.py index 435fa49..da09224 100644 --- a/scenes/devtest.py +++ b/scenes/devtest.py @@ -4,8 +4,8 @@ from libs.screen import Screen class DevScreen(Screen): - def on_screen_start(self, screen_name: str): - super().on_screen_start(screen_name) + def on_screen_start(self): + super().on_screen_start() def on_screen_end(self, next_screen: str): return super().on_screen_end(next_screen) diff --git a/scenes/entry.py b/scenes/entry.py index b13c7a3..dabe2f1 100644 --- a/scenes/entry.py +++ b/scenes/entry.py @@ -351,8 +351,8 @@ class EntryPlayer: class Box: """Box class for the entry screen""" - def __init__(self, text: tuple[OutlinedText, OutlinedText], location: str): - self.text, self.text_highlight = text + def __init__(self, text: OutlinedText, location: str): + self.text = text self.location = location self.box_tex_obj = tex.textures['mode_select']['box'] if isinstance(self.box_tex_obj.texture, list): @@ -419,11 +419,10 @@ class Box: if self.is_selected: text_x += self.open.attribute text_y = self.y + 20 - text_dest = ray.Rectangle(text_x, text_y, self.text.texture.width, self.text.texture.height) if self.is_selected: - self.text_highlight.draw(self.text.default_src, text_dest, ray.Vector2(0, 0), 0, color) + self.text.draw(outline_color=ray.BLACK, x=text_x, y=text_y, color=color) else: - self.text.draw(self.text.default_src, text_dest, ray.Vector2(0, 0), 0, color) + self.text.draw(outline_color=ray.Color(109, 68, 24, 255), x=text_x, y=text_y, color=color) def draw(self, fade: float): color = ray.fade(ray.WHITE, fade) @@ -435,11 +434,9 @@ class Box: class BoxManager: """BoxManager class for the entry screen""" def __init__(self): - self.box_titles: list[tuple[OutlinedText, OutlinedText]] = [ - (OutlinedText('演奏ゲーム', 50, ray.WHITE, ray.Color(109, 68, 24, 255), outline_thickness=5, vertical=True), - OutlinedText('演奏ゲーム', 50, ray.WHITE, ray.BLACK, outline_thickness=5, vertical=True)), - (OutlinedText('ゲーム設定', 50, ray.WHITE, ray.Color(109, 68, 24, 255), outline_thickness=5, vertical=True), - OutlinedText('ゲーム設定', 50, ray.WHITE, ray.BLACK, outline_thickness=5, vertical=True))] + self.box_titles: list[OutlinedText] = [ + OutlinedText('演奏ゲーム', 50, ray.WHITE, outline_thickness=5, vertical=True), + OutlinedText('ゲーム設定', 50, ray.WHITE, outline_thickness=5, vertical=True)] self.box_locations = ["SONG_SELECT", "SETTINGS"] self.num_boxes = len(self.box_titles) self.boxes = [Box(self.box_titles[i], self.box_locations[i]) for i in range(len(self.box_titles))] diff --git a/scenes/game.py b/scenes/game.py index b0fb100..6c9f3b4 100644 --- a/scenes/game.py +++ b/scenes/game.py @@ -1751,7 +1751,7 @@ class SongInfo: def __init__(self, song_name: str, genre: int): self.song_name = song_name self.genre = genre - self.song_title = OutlinedText(song_name, 40, ray.WHITE, ray.BLACK, outline_thickness=5) + self.song_title = OutlinedText(song_name, 40, ray.WHITE, outline_thickness=5) self.fade = tex.get_animation(3) def update(self, current_ms: float): @@ -1762,8 +1762,7 @@ class SongInfo: text_x = 1252 - self.song_title.texture.width text_y = 50 - self.song_title.texture.height//2 - dest = ray.Rectangle(text_x, text_y, self.song_title.texture.width, self.song_title.texture.height) - self.song_title.draw(self.song_title.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, 1 - self.fade.attribute)) + self.song_title.draw(outline_color=ray.BLACK, x=text_x, y=text_y, color=ray.fade(ray.WHITE, 1 - self.fade.attribute)) if self.genre < 9: tex.draw_texture('song_info', 'genre', fade=1 - self.fade.attribute, frame=self.genre) diff --git a/scenes/result.py b/scenes/result.py index 1f138ce..67fc91a 100644 --- a/scenes/result.py +++ b/scenes/result.py @@ -26,7 +26,7 @@ class State: class ResultScreen(Screen): def on_screen_start(self): super().on_screen_start() - self.song_info = OutlinedText(global_data.session_data[0].song_title, 40, ray.WHITE, ray.BLACK, outline_thickness=5) + self.song_info = OutlinedText(global_data.session_data[0].song_title, 40, ray.WHITE, outline_thickness=5) audio.play_sound('bgm', 'music') self.fade_in = FadeIn(str(global_data.player_num)) self.fade_out = tex.get_animation(0) @@ -72,8 +72,7 @@ class ResultScreen(Screen): def draw_song_info(self): tex.draw_texture('song_info', 'song_num', frame=global_data.songs_played%4) - dest = ray.Rectangle(1252 - self.song_info.texture.width, 35 - self.song_info.texture.height / 2, self.song_info.texture.width, self.song_info.texture.height) - self.song_info.draw(self.song_info.default_src, dest, ray.Vector2(0, 0), 0, ray.WHITE) + self.song_info.draw(x=1252 - self.song_info.texture.width, y=35 - self.song_info.texture.height / 2) def draw(self): self.background.draw() diff --git a/scenes/song_select.py b/scenes/song_select.py index 09fff4b..f4c1b4b 100644 --- a/scenes/song_select.py +++ b/scenes/song_select.py @@ -975,8 +975,8 @@ class NeiroSelector: self.move.start() self.blue_arrow_fade = tex.get_animation(29, is_copy=True) self.blue_arrow_move = tex.get_animation(30, is_copy=True) - self.text = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE, ray.BLACK) - self.text_2 = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE, ray.BLACK) + self.text = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE) + self.text_2 = OutlinedText(self.sounds[self.selected_sound], 50, ray.WHITE) self.move_sideways = tex.get_animation(31, is_copy=True) self.fade_sideways = tex.get_animation(32, is_copy=True) self.direction = -1 @@ -1064,11 +1064,8 @@ class NeiroSelector: for i in range(len(counter)): tex.draw_texture('neiro', 'counter', frame=int(counter[i]), x=x-(total_width // 2) + (i * 20) + 60, y=y) - dest = ray.Rectangle(x+235 - (self.text.texture.width//2) + (self.move_sideways.attribute*self.direction), y+1000, self.text.texture.width, self.text.texture.height) - self.text.draw(self.text.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, self.fade_sideways.attribute)) - - dest = ray.Rectangle(x+(self.direction*-100) + 235 - (self.text_2.texture.width//2) + (self.move_sideways.attribute*self.direction), y+1000, self.text_2.texture.width, self.text_2.texture.height) - self.text_2.draw(self.text_2.default_src, dest, ray.Vector2(0, 0), 0, ray.fade(ray.WHITE, 1 - self.fade_sideways.attribute)) + self.text.draw(outline_color=ray.BLACK, x=x+235 - (self.text.texture.width//2) + (self.move_sideways.attribute*self.direction), y=y+1000, color=ray.fade(ray.WHITE, self.fade_sideways.attribute)) + self.text_2.draw(outline_color=ray.BLACK, x=x+(self.direction*-100) + 235 - (self.text_2.texture.width//2) + (self.move_sideways.attribute*self.direction), y=y+1000, color=ray.fade(ray.WHITE, 1 - self.fade_sideways.attribute)) class ModifierSelector: """The menu for selecting the game modifiers.""" @@ -1100,19 +1097,19 @@ class ModifierSelector: self.fade_sideways = tex.get_animation(32, is_copy=True) self.direction = -1 audio.play_sound(f'voice_options_{self.player_num}p', 'sound') - self.text_name = [OutlinedText(ModifierSelector.NAME_MAP[mod.name], 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) for mod in self.mods] - self.text_true = OutlinedText('する', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_false = OutlinedText('しない', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_speed = OutlinedText(str(global_data.modifiers[int(self.player_num)-1].speed), 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_kimagure = OutlinedText('きまぐれ', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_detarame = OutlinedText('でたらめ', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) + self.text_name = [OutlinedText(ModifierSelector.NAME_MAP[mod.name], 30, ray.WHITE, outline_thickness=3.5) for mod in self.mods] + self.text_true = OutlinedText('する', 30, ray.WHITE, outline_thickness=3.5) + self.text_false = OutlinedText('しない', 30, ray.WHITE, outline_thickness=3.5) + self.text_speed = OutlinedText(str(global_data.modifiers[int(self.player_num)-1].speed), 30, ray.WHITE, outline_thickness=3.5) + self.text_kimagure = OutlinedText('きまぐれ', 30, ray.WHITE, outline_thickness=3.5) + self.text_detarame = OutlinedText('でたらめ', 30, ray.WHITE, outline_thickness=3.5) # Secondary text objects for animation - self.text_true_2 = OutlinedText('する', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_false_2 = OutlinedText('しない', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_speed_2 = OutlinedText(str(global_data.modifiers[int(self.player_num)-1].speed), 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_kimagure_2 = OutlinedText('きまぐれ', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) - self.text_detarame_2 = OutlinedText('でたらめ', 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) + self.text_true_2 = OutlinedText('する', 30, ray.WHITE, outline_thickness=3.5) + self.text_false_2 = OutlinedText('しない', 30, ray.WHITE, outline_thickness=3.5) + self.text_speed_2 = OutlinedText(str(global_data.modifiers[int(self.player_num)-1].speed), 30, ray.WHITE, outline_thickness=3.5) + self.text_kimagure_2 = OutlinedText('きまぐれ', 30, ray.WHITE, outline_thickness=3.5) + self.text_detarame_2 = OutlinedText('でたらめ', 30, ray.WHITE, outline_thickness=3.5) def update(self, current_ms): self.is_finished = self.is_confirmed and self.move.is_finished @@ -1130,7 +1127,7 @@ class ModifierSelector: if current_mod.name == 'speed': self.text_speed.unload() - self.text_speed = OutlinedText(str(current_value), 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) + self.text_speed = OutlinedText(str(current_value), 30, ray.WHITE, outline_thickness=3.5) def confirm(self): if self.is_confirmed: @@ -1151,7 +1148,7 @@ class ModifierSelector: if current_mod.name == 'speed': self.text_speed_2.unload() - self.text_speed_2 = OutlinedText(str(current_value), 30, ray.WHITE, ray.BLACK, outline_thickness=3.5) + self.text_speed_2 = OutlinedText(str(current_value), 30, ray.WHITE, outline_thickness=3.5) def left(self): if self.is_confirmed: @@ -1183,23 +1180,16 @@ class ModifierSelector: setattr(global_data.modifiers[int(self.player_num)-1], current_mod.name, (current_value+1) % 3) self._start_text_animation(1) - def _draw_animated_text(self, text_primary, text_secondary, x, y, should_animate): + def _draw_animated_text(self, text_primary: OutlinedText, text_secondary: OutlinedText, x: float, y: float, should_animate: bool): if should_animate and not self.move_sideways.is_finished: # Draw primary text moving out - dest = ray.Rectangle(x + (self.move_sideways.attribute * self.direction), y, - text_primary.texture.width, text_primary.texture.height) - text_primary.draw(text_primary.default_src, dest, ray.Vector2(0, 0), 0, - ray.fade(ray.WHITE, self.fade_sideways.attribute)) + text_primary.draw(outline_color=ray.BLACK, x=x + (self.move_sideways.attribute * self.direction), y=y, color=ray.fade(ray.WHITE, self.fade_sideways.attribute)) # Draw secondary text moving in - dest = ray.Rectangle((self.direction * -100) + x + (self.move_sideways.attribute * self.direction), y, - text_secondary.texture.width, text_secondary.texture.height) - text_secondary.draw(text_secondary.default_src, dest, ray.Vector2(0, 0), 0, - ray.fade(ray.WHITE, 1 - self.fade_sideways.attribute)) + text_secondary.draw(outline_color=ray.BLACK, x=(self.direction * -100) + x + (self.move_sideways.attribute * self.direction), y=y, color=ray.fade(ray.WHITE, 1 - self.fade_sideways.attribute)) else: # Draw static text - dest = ray.Rectangle(x, y, text_primary.texture.width, text_primary.texture.height) - text_primary.draw(text_primary.default_src, dest, ray.Vector2(0, 0), 0, ray.WHITE) + text_primary.draw(outline_color=ray.BLACK, x=x, y=y) def draw(self): if self.is_confirmed: