Lots of rubocop

This commit is contained in:
Maruno17
2023-01-28 15:21:12 +00:00
parent 2d056052ce
commit 13aab8d911
159 changed files with 1679 additions and 1931 deletions

View File

@@ -11,7 +11,7 @@ module RPG
def self.debug
t = Time.now
filename = t.strftime("%H %M %S.%L.txt")
File.open("cache_" + filename, "wb") { |f|
File.open("cache_" + filename, "wb") do |f|
@cache.each do |key, value|
if !value
f.write("#{key} (nil)\r\n")
@@ -21,7 +21,7 @@ module RPG
f.write("#{key} (#{value.refcount}, #{value.width}x#{value.height})\r\n")
end
end
}
end
end
def self.setKey(key, obj)

View File

@@ -208,9 +208,7 @@ 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
end
cmdwindow.height = height if cmdwindow.height != height
cmdwindow.y = msgwindow.y - cmdwindow.height
if cmdwindow.y < 0
cmdwindow.y = msgwindow.y + msgwindow.height
@@ -257,9 +255,7 @@ def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false)
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
end
msgwindow.y = event.screen_y + 24 if msgwindow.y < 0
msgwindow.x = event.screen_x - (msgwindow.width / 2)
msgwindow.x = 0 if msgwindow.x < 0
if msgwindow.x > Graphics.width - msgwindow.width
@@ -623,24 +619,24 @@ def pbFadeOutInWithMusic(zViewport = 99999)
$game_system.bgm_pause(1.0)
$game_system.bgs_pause(1.0)
pos = $game_system.bgm_position
pbFadeOutIn(zViewport) {
pbFadeOutIn(zViewport) do
yield
$game_system.bgm_position = pos
$game_system.bgm_resume(playingBGM)
$game_system.bgs_resume(playingBGS)
}
end
end
def pbFadeOutAndHide(sprites)
visiblesprites = {}
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
pbDeactivateWindows(sprites) do
(0..numFrames).each do |j|
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * alphaDiff))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
end
sprites.each do |i|
next if !i[1]
next if pbDisposed?(i[1])
@@ -660,12 +656,12 @@ def pbFadeInAndShow(sprites, visiblesprites = nil)
end
numFrames = (Graphics.frame_rate * 0.4).floor
alphaDiff = (255.0 / numFrames).ceil
pbDeactivateWindows(sprites) {
pbDeactivateWindows(sprites) do
(0..numFrames).each do |j|
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, ((numFrames - j) * alphaDiff)))
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
end
}
end
end
# Restores which windows are active for the given sprite hash.
@@ -731,9 +727,7 @@ def addBackgroundPlane(sprites, planename, background, viewport = nil)
else
sprites[planename].setBitmap(bitmapName)
sprites.each_value do |spr|
if spr.is_a?(Window)
spr.windowskin = nil
end
spr.windowskin = nil if spr.is_a?(Window)
end
end
end
@@ -753,9 +747,7 @@ def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport
sprites[planename] = AnimatedPlane.new(viewport)
sprites[planename].setBitmap(bitmapName)
sprites.each_value do |spr|
if spr.is_a?(Window)
spr.windowskin = nil
end
spr.windowskin = nil if spr.is_a?(Window)
end
end
end
@@ -767,6 +759,7 @@ module Graphics
if !self.respond_to?("width")
def self.width; return 640; end
end
if !self.respond_to?("height")
def self.height; return 480; end
end
@@ -778,9 +771,7 @@ end
if !defined?(_INTL)
def _INTL(*args)
string = args[0].clone
(1...args.length).each do |i|
string.gsub!(/\{#{i}\}/, args[i].to_s)
end
(1...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i].to_s) }
return string
end
end
@@ -789,9 +780,7 @@ if !defined?(_ISPRINTF)
def _ISPRINTF(*args)
string = args[0].clone
(1...args.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m|
next sprintf("%" + $1, args[i])
}
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, args[i]) }
end
return string
end
@@ -800,9 +789,7 @@ end
if !defined?(_MAPINTL)
def _MAPINTL(*args)
string = args[1].clone
(2...args.length).each do |i|
string.gsub!(/\{#{i}\}/, args[i + 1].to_s)
end
(2...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i + 1].to_s) }
return string
end
end

View File

@@ -42,6 +42,8 @@ class WindowCursorRect < Rect
@window.width = @window.width
end
#-----------------------------------------------------------------------------
private
def needs_update?(x, y, width, height)
@@ -323,6 +325,8 @@ class Window
end
end
#-----------------------------------------------------------------------------
private
def ensureBitmap(bitmap, dwidth, dheight)

