mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Code tidying with Rubocop
This commit is contained in:
@@ -108,7 +108,7 @@ module MessageConfig
|
||||
when 2 then return 1 / 80.0 # Fast
|
||||
when 3 then return 0 # Instant
|
||||
end
|
||||
return TEXT_SPEED || 2 / 80.0 # Normal
|
||||
return TEXT_SPEED || (2 / 80.0) # Normal
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
@@ -302,7 +302,7 @@ class Window
|
||||
mustchange = false
|
||||
if @active
|
||||
cursor_time = System.uptime / 0.4
|
||||
if cursor_time.to_i % 2 == 0
|
||||
if cursor_time.to_i.even?
|
||||
@cursoropacity = lerp(255, 128, 0.4, cursor_time % 2)
|
||||
else
|
||||
@cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2)
|
||||
|
||||
@@ -300,7 +300,7 @@ class SpriteWindow < Window
|
||||
mustchange = false
|
||||
if @active
|
||||
cursor_time = System.uptime / 0.4
|
||||
if cursor_time.to_i % 2 == 0
|
||||
if cursor_time.to_i.even?
|
||||
@cursoropacity = lerp(255, 128, 0.4, cursor_time % 2)
|
||||
else
|
||||
@cursoropacity = lerp(128, 255, 0.4, (cursor_time - 1) % 2)
|
||||
@@ -852,7 +852,8 @@ class SpriteWindow_Base < SpriteWindow
|
||||
end
|
||||
end
|
||||
|
||||
def setSkin(skin) # Filename of windowskin to apply. Supports XP, VX, and animated skins.
|
||||
# Filename of windowskin to apply. Supports XP, VX, and animated skins.
|
||||
def setSkin(skin)
|
||||
@customskin&.dispose
|
||||
@customskin = nil
|
||||
resolvedName = pbResolveBitmap(skin)
|
||||
|
||||
@@ -47,7 +47,8 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
|
||||
return ret
|
||||
end
|
||||
|
||||
def resizeToFitInternal(text, maxwidth) # maxwidth is maximum acceptable window width
|
||||
# maxwidth is maximum acceptable window width.
|
||||
def resizeToFitInternal(text, maxwidth)
|
||||
dims = [0, 0]
|
||||
cwidth = maxwidth < 0 ? Graphics.width : maxwidth
|
||||
getLineBrokenChunks(self.contents, text,
|
||||
@@ -60,14 +61,16 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
|
||||
self.text = text
|
||||
end
|
||||
|
||||
def resizeToFit(text, maxwidth = -1) # maxwidth is maximum acceptable window width
|
||||
# maxwidth is maximum acceptable window width.
|
||||
def resizeToFit(text, maxwidth = -1)
|
||||
dims = resizeToFitInternal(text, maxwidth)
|
||||
self.width = dims[0] + self.borderX + SpriteWindow_Base::TEXT_PADDING
|
||||
self.height = dims[1] + self.borderY
|
||||
refresh
|
||||
end
|
||||
|
||||
def resizeHeightToFit(text, width = -1) # width is current window width
|
||||
# width is current window width.
|
||||
def resizeHeightToFit(text, width = -1)
|
||||
dims = resizeToFitInternal(text, width)
|
||||
self.width = (width < 0) ? Graphics.width : width
|
||||
self.height = dims[1] + self.borderY
|
||||
@@ -685,7 +688,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
|
||||
def update
|
||||
super
|
||||
digits = @digits_max + (@sign ? 1 : 0)
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
|
||||
if cursor_to_show != @cursor_shown
|
||||
@cursor_shown = cursor_to_show
|
||||
refresh
|
||||
@@ -1128,11 +1131,13 @@ class Window_DrawableCommand < SpriteWindow_SelectableEx
|
||||
return Rect.new(rect.x + 16, rect.y, rect.width - 16, rect.height)
|
||||
end
|
||||
|
||||
def itemCount # to be implemented by derived classes
|
||||
# To be implemented by derived classes.
|
||||
def itemCount
|
||||
return 0
|
||||
end
|
||||
|
||||
def drawItem(index, count, rect); end # to be implemented by derived classes
|
||||
# To be implemented by derived classes.
|
||||
def drawItem(index, count, rect); end
|
||||
|
||||
def refresh
|
||||
@item_max = itemCount
|
||||
|
||||
@@ -819,23 +819,22 @@ def getLineBrokenText(bitmap, value, width, dims)
|
||||
words = [ccheck]
|
||||
words.length.times do |i|
|
||||
word = words[i]
|
||||
if word && word != ""
|
||||
textSize = bitmap.text_size(word)
|
||||
textwidth = textSize.width
|
||||
if x > 0 && x + textwidth >= width - 2
|
||||
# Zero-length word break
|
||||
ret.push(["", x, y, 0, textheight, line, position, column, 0])
|
||||
x = 0
|
||||
column = 0
|
||||
y += (textheight == 0) ? bitmap.text_size("X").height : textheight
|
||||
line += 1
|
||||
textheight = 0
|
||||
end
|
||||
textheight = [textheight, textSize.height].max
|
||||
ret.push([word, x, y, textwidth, textheight, line, position, column, length])
|
||||
x += textwidth
|
||||
dims[0] = x if dims && dims[0] < x
|
||||
next if nil_or_empty?(word)
|
||||
textSize = bitmap.text_size(word)
|
||||
textwidth = textSize.width
|
||||
if x > 0 && x + textwidth >= width - 2
|
||||
# Zero-length word break
|
||||
ret.push(["", x, y, 0, textheight, line, position, column, 0])
|
||||
x = 0
|
||||
column = 0
|
||||
y += (textheight == 0) ? bitmap.text_size("X").height : textheight
|
||||
line += 1
|
||||
textheight = 0
|
||||
end
|
||||
textheight = [textheight, textSize.height].max
|
||||
ret.push([word, x, y, textwidth, textheight, line, position, column, length])
|
||||
x += textwidth
|
||||
dims[0] = x if dims && dims[0] < x
|
||||
end
|
||||
position += length
|
||||
column += length
|
||||
@@ -912,16 +911,15 @@ def renderLineBrokenChunksWithShadow(bitmap, xDst, yDst, normtext, maxheight, ba
|
||||
width = text[3]
|
||||
textx = text[1] + xDst
|
||||
texty = text[2] + yDst
|
||||
if maxheight == 0 || text[2] < maxheight
|
||||
height = text[4]
|
||||
text = text[0]
|
||||
bitmap.font.color = shadowColor
|
||||
bitmap.draw_text(textx + 2, texty, width + 2, height, text)
|
||||
bitmap.draw_text(textx, texty + 2, width + 2, height, text)
|
||||
bitmap.draw_text(textx + 2, texty + 2, width + 2, height, text)
|
||||
bitmap.font.color = baseColor
|
||||
bitmap.draw_text(textx, texty, width + 2, height, text)
|
||||
end
|
||||
next if maxheight != 0 && text[2] >= maxheight
|
||||
height = text[4]
|
||||
text = text[0]
|
||||
bitmap.font.color = shadowColor
|
||||
bitmap.draw_text(textx + 2, texty, width + 2, height, text)
|
||||
bitmap.draw_text(textx, texty + 2, width + 2, height, text)
|
||||
bitmap.draw_text(textx + 2, texty + 2, width + 2, height, text)
|
||||
bitmap.font.color = baseColor
|
||||
bitmap.draw_text(textx, texty, width + 2, height, text)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class ChooseNumberParams
|
||||
end
|
||||
|
||||
def initialNumber
|
||||
return clamp(@initialNumber, self.minNumber, self.maxNumber)
|
||||
return @initialNumber.clamp(self.minNumber, self.maxNumber)
|
||||
end
|
||||
|
||||
def cancelNumber
|
||||
@@ -149,10 +149,6 @@ class ChooseNumberParams
|
||||
|
||||
private
|
||||
|
||||
def clamp(v, mn, mx)
|
||||
return v < mn ? mn : (v > mx ? mx : v)
|
||||
end
|
||||
|
||||
def numDigits(number)
|
||||
ans = 1
|
||||
number = number.abs
|
||||
|
||||
@@ -148,7 +148,7 @@ class Window_TextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def update
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
|
||||
if cursor_to_show != @cursor_shown
|
||||
@cursor_shown = cursor_to_show
|
||||
refresh
|
||||
@@ -225,7 +225,7 @@ end
|
||||
#===============================================================================
|
||||
class Window_TextEntry_Keyboard < Window_TextEntry
|
||||
def update
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
|
||||
if cursor_to_show != @cursor_shown
|
||||
@cursor_shown = cursor_to_show
|
||||
refresh
|
||||
@@ -394,19 +394,11 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
thispos = text[6]
|
||||
thiscolumn = text[7]
|
||||
thislength = text[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
|
||||
next if thisline != line
|
||||
endpos = thispos + thislength
|
||||
next if column < thiscolumn || column > thiscolumn + thislength || thislength == 0
|
||||
return thispos + column - thiscolumn
|
||||
end
|
||||
# if endpos==0
|
||||
# echoln [totallines,line,column]
|
||||
# echoln textchars
|
||||
# end
|
||||
# echoln "endpos=#{endpos}"
|
||||
return endpos
|
||||
end
|
||||
|
||||
@@ -465,7 +457,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def update
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i % 2 == 0
|
||||
cursor_to_show = ((System.uptime - @cursor_timer_start) / 0.35).to_i.even?
|
||||
if cursor_to_show != @cursor_shown
|
||||
@cursor_shown = cursor_to_show
|
||||
refresh
|
||||
@@ -544,18 +536,17 @@ class Window_MultilineTextEntry < SpriteWindow_Base
|
||||
thisline = text[5]
|
||||
thiscolumn = text[7]
|
||||
thislength = text[8]
|
||||
if thisline == @cursorLine && @cursorColumn >= thiscolumn &&
|
||||
@cursorColumn <= thiscolumn + thislength
|
||||
cursorY = text[2] - startY
|
||||
cursorX = text[1]
|
||||
textheight = text[4]
|
||||
posToCursor = @cursorColumn - thiscolumn
|
||||
if posToCursor >= 0
|
||||
partialString = text[0].scan(/./m)[0, posToCursor].join
|
||||
cursorX += bitmap.text_size(partialString).width
|
||||
end
|
||||
break
|
||||
next if thisline != @cursorLine || @cursorColumn < thiscolumn ||
|
||||
@cursorColumn > thiscolumn + thislength
|
||||
cursorY = text[2] - startY
|
||||
cursorX = text[1]
|
||||
textheight = text[4]
|
||||
posToCursor = @cursorColumn - thiscolumn
|
||||
if posToCursor >= 0
|
||||
partialString = text[0].scan(/./m)[0, posToCursor].join
|
||||
cursorX += bitmap.text_size(partialString).width
|
||||
end
|
||||
break
|
||||
end
|
||||
cursorY += 4
|
||||
cursorHeight = [4, textheight - 4, bitmap.text_size("X").height - 4].max
|
||||
|
||||
Reference in New Issue
Block a user