More Rubocopping

This commit is contained in:
Maruno17
2021-12-20 17:18:21 +00:00
parent db4acd3369
commit 33fcbf623b
154 changed files with 1388 additions and 1420 deletions

View File

@@ -5,7 +5,7 @@ class Window_Menu < Window_CommandPokemon
def initialize(commands, x, y)
tempbitmap = Bitmap.new(32, 32)
w = 0
for i in commands
commands.each do |i|
width = tempbitmap.text_size(i).width
w = width if w < width
end
@@ -28,7 +28,7 @@ class Window_Menu < Window_CommandPokemon
mousepos = Mouse.getMousePos
return -1 if !mousepos
toprow = self.top_row
for i in toprow...toprow + @item_max
(toprow...toprow + @item_max).each do |i|
rc = Rect.new(0, 32 * (i - toprow), self.contents.width, 32)
rc.x += self.x + self.leftEdge
rc.y += self.y + self.topEdge
@@ -229,7 +229,7 @@ class AnimationWindow < SpriteWrapper
rect = Rect.new(0, 0, 0, 0)
rectdst = Rect.new(0, 0, 0, 0)
x = arrowwidth
for i in 0...NUMFRAMES
NUMFRAMES.times do |i|
j = i + @start
rect.set((j % 5) * 192, (j / 5) * 192, 192, 192)
rectdst.set(x, 0, 96, 96)
@@ -237,7 +237,7 @@ class AnimationWindow < SpriteWrapper
x += 96
end
end
for i in 0...NUMFRAMES
NUMFRAMES.times do |i|
drawrect(@contents, arrowwidth + (i * 96), 0, 96, 96, Color.new(100, 100, 100))
if @start + i == @selected && havebitmap
drawborder(@contents, arrowwidth + (i * 96), 0, 96, 96, Color.new(255, 0, 0))
@@ -265,10 +265,10 @@ class AnimationWindow < SpriteWrapper
right.y += self.y
swatchrects = []
repeattime = Input.time?(Input::MOUSELEFT) / 1000
for i in 0...NUMFRAMES
NUMFRAMES.times do |i|
swatchrects.push(Rect.new(arrowwidth + (i * 96) + self.x, self.y, 96, 96))
end
for i in 0...NUMFRAMES
NUMFRAMES.times do |i|
if swatchrects[i].contains(mousepos[0], mousepos[1])
@selected = @start + i
@changed = true
@@ -458,12 +458,12 @@ class AnimationCanvas < Sprite
@target = AnimatedBitmap.new("Graphics/Pictures/testfront").deanimate
@testscreen = AnimatedBitmap.new("Graphics/Pictures/testscreen")
self.bitmap = @testscreen.bitmap
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
@lastframesprites[i] = SpriteFrame.new(i, @celsprites[i], viewport, true)
@lastframesprites[i].selected = false
@lastframesprites[i].visible = false
end
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
@celsprites[i] = Sprite.new(viewport)
@celsprites[i].visible = false
@celsprites[i].src_rect = Rect.new(0, 0, 0, 0)
@@ -499,7 +499,7 @@ class AnimationCanvas < Sprite
def animbitmap=(value)
@animbitmap.dispose if @animbitmap
@animbitmap = value
for i in 2...PBAnimation::MAX_SPRITES
(2...PBAnimation::MAX_SPRITES).each do |i|
@celsprites[i].bitmap = @animbitmap if @celsprites[i]
end
self.invalidate
@@ -512,7 +512,7 @@ class AnimationCanvas < Sprite
@selectedbitmap.dispose if @selectedbitmap
@celbitmap.dispose if @celbitmap
self.bitmap.dispose if self.bitmap
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
@celsprites[i].dispose if @celsprites[i]
end
super
@@ -557,7 +557,7 @@ class AnimationCanvas < Sprite
@sprites["pokemon_1"].x += BORDERSIZE
@sprites["pokemon_1"].y += BORDERSIZE
oldstate = []
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
oldstate.push([@celsprites[i].visible, @framesprites[i].visible, @lastframesprites[i].visible])
@celsprites[i].visible = false
@framesprites[i].visible = false
@@ -568,7 +568,7 @@ class AnimationCanvas < Sprite
self.update
break if !@playing
end
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
@celsprites[i].visible = oldstate[i][0]
@framesprites[i].visible = oldstate[i][1]
@lastframesprites[i].visible = oldstate[i][2]
@@ -581,7 +581,7 @@ class AnimationCanvas < Sprite
end
def invalidate
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
invalidateCel(i)
end
end
@@ -635,7 +635,7 @@ class AnimationCanvas < Sprite
def offsetFrame(frame, ox, oy)
if frame >= 0 && frame < @animation.length
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
if !self.locked?(i) && @animation[frame][i]
@animation[frame][i][AnimFrame::X] += ox
@animation[frame][i][AnimFrame::Y] += oy
@@ -648,7 +648,7 @@ class AnimationCanvas < Sprite
# Clears all items in the frame except locked items
def clearFrame(frame)
if frame >= 0 && frame < @animation.length
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
if self.deletable?(i)
@animation[frame][i] = nil
else
@@ -667,7 +667,7 @@ class AnimationCanvas < Sprite
def copyFrame(src, dst)
return if dst >= @animation.length
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
clonedframe = @animation[src][i]
clonedframe = clonedframe.clone if clonedframe && clonedframe != true
@animation[dst][i] = clonedframe
@@ -704,7 +704,7 @@ class AnimationCanvas < Sprite
def pasteCel(x, y)
return if @currentframe >= @animation.length
return if Clipboard.typekey != "PBAnimCel"
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
next if @animation[@currentframe][i]
@animation[@currentframe][i] = Clipboard.data
cel = @animation[@currentframe][i]
@@ -754,7 +754,7 @@ class AnimationCanvas < Sprite
if cel[AnimFrame::PATTERN] < 0
count = 0
pattern = cel[AnimFrame::PATTERN]
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
othercel = @animation[self.currentframe][i]
count += 1 if othercel && othercel[AnimFrame::PATTERN] == pattern
end
@@ -786,7 +786,7 @@ class AnimationCanvas < Sprite
def addSprite(x, y)
return false if @currentframe >= @animation.length
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
next if @animation[@currentframe][i]
@animation[@currentframe][i] = pbCreateCel(x, y, @pattern, @animation.position)
@dirty[i] = true
@@ -803,7 +803,7 @@ class AnimationCanvas < Sprite
if Input.trigger?(Input::MOUSELEFT) # Left mouse button
selectedcel = -1
usealpha = (Input.press?(Input::ALT)) ? true : false
for j in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |j|
if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false)
selectedcel = j
end
@@ -924,7 +924,7 @@ class AnimationCanvas < Sprite
# @testscreen.update
# self.bitmap=@testscreen.bitmap
if @currentframe < @animation.length
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
if @dirty[i]
if @celsprites[i]
setBitmap(i, @currentframe)
@@ -938,7 +938,7 @@ class AnimationCanvas < Sprite
end
end
else
for i in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |i|
pbSpriteSetAnimFrame(@celsprites[i], nil, @celsprites[0], @celsprites[1], true)
@celsprites[i].x += BORDERSIZE
@celsprites[i].y += BORDERSIZE

