mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 21:54:58 +00:00
Lots of rubocop
This commit is contained in:
@@ -32,9 +32,7 @@ class Window_Menu < Window_CommandPokemon
|
||||
rc = Rect.new(0, 32 * (i - toprow), self.contents.width, 32)
|
||||
rc.x += self.x + self.leftEdge
|
||||
rc.y += self.y + self.topEdge
|
||||
if rc.contains(mousepos[0], mousepos[1])
|
||||
return i
|
||||
end
|
||||
return i if rc.contains(mousepos[0], mousepos[1])
|
||||
end
|
||||
return -1
|
||||
end
|
||||
@@ -341,8 +339,7 @@ class InvalidatableSprite < Sprite
|
||||
|
||||
# Redraws the sprite. This method should not check whether
|
||||
# the sprite is invalid, to allow it to be explicitly called.
|
||||
def refresh
|
||||
end
|
||||
def refresh; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
@@ -820,11 +817,11 @@ class AnimationCanvas < Sprite
|
||||
currentFrame = getCurrentFrame
|
||||
if currentFrame && !@selecting &&
|
||||
(Input.triggerex?(:TAB) || Input.repeatex?(:TAB))
|
||||
currentFrame.length.times {
|
||||
currentFrame.length.times do
|
||||
@currentcel += 1
|
||||
@currentcel = 0 if @currentcel >= currentFrame.length
|
||||
break if currentFrame[@currentcel]
|
||||
}
|
||||
end
|
||||
invalidate
|
||||
return
|
||||
end
|
||||
|
||||
@@ -72,21 +72,19 @@ class UIControl
|
||||
return @invalid
|
||||
end
|
||||
|
||||
def invalidate # Marks that the control must be redrawn to reflect current logic
|
||||
def invalidate # Marks that the control must be redrawn to reflect current logic
|
||||
@invalid = true
|
||||
end
|
||||
|
||||
def update # Updates the logic on the control, invalidating it if necessary
|
||||
end
|
||||
def update; end # Updates the logic on the control, invalidating it if necessary
|
||||
|
||||
def refresh # Redraws the control
|
||||
end
|
||||
def refresh; end # Redraws the control
|
||||
|
||||
def validate # Makes the control no longer invalid
|
||||
def validate # Makes the control no longer invalid
|
||||
@invalid = false
|
||||
end
|
||||
|
||||
def repaint # Redraws the control only if it is invalid
|
||||
def repaint # Redraws the control only if it is invalid
|
||||
if self.invalid?
|
||||
self.refresh
|
||||
self.validate
|
||||
@@ -208,9 +206,7 @@ class Checkbox < Button
|
||||
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)
|
||||
end
|
||||
shadowtext(bitmap, x, y, 32, 32, "X", @disabled, 1) if self.checked
|
||||
size = bitmap.text_size(self.label).width
|
||||
shadowtext(bitmap, x + 36, y, size, height, self.label, @disabled)
|
||||
return ret
|
||||
@@ -241,9 +237,7 @@ class TextField < UIControl
|
||||
chars = self.text.scan(/./m)
|
||||
chars.insert(@cursor, ch)
|
||||
@text = ""
|
||||
chars.each do |ch|
|
||||
@text += ch
|
||||
end
|
||||
chars.each { |char| @text += char }
|
||||
@cursor += 1
|
||||
@frame = 0
|
||||
self.changed = true
|
||||
@@ -254,9 +248,7 @@ class TextField < UIControl
|
||||
chars = self.text.scan(/./m)
|
||||
chars.delete_at(@cursor - 1)
|
||||
@text = ""
|
||||
chars.each do |ch|
|
||||
@text += ch
|
||||
end
|
||||
chars.each { |char| @text += char }
|
||||
@cursor -= 1
|
||||
@frame = 0
|
||||
self.changed = true
|
||||
@@ -533,6 +525,8 @@ class OptionalSlider < Slider
|
||||
@checkbox.refresh
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
private
|
||||
|
||||
def updatedefs
|
||||
@@ -786,6 +780,8 @@ class OptionalTextSlider < TextSlider
|
||||
@checkbox.refresh
|
||||
end
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
private
|
||||
|
||||
def updatedefs
|
||||
|
||||
@@ -132,13 +132,9 @@ class PointPath
|
||||
end
|
||||
|
||||
def smoothPointPath(frames, roundValues = false)
|
||||
if frames < 0
|
||||
raise ArgumentError.new("frames out of range: #{frames}")
|
||||
end
|
||||
raise ArgumentError.new("frames out of range: #{frames}") if frames < 0
|
||||
ret = PointPath.new
|
||||
if @points.length == 0
|
||||
return ret
|
||||
end
|
||||
return ret if @points.length == 0
|
||||
step = 1.0 / frames
|
||||
t = 0.0
|
||||
(frames + 2).times do
|
||||
@@ -160,9 +156,7 @@ class PointPath
|
||||
end
|
||||
return nil if @points.length == 0
|
||||
ret = @points[@points.length - 1].clone
|
||||
if @points.length == 1
|
||||
return ret
|
||||
end
|
||||
return ret if @points.length == 1
|
||||
curdist = 0
|
||||
distForT = @totaldist * t
|
||||
i = 0
|
||||
@@ -217,9 +211,7 @@ def getCurvePoint(src, t)
|
||||
end
|
||||
|
||||
def curveToPointPath(curve, numpoints)
|
||||
if numpoints < 2
|
||||
return nil
|
||||
end
|
||||
return nil if numpoints < 2
|
||||
path = PointPath.new
|
||||
step = 1.0 / (numpoints - 1)
|
||||
t = 0.0
|
||||
@@ -311,9 +303,7 @@ def pbDefinePath(canvas)
|
||||
end
|
||||
mousepos = Mouse.getMousePos(true)
|
||||
newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
|
||||
if window.text != newtext
|
||||
window.text = newtext
|
||||
end
|
||||
window.text = newtext if window.text != newtext
|
||||
if curve[0].visible && curve[3].visible &&
|
||||
!curve[0].dragging && !curve[3].dragging
|
||||
points.each do |point|
|
||||
@@ -332,10 +322,10 @@ def pbDefinePath(canvas)
|
||||
if showline
|
||||
step = 1.0 / (points.length - 1)
|
||||
t = 0.0
|
||||
points.length.times do |i|
|
||||
points.length.times do |j|
|
||||
point = getCurvePoint(curve, t)
|
||||
points[i].x = point[0]
|
||||
points[i].y = point[1]
|
||||
points[j].x = point[0]
|
||||
points[j].y = point[1]
|
||||
t += step
|
||||
end
|
||||
end
|
||||
@@ -418,14 +408,14 @@ def pbDefinePath(canvas)
|
||||
end
|
||||
thiscel = canvas.currentCel
|
||||
celnumber = canvas.currentcel
|
||||
(canvas.currentframe...neededsize).each do |i|
|
||||
cel = canvas.animation[i][celnumber]
|
||||
if !canvas.animation[i][celnumber]
|
||||
(canvas.currentframe...neededsize).each do |j|
|
||||
cel = canvas.animation[j][celnumber]
|
||||
if !canvas.animation[j][celnumber]
|
||||
cel = pbCreateCel(0, 0, thiscel[AnimFrame::PATTERN], canvas.animation.position)
|
||||
canvas.animation[i][celnumber] = cel
|
||||
canvas.animation[j][celnumber] = cel
|
||||
end
|
||||
cel[AnimFrame::X] = path[i - canvas.currentframe][0]
|
||||
cel[AnimFrame::Y] = path[i - canvas.currentframe][1]
|
||||
cel[AnimFrame::X] = path[j - canvas.currentframe][0]
|
||||
cel[AnimFrame::Y] = path[j - canvas.currentframe][1]
|
||||
end
|
||||
break
|
||||
elsif sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK)
|
||||
|
||||
@@ -26,9 +26,9 @@ def pbExportAnim(animations)
|
||||
if filename != ""
|
||||
begin
|
||||
filename += ".anm"
|
||||
File.open(filename, "wb") { |f|
|
||||
File.open(filename, "wb") do |f|
|
||||
f.write(dumpBase64Anim(animations[animations.selected]))
|
||||
}
|
||||
end
|
||||
failed = false
|
||||
rescue
|
||||
pbMessage(_INTL("Couldn't save the animation to {1}.", filename))
|
||||
@@ -43,9 +43,7 @@ end
|
||||
|
||||
def pbImportAnim(animations, canvas, animwin)
|
||||
animfiles = []
|
||||
pbRgssChdir(".") {
|
||||
animfiles.concat(Dir.glob("*.anm"))
|
||||
}
|
||||
pbRgssChdir(".") { animfiles.concat(Dir.glob("*.anm")) }
|
||||
cmdwin = pbListWindow(animfiles, 320)
|
||||
cmdwin.opacity = 200
|
||||
cmdwin.height = 480
|
||||
|
||||
@@ -25,9 +25,7 @@ end
|
||||
#===============================================================================
|
||||
def pbSelectAnim(canvas, animwin)
|
||||
animfiles = []
|
||||
pbRgssChdir(File.join("Graphics", "Animations")) {
|
||||
animfiles.concat(Dir.glob("*.png"))
|
||||
}
|
||||
pbRgssChdir(File.join("Graphics", "Animations")) { animfiles.concat(Dir.glob("*.png")) }
|
||||
cmdwin = pbListWindow(animfiles, 320)
|
||||
cmdwin.opacity = 200
|
||||
cmdwin.height = 512
|
||||
@@ -507,12 +505,12 @@ def pbSelectSE(canvas, audio)
|
||||
displayname = (filename != "") ? filename : _INTL("<user's cry>")
|
||||
animfiles = []
|
||||
ret = false
|
||||
pbRgssChdir(File.join("Audio", "SE", "Anim")) {
|
||||
pbRgssChdir(File.join("Audio", "SE", "Anim")) do
|
||||
animfiles.concat(Dir.glob("*.wav"))
|
||||
# animfiles.concat(Dir.glob("*.mp3"))
|
||||
animfiles.concat(Dir.glob("*.ogg"))
|
||||
animfiles.concat(Dir.glob("*.wma"))
|
||||
}
|
||||
end
|
||||
animfiles.uniq!
|
||||
animfiles.sort! { |a, b| a.downcase <=> b.downcase }
|
||||
animfiles = [_INTL("[Play user's cry]")] + animfiles
|
||||
@@ -535,13 +533,11 @@ def pbSelectSE(canvas, audio)
|
||||
Input.update
|
||||
cmdwin.update
|
||||
maxsizewindow.update
|
||||
if maxsizewindow.changed?(3) && animfiles.length > 0 # Play Sound
|
||||
if maxsizewindow.changed?(3) && animfiles.length > 0 # Play Sound
|
||||
fname = (cmdwin.index == 0) ? "Cries/001Cry" : "Anim/" + filename
|
||||
pbSEPlay(RPG::AudioFile.new(fname, maxsizewindow.value(1), maxsizewindow.value(2)))
|
||||
end
|
||||
if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound
|
||||
pbSEStop
|
||||
end
|
||||
pbSEStop if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound
|
||||
if maxsizewindow.changed?(5) # OK
|
||||
audio.name = File.basename(filename, ".*")
|
||||
audio.volume = maxsizewindow.value(1)
|
||||
@@ -549,9 +545,7 @@ def pbSelectSE(canvas, audio)
|
||||
ret = true
|
||||
break
|
||||
end
|
||||
if maxsizewindow.changed?(6) # Cancel
|
||||
break
|
||||
end
|
||||
break if maxsizewindow.changed?(6) # Cancel
|
||||
if Input.trigger?(Input::USE) && animfiles.length > 0
|
||||
filename = (cmdwin.index == 0) ? "" : cmdwin.commands[cmdwin.index]
|
||||
displayname = (filename != "") ? filename : _INTL("<user's cry>")
|
||||
@@ -571,13 +565,13 @@ def pbSelectBG(canvas, timing)
|
||||
animfiles = []
|
||||
animfiles[cmdErase = animfiles.length] = _INTL("[Erase background graphic]")
|
||||
ret = false
|
||||
pbRgssChdir(File.join("Graphics", "Animations")) {
|
||||
pbRgssChdir(File.join("Graphics", "Animations")) do
|
||||
animfiles.concat(Dir.glob("*.png"))
|
||||
animfiles.concat(Dir.glob("*.gif"))
|
||||
# animfiles.concat(Dir.glob("*.jpg"))
|
||||
# animfiles.concat(Dir.glob("*.jpeg"))
|
||||
# animfiles.concat(Dir.glob("*.bmp"))
|
||||
}
|
||||
end
|
||||
animfiles.map! { |f| File.basename(f, ".*") }
|
||||
animfiles.uniq!
|
||||
animfiles.sort! { |a, b| a.downcase <=> b.downcase }
|
||||
@@ -615,9 +609,7 @@ def pbSelectBG(canvas, timing)
|
||||
ret = true
|
||||
break
|
||||
end
|
||||
if maxsizewindow.changed?(9) # Cancel
|
||||
break
|
||||
end
|
||||
break if maxsizewindow.changed?(9) # Cancel
|
||||
if Input.trigger?(Input::USE) && animfiles.length > 0
|
||||
filename = (cmdwin.index == cmdErase) ? "" : cmdwin.commands[cmdwin.index]
|
||||
maxsizewindow.controls[0].text = _INTL("File: \"{1}\"", filename)
|
||||
@@ -676,9 +668,7 @@ def pbEditBG(canvas, timing)
|
||||
end
|
||||
break
|
||||
end
|
||||
if maxsizewindow.changed?(9) # Cancel
|
||||
break
|
||||
end
|
||||
break if maxsizewindow.changed?(9) # Cancel
|
||||
if Input.trigger?(Input::BACK)
|
||||
break
|
||||
end
|
||||
@@ -1001,9 +991,7 @@ def animationEditorMain(animation)
|
||||
sidewin.update
|
||||
animwin.update
|
||||
bottomwindow.update
|
||||
if animwin.changed?
|
||||
canvas.pattern = animwin.selected
|
||||
end
|
||||
canvas.pattern = animwin.selected if animwin.changed?
|
||||
if Input.trigger?(Input::BACK)
|
||||
if pbConfirmMessage(_INTL("Save changes?"))
|
||||
save_data(animation, "Data/PkmnAnimations.rxdata")
|
||||
@@ -1031,9 +1019,7 @@ def animationEditorMain(animation)
|
||||
Clipboard.setData(canvas.animation[canvas.currentframe], "PBAnimFrame")
|
||||
end
|
||||
when 1 # Paste
|
||||
if canvas.currentframe >= 0
|
||||
canvas.pasteFrame(canvas.currentframe)
|
||||
end
|
||||
canvas.pasteFrame(canvas.currentframe) if canvas.currentframe >= 0
|
||||
when 2 # Clear Frame
|
||||
canvas.clearFrame(canvas.currentframe)
|
||||
when 3 # Insert Frame
|
||||
@@ -1076,9 +1062,7 @@ def animationEditorMain(animation)
|
||||
canvas.deleteCel(canvas.currentcel)
|
||||
end
|
||||
when 2 # Copy
|
||||
if canvas.currentCel
|
||||
Clipboard.setData(canvas.currentCel, "PBAnimCel")
|
||||
end
|
||||
Clipboard.setData(canvas.currentCel, "PBAnimCel") if canvas.currentCel
|
||||
when 3 # Paste
|
||||
canvas.pasteCel(mousepos[0], mousepos[1])
|
||||
when 4 # Delete
|
||||
@@ -1087,9 +1071,7 @@ def animationEditorMain(animation)
|
||||
if canvas.currentcel && canvas.currentcel >= 2
|
||||
cel1 = canvas.currentcel
|
||||
cel2 = pbChooseNum(cel1)
|
||||
if cel2 >= 2 && cel1 != cel2
|
||||
canvas.swapCels(cel1, cel2)
|
||||
end
|
||||
canvas.swapCels(cel1, cel2) if cel2 >= 2 && cel1 != cel2
|
||||
end
|
||||
when 6 # Extrapolate Path
|
||||
if canvas.currentCel
|
||||
@@ -1128,9 +1110,7 @@ def animationEditorMain(animation)
|
||||
indexes = [2, 1, 3, 4] # Keeping backwards compatibility
|
||||
positions.length.times do |i|
|
||||
selected = "[ ]"
|
||||
if animation[animation.selected].position == indexes[i]
|
||||
selected = "[x]"
|
||||
end
|
||||
selected = "[x]" if animation[animation.selected].position == indexes[i]
|
||||
positions[i] = sprintf("%s %s", selected, positions[i])
|
||||
end
|
||||
pos = pbShowCommands(nil, positions, -1)
|
||||
|
||||
Reference in New Issue
Block a user