More tweaks from the Rubocop overlord

This commit is contained in:
Maruno17
2021-12-19 17:28:59 +00:00
parent 33781493f4
commit 65b1a8d6c3
161 changed files with 2839 additions and 2967 deletions

View File

@@ -146,9 +146,10 @@ module MessageConfig
def self.pbTryFonts(*args)
for a in args
next if !a
if a.is_a?(String)
case a
when String
return a if Font.exist?(a)
elsif a.is_a?(Array)
when Array
for aa in a
ret = MessageConfig.pbTryFonts(aa)
return ret if ret != ""
@@ -177,7 +178,7 @@ end
def pbBottomLeftLines(window, lines, width = nil)
window.x = 0
window.width = width ? width : Graphics.width
window.height = (window.borderY rescue 32) + lines * 32
window.height = (window.borderY rescue 32) + (lines * 32)
window.y = Graphics.height - window.height
end
@@ -230,7 +231,7 @@ end
# internal function
def pbRepositionMessageWindow(msgwindow, linecount = 2)
msgwindow.height = 32 * linecount + msgwindow.borderY
msgwindow.height = (32 * linecount) + msgwindow.borderY
msgwindow.y = (Graphics.height) - (msgwindow.height)
if $game_system
case $game_system.message_position
@@ -278,10 +279,10 @@ def isDarkBackground(background, rect = nil)
return true if rect.width <= 0 || rect.height <= 0
xSeg = (rect.width / 16)
xLoop = (xSeg == 0) ? 1 : 16
xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + xSeg / 2
xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + (xSeg / 2)
ySeg = (rect.height / 16)
yLoop = (ySeg == 0) ? 1 : 16
yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + ySeg / 2
yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + (ySeg / 2)
count = 0
y = yStart
r = g = b = 0
@@ -303,7 +304,7 @@ def isDarkBackground(background, rect = nil)
r /= count
g /= count
b /= count
return (r * 0.299 + g * 0.587 + b * 0.114) < 160
return ((r * 0.299) + (g * 0.587) + (b * 0.114)) < 160
end
def isDarkWindowskin(windowskin)
@@ -316,7 +317,7 @@ def isDarkWindowskin(windowskin)
return isDarkBackground(windowskin, Rect.new(32, 16, 16, 16))
else
clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2)
return (clr.red * 0.299 + clr.green * 0.587 + clr.blue * 0.114) < 160
return ((clr.red * 0.299) + (clr.green * 0.587) + (clr.blue * 0.114)) < 160
end
end
@@ -328,20 +329,20 @@ def getSkinColor(windowskin, color, isDarkSkin)
windowskin.width != 128 || windowskin.height != 128
# Base color, shadow color (these are reversed on dark windowskins)
textcolors = [
"0070F8", "78B8E8", # 1 Blue
"E82010", "F8A8B8", # 2 Red
"60B048", "B0D090", # 3 Green
"48D8D8", "A8E0E0", # 4 Cyan
"D038B8", "E8A0E0", # 5 Magenta
"E8D020", "F8E888", # 6 Yellow
"A0A0A8", "D0D0D8", # 7 Grey
"F0F0F8", "C8C8D0", # 8 White
"9040E8", "B8A8E0", # 9 Purple
"F89818", "F8C898", # 10 Orange
colorToRgb32(MessageConfig::DARK_TEXT_MAIN_COLOR),
colorToRgb32(MessageConfig::DARK_TEXT_SHADOW_COLOR), # 11 Dark default
colorToRgb32(MessageConfig::LIGHT_TEXT_MAIN_COLOR),
colorToRgb32(MessageConfig::LIGHT_TEXT_SHADOW_COLOR) # 12 Light default
"0070F8", "78B8E8", # 1 Blue
"E82010", "F8A8B8", # 2 Red
"60B048", "B0D090", # 3 Green
"48D8D8", "A8E0E0", # 4 Cyan
"D038B8", "E8A0E0", # 5 Magenta
"E8D020", "F8E888", # 6 Yellow
"A0A0A8", "D0D0D8", # 7 Grey
"F0F0F8", "C8C8D0", # 8 White
"9040E8", "B8A8E0", # 9 Purple
"F89818", "F8C898", # 10 Orange
colorToRgb32(MessageConfig::DARK_TEXT_MAIN_COLOR),
colorToRgb32(MessageConfig::DARK_TEXT_SHADOW_COLOR), # 11 Dark default
colorToRgb32(MessageConfig::LIGHT_TEXT_MAIN_COLOR),
colorToRgb32(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
@@ -352,14 +353,14 @@ def getSkinColor(windowskin, color, isDarkSkin)
end
# Special colour as listed above
if isDarkSkin && color != 12 # Dark background, light text
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1) + 1], textcolors[2 * (color - 1)])
return sprintf("<c3=%s,%s>", textcolors[(2 * (color - 1)) + 1], textcolors[2 * (color - 1)])
end
# Light background, dark text
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1)], textcolors[2 * (color - 1) + 1])
return sprintf("<c3=%s,%s>", textcolors[2 * (color - 1)], textcolors[(2 * (color - 1)) + 1])
else # VX windowskin
color = 0 if color >= 32
x = 64 + (color % 8) * 8
y = 96 + (color / 8) * 8
x = 64 + ((color % 8) * 8)
y = 96 + ((color / 8) * 8)
pixel = windowskin.get_pixel(x, y)
return shadowctagFromColor(pixel)
end
@@ -441,10 +442,10 @@ def pbSrcOver(dstColor, srcColor)
cg = dstColor.green * dstColor.alpha / 255
cb = dstColor.blue * dstColor.alpha / 255
ica = 255 - dstColor.alpha
a = 255 - (iea * ica) / 255
r = (iea * cr) / 255 + er
g = (iea * cg) / 255 + eg
b = (iea * cb) / 255 + eb
a = 255 - ((iea * ica) / 255)
r = ((iea * cr) / 255) + er
g = ((iea * cg) / 255) + eg
b = ((iea * cb) / 255) + eb
r = (a == 0) ? 0 : r * 255 / a
g = (a == 0) ? 0 : g * 255 / a
b = (a == 0) ? 0 : b * 255 / a