View File

@@ -34,15 +34,14 @@ class SpriteWindow < Window
@_windowskin
end
# Flags used to preserve compatibility
# with RGSS/RGSS2's version of Window
# Flags used to preserve compatibility with RGSS/RGSS2's version of Window
module CompatBits
CorrectZ = 1
ExpandBack = 2
ShowScrollArrows = 4
StretchSides = 8
ShowPause = 16
ShowCursor = 32
CORRECT_Z = 1
EXPAND_BACK = 2
SHOW_SCROLL_ARROWS = 4
STRETCH_SIDES = 8
SHOW_PAUSE = 16
SHOW_CURSOR = 32
end
attr_reader :compat
@@ -78,7 +77,7 @@ class SpriteWindow < Window
@contents = @blankcontents
@_windowskin = nil
@rpgvx = false
@compat = CompatBits::ExpandBack | CompatBits::StretchSides
@compat = CompatBits::EXPAND_BACK | CompatBits::STRETCH_SIDES
@x = 0
@y = 0
@width = 0
@@ -435,7 +434,7 @@ class SpriteWindow < Window
privRefresh
end
#===============================================================================
#-----------------------------------------------------------------------------
private
@@ -515,9 +514,9 @@ class SpriteWindow < Window
@sprites["back"].visible = @visible
@sprites["contents"].visible = @visible && @openness == 255
@sprites["pause"].visible = supported && @visible && @pause &&
(@combat & CompatBits::ShowPause)
(@combat & CompatBits::SHOW_PAUSE)
@sprites["cursor"].visible = supported && @visible && @openness == 255 &&
(@combat & CompatBits::ShowCursor)
(@combat & CompatBits::SHOW_CURSOR)
@sprites["scroll0"].visible = false
@sprites["scroll1"].visible = false
@sprites["scroll2"].visible = false
@@ -540,7 +539,7 @@ class SpriteWindow < Window
@spritekeys.each do |i|
@sprites[i].z = @z
end
if (@compat & CompatBits::CorrectZ) > 0 && @skinformat == 0 && !@rpgvx
if (@compat & CompatBits::CORRECT_Z) > 0 && @skinformat == 0 && !@rpgvx
# Compatibility Mode: Cursor, pause, and contents have higher Z
@sprites["cursor"].z = @z + 1
@sprites["contents"].z = @z + 2
@@ -630,7 +629,7 @@ class SpriteWindow < Window
end
@sprites["contents"].x = @x + trimStartX
@sprites["contents"].y = @y + trimStartY
if (@compat & CompatBits::ShowScrollArrows) > 0 && @skinformat == 0 &&
if (@compat & CompatBits::SHOW_SCROLL_ARROWS) > 0 && @skinformat == 0 &&
@_windowskin && !@_windowskin.disposed? &&
@contents && !@contents.disposed?
@sprites["scroll0"].visible = @visible && hascontents && @oy > 0
@@ -667,7 +666,7 @@ class SpriteWindow < Window
@sprites["scroll3"].y = @y + @height - 16
@sprites["cursor"].x = @x + startX + @cursor_rect.x
@sprites["cursor"].y = @y + startY + @cursor_rect.y
if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0
if (@compat & CompatBits::EXPAND_BACK) > 0 && @skinformat == 0
# Compatibility mode: Expand background
@sprites["back"].x = @x + 2
@sprites["back"].y = @y + 2
@@ -742,7 +741,7 @@ class SpriteWindow < Window
@sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight)
@sidebitmaps[i].clear
if sideRects[i].width > 0 && sideRects[i].height > 0
if (@compat & CompatBits::StretchSides) > 0 && @skinformat == 0
if (@compat & CompatBits::STRETCH_SIDES) > 0 && @skinformat == 0
# Compatibility mode: Stretch sides
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
@_windowskin, sideRects[i])
@@ -752,7 +751,7 @@ class SpriteWindow < Window
end
end
end
if (@compat & CompatBits::ExpandBack) > 0 && @skinformat == 0
if (@compat & CompatBits::EXPAND_BACK) > 0 && @skinformat == 0
# Compatibility mode: Expand background
backwidth = @width - 4
backheight = @height - 4
@@ -816,7 +815,7 @@ end
#
#===============================================================================
class SpriteWindow_Base < SpriteWindow
TEXTPADDING = 4 # In pixels
TEXT_PADDING = 4 # In pixels
def initialize(x, y, width, height)
super()

