Minor refactoring to kill various Rubocop warnings

This commit is contained in:
Maruno17
2021-12-17 20:29:47 +00:00
parent b5ee1b211d
commit 5dc64f1709
46 changed files with 145 additions and 151 deletions

View File

@@ -6,7 +6,6 @@ class WindowCursorRect < Rect
def empty
return unless needs_update?(0, 0, 0, 0)
set(0, 0, 0, 0)
end
@@ -16,9 +15,7 @@ class WindowCursorRect < Rect
def set(x, y, width, height)
return unless needs_update?(x, y, width, height)
super(x, y, width, height)
@window.width = @window.width
end
@@ -336,9 +333,11 @@ class Window
left=dstrect.x
top=dstrect.y
y = 0
loop do break unless y < dstrect.height
loop do
break unless y < dstrect.height
x = 0
loop do break unless x < dstrect.width
loop do
break unless x < dstrect.width
dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
x+=srcrect.width
end
@@ -527,10 +526,10 @@ class Window
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(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
rect = Rect.new(margin, 0,
width - fullmargin, margin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])

View File

@@ -456,9 +456,11 @@ class SpriteWindow < Window
left=dstrect.x
top=dstrect.y
y = 0
loop do break unless y < dstrect.height
loop do
break unless y < dstrect.height
x = 0
loop do break unless x < dstrect.width
loop do
break unless x < dstrect.width
dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
x+=srcrect.width
end
@@ -714,10 +716,10 @@ class SpriteWindow < Window
@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(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
rect = Rect.new(margin, 0,width - fullmargin, margin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])
rect = Rect.new(0, margin,margin, height - fullmargin)

View File

@@ -731,6 +731,7 @@ end
#===============================================================================
class SpriteWindow_Selectable < SpriteWindow_Base
attr_reader :index
attr_writer :ignore_input
def initialize(x, y, width, height)
super(x, y, width, height)
@@ -789,10 +790,6 @@ class SpriteWindow_Selectable < SpriteWindow_Base
end
end
def ignore_input=(value)
@ignore_input=value
end
def count
return @item_max
end

View File

@@ -106,11 +106,9 @@ class PictureWindow < SpriteWindow_Base
self.height=@_iconbitmap.bitmap.height+self.borderY
else
@_iconbitmap=AnimatedBitmap.new(pathOrBitmap,hue)
self.contents=@_iconbitmap ? @_iconbitmap.bitmap : nil
self.width=@_iconbitmap ? @_iconbitmap.bitmap.width+self.borderX :
32+self.borderX
self.height=@_iconbitmap ? @_iconbitmap.bitmap.height+self.borderY :
32+self.borderY
self.contents = @_iconbitmap&.bitmap
self.width = self.borderX + (@_iconbitmap&.bitmap&.width || 32)
self.height = self.borderY + (@_iconbitmap&.bitmap&.height || 32)
end
else
@_iconbitmap=nil

View File

@@ -346,14 +346,14 @@ class ChangelingSprite < SpriteWrapper
def dispose
return if disposed?
@bitmaps.values.each { |bm| bm.dispose }
@bitmaps.each_value { |bm| bm.dispose }
@bitmaps.clear
super
end
def update
return if disposed?
@bitmaps.values.each { |bm| bm.update }
@bitmaps.each_value { |bm| bm.update }
self.bitmap = (@currentBitmap) ? @currentBitmap.bitmap : nil
end
end

View File

@@ -402,9 +402,9 @@ def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
while text[FORMATREGEXP]
textchunks.push($~.pre_match)
if $~[3]
controls.push([$~[2].downcase,$~[4],-1,$~[1]=="/" ? true : false])
controls.push([$~[2].downcase, $~[4], -1, $~[1] == "/"])
else
controls.push([$~[2].downcase,"",-1,$~[1]=="/" ? true : false])
controls.push([$~[2].downcase, "", -1, $~[1] == "/"])
end
text=$~.post_match
end

View File

@@ -56,6 +56,9 @@ end
#
#===============================================================================
class ChooseNumberParams
attr_reader :messageSkin # Set the full path for the message's window skin
attr_reader :skin
def initialize
@maxDigits=0
@minNumber=0
@@ -71,18 +74,10 @@ class ChooseNumberParams
@messageSkin=value
end
def messageSkin # Set the full path for the message's window skin
@messageSkin
end
def setSkin(value)
@skin=value
end
def skin
@skin
end
def setNegativesAllowed(value)
@negativeAllowed=value
end

View File

@@ -2,7 +2,7 @@
#
#===============================================================================
class CharacterEntryHelper
attr_reader :text
attr_accessor :text
attr_accessor :maxlength
attr_reader :passwordChar
attr_accessor :cursor
@@ -14,10 +14,6 @@ class CharacterEntryHelper
@cursor=text.scan(/./m).length
end
def text=(value)
@text=value
end
def textChars
chars=text.scan(/./m)
if @passwordChar!=""
@@ -502,7 +498,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
self.delete
return
end
Input.gets.each_char{|c|insert(c)}
Input.gets.each_char { |c| insert(c) }
end
def refresh