View File

@@ -78,12 +78,12 @@ class Window
def initialize(viewport = nil)
@sprites = {}
@spritekeys = [
"back",
"corner0", "side0", "scroll0",
"corner1", "side1", "scroll1",
"corner2", "side2", "scroll2",
"corner3", "side3", "scroll3",
"cursor", "contents", "pause"
"back",
"corner0", "side0", "scroll0",
"corner1", "side1", "scroll1",
"corner2", "side2", "scroll2",
"corner3", "side3", "scroll3",
"cursor", "contents", "pause"
]
@sidebitmaps = [nil, nil, nil, nil]
@cursorbitmap = nil
@@ -444,10 +444,10 @@ class Window
cursorX = trimX
cursorY = trimY + 64
sideRects = [
Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX, trimY + 16, 16, 32),
Rect.new(trimX + 48, trimY + 16, 16, 32),
Rect.new(trimX + 16, trimY + 48, 32, 16)
Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX, trimY + 16, 16, 32),
Rect.new(trimX + 48, trimY + 16, 16, 32),
Rect.new(trimX + 16, trimY + 48, 32, 16)
]
if @width > 32 && @height > 32
@sprites["contents"].src_rect.set(@ox, @oy, @width - 32, @height - 32)
@@ -455,15 +455,15 @@ class Window
@sprites["contents"].src_rect.set(0, 0, 0, 0)
end
pauseRects = [
trimX + 32, trimY + 64,
trimX + 48, trimY + 64,
trimX + 32, trimY + 80,
trimX + 48, trimY + 80
trimX + 32, trimY + 64,
trimX + 48, trimY + 64,
trimX + 32, trimY + 80,
trimX + 48, trimY + 80
]
pauseWidth = 16
pauseHeight = 16
@sprites["pause"].src_rect.set(pauseRects[@pauseframe * 2],
pauseRects[@pauseframe * 2 + 1],
pauseRects[(@pauseframe * 2) + 1],
pauseWidth,
pauseHeight)
@sprites["pause"].x = @x + (@width / 2) - (pauseWidth / 2)
@@ -486,13 +486,13 @@ class Window
@sprites["side2"].y = @y + 16
@sprites["side3"].x = @x + 16
@sprites["side3"].y = @y + @height - 16
@sprites["scroll0"].x = @x + @width / 2 - 8
@sprites["scroll0"].x = @x + (@width / 2) - 8
@sprites["scroll0"].y = @y + 8
@sprites["scroll1"].x = @x + 8
@sprites["scroll1"].y = @y + @height / 2 - 8
@sprites["scroll1"].y = @y + (@height / 2) - 8
@sprites["scroll2"].x = @x + @width - 16
@sprites["scroll2"].y = @y + @height / 2 - 8
@sprites["scroll3"].x = @x + @width / 2 - 8
@sprites["scroll2"].y = @y + (@height / 2) - 8
@sprites["scroll3"].x = @x + (@width / 2) - 8
@sprites["scroll3"].y = @y + @height - 16
@sprites["back"].x = @x + 2
@sprites["back"].y = @y + 2
@@ -503,18 +503,18 @@ class Window
height = @cursor_rect.height
if width > 0 && height > 0
cursorrects = [
# sides
Rect.new(cursorX + 2, cursorY + 0, 28, 2),
Rect.new(cursorX + 0, cursorY + 2, 2, 28),
Rect.new(cursorX + 30, cursorY + 2, 2, 28),
Rect.new(cursorX + 2, cursorY + 30, 28, 2),
# corners
Rect.new(cursorX + 0, cursorY + 0, 2, 2),
Rect.new(cursorX + 30, cursorY + 0, 2, 2),
Rect.new(cursorX + 0, cursorY + 30, 2, 2),
Rect.new(cursorX + 30, cursorY + 30, 2, 2),
# back
Rect.new(cursorX + 2, cursorY + 2, 28, 28)
# sides
Rect.new(cursorX + 2, cursorY + 0, 28, 2),
Rect.new(cursorX + 0, cursorY + 2, 2, 28),
Rect.new(cursorX + 30, cursorY + 2, 2, 28),
Rect.new(cursorX + 2, cursorY + 30, 28, 2),
# corners
Rect.new(cursorX + 0, cursorY + 0, 2, 2),
Rect.new(cursorX + 30, cursorY + 0, 2, 2),
Rect.new(cursorX + 0, cursorY + 30, 2, 2),
Rect.new(cursorX + 30, cursorY + 30, 2, 2),
# back
Rect.new(cursorX + 2, cursorY + 2, 28, 28)
]
margin = 2
fullmargin = 4
@@ -575,7 +575,7 @@ class Window
opn = @openness / 255.0
for k in @spritekeys
sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height
ratio = (@height <= 0) ? 0 : (sprite.y - @y) / @height.to_f
sprite.zoom_y = opn
sprite.oy = 0
sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor

View File

@@ -55,12 +55,12 @@ class SpriteWindow < Window
def initialize(viewport = nil)
@sprites = {}
@spritekeys = [
"back",
"corner0", "side0", "scroll0",
"corner1", "side1", "scroll1",
"corner2", "side2", "scroll2",
"corner3", "side3", "scroll3",
"cursor", "contents", "pause"
"back",
"corner0", "side0", "scroll0",
"corner1", "side1", "scroll1",
"corner2", "side2", "scroll2",
"corner3", "side3", "scroll3",
"cursor", "contents", "pause"
]
@viewport = viewport
@sidebitmaps = [nil, nil, nil, nil]
@@ -578,25 +578,21 @@ class SpriteWindow < Window
@sprites["scroll2"].src_rect.set(trimX + 40, trimY + 24, 8, 16) # right
cursorX = trimX
cursorY = trimY + 64
sideRects = [
Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX, trimY + 16, 16, 32),
Rect.new(trimX + 48, trimY + 16, 16, 32),
Rect.new(trimX + 16, trimY + 48, 32, 16)
]
pauseRects = [
trimX + 32, trimY + 64,
trimX + 48, trimY + 64,
trimX + 32, trimY + 80,
trimX + 48, trimY + 80
]
sideRects = [Rect.new(trimX + 16, trimY + 0, 32, 16),
Rect.new(trimX, trimY + 16, 16, 32),
Rect.new(trimX + 48, trimY + 16, 16, 32),
Rect.new(trimX + 16, trimY + 48, 32, 16)]
pauseRects = [trimX + 32, trimY + 64,
trimX + 48, trimY + 64,
trimX + 32, trimY + 80,
trimX + 48, trimY + 80]
pauseWidth = 16
pauseHeight = 16
@sprites["pause"].src_rect.set(
pauseRects[@pauseframe * 2],
pauseRects[@pauseframe * 2 + 1],
pauseWidth, pauseHeight
)
pauseRects[@pauseframe * 2],
pauseRects[(@pauseframe * 2) + 1],
pauseWidth, pauseHeight
)
end
else
trimStartX = @trim[0]
@@ -621,10 +617,10 @@ class SpriteWindow < Window
backRect = Rect.new(@skinrect.x, @skinrect.y, @skinrect.width, @skinrect.height)
blindsRect = nil
sideRects = [
Rect.new(startX, 0, @skinrect.width, startY), # side0 (top)
Rect.new(0, startY, startX, @skinrect.height), # side1 (left)
Rect.new(cx, startY, endX, @skinrect.height), # side2 (right)
Rect.new(startX, cy, @skinrect.width, endY) # side3 (bottom)
Rect.new(startX, 0, @skinrect.width, startY), # side0 (top)
Rect.new(0, startY, startX, @skinrect.height), # side1 (left)
Rect.new(cx, startY, endX, @skinrect.height), # side2 (right)
Rect.new(startX, cy, @skinrect.width, endY) # side3 (bottom)
]
end
end
@@ -664,13 +660,13 @@ class SpriteWindow < Window
@sprites["side2"].y = @y + startY
@sprites["side3"].x = @x + startX
@sprites["side3"].y = @y + @height - endY
@sprites["scroll0"].x = @x + @width / 2 - 8
@sprites["scroll0"].x = @x + (@width / 2) - 8
@sprites["scroll0"].y = @y + 8
@sprites["scroll1"].x = @x + 8
@sprites["scroll1"].y = @y + @height / 2 - 8
@sprites["scroll1"].y = @y + (@height / 2) - 8
@sprites["scroll2"].x = @x + @width - 16
@sprites["scroll2"].y = @y + @height / 2 - 8
@sprites["scroll3"].x = @x + @width / 2 - 8
@sprites["scroll2"].y = @y + (@height / 2) - 8
@sprites["scroll3"].x = @x + (@width / 2) - 8
@sprites["scroll3"].y = @y + @height - 16
@sprites["cursor"].x = @x + startX + @cursor_rect.x
@sprites["cursor"].y = @y + startY + @cursor_rect.y
@@ -691,18 +687,18 @@ class SpriteWindow < Window
height = @cursor_rect.height
if width > 0 && height > 0
cursorrects = [
# sides
Rect.new(cursorX + 2, cursorY + 0, 28, 2),
Rect.new(cursorX + 0, cursorY + 2, 2, 28),
Rect.new(cursorX + 30, cursorY + 2, 2, 28),
Rect.new(cursorX + 2, cursorY + 30, 28, 2),
# corners
Rect.new(cursorX + 0, cursorY + 0, 2, 2),
Rect.new(cursorX + 30, cursorY + 0, 2, 2),
Rect.new(cursorX + 0, cursorY + 30, 2, 2),
Rect.new(cursorX + 30, cursorY + 30, 2, 2),
# back
Rect.new(cursorX + 2, cursorY + 2, 28, 28)
# sides
Rect.new(cursorX + 2, cursorY + 0, 28, 2),
Rect.new(cursorX + 0, cursorY + 2, 2, 28),
Rect.new(cursorX + 30, cursorY + 2, 2, 28),
Rect.new(cursorX + 2, cursorY + 30, 28, 2),
# corners
Rect.new(cursorX + 0, cursorY + 0, 2, 2),
Rect.new(cursorX + 30, cursorY + 0, 2, 2),
Rect.new(cursorX + 0, cursorY + 30, 2, 2),
Rect.new(cursorX + 30, cursorY + 30, 2, 2),
# back
Rect.new(cursorX + 2, cursorY + 2, 28, 28)
]
margin = 2
fullmargin = 4
@@ -789,7 +785,7 @@ class SpriteWindow < Window
opn = @openness / 255.0
for k in @spritekeys
sprite = @sprites[k]
ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height
ratio = (@height <= 0) ? 0 : (sprite.y - @y) / @height.to_f
sprite.zoom_y = opn
sprite.zoom_x = 1.0
sprite.oy = 0
@@ -845,8 +841,8 @@ class SpriteWindow_Base < SpriteWindow
end
def __setWindowskin(skin)
if skin && (skin.width == 192 && skin.height == 128) || # RPGXP Windowskin
(skin.width == 128 && skin.height == 128) # RPGVX Windowskin
if skin && ((skin.width == 192 && skin.height == 128) || # RPGXP Windowskin
(skin.width == 128 && skin.height == 128)) # RPGVX Windowskin
self.skinformat = 0
else
self.skinformat = 1

