Yet more Rubocopping

This commit is contained in:
Maruno17
2021-12-23 00:27:17 +00:00
parent 514fe13ca2
commit 132a16950d
171 changed files with 1455 additions and 1647 deletions

View File

@@ -85,14 +85,14 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
return false if sprite.bitmap.disposed?
width = sprite.src_rect.width
height = sprite.src_rect.height
if !wholecanvas
if wholecanvas
xwidth = 0
xheight = 0
else
xwidth = width - 64
xheight = height - 64
width = 64 if width > 64 && !usealpha
height = 64 if height > 64 && !usealpha
else
xwidth = 0
xheight = 0
end
width = sprite.bitmap.width if width > sprite.bitmap.width
height = sprite.bitmap.height if height > sprite.bitmap.height
@@ -125,7 +125,7 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
bitmapX = sprite.src_rect.x + 192 - xmirror
end
color = sprite.bitmap.get_pixel(bitmapX, bitmapY)
return false if (color.alpha == 0)
return false if color.alpha == 0
end
return true
end
@@ -478,7 +478,7 @@ class AnimationCanvas < Sprite
def loadAnimation(anim)
@animation = anim
@animbitmap.dispose if @animbitmap
@animbitmap&.dispose
if @animation.graphic == ""
@animbitmap = nil
else
@@ -497,7 +497,7 @@ class AnimationCanvas < Sprite
end
def animbitmap=(value)
@animbitmap.dispose if @animbitmap
@animbitmap&.dispose
@animbitmap = value
(2...PBAnimation::MAX_SPRITES).each do |i|
@celsprites[i].bitmap = @animbitmap if @celsprites[i]
@@ -508,12 +508,12 @@ class AnimationCanvas < Sprite
def dispose
@user.dispose
@target.dispose
@animbitmap.dispose if @animbitmap
@selectedbitmap.dispose if @selectedbitmap
@celbitmap.dispose if @celbitmap
self.bitmap.dispose if self.bitmap
@animbitmap&.dispose
@selectedbitmap&.dispose
@celbitmap&.dispose
self.bitmap&.dispose
PBAnimation::MAX_SPRITES.times do |i|
@celsprites[i].dispose if @celsprites[i]
@celsprites[i]&.dispose
end
super
end
@@ -616,7 +616,9 @@ class AnimationCanvas < Sprite
def setPreviousFrame(i)
if @currentframe > 0
cel = @animation[@currentframe - 1][i]
if cel != nil
if cel.nil?
@lastframesprites[i].visible = false
else
@lastframesprites[i].ox = 32
@lastframesprites[i].oy = 32
@lastframesprites[i].selected = false
@@ -625,8 +627,6 @@ class AnimationCanvas < Sprite
@lastframesprites[i].y = cel[AnimFrame::Y] + 64
@lastframesprites[i].visible = true
@lastframesprites[i].repaint
else
@lastframesprites[i].visible = false
end
else
@lastframesprites[i].visible = false
@@ -799,31 +799,30 @@ class AnimationCanvas < Sprite
def updateInput
cel = currentCel
mousepos = Mouse.getMousePos
if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
if Input.trigger?(Input::MOUSELEFT) # Left mouse button
selectedcel = -1
usealpha = (Input.press?(Input::ALT)) ? true : false
PBAnimation::MAX_SPRITES.times do |j|
if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false)
selectedcel = j
end
if Input.trigger?(Input::MOUSELEFT) && mousepos &&
pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
selectedcel = -1
usealpha = (Input.press?(Input::ALT)) ? true : false
PBAnimation::MAX_SPRITES.times do |j|
if pbSpriteHitTest(@celsprites[j], mousepos[0], mousepos[1], usealpha, false)
selectedcel = j
end
if selectedcel < 0
if @animbitmap && addSprite(mousepos[0] - BORDERSIZE, mousepos[1] - BORDERSIZE)
@selecting = true if !self.locked?(@currentcel)
@selectOffsetX = 0
@selectOffsetY = 0
cel = currentCel
invalidate
end
else
@currentcel = selectedcel
end
if selectedcel < 0
if @animbitmap && addSprite(mousepos[0] - BORDERSIZE, mousepos[1] - BORDERSIZE)
@selecting = true if !self.locked?(@currentcel)
@selectOffsetX = 0
@selectOffsetY = 0
cel = currentCel
@selectOffsetX = cel[AnimFrame::X] - mousepos[0] + BORDERSIZE
@selectOffsetY = cel[AnimFrame::Y] - mousepos[1] + BORDERSIZE
invalidate
end
else
@currentcel = selectedcel
@selecting = true if !self.locked?(@currentcel)
cel = currentCel
@selectOffsetX = cel[AnimFrame::X] - mousepos[0] + BORDERSIZE
@selectOffsetY = cel[AnimFrame::Y] - mousepos[1] + BORDERSIZE
invalidate
end
end
currentFrame = getCurrentFrame