View File

@@ -51,7 +51,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
dims = [0, 0]
cwidth = maxwidth < 0 ? Graphics.width : maxwidth
getLineBrokenChunks(self.contents, text,
cwidth - self.borderX - SpriteWindow_Base::TEXTPADDING, dims, true)
cwidth - self.borderX - SpriteWindow_Base::TEXT_PADDING, dims, true)
return dims
end
@@ -62,7 +62,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width
dims = resizeToFitInternal(text, maxwidth)
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING
self.height = dims[1] + self.borderY
refresh
end
@@ -211,7 +211,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
dims = resizeToFitInternal(text, maxwidth)
oldstarting = @starting
@starting = true
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING
self.height = dims[1] + self.borderY
@starting = oldstarting
redrawText
@@ -221,7 +221,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
dims = resizeToFitInternal(text, maxwidth)
oldstarting = @starting
@starting = true
self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXTPADDING, maxwidth].min
self.width = [dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING, maxwidth].min
self.height = [dims[1] + self.borderY, maxheight].min
@starting = oldstarting
redrawText
@@ -306,7 +306,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
if @letterbyletter
@fmtchars = []
fmt = getFormattedText(self.contents, 0, 0,
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
self.width - self.borderX - SpriteWindow_Base::TEXT_PADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone
fmt.each do |ch|
@@ -333,7 +333,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
fmt.clear
else
@fmtchars = getFormattedText(self.contents, 0, 0,
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
self.width - self.borderX - SpriteWindow_Base::TEXT_PADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone
@fmtchars.each do |ch|
@@ -586,6 +586,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
@frameskipChanged = false
end
#-----------------------------------------------------------------------------
private
def curcharSkip(skip)
@@ -704,6 +706,8 @@ class Window_InputNumberPokemon < SpriteWindow_Base
@frame = (@frame + 1) % 30
end
#-----------------------------------------------------------------------------
private
def textHelper(x, y, text, i)
@@ -895,6 +899,8 @@ class SpriteWindow_Selectable < SpriteWindow_Base
end
end
#-----------------------------------------------------------------------------
private
def priv_page_row_max
@@ -1074,7 +1080,7 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
width = [width, tmpbitmap.text_size(i).width].max
end
# one 16 to allow cursor
width += 16 + 16 + SpriteWindow_Base::TEXTPADDING
width += 16 + 16 + SpriteWindow_Base::TEXT_PADDING
tmpbitmap.dispose
end
# Store suggested width and height of window
@@ -1229,7 +1235,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
def textWidth(bitmap, text)
dims = [nil, 0]
chars = getFormattedText(bitmap, 0, 0,
Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16,
Graphics.width - self.borderX - SpriteWindow_Base::TEXT_PADDING - 16,
-1, text, self.rowHeight, true, true)
chars.each do |ch|
dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1]

View File

@@ -218,9 +218,9 @@ end
#
#===============================================================================
def pbGetTileBitmap(filename, tile_id, hue, width = 1, height = 1)
return RPG::Cache.tileEx(filename, tile_id, hue, width, height) { |f|
return RPG::Cache.tileEx(filename, tile_id, hue, width, height) do |f|
AnimatedBitmap.new("Graphics/Tilesets/" + filename).deanimate
}
end
end
def pbGetTileset(name, hue = 0)

View File

@@ -64,6 +64,8 @@ class AnimatedPlane < Plane
end
end
#-----------------------------------------------------------------------------
private
def clear_bitmap

View File

@@ -97,9 +97,7 @@ end
def getFormattedTextForDims(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight,
newlineBreaks = true, explicitBreaksOnly = false)
text2 = text.gsub(/<(\/?)(c|c2|c3|o|u|s)(\s*\=\s*([^>]*))?>/i, "")
if newlineBreaks
text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n")
end
text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n") if newlineBreaks
return getFormattedText(bitmap, xDst, yDst, widthDst, heightDst,
text2, lineheight, newlineBreaks,
explicitBreaksOnly, true)
@@ -249,70 +247,79 @@ end
#===============================================================================
# Formats a string of text and returns an array containing a list of formatted
# characters.
#
# Parameters:
# bitmap: Source bitmap. Will be used to determine the default font of
# the text.
# xDst: X coordinate of the text's top left corner.
# yDst: Y coordinate of the text's top left corner.
# widthDst: Width of the text. Used to determine line breaks.
# heightDst: Height of the text. If -1, there is no height restriction.
# If 1 or greater, any characters exceeding the height are
# removed from the returned list.
# newLineBreaks: If true, newline characters will be treated as line breaks.
# The default is true.
#
# Return Values:
# A list of formatted characters. Returns an empty array if _bitmap_ is nil
# or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0.
#
# Formatting Specification:
# This function uses the following syntax when formatting the text.
#
# <b> ... </b> - Formats the text in bold.
# <i> ... </i> - Formats the text in italics.
# <u> ... </u> - Underlines the text.
# <s> ... </s> - Draws a strikeout line over the text.
# <al> ... </al> - Left-aligns the text. Causes line breaks before and
# after the text.
# <r> - Right-aligns the text until the next line break.
# <ar> ... </ar> - Right-aligns the text. Causes line breaks before and
# after the text.
# <ac> ... </ac> - Centers the text. Causes line breaks before and after
# the text.
# <br> - Causes a line break.
# <c=X> ... </c> - Color specification. A total of four formats are
# supported: RRGGBBAA, RRGGBB, 16-bit RGB, and
# Window_Base color numbers.
# <c2=X> ... </c2> - Color specification where the first half is the base
# color and the second half is the shadow color. 16-bit
# RGB is supported.
#
# Added 2009-10-20
#
# <c3=B,S> ... </c3> - Color specification where B is the base color and S is
# the shadow color. B and/or S can be omitted. A total of
# four formats are supported: RRGGBBAA, RRGGBB, 16-bit
# RGB, and Window_Base color numbers.
#
# Added 2009-9-12
#
# <o=X> - Displays the text in the given opacity (0-255)
#
# Added 2009-10-19
#
# <outln> - Displays the text in outline format.
#
# Added 2010-05-12
#
# <outln2> - Displays the text in outline format (outlines more
# exaggerated.
# <fn=X> ... </fn> - Formats the text in the specified font, or Arial if the
# font doesn't exist.
# <fs=X> ... </fs> - Changes the font size to X.
# <icon=X> - Displays the icon X (in Graphics/Icons/).
#
# In addition, the syntax supports the following:
# &apos; - Converted to "'".
# &lt; - Converted to "<".
# &gt; - Converted to ">".
# &amp; - Converted to "&".
# &quot; - Converted to double quotation mark.
#
# To draw the characters, pass the returned array to the
# _drawFormattedChars_ function.
#===============================================================================
=begin
Parameters:
bitmap: Source bitmap. Will be used to determine the default font of
the text.
xDst: X coordinate of the text's top left corner.
yDst: Y coordinate of the text's top left corner.
widthDst: Width of the text. Used to determine line breaks.
heightDst: Height of the text. If -1, there is no height restriction. If
1 or greater, any characters exceeding the height are removed
from the returned list.
newLineBreaks: If true, newline characters will be treated as line breaks. The
default is true.
Return Values:
A list of formatted characters. Returns an empty array if _bitmap_ is nil
or disposed, or if _widthDst_ is 0 or less or _heightDst_ is 0.
Formatting Specification:
This function uses the following syntax when formatting the text.
<b> ... </b> - Formats the text in bold.
<i> ... </i> - Formats the text in italics.
<u> ... </u> - Underlines the text.
<s> ... </s> - Draws a strikeout line over the text.
<al> ... </al> - Left-aligns the text. Causes line breaks before and after
the text.
<r> - Right-aligns the text until the next line break.
<ar> ... </ar> - Right-aligns the text. Causes line breaks before and after
the text.
<ac> ... </ac> - Centers the text. Causes line breaks before and after the
text.
<br> - Causes a line break.
<c=X> ... </c> - Color specification. A total of four formats are supported:
RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers.
<c2=X> ... </c2> - Color specification where the first half is the base color
and the second half is the shadow color. 16-bit RGB is
supported.
Added 2009-10-20
<c3=B,S> ... </c3> - Color specification where B is the base color and S is the
shadow color. B and/or S can be omitted. A total of four
formats are supported:
RRGGBBAA, RRGGBB, 16-bit RGB, and Window_Base color numbers.
Added 2009-9-12
<o=X> - Displays the text in the given opacity (0-255)
Added 2009-10-19
<outln> - Displays the text in outline format.
Added 2010-05-12
<outln2> - Displays the text in outline format (outlines more
exaggerated.
<fn=X> ... </fn> - Formats the text in the specified font, or Arial if the
font doesn't exist.
<fs=X> ... </fs> - Changes the font size to X.
<icon=X> - Displays the icon X (in Graphics/Icons/).
In addition, the syntax supports the following:
&apos; - Converted to "'".
&lt; - Converted to "<".
&gt; - Converted to ">".
&amp; - Converted to "&".
&quot; - Converted to double quotation mark.
To draw the characters, pass the returned array to the
_drawFormattedChars_ function.
=end
def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight = 32,
newlineBreaks = true, explicitBreaksOnly = false,
collapseAlignments = false)
@@ -515,9 +522,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
break
end
when "br" # Line break
if !endtag
nextline += 1
end
nextline += 1 if !endtag
when "r" # Right align this line
if !endtag
x = 0
@@ -639,49 +644,47 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end
# This code looks at whether the text occupies exactly two lines when
# displayed. If it does, it balances the length of each line.
=begin
# Count total number of lines
numlines = (x==0 && y>0) ? y : y+1
if numlines==2 && realtext && !realtext[/\n/] && realtext.length>=50
# Set half to middle of text (known to contain no formatting)
half = realtext.length/2
leftSearch = 0
rightSearch = 0
# Search left for a space
i = half
while i>=0
break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space
leftSearch += 1
i -= 1
end
# Search right for a space
i = half
while i<realtext.length
break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space
rightSearch += 1
i += 1
end
# Move half left or right whichever is closer
trialHalf = half+((rightSearch<leftSearch) ? rightSearch : -leftSearch)
if trialHalf!=0 && trialHalf!=realtext.length
# Insert newline and re-call this function (force newlineBreaksOnly)
newText = realtext.clone
if isWaitChar(newText[trialHalf,1])
# insert after wait character
newText.insert(trialHalf+1,"\n")
else
# remove spaces after newline
newText.insert(trialHalf,"\n")
newText.gsub!(/\n\s+/,"\n")
end
bitmap.font = oldfont
dummybitmap.dispose if dummybitmap
return getFormattedText(dummybitmap ? nil : bitmap,xDst,yDst,
widthDst,heightDst,realtextStart+newText,
lineheight,true,explicitBreaksOnly)
end
end
=end
# # Count total number of lines
# numlines = (x==0 && y>0) ? y : y+1
# if numlines==2 && realtext && !realtext[/\n/] && realtext.length>=50
# # Set half to middle of text (known to contain no formatting)
# half = realtext.length/2
# leftSearch = 0
# rightSearch = 0
# # Search left for a space
# i = half
# while i>=0
# break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space
# leftSearch += 1
# i -= 1
# end
# # Search right for a space
# i = half
# while i<realtext.length
# break if realtext[i,1][/\s/]||isWaitChar(realtext[i,1]) # found a space
# rightSearch += 1
# i += 1
# end
# # Move half left or right whichever is closer
# trialHalf = half+((rightSearch<leftSearch) ? rightSearch : -leftSearch)
# if trialHalf!=0 && trialHalf!=realtext.length
# # Insert newline and re-call this function (force newlineBreaksOnly)
# newText = realtext.clone
# if isWaitChar(newText[trialHalf,1])
# # insert after wait character
# newText.insert(trialHalf+1,"\n")
# else
# # remove spaces after newline
# newText.insert(trialHalf,"\n")
# newText.gsub!(/\n\s+/,"\n")
# end
# bitmap.font = oldfont
# dummybitmap.dispose if dummybitmap
# return getFormattedText(dummybitmap ? nil : bitmap,xDst,yDst,
# widthDst,heightDst,realtextStart+newText,
# lineheight,true,explicitBreaksOnly)
# end
# end
if havenl
# Eliminate spaces before newlines and pause character
firstspace = -1
@@ -696,9 +699,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end
firstspace = -1
elsif characters[i][0][/[ \r\t]/]
if firstspace < 0
firstspace = i
end
firstspace = i if firstspace < 0
else
firstspace = -1
end
@@ -739,9 +740,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
totalLineWidths = []
widthblocks.each do |block|
y = block[4]
if !totalLineWidths[y]
totalLineWidths[y] = 0
end
totalLineWidths[y] = 0 if !totalLineWidths[y]
if totalLineWidths[y] != 0
# padding in case more than one line has different alignments
totalLineWidths[y] += 16
@@ -874,9 +873,7 @@ def getLineBrokenChunks(bitmap, value, width, dims, plain = false)
x += textwidth
dims[0] = x if dims && dims[0] < x
end
if textcols[i]
color = textcols[i]
end
color = textcols[i] if textcols[i]
end
end
dims[1] = y + 32 if dims

View File

@@ -145,6 +145,8 @@ class ChooseNumberParams
end
end
#-----------------------------------------------------------------------------
private
def clamp(v, mn, mx)
@@ -422,16 +424,13 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgback = nil
linecount = (Graphics.height > 400) ? 3 : 2
### Text replacement
text.gsub!(/\\sign\[([^\]]*)\]/i) { # \sign[something] gets turned into
text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into
next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something]
}
end
text.gsub!(/\\\\/, "\5")
text.gsub!(/\\1/, "\1")
if $game_actors
text.gsub!(/\\n\[([1-8])\]/i) {
m = $1.to_i
next $game_actors[m].name
}
text.gsub!(/\\n\[([1-8])\]/i) { next $game_actors[$1.to_i].name }
end
text.gsub!(/\\pn/i, $player.name) if $player
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
@@ -445,7 +444,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
text.gsub!(/\\pog/i, "")
text.gsub!(/\\b/i, "<c3=3050C8,D0D0C8>")
text.gsub!(/\\r/i, "<c3=E00808,D0D0C8>")
text.gsub!(/\\[Ww]\[([^\]]*)\]/) {
text.gsub!(/\\[Ww]\[([^\]]*)\]/) do
w = $1.to_s
if w == ""
msgwindow.windowskin = nil
@@ -453,12 +452,11 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
msgwindow.setSkin("Graphics/Windowskins/#{w}", false)
end
next ""
}
end
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
text.gsub!(/\\c\[([0-9]+)\]/i) {
m = $1.to_i
next getSkinColor(msgwindow.windowskin, m, isDarkSkin)
}
text.gsub!(/\\c\[([0-9]+)\]/i) do
next getSkinColor(msgwindow.windowskin, $1.to_i, isDarkSkin)
end
loop do
last_text = text.clone
text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
@@ -466,10 +464,10 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
end
loop do
last_text = text.clone
text.gsub!(/\\l\[([0-9]+)\]/i) {
text.gsub!(/\\l\[([0-9]+)\]/i) do
linecount = [1, $1.to_i].max
next ""
}
end
break if text == last_text
end
colortag = ""
@@ -664,9 +662,7 @@ def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = ni
$game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel)
$game_map.need_refresh = true if $game_map
end
if commandProc
ret = commandProc.call(msgwindow)
end
ret = commandProc.call(msgwindow) if commandProc
msgback&.dispose
goldwindow&.dispose
coinwindow&.dispose
@@ -698,8 +694,8 @@ def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd =
msgwindow = pbCreateMessageWindow(nil, skin)
if commands
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block)
proc { |msgwndw|
next Kernel.pbShowCommands(msgwndw, commands, cmdIfCancel, defaultCmd, &block)
}, &block)
else
pbMessageDisplay(msgwindow, message, &block)
@@ -720,8 +716,8 @@ end
def pbMessageChooseNumber(message, params, &block)
msgwindow = pbCreateMessageWindow(nil, params.messageSkin)
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next pbChooseNumber(msgwindow, params, &block)
proc { |msgwndw|
next pbChooseNumber(msgwndw, params, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return ret
@@ -783,9 +779,7 @@ def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCm
Input.update
oldindex = cmdwindow.index
cmdwindow.update
if oldindex != cmdwindow.index
msgwin.text = help[cmdwindow.index]
end
msgwin.text = help[cmdwindow.index] if oldindex != cmdwindow.index
msgwin.update
yield if block_given?
if Input.trigger?(Input::BACK)
@@ -822,9 +816,7 @@ def pbMessageWaitForInput(msgwindow, frames, showPause = false)
Input.update
msgwindow&.update
pbUpdateSceneMap
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
break
end
break if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
yield if block_given?
end
msgwindow.stopPause if msgwindow && showPause
@@ -863,8 +855,8 @@ end
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)
proc { |msgwndw|
next pbFreeText(msgwndw, currenttext, passwordbox, maxlength, width, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return retval

View File

@@ -41,9 +41,7 @@ class CharacterEntryHelper
return false if @maxlength >= 0 && chars.length >= @maxlength
chars.insert(@cursor, ch)
@text = ""
chars.each do |ch|
@text += ch if ch
end
chars.each { |char| @text += char if char }
@cursor += 1
return true
end
@@ -66,14 +64,14 @@ class CharacterEntryHelper
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]
end
chars = chars[0, @maxlength] if chars.length > @maxlength && @maxlength >= 0
@text = ""
chars.each do |ch|
@text += ch if ch