mirror of
https://github.com/Yonokid/PyTaiko.git
synced 2026-02-04 11:40:13 +01:00
modify outlinedtext drawing
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))]
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user