View File

@@ -144,10 +144,10 @@ class Button < UIControl
color = Color.new(120, 120, 120)
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
if !@captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
else
if @captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80))
else
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
end
size = bitmap.text_size(self.label).width
shadowtext(bitmap, x + 4, y, size, height, self.label, @disabled)
@@ -196,10 +196,10 @@ class Checkbox < Button
bitmap.fill_rect(x + 2, y + 2, self.width - 4, self.height - 4, Color.new(0, 0, 0, 0))
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
if !@captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
else
if @captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80))
else
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
end
if self.checked
shadowtext(bitmap, x, y, 32, 32, "X", @disabled, 1)
@@ -259,7 +259,7 @@ class TextField < UIControl
@frame += 1
@frame %= 20
self.changed = false
self.invalidate if ((@frame % 10) == 0)
self.invalidate if (@frame % 10) == 0
# Moving cursor
if Input.triggerex?(:LEFT) || Input.repeatex?(:LEFT)
if @cursor > 0
@@ -302,10 +302,10 @@ class TextField < UIControl
width -= size
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
if !@captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
else
if @captured
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(120, 120, 120, 80))
else
bitmap.fill_rect(x + 2, y + 2, width - 4, height - 4, Color.new(0, 0, 0, 0))
end
x += 4
textscan = self.text.scan(/./m)
@@ -314,7 +314,7 @@ class TextField < UIControl
@cursor = 0 if @cursor < 0
startpos = @cursor
fromcursor = 0
while (startpos > 0)
while startpos > 0
c = textscan[startpos - 1]
fromcursor += bitmap.text_size(c).width
break if fromcursor > width - 4
@@ -668,7 +668,7 @@ class TextSlider < UIControl
def refresh
bitmap = self.bitmap
if @maxoptionwidth == nil
if @maxoptionwidth.nil?
@options.length.times do |i|
w = self.bitmap.text_size(" " + @options[i] + " ").width
@maxoptionwidth = w if !@maxoptionwidth || @maxoptionwidth < w

View File

@@ -166,15 +166,13 @@ class PointPath
i = 0
@distances.each do |dist|
curdist += dist
if dist > 0.0
if curdist >= distForT
distT = 1.0 - ((curdist - distForT) / dist)
dx = @points[i + 1][0] - @points[i][0]
dy = @points[i + 1][1] - @points[i][1]
ret = [@points[i][0] + (dx * distT),
@points[i][1] + (dy * distT)]
break
end
if dist > 0.0 && curdist >= distForT
distT = 1.0 - ((curdist - distForT) / dist)
dx = @points[i + 1][0] - @points[i][0]
dy = @points[i + 1][1] - @points[i][1]
ret = [@points[i][0] + (dx * distT),
@points[i][1] + (dy * distT)]
break
end
i += 1
end
@@ -295,8 +293,8 @@ def pbDefinePath(canvas)
if Input.trigger?(Input::MOUSELEFT)
4.times do |j|
next if !curve[j].hittest?
if [1, 2].include?(j)
next if !curve[0].visible || !curve[3].visible
if [1, 2].include?(j) && (!curve[0].visible || !curve[3].visible)
next
end
curve[j].visible = true
4.times do |k|
@@ -381,7 +379,7 @@ def pbDefinePath(canvas)
mousepos = Mouse.getMousePos(true)
window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
end
while !canceled
until canceled
mousepos = Mouse.getMousePos(true)
if mousepos && !pointpath.isEndPoint?(mousepos[0], mousepos[1])
pointpath.addPoint(mousepos[0], mousepos[1])

View File

@@ -91,7 +91,7 @@ def pbConvertAnimToNewFormat(textdata)
next if !textdata[i]
PBAnimation::MAX_SPRITES.times do |j|
next if !textdata[i][j]
needconverting = true if textdata[i][j][AnimFrame::FOCUS] == nil
needconverting = true if textdata[i][j][AnimFrame::FOCUS].nil?
break if needconverting
end
break if needconverting
@@ -101,7 +101,7 @@ def pbConvertAnimToNewFormat(textdata)
next if !textdata[i]
PBAnimation::MAX_SPRITES.times do |j|
next if !textdata[i][j]
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY].nil?
case j
when 0 # User battler
textdata[i][j][AnimFrame::FOCUS] = 2

View File

@@ -707,7 +707,7 @@ def pbCopyFrames(canvas)
dstvalue = sliderwin2.value(2) - 1
length = (endvalue - startvalue) + 1
if length > 0 # Ensure correct overlap handling
if (startvalue < dstvalue)
if startvalue < dstvalue
startvalue += length
dstvalue += length
while length != 0
@@ -1187,5 +1187,5 @@ def pbAnimationEditor
animationEditorMain(animation)
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
pbSetResizeFactor($PokemonSystem.screensize)
$game_map.autoplay if $game_map
$game_map&.autoplay
end