Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -40,39 +40,39 @@ module MessageConfig
end
def self.pbDefaultWindowskin
skin=($data_system) ? $data_system.windowskin_name : nil
if skin && skin!=""
skin=pbResolveBitmap("Graphics/Windowskins/"+skin) || ""
skin = ($data_system) ? $data_system.windowskin_name : nil
if skin && skin != ""
skin = pbResolveBitmap("Graphics/Windowskins/" + skin) || ""
end
skin=pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin)
skin=pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin)
skin = pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin)
skin = pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin)
return skin || ""
end
def self.pbGetSystemFrame
if !@@systemFrame
skin=MessageConfig.pbDefaultSystemFrame
skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@systemFrame=skin || ""
skin = MessageConfig.pbDefaultSystemFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@systemFrame = skin || ""
end
return @@systemFrame
end
def self.pbGetSpeechFrame
if !@@defaultTextSkin
skin=MessageConfig.pbDefaultSpeechFrame
skin=MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@defaultTextSkin=skin || ""
skin = MessageConfig.pbDefaultSpeechFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@defaultTextSkin = skin || ""
end
return @@defaultTextSkin
end
def self.pbSetSystemFrame(value)
@@systemFrame=pbResolveBitmap(value) || ""
@@systemFrame = pbResolveBitmap(value) || ""
end
def self.pbSetSpeechFrame(value)
@@defaultTextSkin=pbResolveBitmap(value) || ""
@@defaultTextSkin = pbResolveBitmap(value) || ""
end
#-----------------------------------------------------------------------------
@@ -82,12 +82,12 @@ module MessageConfig
end
def self.pbGetTextSpeed
@@textSpeed=pbDefaultTextSpeed if !@@textSpeed
@@textSpeed = pbDefaultTextSpeed if !@@textSpeed
return @@textSpeed
end
def self.pbSetTextSpeed(value)
@@textSpeed=value
@@textSpeed = value
end
def self.pbSettingToTextSpeed(speed)
@@ -165,106 +165,106 @@ end
# Position a window
#===============================================================================
def pbBottomRight(window)
window.x=Graphics.width-window.width
window.y=Graphics.height-window.height
window.x = Graphics.width - window.width
window.y = Graphics.height - window.height
end
def pbBottomLeft(window)
window.x=0
window.y=Graphics.height-window.height
window.x = 0
window.y = Graphics.height - window.height
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.y=Graphics.height-window.height
def pbBottomLeftLines(window, lines, width = nil)
window.x = 0
window.width = width ? width : Graphics.width
window.height = (window.borderY rescue 32) + lines * 32
window.y = Graphics.height - window.height
end
def pbPositionFaceWindow(facewindow,msgwindow)
def pbPositionFaceWindow(facewindow, msgwindow)
return if !facewindow
if msgwindow
if facewindow.height<=msgwindow.height
facewindow.y=msgwindow.y
if facewindow.height <= msgwindow.height
facewindow.y = msgwindow.y
else
facewindow.y=msgwindow.y+msgwindow.height-facewindow.height
facewindow.y = msgwindow.y + msgwindow.height - facewindow.height
end
facewindow.x=Graphics.width-facewindow.width
msgwindow.x=0
msgwindow.width=Graphics.width-facewindow.width
facewindow.x = Graphics.width - facewindow.width
msgwindow.x = 0
msgwindow.width = Graphics.width - facewindow.width
else
facewindow.height=Graphics.height if facewindow.height>Graphics.height
facewindow.x=0
facewindow.y=0
facewindow.height = Graphics.height if facewindow.height > Graphics.height
facewindow.x = 0
facewindow.y = 0
end
end
def pbPositionNearMsgWindow(cmdwindow,msgwindow,side)
def pbPositionNearMsgWindow(cmdwindow, msgwindow, side)
return if !cmdwindow
if msgwindow
height=[cmdwindow.height,Graphics.height-msgwindow.height].min
if cmdwindow.height!=height
cmdwindow.height=height
height = [cmdwindow.height, Graphics.height - msgwindow.height].min
if cmdwindow.height != height
cmdwindow.height = height
end
cmdwindow.y=msgwindow.y-cmdwindow.height
if cmdwindow.y<0
cmdwindow.y=msgwindow.y+msgwindow.height
if cmdwindow.y+cmdwindow.height>Graphics.height
cmdwindow.y=msgwindow.y-cmdwindow.height
cmdwindow.y = msgwindow.y - cmdwindow.height
if cmdwindow.y < 0
cmdwindow.y = msgwindow.y + msgwindow.height
if cmdwindow.y + cmdwindow.height > Graphics.height
cmdwindow.y = msgwindow.y - cmdwindow.height
end
end
case side
when :left
cmdwindow.x=msgwindow.x
cmdwindow.x = msgwindow.x
when :right
cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width
else
cmdwindow.x=msgwindow.x+msgwindow.width-cmdwindow.width
cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width
end
else
cmdwindow.height=Graphics.height if cmdwindow.height>Graphics.height
cmdwindow.x=0
cmdwindow.y=0
cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height
cmdwindow.x = 0
cmdwindow.y = 0
end
end
# internal function
def pbRepositionMessageWindow(msgwindow, linecount = 2)
msgwindow.height=32*linecount+msgwindow.borderY
msgwindow.y=(Graphics.height)-(msgwindow.height)
msgwindow.height = 32 * linecount + msgwindow.borderY
msgwindow.y = (Graphics.height) - (msgwindow.height)
if $game_system
case $game_system.message_position
when 0 # up
msgwindow.y=0
msgwindow.y = 0
when 1 # middle
msgwindow.y=(Graphics.height/2)-(msgwindow.height/2)
msgwindow.y = (Graphics.height / 2) - (msgwindow.height / 2)
when 2
msgwindow.y=(Graphics.height)-(msgwindow.height)
msgwindow.y = (Graphics.height) - (msgwindow.height)
end
msgwindow.opacity = 0 if $game_system.message_frame != 0
end
end
# internal function
def pbUpdateMsgWindowPos(msgwindow,event,eventChanged = false)
def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false)
if event
if eventChanged
msgwindow.resizeToFit2(msgwindow.text,Graphics.width*2/3,msgwindow.height)
msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height)
end
msgwindow.y=event.screen_y-48-msgwindow.height
if msgwindow.y<0
msgwindow.y=event.screen_y+24
msgwindow.y = event.screen_y - 48 - msgwindow.height
if msgwindow.y < 0
msgwindow.y = event.screen_y + 24
end
msgwindow.x=event.screen_x-(msgwindow.width/2)
msgwindow.x=0 if msgwindow.x<0
if msgwindow.x>Graphics.width-msgwindow.width
msgwindow.x=Graphics.width-msgwindow.width
msgwindow.x = event.screen_x - (msgwindow.width / 2)
msgwindow.x = 0 if msgwindow.x < 0
if msgwindow.x > Graphics.width - msgwindow.width
msgwindow.x = Graphics.width - msgwindow.width
end
else
curwidth=msgwindow.width
if curwidth!=Graphics.width
msgwindow.width=Graphics.width
msgwindow.width=Graphics.width
curwidth = msgwindow.width
if curwidth != Graphics.width
msgwindow.width = Graphics.width
msgwindow.width = Graphics.width
end
end
end
@@ -272,24 +272,24 @@ end
#===============================================================================
# Determine the colour of a background
#===============================================================================
def isDarkBackground(background,rect = nil)
def isDarkBackground(background, rect = nil)
return true if !background || background.disposed?
rect = background.rect if !rect
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
ySeg = (rect.height/16)
yLoop = (ySeg==0) ? 1 : 16
yStart = (ySeg==0) ? rect.y+(rect.height/2) : rect.y+ySeg/2
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
ySeg = (rect.height / 16)
yLoop = (ySeg == 0) ? 1 : 16
yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + ySeg / 2
count = 0
y = yStart
r = g = b = 0
yLoop.times do
x = xStart
xLoop.times do
clr = background.get_pixel(x,y)
if clr.alpha!=0
clr = background.get_pixel(x, y)
if clr.alpha != 0
r += clr.red
g += clr.green
b += clr.blue
@@ -299,51 +299,51 @@ def isDarkBackground(background,rect = nil)
end
y += ySeg
end
return true if count==0
return true if count == 0
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)
return true if !windowskin || windowskin.disposed?
if windowskin.width==192 && windowskin.height==128
return isDarkBackground(windowskin,Rect.new(0,0,128,128))
elsif windowskin.width==128 && windowskin.height==128
return isDarkBackground(windowskin,Rect.new(0,0,64,64))
elsif windowskin.width==96 && windowskin.height==48
return isDarkBackground(windowskin,Rect.new(32,16,16,16))
if windowskin.width == 192 && windowskin.height == 128
return isDarkBackground(windowskin, Rect.new(0, 0, 128, 128))
elsif windowskin.width == 128 && windowskin.height == 128
return isDarkBackground(windowskin, Rect.new(0, 0, 64, 64))
elsif windowskin.width == 96 && windowskin.height == 48
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
clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2)
return (clr.red * 0.299 + clr.green * 0.587 + clr.blue * 0.114) < 160
end
end
#===============================================================================
# Determine which text colours to use based on the darkness of the background
#===============================================================================
def getSkinColor(windowskin,color,isDarkSkin)
def getSkinColor(windowskin, color, isDarkSkin)
if !windowskin || windowskin.disposed? ||
windowskin.width!=128 || windowskin.height!=128
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
"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 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
@@ -351,13 +351,13 @@ def getSkinColor(windowskin,color,isDarkSkin)
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 sprintf("<c3=%s,%s>",textcolors[2*(color-1)+1],textcolors[2*(color-1)])
if isDarkSkin && color != 12 # Dark background, light text
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
color = 0 if color >= 32
x = 64 + (color % 8) * 8
y = 96 + (color / 8) * 8
pixel = windowskin.get_pixel(x, y)
@@ -367,7 +367,7 @@ end
def getDefaultTextColors(windowskin)
if !windowskin || windowskin.disposed? ||
windowskin.width!=128 || windowskin.height!=128
windowskin.width != 128 || windowskin.height != 128
if isDarkWindowskin(windowskin)
return [MessageConfig::LIGHT_TEXT_MAIN_COLOR, MessageConfig::LIGHT_TEXT_SHADOW_COLOR] # White
else
@@ -376,24 +376,24 @@ def getDefaultTextColors(windowskin)
else # VX windowskin
color = windowskin.get_pixel(64, 96)
shadow = nil
isDark = (color.red+color.green+color.blue)/3 < 128
isDark = (color.red + color.green + color.blue) / 3 < 128
if isDark
shadow = Color.new(color.red+64,color.green+64,color.blue+64)
shadow = Color.new(color.red + 64, color.green + 64, color.blue + 64)
else
shadow = Color.new(color.red-64,color.green-64,color.blue-64)
shadow = Color.new(color.red - 64, color.green - 64, color.blue - 64)
end
return [color,shadow]
return [color, shadow]
end
end
#===============================================================================
# Makes sure a bitmap exists
#===============================================================================
def pbDoEnsureBitmap(bitmap,dwidth,dheight)
if !bitmap || bitmap.disposed? || bitmap.width<dwidth || bitmap.height<dheight
def pbDoEnsureBitmap(bitmap, dwidth, dheight)
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
oldfont = (bitmap && !bitmap.disposed?) ? bitmap.font : nil
bitmap.dispose if bitmap
bitmap = Bitmap.new([1,dwidth].max,[1,dheight].max)
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
(oldfont) ? bitmap.font = oldfont : pbSetSystemFont(bitmap)
bitmap.font.shadow = false if bitmap.font && bitmap.font.respond_to?("shadow")
end
@@ -424,46 +424,46 @@ end
#===============================================================================
# Blend colours, set the colour of all bitmaps in a sprite hash
#===============================================================================
def pbAlphaBlend(dstColor,srcColor)
r=(255*(srcColor.red-dstColor.red)/255)+dstColor.red
g=(255*(srcColor.green-dstColor.green)/255)+dstColor.green
b=(255*(srcColor.blue-dstColor.blue)/255)+dstColor.blue
a=(255*(srcColor.alpha-dstColor.alpha)/255)+dstColor.alpha
return Color.new(r,g,b,a)
def pbAlphaBlend(dstColor, srcColor)
r = (255 * (srcColor.red - dstColor.red) / 255) + dstColor.red
g = (255 * (srcColor.green - dstColor.green) / 255) + dstColor.green
b = (255 * (srcColor.blue - dstColor.blue) / 255) + dstColor.blue
a = (255 * (srcColor.alpha - dstColor.alpha) / 255) + dstColor.alpha
return Color.new(r, g, b, a)
end
def pbSrcOver(dstColor,srcColor)
er=srcColor.red*srcColor.alpha/255
eg=srcColor.green*srcColor.alpha/255
eb=srcColor.blue*srcColor.alpha/255
iea=255-srcColor.alpha
cr=dstColor.red*dstColor.alpha/255
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
r=(a==0) ? 0 : r*255/a
g=(a==0) ? 0 : g*255/a
b=(a==0) ? 0 : b*255/a
return Color.new(r,g,b,a)
def pbSrcOver(dstColor, srcColor)
er = srcColor.red * srcColor.alpha / 255
eg = srcColor.green * srcColor.alpha / 255
eb = srcColor.blue * srcColor.alpha / 255
iea = 255 - srcColor.alpha
cr = dstColor.red * dstColor.alpha / 255
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
r = (a == 0) ? 0 : r * 255 / a
g = (a == 0) ? 0 : g * 255 / a
b = (a == 0) ? 0 : b * 255 / a
return Color.new(r, g, b, a)
end
def pbSetSpritesToColor(sprites,color)
def pbSetSpritesToColor(sprites, color)
return if !sprites || !color
colors={}
colors = {}
for i in sprites
next if !i[1] || pbDisposed?(i[1])
colors[i[0]]=i[1].color.clone
i[1].color=pbSrcOver(i[1].color,color)
colors[i[0]] = i[1].color.clone
i[1].color = pbSrcOver(i[1].color, color)
end
Graphics.update
Input.update
for i in colors
next if !sprites[i[0]]
sprites[i[0]].color=i[1]
sprites[i[0]].color = i[1]
end
end
@@ -480,7 +480,7 @@ end
def pbUpdateSpriteHash(windows)
for i in windows
window=i[1]
window = i[1]
if window
if window.is_a?(Sprite) || window.is_a?(Window)
window.update if !pbDisposed?(window)
@@ -503,14 +503,14 @@ end
def pbDisposeSpriteHash(sprites)
return if !sprites
for i in sprites.keys
pbDisposeSprite(sprites,i)
pbDisposeSprite(sprites, i)
end
sprites.clear
end
# Disposes the specified graphics object within the specified hash. Basically
# like: sprites[id].dispose
def pbDisposeSprite(sprites,id)
def pbDisposeSprite(sprites, id)
sprite = sprites[id]
sprite.dispose if sprite && !pbDisposed?(sprite)
sprites[id] = nil
@@ -531,29 +531,29 @@ end
# Fades and window activations for sprite hashes
#===============================================================================
def pbPushFade
$game_temp.fadestate = [$game_temp.fadestate+1,0].max if $game_temp
$game_temp.fadestate = [$game_temp.fadestate + 1, 0].max if $game_temp
end
def pbPopFade
$game_temp.fadestate = [$game_temp.fadestate-1,0].max if $game_temp
$game_temp.fadestate = [$game_temp.fadestate - 1, 0].max if $game_temp
end
def pbIsFaded?
return ($game_temp) ? $game_temp.fadestate>0 : false
return ($game_temp) ? $game_temp.fadestate > 0 : false
end
# pbFadeOutIn(z) { block }
# Fades out the screen before a block is run and fades it back in after the
# block exits. z indicates the z-coordinate of the viewport used for this effect
def pbFadeOutIn(z = 99999,nofadeout = false)
col=Color.new(0,0,0,0)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=z
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
def pbFadeOutIn(z = 99999, nofadeout = false)
col = Color.new(0, 0, 0, 0)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = z
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
col.set(0,0,0,j*alphaDiff)
viewport.color=col
col.set(0, 0, 0, j * alphaDiff)
viewport.color = col
Graphics.update
Input.update
end
@@ -566,8 +566,8 @@ def pbFadeOutIn(z = 99999,nofadeout = false)
pbPopFade
if !nofadeout
for j in 0..numFrames
col.set(0,0,0,(numFrames-j)*alphaDiff)
viewport.color=col
col.set(0, 0, 0, (numFrames - j) * alphaDiff)
viewport.color = col
Graphics.update
Input.update
end
@@ -576,15 +576,15 @@ def pbFadeOutIn(z = 99999,nofadeout = false)
end
end
def pbFadeOutInWithUpdate(z,sprites,nofadeout = false)
col=Color.new(0,0,0,0)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=z
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
def pbFadeOutInWithUpdate(z, sprites, nofadeout = false)
col = Color.new(0, 0, 0, 0)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = z
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
for j in 0..numFrames
col.set(0,0,0,j*alphaDiff)
viewport.color=col
col.set(0, 0, 0, j * alphaDiff)
viewport.color = col
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
@@ -596,8 +596,8 @@ def pbFadeOutInWithUpdate(z,sprites,nofadeout = false)
pbPopFade
if !nofadeout
for j in 0..numFrames
col.set(0,0,0,(numFrames-j)*alphaDiff)
viewport.color=col
col.set(0, 0, 0, (numFrames - j) * alphaDiff)
viewport.color = col
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
@@ -625,11 +625,11 @@ end
def pbFadeOutAndHide(sprites)
visiblesprites = {}
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
for j in 0..numFrames
pbSetSpritesToColor(sprites,Color.new(0,0,0,j*alphaDiff))
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
@@ -642,7 +642,7 @@ def pbFadeOutAndHide(sprites)
return visiblesprites
end
def pbFadeInAndShow(sprites,visiblesprites = nil)
def pbFadeInAndShow(sprites, visiblesprites = nil)
if visiblesprites
for i in visiblesprites
if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]])
@@ -650,11 +650,11 @@ def pbFadeInAndShow(sprites,visiblesprites = nil)
end
end
end
numFrames = (Graphics.frame_rate*0.4).floor
alphaDiff = (255.0/numFrames).ceil
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
for j in 0..numFrames
pbSetSpritesToColor(sprites,Color.new(0,0,0,((numFrames-j)*alphaDiff)))
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff)))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
@@ -662,11 +662,11 @@ end
# Restores which windows are active for the given sprite hash.
# _activeStatuses_ is the result of a previous call to pbActivateWindows
def pbRestoreActivations(sprites,activeStatuses)
def pbRestoreActivations(sprites, activeStatuses)
return if !sprites || !activeStatuses
for k in activeStatuses.keys
if sprites[k] && sprites[k].is_a?(Window) && !pbDisposed?(sprites[k])
sprites[k].active=activeStatuses[k] ? true : false
sprites[k].active = activeStatuses[k] ? true : false
end
end
end
@@ -675,29 +675,29 @@ end
# runs the code in the block, and reactivates them.
def pbDeactivateWindows(sprites)
if block_given?
pbActivateWindow(sprites,nil) { yield }
pbActivateWindow(sprites, nil) { yield }
else
pbActivateWindow(sprites,nil)
pbActivateWindow(sprites, nil)
end
end
# Activates a specific window of a sprite hash. _key_ is the key of the window
# in the sprite hash. If a code block is given, deactivates all windows except
# the specified window, runs the code in the block, and reactivates them.
def pbActivateWindow(sprites,key)
def pbActivateWindow(sprites, key)
return if !sprites
activeStatuses={}
activeStatuses = {}
for i in sprites
if i[1] && i[1].is_a?(Window) && !pbDisposed?(i[1])
activeStatuses[i[0]]=i[1].active
i[1].active=(i[0]==key)
activeStatuses[i[0]] = i[1].active
i[1].active = (i[0] == key)
end
end
if block_given?
begin
yield
ensure
pbRestoreActivations(sprites,activeStatuses)
pbRestoreActivations(sprites, activeStatuses)
end
return {}
else
@@ -713,18 +713,18 @@ end
# _background_ is a filename within the Graphics/Pictures/ folder and can be
# an animated image.
# _viewport_ is a viewport to place the background in.
def addBackgroundPlane(sprites,planename,background,viewport = nil)
sprites[planename]=AnimatedPlane.new(viewport)
bitmapName=pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName==nil
def addBackgroundPlane(sprites, planename, background, viewport = nil)
sprites[planename] = AnimatedPlane.new(viewport)
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName == nil
# Plane should exist in any case
sprites[planename].bitmap=nil
sprites[planename].visible=false
sprites[planename].bitmap = nil
sprites[planename].visible = false
else
sprites[planename].setBitmap(bitmapName)
for spr in sprites.values
if spr.is_a?(Window)
spr.windowskin=nil
spr.windowskin = nil
end
end
end
@@ -736,17 +736,17 @@ end
# an animated image.
# _color_ is the color to use if the background can't be found.
# _viewport_ is a viewport to place the background in.
def addBackgroundOrColoredPlane(sprites,planename,background,color,viewport = nil)
bitmapName=pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName==nil
def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport = nil)
bitmapName = pbResolveBitmap("Graphics/Pictures/#{background}")
if bitmapName == nil
# Plane should exist in any case
sprites[planename]=ColoredPlane.new(color,viewport)
sprites[planename] = ColoredPlane.new(color, viewport)
else
sprites[planename]=AnimatedPlane.new(viewport)
sprites[planename] = AnimatedPlane.new(viewport)
sprites[planename].setBitmap(bitmapName)
for spr in sprites.values
if spr.is_a?(Window)
spr.windowskin=nil
spr.windowskin = nil
end
end
end
@@ -770,9 +770,9 @@ end
if !defined?(_INTL)
def _INTL(*args)
string=args[0].clone
string = args[0].clone
for i in 1...args.length
string.gsub!(/\{#{i}\}/,"#{args[i]}")
string.gsub!(/\{#{i}\}/, "#{args[i]}")
end
return string
end
@@ -780,10 +780,10 @@ end
if !defined?(_ISPRINTF)
def _ISPRINTF(*args)
string=args[0].clone
string = args[0].clone
for i in 1...args.length
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%"+$1,args[i])
next sprintf("%" + $1, args[i])
}
end
return string
@@ -792,9 +792,9 @@ end
if !defined?(_MAPINTL)
def _MAPINTL(*args)
string=args[1].clone
string = args[1].clone
for i in 2...args.length
string.gsub!(/\{#{i}\}/,"#{args[i+1]}")
string.gsub!(/\{#{i}\}/, "#{args[i + 1]}")
end
return string
end