View File

@@ -233,7 +233,7 @@ class TextField < UIControl
chars = self.text.scan(/./m)
chars.insert(@cursor, ch)
@text = ""
for ch in chars
chars.each do |ch|
@text += ch
end
@cursor += 1
@@ -246,7 +246,7 @@ class TextField < UIControl
chars = self.text.scan(/./m)
chars.delete_at(@cursor - 1)
@text = ""
for ch in chars
chars.each do |ch|
@text += ch
end
@cursor -= 1
@@ -320,7 +320,7 @@ class TextField < UIControl
break if fromcursor > width - 4
startpos -= 1
end
for i in startpos...scanlength
(startpos...scanlength).each do |i|
c = textscan[i]
textwidth = bitmap.text_size(c).width
next if c == "\n"
@@ -669,7 +669,7 @@ class TextSlider < UIControl
def refresh
bitmap = self.bitmap
if @maxoptionwidth == nil
for i in 0...@options.length
@options.length.times do |i|
w = self.bitmap.text_size(" " + @options[i] + " ").width
@maxoptionwidth = w if !@maxoptionwidth || @maxoptionwidth < w
end
@@ -808,21 +808,15 @@ class ControlWindow < SpriteWindow_Base
end
def refresh
for i in 0...@controls.length
@controls[i].refresh
end
@controls.each { |ctrl| ctrl.refresh }
end
def repaint
for i in 0...@controls.length
@controls[i].repaint
end
@controls.each { |ctrl| ctrl.repaint }
end
def invalidate
for i in 0...@controls.length
@controls[i].invalidate
end
@controls.each { |ctrl| ctrl.invalidate }
end
def hittest?(i)
@@ -882,9 +876,7 @@ class ControlWindow < SpriteWindow_Base
def update
super
for i in 0...@controls.length
@controls[i].update
end
@controls.each { |ctrl| ctrl.update }
repaint
end

