Tidying up

This commit is contained in:
Maruno17
2024-09-09 21:31:22 +01:00
parent 2190f7c251
commit 9c95db2324
4 changed files with 49 additions and 33 deletions

View File

@@ -369,9 +369,15 @@ def get_text_colors_for_windowskin(windowskin, color, isDarkSkin)
end end
# Special colour as listed above # Special colour as listed above
if isDarkSkin && color != 12 # Dark background, light text if isDarkSkin && color != 12 # Dark background, light text
if textcolors[(2 * (color - 1))].is_a?(Color)
return textcolors[(2 * (color - 1)) + 1], textcolors[2 * (color - 1)]
end
return Color.new(*textcolors[(2 * (color - 1)) + 1]), Color.new(*textcolors[2 * (color - 1)]) return Color.new(*textcolors[(2 * (color - 1)) + 1]), Color.new(*textcolors[2 * (color - 1)])
end end
# Light background, dark text # Light background, dark text
if textcolors[(2 * (color - 1))].is_a?(Color)
return textcolors[(2 * (color - 1))], textcolors[2 * (color - 1) + 1]
end
return Color.new(*textcolors[2 * (color - 1)]), Color.new(*textcolors[(2 * (color - 1)) + 1]) return Color.new(*textcolors[2 * (color - 1)]), Color.new(*textcolors[(2 * (color - 1)) + 1])
end end

View File

@@ -304,6 +304,44 @@ def pbCsvPosInt!(str)
return ret.to_i return ret.to_i
end end
def pbReplaceMessageText(text, msg_window)
# \sign[something] gets turned into \op\cl\ts[]\w[something]
text.gsub!(/\\sign\[([^\]]*)\]/i) { next "\\op\\cl\\ts[]\\w[" + $1 + "]" }
# Escaped characters
text.gsub!(/\\\\/, "\5")
text.gsub!(/\\1/, "\1")
text.gsub!(/\\n/i, "\n")
# Text placeholders
text.gsub!(/\\pn/i, $player.name) if $player
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
loop do
last_text = text.clone
text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
break if text == last_text
end
if $game_actors
text.gsub!(/\\n\[([1-8])\]/i) { next $game_actors[$1.to_i].name }
end
# Male/female text colors
text.gsub!(/\\pg/i, "\\b") if $player&.male?
text.gsub!(/\\pg/i, "\\r") if $player&.female?
text.gsub!(/\\pog/i, "\\r") if $player&.male?
text.gsub!(/\\pog/i, "\\b") if $player&.female?
text.gsub!(/\\pg/i, "")
text.gsub!(/\\pog/i, "")
male_text_tag = shadowc3tag(MessageConfig::MALE_TEXT_MAIN_COLOR, MessageConfig::MALE_TEXT_SHADOW_COLOR)
female_text_tag = shadowc3tag(MessageConfig::FEMALE_TEXT_MAIN_COLOR, MessageConfig::FEMALE_TEXT_SHADOW_COLOR)
text.gsub!(/\\b/i, male_text_tag)
text.gsub!(/\\r/i, female_text_tag)
# Other text colors
text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2=" + $1 + ">" }
isDarkSkin = isDarkWindowskin(msg_window.windowskin)
text.gsub!(/\\c\[([0-9]+)\]/i) do
main_color, shadow_color = get_text_colors_for_windowskin(msg_window.windowskin, $1.to_i, isDarkSkin)
next shadowc3tag(main_color, shadow_color)
end
end
#=============================================================================== #===============================================================================
# Money and coins windows. # Money and coins windows.
#=============================================================================== #===============================================================================
@@ -419,28 +457,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
text = message.clone text = message.clone
linecount = (Graphics.height > 400) ? 3 : 2 linecount = (Graphics.height > 400) ? 3 : 2
### Text replacement ### Text replacement
text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into pbReplaceMessageText(text, msgwindow)
next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something]
end
text.gsub!(/\\\\/, "\5")
text.gsub!(/\\1/, "\1")
if $game_actors
text.gsub!(/\\n\[([1-8])\]/i) { next $game_actors[$1.to_i].name }
end
text.gsub!(/\\pn/i, $player.name) if $player
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
text.gsub!(/\\n/i, "\n")
text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2=" + $1 + ">" }
text.gsub!(/\\pg/i, "\\b") if $player&.male?
text.gsub!(/\\pg/i, "\\r") if $player&.female?
text.gsub!(/\\pog/i, "\\r") if $player&.male?
text.gsub!(/\\pog/i, "\\b") if $player&.female?
text.gsub!(/\\pg/i, "")
text.gsub!(/\\pog/i, "")
male_text_tag = shadowc3tag(MessageConfig::MALE_TEXT_MAIN_COLOR, MessageConfig::MALE_TEXT_SHADOW_COLOR)
female_text_tag = shadowc3tag(MessageConfig::FEMALE_TEXT_MAIN_COLOR, MessageConfig::FEMALE_TEXT_SHADOW_COLOR)
text.gsub!(/\\b/i, male_text_tag)
text.gsub!(/\\r/i, female_text_tag)
text.gsub!(/\\[Ww]\[([^\]]*)\]/) do text.gsub!(/\\[Ww]\[([^\]]*)\]/) do
w = $1.to_s w = $1.to_s
if w == "" if w == ""
@@ -450,16 +467,6 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
end end
next "" next ""
end end
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
text.gsub!(/\\c\[([0-9]+)\]/i) do
main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, $1.to_i, isDarkSkin)
next shadowc3tag(main_color, shadow_color)
end
loop do
last_text = text.clone
text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
break if text == last_text
end
loop do loop do
last_text = text.clone last_text = text.clone
text.gsub!(/\\l\[([0-9]+)\]/i) do text.gsub!(/\\l\[([0-9]+)\]/i) do
@@ -473,6 +480,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, 0, true) main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, 0, true)
colortag = shadowc3tag(main_color, shadow_color) colortag = shadowc3tag(main_color, shadow_color)
else else
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, 0, isDarkSkin) main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, 0, isDarkSkin)
colortag = shadowc3tag(main_color, shadow_color) colortag = shadowc3tag(main_color, shadow_color)
end end

View File

@@ -743,7 +743,7 @@ class UI::PokemonSummaryVisuals < UI::BaseVisuals
# Draw move name # Draw move name
move_name = move.name move_name = move.name
move_name = crop_text(move_name, (showing_detailed_move_page?) ? 230 : 262) move_name = crop_text(move_name, (showing_detailed_move_page?) ? 230 : 262)
draw_text(move.name, x + 8, y + 6, theme: :black) draw_text(move_name, x + 8, y + 6, theme: :black)
# Draw move type icon # Draw move type icon
type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position type_number = GameData::Type.get(move.display_type(@pokemon)).icon_position
draw_image(@bitmaps[:types], x + 8, y + 32, draw_image(@bitmaps[:types], x + 8, y + 32,

View File

@@ -1,3 +1,4 @@
=begin
#=============================================================================== #===============================================================================
# Pokémon party buttons and menu. # Pokémon party buttons and menu.
#=============================================================================== #===============================================================================
@@ -1477,3 +1478,4 @@ MenuHandlers.add(:party_menu_item, :move, {
screen.scene.pbSelect(old_party_idx) if !moved screen.scene.pbSelect(old_party_idx) if !moved
} }
}) })
=end