mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Fixed replacement battler being invisible if its predecessor fainted and used the same sprite, refactoring
This commit is contained in:
@@ -330,58 +330,52 @@ end
|
||||
#===============================================================================
|
||||
# Determine which text colours to use based on the darkness of the background
|
||||
#===============================================================================
|
||||
def getSkinColor(windowskin, color, isDarkSkin)
|
||||
if !windowskin || windowskin.disposed? ||
|
||||
windowskin.width != 128 || windowskin.height != 128
|
||||
# Base color, shadow color (these are reversed on dark windowskins)
|
||||
# Values in arrays are RGB numbers
|
||||
textcolors = [
|
||||
[ 0, 112, 248], [120, 184, 232], # 1 Blue
|
||||
[232, 32, 16], [248, 168, 184], # 2 Red
|
||||
[ 96, 176, 72], [174, 208, 144], # 3 Green
|
||||
[ 72, 216, 216], [168, 224, 224], # 4 Cyan
|
||||
[208, 56, 184], [232, 160, 224], # 5 Magenta
|
||||
[232, 208, 32], [248, 232, 136], # 6 Yellow
|
||||
[160, 160, 168], [208, 208, 216], # 7 Gray
|
||||
[240, 240, 248], [200, 200, 208], # 8 White
|
||||
[114, 64, 232], [184, 168, 224], # 9 Purple
|
||||
[248, 152, 24], [248, 200, 152], # 10 Orange
|
||||
MessageConfig::DARK_TEXT_MAIN_COLOR,
|
||||
MessageConfig::DARK_TEXT_SHADOW_COLOR, # 11 Dark default
|
||||
MessageConfig::LIGHT_TEXT_MAIN_COLOR,
|
||||
MessageConfig::LIGHT_TEXT_SHADOW_COLOR # 12 Light default
|
||||
]
|
||||
if color == 0 || color > textcolors.length / 2 # No special colour, use default
|
||||
if isDarkSkin # Dark background, light text
|
||||
return shadowc3tag(MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR)
|
||||
end
|
||||
# Light background, dark text
|
||||
return shadowc3tag(MessageConfig::DARK_TEXT_MAIN_COLOR, MessageConfig::DARK_TEXT_SHADOW_COLOR)
|
||||
end
|
||||
# Special colour as listed above
|
||||
if isDarkSkin && color != 12 # Dark background, light text
|
||||
return shadowc3tag(textcolors[(2 * (color - 1)) + 1], textcolors[2 * (color - 1)])
|
||||
end
|
||||
# Light background, dark text
|
||||
return shadowc3tag(textcolors[2 * (color - 1)], textcolors[(2 * (color - 1)) + 1])
|
||||
else # VX windowskin
|
||||
def get_text_colors_for_windowskin(windowskin, color, isDarkSkin)
|
||||
# VX windowskin
|
||||
if windowskin && !windowskin.disposed? && windowskin.width == 128 && windowskin.height == 128
|
||||
color = 0 if color >= 32
|
||||
x = 64 + ((color % 8) * 8)
|
||||
y = 96 + ((color / 8) * 8)
|
||||
pixel = windowskin.get_pixel(x, y)
|
||||
return shadowc3tag(pixel, pixel.get_contrast_color)
|
||||
return pixel, pixel.get_contrast_color
|
||||
end
|
||||
# No windowskin or not a VX windowskin
|
||||
# Base color, shadow color (these are reversed on dark windowskins)
|
||||
# Values in arrays are RGB numbers
|
||||
textcolors = [
|
||||
[ 0, 112, 248], [120, 184, 232], # 1 Blue
|
||||
[232, 32, 16], [248, 168, 184], # 2 Red
|
||||
[ 96, 176, 72], [174, 208, 144], # 3 Green
|
||||
[ 72, 216, 216], [168, 224, 224], # 4 Cyan
|
||||
[208, 56, 184], [232, 160, 224], # 5 Magenta
|
||||
[232, 208, 32], [248, 232, 136], # 6 Yellow
|
||||
[160, 160, 168], [208, 208, 216], # 7 Gray
|
||||
[240, 240, 248], [200, 200, 208], # 8 White
|
||||
[114, 64, 232], [184, 168, 224], # 9 Purple
|
||||
[248, 152, 24], [248, 200, 152], # 10 Orange
|
||||
MessageConfig::DARK_TEXT_MAIN_COLOR,
|
||||
MessageConfig::DARK_TEXT_SHADOW_COLOR, # 11 Dark default
|
||||
MessageConfig::LIGHT_TEXT_MAIN_COLOR,
|
||||
MessageConfig::LIGHT_TEXT_SHADOW_COLOR # 12 Light default
|
||||
]
|
||||
if color == 0 || color > textcolors.length / 2 # No special colour, use default
|
||||
if isDarkSkin # Dark background, light text
|
||||
return MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR
|
||||
end
|
||||
# Light background, dark text
|
||||
return MessageConfig::DARK_TEXT_MAIN_COLOR, MessageConfig::DARK_TEXT_SHADOW_COLOR
|
||||
end
|
||||
# Special colour as listed above
|
||||
if isDarkSkin && color != 12 # Dark background, light text
|
||||
return Color.new(*textcolors[(2 * (color - 1)) + 1]), Color.new(*textcolors[2 * (color - 1)])
|
||||
end
|
||||
# Light background, dark text
|
||||
return Color.new(*textcolors[2 * (color - 1)]), Color.new(*textcolors[(2 * (color - 1)) + 1])
|
||||
end
|
||||
|
||||
def getDefaultTextColors(windowskin)
|
||||
if !windowskin || windowskin.disposed? ||
|
||||
windowskin.width != 128 || windowskin.height != 128
|
||||
if isDarkWindowskin(windowskin)
|
||||
return [MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR] # White
|
||||
else
|
||||
return [MessageConfig::DARK_TEXT_MAIN_COLOR, MessageConfig::DARK_TEXT_SHADOW_COLOR] # Dark gray
|
||||
end
|
||||
else # VX windowskin
|
||||
# VX windowskin
|
||||
if windowskin && !windowskin.disposed? && windowskin.width == 128 && windowskin.height == 128
|
||||
color = windowskin.get_pixel(64, 96)
|
||||
shadow = nil
|
||||
isDark = (color.red + color.green + color.blue) / 3 < 128
|
||||
@@ -390,8 +384,13 @@ def getDefaultTextColors(windowskin)
|
||||
else
|
||||
shadow = Color.new(color.red - 64, color.green - 64, color.blue - 64)
|
||||
end
|
||||
return [color, shadow]
|
||||
return color, shadow
|
||||
end
|
||||
# No windowskin or not a VX windowskin
|
||||
if isDarkWindowskin(windowskin)
|
||||
return MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR # White
|
||||
end
|
||||
return MessageConfig::DARK_TEXT_MAIN_COLOR, MessageConfig::DARK_TEXT_SHADOW_COLOR # Dark gray
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
|
||||
@@ -30,9 +30,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
|
||||
pbSetSystemFont(self.contents)
|
||||
@text = text
|
||||
@letterbyletter = false # Not supported in this class
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
resizeToFit(text)
|
||||
end
|
||||
|
||||
@@ -88,9 +86,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
|
||||
oldshadowg = @shadowColor.green
|
||||
oldshadowb = @shadowColor.blue
|
||||
oldshadowa = @shadowColor.alpha
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
if oldbaser != @baseColor.red || oldbaseg != @baseColor.green ||
|
||||
oldbaseb != @baseColor.blue || oldbasea != @baseColor.alpha ||
|
||||
oldshadowr != @shadowColor.red || oldshadowg != @shadowColor.green ||
|
||||
@@ -142,9 +138,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
||||
self.contents = Bitmap.new(1, 1)
|
||||
pbSetSystemFont(self.contents)
|
||||
self.resizeToFit(text, Graphics.width)
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
self.text = text
|
||||
@starting = false
|
||||
end
|
||||
@@ -266,9 +260,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
|
||||
oldshadowg = @shadowColor.green
|
||||
oldshadowb = @shadowColor.blue
|
||||
oldshadowa = @shadowColor.alpha
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
if redrawText &&
|
||||
(oldbaser != @baseColor.red || oldbaseg != @baseColor.green ||
|
||||
oldbaseb != @baseColor.blue || oldbasea != @baseColor.alpha ||
|
||||
@@ -634,9 +626,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
|
||||
super(0, 0, 32, 32)
|
||||
self.width = (digits_max * 24) + 8 + self.borderX
|
||||
self.height = 32 + self.borderY
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
@index = digits_max - 1
|
||||
self.active = true
|
||||
refresh
|
||||
@@ -1068,9 +1058,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
|
||||
RPG::Cache.retain("Graphics/UI/sel_arrow")
|
||||
end
|
||||
@index = 0
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
refresh
|
||||
end
|
||||
|
||||
@@ -1118,9 +1106,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
|
||||
def setSkin(skin)
|
||||
super(skin)
|
||||
privRefresh(true)
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
end
|
||||
|
||||
def drawCursor(index, rect)
|
||||
@@ -1173,9 +1159,7 @@ class Window_CommandPokemon < Window_DrawableCommand
|
||||
self.height = dims[1]
|
||||
@commands = commands
|
||||
self.active = true
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
self.baseColor = colors[0]
|
||||
self.shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
refresh
|
||||
@starting = false
|
||||
end
|
||||
@@ -1282,9 +1266,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
|
||||
self.height = dims[1]
|
||||
@commands = commands
|
||||
self.active = true
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
self.baseColor = colors[0]
|
||||
self.shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
refresh
|
||||
@starting = false
|
||||
end
|
||||
|
||||
@@ -452,7 +452,8 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
end
|
||||
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
|
||||
text.gsub!(/\\c\[([0-9]+)\]/i) do
|
||||
next getSkinColor(msgwindow.windowskin, $1.to_i, isDarkSkin)
|
||||
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
|
||||
@@ -469,9 +470,11 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
|
||||
end
|
||||
colortag = ""
|
||||
if $game_system && $game_system.message_frame != 0
|
||||
colortag = getSkinColor(msgwindow.windowskin, 0, true)
|
||||
main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, 0, true)
|
||||
colortag = shadowc3tag(main_color, shadow_color)
|
||||
else
|
||||
colortag = getSkinColor(msgwindow.windowskin, 0, isDarkSkin)
|
||||
main_color, shadow_color = get_text_colors_for_windowskin(msgwindow.windowskin, 0, isDarkSkin)
|
||||
colortag = shadowc3tag(main_color, shadow_color)
|
||||
end
|
||||
text = colortag + text
|
||||
### Controls
|
||||
|
||||
@@ -85,9 +85,7 @@ end
|
||||
class Window_TextEntry < SpriteWindow_Base
|
||||
def initialize(text, x, y, width, height, heading = nil, usedarkercolor = false)
|
||||
super(x, y, width, height)
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
if usedarkercolor
|
||||
@baseColor = Color.new(16, 24, 32)
|
||||
@shadowColor = Color.new(168, 184, 184)
|
||||
@@ -264,9 +262,7 @@ end
|
||||
class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
def initialize(text, x, y, width, height)
|
||||
super(x, y, width, height)
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@baseColor, @shadowColor = getDefaultTextColors(self.windowskin)
|
||||
@helper = CharacterEntryHelper.new(text)
|
||||
@firstline = 0
|
||||
@cursorLine = 0
|
||||
|
||||
@@ -312,6 +312,7 @@ class Battle::Scene
|
||||
#=============================================================================
|
||||
def pbFaintBattler(battler)
|
||||
@briefMessage = false
|
||||
old_height = @sprites["pokemon_#{battler.index}"].src_rect.height
|
||||
# Pokémon plays cry and drops down, data box disappears
|
||||
faintAnim = Animation::BattlerFaint.new(@sprites, @viewport, battler.index, @battle)
|
||||
dataBoxAnim = Animation::DataBoxDisappear.new(@sprites, @viewport, battler.index)
|
||||
@@ -323,6 +324,7 @@ class Battle::Scene
|
||||
end
|
||||
faintAnim.dispose
|
||||
dataBoxAnim.dispose
|
||||
@sprites["pokemon_#{battler.index}"].src_rect.height = old_height
|
||||
end
|
||||
|
||||
#=============================================================================
|
||||
|
||||
@@ -10,9 +10,7 @@ class Window_CharacterEntry < Window_DrawableCommand
|
||||
@charset = charset
|
||||
@othercharset = ""
|
||||
super(0, 96, 480, 192)
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
self.baseColor = colors[0]
|
||||
self.shadowColor = colors[1]
|
||||
self.baseColor, self.shadowColor = getDefaultTextColors(self.windowskin)
|
||||
self.columns = XSIZE
|
||||
refresh
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user