mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added decent spacing to all scripts thanks to Rubocop
This commit is contained in:
@@ -10,22 +10,22 @@ def pbGetLegalMoves(species)
|
||||
return moves
|
||||
end
|
||||
|
||||
def pbSafeCopyFile(x,y,z = nil)
|
||||
def pbSafeCopyFile(x, y, z = nil)
|
||||
if safeExists?(x)
|
||||
safetocopy = true
|
||||
filedata = nil
|
||||
if safeExists?(y)
|
||||
different = false
|
||||
if FileTest.size(x)!=FileTest.size(y)
|
||||
if FileTest.size(x) != FileTest.size(y)
|
||||
different = true
|
||||
else
|
||||
filedata2 = ""
|
||||
File.open(x,"rb") { |f| filedata = f.read }
|
||||
File.open(y,"rb") { |f| filedata2 = f.read }
|
||||
different = true if filedata!=filedata2
|
||||
File.open(x, "rb") { |f| filedata = f.read }
|
||||
File.open(y, "rb") { |f| filedata2 = f.read }
|
||||
different = true if filedata != filedata2
|
||||
end
|
||||
if different
|
||||
safetocopy=pbConfirmMessage(_INTL("A different file named '{1}' already exists. Overwrite it?",y))
|
||||
safetocopy = pbConfirmMessage(_INTL("A different file named '{1}' already exists. Overwrite it?", y))
|
||||
else
|
||||
# No need to copy
|
||||
return
|
||||
@@ -33,14 +33,14 @@ def pbSafeCopyFile(x,y,z = nil)
|
||||
end
|
||||
if safetocopy
|
||||
if !filedata
|
||||
File.open(x,"rb") { |f| filedata = f.read }
|
||||
File.open(x, "rb") { |f| filedata = f.read }
|
||||
end
|
||||
File.open((z) ? z : y,"wb") { |f| f.write(filedata) }
|
||||
File.open((z) ? z : y, "wb") { |f| f.write(filedata) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbAllocateAnimation(animations,name)
|
||||
def pbAllocateAnimation(animations, name)
|
||||
for i in 1...animations.length
|
||||
anim = animations[i]
|
||||
return i if !anim
|
||||
@@ -48,7 +48,7 @@ def pbAllocateAnimation(animations,name)
|
||||
# # use animation with same name
|
||||
# return i
|
||||
# end
|
||||
if anim.length==1 && anim[0].length==2 && anim.name==""
|
||||
if anim.length == 1 && anim[0].length == 2 && anim.name == ""
|
||||
# assume empty
|
||||
return i
|
||||
end
|
||||
@@ -69,36 +69,36 @@ def pbMapTree
|
||||
info = mapinfos[info.parent_id]
|
||||
level += 1
|
||||
end
|
||||
if level>=0
|
||||
if level >= 0
|
||||
info = mapinfos[i]
|
||||
maplevels.push([i,level,info.parent_id,info.order])
|
||||
maplevels.push([i, level, info.parent_id, info.order])
|
||||
end
|
||||
end
|
||||
maplevels.sort! { |a,b|
|
||||
next a[1]<=>b[1] if a[1]!=b[1] # level
|
||||
next a[2]<=>b[2] if a[2]!=b[2] # parent ID
|
||||
next a[3]<=>b[3] # order
|
||||
maplevels.sort! { |a, b|
|
||||
next a[1] <=> b[1] if a[1] != b[1] # level
|
||||
next a[2] <=> b[2] if a[2] != b[2] # parent ID
|
||||
next a[3] <=> b[3] # order
|
||||
}
|
||||
stack = []
|
||||
stack.push(0,0)
|
||||
while stack.length>0
|
||||
parent = stack[stack.length-1]
|
||||
index = stack[stack.length-2]
|
||||
if index>=maplevels.length
|
||||
stack.push(0, 0)
|
||||
while stack.length > 0
|
||||
parent = stack[stack.length - 1]
|
||||
index = stack[stack.length - 2]
|
||||
if index >= maplevels.length
|
||||
stack.pop
|
||||
stack.pop
|
||||
next
|
||||
end
|
||||
maplevel = maplevels[index]
|
||||
stack[stack.length-2] += 1
|
||||
if maplevel[2]!=parent
|
||||
stack[stack.length - 2] += 1
|
||||
if maplevel[2] != parent
|
||||
stack.pop
|
||||
stack.pop
|
||||
next
|
||||
end
|
||||
retarray.push([maplevel[0],mapinfos[maplevel[0]].name,maplevel[1]])
|
||||
for i in index+1...maplevels.length
|
||||
if maplevels[i][2]==maplevel[0]
|
||||
retarray.push([maplevel[0], mapinfos[maplevel[0]].name, maplevel[1]])
|
||||
for i in index + 1...maplevels.length
|
||||
if maplevels[i][2] == maplevel[0]
|
||||
stack.push(i)
|
||||
stack.push(maplevel[0])
|
||||
break
|
||||
@@ -245,17 +245,17 @@ end
|
||||
#===============================================================================
|
||||
# General list methods
|
||||
#===============================================================================
|
||||
def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = false)
|
||||
def pbCommands2(cmdwindow, commands, cmdIfCancel, defaultindex = -1, noresize = false)
|
||||
cmdwindow.commands = commands
|
||||
cmdwindow.index = defaultindex if defaultindex>=0
|
||||
cmdwindow.index = defaultindex if defaultindex >= 0
|
||||
cmdwindow.x = 0
|
||||
cmdwindow.y = 0
|
||||
if noresize
|
||||
cmdwindow.height = Graphics.height
|
||||
else
|
||||
cmdwindow.width = Graphics.width/2
|
||||
cmdwindow.width = Graphics.width / 2
|
||||
end
|
||||
cmdwindow.height = Graphics.height if cmdwindow.height>Graphics.height
|
||||
cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height
|
||||
cmdwindow.z = 99999
|
||||
cmdwindow.visible = true
|
||||
cmdwindow.active = true
|
||||
@@ -265,10 +265,10 @@ def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = fals
|
||||
Input.update
|
||||
cmdwindow.update
|
||||
if Input.trigger?(Input::BACK)
|
||||
if cmdIfCancel>0
|
||||
command = cmdIfCancel-1
|
||||
if cmdIfCancel > 0
|
||||
command = cmdIfCancel - 1
|
||||
break
|
||||
elsif cmdIfCancel<0
|
||||
elsif cmdIfCancel < 0
|
||||
command = cmdIfCancel
|
||||
break
|
||||
end
|
||||
@@ -282,17 +282,17 @@ def pbCommands2(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = fals
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = false)
|
||||
def pbCommands3(cmdwindow, commands, cmdIfCancel, defaultindex = -1, noresize = false)
|
||||
cmdwindow.commands = commands
|
||||
cmdwindow.index = defaultindex if defaultindex>=0
|
||||
cmdwindow.index = defaultindex if defaultindex >= 0
|
||||
cmdwindow.x = 0
|
||||
cmdwindow.y = 0
|
||||
if noresize
|
||||
cmdwindow.height = Graphics.height
|
||||
else
|
||||
cmdwindow.width = Graphics.width/2
|
||||
cmdwindow.width = Graphics.width / 2
|
||||
end
|
||||
cmdwindow.height = Graphics.height if cmdwindow.height>Graphics.height
|
||||
cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height
|
||||
cmdwindow.z = 99999
|
||||
cmdwindow.visible = true
|
||||
cmdwindow.active = true
|
||||
@@ -302,32 +302,32 @@ def pbCommands3(cmdwindow,commands,cmdIfCancel,defaultindex = -1,noresize = fals
|
||||
Input.update
|
||||
cmdwindow.update
|
||||
if Input.trigger?(Input::SPECIAL)
|
||||
command = [5,cmdwindow.index]
|
||||
command = [5, cmdwindow.index]
|
||||
break
|
||||
elsif Input.press?(Input::ACTION)
|
||||
if Input.repeat?(Input::UP)
|
||||
command = [1,cmdwindow.index]
|
||||
command = [1, cmdwindow.index]
|
||||
break
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
command = [2,cmdwindow.index]
|
||||
command = [2, cmdwindow.index]
|
||||
break
|
||||
elsif Input.trigger?(Input::LEFT)
|
||||
command = [3,cmdwindow.index]
|
||||
command = [3, cmdwindow.index]
|
||||
break
|
||||
elsif Input.trigger?(Input::RIGHT)
|
||||
command = [4,cmdwindow.index]
|
||||
command = [4, cmdwindow.index]
|
||||
break
|
||||
end
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
if cmdIfCancel>0
|
||||
command = [0,cmdIfCancel-1]
|
||||
if cmdIfCancel > 0
|
||||
command = [0, cmdIfCancel - 1]
|
||||
break
|
||||
elsif cmdIfCancel<0
|
||||
command = [0,cmdIfCancel]
|
||||
elsif cmdIfCancel < 0
|
||||
command = [0, cmdIfCancel]
|
||||
break
|
||||
end
|
||||
elsif Input.trigger?(Input::USE)
|
||||
command = [0,cmdwindow.index]
|
||||
command = [0, cmdwindow.index]
|
||||
break
|
||||
end
|
||||
end
|
||||
@@ -378,7 +378,7 @@ def pbChooseList(commands, default = 0, cancelValue = -1, sortType = 1)
|
||||
return itemID
|
||||
end
|
||||
|
||||
def pbCommandsSortable(cmdwindow,commands,cmdIfCancel,defaultindex = -1,sortable = false)
|
||||
def pbCommandsSortable(cmdwindow, commands, cmdIfCancel, defaultindex = -1, sortable = false)
|
||||
cmdwindow.commands = commands
|
||||
cmdwindow.index = defaultindex if defaultindex >= 0
|
||||
cmdwindow.x = 0
|
||||
@@ -393,13 +393,13 @@ def pbCommandsSortable(cmdwindow,commands,cmdIfCancel,defaultindex = -1,sortable
|
||||
Input.update
|
||||
cmdwindow.update
|
||||
if Input.trigger?(Input::ACTION) && sortable
|
||||
command = [1,cmdwindow.index]
|
||||
command = [1, cmdwindow.index]
|
||||
break
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
command = [0,(cmdIfCancel>0) ? cmdIfCancel-1 : cmdIfCancel]
|
||||
command = [0, (cmdIfCancel > 0) ? cmdIfCancel - 1 : cmdIfCancel]
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
command = [0,cmdwindow.index]
|
||||
command = [0, cmdwindow.index]
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user