View File

@@ -98,7 +98,7 @@ class PointPath
def inspect
p = []
for point in @points
@points.each do |point|
p.push([point[0].to_i, point[1].to_i])
end
return p.inspect
@@ -164,7 +164,7 @@ class PointPath
curdist = 0
distForT = @totaldist * t
i = 0
for dist in @distances
@distances.each do |dist|
curdist += dist
if dist > 0.0
if curdist >= distForT
@@ -249,7 +249,7 @@ def pbDefinePath(canvas)
if path
path = path.smoothPointPath(sliderwin2.value(0), false)
i = 0
for point in path
path.each do |point|
if i < points.length
points[i].x = point[0]
points[i].y = point[1]
@@ -258,14 +258,14 @@ def pbDefinePath(canvas)
end
i += 1
end
for j in i...points.length
(i...points.length).each do |j|
points[j].dispose
points[j] = nil
end
points.compact!
end
elsif sliderwin2.changed?(defcurvebutton)
for point in points
points.each do |point|
point.dispose
end
points.clear
@@ -293,19 +293,19 @@ def pbDefinePath(canvas)
break
end
if Input.trigger?(Input::MOUSELEFT)
for j in 0...4
4.times do |j|
next if !curve[j].hittest?
if [1, 2].include?(j)
next if !curve[0].visible || !curve[3].visible
end
curve[j].visible = true
for k in 0...4
4.times do |k|
curve[k].dragging = (k == j)
end
break
end
end
for j in 0...4
4.times do |j|
curve[j].mouseover
end
mousepos = Mouse.getMousePos(true)
@@ -315,7 +315,7 @@ def pbDefinePath(canvas)
end
if curve[0].visible && curve[3].visible &&
!curve[0].dragging && !curve[3].dragging
for point in points
points.each do |point|
point.visible = true
end
if !showline
@@ -331,7 +331,7 @@ def pbDefinePath(canvas)
if showline
step = 1.0 / (points.length - 1)
t = 0.0
for i in 0...points.length
points.length.times do |i|
point = getCurvePoint(curve, t)
points[i].x = point[0]
points[i].y = point[1]
@@ -341,18 +341,18 @@ def pbDefinePath(canvas)
end
window.dispose
# dispose temporary path
for point in points
points.each do |point|
point.dispose
end
points.clear
if showline
path = curveToPointPath(curve, sliderwin2.value(0))
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
for point in path
path.each do |point|
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
end
end
for point in curve
curve.each do |point|
point.dispose
end
sliderwin2.visible = true
@@ -360,7 +360,7 @@ def pbDefinePath(canvas)
elsif sliderwin2.changed?(defpathbutton)
canceled = false
pointpath = PointPath.new
for point in points
points.each do |point|
point.dispose
end
points.clear
@@ -396,14 +396,14 @@ def pbDefinePath(canvas)
end
window.dispose
# dispose temporary path
for point in points
points.each do |point|
point.dispose
end
points.clear
# generate smooth path from temporary path
path = pointpath.smoothPointPath(sliderwin2.value(0), true)
# redraw path from smooth path
for point in path
path.each do |point|
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
end
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
@@ -417,7 +417,7 @@ def pbDefinePath(canvas)
end
thiscel = canvas.currentCel
celnumber = canvas.currentcel
for i in canvas.currentframe...neededsize
(canvas.currentframe...neededsize).each do |i|
cel = canvas.animation[i][celnumber]
if !canvas.animation[i][celnumber]
cel = pbCreateCel(0, 0, thiscel[AnimFrame::PATTERN], canvas.animation.position)
@@ -432,7 +432,7 @@ def pbDefinePath(canvas)
end
end
# dispose all points
for point in points
points.each do |point|
point.dispose
end
points.clear

View File