View File

@@ -621,7 +621,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
@sign = false
@negative = false
super(0, 0, 32, 32)
self.width = digits_max * 24 + 8 + self.borderX
self.width = (digits_max * 24) + 8 + self.borderX
self.height = 32 + self.borderY
colors = getDefaultTextColors(self.windowskin)
@baseColor = colors[0]
@@ -644,16 +644,16 @@ class Window_InputNumberPokemon < SpriteWindow_Base
value = 0 if !value.is_a?(Numeric)
if @sign
@negative = (value < 0)
@number = [value.abs, 10**@digits_max - 1].min
@number = [value.abs, (10**@digits_max) - 1].min
else
@number = [[value, 0].max, 10**@digits_max - 1].min
@number = [[value, 0].max, (10**@digits_max) - 1].min
end
refresh
end
def sign=(value)
@sign = value
self.width = @digits_max * 24 + 8 + self.borderX + (@sign ? 24 : 0)
self.width = (@digits_max * 24) + 8 + self.borderX + (@sign ? 24 : 0)
@index = (@digits_max - 1) + (@sign ? 1 : 0)
refresh
end
@@ -717,9 +717,9 @@ class Window_InputNumberPokemon < SpriteWindow_Base
def textHelper(x, y, text, i)
textwidth = self.contents.text_size(text).width
pbDrawShadowText(self.contents, x + (12 - textwidth / 2), y, textwidth + 4, 32, text, @baseColor, @shadowColor)
pbDrawShadowText(self.contents, x + (12 - (textwidth / 2)), y, textwidth + 4, 32, text, @baseColor, @shadowColor)
if @index == i && @active && @frame / 15 == 0
self.contents.fill_rect(x + (12 - textwidth / 2), y + 30, textwidth, 2, @baseColor)
self.contents.fill_rect(x + (12 - (textwidth / 2)), y + 30, textwidth, 2, @baseColor)
end
end
end
@@ -825,9 +825,9 @@ class SpriteWindow_Selectable < SpriteWindow_Base
item > self.top_item + self.page_item_max
return Rect.new(0, 0, 0, 0)
else
cursor_width = (self.width - self.borderX - (@column_max - 1) * @column_spacing) / @column_max
cursor_width = (self.width - self.borderX - ((@column_max - 1) * @column_spacing)) / @column_max
x = item % @column_max * (cursor_width + @column_spacing)
y = item / @column_max * @row_height - @virtualOy
y = (item / @column_max * @row_height) - @virtualOy
return Rect.new(x, y, cursor_width, @row_height)
end
end
@@ -946,7 +946,7 @@ class SpriteWindow_Selectable < SpriteWindow_Base
# End of code
cursor_width = (self.width - self.borderX) / @column_max
x = self.index % @column_max * (cursor_width + @column_spacing)
y = self.index / @column_max * @row_height - @virtualOy
y = (self.index / @column_max * @row_height) - @virtualOy
self.cursor_rect.set(x, y, cursor_width, @row_height)
self.refresh if dorefresh || force
end
@@ -992,8 +992,8 @@ module UpDownArrowMixin
def adjustForZoom(sprite)
sprite.zoom_x = self.zoom_x
sprite.zoom_y = self.zoom_y
sprite.x = sprite.x * self.zoom_x + self.offset_x / self.zoom_x
sprite.y = sprite.y * self.zoom_y + self.offset_y / self.zoom_y
sprite.x = (sprite.x * self.zoom_x) + (self.offset_x / self.zoom_x)
sprite.y = (sprite.y * self.zoom_y) + (self.offset_y / self.zoom_y)
end
def update
@@ -1093,7 +1093,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
end
# Store suggested width and height of window
dims[0] = [self.borderX + 1,
(width * self.columns) + self.borderX + (self.columns - 1) * self.columnSpacing].max
(width * self.columns) + self.borderX + ((self.columns - 1) * self.columnSpacing)].max
dims[1] = [self.borderY + 1, windowheight].max
dims[1] = [dims[1], Graphics.height].min
end

