mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-22 22:36:03 +00:00
Many more Rubocop-inspired code improvements
This commit is contained in:
@@ -25,7 +25,7 @@ class Window_Menu < Window_CommandPokemon
|
||||
end
|
||||
|
||||
def hittest
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
return -1 if !mousepos
|
||||
toprow = self.top_row
|
||||
for i in toprow...toprow + @item_max
|
||||
@@ -51,7 +51,7 @@ module Clipboard
|
||||
|
||||
def self.data
|
||||
return nil if !@data
|
||||
return Marshal::load(@data)
|
||||
return Marshal.load(@data)
|
||||
end
|
||||
|
||||
def self.typekey
|
||||
@@ -131,7 +131,7 @@ def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
|
||||
end
|
||||
|
||||
def pbTrackPopupMenu(commands)
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
return -1 if !mousepos
|
||||
menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1])
|
||||
menuwindow.z = 99999
|
||||
@@ -250,7 +250,7 @@ class AnimationWindow < SpriteWrapper
|
||||
end
|
||||
|
||||
def update
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
@changed = false
|
||||
return if !Input.repeat?(Input::MOUSELEFT)
|
||||
return if !mousepos
|
||||
@@ -795,7 +795,7 @@ class AnimationCanvas < Sprite
|
||||
|
||||
def updateInput
|
||||
cel = currentCel
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
if mousepos && pbSpriteHitTest(self, mousepos[0], mousepos[1], false, true)
|
||||
if Input.trigger?(Input::MOUSELEFT) # Left mouse button
|
||||
selectedcel = -1
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
module ShadowText
|
||||
def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0)
|
||||
width = bitmap.text_size(t).width
|
||||
if align == 2
|
||||
case align
|
||||
when 2
|
||||
x += (w - width)
|
||||
elsif align == 1
|
||||
when 1
|
||||
x += (w / 2) - (width / 2)
|
||||
end
|
||||
pbDrawShadowText(bitmap, x, y, w, h, t,
|
||||
@@ -120,7 +121,7 @@ class Button < UIControl
|
||||
end
|
||||
|
||||
def update
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
self.changed = false
|
||||
return if !mousepos
|
||||
rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2)
|
||||
@@ -385,7 +386,7 @@ class Slider < UIControl
|
||||
end
|
||||
|
||||
def update
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
self.changed = false
|
||||
if self.minvalue < self.maxvalue && self.curvalue < self.minvalue
|
||||
self.curvalue = self.minvalue
|
||||
@@ -401,14 +402,12 @@ class Slider < UIControl
|
||||
if left.contains(mousepos[0], mousepos[1])
|
||||
if repeattime > 2500
|
||||
self.curvalue -= 10
|
||||
self.curvalue = self.curvalue.floor
|
||||
elsif repeattime > 1250
|
||||
self.curvalue -= 5
|
||||
self.curvalue = self.curvalue.floor
|
||||
else
|
||||
self.curvalue -= 1
|
||||
self.curvalue = self.curvalue.floor
|
||||
end
|
||||
self.curvalue = self.curvalue.floor
|
||||
self.changed = (self.curvalue != oldvalue)
|
||||
self.invalidate
|
||||
end
|
||||
@@ -416,14 +415,12 @@ class Slider < UIControl
|
||||
if right.contains(mousepos[0], mousepos[1])
|
||||
if repeattime > 2500
|
||||
self.curvalue += 10
|
||||
self.curvalue = self.curvalue.floor
|
||||
elsif repeattime > 1250
|
||||
self.curvalue += 5
|
||||
self.curvalue = self.curvalue.floor
|
||||
else
|
||||
self.curvalue += 1
|
||||
self.curvalue = self.curvalue.floor
|
||||
end
|
||||
self.curvalue = self.curvalue.floor
|
||||
self.changed = (self.curvalue != oldvalue)
|
||||
self.invalidate
|
||||
end
|
||||
@@ -634,7 +631,7 @@ class TextSlider < UIControl
|
||||
end
|
||||
|
||||
def update
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
self.changed = false
|
||||
if self.minvalue < self.maxvalue && self.curvalue < self.minvalue
|
||||
self.curvalue = self.minvalue
|
||||
@@ -832,7 +829,7 @@ class ControlWindow < SpriteWindow_Base
|
||||
end
|
||||
|
||||
def hittest?(i)
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
return false if !mousepos
|
||||
return false if i < 0 || i >= @controls.length
|
||||
rc = Rect.new(
|
||||
|
||||
@@ -24,7 +24,7 @@ class ControlPointSprite < SpriteWrapper
|
||||
@dragging = false
|
||||
return
|
||||
end
|
||||
mouse = Mouse::getMousePos(true)
|
||||
mouse = Mouse.getMousePos(true)
|
||||
return if !mouse
|
||||
self.x = [[mouse[0], 0].max, 512].min
|
||||
self.y = [[mouse[1], 0].max, 384].min
|
||||
@@ -32,7 +32,7 @@ class ControlPointSprite < SpriteWrapper
|
||||
|
||||
def hittest?
|
||||
return true if !self.visible
|
||||
mouse = Mouse::getMousePos(true)
|
||||
mouse = Mouse.getMousePos(true)
|
||||
return false if !mouse
|
||||
return mouse[0] >= self.x && mouse[0] < self.x + 6 &&
|
||||
mouse[1] >= self.y && mouse[1] < self.y + 6
|
||||
@@ -294,7 +294,7 @@ def pbDefinePath(canvas)
|
||||
if Input.trigger?(Input::MOUSELEFT)
|
||||
for j in 0...4
|
||||
next if !curve[j].hittest?
|
||||
if j == 1 || j == 2
|
||||
if [1, 2].include?(j)
|
||||
next if !curve[0].visible || !curve[3].visible
|
||||
end
|
||||
curve[j].visible = true
|
||||
@@ -307,7 +307,7 @@ def pbDefinePath(canvas)
|
||||
for j in 0...4
|
||||
curve[j].mouseover
|
||||
end
|
||||
mousepos = Mouse::getMousePos(true)
|
||||
mousepos = Mouse.getMousePos(true)
|
||||
newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
|
||||
if window.text != newtext
|
||||
window.text = newtext
|
||||
@@ -376,11 +376,11 @@ def pbDefinePath(canvas)
|
||||
if Input.trigger?(Input::MOUSELEFT)
|
||||
break
|
||||
end
|
||||
mousepos = Mouse::getMousePos(true)
|
||||
mousepos = Mouse.getMousePos(true)
|
||||
window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
|
||||
end
|
||||
while !canceled
|
||||
mousepos = Mouse::getMousePos(true)
|
||||
mousepos = Mouse.getMousePos(true)
|
||||
if mousepos && !pointpath.isEndPoint?(mousepos[0], mousepos[1])
|
||||
pointpath.addPoint(mousepos[0], mousepos[1])
|
||||
points.push(PointSprite.new(mousepos[0], mousepos[1], canvas.viewport))
|
||||
|
||||
@@ -102,11 +102,12 @@ def pbConvertAnimToNewFormat(textdata)
|
||||
for j in 0...PBAnimation::MAX_SPRITES
|
||||
next if !textdata[i][j]
|
||||
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil
|
||||
if j == 0 # User battler
|
||||
case j
|
||||
when 0 # User battler
|
||||
textdata[i][j][AnimFrame::FOCUS] = 2
|
||||
textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSUSER_X
|
||||
textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSUSER_Y
|
||||
elsif j == 1 # Target battler
|
||||
when 1 # Target battler
|
||||
textdata[i][j][AnimFrame::FOCUS] = 1
|
||||
textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSTARGET_X
|
||||
textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSTARGET_Y
|
||||
|
||||
@@ -158,15 +158,16 @@ def pbAnimList(animations, canvas, animwin)
|
||||
_INTL("Rename"),
|
||||
_INTL("Delete")
|
||||
], -1)
|
||||
if cmd2 == 0 # Load Animation
|
||||
case cmd2
|
||||
when 0 # Load Animation
|
||||
canvas.loadAnimation(animations[cmdwin.index])
|
||||
animwin.animbitmap = canvas.animbitmap
|
||||
animations.selected = cmdwin.index
|
||||
break
|
||||
elsif cmd2 == 1 # Rename
|
||||
when 1 # Rename
|
||||
pbAnimName(animations[cmdwin.index], cmdwin)
|
||||
cmdwin.refresh
|
||||
elsif cmd2 == 2 # Delete
|
||||
when 2 # Delete
|
||||
if pbConfirmMessage(_INTL("Are you sure you want to delete this animation?"))
|
||||
animations[cmdwin.index] = PBAnimation.new
|
||||
cmdwin.commands[cmdwin.index] = _INTL("{1} {2}", cmdwin.index, animations[cmdwin.index].name)
|
||||
@@ -683,10 +684,8 @@ def pbEditBG(canvas, timing)
|
||||
timing.colorBlue = maxsizewindow.value(6)
|
||||
timing.colorAlpha = maxsizewindow.value(7)
|
||||
ret = true
|
||||
break
|
||||
else
|
||||
break
|
||||
end
|
||||
break
|
||||
end
|
||||
if maxsizewindow.changed?(9) # Cancel
|
||||
break
|
||||
@@ -1064,7 +1063,7 @@ def animationEditorMain(animation)
|
||||
end
|
||||
next
|
||||
elsif Input.trigger?(Input::MOUSERIGHT) # Right mouse button
|
||||
mousepos = Mouse::getMousePos
|
||||
mousepos = Mouse.getMousePos
|
||||
mousepos = [0, 0] if !mousepos
|
||||
commands = [
|
||||
_INTL("Properties..."),
|
||||
@@ -1187,7 +1186,7 @@ end
|
||||
# Start
|
||||
################################################################################
|
||||
def pbAnimationEditor
|
||||
pbBGMStop()
|
||||
pbBGMStop
|
||||
animation = pbLoadBattleAnimations
|
||||
if !animation || !animation[0]
|
||||
animation = PBAnimations.new
|
||||
|
||||
Reference in New Issue
Block a user