@@ -87,9 +87,9 @@ end
################################################################################
def pbConvertAnimToNewFormat(textdata)
needconverting = false
for i in 0...textdata.length
textdata.length.times do |i|
next if !textdata[i]
for j in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |j|
next if !textdata[i][j]
needconverting = true if textdata[i][j][AnimFrame::FOCUS] == nil
break if needconverting
@@ -97,9 +97,9 @@ def pbConvertAnimToNewFormat(textdata)
break if needconverting
end
if needconverting
for i in 0...textdata.length
textdata.length.times do |i|
next if !textdata[i]
for j in 0...PBAnimation::MAX_SPRITES
PBAnimation::MAX_SPRITES.times do |j|
next if !textdata[i][j]
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil
case j
@@ -132,7 +132,7 @@ def pbConvertAnimsToNewFormat
pbMessage(_INTL("No animations exist."))
return
end
for k in 0...animations.length
animations.length.times do |k|
next if !animations[k]
ret = pbConvertAnimToNewFormat(animations[k])
count += 1 if ret

View File

@@ -15,9 +15,7 @@ class MiniBattle
def initialize
@battlers = []
for i in 0...4
@battlers[i] = MiniBattler.new(i)
end
4.times { |i| @battlers[i] = MiniBattler.new(i) }
end
end
@@ -118,7 +116,7 @@ end
def pbAnimList(animations, canvas, animwin)
commands = []
for i in 0...animations.length
animations.length.times do |i|
animations[i] = PBAnimation.new if !animations[i]
commands[commands.length] = _INTL("{1} {2}", i, animations[i].name)
end
@@ -146,7 +144,7 @@ def pbAnimList(animations, canvas, animwin)
newsize = maxsizewindow.value(0)
animations.resize(newsize)
commands.clear
for i in 0...animations.length
animations.length.times do |i|
commands[commands.length] = _INTL("{1} {2}", i, animations[i].name)
end
cmdwin.commands = commands
@@ -382,7 +380,7 @@ def pbTimingList(canvas)
cmdEditBG = -1
cmdNewFO = -1
cmdEditFO = -1
for i in canvas.animation.timing
canvas.animation.timing.each do |i|
commands.push(sprintf("%s", i))
end
commands[cmdNewSound = commands.length] = _INTL("Add: Play Sound...")
@@ -752,7 +750,7 @@ def pbClearFrames(canvas)
if sliderwin2.changed?(okbutton)
startframe = sliderwin2.value(0) - 1
endframe = sliderwin2.value(1) - 1
for i in startframe..endframe
(startframe..endframe).each do |i|
canvas.clearFrame(i)
end
break
@@ -789,7 +787,7 @@ def pbTweening(canvas)
frames = endframe - startframe
startcel = sliderwin2.value(s1set2)
endcel = sliderwin2.value(s1set3)
for j in startcel..endcel
(startcel..endcel).each do |j|
cel1 = canvas.animation[startframe][j]
cel2 = canvas.animation[endframe][j]
next if !cel1 || !cel2
@@ -809,7 +807,7 @@ def pbTweening(canvas)
startAngle = cel1[AnimFrame::ANGLE]
startOpacity = cel1[AnimFrame::OPACITY]
startBlend = cel1[AnimFrame::BLENDTYPE]
for k in 0..frames
(0..frames).each do |k|
cel = canvas.animation[startframe + k][j]
curcel = cel
if !cel
@@ -879,8 +877,8 @@ def pbCellBatch(canvas)
endframe = sliderwin1.value(s1set1) - 1
startcel = sliderwin1.value(s1set2)
endcel = sliderwin1.value(s1set3)
for i in startframe..endframe
for j in startcel..endcel
(startframe..endframe).each do |i|
(startcel..endcel).each do |j|
next if !canvas.animation[i][j]
cel = canvas.animation[i][j]
cel[AnimFrame::PATTERN] = sliderwin2.value(set0) if sliderwin2.value(set0)
@@ -926,7 +924,7 @@ def pbEntireSlide(canvas)
endvalue = sliderwin2.value(1) - 1
xoffset = sliderwin2.value(2)
yoffset = sliderwin2.value(3)
for i in startvalue..endvalue
(startvalue..endvalue).each do |i|
canvas.offsetFrame(i, xoffset, yoffset)
end
break
@@ -1129,7 +1127,7 @@ def animationEditorMain(animation)
if sidewin.changed?(1)
positions = [_INTL("User"), _INTL("Target"), _INTL("User and target"), _INTL("Screen")]
indexes = [2, 1, 3, 4] # Keeping backwards compatibility
for i in 0...positions.length
positions.length.times do |i|
selected = "[ ]"
if animation[animation.selected].position == indexes[i]
selected = "[x]"