Resolved many Rubocop warnings

This commit is contained in:
Maruno17
2020-09-06 17:31:12 +01:00
parent 6c4670eaa3
commit 681a8331ab
137 changed files with 921 additions and 1200 deletions

View File

@@ -46,7 +46,7 @@ class Window_CharacterEntry < Window_DrawableCommand
return @charset.length+3
end
def drawItem(index,count,rect)
def drawItem(index,_count,rect)
rect=drawCursor(index,rect)
if index==@charset.length # -1
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,"[ ]",
@@ -70,9 +70,9 @@ end
#
#===============================================================================
class CharacterEntryHelper
attr_reader :text
attr_reader :maxlength
attr_reader :passwordChar
attr_reader :text
attr_accessor :maxlength
attr_reader :passwordChar
attr_accessor :cursor
def initialize(text)
@@ -80,12 +80,10 @@ class CharacterEntryHelper
@text=text
@passwordChar=""
@cursor=text.scan(/./m).length
ensure
end
def text=(value)
@text=value
ensure
end
def textChars
@@ -100,11 +98,6 @@ class CharacterEntryHelper
@passwordChar=value ? value : ""
end
def maxlength=(value)
@maxlength=value
ensure
end
def length
return self.text.scan(/./m).length
end
@@ -264,7 +257,6 @@ class Window_TextEntry < SpriteWindow_Base
end
x+=4
width=self.width-self.borderX
height=self.height-self.borderY
cursorcolor=Color.new(16,24,32)
textscan=self.text.scan(/./m)
scanlength=textscan.length
@@ -316,8 +308,6 @@ def getLineBrokenText(bitmap,value,width,dims)
column=0
return ret if !bitmap || bitmap.disposed? || width<=0
textmsg=value.clone
lines=0
color=Font.default_color
ret.push(["",0,0,0,bitmap.text_size("X").height,0,0,0,0])
while ((c = textmsg.slice!(/\n|(\S*([ \r\t\f]?))/)) != nil)
break if c==""
@@ -334,7 +324,6 @@ def getLineBrokenText(bitmap,value,width,dims)
ret.push(["",x,y,0,textheight,line,position,column,0])
next
end
textcols=[]
words=[ccheck]
for i in 0...words.length
word=words[i]
@@ -355,7 +344,6 @@ def getLineBrokenText(bitmap,value,width,dims)
x+=textwidth
dims[0]=x if dims && dims[0]<x
end
color=textcols[i] if textcols[i]
end
position+=length
column+=length
@@ -451,87 +439,72 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getTotalLines
textchars=getTextChars
if textchars.length==0
return 1
else
tchar=textchars[textchars.length-1]
return tchar[5]+1
end
return 1 if textchars.length==0
tchar=textchars[textchars.length-1]
return tchar[5]+1
end
def getLineY(line)
textchars=getTextChars
if textchars.length==0
return 0
else
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
end
return maximumY
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
end
return maximumY
end
def getColumnsInLine(line)
textchars=getTextChars
if textchars.length==0
return 0
else
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]
thislength=textchars[i][8]
if thisline==line
endpos+=thislength
end
end
return endpos
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
end
return endpos
end
def getPosFromLineAndColumn(line,column)
textchars=getTextChars
if textchars.length==0
return 0
else
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
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]]
if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0
return thispos+(column-thiscolumn)
end
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
# echoln [endpos,thispos+(column-thiscolumn),textchars[i]]
if column>=thiscolumn && column<=thiscolumn+thislength && thislength>0
return thispos+(column-thiscolumn)
end
end
if endpos==0
# echoln [totallines,line,column]
# echoln textchars
end
# echoln "endpos=#{endpos}"
return endpos
end
# if endpos==0
# echoln [totallines,line,column]
# echoln textchars
# end
# echoln "endpos=#{endpos}"
return endpos
end
def getLastVisibleLine
textchars=getTextChars()
getTextChars()
textheight=[1,self.contents.text_size("X").height].max
lastVisible=@firstline+((self.height-self.borderY)/textheight)-1
return lastVisible
@@ -544,13 +517,9 @@ class Window_MultilineTextEntry < SpriteWindow_Base
@frame=0
self.refresh
end
if @cursorLine<@firstline
@firstline=@cursorLine
end
@firstline=@cursorLine if @cursorLine<@firstline
lastVisible=getLastVisibleLine()
if @cursorLine>lastVisible
@firstline+=(@cursorLine-lastVisible)
end
@firstline+=(@cursorLine-lastVisible) if @cursorLine>lastVisible
end
def moveCursor(lineOffset, columnOffset)
@@ -570,7 +539,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base
# Will happen if cursor is moved right from the end of a line
@cursorLine+=1
@cursorColumn=0
updateColumns=true
end
# Ensure column bounds
totalColumns=getColumnsInLine(@cursorLine)
@@ -688,20 +656,13 @@ class Window_MultilineTextEntry < SpriteWindow_Base
self.contents=newContents
bitmap=self.contents
bitmap.clear
x=0
y=0
getTextChars
x+=4
width=self.width-self.borderX
height=self.height-self.borderY
cursorcolor=Color.new(0,0,0)
textchars=getTextChars()
scanlength=@helper.length
startY=getLineY(@firstline)
lastheight=32
for i in 0...textchars.length
thisline=textchars[i][5]
thispos=textchars[i][6]
thiscolumn=textchars[i][7]
thislength=textchars[i][8]
textY=textchars[i][2]-startY
@@ -712,11 +673,10 @@ class Window_MultilineTextEntry < SpriteWindow_Base
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
textwidth=textchars[i][3]+4 # add 4 to prevent draw_text from stretching text
textheight=textchars[i][4]
lastheight=textheight
# Draw text
pbDrawShadowText(bitmap,textchars[i][1],textY, textwidth, textheight, c,@baseColor,@shadowColor)
pbDrawShadowText(bitmap, textchars[i][1], textY, textwidth, textheight, c, @baseColor, @shadowColor)
end
# Draw cursor
if ((@frame/10)&1) == 0
@@ -725,7 +685,6 @@ class Window_MultilineTextEntry < SpriteWindow_Base
cursorX=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==@cursorLine && @cursorColumn>=thiscolumn &&
@@ -1560,7 +1519,6 @@ class Interpreter
if $game_actors && $data_actors && $data_actors[@parameters[0]] != nil
# Set battle abort flag
$game_temp.battle_abort = true
ret=""
pbFadeOutIn {
sscene=PokemonEntryScene.new
sscreen=PokemonEntry.new(sscene)
@@ -1583,7 +1541,6 @@ class Game_Interpreter
end
if $game_actors && $data_actors && $data_actors[@params[0]] != nil
# Set battle abort flag
ret=""
pbFadeOutIn {
sscene=PokemonEntryScene.new
sscreen=PokemonEntry.new(sscene)