View File

@@ -94,12 +94,13 @@ class PictureWindow < SpriteWindow_Base
def setBitmap(pathOrBitmap, hue = 0)
clearBitmaps
if pathOrBitmap != nil && pathOrBitmap != ""
if pathOrBitmap.is_a?(Bitmap)
case pathOrBitmap
when Bitmap
@_iconbitmap = pathOrBitmap
self.contents = @_iconbitmap
self.width = @_iconbitmap.width + self.borderX
self.height = @_iconbitmap.height + self.borderY
elsif pathOrBitmap.is_a?(AnimatedBitmap)
when AnimatedBitmap
@_iconbitmap = pathOrBitmap
self.contents = @_iconbitmap.bitmap
self.width = @_iconbitmap.bitmap.width + self.borderX

View File

@@ -48,35 +48,35 @@ def rgbToColor(param)
case param.length
when 8 # 32-bit hex
return Color.new(
(baseint >> 24) & 0xFF,
(baseint >> 16) & 0xFF,
(baseint >> 8) & 0xFF,
(baseint) & 0xFF
(baseint >> 24) & 0xFF,
(baseint >> 16) & 0xFF,
(baseint >> 8) & 0xFF,
(baseint) & 0xFF
)
when 6 # 24-bit hex
return Color.new(
(baseint >> 16) & 0xFF,
(baseint >> 8) & 0xFF,
(baseint) & 0xFF
(baseint >> 16) & 0xFF,
(baseint >> 8) & 0xFF,
(baseint) & 0xFF
)
when 4 # 16-bit hex
return Color.new(
((baseint) & 0x1F) << 3,
((baseint >> 5) & 0x1F) << 3,
((baseint >> 10) & 0x1F) << 3
((baseint) & 0x1F) << 3,
((baseint >> 5) & 0x1F) << 3,
((baseint >> 10) & 0x1F) << 3
)
when 1 # Color number
i = param.to_i
return Font.default_color if i >= 8
return [
Color.new(255, 255, 255, 255),
Color.new(128, 128, 255, 255),
Color.new(255, 128, 128, 255),
Color.new(128, 255, 128, 255),
Color.new(128, 255, 255, 255),
Color.new(255, 128, 255, 255),
Color.new(255, 255, 128, 255),
Color.new(192, 192, 192, 255)
Color.new(255, 255, 255, 255),
Color.new(128, 128, 255, 255),
Color.new(255, 128, 128, 255),
Color.new(128, 255, 128, 255),
Color.new(128, 255, 255, 255),
Color.new(255, 128, 255, 255),
Color.new(255, 255, 128, 255),
Color.new(192, 192, 192, 255)
][i]
else
return Font.default_color
@@ -86,9 +86,9 @@ end
def Rgb16ToColor(param)
baseint = param.to_i(16)
return Color.new(
((baseint) & 0x1F) << 3,
((baseint >> 5) & 0x1F) << 3,
((baseint >> 10) & 0x1F) << 3
((baseint) & 0x1F) << 3,
((baseint >> 5) & 0x1F) << 3,
((baseint >> 10) & 0x1F) << 3
)
end
@@ -98,9 +98,9 @@ def getContrastColor(color)
g = color.green
b = color.blue
yuv = [
r * 0.299 + g * 0.587 + b * 0.114,
r * -0.1687 + g * -0.3313 + b * 0.500 + 0.5,
r * 0.500 + g * -0.4187 + b * -0.0813 + 0.5
(r * 0.299) + (g * 0.587) + (b * 0.114),
(r * -0.1687) + (g * -0.3313) + (b * 0.500) + 0.5,
(r * 0.500) + (g * -0.4187) + (b * -0.0813) + 0.5
]
if yuv[0] < 127.5
yuv[0] += (255 - yuv[0]) / 2
@@ -108,10 +108,10 @@ def getContrastColor(color)
yuv[0] = yuv[0] / 2
end
return Color.new(
yuv[0] + 1.4075 * (yuv[2] - 0.5),
yuv[0] - 0.3455 * (yuv[1] - 0.5) - 0.7169 * (yuv[2] - 0.5),
yuv[0] + 1.7790 * (yuv[1] - 0.5),
color.alpha
yuv[0] + (1.4075 * (yuv[2] - 0.5)),
yuv[0] - (0.3455 * (yuv[1] - 0.5)) - (0.7169 * (yuv[2] - 0.5)),
yuv[0] + (1.7790 * (yuv[1] - 0.5)),
color.alpha
)
end
@@ -198,7 +198,7 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
if textchars[position] == "\n"
if newlineBreaks # treat newline as break
havenl = true
characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false,
characters.push(["\n", x, (y * lineheight) + yDst, 0, lineheight, false, false,
false, colorclone, nil, false, false, "", 8, position, nil, 0])
y += 1
x = 0
@@ -224,18 +224,16 @@ def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheig
# Push character
if heightDst < 0 || yStart < yDst + heightDst
havenl = true if isWaitChar(textchars[position])
characters.push([
textchars[position],
x + xStart, texty, width + 2, lineheight,
false, bold, italic, colorclone, nil, false, false,
defaultfontname, bitmap.font.size, position, nil, 0
])
characters.push([textchars[position],
x + xStart, texty, width + 2, lineheight,
false, bold, italic, colorclone, nil, false, false,
defaultfontname, bitmap.font.size, position, nil, 0])
end
x += width
if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 &&
(!hadnonspace || !hadspace)
havenl = true
characters.insert(lastword[0], ["\n", x, y * lineheight + yDst, 0, lineheight,
characters.insert(lastword[0], ["\n", x, (y * lineheight) + yDst, 0, lineheight,
false, false, false, colorclone, nil, false, false, "", 8, position])
lastword[0] += 1
y += 1
@@ -626,7 +624,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end
nextline.times do
havenl = true
characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false,
characters.push(["\n", x, (y * lineheight) + yDst, 0, lineheight, false, false, false,
defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0])
charactersInternal.push([alignment, y, 0])
y += 1
@@ -640,7 +638,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
if newlineBreaks
if nextline == 0
havenl = true
characters.push(["\n", x, y * lineheight + yDst, 0, lineheight, false, false, false,
characters.push(["\n", x, (y * lineheight) + yDst, 0, lineheight, false, false, false,
defaultcolors[0], defaultcolors[1], false, false, "", 8, position, nil, 0])
charactersInternal.push([alignment, y, 0])
y += 1
@@ -675,22 +673,20 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
if heightDst < 0 || texty < yDst + heightDst
havenl = true if !graphic && isWaitChar(textchars[position])
extraspace = (!graphic && italiccount > 0) ? 2 + (width / 2) : 2
characters.push([
graphic || textchars[position],
x + xStart, texty, width + extraspace, lineheight,
graphic ? true : false,
(boldcount > 0), (italiccount > 0), colors[0], colors[1],
(underlinecount > 0), (strikecount > 0), fontname, fontsize,
position, graphicRect,
((outlinecount > 0) ? 1 : 0) + ((outline2count > 0) ? 2 : 0)
])
characters.push([graphic || textchars[position],
x + xStart, texty, width + extraspace, lineheight,
graphic ? true : false,
(boldcount > 0), (italiccount > 0), colors[0], colors[1],
(underlinecount > 0), (strikecount > 0), fontname, fontsize,
position, graphicRect,
((outlinecount > 0) ? 1 : 0) + ((outline2count > 0) ? 2 : 0)])
charactersInternal.push([alignment, y, xStart, textchars[position], extraspace])
end
x += width
if !explicitBreaksOnly && x + 2 > widthDst && lastword[1] != 0 &&
(!hadnonspace || !hadspace)
havenl = true
characters.insert(lastword[0], ["\n", x, y * lineheight + yDst, 0, lineheight,
characters.insert(lastword[0], ["\n", x, (y * lineheight) + yDst, 0, lineheight,
false, false, false,
defaultcolors[0], defaultcolors[1],
false, false, "", 8, position, nil])
@@ -1045,8 +1041,8 @@ def drawSingleFormattedChar(bitmap, ch)
end
bitmap.font.color = ch[8] if bitmap.font.color != ch[8]
bitmap.draw_text(ch[1] + offset, ch[2] + offset, ch[3], ch[4], ch[0])
else
bitmap.font.color = ch[8] if bitmap.font.color != ch[8]
elsif bitmap.font.color != ch[8]
bitmap.font.color = ch[8]
end
if ch[10] # underline
bitmap.fill_rect(ch[1], ch[2] + ch[4] - 4 - [(ch[4] - bitmap.font.size) / 2, 0].max - 2,

View File

@@ -224,10 +224,9 @@ class FaceWindowVX < SpriteWindow_Base
@faceIndex = faceinfo[1].to_i
@facebitmaptmp = AnimatedBitmap.new(facefile)
@facebitmap = BitmapWrapper.new(96, 96)
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new(
(@faceIndex % 4) * 96,
(@faceIndex / 4) * 96, 96, 96
))
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96)
)
self.contents = @facebitmap
end
@@ -235,10 +234,9 @@ class FaceWindowVX < SpriteWindow_Base
super
if @facebitmaptmp.totalFrames > 1
@facebitmaptmp.update
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new(
(@faceIndex % 4) * 96,
(@faceIndex / 4) * 96, 96, 96
))
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96)
)
end
end
@@ -581,7 +579,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if atTop
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
else
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
end
end
for i in 0...controls.length
@@ -627,7 +625,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgwindow.y = Graphics.height - msgwindow.height
msgback.y = msgwindow.y if msgback
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime)
when "ts" # Change text speed
msgwindow.textspeed = (param == "") ? -999 : param.to_i
when "." # Wait 0.25 seconds
@@ -662,8 +660,8 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if msgwindow.busy?
pbPlayDecisionSE if msgwindow.pausing?
msgwindow.resume
else
break if signWaitCount == 0
elsif signWaitCount == 0
break
end
end
pbUpdateSceneMap
@@ -692,7 +690,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
if atTop
msgwindow.y = -msgwindow.height * i / signWaitTime
else
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - i) / signWaitTime
msgwindow.y = Graphics.height - (msgwindow.height * (signWaitTime - i) / signWaitTime)
end
Graphics.update
Input.update

View File

@@ -453,10 +453,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
totalColumns = getColumnsInLine(@cursorLine)
@cursorColumn = totalColumns if @cursorColumn > totalColumns
@cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0
updateCursorPos(
oldCursorLine != @cursorLine ||
oldCursorColumn != @cursorColumn
)
updateCursorPos(oldCursorLine != @cursorLine || oldCursorColumn != @cursorColumn)
# echoln ["aftermoving",@cursorLine,@cursorColumn]
end