mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -76,51 +76,51 @@ class Window
|
||||
end
|
||||
|
||||
def initialize(viewport = nil)
|
||||
@sprites={}
|
||||
@spritekeys=[
|
||||
@sprites = {}
|
||||
@spritekeys = [
|
||||
"back",
|
||||
"corner0","side0","scroll0",
|
||||
"corner1","side1","scroll1",
|
||||
"corner2","side2","scroll2",
|
||||
"corner3","side3","scroll3",
|
||||
"cursor","contents","pause"
|
||||
"corner0", "side0", "scroll0",
|
||||
"corner1", "side1", "scroll1",
|
||||
"corner2", "side2", "scroll2",
|
||||
"corner3", "side3", "scroll3",
|
||||
"cursor", "contents", "pause"
|
||||
]
|
||||
@sidebitmaps=[nil,nil,nil,nil]
|
||||
@cursorbitmap=nil
|
||||
@bgbitmap=nil
|
||||
@viewport=viewport
|
||||
@sidebitmaps = [nil, nil, nil, nil]
|
||||
@cursorbitmap = nil
|
||||
@bgbitmap = nil
|
||||
@viewport = viewport
|
||||
for i in @spritekeys
|
||||
@sprites[i]=Sprite.new(@viewport)
|
||||
@sprites[i] = Sprite.new(@viewport)
|
||||
end
|
||||
@disposed=false
|
||||
@tone=Tone.new(0,0,0)
|
||||
@color=Color.new(0,0,0,0)
|
||||
@blankcontents=Bitmap.new(1,1) # RGSS2 requires this
|
||||
@contents=@blankcontents
|
||||
@_windowskin=nil
|
||||
@rpgvx=false # Set to true to emulate RPGVX windows
|
||||
@x=0
|
||||
@y=0
|
||||
@width=0
|
||||
@openness=255
|
||||
@height=0
|
||||
@ox=0
|
||||
@oy=0
|
||||
@z=0
|
||||
@stretch=true
|
||||
@visible=true
|
||||
@active=true
|
||||
@blend_type=0
|
||||
@contents_blend_type=0
|
||||
@opacity=255
|
||||
@back_opacity=255
|
||||
@contents_opacity=255
|
||||
@cursor_rect=WindowCursorRect.new(self)
|
||||
@cursorblink=0
|
||||
@cursoropacity=255
|
||||
@pause=false
|
||||
@pauseopacity=255
|
||||
@pauseframe=0
|
||||
@disposed = false
|
||||
@tone = Tone.new(0, 0, 0)
|
||||
@color = Color.new(0, 0, 0, 0)
|
||||
@blankcontents = Bitmap.new(1, 1) # RGSS2 requires this
|
||||
@contents = @blankcontents
|
||||
@_windowskin = nil
|
||||
@rpgvx = false # Set to true to emulate RPGVX windows
|
||||
@x = 0
|
||||
@y = 0
|
||||
@width = 0
|
||||
@openness = 255
|
||||
@height = 0
|
||||
@ox = 0
|
||||
@oy = 0
|
||||
@z = 0
|
||||
@stretch = true
|
||||
@visible = true
|
||||
@active = true
|
||||
@blend_type = 0
|
||||
@contents_blend_type = 0
|
||||
@opacity = 255
|
||||
@back_opacity = 255
|
||||
@contents_opacity = 255
|
||||
@cursor_rect = WindowCursorRect.new(self)
|
||||
@cursorblink = 0
|
||||
@cursoropacity = 255
|
||||
@pause = false
|
||||
@pauseopacity = 255
|
||||
@pauseframe = 0
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
@@ -128,55 +128,55 @@ class Window
|
||||
if !self.disposed?
|
||||
for i in @sprites
|
||||
i[1].dispose if i[1]
|
||||
@sprites[i[0]]=nil
|
||||
@sprites[i[0]] = nil
|
||||
end
|
||||
for i in 0...@sidebitmaps.length
|
||||
@sidebitmaps[i].dispose if @sidebitmaps[i]
|
||||
@sidebitmaps[i]=nil
|
||||
@sidebitmaps[i] = nil
|
||||
end
|
||||
@blankcontents.dispose
|
||||
@cursorbitmap.dispose if @cursorbitmap
|
||||
@backbitmap.dispose if @backbitmap
|
||||
@sprites.clear
|
||||
@sidebitmaps.clear
|
||||
@_windowskin=nil
|
||||
@_contents=nil
|
||||
@disposed=true
|
||||
@_windowskin = nil
|
||||
@_contents = nil
|
||||
@disposed = true
|
||||
end
|
||||
end
|
||||
|
||||
def openness=(value)
|
||||
@openness=value
|
||||
@openness=0 if @openness<0
|
||||
@openness=255 if @openness>255
|
||||
@openness = value
|
||||
@openness = 0 if @openness < 0
|
||||
@openness = 255 if @openness > 255
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def stretch=(value)
|
||||
@stretch=value
|
||||
@stretch = value
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
@visible=value
|
||||
@visible = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def viewport=(value)
|
||||
@viewport=value
|
||||
@viewport = value
|
||||
for i in @spritekeys
|
||||
@sprites[i].dispose
|
||||
if @sprites[i].is_a?(Sprite)
|
||||
@sprites[i]=Sprite.new(@viewport)
|
||||
@sprites[i] = Sprite.new(@viewport)
|
||||
else
|
||||
@sprites[i]=nil
|
||||
@sprites[i] = nil
|
||||
end
|
||||
end
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
def z=(value)
|
||||
@z=value
|
||||
@z = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
@@ -185,27 +185,27 @@ class Window
|
||||
end
|
||||
|
||||
def contents=(value)
|
||||
@contents=value
|
||||
@contents = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def windowskin=(value)
|
||||
@_windowskin=value
|
||||
if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128
|
||||
@rpgvx=true
|
||||
@_windowskin = value
|
||||
if value && value.is_a?(Bitmap) && !value.disposed? && value.width == 128
|
||||
@rpgvx = true
|
||||
else
|
||||
@rpgvx=false
|
||||
@rpgvx = false
|
||||
end
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
def ox=(value)
|
||||
@ox=value
|
||||
@ox = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def active=(value)
|
||||
@active=value
|
||||
@active = value
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
@@ -213,104 +213,104 @@ class Window
|
||||
if !value
|
||||
@cursor_rect.empty
|
||||
else
|
||||
@cursor_rect.set(value.x,value.y,value.width,value.height)
|
||||
@cursor_rect.set(value.x, value.y, value.width, value.height)
|
||||
end
|
||||
end
|
||||
|
||||
def oy=(value)
|
||||
@oy=value
|
||||
@oy = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def width=(value)
|
||||
@width=value
|
||||
@width = value
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
def height=(value)
|
||||
@height=value
|
||||
@height = value
|
||||
privRefresh(true)
|
||||
end
|
||||
|
||||
def pause=(value)
|
||||
@pause=value
|
||||
@pauseopacity=0 if !value
|
||||
@pause = value
|
||||
@pauseopacity = 0 if !value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def x=(value)
|
||||
@x=value
|
||||
@x = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def y=(value)
|
||||
@y=value
|
||||
@y = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def opacity=(value)
|
||||
@opacity=value
|
||||
@opacity=0 if @opacity<0
|
||||
@opacity=255 if @opacity>255
|
||||
@opacity = value
|
||||
@opacity = 0 if @opacity < 0
|
||||
@opacity = 255 if @opacity > 255
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def back_opacity=(value)
|
||||
@back_opacity=value
|
||||
@back_opacity=0 if @back_opacity<0
|
||||
@back_opacity=255 if @back_opacity>255
|
||||
@back_opacity = value
|
||||
@back_opacity = 0 if @back_opacity < 0
|
||||
@back_opacity = 255 if @back_opacity > 255
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def contents_opacity=(value)
|
||||
@contents_opacity=value
|
||||
@contents_opacity=0 if @contents_opacity<0
|
||||
@contents_opacity=255 if @contents_opacity>255
|
||||
@contents_opacity = value
|
||||
@contents_opacity = 0 if @contents_opacity < 0
|
||||
@contents_opacity = 255 if @contents_opacity > 255
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def tone=(value)
|
||||
@tone=value
|
||||
@tone = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def color=(value)
|
||||
@color=value
|
||||
@color = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def blend_type=(value)
|
||||
@blend_type=value
|
||||
@blend_type = value
|
||||
privRefresh
|
||||
end
|
||||
|
||||
def flash(color,duration)
|
||||
def flash(color, duration)
|
||||
return if disposed?
|
||||
for i in @sprites
|
||||
i[1].flash(color,duration)
|
||||
i[1].flash(color, duration)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
return if disposed?
|
||||
mustchange=false
|
||||
mustchange = false
|
||||
if @active
|
||||
if @cursorblink==0
|
||||
@cursoropacity-=8
|
||||
@cursorblink=1 if @cursoropacity<=128
|
||||
if @cursorblink == 0
|
||||
@cursoropacity -= 8
|
||||
@cursorblink = 1 if @cursoropacity <= 128
|
||||
else
|
||||
@cursoropacity+=8
|
||||
@cursorblink=0 if @cursoropacity>=255
|
||||
@cursoropacity += 8
|
||||
@cursorblink = 0 if @cursoropacity >= 255
|
||||
end
|
||||
mustchange=true if !@cursor_rect.empty?
|
||||
mustchange = true if !@cursor_rect.empty?
|
||||
else
|
||||
mustchange=true if @cursoropacity!=128
|
||||
@cursoropacity=128
|
||||
mustchange = true if @cursoropacity != 128
|
||||
@cursoropacity = 128
|
||||
end
|
||||
if @pause
|
||||
@pauseframe=(Graphics.frame_count / 8) % 4
|
||||
@pauseopacity=[@pauseopacity+64,255].min
|
||||
mustchange=true
|
||||
@pauseframe = (Graphics.frame_count / 8) % 4
|
||||
@pauseopacity = [@pauseopacity + 64, 255].min
|
||||
mustchange = true
|
||||
end
|
||||
privRefresh if mustchange
|
||||
for i in @sprites
|
||||
@@ -320,139 +320,139 @@ class Window
|
||||
|
||||
private
|
||||
|
||||
def ensureBitmap(bitmap,dwidth,dheight)
|
||||
if !bitmap||bitmap.disposed?||bitmap.width<dwidth||bitmap.height<dheight
|
||||
def ensureBitmap(bitmap, dwidth, dheight)
|
||||
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
|
||||
bitmap.dispose if bitmap
|
||||
bitmap=Bitmap.new([1,dwidth].max,[1,dheight].max)
|
||||
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
|
||||
end
|
||||
return bitmap
|
||||
end
|
||||
|
||||
def tileBitmap(dstbitmap,dstrect,srcbitmap,srcrect)
|
||||
def tileBitmap(dstbitmap, dstrect, srcbitmap, srcrect)
|
||||
return if !srcbitmap || srcbitmap.disposed?
|
||||
left=dstrect.x
|
||||
top=dstrect.y
|
||||
left = dstrect.x
|
||||
top = dstrect.y
|
||||
y = 0
|
||||
loop do
|
||||
break unless y < dstrect.height
|
||||
x = 0
|
||||
loop do
|
||||
break unless x < dstrect.width
|
||||
dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
|
||||
x+=srcrect.width
|
||||
dstbitmap.blt(x + left, y + top, srcbitmap, srcrect)
|
||||
x += srcrect.width
|
||||
end
|
||||
y+=srcrect.height
|
||||
y += srcrect.height
|
||||
end
|
||||
end
|
||||
|
||||
def privRefresh(changeBitmap = false)
|
||||
return if self.disposed?
|
||||
backopac=self.back_opacity*self.opacity/255
|
||||
contopac=self.contents_opacity
|
||||
cursoropac=@cursoropacity*contopac/255
|
||||
backopac = self.back_opacity * self.opacity / 255
|
||||
contopac = self.contents_opacity
|
||||
cursoropac = @cursoropacity * contopac / 255
|
||||
for i in 0...4
|
||||
@sprites["corner#{i}"].bitmap=@_windowskin
|
||||
@sprites["scroll#{i}"].bitmap=@_windowskin
|
||||
@sprites["corner#{i}"].bitmap = @_windowskin
|
||||
@sprites["scroll#{i}"].bitmap = @_windowskin
|
||||
end
|
||||
@sprites["pause"].bitmap=@_windowskin
|
||||
@sprites["contents"].bitmap=@contents
|
||||
@sprites["pause"].bitmap = @_windowskin
|
||||
@sprites["contents"].bitmap = @contents
|
||||
if @_windowskin && !@_windowskin.disposed?
|
||||
for i in 0...4
|
||||
@sprites["corner#{i}"].opacity=@opacity
|
||||
@sprites["corner#{i}"].tone=@tone
|
||||
@sprites["corner#{i}"].color=@color
|
||||
@sprites["corner#{i}"].blend_type=@blend_type
|
||||
@sprites["corner#{i}"].visible=@visible
|
||||
@sprites["side#{i}"].opacity=@opacity
|
||||
@sprites["side#{i}"].tone=@tone
|
||||
@sprites["side#{i}"].color=@color
|
||||
@sprites["side#{i}"].blend_type=@blend_type
|
||||
@sprites["side#{i}"].visible=@visible
|
||||
@sprites["scroll#{i}"].opacity=@opacity
|
||||
@sprites["scroll#{i}"].tone=@tone
|
||||
@sprites["scroll#{i}"].blend_type=@blend_type
|
||||
@sprites["scroll#{i}"].color=@color
|
||||
@sprites["scroll#{i}"].visible=@visible
|
||||
@sprites["corner#{i}"].opacity = @opacity
|
||||
@sprites["corner#{i}"].tone = @tone
|
||||
@sprites["corner#{i}"].color = @color
|
||||
@sprites["corner#{i}"].blend_type = @blend_type
|
||||
@sprites["corner#{i}"].visible = @visible
|
||||
@sprites["side#{i}"].opacity = @opacity
|
||||
@sprites["side#{i}"].tone = @tone
|
||||
@sprites["side#{i}"].color = @color
|
||||
@sprites["side#{i}"].blend_type = @blend_type
|
||||
@sprites["side#{i}"].visible = @visible
|
||||
@sprites["scroll#{i}"].opacity = @opacity
|
||||
@sprites["scroll#{i}"].tone = @tone
|
||||
@sprites["scroll#{i}"].blend_type = @blend_type
|
||||
@sprites["scroll#{i}"].color = @color
|
||||
@sprites["scroll#{i}"].visible = @visible
|
||||
end
|
||||
for i in ["back","cursor","pause","contents"]
|
||||
@sprites[i].color=@color
|
||||
@sprites[i].tone=@tone
|
||||
@sprites[i].blend_type=@blend_type
|
||||
for i in ["back", "cursor", "pause", "contents"]
|
||||
@sprites[i].color = @color
|
||||
@sprites[i].tone = @tone
|
||||
@sprites[i].blend_type = @blend_type
|
||||
end
|
||||
@sprites["contents"].blend_type=@contents_blend_type
|
||||
@sprites["back"].opacity=backopac
|
||||
@sprites["contents"].opacity=contopac
|
||||
@sprites["cursor"].opacity=cursoropac
|
||||
@sprites["pause"].opacity=@pauseopacity
|
||||
@sprites["back"].visible=@visible
|
||||
@sprites["contents"].visible=@visible && @openness==255
|
||||
@sprites["pause"].visible=@visible && @pause
|
||||
@sprites["cursor"].visible=@visible && @openness==255
|
||||
hascontents=(@contents && !@contents.disposed?)
|
||||
@sprites["contents"].blend_type = @contents_blend_type
|
||||
@sprites["back"].opacity = backopac
|
||||
@sprites["contents"].opacity = contopac
|
||||
@sprites["cursor"].opacity = cursoropac
|
||||
@sprites["pause"].opacity = @pauseopacity
|
||||
@sprites["back"].visible = @visible
|
||||
@sprites["contents"].visible = @visible && @openness == 255
|
||||
@sprites["pause"].visible = @visible && @pause
|
||||
@sprites["cursor"].visible = @visible && @openness == 255
|
||||
hascontents = (@contents && !@contents.disposed?)
|
||||
@sprites["scroll0"].visible = @visible && hascontents && @oy > 0
|
||||
@sprites["scroll1"].visible = @visible && hascontents && @ox > 0
|
||||
@sprites["scroll2"].visible = @visible && hascontents &&
|
||||
(@contents.width - @ox) > @width-32
|
||||
(@contents.width - @ox) > @width - 32
|
||||
@sprites["scroll3"].visible = @visible && hascontents &&
|
||||
(@contents.height - @oy) > @height-32
|
||||
(@contents.height - @oy) > @height - 32
|
||||
else
|
||||
for i in 0...4
|
||||
@sprites["corner#{i}"].visible=false
|
||||
@sprites["side#{i}"].visible=false
|
||||
@sprites["scroll#{i}"].visible=false
|
||||
@sprites["corner#{i}"].visible = false
|
||||
@sprites["side#{i}"].visible = false
|
||||
@sprites["scroll#{i}"].visible = false
|
||||
end
|
||||
@sprites["contents"].visible=@visible && @openness==255
|
||||
@sprites["contents"].color=@color
|
||||
@sprites["contents"].tone=@tone
|
||||
@sprites["contents"].blend_type=@contents_blend_type
|
||||
@sprites["contents"].opacity=contopac
|
||||
@sprites["back"].visible=false
|
||||
@sprites["pause"].visible=false
|
||||
@sprites["cursor"].visible=false
|
||||
@sprites["contents"].visible = @visible && @openness == 255
|
||||
@sprites["contents"].color = @color
|
||||
@sprites["contents"].tone = @tone
|
||||
@sprites["contents"].blend_type = @contents_blend_type
|
||||
@sprites["contents"].opacity = contopac
|
||||
@sprites["back"].visible = false
|
||||
@sprites["pause"].visible = false
|
||||
@sprites["cursor"].visible = false
|
||||
end
|
||||
for i in @sprites
|
||||
i[1].z=@z
|
||||
i[1].z = @z
|
||||
end
|
||||
if @rpgvx
|
||||
@sprites["cursor"].z=@z # For Compatibility
|
||||
@sprites["contents"].z=@z # For Compatibility
|
||||
@sprites["pause"].z=@z # For Compatibility
|
||||
@sprites["cursor"].z = @z # For Compatibility
|
||||
@sprites["contents"].z = @z # For Compatibility
|
||||
@sprites["pause"].z = @z # For Compatibility
|
||||
else
|
||||
@sprites["cursor"].z=@z+1 # For Compatibility
|
||||
@sprites["contents"].z=@z+2 # For Compatibility
|
||||
@sprites["pause"].z=@z+2 # For Compatibility
|
||||
@sprites["cursor"].z = @z + 1 # For Compatibility
|
||||
@sprites["contents"].z = @z + 2 # For Compatibility
|
||||
@sprites["pause"].z = @z + 2 # For Compatibility
|
||||
end
|
||||
if @rpgvx
|
||||
trimX=64
|
||||
trimY=0
|
||||
backRect=Rect.new(0,0,64,64)
|
||||
blindsRect=Rect.new(0,64,64,64)
|
||||
trimX = 64
|
||||
trimY = 0
|
||||
backRect = Rect.new(0, 0, 64, 64)
|
||||
blindsRect = Rect.new(0, 64, 64, 64)
|
||||
else
|
||||
trimX=128
|
||||
trimY=0
|
||||
backRect=Rect.new(0,0,128,128)
|
||||
blindsRect=nil
|
||||
trimX = 128
|
||||
trimY = 0
|
||||
backRect = Rect.new(0, 0, 128, 128)
|
||||
blindsRect = nil
|
||||
end
|
||||
@sprites["corner0"].src_rect.set(trimX,trimY+0,16,16)
|
||||
@sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16)
|
||||
@sprites["corner2"].src_rect.set(trimX,trimY+48,16,16)
|
||||
@sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16)
|
||||
@sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up
|
||||
@sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down
|
||||
@sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left
|
||||
@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)
|
||||
@sprites["corner0"].src_rect.set(trimX, trimY + 0, 16, 16)
|
||||
@sprites["corner1"].src_rect.set(trimX + 48, trimY + 0, 16, 16)
|
||||
@sprites["corner2"].src_rect.set(trimX, trimY + 48, 16, 16)
|
||||
@sprites["corner3"].src_rect.set(trimX + 48, trimY + 48, 16, 16)
|
||||
@sprites["scroll0"].src_rect.set(trimX + 24, trimY + 16, 16, 8) # up
|
||||
@sprites["scroll3"].src_rect.set(trimX + 24, trimY + 40, 16, 8) # down
|
||||
@sprites["scroll1"].src_rect.set(trimX + 16, trimY + 24, 8, 16) # left
|
||||
@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)
|
||||
]
|
||||
if @width>32 && @height>32
|
||||
@sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32)
|
||||
if @width > 32 && @height > 32
|
||||
@sprites["contents"].src_rect.set(@ox, @oy, @width - 32, @height - 32)
|
||||
else
|
||||
@sprites["contents"].src_rect.set(0,0,0,0)
|
||||
@sprites["contents"].src_rect.set(0, 0, 0, 0)
|
||||
end
|
||||
pauseRects = [
|
||||
trimX + 32, trimY + 64,
|
||||
@@ -460,75 +460,75 @@ class Window
|
||||
trimX + 32, trimY + 80,
|
||||
trimX + 48, trimY + 80
|
||||
]
|
||||
pauseWidth=16
|
||||
pauseHeight=16
|
||||
pauseWidth = 16
|
||||
pauseHeight = 16
|
||||
@sprites["pause"].src_rect.set(pauseRects[@pauseframe * 2],
|
||||
pauseRects[@pauseframe * 2 + 1],
|
||||
pauseWidth,
|
||||
pauseHeight)
|
||||
@sprites["pause"].x=@x+(@width/2)-(pauseWidth/2)
|
||||
@sprites["pause"].y=@y+@height-16 # 16 refers to skin margin
|
||||
@sprites["contents"].x=@x+16
|
||||
@sprites["contents"].y=@y+16
|
||||
@sprites["corner0"].x=@x
|
||||
@sprites["corner0"].y=@y
|
||||
@sprites["corner1"].x=@x+@width-16
|
||||
@sprites["corner1"].y=@y
|
||||
@sprites["corner2"].x=@x
|
||||
@sprites["corner2"].y=@y+@height-16
|
||||
@sprites["corner3"].x=@x+@width-16
|
||||
@sprites["corner3"].y=@y+@height-16
|
||||
@sprites["side0"].x=@x+16
|
||||
@sprites["side0"].y=@y
|
||||
@sprites["side1"].x=@x
|
||||
@sprites["side1"].y=@y+16
|
||||
@sprites["side2"].x=@x+@width-16
|
||||
@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"].y = @y+8
|
||||
@sprites["scroll1"].x = @x+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["scroll3"].y = @y+@height - 16
|
||||
@sprites["back"].x=@x+2
|
||||
@sprites["back"].y=@y+2
|
||||
@sprites["cursor"].x=@x+16+@cursor_rect.x
|
||||
@sprites["cursor"].y=@y+16+@cursor_rect.y
|
||||
@sprites["pause"].x = @x + (@width / 2) - (pauseWidth / 2)
|
||||
@sprites["pause"].y = @y + @height - 16 # 16 refers to skin margin
|
||||
@sprites["contents"].x = @x + 16
|
||||
@sprites["contents"].y = @y + 16
|
||||
@sprites["corner0"].x = @x
|
||||
@sprites["corner0"].y = @y
|
||||
@sprites["corner1"].x = @x + @width - 16
|
||||
@sprites["corner1"].y = @y
|
||||
@sprites["corner2"].x = @x
|
||||
@sprites["corner2"].y = @y + @height - 16
|
||||
@sprites["corner3"].x = @x + @width - 16
|
||||
@sprites["corner3"].y = @y + @height - 16
|
||||
@sprites["side0"].x = @x + 16
|
||||
@sprites["side0"].y = @y
|
||||
@sprites["side1"].x = @x
|
||||
@sprites["side1"].y = @y + 16
|
||||
@sprites["side2"].x = @x + @width - 16
|
||||
@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"].y = @y + 8
|
||||
@sprites["scroll1"].x = @x + 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["scroll3"].y = @y + @height - 16
|
||||
@sprites["back"].x = @x + 2
|
||||
@sprites["back"].y = @y + 2
|
||||
@sprites["cursor"].x = @x + 16 + @cursor_rect.x
|
||||
@sprites["cursor"].y = @y + 16 + @cursor_rect.y
|
||||
if changeBitmap && @_windowskin && !@_windowskin.disposed?
|
||||
width=@cursor_rect.width
|
||||
height=@cursor_rect.height
|
||||
width = @cursor_rect.width
|
||||
height = @cursor_rect.height
|
||||
if width > 0 && height > 0
|
||||
cursorrects=[
|
||||
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),
|
||||
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),
|
||||
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)
|
||||
Rect.new(cursorX + 2, cursorY + 2, 28, 28)
|
||||
]
|
||||
margin=2
|
||||
fullmargin=4
|
||||
margin = 2
|
||||
fullmargin = 4
|
||||
@cursorbitmap = ensureBitmap(@cursorbitmap, width, height)
|
||||
@cursorbitmap.clear
|
||||
@sprites["cursor"].bitmap=@cursorbitmap
|
||||
@sprites["cursor"].src_rect.set(0,0,width,height)
|
||||
rect = Rect.new(margin,margin,
|
||||
@sprites["cursor"].bitmap = @cursorbitmap
|
||||
@sprites["cursor"].src_rect.set(0, 0, width, height)
|
||||
rect = Rect.new(margin, margin,
|
||||
width - fullmargin, height - fullmargin)
|
||||
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8])
|
||||
@cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left
|
||||
@cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right
|
||||
@cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right
|
||||
@cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left
|
||||
@cursorbitmap.blt(width - margin, 0, @_windowskin, cursorrects[5]) # top right
|
||||
@cursorbitmap.blt(0, height - margin, @_windowskin, cursorrects[6]) # bottom right
|
||||
@cursorbitmap.blt(width - margin, height - margin, @_windowskin, cursorrects[7]) # bottom left
|
||||
rect = Rect.new(margin, 0,
|
||||
width - fullmargin, margin)
|
||||
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])
|
||||
@@ -538,67 +538,67 @@ class Window
|
||||
rect = Rect.new(width - margin, margin,
|
||||
margin, height - fullmargin)
|
||||
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2])
|
||||
rect = Rect.new(margin, height-margin,
|
||||
rect = Rect.new(margin, height - margin,
|
||||
width - fullmargin, margin)
|
||||
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3])
|
||||
else
|
||||
@sprites["cursor"].visible=false
|
||||
@sprites["cursor"].src_rect.set(0,0,0,0)
|
||||
@sprites["cursor"].visible = false
|
||||
@sprites["cursor"].src_rect.set(0, 0, 0, 0)
|
||||
end
|
||||
for i in 0...4
|
||||
dwidth = [0, 3].include?(i) ? @width - 32 : 16
|
||||
dheight = [0, 3].include?(i) ? 16 : @height - 32
|
||||
@sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight)
|
||||
@sprites["side#{i}"].bitmap=@sidebitmaps[i]
|
||||
@sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight)
|
||||
@sidebitmaps[i] = ensureBitmap(@sidebitmaps[i], dwidth, dheight)
|
||||
@sprites["side#{i}"].bitmap = @sidebitmaps[i]
|
||||
@sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight)
|
||||
@sidebitmaps[i].clear
|
||||
if sideRects[i].width>0 && sideRects[i].height>0
|
||||
if sideRects[i].width > 0 && sideRects[i].height > 0
|
||||
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
|
||||
@_windowskin,sideRects[i])
|
||||
@_windowskin, sideRects[i])
|
||||
end
|
||||
end
|
||||
backwidth=@width-4
|
||||
backheight=@height-4
|
||||
if backwidth>0 && backheight>0
|
||||
@backbitmap=ensureBitmap(@backbitmap,backwidth,backheight)
|
||||
@sprites["back"].bitmap=@backbitmap
|
||||
@sprites["back"].src_rect.set(0,0,backwidth,backheight)
|
||||
backwidth = @width - 4
|
||||
backheight = @height - 4
|
||||
if backwidth > 0 && backheight > 0
|
||||
@backbitmap = ensureBitmap(@backbitmap, backwidth, backheight)
|
||||
@sprites["back"].bitmap = @backbitmap
|
||||
@sprites["back"].src_rect.set(0, 0, backwidth, backheight)
|
||||
@backbitmap.clear
|
||||
if @stretch
|
||||
@backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect)
|
||||
@backbitmap.stretch_blt(@sprites["back"].src_rect, @_windowskin, backRect)
|
||||
else
|
||||
tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect)
|
||||
tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, backRect)
|
||||
end
|
||||
if blindsRect
|
||||
tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect)
|
||||
tileBitmap(@backbitmap, @sprites["back"].src_rect, @_windowskin, blindsRect)
|
||||
end
|
||||
else
|
||||
@sprites["back"].visible=false
|
||||
@sprites["back"].src_rect.set(0,0,0,0)
|
||||
@sprites["back"].visible = false
|
||||
@sprites["back"].src_rect.set(0, 0, 0, 0)
|
||||
end
|
||||
end
|
||||
if @openness!=255
|
||||
opn=@openness/255.0
|
||||
if @openness != 255
|
||||
opn = @openness / 255.0
|
||||
for k in @spritekeys
|
||||
sprite=@sprites[k]
|
||||
ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height
|
||||
sprite.zoom_y=opn
|
||||
sprite.oy=0
|
||||
sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor
|
||||
sprite = @sprites[k]
|
||||
ratio = (@height <= 0) ? 0 : (sprite.y - @y) * 1.0 / @height
|
||||
sprite.zoom_y = opn
|
||||
sprite.oy = 0
|
||||
sprite.y = (@y + (@height / 2.0) + (@height * ratio * opn) - (@height / 2 * opn)).floor
|
||||
end
|
||||
else
|
||||
for k in @spritekeys
|
||||
sprite=@sprites[k]
|
||||
sprite.zoom_y=1.0
|
||||
sprite = @sprites[k]
|
||||
sprite.zoom_y = 1.0
|
||||
end
|
||||
end
|
||||
i=0
|
||||
i = 0
|
||||
# Ensure Z order
|
||||
for k in @spritekeys
|
||||
sprite=@sprites[k]
|
||||
y=sprite.y
|
||||
sprite.y=i
|
||||
sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y
|
||||
sprite = @sprites[k]
|
||||
y = sprite.y
|
||||
sprite.y = i
|
||||
sprite.oy = (sprite.zoom_y <= 0) ? 0 : (i - y) / sprite.zoom_y
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -4,12 +4,12 @@
|
||||
class IconWindow < SpriteWindow_Base
|
||||
attr_reader :name
|
||||
|
||||
def initialize(x,y,width,height,viewport = nil)
|
||||
super(x,y,width,height)
|
||||
self.viewport=viewport
|
||||
self.contents=nil
|
||||
@name=""
|
||||
@_iconbitmap=nil
|
||||
def initialize(x, y, width, height, viewport = nil)
|
||||
super(x, y, width, height)
|
||||
self.viewport = viewport
|
||||
self.contents = nil
|
||||
@name = ""
|
||||
@_iconbitmap = nil
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -21,14 +21,14 @@ class IconWindow < SpriteWindow_Base
|
||||
super
|
||||
if @_iconbitmap
|
||||
@_iconbitmap.update
|
||||
self.contents=@_iconbitmap.bitmap
|
||||
self.contents = @_iconbitmap.bitmap
|
||||
end
|
||||
end
|
||||
|
||||
def clearBitmaps
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap=nil
|
||||
self.contents=nil if !self.disposed?
|
||||
@_iconbitmap = nil
|
||||
self.contents = nil if !self.disposed?
|
||||
end
|
||||
|
||||
# Sets the icon's filename. Alias for setBitmap.
|
||||
@@ -37,16 +37,16 @@ class IconWindow < SpriteWindow_Base
|
||||
end
|
||||
|
||||
# Sets the icon's filename.
|
||||
def setBitmap(file,hue = 0)
|
||||
def setBitmap(file, hue = 0)
|
||||
clearBitmaps()
|
||||
@name=file
|
||||
return if file==nil
|
||||
if file!=""
|
||||
@_iconbitmap=AnimatedBitmap.new(file,hue)
|
||||
@name = file
|
||||
return if file == nil
|
||||
if file != ""
|
||||
@_iconbitmap = AnimatedBitmap.new(file, hue)
|
||||
# for compatibility
|
||||
self.contents=@_iconbitmap ? @_iconbitmap.bitmap : nil
|
||||
self.contents = @_iconbitmap ? @_iconbitmap.bitmap : nil
|
||||
else
|
||||
@_iconbitmap=nil
|
||||
@_iconbitmap = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -59,10 +59,10 @@ end
|
||||
#===============================================================================
|
||||
class PictureWindow < SpriteWindow_Base
|
||||
def initialize(pathOrBitmap)
|
||||
super(0,0,32,32)
|
||||
self.viewport=viewport
|
||||
self.contents=nil
|
||||
@_iconbitmap=nil
|
||||
super(0, 0, 32, 32)
|
||||
self.viewport = viewport
|
||||
self.contents = nil
|
||||
@_iconbitmap = nil
|
||||
setBitmap(pathOrBitmap)
|
||||
end
|
||||
|
||||
@@ -75,45 +75,45 @@ class PictureWindow < SpriteWindow_Base
|
||||
super
|
||||
if @_iconbitmap
|
||||
if @_iconbitmap.is_a?(Bitmap)
|
||||
self.contents=@_iconbitmap
|
||||
self.contents = @_iconbitmap
|
||||
else
|
||||
@_iconbitmap.update
|
||||
self.contents=@_iconbitmap.bitmap
|
||||
self.contents = @_iconbitmap.bitmap
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def clearBitmaps
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap=nil
|
||||
self.contents=nil if !self.disposed?
|
||||
@_iconbitmap = nil
|
||||
self.contents = nil if !self.disposed?
|
||||
end
|
||||
|
||||
# Sets the icon's bitmap or filename. (hue parameter
|
||||
# is ignored unless pathOrBitmap is a filename)
|
||||
def setBitmap(pathOrBitmap,hue = 0)
|
||||
def setBitmap(pathOrBitmap, hue = 0)
|
||||
clearBitmaps()
|
||||
if pathOrBitmap!=nil && pathOrBitmap!=""
|
||||
if pathOrBitmap != nil && pathOrBitmap != ""
|
||||
if pathOrBitmap.is_a?(Bitmap)
|
||||
@_iconbitmap=pathOrBitmap
|
||||
self.contents=@_iconbitmap
|
||||
self.width=@_iconbitmap.width+self.borderX
|
||||
self.height=@_iconbitmap.height+self.borderY
|
||||
@_iconbitmap = pathOrBitmap
|
||||
self.contents = @_iconbitmap
|
||||
self.width = @_iconbitmap.width + self.borderX
|
||||
self.height = @_iconbitmap.height + self.borderY
|
||||
elsif pathOrBitmap.is_a?(AnimatedBitmap)
|
||||
@_iconbitmap=pathOrBitmap
|
||||
self.contents=@_iconbitmap.bitmap
|
||||
self.width=@_iconbitmap.bitmap.width+self.borderX
|
||||
self.height=@_iconbitmap.bitmap.height+self.borderY
|
||||
@_iconbitmap = pathOrBitmap
|
||||
self.contents = @_iconbitmap.bitmap
|
||||
self.width = @_iconbitmap.bitmap.width + self.borderX
|
||||
self.height = @_iconbitmap.bitmap.height + self.borderY
|
||||
else
|
||||
@_iconbitmap=AnimatedBitmap.new(pathOrBitmap,hue)
|
||||
@_iconbitmap = AnimatedBitmap.new(pathOrBitmap, hue)
|
||||
self.contents = @_iconbitmap&.bitmap
|
||||
self.width = self.borderX + (@_iconbitmap&.bitmap&.width || 32)
|
||||
self.height = self.borderY + (@_iconbitmap&.bitmap&.height || 32)
|
||||
end
|
||||
else
|
||||
@_iconbitmap=nil
|
||||
self.width=32+self.borderX
|
||||
self.height=32+self.borderY
|
||||
@_iconbitmap = nil
|
||||
self.width = 32 + self.borderX
|
||||
self.height = 32 + self.borderY
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,48 +6,48 @@ class SpriteWrapper
|
||||
@sprite = Sprite.new(viewport)
|
||||
end
|
||||
|
||||
def dispose; @sprite.dispose; end
|
||||
def disposed?; return @sprite.disposed?; end
|
||||
def viewport; return @sprite.viewport; end
|
||||
def flash(color,duration); return @sprite.flash(color,duration); end
|
||||
def update; return @sprite.update; end
|
||||
def x; @sprite.x; end
|
||||
def x=(value); @sprite.x = value; end
|
||||
def y; @sprite.y; end
|
||||
def y=(value); @sprite.y = value; end
|
||||
def bitmap; @sprite.bitmap; end
|
||||
def bitmap=(value); @sprite.bitmap = value; end
|
||||
def src_rect; @sprite.src_rect; end
|
||||
def src_rect=(value); @sprite.src_rect = value; end
|
||||
def visible; @sprite.visible; end
|
||||
def visible=(value); @sprite.visible = value; end
|
||||
def z; @sprite.z; end
|
||||
def z=(value); @sprite.z = value; end
|
||||
def ox; @sprite.ox; end
|
||||
def ox=(value); @sprite.ox = value; end
|
||||
def oy; @sprite.oy; end
|
||||
def oy=(value); @sprite.oy = value; end
|
||||
def zoom_x; @sprite.zoom_x; end
|
||||
def zoom_x=(value); @sprite.zoom_x = value; end
|
||||
def zoom_y; @sprite.zoom_y; end
|
||||
def zoom_y=(value); @sprite.zoom_y = value; end
|
||||
def angle; @sprite.angle; end
|
||||
def angle=(value); @sprite.angle = value; end
|
||||
def mirror; @sprite.mirror; end
|
||||
def mirror=(value); @sprite.mirror = value; end
|
||||
def bush_depth; @sprite.bush_depth; end
|
||||
def bush_depth=(value); @sprite.bush_depth = value; end
|
||||
def opacity; @sprite.opacity; end
|
||||
def opacity=(value); @sprite.opacity = value; end
|
||||
def blend_type; @sprite.blend_type; end
|
||||
def blend_type=(value); @sprite.blend_type = value; end
|
||||
def color; @sprite.color; end
|
||||
def color=(value); @sprite.color = value; end
|
||||
def tone; @sprite.tone; end
|
||||
def tone=(value); @sprite.tone = value; end
|
||||
def dispose; @sprite.dispose; end
|
||||
def disposed?; return @sprite.disposed?; end
|
||||
def viewport; return @sprite.viewport; end
|
||||
def flash(color, duration); return @sprite.flash(color, duration); end
|
||||
def update; return @sprite.update; end
|
||||
def x; @sprite.x; end
|
||||
def x=(value); @sprite.x = value; end
|
||||
def y; @sprite.y; end
|
||||
def y=(value); @sprite.y = value; end
|
||||
def bitmap; @sprite.bitmap; end
|
||||
def bitmap=(value); @sprite.bitmap = value; end
|
||||
def src_rect; @sprite.src_rect; end
|
||||
def src_rect=(value); @sprite.src_rect = value; end
|
||||
def visible; @sprite.visible; end
|
||||
def visible=(value); @sprite.visible = value; end
|
||||
def z; @sprite.z; end
|
||||
def z=(value); @sprite.z = value; end
|
||||
def ox; @sprite.ox; end
|
||||
def ox=(value); @sprite.ox = value; end
|
||||
def oy; @sprite.oy; end
|
||||
def oy=(value); @sprite.oy = value; end
|
||||
def zoom_x; @sprite.zoom_x; end
|
||||
def zoom_x=(value); @sprite.zoom_x = value; end
|
||||
def zoom_y; @sprite.zoom_y; end
|
||||
def zoom_y=(value); @sprite.zoom_y = value; end
|
||||
def angle; @sprite.angle; end
|
||||
def angle=(value); @sprite.angle = value; end
|
||||
def mirror; @sprite.mirror; end
|
||||
def mirror=(value); @sprite.mirror = value; end
|
||||
def bush_depth; @sprite.bush_depth; end
|
||||
def bush_depth=(value); @sprite.bush_depth = value; end
|
||||
def opacity; @sprite.opacity; end
|
||||
def opacity=(value); @sprite.opacity = value; end
|
||||
def blend_type; @sprite.blend_type; end
|
||||
def blend_type=(value); @sprite.blend_type = value; end
|
||||
def color; @sprite.color; end
|
||||
def color=(value); @sprite.color = value; end
|
||||
def tone; @sprite.tone; end
|
||||
def tone=(value); @sprite.tone = value; end
|
||||
|
||||
def viewport=(value)
|
||||
return if self.viewport==value
|
||||
return if self.viewport == value
|
||||
bitmap = @sprite.bitmap
|
||||
src_rect = @sprite.src_rect
|
||||
visible = @sprite.visible
|
||||
@@ -94,10 +94,10 @@ end
|
||||
# This bitmap can't be changed to a different one.
|
||||
#===============================================================================
|
||||
class BitmapSprite < SpriteWrapper
|
||||
def initialize(width,height,viewport = nil)
|
||||
def initialize(width, height, viewport = nil)
|
||||
super(viewport)
|
||||
self.bitmap=Bitmap.new(width,height)
|
||||
@initialized=true
|
||||
self.bitmap = Bitmap.new(width, height)
|
||||
@initialized = true
|
||||
end
|
||||
|
||||
def bitmap=(value)
|
||||
@@ -122,82 +122,82 @@ class AnimatedSprite < SpriteWrapper
|
||||
attr_reader :framecount
|
||||
attr_reader :animname
|
||||
|
||||
def initializeLong(animname,framecount,framewidth,frameheight,frameskip)
|
||||
@animname=pbBitmapName(animname)
|
||||
@realframes=0
|
||||
@frameskip=[1,frameskip].max
|
||||
@frameskip *= Graphics.frame_rate/20
|
||||
raise _INTL("Frame width is 0") if framewidth==0
|
||||
raise _INTL("Frame height is 0") if frameheight==0
|
||||
def initializeLong(animname, framecount, framewidth, frameheight, frameskip)
|
||||
@animname = pbBitmapName(animname)
|
||||
@realframes = 0
|
||||
@frameskip = [1, frameskip].max
|
||||
@frameskip *= Graphics.frame_rate / 20
|
||||
raise _INTL("Frame width is 0") if framewidth == 0
|
||||
raise _INTL("Frame height is 0") if frameheight == 0
|
||||
begin
|
||||
@animbitmap=AnimatedBitmap.new(animname).deanimate
|
||||
@animbitmap = AnimatedBitmap.new(animname).deanimate
|
||||
rescue
|
||||
@animbitmap=Bitmap.new(framewidth,frameheight)
|
||||
@animbitmap = Bitmap.new(framewidth, frameheight)
|
||||
end
|
||||
if @animbitmap.width%framewidth!=0
|
||||
if @animbitmap.width % framewidth != 0
|
||||
raise _INTL("Bitmap's width ({1}) is not a multiple of frame width ({2}) [Bitmap={3}]",
|
||||
@animbitmap.width,framewidth,animname)
|
||||
@animbitmap.width, framewidth, animname)
|
||||
end
|
||||
if @animbitmap.height%frameheight!=0
|
||||
if @animbitmap.height % frameheight != 0
|
||||
raise _INTL("Bitmap's height ({1}) is not a multiple of frame height ({2}) [Bitmap={3}]",
|
||||
@animbitmap.height,frameheight,animname)
|
||||
@animbitmap.height, frameheight, animname)
|
||||
end
|
||||
@framecount=framecount
|
||||
@framewidth=framewidth
|
||||
@frameheight=frameheight
|
||||
@framesperrow=@animbitmap.width/@framewidth
|
||||
@playing=false
|
||||
self.bitmap=@animbitmap
|
||||
self.src_rect.width=@framewidth
|
||||
self.src_rect.height=@frameheight
|
||||
self.frame=0
|
||||
@framecount = framecount
|
||||
@framewidth = framewidth
|
||||
@frameheight = frameheight
|
||||
@framesperrow = @animbitmap.width / @framewidth
|
||||
@playing = false
|
||||
self.bitmap = @animbitmap
|
||||
self.src_rect.width = @framewidth
|
||||
self.src_rect.height = @frameheight
|
||||
self.frame = 0
|
||||
end
|
||||
|
||||
# Shorter version of AnimationSprite. All frames are placed on a single row
|
||||
# of the bitmap, so that the width and height need not be defined beforehand
|
||||
def initializeShort(animname,framecount,frameskip)
|
||||
@animname=pbBitmapName(animname)
|
||||
@realframes=0
|
||||
@frameskip=[1,frameskip].max
|
||||
@frameskip *= Graphics.frame_rate/20
|
||||
def initializeShort(animname, framecount, frameskip)
|
||||
@animname = pbBitmapName(animname)
|
||||
@realframes = 0
|
||||
@frameskip = [1, frameskip].max
|
||||
@frameskip *= Graphics.frame_rate / 20
|
||||
begin
|
||||
@animbitmap=AnimatedBitmap.new(animname).deanimate
|
||||
@animbitmap = AnimatedBitmap.new(animname).deanimate
|
||||
rescue
|
||||
@animbitmap=Bitmap.new(framecount*4,32)
|
||||
@animbitmap = Bitmap.new(framecount * 4, 32)
|
||||
end
|
||||
if @animbitmap.width%framecount!=0
|
||||
if @animbitmap.width % framecount != 0
|
||||
raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]",
|
||||
@animbitmap.width,framewidth,animname)
|
||||
@animbitmap.width, framewidth, animname)
|
||||
end
|
||||
@framecount=framecount
|
||||
@framewidth=@animbitmap.width/@framecount
|
||||
@frameheight=@animbitmap.height
|
||||
@framesperrow=framecount
|
||||
@playing=false
|
||||
self.bitmap=@animbitmap
|
||||
self.src_rect.width=@framewidth
|
||||
self.src_rect.height=@frameheight
|
||||
self.frame=0
|
||||
@framecount = framecount
|
||||
@framewidth = @animbitmap.width / @framecount
|
||||
@frameheight = @animbitmap.height
|
||||
@framesperrow = framecount
|
||||
@playing = false
|
||||
self.bitmap = @animbitmap
|
||||
self.src_rect.width = @framewidth
|
||||
self.src_rect.height = @frameheight
|
||||
self.frame = 0
|
||||
end
|
||||
|
||||
def initialize(*args)
|
||||
if args.length==1
|
||||
if args.length == 1
|
||||
super(args[0][3])
|
||||
initializeShort(args[0][0],args[0][1],args[0][2])
|
||||
initializeShort(args[0][0], args[0][1], args[0][2])
|
||||
else
|
||||
super(args[5])
|
||||
initializeLong(args[0],args[1],args[2],args[3],args[4])
|
||||
initializeLong(args[0], args[1], args[2], args[3], args[4])
|
||||
end
|
||||
end
|
||||
|
||||
def self.create(animname,framecount,frameskip,viewport = nil)
|
||||
return self.new([animname,framecount,frameskip,viewport])
|
||||
def self.create(animname, framecount, frameskip, viewport = nil)
|
||||
return self.new([animname, framecount, frameskip, viewport])
|
||||
end
|
||||
|
||||
def dispose
|
||||
return if disposed?
|
||||
@animbitmap.dispose
|
||||
@animbitmap=nil
|
||||
@animbitmap = nil
|
||||
super
|
||||
end
|
||||
|
||||
@@ -206,31 +206,31 @@ class AnimatedSprite < SpriteWrapper
|
||||
end
|
||||
|
||||
def frame=(value)
|
||||
@frame=value
|
||||
@realframes=0
|
||||
self.src_rect.x=@frame%@framesperrow*@framewidth
|
||||
self.src_rect.y=@frame/@framesperrow*@frameheight
|
||||
@frame = value
|
||||
@realframes = 0
|
||||
self.src_rect.x = @frame % @framesperrow * @framewidth
|
||||
self.src_rect.y = @frame / @framesperrow * @frameheight
|
||||
end
|
||||
|
||||
def start
|
||||
@playing=true
|
||||
@realframes=0
|
||||
@playing = true
|
||||
@realframes = 0
|
||||
end
|
||||
|
||||
alias play start
|
||||
|
||||
def stop
|
||||
@playing=false
|
||||
@playing = false
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
if @playing
|
||||
@realframes+=1
|
||||
if @realframes==@frameskip
|
||||
@realframes=0
|
||||
self.frame+=1
|
||||
self.frame%=self.framecount
|
||||
@realframes += 1
|
||||
if @realframes == @frameskip
|
||||
@realframes = 0
|
||||
self.frame += 1
|
||||
self.frame %= self.framecount
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -245,23 +245,23 @@ class IconSprite < SpriteWrapper
|
||||
attr_reader :name
|
||||
|
||||
def initialize(*args)
|
||||
if args.length==0
|
||||
if args.length == 0
|
||||
super(nil)
|
||||
self.bitmap=nil
|
||||
elsif args.length==1
|
||||
self.bitmap = nil
|
||||
elsif args.length == 1
|
||||
super(args[0])
|
||||
self.bitmap=nil
|
||||
elsif args.length==2
|
||||
self.bitmap = nil
|
||||
elsif args.length == 2
|
||||
super(nil)
|
||||
self.x=args[0]
|
||||
self.y=args[1]
|
||||
self.x = args[0]
|
||||
self.y = args[1]
|
||||
else
|
||||
super(args[2])
|
||||
self.x=args[0]
|
||||
self.y=args[1]
|
||||
self.x = args[0]
|
||||
self.y = args[1]
|
||||
end
|
||||
@name=""
|
||||
@_iconbitmap=nil
|
||||
@name = ""
|
||||
@_iconbitmap = nil
|
||||
end
|
||||
|
||||
def dispose
|
||||
@@ -275,35 +275,35 @@ class IconSprite < SpriteWrapper
|
||||
end
|
||||
|
||||
# Sets the icon's filename.
|
||||
def setBitmap(file,hue = 0)
|
||||
oldrc=self.src_rect
|
||||
def setBitmap(file, hue = 0)
|
||||
oldrc = self.src_rect
|
||||
clearBitmaps()
|
||||
@name=file
|
||||
return if file==nil
|
||||
if file!=""
|
||||
@_iconbitmap=AnimatedBitmap.new(file,hue)
|
||||
@name = file
|
||||
return if file == nil
|
||||
if file != ""
|
||||
@_iconbitmap = AnimatedBitmap.new(file, hue)
|
||||
# for compatibility
|
||||
self.bitmap=@_iconbitmap ? @_iconbitmap.bitmap : nil
|
||||
self.src_rect=oldrc
|
||||
self.bitmap = @_iconbitmap ? @_iconbitmap.bitmap : nil
|
||||
self.src_rect = oldrc
|
||||
else
|
||||
@_iconbitmap=nil
|
||||
@_iconbitmap = nil
|
||||
end
|
||||
end
|
||||
|
||||
def clearBitmaps
|
||||
@_iconbitmap.dispose if @_iconbitmap
|
||||
@_iconbitmap=nil
|
||||
self.bitmap=nil if !self.disposed?
|
||||
@_iconbitmap = nil
|
||||
self.bitmap = nil if !self.disposed?
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
return if !@_iconbitmap
|
||||
@_iconbitmap.update
|
||||
if self.bitmap!=@_iconbitmap.bitmap
|
||||
oldrc=self.src_rect
|
||||
self.bitmap=@_iconbitmap.bitmap
|
||||
self.src_rect=oldrc
|
||||
if self.bitmap != @_iconbitmap.bitmap
|
||||
oldrc = self.src_rect
|
||||
self.bitmap = @_iconbitmap.bitmap
|
||||
self.src_rect = oldrc
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -315,7 +315,7 @@ end
|
||||
#===============================================================================
|
||||
class GifSprite < IconSprite
|
||||
def initialize(path)
|
||||
super(0,0)
|
||||
super(0, 0)
|
||||
setBitmap(path)
|
||||
end
|
||||
end
|
||||
@@ -326,7 +326,7 @@ end
|
||||
# SpriteWrapper that stores multiple bitmaps, and displays only one at once.
|
||||
#===============================================================================
|
||||
class ChangelingSprite < SpriteWrapper
|
||||
def initialize(x = 0,y = 0,viewport = nil)
|
||||
def initialize(x = 0, y = 0, viewport = nil)
|
||||
super(viewport)
|
||||
self.x = x
|
||||
self.y = y
|
||||
@@ -334,7 +334,7 @@ class ChangelingSprite < SpriteWrapper
|
||||
@currentBitmap = nil
|
||||
end
|
||||
|
||||
def addBitmap(key,path)
|
||||
def addBitmap(key, path)
|
||||
@bitmaps[key].dispose if @bitmaps[key]
|
||||
@bitmaps[key] = AnimatedBitmap.new(path)
|
||||
end
|
||||
|
||||
@@ -225,14 +225,14 @@ def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1)
|
||||
}
|
||||
end
|
||||
|
||||
def pbGetTileset(name,hue = 0)
|
||||
def pbGetTileset(name, hue = 0)
|
||||
return AnimatedBitmap.new("Graphics/Tilesets/" + name, hue).deanimate
|
||||
end
|
||||
|
||||
def pbGetAutotile(name,hue = 0)
|
||||
def pbGetAutotile(name, hue = 0)
|
||||
return AnimatedBitmap.new("Graphics/Autotiles/" + name, hue).deanimate
|
||||
end
|
||||
|
||||
def pbGetAnimation(name,hue = 0)
|
||||
def pbGetAnimation(name, hue = 0)
|
||||
return AnimatedBitmap.new("Graphics/Animations/" + name, hue).deanimate
|
||||
end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -43,11 +43,11 @@ def pbEventCommentInput(*args)
|
||||
return nil
|
||||
end
|
||||
|
||||
def pbCurrentEventCommentInput(elements,trigger)
|
||||
def pbCurrentEventCommentInput(elements, trigger)
|
||||
return nil if !pbMapInterpreterRunning?
|
||||
event = pbMapInterpreter.get_self
|
||||
return nil if !event
|
||||
return pbEventCommentInput(event,elements,trigger)
|
||||
return pbEventCommentInput(event, elements, trigger)
|
||||
end
|
||||
|
||||
|
||||
@@ -60,54 +60,54 @@ class ChooseNumberParams
|
||||
attr_reader :skin
|
||||
|
||||
def initialize
|
||||
@maxDigits=0
|
||||
@minNumber=0
|
||||
@maxNumber=0
|
||||
@skin=nil
|
||||
@messageSkin=nil
|
||||
@negativesAllowed=false
|
||||
@initialNumber=0
|
||||
@cancelNumber=nil
|
||||
@maxDigits = 0
|
||||
@minNumber = 0
|
||||
@maxNumber = 0
|
||||
@skin = nil
|
||||
@messageSkin = nil
|
||||
@negativesAllowed = false
|
||||
@initialNumber = 0
|
||||
@cancelNumber = nil
|
||||
end
|
||||
|
||||
def setMessageSkin(value)
|
||||
@messageSkin=value
|
||||
@messageSkin = value
|
||||
end
|
||||
|
||||
def setSkin(value)
|
||||
@skin=value
|
||||
@skin = value
|
||||
end
|
||||
|
||||
def setNegativesAllowed(value)
|
||||
@negativeAllowed=value
|
||||
@negativeAllowed = value
|
||||
end
|
||||
|
||||
def negativesAllowed
|
||||
@negativeAllowed ? true : false
|
||||
end
|
||||
|
||||
def setRange(minNumber,maxNumber)
|
||||
maxNumber=minNumber if minNumber>maxNumber
|
||||
@maxDigits=0
|
||||
@minNumber=minNumber
|
||||
@maxNumber=maxNumber
|
||||
def setRange(minNumber, maxNumber)
|
||||
maxNumber = minNumber if minNumber > maxNumber
|
||||
@maxDigits = 0
|
||||
@minNumber = minNumber
|
||||
@maxNumber = maxNumber
|
||||
end
|
||||
|
||||
def setDefaultValue(number)
|
||||
@initialNumber=number
|
||||
@cancelNumber=nil
|
||||
@initialNumber = number
|
||||
@cancelNumber = nil
|
||||
end
|
||||
|
||||
def setInitialValue(number)
|
||||
@initialNumber=number
|
||||
@initialNumber = number
|
||||
end
|
||||
|
||||
def setCancelValue(number)
|
||||
@cancelNumber=number
|
||||
@cancelNumber = number
|
||||
end
|
||||
|
||||
def initialNumber
|
||||
return clamp(@initialNumber,self.minNumber,self.maxNumber)
|
||||
return clamp(@initialNumber, self.minNumber, self.maxNumber)
|
||||
end
|
||||
|
||||
def cancelNumber
|
||||
@@ -115,51 +115,51 @@ class ChooseNumberParams
|
||||
end
|
||||
|
||||
def minNumber
|
||||
ret=0
|
||||
if @maxDigits>0
|
||||
ret=-((10**@maxDigits)-1)
|
||||
ret = 0
|
||||
if @maxDigits > 0
|
||||
ret = -((10**@maxDigits) - 1)
|
||||
else
|
||||
ret=@minNumber
|
||||
ret = @minNumber
|
||||
end
|
||||
ret=0 if !@negativeAllowed && ret<0
|
||||
ret = 0 if !@negativeAllowed && ret < 0
|
||||
return ret
|
||||
end
|
||||
|
||||
def maxNumber
|
||||
ret=0
|
||||
if @maxDigits>0
|
||||
ret=((10**@maxDigits)-1)
|
||||
ret = 0
|
||||
if @maxDigits > 0
|
||||
ret = ((10**@maxDigits) - 1)
|
||||
else
|
||||
ret=@maxNumber
|
||||
ret = @maxNumber
|
||||
end
|
||||
ret=0 if !@negativeAllowed && ret<0
|
||||
ret = 0 if !@negativeAllowed && ret < 0
|
||||
return ret
|
||||
end
|
||||
|
||||
def setMaxDigits(value)
|
||||
@maxDigits=[1,value].max
|
||||
@maxDigits = [1, value].max
|
||||
end
|
||||
|
||||
def maxDigits
|
||||
if @maxDigits>0
|
||||
if @maxDigits > 0
|
||||
return @maxDigits
|
||||
else
|
||||
return [numDigits(self.minNumber),numDigits(self.maxNumber)].max
|
||||
return [numDigits(self.minNumber), numDigits(self.maxNumber)].max
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def clamp(v,mn,mx)
|
||||
return v<mn ? mn : (v>mx ? mx : v)
|
||||
def clamp(v, mn, mx)
|
||||
return v < mn ? mn : (v > mx ? mx : v)
|
||||
end
|
||||
|
||||
def numDigits(number)
|
||||
ans = 1
|
||||
number=number.abs
|
||||
number = number.abs
|
||||
while number >= 10
|
||||
ans+=1
|
||||
number/=10
|
||||
ans += 1
|
||||
number /= 10
|
||||
end
|
||||
return ans
|
||||
end
|
||||
@@ -167,20 +167,20 @@ end
|
||||
|
||||
|
||||
|
||||
def pbChooseNumber(msgwindow,params)
|
||||
def pbChooseNumber(msgwindow, params)
|
||||
return 0 if !params
|
||||
ret=0
|
||||
maximum=params.maxNumber
|
||||
minimum=params.minNumber
|
||||
defaultNumber=params.initialNumber
|
||||
cancelNumber=params.cancelNumber
|
||||
cmdwindow=Window_InputNumberPokemon.new(params.maxDigits)
|
||||
cmdwindow.z=99999
|
||||
cmdwindow.visible=true
|
||||
ret = 0
|
||||
maximum = params.maxNumber
|
||||
minimum = params.minNumber
|
||||
defaultNumber = params.initialNumber
|
||||
cancelNumber = params.cancelNumber
|
||||
cmdwindow = Window_InputNumberPokemon.new(params.maxDigits)
|
||||
cmdwindow.z = 99999
|
||||
cmdwindow.visible = true
|
||||
cmdwindow.setSkin(params.skin) if params.skin
|
||||
cmdwindow.sign=params.negativesAllowed # must be set before number
|
||||
cmdwindow.number=defaultNumber
|
||||
pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
|
||||
cmdwindow.sign = params.negativesAllowed # must be set before number
|
||||
cmdwindow.number = defaultNumber
|
||||
pbPositionNearMsgWindow(cmdwindow, msgwindow, :right)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@@ -189,10 +189,10 @@ def pbChooseNumber(msgwindow,params)
|
||||
msgwindow.update if msgwindow
|
||||
yield if block_given?
|
||||
if Input.trigger?(Input::USE)
|
||||
ret=cmdwindow.number
|
||||
if ret>maximum
|
||||
ret = cmdwindow.number
|
||||
if ret > maximum
|
||||
pbPlayBuzzerSE()
|
||||
elsif ret<minimum
|
||||
elsif ret < minimum
|
||||
pbPlayBuzzerSE()
|
||||
else
|
||||
pbPlayDecisionSE()
|
||||
@@ -200,7 +200,7 @@ def pbChooseNumber(msgwindow,params)
|
||||
end
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCancelSE()
|
||||
ret=cancelNumber
|
||||
ret = cancelNumber
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -216,26 +216,26 @@ end
|
||||
#===============================================================================
|
||||
class FaceWindowVX < SpriteWindow_Base
|
||||
def initialize(face)
|
||||
super(0,0,128,128)
|
||||
faceinfo=face.split(",")
|
||||
facefile=pbResolveBitmap("Graphics/Faces/"+faceinfo[0])
|
||||
facefile=pbResolveBitmap("Graphics/Pictures/"+faceinfo[0]) if !facefile
|
||||
super(0, 0, 128, 128)
|
||||
faceinfo = face.split(",")
|
||||
facefile = pbResolveBitmap("Graphics/Faces/" + faceinfo[0])
|
||||
facefile = pbResolveBitmap("Graphics/Pictures/" + faceinfo[0]) if !facefile
|
||||
self.contents.dispose if self.contents
|
||||
@faceIndex=faceinfo[1].to_i
|
||||
@facebitmaptmp=AnimatedBitmap.new(facefile)
|
||||
@facebitmap=BitmapWrapper.new(96,96)
|
||||
@facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
|
||||
@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
|
||||
))
|
||||
self.contents=@facebitmap
|
||||
self.contents = @facebitmap
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
if @facebitmaptmp.totalFrames>1
|
||||
if @facebitmaptmp.totalFrames > 1
|
||||
@facebitmaptmp.update
|
||||
@facebitmap.blt(0,0,@facebitmaptmp.bitmap,Rect.new(
|
||||
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap, Rect.new(
|
||||
(@faceIndex % 4) * 96,
|
||||
(@faceIndex / 4) * 96, 96, 96
|
||||
))
|
||||
@@ -272,44 +272,44 @@ def pbGetMapNameFromId(id)
|
||||
end
|
||||
|
||||
def pbCsvField!(str)
|
||||
ret=""
|
||||
str.sub!(/\A\s*/,"")
|
||||
if str[0,1]=="\""
|
||||
str[0,1]=""
|
||||
escaped=false
|
||||
fieldbytes=0
|
||||
ret = ""
|
||||
str.sub!(/\A\s*/, "")
|
||||
if str[0, 1] == "\""
|
||||
str[0, 1] = ""
|
||||
escaped = false
|
||||
fieldbytes = 0
|
||||
str.scan(/./) do |s|
|
||||
fieldbytes+=s.length
|
||||
break if s=="\"" && !escaped
|
||||
if s=="\\" && !escaped
|
||||
escaped=true
|
||||
fieldbytes += s.length
|
||||
break if s == "\"" && !escaped
|
||||
if s == "\\" && !escaped
|
||||
escaped = true
|
||||
else
|
||||
ret+=s
|
||||
escaped=false
|
||||
ret += s
|
||||
escaped = false
|
||||
end
|
||||
end
|
||||
str[0,fieldbytes]=""
|
||||
str[0, fieldbytes] = ""
|
||||
if !str[/\A\s*,/] && !str[/\A\s*$/]
|
||||
raise _INTL("Invalid quoted field (in: {1})",ret)
|
||||
raise _INTL("Invalid quoted field (in: {1})", ret)
|
||||
end
|
||||
str[0,str.length]=$~.post_match
|
||||
str[0, str.length] = $~.post_match
|
||||
else
|
||||
if str[/,/]
|
||||
str[0,str.length]=$~.post_match
|
||||
ret=$~.pre_match
|
||||
str[0, str.length] = $~.post_match
|
||||
ret = $~.pre_match
|
||||
else
|
||||
ret=str.clone
|
||||
str[0,str.length]=""
|
||||
ret = str.clone
|
||||
str[0, str.length] = ""
|
||||
end
|
||||
ret.gsub!(/\s+$/,"")
|
||||
ret.gsub!(/\s+$/, "")
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbCsvPosInt!(str)
|
||||
ret=pbCsvField!(str)
|
||||
ret = pbCsvField!(str)
|
||||
if !ret[/\A\d+$/]
|
||||
raise _INTL("Field {1} is not a positive integer",ret)
|
||||
raise _INTL("Field {1} is not a positive integer", ret)
|
||||
end
|
||||
return ret.to_i
|
||||
end
|
||||
@@ -324,50 +324,50 @@ def pbGetGoldString
|
||||
end
|
||||
|
||||
def pbDisplayGoldWindow(msgwindow)
|
||||
moneyString=pbGetGoldString()
|
||||
goldwindow=Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>",moneyString))
|
||||
moneyString = pbGetGoldString()
|
||||
goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>", moneyString))
|
||||
goldwindow.setSkin("Graphics/Windowskins/goldskin")
|
||||
goldwindow.resizeToFit(goldwindow.text,Graphics.width)
|
||||
goldwindow.width=160 if goldwindow.width<=160
|
||||
if msgwindow.y==0
|
||||
goldwindow.y=Graphics.height-goldwindow.height
|
||||
goldwindow.resizeToFit(goldwindow.text, Graphics.width)
|
||||
goldwindow.width = 160 if goldwindow.width <= 160
|
||||
if msgwindow.y == 0
|
||||
goldwindow.y = Graphics.height - goldwindow.height
|
||||
else
|
||||
goldwindow.y=0
|
||||
goldwindow.y = 0
|
||||
end
|
||||
goldwindow.viewport=msgwindow.viewport
|
||||
goldwindow.z=msgwindow.z
|
||||
goldwindow.viewport = msgwindow.viewport
|
||||
goldwindow.z = msgwindow.z
|
||||
return goldwindow
|
||||
end
|
||||
|
||||
def pbDisplayCoinsWindow(msgwindow,goldwindow)
|
||||
def pbDisplayCoinsWindow(msgwindow, goldwindow)
|
||||
coinString = ($player) ? $player.coins.to_s_formatted : "0"
|
||||
coinwindow=Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>",coinString))
|
||||
coinwindow = Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>", coinString))
|
||||
coinwindow.setSkin("Graphics/Windowskins/goldskin")
|
||||
coinwindow.resizeToFit(coinwindow.text,Graphics.width)
|
||||
coinwindow.width=160 if coinwindow.width<=160
|
||||
if msgwindow.y==0
|
||||
coinwindow.y=(goldwindow) ? goldwindow.y-coinwindow.height : Graphics.height-coinwindow.height
|
||||
coinwindow.resizeToFit(coinwindow.text, Graphics.width)
|
||||
coinwindow.width = 160 if coinwindow.width <= 160
|
||||
if msgwindow.y == 0
|
||||
coinwindow.y = (goldwindow) ? goldwindow.y - coinwindow.height : Graphics.height - coinwindow.height
|
||||
else
|
||||
coinwindow.y=(goldwindow) ? goldwindow.height : 0
|
||||
coinwindow.y = (goldwindow) ? goldwindow.height : 0
|
||||
end
|
||||
coinwindow.viewport=msgwindow.viewport
|
||||
coinwindow.z=msgwindow.z
|
||||
coinwindow.viewport = msgwindow.viewport
|
||||
coinwindow.z = msgwindow.z
|
||||
return coinwindow
|
||||
end
|
||||
|
||||
def pbDisplayBattlePointsWindow(msgwindow)
|
||||
pointsString = ($player) ? $player.battle_points.to_s_formatted : "0"
|
||||
pointswindow=Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
|
||||
pointswindow = Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
|
||||
pointswindow.setSkin("Graphics/Windowskins/goldskin")
|
||||
pointswindow.resizeToFit(pointswindow.text,Graphics.width)
|
||||
pointswindow.width=160 if pointswindow.width<=160
|
||||
if msgwindow.y==0
|
||||
pointswindow.y=Graphics.height-pointswindow.height
|
||||
pointswindow.resizeToFit(pointswindow.text, Graphics.width)
|
||||
pointswindow.width = 160 if pointswindow.width <= 160
|
||||
if msgwindow.y == 0
|
||||
pointswindow.y = Graphics.height - pointswindow.height
|
||||
else
|
||||
pointswindow.y=0
|
||||
pointswindow.y = 0
|
||||
end
|
||||
pointswindow.viewport=msgwindow.viewport
|
||||
pointswindow.z=msgwindow.z
|
||||
pointswindow.viewport = msgwindow.viewport
|
||||
pointswindow.z = msgwindow.z
|
||||
return pointswindow
|
||||
end
|
||||
|
||||
@@ -377,39 +377,39 @@ end
|
||||
#
|
||||
#===============================================================================
|
||||
def pbCreateStatusWindow(viewport = nil)
|
||||
msgwindow=Window_AdvancedTextPokemon.new("")
|
||||
msgwindow = Window_AdvancedTextPokemon.new("")
|
||||
if !viewport
|
||||
msgwindow.z=99999
|
||||
msgwindow.z = 99999
|
||||
else
|
||||
msgwindow.viewport=viewport
|
||||
msgwindow.viewport = viewport
|
||||
end
|
||||
msgwindow.visible=false
|
||||
msgwindow.letterbyletter=false
|
||||
pbBottomLeftLines(msgwindow,2)
|
||||
skinfile=MessageConfig.pbGetSpeechFrame()
|
||||
msgwindow.visible = false
|
||||
msgwindow.letterbyletter = false
|
||||
pbBottomLeftLines(msgwindow, 2)
|
||||
skinfile = MessageConfig.pbGetSpeechFrame()
|
||||
msgwindow.setSkin(skinfile)
|
||||
return msgwindow
|
||||
end
|
||||
|
||||
def pbCreateMessageWindow(viewport = nil,skin = nil)
|
||||
msgwindow=Window_AdvancedTextPokemon.new("")
|
||||
def pbCreateMessageWindow(viewport = nil, skin = nil)
|
||||
msgwindow = Window_AdvancedTextPokemon.new("")
|
||||
if !viewport
|
||||
msgwindow.z=99999
|
||||
msgwindow.z = 99999
|
||||
else
|
||||
msgwindow.viewport=viewport
|
||||
msgwindow.viewport = viewport
|
||||
end
|
||||
msgwindow.visible=true
|
||||
msgwindow.letterbyletter=true
|
||||
msgwindow.back_opacity=MessageConfig::WINDOW_OPACITY
|
||||
pbBottomLeftLines(msgwindow,2)
|
||||
$game_temp.message_window_showing=true if $game_temp
|
||||
skin=MessageConfig.pbGetSpeechFrame() if !skin
|
||||
msgwindow.visible = true
|
||||
msgwindow.letterbyletter = true
|
||||
msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY
|
||||
pbBottomLeftLines(msgwindow, 2)
|
||||
$game_temp.message_window_showing = true if $game_temp
|
||||
skin = MessageConfig.pbGetSpeechFrame() if !skin
|
||||
msgwindow.setSkin(skin)
|
||||
return msgwindow
|
||||
end
|
||||
|
||||
def pbDisposeMessageWindow(msgwindow)
|
||||
$game_temp.message_window_showing=false if $game_temp
|
||||
$game_temp.message_window_showing = false if $game_temp
|
||||
msgwindow.dispose
|
||||
end
|
||||
|
||||
@@ -418,29 +418,29 @@ end
|
||||
#===============================================================================
|
||||
# Main message-displaying function
|
||||
#===============================================================================
|
||||
def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil)
|
||||
return if !msgwindow
|
||||
oldletterbyletter=msgwindow.letterbyletter
|
||||
msgwindow.letterbyletter=(letterbyletter) ? true : false
|
||||
ret=nil
|
||||
commands=nil
|
||||
facewindow=nil
|
||||
goldwindow=nil
|
||||
coinwindow=nil
|
||||
battlepointswindow=nil
|
||||
cmdvariable=0
|
||||
cmdIfCancel=0
|
||||
msgwindow.waitcount=0
|
||||
autoresume=false
|
||||
text=message.clone
|
||||
msgback=nil
|
||||
linecount=(Graphics.height>400) ? 3 : 2
|
||||
oldletterbyletter = msgwindow.letterbyletter
|
||||
msgwindow.letterbyletter = (letterbyletter) ? true : false
|
||||
ret = nil
|
||||
commands = nil
|
||||
facewindow = nil
|
||||
goldwindow = nil
|
||||
coinwindow = nil
|
||||
battlepointswindow = nil
|
||||
cmdvariable = 0
|
||||
cmdIfCancel = 0
|
||||
msgwindow.waitcount = 0
|
||||
autoresume = false
|
||||
text = message.clone
|
||||
msgback = nil
|
||||
linecount = (Graphics.height > 400) ? 3 : 2
|
||||
### Text replacement
|
||||
text.gsub!(/\\sign\[([^\]]*)\]/i) { # \sign[something] gets turned into
|
||||
next "\\op\\cl\\ts[]\\w["+$1+"]" # \op\cl\ts[]\w[something]
|
||||
next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something]
|
||||
}
|
||||
text.gsub!(/\\\\/,"\5")
|
||||
text.gsub!(/\\1/,"\1")
|
||||
text.gsub!(/\\\\/, "\5")
|
||||
text.gsub!(/\\1/, "\1")
|
||||
if $game_actors
|
||||
text.gsub!(/\\n\[([1-8])\]/i) {
|
||||
m = $1.to_i
|
||||
@@ -461,17 +461,17 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
text.gsub!(/\\r/i, "<c3=E00808,D0D0C8>")
|
||||
text.gsub!(/\\[Ww]\[([^\]]*)\]/) {
|
||||
w = $1.to_s
|
||||
if w==""
|
||||
if w == ""
|
||||
msgwindow.windowskin = nil
|
||||
else
|
||||
msgwindow.setSkin("Graphics/Windowskins/#{w}",false)
|
||||
msgwindow.setSkin("Graphics/Windowskins/#{w}", false)
|
||||
end
|
||||
next ""
|
||||
}
|
||||
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
|
||||
text.gsub!(/\\[Cc]\[([0-9]+)\]/) {
|
||||
m = $1.to_i
|
||||
next getSkinColor(msgwindow.windowskin,m,isDarkSkin)
|
||||
next getSkinColor(msgwindow.windowskin, m, isDarkSkin)
|
||||
}
|
||||
loop do
|
||||
last_text = text.clone
|
||||
@@ -481,33 +481,33 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
loop do
|
||||
last_text = text.clone
|
||||
text.gsub!(/\\l\[([0-9]+)\]/i) {
|
||||
linecount = [1,$1.to_i].max
|
||||
linecount = [1, $1.to_i].max
|
||||
next ""
|
||||
}
|
||||
break if text == last_text
|
||||
end
|
||||
colortag = ""
|
||||
if $game_system && $game_system.message_frame != 0
|
||||
colortag = getSkinColor(msgwindow.windowskin,0,true)
|
||||
colortag = getSkinColor(msgwindow.windowskin, 0, true)
|
||||
else
|
||||
colortag = getSkinColor(msgwindow.windowskin,0,isDarkSkin)
|
||||
colortag = getSkinColor(msgwindow.windowskin, 0, isDarkSkin)
|
||||
end
|
||||
text = colortag+text
|
||||
text = colortag + text
|
||||
### Controls
|
||||
textchunks=[]
|
||||
controls=[]
|
||||
textchunks = []
|
||||
controls = []
|
||||
while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|pt|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
|
||||
textchunks.push($~.pre_match)
|
||||
if $~[1]
|
||||
controls.push([$~[1].downcase,$~[2],-1])
|
||||
controls.push([$~[1].downcase, $~[2], -1])
|
||||
else
|
||||
controls.push([$~[3].downcase,"",-1])
|
||||
controls.push([$~[3].downcase, "", -1])
|
||||
end
|
||||
text=$~.post_match
|
||||
text = $~.post_match
|
||||
end
|
||||
textchunks.push(text)
|
||||
for chunk in textchunks
|
||||
chunk.gsub!(/\005/,"\\")
|
||||
chunk.gsub!(/\005/, "\\")
|
||||
end
|
||||
textlen = 0
|
||||
for i in 0...controls.length
|
||||
@@ -523,7 +523,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
end
|
||||
text = textchunks.join("")
|
||||
signWaitCount = 0
|
||||
signWaitTime = Graphics.frame_rate/2
|
||||
signWaitTime = Graphics.frame_rate / 2
|
||||
haveSpecialClose = false
|
||||
specialCloseSE = ""
|
||||
for i in 0...controls.length
|
||||
@@ -531,9 +531,9 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
param = controls[i][1]
|
||||
case control
|
||||
when "op"
|
||||
signWaitCount = signWaitTime+1
|
||||
signWaitCount = signWaitTime + 1
|
||||
when "cl"
|
||||
text = text.sub(/\001\z/,"") # fix: '$' can match end of line as well
|
||||
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
|
||||
haveSpecialClose = true
|
||||
specialCloseSE = param
|
||||
when "f"
|
||||
@@ -547,59 +547,59 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
cmdvariable = pbCsvPosInt!(cmds)
|
||||
cmdIfCancel = pbCsvField!(cmds).to_i
|
||||
commands = []
|
||||
while cmds.length>0
|
||||
while cmds.length > 0
|
||||
commands.push(pbCsvField!(cmds))
|
||||
end
|
||||
when "wtnp", "^"
|
||||
text = text.sub(/\001\z/,"") # fix: '$' can match end of line as well
|
||||
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
|
||||
when "se"
|
||||
if controls[i][2]==0
|
||||
if controls[i][2] == 0
|
||||
startSE = param
|
||||
controls[i] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
if startSE!=nil
|
||||
if startSE != nil
|
||||
pbSEPlay(pbStringToAudioFile(startSE))
|
||||
elsif signWaitCount==0 && letterbyletter
|
||||
elsif signWaitCount == 0 && letterbyletter
|
||||
pbPlayDecisionSE()
|
||||
end
|
||||
########## Position message window ##############
|
||||
pbRepositionMessageWindow(msgwindow,linecount)
|
||||
pbRepositionMessageWindow(msgwindow, linecount)
|
||||
if facewindow
|
||||
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
facewindow.viewport = msgwindow.viewport
|
||||
facewindow.z = msgwindow.z
|
||||
end
|
||||
atTop = (msgwindow.y==0)
|
||||
atTop = (msgwindow.y == 0)
|
||||
########## Show text #############################
|
||||
msgwindow.text = text
|
||||
Graphics.frame_reset if Graphics.frame_rate>40
|
||||
Graphics.frame_reset if Graphics.frame_rate > 40
|
||||
loop do
|
||||
if signWaitCount>0
|
||||
if signWaitCount > 0
|
||||
signWaitCount -= 1
|
||||
if atTop
|
||||
msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
|
||||
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
|
||||
next if !controls[i]
|
||||
next if controls[i][2]>msgwindow.position || msgwindow.waitcount!=0
|
||||
next if controls[i][2] > msgwindow.position || msgwindow.waitcount != 0
|
||||
control = controls[i][0]
|
||||
param = controls[i][1]
|
||||
case control
|
||||
when "f"
|
||||
facewindow.dispose if facewindow
|
||||
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
|
||||
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
facewindow.viewport = msgwindow.viewport
|
||||
facewindow.z = msgwindow.z
|
||||
when "ff"
|
||||
facewindow.dispose if facewindow
|
||||
facewindow = FaceWindowVX.new(param)
|
||||
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
facewindow.viewport = msgwindow.viewport
|
||||
facewindow.z = msgwindow.z
|
||||
when "g" # Display gold window
|
||||
@@ -607,7 +607,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
goldwindow = pbDisplayGoldWindow(msgwindow)
|
||||
when "cn" # Display coins window
|
||||
coinwindow.dispose if coinwindow
|
||||
coinwindow = pbDisplayCoinsWindow(msgwindow,goldwindow)
|
||||
coinwindow = pbDisplayCoinsWindow(msgwindow, goldwindow)
|
||||
when "pt" # Display battle points window
|
||||
battlepointswindow.dispose if battlepointswindow
|
||||
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
|
||||
@@ -615,31 +615,31 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
msgwindow.y = 0
|
||||
atTop = true
|
||||
msgback.y = msgwindow.y if msgback
|
||||
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
|
||||
msgwindow.y = -msgwindow.height*signWaitCount/signWaitTime
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
msgwindow.y = -msgwindow.height * signWaitCount / signWaitTime
|
||||
when "wm"
|
||||
atTop = false
|
||||
msgwindow.y = (Graphics.height-msgwindow.height)/2
|
||||
msgwindow.y = (Graphics.height - msgwindow.height) / 2
|
||||
msgback.y = msgwindow.y if msgback
|
||||
pbPositionNearMsgWindow(facewindow,msgwindow,:left)
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
when "wd"
|
||||
atTop = false
|
||||
msgwindow.y = Graphics.height-msgwindow.height
|
||||
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
|
||||
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
|
||||
msgwindow.y = Graphics.height - msgwindow.height * (signWaitTime - signWaitCount) / signWaitTime
|
||||
when "ts" # Change text speed
|
||||
msgwindow.textspeed = (param=="") ? -999 : param.to_i
|
||||
msgwindow.textspeed = (param == "") ? -999 : param.to_i
|
||||
when "." # Wait 0.25 seconds
|
||||
msgwindow.waitcount += Graphics.frame_rate/4
|
||||
msgwindow.waitcount += Graphics.frame_rate / 4
|
||||
when "|" # Wait 1 second
|
||||
msgwindow.waitcount += Graphics.frame_rate
|
||||
when "wt" # Wait X/20 seconds
|
||||
param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
|
||||
msgwindow.waitcount += param.to_i*Graphics.frame_rate/20
|
||||
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
||||
msgwindow.waitcount += param.to_i * Graphics.frame_rate / 20
|
||||
when "wtnp" # Wait X/20 seconds, no pause
|
||||
param = param.sub(/\A\s+/,"").sub(/\s+\z/,"")
|
||||
msgwindow.waitcount = param.to_i*Graphics.frame_rate/20
|
||||
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
|
||||
msgwindow.waitcount = param.to_i * Graphics.frame_rate / 20
|
||||
autoresume = true
|
||||
when "^" # Wait, no pause
|
||||
autoresume = true
|
||||
@@ -654,7 +654,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
Graphics.update
|
||||
Input.update
|
||||
facewindow.update if facewindow
|
||||
if autoresume && msgwindow.waitcount==0
|
||||
if autoresume && msgwindow.waitcount == 0
|
||||
msgwindow.resume if msgwindow.busy?
|
||||
break if !msgwindow.busy?
|
||||
end
|
||||
@@ -663,7 +663,7 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
pbPlayDecisionSE if msgwindow.pausing?
|
||||
msgwindow.resume
|
||||
else
|
||||
break if signWaitCount==0
|
||||
break if signWaitCount == 0
|
||||
end
|
||||
end
|
||||
pbUpdateSceneMap
|
||||
@@ -672,13 +672,13 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
break if (!letterbyletter || commandProc || commands) && !msgwindow.busy?
|
||||
end
|
||||
Input.update # Must call Input.update again to avoid extra triggers
|
||||
msgwindow.letterbyletter=oldletterbyletter
|
||||
msgwindow.letterbyletter = oldletterbyletter
|
||||
if commands
|
||||
$game_variables[cmdvariable]=pbShowCommands(msgwindow,commands,cmdIfCancel)
|
||||
$game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel)
|
||||
$game_map.need_refresh = true if $game_map
|
||||
end
|
||||
if commandProc
|
||||
ret=commandProc.call(msgwindow)
|
||||
ret = commandProc.call(msgwindow)
|
||||
end
|
||||
msgback.dispose if msgback
|
||||
goldwindow.dispose if goldwindow
|
||||
@@ -687,12 +687,12 @@ def pbMessageDisplay(msgwindow,message,letterbyletter = true,commandProc = nil)
|
||||
facewindow.dispose if facewindow
|
||||
if haveSpecialClose
|
||||
pbSEPlay(pbStringToAudioFile(specialCloseSE))
|
||||
atTop = (msgwindow.y==0)
|
||||
atTop = (msgwindow.y == 0)
|
||||
for i in 0..signWaitTime
|
||||
if atTop
|
||||
msgwindow.y = -msgwindow.height*i/signWaitTime
|
||||
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
|
||||
@@ -708,49 +708,49 @@ end
|
||||
#===============================================================================
|
||||
# Message-displaying functions
|
||||
#===============================================================================
|
||||
def pbMessage(message,commands = nil,cmdIfCancel = 0,skin = nil,defaultCmd = 0,&block)
|
||||
def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block)
|
||||
ret = 0
|
||||
msgwindow = pbCreateMessageWindow(nil,skin)
|
||||
msgwindow = pbCreateMessageWindow(nil, skin)
|
||||
if commands
|
||||
ret = pbMessageDisplay(msgwindow,message,true,
|
||||
ret = pbMessageDisplay(msgwindow, message, true,
|
||||
proc { |msgwindow|
|
||||
next Kernel.pbShowCommands(msgwindow,commands,cmdIfCancel,defaultCmd,&block)
|
||||
},&block)
|
||||
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block)
|
||||
}, &block)
|
||||
else
|
||||
pbMessageDisplay(msgwindow,message,&block)
|
||||
pbMessageDisplay(msgwindow, message, &block)
|
||||
end
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
Input.update
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbConfirmMessage(message,&block)
|
||||
return (pbMessage(message,[_INTL("Yes"),_INTL("No")],2,&block)==0)
|
||||
def pbConfirmMessage(message, &block)
|
||||
return (pbMessage(message, [_INTL("Yes"), _INTL("No")], 2, &block) == 0)
|
||||
end
|
||||
|
||||
def pbConfirmMessageSerious(message,&block)
|
||||
return (pbMessage(message,[_INTL("No"),_INTL("Yes")],1,&block)==1)
|
||||
def pbConfirmMessageSerious(message, &block)
|
||||
return (pbMessage(message, [_INTL("No"), _INTL("Yes")], 1, &block) == 1)
|
||||
end
|
||||
|
||||
def pbMessageChooseNumber(message,params,&block)
|
||||
msgwindow = pbCreateMessageWindow(nil,params.messageSkin)
|
||||
ret = pbMessageDisplay(msgwindow,message,true,
|
||||
def pbMessageChooseNumber(message, params, &block)
|
||||
msgwindow = pbCreateMessageWindow(nil, params.messageSkin)
|
||||
ret = pbMessageDisplay(msgwindow, message, true,
|
||||
proc { |msgwindow|
|
||||
next pbChooseNumber(msgwindow,params,&block)
|
||||
},&block)
|
||||
next pbChooseNumber(msgwindow, params, &block)
|
||||
}, &block)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbShowCommands(msgwindow,commands = nil,cmdIfCancel = 0,defaultCmd = 0)
|
||||
def pbShowCommands(msgwindow, commands = nil, cmdIfCancel = 0, defaultCmd = 0)
|
||||
return 0 if !commands
|
||||
cmdwindow=Window_CommandPokemonEx.new(commands)
|
||||
cmdwindow.z=99999
|
||||
cmdwindow.visible=true
|
||||
cmdwindow = Window_CommandPokemonEx.new(commands)
|
||||
cmdwindow.z = 99999
|
||||
cmdwindow.visible = true
|
||||
cmdwindow.resizeToFit(cmdwindow.commands)
|
||||
pbPositionNearMsgWindow(cmdwindow,msgwindow,:right)
|
||||
cmdwindow.index=defaultCmd
|
||||
command=0
|
||||
pbPositionNearMsgWindow(cmdwindow, msgwindow, :right)
|
||||
cmdwindow.index = defaultCmd
|
||||
command = 0
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@@ -758,80 +758,80 @@ def pbShowCommands(msgwindow,commands = nil,cmdIfCancel = 0,defaultCmd = 0)
|
||||
msgwindow.update if msgwindow
|
||||
yield if block_given?
|
||||
if Input.trigger?(Input::BACK)
|
||||
if cmdIfCancel>0
|
||||
command=cmdIfCancel-1
|
||||
if cmdIfCancel > 0
|
||||
command = cmdIfCancel - 1
|
||||
break
|
||||
elsif cmdIfCancel<0
|
||||
command=cmdIfCancel
|
||||
elsif cmdIfCancel < 0
|
||||
command = cmdIfCancel
|
||||
break
|
||||
end
|
||||
end
|
||||
if Input.trigger?(Input::USE)
|
||||
command=cmdwindow.index
|
||||
command = cmdwindow.index
|
||||
break
|
||||
end
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
ret=command
|
||||
ret = command
|
||||
cmdwindow.dispose
|
||||
Input.update
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbShowCommandsWithHelp(msgwindow,commands,help,cmdIfCancel = 0,defaultCmd = 0)
|
||||
msgwin=msgwindow
|
||||
msgwin=pbCreateMessageWindow(nil) if !msgwindow
|
||||
oldlbl=msgwin.letterbyletter
|
||||
msgwin.letterbyletter=false
|
||||
def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCmd = 0)
|
||||
msgwin = msgwindow
|
||||
msgwin = pbCreateMessageWindow(nil) if !msgwindow
|
||||
oldlbl = msgwin.letterbyletter
|
||||
msgwin.letterbyletter = false
|
||||
if commands
|
||||
cmdwindow=Window_CommandPokemonEx.new(commands)
|
||||
cmdwindow.z=99999
|
||||
cmdwindow.visible=true
|
||||
cmdwindow = Window_CommandPokemonEx.new(commands)
|
||||
cmdwindow.z = 99999
|
||||
cmdwindow.visible = true
|
||||
cmdwindow.resizeToFit(cmdwindow.commands)
|
||||
cmdwindow.height=msgwin.y if cmdwindow.height>msgwin.y
|
||||
cmdwindow.index=defaultCmd
|
||||
command=0
|
||||
msgwin.text=help[cmdwindow.index]
|
||||
msgwin.width=msgwin.width # Necessary evil to make it use the proper margins
|
||||
cmdwindow.height = msgwin.y if cmdwindow.height > msgwin.y
|
||||
cmdwindow.index = defaultCmd
|
||||
command = 0
|
||||
msgwin.text = help[cmdwindow.index]
|
||||
msgwin.width = msgwin.width # Necessary evil to make it use the proper margins
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
oldindex=cmdwindow.index
|
||||
oldindex = cmdwindow.index
|
||||
cmdwindow.update
|
||||
if oldindex!=cmdwindow.index
|
||||
msgwin.text=help[cmdwindow.index]
|
||||
if oldindex != cmdwindow.index
|
||||
msgwin.text = help[cmdwindow.index]
|
||||
end
|
||||
msgwin.update
|
||||
yield if block_given?
|
||||
if Input.trigger?(Input::BACK)
|
||||
if cmdIfCancel>0
|
||||
command=cmdIfCancel-1
|
||||
if cmdIfCancel > 0
|
||||
command = cmdIfCancel - 1
|
||||
break
|
||||
elsif cmdIfCancel<0
|
||||
command=cmdIfCancel
|
||||
elsif cmdIfCancel < 0
|
||||
command = cmdIfCancel
|
||||
break
|
||||
end
|
||||
end
|
||||
if Input.trigger?(Input::USE)
|
||||
command=cmdwindow.index
|
||||
command = cmdwindow.index
|
||||
break
|
||||
end
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
ret=command
|
||||
ret = command
|
||||
cmdwindow.dispose
|
||||
Input.update
|
||||
end
|
||||
msgwin.letterbyletter=oldlbl
|
||||
msgwin.letterbyletter = oldlbl
|
||||
msgwin.dispose if !msgwindow
|
||||
return ret
|
||||
end
|
||||
|
||||
# frames is the number of 1/20 seconds to wait for
|
||||
def pbMessageWaitForInput(msgwindow,frames,showPause = false)
|
||||
return if !frames || frames<=0
|
||||
def pbMessageWaitForInput(msgwindow, frames, showPause = false)
|
||||
return if !frames || frames <= 0
|
||||
msgwindow.startPause if msgwindow && showPause
|
||||
frames = frames*Graphics.frame_rate/20
|
||||
frames = frames * Graphics.frame_rate / 20
|
||||
frames.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@@ -845,24 +845,24 @@ def pbMessageWaitForInput(msgwindow,frames,showPause = false)
|
||||
msgwindow.stopPause if msgwindow && showPause
|
||||
end
|
||||
|
||||
def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width = 240)
|
||||
window=Window_TextEntry_Keyboard.new(currenttext,0,0,width,64)
|
||||
ret=""
|
||||
window.maxlength=maxlength
|
||||
window.visible=true
|
||||
window.z=99999
|
||||
pbPositionNearMsgWindow(window,msgwindow,:right)
|
||||
window.text=currenttext
|
||||
window.passwordChar="*" if passwordbox
|
||||
def pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width = 240)
|
||||
window = Window_TextEntry_Keyboard.new(currenttext, 0, 0, width, 64)
|
||||
ret = ""
|
||||
window.maxlength = maxlength
|
||||
window.visible = true
|
||||
window.z = 99999
|
||||
pbPositionNearMsgWindow(window, msgwindow, :right)
|
||||
window.text = currenttext
|
||||
window.passwordChar = "*" if passwordbox
|
||||
Input.text_input = true
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
if Input.triggerex?(:ESCAPE)
|
||||
ret=currenttext
|
||||
ret = currenttext
|
||||
break
|
||||
elsif Input.triggerex?(:RETURN)
|
||||
ret=window.text
|
||||
ret = window.text
|
||||
break
|
||||
end
|
||||
window.update
|
||||
@@ -875,12 +875,12 @@ def pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width = 240)
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbMessageFreeText(message,currenttext,passwordbox,maxlength,width = 240,&block)
|
||||
msgwindow=pbCreateMessageWindow
|
||||
retval=pbMessageDisplay(msgwindow,message,true,
|
||||
def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block)
|
||||
msgwindow = pbCreateMessageWindow
|
||||
retval = pbMessageDisplay(msgwindow, message, true,
|
||||
proc { |msgwindow|
|
||||
next pbFreeText(msgwindow,currenttext,passwordbox,maxlength,width,&block)
|
||||
},&block)
|
||||
next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block)
|
||||
}, &block)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
return retval
|
||||
end
|
||||
|
||||
@@ -8,22 +8,22 @@ class CharacterEntryHelper
|
||||
attr_accessor :cursor
|
||||
|
||||
def initialize(text)
|
||||
@maxlength=-1
|
||||
@text=text
|
||||
@passwordChar=""
|
||||
@cursor=text.scan(/./m).length
|
||||
@maxlength = -1
|
||||
@text = text
|
||||
@passwordChar = ""
|
||||
@cursor = text.scan(/./m).length
|
||||
end
|
||||
|
||||
def textChars
|
||||
chars=text.scan(/./m)
|
||||
if @passwordChar!=""
|
||||
chars = text.scan(/./m)
|
||||
if @passwordChar != ""
|
||||
chars.length.times { |i| chars[i] = @passwordChar }
|
||||
end
|
||||
return chars
|
||||
end
|
||||
|
||||
def passwordChar=(value)
|
||||
@passwordChar=value ? value : ""
|
||||
@passwordChar = value ? value : ""
|
||||
end
|
||||
|
||||
def length
|
||||
@@ -31,52 +31,52 @@ class CharacterEntryHelper
|
||||
end
|
||||
|
||||
def canInsert?
|
||||
chars=self.text.scan(/./m)
|
||||
return false if @maxlength>=0 && chars.length>=@maxlength
|
||||
chars = self.text.scan(/./m)
|
||||
return false if @maxlength >= 0 && chars.length >= @maxlength
|
||||
return true
|
||||
end
|
||||
|
||||
def insert(ch)
|
||||
chars=self.text.scan(/./m)
|
||||
return false if @maxlength>=0 && chars.length>=@maxlength
|
||||
chars.insert(@cursor,ch)
|
||||
@text=""
|
||||
chars = self.text.scan(/./m)
|
||||
return false if @maxlength >= 0 && chars.length >= @maxlength
|
||||
chars.insert(@cursor, ch)
|
||||
@text = ""
|
||||
for ch in chars
|
||||
@text+=ch if ch
|
||||
@text += ch if ch
|
||||
end
|
||||
@cursor+=1
|
||||
@cursor += 1
|
||||
return true
|
||||
end
|
||||
|
||||
def canDelete?
|
||||
chars=self.text.scan(/./m)
|
||||
return false if chars.length<=0 || @cursor<=0
|
||||
chars = self.text.scan(/./m)
|
||||
return false if chars.length <= 0 || @cursor <= 0
|
||||
return true
|
||||
end
|
||||
|
||||
def delete
|
||||
chars=self.text.scan(/./m)
|
||||
return false if chars.length<=0 || @cursor<=0
|
||||
chars.delete_at(@cursor-1)
|
||||
@text=""
|
||||
chars = self.text.scan(/./m)
|
||||
return false if chars.length <= 0 || @cursor <= 0
|
||||
chars.delete_at(@cursor - 1)
|
||||
@text = ""
|
||||
for ch in chars
|
||||
@text+=ch if ch
|
||||
@text += ch if ch
|
||||
end
|
||||
@cursor-=1
|
||||
@cursor -= 1
|
||||
return true
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ensure
|
||||
return if @maxlength<0
|
||||
chars=self.text.scan(/./m)
|
||||
if chars.length>@maxlength && @maxlength>=0
|
||||
chars=chars[0,@maxlength]
|
||||
return if @maxlength < 0
|
||||
chars = self.text.scan(/./m)
|
||||
if chars.length > @maxlength && @maxlength >= 0
|
||||
chars = chars[0, @maxlength]
|
||||
end
|
||||
@text=""
|
||||
@text = ""
|
||||
for ch in chars
|
||||
@text+=ch if ch
|
||||
@text += ch if ch
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -87,19 +87,19 @@ 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]
|
||||
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]
|
||||
if usedarkercolor
|
||||
@baseColor=Color.new(16,24,32)
|
||||
@shadowColor=Color.new(168,184,184)
|
||||
@baseColor = Color.new(16, 24, 32)
|
||||
@shadowColor = Color.new(168, 184, 184)
|
||||
end
|
||||
@helper=CharacterEntryHelper.new(text)
|
||||
@heading=heading
|
||||
self.active=true
|
||||
@frame=0
|
||||
@helper = CharacterEntryHelper.new(text)
|
||||
@heading = heading
|
||||
self.active = true
|
||||
@frame = 0
|
||||
refresh
|
||||
end
|
||||
|
||||
@@ -116,23 +116,23 @@ class Window_TextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def text=(value)
|
||||
@helper.text=value
|
||||
@helper.text = value
|
||||
self.refresh
|
||||
end
|
||||
|
||||
def passwordChar=(value)
|
||||
@helper.passwordChar=value
|
||||
@helper.passwordChar = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def maxlength=(value)
|
||||
@helper.maxlength=value
|
||||
@helper.maxlength = value
|
||||
self.refresh
|
||||
end
|
||||
|
||||
def insert(ch)
|
||||
if @helper.insert(ch)
|
||||
@frame=0
|
||||
@frame = 0
|
||||
self.refresh
|
||||
return true
|
||||
end
|
||||
@@ -141,7 +141,7 @@ class Window_TextEntry < SpriteWindow_Base
|
||||
|
||||
def delete
|
||||
if @helper.delete
|
||||
@frame=0
|
||||
@frame = 0
|
||||
self.refresh
|
||||
return true
|
||||
end
|
||||
@@ -151,7 +151,7 @@ class Window_TextEntry < SpriteWindow_Base
|
||||
def update
|
||||
@frame += 1
|
||||
@frame %= 20
|
||||
self.refresh if (@frame%10)==0
|
||||
self.refresh if (@frame % 10) == 0
|
||||
return if !self.active
|
||||
# Moving cursor
|
||||
if Input.repeat?(Input::LEFT) && Input.press?(Input::ACTION)
|
||||
@@ -172,47 +172,47 @@ class Window_TextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def refresh
|
||||
self.contents=pbDoEnsureBitmap(self.contents,self.width-self.borderX,
|
||||
self.height-self.borderY)
|
||||
bitmap=self.contents
|
||||
self.contents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
|
||||
self.height - self.borderY)
|
||||
bitmap = self.contents
|
||||
bitmap.clear
|
||||
x=0
|
||||
y=0
|
||||
x = 0
|
||||
y = 0
|
||||
if @heading
|
||||
textwidth=bitmap.text_size(@heading).width
|
||||
pbDrawShadowText(bitmap,x,y, textwidth+4, 32, @heading,@baseColor,@shadowColor)
|
||||
y+=32
|
||||
textwidth = bitmap.text_size(@heading).width
|
||||
pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, @heading, @baseColor, @shadowColor)
|
||||
y += 32
|
||||
end
|
||||
x+=4
|
||||
width=self.width-self.borderX
|
||||
cursorcolor=Color.new(16,24,32)
|
||||
textscan=self.text.scan(/./m)
|
||||
scanlength=textscan.length
|
||||
@helper.cursor=scanlength if @helper.cursor>scanlength
|
||||
@helper.cursor=0 if @helper.cursor<0
|
||||
startpos=@helper.cursor
|
||||
fromcursor=0
|
||||
while (startpos>0)
|
||||
c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[startpos-1]
|
||||
fromcursor+=bitmap.text_size(c).width
|
||||
break if fromcursor>width-4
|
||||
startpos-=1
|
||||
x += 4
|
||||
width = self.width - self.borderX
|
||||
cursorcolor = Color.new(16, 24, 32)
|
||||
textscan = self.text.scan(/./m)
|
||||
scanlength = textscan.length
|
||||
@helper.cursor = scanlength if @helper.cursor > scanlength
|
||||
@helper.cursor = 0 if @helper.cursor < 0
|
||||
startpos = @helper.cursor
|
||||
fromcursor = 0
|
||||
while (startpos > 0)
|
||||
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[startpos - 1]
|
||||
fromcursor += bitmap.text_size(c).width
|
||||
break if fromcursor > width - 4
|
||||
startpos -= 1
|
||||
end
|
||||
for i in startpos...scanlength
|
||||
c=(@helper.passwordChar!="") ? @helper.passwordChar : textscan[i]
|
||||
textwidth=bitmap.text_size(c).width
|
||||
next if c=="\n"
|
||||
c = (@helper.passwordChar != "") ? @helper.passwordChar : textscan[i]
|
||||
textwidth = bitmap.text_size(c).width
|
||||
next if c == "\n"
|
||||
# Draw text
|
||||
pbDrawShadowText(bitmap,x,y, textwidth+4, 32, c,@baseColor,@shadowColor)
|
||||
pbDrawShadowText(bitmap, x, y, textwidth + 4, 32, c, @baseColor, @shadowColor)
|
||||
# Draw cursor if necessary
|
||||
if ((@frame/10)&1) == 0 && i==@helper.cursor
|
||||
bitmap.fill_rect(x,y+4,2,24,cursorcolor)
|
||||
if ((@frame / 10) & 1) == 0 && i == @helper.cursor
|
||||
bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor)
|
||||
end
|
||||
# Add x to drawn text width
|
||||
x += textwidth
|
||||
end
|
||||
if ((@frame/10)&1) == 0 && textscan.length==@helper.cursor
|
||||
bitmap.fill_rect(x,y+4,2,24,cursorcolor)
|
||||
if ((@frame / 10) & 1) == 0 && textscan.length == @helper.cursor
|
||||
bitmap.fill_rect(x, y + 4, 2, 24, cursorcolor)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -224,27 +224,27 @@ end
|
||||
#===============================================================================
|
||||
class Window_TextEntry_Keyboard < Window_TextEntry
|
||||
def update
|
||||
@frame+=1
|
||||
@frame%=20
|
||||
self.refresh if ((@frame%10)==0)
|
||||
@frame += 1
|
||||
@frame %= 20
|
||||
self.refresh if ((@frame % 10) == 0)
|
||||
return if !self.active
|
||||
# Moving cursor
|
||||
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
|
||||
if @helper.cursor > 0
|
||||
@helper.cursor-=1
|
||||
@frame=0
|
||||
@helper.cursor -= 1
|
||||
@frame = 0
|
||||
self.refresh
|
||||
end
|
||||
return
|
||||
elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT)
|
||||
if @helper.cursor < self.text.scan(/./m).length
|
||||
@helper.cursor+=1
|
||||
@frame=0
|
||||
@helper.cursor += 1
|
||||
@frame = 0
|
||||
self.refresh
|
||||
end
|
||||
return
|
||||
elsif Input.triggerex?(:BACKSPACE) || Input.repeatex?(:BACKSPACE)
|
||||
self.delete if @helper.cursor>0
|
||||
self.delete if @helper.cursor > 0
|
||||
return
|
||||
elsif Input.triggerex?(:RETURN) || Input.triggerex?(:ESCAPE)
|
||||
return
|
||||
@@ -259,17 +259,17 @@ 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]
|
||||
@helper=CharacterEntryHelper.new(text)
|
||||
@firstline=0
|
||||
@cursorLine=0
|
||||
@cursorColumn=0
|
||||
@frame=0
|
||||
self.active=true
|
||||
def initialize(text, x, y, width, height)
|
||||
super(x, y, width, height)
|
||||
colors = getDefaultTextColors(self.windowskin)
|
||||
@baseColor = colors[0]
|
||||
@shadowColor = colors[1]
|
||||
@helper = CharacterEntryHelper.new(text)
|
||||
@firstline = 0
|
||||
@cursorLine = 0
|
||||
@cursorColumn = 0
|
||||
@frame = 0
|
||||
self.active = true
|
||||
refresh
|
||||
end
|
||||
|
||||
@@ -277,12 +277,12 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
attr_reader :shadowColor
|
||||
|
||||
def baseColor=(value)
|
||||
@baseColor=value
|
||||
@baseColor = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def shadowColor=(value)
|
||||
@shadowColor=value
|
||||
@shadowColor = value
|
||||
refresh
|
||||
end
|
||||
|
||||
@@ -295,23 +295,23 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def text=(value)
|
||||
@helper.text=value
|
||||
@textchars=nil
|
||||
@helper.text = value
|
||||
@textchars = nil
|
||||
self.refresh
|
||||
end
|
||||
|
||||
def maxlength=(value)
|
||||
@helper.maxlength=value
|
||||
@textchars=nil
|
||||
@helper.maxlength = value
|
||||
@textchars = nil
|
||||
self.refresh
|
||||
end
|
||||
|
||||
def insert(ch)
|
||||
@helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn)
|
||||
@helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn)
|
||||
if @helper.insert(ch)
|
||||
@frame=0
|
||||
@textchars=nil
|
||||
moveCursor(0,1)
|
||||
@frame = 0
|
||||
@textchars = nil
|
||||
moveCursor(0, 1)
|
||||
self.refresh
|
||||
return true
|
||||
end
|
||||
@@ -319,11 +319,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def delete
|
||||
@helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn)
|
||||
@helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn)
|
||||
if @helper.delete
|
||||
@frame=0
|
||||
moveCursor(0,-1) # use old textchars
|
||||
@textchars=nil
|
||||
@frame = 0
|
||||
moveCursor(0, -1) # use old textchars
|
||||
@textchars = nil
|
||||
self.refresh
|
||||
return true
|
||||
end
|
||||
@@ -332,67 +332,67 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
|
||||
def getTextChars
|
||||
if !@textchars
|
||||
@textchars=getLineBrokenText(self.contents,@helper.text,
|
||||
self.contents.width,nil)
|
||||
@textchars = getLineBrokenText(self.contents, @helper.text,
|
||||
self.contents.width, nil)
|
||||
end
|
||||
return @textchars
|
||||
end
|
||||
|
||||
def getTotalLines
|
||||
textchars=getTextChars
|
||||
return 1 if textchars.length==0
|
||||
tchar=textchars[textchars.length-1]
|
||||
return tchar[5]+1
|
||||
textchars = getTextChars
|
||||
return 1 if textchars.length == 0
|
||||
tchar = textchars[textchars.length - 1]
|
||||
return tchar[5] + 1
|
||||
end
|
||||
|
||||
def getLineY(line)
|
||||
textchars=getTextChars
|
||||
return 0 if textchars.length==0
|
||||
totallines=getTotalLines()
|
||||
line=0 if line<0
|
||||
line=totallines-1 if line>=totallines
|
||||
maximumY=0
|
||||
textchars = getTextChars
|
||||
return 0 if textchars.length == 0
|
||||
totallines = getTotalLines()
|
||||
line = 0 if line < 0
|
||||
line = totallines - 1 if line >= totallines
|
||||
maximumY = 0
|
||||
for i in 0...textchars.length
|
||||
thisline=textchars[i][5]
|
||||
y=textchars[i][2]
|
||||
return y if thisline==line
|
||||
maximumY=y if maximumY<y
|
||||
thisline = textchars[i][5]
|
||||
y = textchars[i][2]
|
||||
return y if thisline == line
|
||||
maximumY = y if maximumY < y
|
||||
end
|
||||
return maximumY
|
||||
end
|
||||
|
||||
def getColumnsInLine(line)
|
||||
textchars=getTextChars
|
||||
return 0 if textchars.length==0
|
||||
totallines=getTotalLines()
|
||||
line=0 if line<0
|
||||
line=totallines-1 if line>=totallines
|
||||
endpos=0
|
||||
textchars = getTextChars
|
||||
return 0 if textchars.length == 0
|
||||
totallines = getTotalLines()
|
||||
line = 0 if line < 0
|
||||
line = totallines - 1 if line >= totallines
|
||||
endpos = 0
|
||||
for i in 0...textchars.length
|
||||
thisline=textchars[i][5]
|
||||
thislength=textchars[i][8]
|
||||
endpos+=thislength if thisline==line
|
||||
thisline = textchars[i][5]
|
||||
thislength = textchars[i][8]
|
||||
endpos += thislength if thisline == line
|
||||
end
|
||||
return endpos
|
||||
end
|
||||
|
||||
def getPosFromLineAndColumn(line,column)
|
||||
textchars=getTextChars
|
||||
return 0 if textchars.length==0
|
||||
totallines=getTotalLines()
|
||||
line=0 if line<0
|
||||
line=totallines-1 if line>=totallines
|
||||
endpos=0
|
||||
def getPosFromLineAndColumn(line, column)
|
||||
textchars = getTextChars
|
||||
return 0 if textchars.length == 0
|
||||
totallines = getTotalLines()
|
||||
line = 0 if line < 0
|
||||
line = totallines - 1 if line >= totallines
|
||||
endpos = 0
|
||||
for i in 0...textchars.length
|
||||
thisline=textchars[i][5]
|
||||
thispos=textchars[i][6]
|
||||
thiscolumn=textchars[i][7]
|
||||
thislength=textchars[i][8]
|
||||
if thisline==line
|
||||
endpos=thispos+thislength
|
||||
thisline = textchars[i][5]
|
||||
thispos = textchars[i][6]
|
||||
thiscolumn = textchars[i][7]
|
||||
thislength = textchars[i][8]
|
||||
if thisline == line
|
||||
endpos = thispos + thislength
|
||||
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]]
|
||||
if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0
|
||||
return thispos+(column-thiscolumn)
|
||||
if column >= thiscolumn && column <= thiscolumn + thislength && thislength > 0
|
||||
return thispos + (column - thiscolumn)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -406,89 +406,89 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
|
||||
def getLastVisibleLine
|
||||
getTextChars()
|
||||
textheight=[1,self.contents.text_size("X").height].max
|
||||
lastVisible=@firstline+((self.height-self.borderY)/textheight)-1
|
||||
textheight = [1, self.contents.text_size("X").height].max
|
||||
lastVisible = @firstline + ((self.height - self.borderY) / textheight) - 1
|
||||
return lastVisible
|
||||
end
|
||||
|
||||
def updateCursorPos(doRefresh)
|
||||
# Calculate new cursor position
|
||||
@helper.cursor=getPosFromLineAndColumn(@cursorLine,@cursorColumn)
|
||||
@helper.cursor = getPosFromLineAndColumn(@cursorLine, @cursorColumn)
|
||||
if doRefresh
|
||||
@frame=0
|
||||
@frame = 0
|
||||
self.refresh
|
||||
end
|
||||
@firstline=@cursorLine if @cursorLine<@firstline
|
||||
lastVisible=getLastVisibleLine()
|
||||
@firstline+=(@cursorLine-lastVisible) if @cursorLine>lastVisible
|
||||
@firstline = @cursorLine if @cursorLine < @firstline
|
||||
lastVisible = getLastVisibleLine()
|
||||
@firstline += (@cursorLine - lastVisible) if @cursorLine > lastVisible
|
||||
end
|
||||
|
||||
def moveCursor(lineOffset, columnOffset)
|
||||
# Move column offset first, then lines (since column offset
|
||||
# can affect line offset)
|
||||
# echoln ["beforemoving",@cursorLine,@cursorColumn]
|
||||
totalColumns=getColumnsInLine(@cursorLine) # check current line
|
||||
totalLines=getTotalLines()
|
||||
oldCursorLine=@cursorLine
|
||||
oldCursorColumn=@cursorColumn
|
||||
@cursorColumn+=columnOffset
|
||||
if @cursorColumn<0 && @cursorLine>0
|
||||
totalColumns = getColumnsInLine(@cursorLine) # check current line
|
||||
totalLines = getTotalLines()
|
||||
oldCursorLine = @cursorLine
|
||||
oldCursorColumn = @cursorColumn
|
||||
@cursorColumn += columnOffset
|
||||
if @cursorColumn < 0 && @cursorLine > 0
|
||||
# Will happen if cursor is moved left from the beginning of a line
|
||||
@cursorLine-=1
|
||||
@cursorColumn=getColumnsInLine(@cursorLine)
|
||||
elsif @cursorColumn>totalColumns && @cursorLine<totalLines-1
|
||||
@cursorLine -= 1
|
||||
@cursorColumn = getColumnsInLine(@cursorLine)
|
||||
elsif @cursorColumn > totalColumns && @cursorLine < totalLines - 1
|
||||
# Will happen if cursor is moved right from the end of a line
|
||||
@cursorLine+=1
|
||||
@cursorColumn=0
|
||||
@cursorLine += 1
|
||||
@cursorColumn = 0
|
||||
end
|
||||
# Ensure column bounds
|
||||
totalColumns=getColumnsInLine(@cursorLine)
|
||||
@cursorColumn=totalColumns if @cursorColumn>totalColumns
|
||||
@cursorColumn=0 if @cursorColumn<0 # totalColumns can be 0
|
||||
totalColumns = getColumnsInLine(@cursorLine)
|
||||
@cursorColumn = totalColumns if @cursorColumn > totalColumns
|
||||
@cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0
|
||||
# Move line offset
|
||||
@cursorLine+=lineOffset
|
||||
@cursorLine=0 if @cursorLine<0
|
||||
@cursorLine=totalLines-1 if @cursorLine>=totalLines
|
||||
@cursorLine += lineOffset
|
||||
@cursorLine = 0 if @cursorLine < 0
|
||||
@cursorLine = totalLines - 1 if @cursorLine >= totalLines
|
||||
# Ensure column bounds again
|
||||
totalColumns=getColumnsInLine(@cursorLine)
|
||||
@cursorColumn=totalColumns if @cursorColumn>totalColumns
|
||||
@cursorColumn=0 if @cursorColumn<0 # totalColumns can be 0
|
||||
totalColumns = getColumnsInLine(@cursorLine)
|
||||
@cursorColumn = totalColumns if @cursorColumn > totalColumns
|
||||
@cursorColumn = 0 if @cursorColumn < 0 # totalColumns can be 0
|
||||
updateCursorPos(
|
||||
oldCursorLine!=@cursorLine ||
|
||||
oldCursorColumn!=@cursorColumn
|
||||
oldCursorLine != @cursorLine ||
|
||||
oldCursorColumn != @cursorColumn
|
||||
)
|
||||
# echoln ["aftermoving",@cursorLine,@cursorColumn]
|
||||
end
|
||||
|
||||
def update
|
||||
@frame+=1
|
||||
@frame%=20
|
||||
self.refresh if ((@frame%10)==0)
|
||||
@frame += 1
|
||||
@frame %= 20
|
||||
self.refresh if ((@frame % 10) == 0)
|
||||
return if !self.active
|
||||
# Moving cursor
|
||||
if Input.triggerex?(:UP) || Input.repeatex?(:UP)
|
||||
moveCursor(-1,0)
|
||||
moveCursor(-1, 0)
|
||||
return
|
||||
elsif Input.triggerex?(:DOWN) || Input.repeatex?(:DOWN)
|
||||
moveCursor(1,0)
|
||||
moveCursor(1, 0)
|
||||
return
|
||||
elsif Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
|
||||
moveCursor(0,-1)
|
||||
moveCursor(0, -1)
|
||||
return
|
||||
elsif Input.triggerex?(:RIGHT) || Input.repeatex?(:RIGHT)
|
||||
moveCursor(0,1)
|
||||
moveCursor(0, 1)
|
||||
return
|
||||
end
|
||||
if Input.press?(Input::CTRL) && Input.triggerex?(:HOME)
|
||||
# Move cursor to beginning
|
||||
@cursorLine=0
|
||||
@cursorColumn=0
|
||||
@cursorLine = 0
|
||||
@cursorColumn = 0
|
||||
updateCursorPos(true)
|
||||
return
|
||||
elsif Input.press?(Input::CTRL) && Input.triggerex?(:END)
|
||||
# Move cursor to end
|
||||
@cursorLine=getTotalLines()-1
|
||||
@cursorColumn=getColumnsInLine(@cursorLine)
|
||||
@cursorLine = getTotalLines() - 1
|
||||
@cursorColumn = getColumnsInLine(@cursorLine)
|
||||
updateCursorPos(true)
|
||||
return
|
||||
elsif Input.triggerex?(:RETURN) || Input.repeatex?(:RETURN)
|
||||
@@ -502,59 +502,59 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def refresh
|
||||
newContents=pbDoEnsureBitmap(self.contents,self.width-self.borderX,
|
||||
self.height-self.borderY)
|
||||
@textchars=nil if self.contents!=newContents
|
||||
self.contents=newContents
|
||||
bitmap=self.contents
|
||||
newContents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
|
||||
self.height - self.borderY)
|
||||
@textchars = nil if self.contents != newContents
|
||||
self.contents = newContents
|
||||
bitmap = self.contents
|
||||
bitmap.clear
|
||||
getTextChars
|
||||
height=self.height-self.borderY
|
||||
cursorcolor=Color.new(0,0,0)
|
||||
textchars=getTextChars()
|
||||
startY=getLineY(@firstline)
|
||||
height = self.height - self.borderY
|
||||
cursorcolor = Color.new(0, 0, 0)
|
||||
textchars = getTextChars()
|
||||
startY = getLineY(@firstline)
|
||||
for i in 0...textchars.length
|
||||
thisline=textchars[i][5]
|
||||
thiscolumn=textchars[i][7]
|
||||
thislength=textchars[i][8]
|
||||
textY=textchars[i][2]-startY
|
||||
thisline = textchars[i][5]
|
||||
thiscolumn = textchars[i][7]
|
||||
thislength = textchars[i][8]
|
||||
textY = textchars[i][2] - startY
|
||||
# Don't draw lines before the first or zero-length segments
|
||||
next if thisline<@firstline || thislength==0
|
||||
next if thisline < @firstline || thislength == 0
|
||||
# Don't draw lines beyond the window's height
|
||||
break if textY >= height
|
||||
c=textchars[i][0]
|
||||
c = textchars[i][0]
|
||||
# Don't draw spaces
|
||||
next if c==" "
|
||||
textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text
|
||||
textheight=textchars[i][4]
|
||||
next if c == " "
|
||||
textwidth = textchars[i][3] + 4 # add 4 to prevent draw_text from stretching text
|
||||
textheight = textchars[i][4]
|
||||
# Draw text
|
||||
pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor)
|
||||
end
|
||||
# Draw cursor
|
||||
if ((@frame/10)&1) == 0
|
||||
textheight=bitmap.text_size("X").height
|
||||
cursorY=(textheight*@cursorLine)-startY
|
||||
cursorX=0
|
||||
if ((@frame / 10) & 1) == 0
|
||||
textheight = bitmap.text_size("X").height
|
||||
cursorY = (textheight * @cursorLine) - startY
|
||||
cursorX = 0
|
||||
for i in 0...textchars.length
|
||||
thisline=textchars[i][5]
|
||||
thiscolumn=textchars[i][7]
|
||||
thislength=textchars[i][8]
|
||||
if thisline==@cursorLine && @cursorColumn>=thiscolumn &&
|
||||
@cursorColumn<=thiscolumn+thislength
|
||||
cursorY=textchars[i][2]-startY
|
||||
cursorX=textchars[i][1]
|
||||
textheight=textchars[i][4]
|
||||
posToCursor=@cursorColumn-thiscolumn
|
||||
if posToCursor>=0
|
||||
partialString=textchars[i][0].scan(/./m)[0,posToCursor].join("")
|
||||
cursorX+=bitmap.text_size(partialString).width
|
||||
thisline = textchars[i][5]
|
||||
thiscolumn = textchars[i][7]
|
||||
thislength = textchars[i][8]
|
||||
if thisline == @cursorLine && @cursorColumn >= thiscolumn &&
|
||||
@cursorColumn <= thiscolumn + thislength
|
||||
cursorY = textchars[i][2] - startY
|
||||
cursorX = textchars[i][1]
|
||||
textheight = textchars[i][4]
|
||||
posToCursor = @cursorColumn - thiscolumn
|
||||
if posToCursor >= 0
|
||||
partialString = textchars[i][0].scan(/./m)[0, posToCursor].join("")
|
||||
cursorX += bitmap.text_size(partialString).width
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
cursorY+=4
|
||||
cursorHeight=[4,textheight-4,bitmap.text_size("X").height-4].max
|
||||
bitmap.fill_rect(cursorX,cursorY,2,cursorHeight,cursorcolor)
|
||||
cursorY += 4
|
||||
cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max
|
||||
bitmap.fill_rect(cursorX, cursorY, 2, cursorHeight, cursorcolor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user