Added decent spacing to all scripts thanks to Rubocop

This commit is contained in:
Maruno17
2021-12-18 15:25:40 +00:00
parent f7b76ae62e
commit d17fc40a47
207 changed files with 18577 additions and 18587 deletions

View File

@@ -620,7 +620,7 @@ end
# Trainer Pokémon editor
#===============================================================================
module TrainerPokemonProperty
def self.set(settingname,initsetting)
def self.set(settingname, initsetting)
initsetting = { :species => nil, :level => 10 } if !initsetting
oldsetting = [
initsetting[:species],
@@ -1248,7 +1248,7 @@ def pbRegionalDexEditor(dex)
end
else # Cancel
case pbMessage(_INTL("Save changes?"),
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3)
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
when 0 # Save all changes to Dex
dex.slice!(-1) while !dex[-1]
ret = dex
@@ -1400,7 +1400,7 @@ def pbEvoFamiliesToStrings
for fam in 0...families.length
string = ""
for p in 0...families[fam].length
if p>=3
if p >= 3
string += " + #{families[fam].length - 3} more"
break
end
@@ -1423,7 +1423,7 @@ def pbAnimationsOrganiser
pbMessage(_INTL("No animations exist."))
return
end
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
cmdwin = pbListWindow([])
cmdwin.viewport = viewport
@@ -1437,43 +1437,43 @@ def pbAnimationsOrganiser
commands = []
refreshlist = true
oldsel = -1
cmd = [0,0]
cmd = [0, 0]
loop do
if refreshlist
commands = []
for i in 0...list.length
commands.push(sprintf("%d: %s",i,(list[i]) ? list[i].name : "???"))
commands.push(sprintf("%d: %s", i, (list[i]) ? list[i].name : "???"))
end
end
refreshlist = false
oldsel = -1
cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true)
if cmd[0]==1 # Swap animation up
if cmd[1]>=0 && cmd[1]<commands.length-1
list[cmd[1]+1],list[cmd[1]] = list[cmd[1]],list[cmd[1]+1]
cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true)
if cmd[0] == 1 # Swap animation up
if cmd[1] >= 0 && cmd[1] < commands.length - 1
list[cmd[1] + 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] + 1]
refreshlist = true
end
elsif cmd[0]==2 # Swap animation down
if cmd[1]>0
list[cmd[1]-1],list[cmd[1]] = list[cmd[1]],list[cmd[1]-1]
elsif cmd[0] == 2 # Swap animation down
if cmd[1] > 0
list[cmd[1] - 1], list[cmd[1]] = list[cmd[1]], list[cmd[1] - 1]
refreshlist = true
end
elsif cmd[0]==3 # Delete spot
elsif cmd[0] == 3 # Delete spot
list.delete_at(cmd[1])
cmd[1] = [cmd[1],list.length-1].min
cmd[1] = [cmd[1], list.length - 1].min
refreshlist = true
pbWait(Graphics.frame_rate*2/10)
elsif cmd[0]==4 # Insert spot
list.insert(cmd[1],PBAnimation.new)
pbWait(Graphics.frame_rate * 2 / 10)
elsif cmd[0] == 4 # Insert spot
list.insert(cmd[1], PBAnimation.new)
refreshlist = true
pbWait(Graphics.frame_rate*2/10)
elsif cmd[0]==0
pbWait(Graphics.frame_rate * 2 / 10)
elsif cmd[0] == 0
cmd2 = pbMessage(_INTL("Save changes?"),
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3)
if cmd2==0 || cmd2==1
if cmd2==0
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd2 == 0 || cmd2 == 1
if cmd2 == 0
# Save animations here
save_data(list,"Data/PkmnAnimations.rxdata")
save_data(list, "Data/PkmnAnimations.rxdata")
$game_temp.battle_animations_data = nil
pbMessage(_INTL("Data saved."))
end

View File

@@ -2,11 +2,11 @@
# Miniature game map drawing
#===============================================================================
class MapSprite
def initialize(map,viewport = nil)
@sprite=Sprite.new(viewport)
@sprite.bitmap=createMinimap(map)
@sprite.x=(Graphics.width/2)-(@sprite.bitmap.width/2)
@sprite.y=(Graphics.height/2)-(@sprite.bitmap.height/2)
def initialize(map, viewport = nil)
@sprite = Sprite.new(viewport)
@sprite.bitmap = createMinimap(map)
@sprite.x = (Graphics.width / 2) - (@sprite.bitmap.width / 2)
@sprite.y = (Graphics.height / 2) - (@sprite.bitmap.height / 2)
end
def dispose
@@ -15,22 +15,22 @@ class MapSprite
end
def z=(value)
@sprite.z=value
@sprite.z = value
end
def getXY
return nil if !Input.trigger?(Input::MOUSELEFT)
mouse = Mouse::getMousePos(true)
return nil if !mouse
if mouse[0]<@sprite.x || mouse[0]>=@sprite.x+@sprite.bitmap.width
if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width
return nil
end
if mouse[1]<@sprite.y || mouse[1]>=@sprite.y+@sprite.bitmap.height
if mouse[1] < @sprite.y || mouse[1] >= @sprite.y + @sprite.bitmap.height
return nil
end
x = mouse[0]-@sprite.x
y = mouse[1]-@sprite.y
return [x/4,y/4]
x = mouse[0] - @sprite.x
y = mouse[1] - @sprite.y
return [x / 4, y / 4]
end
end
@@ -39,10 +39,10 @@ end
#===============================================================================
class SelectionSprite < Sprite
def initialize(viewport = nil)
@sprite=Sprite.new(viewport)
@sprite.bitmap=nil
@sprite.z=2
@othersprite=nil
@sprite = Sprite.new(viewport)
@sprite.bitmap = nil
@sprite.z = 2
@othersprite = nil
end
def disposed?
@@ -51,34 +51,34 @@ class SelectionSprite < Sprite
def dispose
@sprite.bitmap.dispose if @sprite.bitmap
@othersprite=nil
@othersprite = nil
@sprite.dispose
end
def othersprite=(value)
@othersprite=value
@othersprite = value
if @othersprite && !@othersprite.disposed? &&
@othersprite.bitmap && !@othersprite.bitmap.disposed?
@sprite.bitmap=pbDoEnsureBitmap(
@sprite.bitmap,@othersprite.bitmap.width,@othersprite.bitmap.height)
red=Color.new(255,0,0)
@sprite.bitmap = pbDoEnsureBitmap(
@sprite.bitmap, @othersprite.bitmap.width, @othersprite.bitmap.height)
red = Color.new(255, 0, 0)
@sprite.bitmap.clear
@sprite.bitmap.fill_rect(0,0,@othersprite.bitmap.width,2,red)
@sprite.bitmap.fill_rect(0,@othersprite.bitmap.height-2,
@othersprite.bitmap.width,2,red)
@sprite.bitmap.fill_rect(0,0,2,@othersprite.bitmap.height,red)
@sprite.bitmap.fill_rect(@othersprite.bitmap.width-2,0,2,
@othersprite.bitmap.height,red)
@sprite.bitmap.fill_rect(0, 0, @othersprite.bitmap.width, 2, red)
@sprite.bitmap.fill_rect(0, @othersprite.bitmap.height - 2,
@othersprite.bitmap.width, 2, red)
@sprite.bitmap.fill_rect(0, 0, 2, @othersprite.bitmap.height, red)
@sprite.bitmap.fill_rect(@othersprite.bitmap.width - 2, 0, 2,
@othersprite.bitmap.height, red)
end
end
def update
if @othersprite && !@othersprite.disposed?
@sprite.visible=@othersprite.visible
@sprite.x=@othersprite.x
@sprite.y=@othersprite.y
@sprite.visible = @othersprite.visible
@sprite.x = @othersprite.x
@sprite.y = @othersprite.y
else
@sprite.visible=false
@sprite.visible = false
end
end
end
@@ -87,11 +87,11 @@ end
#
#===============================================================================
class RegionMapSprite
def initialize(map,viewport = nil)
@sprite=Sprite.new(viewport)
@sprite.bitmap=createRegionMap(map)
@sprite.x=(Graphics.width/2)-(@sprite.bitmap.width/2)
@sprite.y=(Graphics.height/2)-(@sprite.bitmap.height/2)
def initialize(map, viewport = nil)
@sprite = Sprite.new(viewport)
@sprite.bitmap = createRegionMap(map)
@sprite.x = (Graphics.width / 2) - (@sprite.bitmap.width / 2)
@sprite.y = (Graphics.height / 2) - (@sprite.bitmap.height / 2)
end
def dispose
@@ -100,18 +100,18 @@ class RegionMapSprite
end
def z=(value)
@sprite.z=value
@sprite.z = value
end
def createRegionMap(map)
@mapdata = pbLoadTownMapData
@map=@mapdata[map]
bitmap=AnimatedBitmap.new("Graphics/Pictures/#{@map[1]}").deanimate
retbitmap=BitmapWrapper.new(bitmap.width/2,bitmap.height/2)
@map = @mapdata[map]
bitmap = AnimatedBitmap.new("Graphics/Pictures/#{@map[1]}").deanimate
retbitmap = BitmapWrapper.new(bitmap.width / 2, bitmap.height / 2)
retbitmap.stretch_blt(
Rect.new(0,0,bitmap.width/2,bitmap.height/2),
Rect.new(0, 0, bitmap.width / 2, bitmap.height / 2),
bitmap,
Rect.new(0,0,bitmap.width,bitmap.height)
Rect.new(0, 0, bitmap.width, bitmap.height)
)
bitmap.dispose
return retbitmap
@@ -119,17 +119,17 @@ class RegionMapSprite
def getXY
return nil if !Input.trigger?(Input::MOUSELEFT)
mouse=Mouse::getMousePos(true)
mouse = Mouse::getMousePos(true)
return nil if !mouse
if mouse[0]<@sprite.x||mouse[0]>=@sprite.x+@sprite.bitmap.width
if mouse[0] < @sprite.x || mouse[0] >= @sprite.x + @sprite.bitmap.width
return nil
end
if mouse[1]<@sprite.y||mouse[1]>=@sprite.y+@sprite.bitmap.height
if mouse[1] < @sprite.y || mouse[1] >= @sprite.y + @sprite.bitmap.height
return nil
end
x=mouse[0]-@sprite.x
y=mouse[1]-@sprite.y
return [x/8,y/8]
x = mouse[0] - @sprite.x
y = mouse[1] - @sprite.y
return [x / 8, y / 8]
end
end
@@ -139,12 +139,12 @@ end
class MapScreenScene
def getMapSprite(id)
if !@mapsprites[id]
@mapsprites[id]=Sprite.new(@viewport)
@mapsprites[id].z=0
@mapsprites[id].bitmap=nil
@mapsprites[id] = Sprite.new(@viewport)
@mapsprites[id].z = 0
@mapsprites[id].bitmap = nil
end
if !@mapsprites[id].bitmap || @mapsprites[id].bitmap.disposed?
@mapsprites[id].bitmap=createMinimap(id)
@mapsprites[id].bitmap = createMinimap(id)
end
return @mapsprites[id]
end
@@ -155,64 +155,64 @@ class MapScreenScene
@viewport.dispose
end
def setMapSpritePos(id,x,y)
sprite=getMapSprite(id)
sprite.x=x
sprite.y=y
sprite.visible=true
def setMapSpritePos(id, x, y)
sprite = getMapSprite(id)
sprite.x = x
sprite.y = y
sprite.visible = true
end
def putNeighbors(id,sprites)
conns=@mapconns
mapsprite=getMapSprite(id)
dispx=mapsprite.x
dispy=mapsprite.y
def putNeighbors(id, sprites)
conns = @mapconns
mapsprite = getMapSprite(id)
dispx = mapsprite.x
dispy = mapsprite.y
for conn in conns
if conn[0]==id
b=sprites.any? { |i| i==conn[3] }
if conn[0] == id
b = sprites.any? { |i| i == conn[3] }
if !b
x=(conn[1]-conn[4])*4+dispx
y=(conn[2]-conn[5])*4+dispy
setMapSpritePos(conn[3],x,y)
x = (conn[1] - conn[4]) * 4 + dispx
y = (conn[2] - conn[5]) * 4 + dispy
setMapSpritePos(conn[3], x, y)
sprites.push(conn[3])
putNeighbors(conn[3],sprites)
putNeighbors(conn[3], sprites)
end
elsif conn[3]==id
b=sprites.any? { |i| i==conn[0] }
elsif conn[3] == id
b = sprites.any? { |i| i == conn[0] }
if !b
x=(conn[4]-conn[1])*4+dispx
y=(conn[5]-conn[2])*4+dispy
setMapSpritePos(conn[0],x,y)
x = (conn[4] - conn[1]) * 4 + dispx
y = (conn[5] - conn[2]) * 4 + dispy
setMapSpritePos(conn[0], x, y)
sprites.push(conn[3])
putNeighbors(conn[0],sprites)
putNeighbors(conn[0], sprites)
end
end
end
end
def hasConnections?(conns,id)
def hasConnections?(conns, id)
for conn in conns
return true if conn[0]==id || conn[3]==id
return true if conn[0] == id || conn[3] == id
end
return false
end
def connectionsSymmetric?(conn1,conn2)
if conn1[0]==conn2[0]
def connectionsSymmetric?(conn1, conn2)
if conn1[0] == conn2[0]
# Equality
return false if conn1[1]!=conn2[1]
return false if conn1[2]!=conn2[2]
return false if conn1[3]!=conn2[3]
return false if conn1[4]!=conn2[4]
return false if conn1[5]!=conn2[5]
return false if conn1[1] != conn2[1]
return false if conn1[2] != conn2[2]
return false if conn1[3] != conn2[3]
return false if conn1[4] != conn2[4]
return false if conn1[5] != conn2[5]
return true
elsif conn1[0]==conn2[3]
elsif conn1[0] == conn2[3]
# Symmetry
return false if conn1[1]!=-conn2[1]
return false if conn1[2]!=-conn2[2]
return false if conn1[3]!=conn2[0]
return false if conn1[4]!=-conn2[4]
return false if conn1[5]!=-conn2[5]
return false if conn1[1] != -conn2[1]
return false if conn1[2] != -conn2[2]
return false if conn1[3] != conn2[0]
return false if conn1[4] != -conn2[4]
return false if conn1[5] != -conn2[5]
return true
end
return false
@@ -223,55 +223,55 @@ class MapScreenScene
end
# Returns the maps within _keys_ that are directly connected to this map, _map_.
def getDirectConnections(keys,map)
thissprite=getMapSprite(map)
thisdims=MapFactoryHelper.getMapDims(map)
ret=[]
def getDirectConnections(keys, map)
thissprite = getMapSprite(map)
thisdims = MapFactoryHelper.getMapDims(map)
ret = []
for i in keys
next if i==map
othersprite=getMapSprite(i)
otherdims=MapFactoryHelper.getMapDims(i)
x1=(thissprite.x-othersprite.x)/4
y1=(thissprite.y-othersprite.y)/4
if (x1==otherdims[0] || x1==-thisdims[0] ||
y1==otherdims[1] || y1==-thisdims[1])
next if i == map
othersprite = getMapSprite(i)
otherdims = MapFactoryHelper.getMapDims(i)
x1 = (thissprite.x - othersprite.x) / 4
y1 = (thissprite.y - othersprite.y) / 4
if (x1 == otherdims[0] || x1 == -thisdims[0] ||
y1 == otherdims[1] || y1 == -thisdims[1])
ret.push(i)
end
end
# If no direct connections, add an indirect connection
if ret.length==0
key=(map==keys[0]) ? keys[1] : keys[0]
if ret.length == 0
key = (map == keys[0]) ? keys[1] : keys[0]
ret.push(key)
end
return ret
end
def generateConnectionData
ret=[]
ret = []
# Create a clone of current map connection
for conn in @mapconns
ret.push(conn.clone)
end
keys=@mapsprites.keys
return ret if keys.length<2
keys = @mapsprites.keys
return ret if keys.length < 2
# Remove all connections containing any sprites on the canvas from the array
for i in keys
removeOldConnections(ret,i)
removeOldConnections(ret, i)
end
# Rebuild connections
for i in keys
refs=getDirectConnections(keys,i)
refs = getDirectConnections(keys, i)
for refmap in refs
othersprite=getMapSprite(i)
refsprite=getMapSprite(refmap)
c1=(refsprite.x-othersprite.x)/4
c2=(refsprite.y-othersprite.y)/4
conn=[refmap,0,0,i,c1,c2]
j=0
while j<ret.length && !connectionsSymmetric?(ret[j],conn)
j+=1
othersprite = getMapSprite(i)
refsprite = getMapSprite(refmap)
c1 = (refsprite.x - othersprite.x) / 4
c2 = (refsprite.y - othersprite.y) / 4
conn = [refmap, 0, 0, i, c1, c2]
j = 0
while j < ret.length && !connectionsSymmetric?(ret[j], conn)
j += 1
end
if j==ret.length
if j == ret.length
ret.push(conn)
end
end
@@ -280,56 +280,56 @@ class MapScreenScene
end
def serializeConnectionData
conndata=generateConnectionData()
conndata = generateConnectionData()
save_data(conndata, "Data/map_connections.dat")
Compiler.write_connections
@mapconns=conndata
@mapconns = conndata
end
def putSprite(id)
addSprite(id)
putNeighbors(id,[])
putNeighbors(id, [])
end
def addSprite(id)
mapsprite=getMapSprite(id)
x=(Graphics.width-mapsprite.bitmap.width)/2
y=(Graphics.height-mapsprite.bitmap.height)/2
mapsprite.x=x.to_i&~3
mapsprite.y=y.to_i&~3
mapsprite = getMapSprite(id)
x = (Graphics.width - mapsprite.bitmap.width) / 2
y = (Graphics.height - mapsprite.bitmap.height) / 2
mapsprite.x = x.to_i & ~3
mapsprite.y = y.to_i & ~3
end
def saveMapSpritePos
@mapspritepos.clear
for i in @mapsprites.keys
s=@mapsprites[i]
@mapspritepos[i]=[s.x,s.y] if s && !s.disposed?
s = @mapsprites[i]
@mapspritepos[i] = [s.x, s.y] if s && !s.disposed?
end
end
def mapScreen
@sprites={}
@mapsprites={}
@mapspritepos={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@lasthitmap=-1
@lastclick=-1
@oldmousex=nil
@oldmousey=nil
@dragging=false
@dragmapid=-1
@dragOffsetX=0
@dragOffsetY=0
@selmapid=-1
@sprites = {}
@mapsprites = {}
@mapspritepos = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@lasthitmap = -1
@lastclick = -1
@oldmousex = nil
@oldmousey = nil
@dragging = false
@dragmapid = -1
@dragOffsetX = 0
@dragOffsetY = 0
@selmapid = -1
@sprites["background"] = ColoredPlane.new(Color.new(160, 208, 240), @viewport)
@sprites["selsprite"]=SelectionSprite.new(@viewport)
@sprites["selsprite"] = SelectionSprite.new(@viewport)
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("D: Help"),
0, Graphics.height - 64, Graphics.width, 64, @viewport)
@sprites["title"].z = 2
@mapinfos=pbLoadMapInfos
conns=MapFactoryHelper.getMapConnections
@mapconns=[]
@mapinfos = pbLoadMapInfos
conns = MapFactoryHelper.getMapConnections
@mapconns = []
for map_conns in conns
next if !map_conns
map_conns.each do |c|
@@ -337,9 +337,9 @@ class MapScreenScene
end
end
if $game_map
@currentmap=$game_map.map_id
@currentmap = $game_map.map_id
else
@currentmap=($data_system) ? $data_system.edit_map_id : 1
@currentmap = ($data_system) ? $data_system.edit_map_id : 1
end
putSprite(@currentmap)
end
@@ -351,13 +351,13 @@ class MapScreenScene
end
def helpWindow
helptext=_INTL("A: Add map to canvas\r\n")
helptext+=_INTL("DEL: Delete map from canvas\r\n")
helptext+=_INTL("S: Go to another map\r\n")
helptext+=_INTL("Click to select a map\r\n")
helptext+=_INTL("Double-click: Edit map's metadata\r\n")
helptext+=_INTL("Drag map to move it\r\n")
helptext+=_INTL("Arrow keys/drag canvas: Move around canvas")
helptext = _INTL("A: Add map to canvas\r\n")
helptext += _INTL("DEL: Delete map from canvas\r\n")
helptext += _INTL("S: Go to another map\r\n")
helptext += _INTL("Click to select a map\r\n")
helptext += _INTL("Double-click: Edit map's metadata\r\n")
helptext += _INTL("Drag map to move it\r\n")
helptext += _INTL("Arrow keys/drag canvas: Move around canvas")
title = Window_UnformattedTextPokemon.newWithSize(helptext,
0, 0, Graphics.width * 8 / 10, Graphics.height, @viewport)
title.z = 2
@@ -371,13 +371,13 @@ class MapScreenScene
end
def getMapRect(mapid)
sprite=getMapSprite(mapid)
sprite = getMapSprite(mapid)
if sprite
return [
sprite.x,
sprite.y,
sprite.x+sprite.bitmap.width,
sprite.y+sprite.bitmap.height
sprite.x + sprite.bitmap.width,
sprite.y + sprite.bitmap.height
]
else
return nil
@@ -388,115 +388,115 @@ class MapScreenScene
pbEditMapMetadata(map_id) if map_id > 0
end
def onClick(mapid,x,y)
if @lastclick>0 && Graphics.frame_count - @lastclick < Graphics.frame_rate * 0.5
def onClick(mapid, x, y)
if @lastclick > 0 && Graphics.frame_count - @lastclick < Graphics.frame_rate * 0.5
onDoubleClick(mapid)
@lastclick=-1
@lastclick = -1
else
@lastclick=Graphics.frame_count
if mapid>=0
@dragging=true
@dragmapid=mapid
sprite=getMapSprite(mapid)
@sprites["selsprite"].othersprite=sprite
@selmapid=mapid
@dragOffsetX=sprite.x-x
@dragOffsetY=sprite.y-y
@lastclick = Graphics.frame_count
if mapid >= 0
@dragging = true
@dragmapid = mapid
sprite = getMapSprite(mapid)
@sprites["selsprite"].othersprite = sprite
@selmapid = mapid
@dragOffsetX = sprite.x - x
@dragOffsetY = sprite.y - y
setTopSprite(mapid)
else
@sprites["selsprite"].othersprite=nil
@dragging=true
@dragmapid=mapid
@selmapid=-1
@dragOffsetX=x
@dragOffsetY=y
@sprites["selsprite"].othersprite = nil
@dragging = true
@dragmapid = mapid
@selmapid = -1
@dragOffsetX = x
@dragOffsetY = y
saveMapSpritePos
end
end
end
def onRightClick(mapid,x,y)
def onRightClick(mapid, x, y)
# echoln "rightclick (#{mapid})"
end
def onMouseUp(mapid)
# echoln "mouseup (#{mapid})"
@dragging=false if @dragging
@dragging = false if @dragging
end
def onRightMouseUp(mapid)
# echoln "rightmouseup (#{mapid})"
end
def onMouseOver(mapid,x,y)
def onMouseOver(mapid, x, y)
# echoln "mouseover (#{mapid},#{x},#{y})"
end
def onMouseMove(mapid,x,y)
def onMouseMove(mapid, x, y)
# echoln "mousemove (#{mapid},#{x},#{y})"
if @dragging
if @dragmapid>=0
sprite=getMapSprite(@dragmapid)
x=x+@dragOffsetX
y=y+@dragOffsetY
sprite.x=x&~3
sprite.y=y&~3
@sprites["title"].text=_ISPRINTF("D: Help [{1:03d}: {2:s}]",mapid,@mapinfos[@dragmapid].name)
if @dragmapid >= 0
sprite = getMapSprite(@dragmapid)
x = x + @dragOffsetX
y = y + @dragOffsetY
sprite.x = x & ~3
sprite.y = y & ~3
@sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[@dragmapid].name)
else
xpos=x-@dragOffsetX
ypos=y-@dragOffsetY
xpos = x - @dragOffsetX
ypos = y - @dragOffsetY
for i in @mapspritepos.keys
sprite=getMapSprite(i)
sprite.x=(@mapspritepos[i][0]+xpos)&~3
sprite.y=(@mapspritepos[i][1]+ypos)&~3
sprite = getMapSprite(i)
sprite.x = (@mapspritepos[i][0] + xpos) & ~3
sprite.y = (@mapspritepos[i][1] + ypos) & ~3
end
@sprites["title"].text=_INTL("D: Help")
@sprites["title"].text = _INTL("D: Help")
end
else
if mapid>=0
@sprites["title"].text=_ISPRINTF("D: Help [{1:03d}: {2:s}]",mapid,@mapinfos[mapid].name)
if mapid >= 0
@sprites["title"].text = _ISPRINTF("D: Help [{1:03d}: {2:s}]", mapid, @mapinfos[mapid].name)
else
@sprites["title"].text=_INTL("D: Help")
@sprites["title"].text = _INTL("D: Help")
end
end
end
def hittest(x,y)
def hittest(x, y)
for i in @mapsprites.keys
sx=@mapsprites[i].x
sy=@mapsprites[i].y
sr=sx+@mapsprites[i].bitmap.width
sb=sy+@mapsprites[i].bitmap.height
return i if x>=sx && x<sr && y>=sy && y<sb
sx = @mapsprites[i].x
sy = @mapsprites[i].y
sr = sx + @mapsprites[i].bitmap.width
sb = sy + @mapsprites[i].bitmap.height
return i if x >= sx && x < sr && y >= sy && y < sb
end
return -1
end
def chooseMapScreen(title,currentmap)
return pbListScreen(title,MapLister.new(currentmap))
def chooseMapScreen(title, currentmap)
return pbListScreen(title, MapLister.new(currentmap))
end
def update
mousepos=Mouse::getMousePos
mousepos = Mouse::getMousePos
if mousepos
hitmap=hittest(mousepos[0],mousepos[1])
hitmap = hittest(mousepos[0], mousepos[1])
if Input.trigger?(Input::MOUSELEFT)
onClick(hitmap,mousepos[0],mousepos[1])
onClick(hitmap, mousepos[0], mousepos[1])
elsif Input.trigger?(Input::MOUSERIGHT)
onRightClick(hitmap,mousepos[0],mousepos[1])
onRightClick(hitmap, mousepos[0], mousepos[1])
elsif Input.release?(Input::MOUSELEFT)
onMouseUp(hitmap)
elsif Input.release?(Input::MOUSERIGHT)
onRightMouseUp(hitmap)
else
if @lasthitmap!=hitmap
onMouseOver(hitmap,mousepos[0],mousepos[1])
@lasthitmap=hitmap
if @lasthitmap != hitmap
onMouseOver(hitmap, mousepos[0], mousepos[1])
@lasthitmap = hitmap
end
if @oldmousex!=mousepos[0] || @oldmousey!=mousepos[1]
onMouseMove(hitmap,mousepos[0],mousepos[1])
@oldmousex=mousepos[0]
@oldmousey=mousepos[1]
if @oldmousex != mousepos[0] || @oldmousey != mousepos[1]
onMouseMove(hitmap, mousepos[0], mousepos[1])
@oldmousex = mousepos[0]
@oldmousey = mousepos[1]
end
end
end
@@ -521,30 +521,30 @@ class MapScreenScene
end
end
if Input.triggerex?(:A)
id=chooseMapScreen(_INTL("Add Map"),@currentmap)
if id>0
id = chooseMapScreen(_INTL("Add Map"), @currentmap)
if id > 0
addSprite(id)
setTopSprite(id)
@mapconns=generateConnectionData
@mapconns = generateConnectionData
end
elsif Input.triggerex?(:S)
id=chooseMapScreen(_INTL("Go to Map"),@currentmap)
if id>0
@mapconns=generateConnectionData
id = chooseMapScreen(_INTL("Go to Map"), @currentmap)
if id > 0
@mapconns = generateConnectionData
pbDisposeSpriteHash(@mapsprites)
@mapsprites.clear
@sprites["selsprite"].othersprite=nil
@selmapid=-1
@sprites["selsprite"].othersprite = nil
@selmapid = -1
putSprite(id)
@currentmap=id
@currentmap = id
end
elsif Input.triggerex?(:DELETE)
if @mapsprites.keys.length>1 && @selmapid>=0
if @mapsprites.keys.length > 1 && @selmapid >= 0
@mapsprites[@selmapid].bitmap.dispose
@mapsprites[@selmapid].dispose
@mapsprites.delete(@selmapid)
@sprites["selsprite"].othersprite=nil
@selmapid=-1
@sprites["selsprite"].othersprite = nil
@selmapid = -1
end
elsif Input.triggerex?(:D)
helpWindow

View File

@@ -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

View File

@@ -4,38 +4,38 @@
class ControlPointSprite < SpriteWrapper
attr_accessor :dragging
def initialize(red,viewport = nil)
def initialize(red, viewport = nil)
super(viewport)
self.bitmap=Bitmap.new(6,6)
self.bitmap.fill_rect(0,0,6,1,Color.new(0,0,0))
self.bitmap.fill_rect(0,0,1,6,Color.new(0,0,0))
self.bitmap.fill_rect(0,5,6,1,Color.new(0,0,0))
self.bitmap.fill_rect(5,0,1,6,Color.new(0,0,0))
color=(red) ? Color.new(255,0,0) : Color.new(0,0,0)
self.bitmap.fill_rect(2,2,2,2,color)
self.x=-6
self.y=-6
self.visible=false
@dragging=false
self.bitmap = Bitmap.new(6, 6)
self.bitmap.fill_rect(0, 0, 6, 1, Color.new(0, 0, 0))
self.bitmap.fill_rect(0, 0, 1, 6, Color.new(0, 0, 0))
self.bitmap.fill_rect(0, 5, 6, 1, Color.new(0, 0, 0))
self.bitmap.fill_rect(5, 0, 1, 6, Color.new(0, 0, 0))
color = (red) ? Color.new(255, 0, 0) : Color.new(0, 0, 0)
self.bitmap.fill_rect(2, 2, 2, 2, color)
self.x = -6
self.y = -6
self.visible = false
@dragging = false
end
def mouseover
if Input.time?(Input::MOUSELEFT)==0 || !@dragging
@dragging=false
if Input.time?(Input::MOUSELEFT) == 0 || !@dragging
@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
self.x = [[mouse[0], 0].max, 512].min
self.y = [[mouse[1], 0].max, 384].min
end
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
return mouse[0] >= self.x && mouse[0] < self.x + 6 &&
mouse[1] >= self.y && mouse[1] < self.y + 6
end
def inspect
@@ -51,12 +51,12 @@ end
class PointSprite < SpriteWrapper
def initialize(x,y,viewport = nil)
def initialize(x, y, viewport = nil)
super(viewport)
self.bitmap=Bitmap.new(2,2)
self.bitmap.fill_rect(0,0,2,2,Color.new(0,0,0))
self.x=x
self.y=y
self.bitmap = Bitmap.new(2, 2)
self.bitmap.fill_rect(0, 0, 2, 2, Color.new(0, 0, 0))
self.x = x
self.y = y
end
def dispose
@@ -71,9 +71,9 @@ class PointPath
include Enumerable
def initialize
@points=[]
@distances=[]
@totaldist=0
@points = []
@distances = []
@totaldist = 0
end
def [](x)
@@ -97,86 +97,86 @@ class PointPath
end
def inspect
p=[]
p = []
for point in @points
p.push([point[0].to_i,point[1].to_i])
p.push([point[0].to_i, point[1].to_i])
end
return p.inspect
end
def isEndPoint?(x,y)
return false if @points.length==0
index=@points.length-1
return @points[index][0]==x &&
@points[index][1]==y
def isEndPoint?(x, y)
return false if @points.length == 0
index = @points.length - 1
return @points[index][0] == x &&
@points[index][1] == y
end
def addPoint(x,y)
@points.push([x,y])
if @points.length>1
len=@points.length
dx=@points[len-2][0]-@points[len-1][0]
dy=@points[len-2][1]-@points[len-1][1]
dist=Math.sqrt(dx*dx+dy*dy)
def addPoint(x, y)
@points.push([x, y])
if @points.length > 1
len = @points.length
dx = @points[len - 2][0] - @points[len - 1][0]
dy = @points[len - 2][1] - @points[len - 1][1]
dist = Math.sqrt(dx * dx + dy * dy)
@distances.push(dist)
@totaldist+=dist
@totaldist += dist
end
end
def clear
@points.clear
@distances.clear
@totaldist=0
@totaldist = 0
end
def smoothPointPath(frames,roundValues = false)
if frames<0
def smoothPointPath(frames, roundValues = false)
if frames < 0
raise ArgumentError.new("frames out of range: #{frames}")
end
ret=PointPath.new
if @points.length==0
ret = PointPath.new
if @points.length == 0
return ret
end
step=1.0/frames
t=0.0
(frames+2).times do
point=pointOnPath(t)
step = 1.0 / frames
t = 0.0
(frames + 2).times do
point = pointOnPath(t)
if roundValues
ret.addPoint(point[0].round,point[1].round)
ret.addPoint(point[0].round, point[1].round)
else
ret.addPoint(point[0],point[1])
ret.addPoint(point[0], point[1])
end
t+=step
t=[1.0,t].min
t += step
t = [1.0, t].min
end
return ret
end
def pointOnPath(t)
if t<0 || t>1
if t < 0 || t > 1
raise ArgumentError.new("t out of range for pointOnPath: #{t}")
end
return nil if @points.length==0
ret=@points[@points.length-1].clone
if @points.length==1
return nil if @points.length == 0
ret = @points[@points.length - 1].clone
if @points.length == 1
return ret
end
curdist=0
distForT=@totaldist*t
i=0
curdist = 0
distForT = @totaldist * t
i = 0
for dist in @distances
curdist+=dist
if dist>0.0
if curdist>=distForT
distT=1.0-((curdist-distForT)/dist)
dx=@points[i+1][0]-@points[i][0]
dy=@points[i+1][1]-@points[i][1]
ret=[@points[i][0]+dx*distT,
@points[i][1]+dy*distT]
curdist += dist
if dist > 0.0
if curdist >= distForT
distT = 1.0 - ((curdist - distForT) / dist)
dx = @points[i + 1][0] - @points[i][0]
dy = @points[i + 1][1] - @points[i][1]
ret = [@points[i][0] + dx * distT,
@points[i][1] + dy * distT]
break
end
end
i+=1
i += 1
end
return ret
end
@@ -184,83 +184,83 @@ end
def catmullRom(p1,p2,p3,p4,t)
def catmullRom(p1, p2, p3, p4, t)
# p1=prevPoint, p2=startPoint, p3=endPoint, p4=nextPoint, t is from 0 through 1
t2=t*t
t3=t2*t
return 0.5*(2*p2+t*(p3-p1) +
t2*(2*p1-5*p2+4*p3-p4)+
t3*(p4-3*p3+3*p2-p1))
t2 = t * t
t3 = t2 * t
return 0.5 * (2 * p2 + t * (p3 - p1) +
t2 * (2 * p1 - 5 * p2 + 4 * p3 - p4) +
t3 * (p4 - 3 * p3 + 3 * p2 - p1))
end
def getCatmullRomPoint(src,t)
x=0,y=0
t*=3.0
if t<1.0
x=catmullRom(src[0].x,src[0].x,src[1].x,src[2].x,t)
y=catmullRom(src[0].y,src[0].y,src[1].y,src[2].y,t)
elsif t<2.0
t-=1.0
x=catmullRom(src[0].x,src[1].x,src[2].x,src[3].x,t)
y=catmullRom(src[0].y,src[1].y,src[2].y,src[3].y,t)
def getCatmullRomPoint(src, t)
x = 0, y = 0
t *= 3.0
if t < 1.0
x = catmullRom(src[0].x, src[0].x, src[1].x, src[2].x, t)
y = catmullRom(src[0].y, src[0].y, src[1].y, src[2].y, t)
elsif t < 2.0
t -= 1.0
x = catmullRom(src[0].x, src[1].x, src[2].x, src[3].x, t)
y = catmullRom(src[0].y, src[1].y, src[2].y, src[3].y, t)
else
t-=2.0
x=catmullRom(src[1].x,src[2].x,src[3].x,src[3].x,t)
y=catmullRom(src[1].y,src[2].y,src[3].y,src[3].y,t)
t -= 2.0
x = catmullRom(src[1].x, src[2].x, src[3].x, src[3].x, t)
y = catmullRom(src[1].y, src[2].y, src[3].y, src[3].y, t)
end
return [x,y]
return [x, y]
end
def getCurvePoint(src,t)
return getCatmullRomPoint(src,t)
def getCurvePoint(src, t)
return getCatmullRomPoint(src, t)
end
def curveToPointPath(curve,numpoints)
if numpoints<2
def curveToPointPath(curve, numpoints)
if numpoints < 2
return nil
end
path=PointPath.new
step=1.0/(numpoints-1)
t=0.0
path = PointPath.new
step = 1.0 / (numpoints - 1)
t = 0.0
numpoints.times do
point=getCurvePoint(curve,t)
path.addPoint(point[0],point[1])
t+=step
point = getCurvePoint(curve, t)
path.addPoint(point[0], point[1])
t += step
end
return path
end
def pbDefinePath(canvas)
sliderwin2=ControlWindow.new(0,0,320,320)
sliderwin2.viewport=canvas.viewport
sliderwin2.addSlider(_INTL("Number of frames:"),2,500,20)
sliderwin2.opacity=200
defcurvebutton=sliderwin2.addButton(_INTL("Define Smooth Curve"))
defpathbutton=sliderwin2.addButton(_INTL("Define Freehand Path"))
okbutton=sliderwin2.addButton(_INTL("OK"))
cancelbutton=sliderwin2.addButton(_INTL("Cancel"))
points=[]
path=nil
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
sliderwin2.viewport = canvas.viewport
sliderwin2.addSlider(_INTL("Number of frames:"), 2, 500, 20)
sliderwin2.opacity = 200
defcurvebutton = sliderwin2.addButton(_INTL("Define Smooth Curve"))
defpathbutton = sliderwin2.addButton(_INTL("Define Freehand Path"))
okbutton = sliderwin2.addButton(_INTL("OK"))
cancelbutton = sliderwin2.addButton(_INTL("Cancel"))
points = []
path = nil
loop do
Graphics.update
Input.update
sliderwin2.update
if sliderwin2.changed?(0) # Number of frames
if path
path=path.smoothPointPath(sliderwin2.value(0),false)
i=0
path = path.smoothPointPath(sliderwin2.value(0), false)
i = 0
for point in path
if i<points.length
points[i].x=point[0]
points[i].y=point[1]
if i < points.length
points[i].x = point[0]
points[i].y = point[1]
else
points.push(PointSprite.new(point[0],point[1],canvas.viewport))
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
end
i+=1
i += 1
end
for j in i...points.length
points[j].dispose
points[j]=nil
points[j] = nil
end
points.compact!
end
@@ -270,20 +270,20 @@ def pbDefinePath(canvas)
end
points.clear
30.times do
point=PointSprite.new(0,0,canvas.viewport)
point.visible=false
point = PointSprite.new(0, 0, canvas.viewport)
point.visible = false
points.push(point)
end
curve=[
ControlPointSprite.new(true,canvas.viewport),
ControlPointSprite.new(false,canvas.viewport),
ControlPointSprite.new(false,canvas.viewport),
ControlPointSprite.new(true,canvas.viewport)
curve = [
ControlPointSprite.new(true, canvas.viewport),
ControlPointSprite.new(false, canvas.viewport),
ControlPointSprite.new(false, canvas.viewport),
ControlPointSprite.new(true, canvas.viewport)
]
showline=false
sliderwin2.visible=false
showline = false
sliderwin2.visible = false
# This window displays the mouse's current position
window=Window_UnformattedTextPokemon.newWithSize("",
window = Window_UnformattedTextPokemon.newWithSize("",
0, 320 - 64, 128, 64, canvas.viewport)
loop do
Graphics.update
@@ -294,12 +294,12 @@ def pbDefinePath(canvas)
if Input.trigger?(Input::MOUSELEFT)
for j in 0...4
next if !curve[j].hittest?
if j==1||j==2
if j == 1 || j == 2
next if !curve[0].visible || !curve[3].visible
end
curve[j].visible=true
curve[j].visible = true
for k in 0...4
curve[k].dragging=(k==j)
curve[k].dragging = (k == j)
end
break
end
@@ -308,33 +308,33 @@ def pbDefinePath(canvas)
curve[j].mouseover
end
mousepos = Mouse::getMousePos(true)
newtext = (mousepos) ? sprintf("(%d,%d)",mousepos[0],mousepos[1]) : "(??,??)"
if window.text!=newtext
window.text=newtext
newtext = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
if window.text != newtext
window.text = newtext
end
if curve[0].visible && curve[3].visible &&
!curve[0].dragging && !curve[3].dragging
for point in points
point.visible=true
point.visible = true
end
if !showline
curve[1].visible=true
curve[2].visible=true
curve[1].x=curve[0].x+0.3333*(curve[3].x-curve[0].x)
curve[1].y=curve[0].y+0.3333*(curve[3].y-curve[0].y)
curve[2].x=curve[0].x+0.6666*(curve[3].x-curve[0].x)
curve[2].y=curve[0].y+0.6666*(curve[3].y-curve[0].y)
curve[1].visible = true
curve[2].visible = true
curve[1].x = curve[0].x + 0.3333 * (curve[3].x - curve[0].x)
curve[1].y = curve[0].y + 0.3333 * (curve[3].y - curve[0].y)
curve[2].x = curve[0].x + 0.6666 * (curve[3].x - curve[0].x)
curve[2].y = curve[0].y + 0.6666 * (curve[3].y - curve[0].y)
end
showline=true
showline = true
end
if showline
step=1.0/(points.length-1)
t=0.0
step = 1.0 / (points.length - 1)
t = 0.0
for i in 0...points.length
point=getCurvePoint(curve,t)
points[i].x=point[0]
points[i].y=point[1]
t+=step
point = getCurvePoint(curve, t)
points[i].x = point[0]
points[i].y = point[1]
t += step
end
end
end
@@ -345,50 +345,50 @@ def pbDefinePath(canvas)
end
points.clear
if showline
path=curveToPointPath(curve,sliderwin2.value(0))
path = curveToPointPath(curve, sliderwin2.value(0))
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
for point in path
points.push(PointSprite.new(point[0],point[1],canvas.viewport))
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
end
end
for point in curve
point.dispose
end
sliderwin2.visible=true
sliderwin2.visible = true
next
elsif sliderwin2.changed?(defpathbutton)
canceled=false
pointpath=PointPath.new
canceled = false
pointpath = PointPath.new
for point in points
point.dispose
end
points.clear
window=Window_UnformattedTextPokemon.newWithSize("",
0, 320-64, 128, 64, canvas.viewport)
sliderwin2.visible=false
window = Window_UnformattedTextPokemon.newWithSize("",
0, 320 - 64, 128, 64, canvas.viewport)
sliderwin2.visible = false
loop do
Graphics.update
Input.update
if Input.triggerex?(:ESCAPE)
canceled=true
canceled = true
break
end
if Input.trigger?(Input::MOUSELEFT)
break
end
mousepos=Mouse::getMousePos(true)
window.text = (mousepos) ? sprintf("(%d,%d)",mousepos[0],mousepos[1]) : "(??,??)"
mousepos = Mouse::getMousePos(true)
window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
end
while !canceled
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))
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))
end
window.text = (mousepos) ? sprintf("(%d,%d)",mousepos[0],mousepos[1]) : "(??,??)"
window.text = (mousepos) ? sprintf("(%d,%d)", mousepos[0], mousepos[1]) : "(??,??)"
Graphics.update
Input.update
if Input.triggerex?(:ESCAPE) || Input.time?(Input::MOUSELEFT)==0
if Input.triggerex?(:ESCAPE) || Input.time?(Input::MOUSELEFT) == 0
break
end
end
@@ -399,30 +399,30 @@ def pbDefinePath(canvas)
end
points.clear
# generate smooth path from temporary path
path=pointpath.smoothPointPath(sliderwin2.value(0),true)
path = pointpath.smoothPointPath(sliderwin2.value(0), true)
# redraw path from smooth path
for point in path
points.push(PointSprite.new(point[0],point[1],canvas.viewport))
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
end
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
sliderwin2.visible=true
sliderwin2.visible = true
next
elsif sliderwin2.changed?(okbutton) && path
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
neededsize=canvas.currentframe+sliderwin2.value(0)
if neededsize>canvas.animation.length
neededsize = canvas.currentframe + sliderwin2.value(0)
if neededsize > canvas.animation.length
canvas.animation.resize(neededsize)
end
thiscel=canvas.currentCel
celnumber=canvas.currentcel
thiscel = canvas.currentCel
celnumber = canvas.currentcel
for i in canvas.currentframe...neededsize
cel=canvas.animation[i][celnumber]
cel = canvas.animation[i][celnumber]
if !canvas.animation[i][celnumber]
cel=pbCreateCel(0,0,thiscel[AnimFrame::PATTERN],canvas.animation.position)
canvas.animation[i][celnumber]=cel
cel = pbCreateCel(0, 0, thiscel[AnimFrame::PATTERN], canvas.animation.position)
canvas.animation[i][celnumber] = cel
end
cel[AnimFrame::X]=path[i-canvas.currentframe][0]
cel[AnimFrame::Y]=path[i-canvas.currentframe][1]
cel[AnimFrame::X] = path[i - canvas.currentframe][0]
cel[AnimFrame::Y] = path[i - canvas.currentframe][1]
end
break
elsif sliderwin2.changed?(cancelbutton) || Input.trigger?(Input::BACK)

View File

@@ -14,7 +14,7 @@ def tryLoadData(file)
end
def dumpBase64Anim(s)
return [Zlib::Deflate.deflate(Marshal.dump(s))].pack("m").gsub(/\n/,"\r\n")
return [Zlib::Deflate.deflate(Marshal.dump(s))].pack("m").gsub(/\n/, "\r\n")
end
def loadBase64Anim(s)
@@ -22,56 +22,56 @@ def loadBase64Anim(s)
end
def pbExportAnim(animations)
filename=pbMessageFreeText(_INTL("Enter a filename."),"",false,32)
if filename!=""
filename = pbMessageFreeText(_INTL("Enter a filename."), "", false, 32)
if filename != ""
begin
filename+=".anm"
File.open(filename,"wb") { |f|
filename += ".anm"
File.open(filename, "wb") { |f|
f.write(dumpBase64Anim(animations[animations.selected]))
}
failed=false
failed = false
rescue
pbMessage(_INTL("Couldn't save the animation to {1}.",filename))
failed=true
pbMessage(_INTL("Couldn't save the animation to {1}.", filename))
failed = true
end
if !failed
pbMessage(_INTL("Animation was saved to {1} in the game folder.",filename))
pbMessage(_INTL("Animation was saved to {1} in the game folder.", filename))
pbMessage(_INTL("It's a text file, so it can be transferred to others easily."))
end
end
end
def pbImportAnim(animations,canvas,animwin)
animfiles=[]
def pbImportAnim(animations, canvas, animwin)
animfiles = []
pbRgssChdir(".") {
animfiles.concat(Dir.glob("*.anm"))
}
cmdwin=pbListWindow(animfiles,320)
cmdwin.opacity=200
cmdwin.height=480
cmdwin.viewport=canvas.viewport
cmdwin = pbListWindow(animfiles, 320)
cmdwin.opacity = 200
cmdwin.height = 480
cmdwin.viewport = canvas.viewport
loop do
Graphics.update
Input.update
cmdwin.update
if Input.trigger?(Input::USE) && animfiles.length>0
if Input.trigger?(Input::USE) && animfiles.length > 0
begin
textdata=loadBase64Anim(IO.read(animfiles[cmdwin.index]))
textdata = loadBase64Anim(IO.read(animfiles[cmdwin.index]))
throw "Bad data" if !textdata.is_a?(PBAnimation)
textdata.id=-1 # this is not an RPG Maker XP animation
textdata.id = -1 # this is not an RPG Maker XP animation
pbConvertAnimToNewFormat(textdata)
animations[animations.selected]=textdata
animations[animations.selected] = textdata
rescue
pbMessage(_INTL("The animation is invalid or could not be loaded."))
next
end
graphic=animations[animations.selected].graphic
graphic="Graphics/Animations/#{graphic}"
if graphic && graphic!="" && !FileTest.image_exist?(graphic)
pbMessage(_INTL("The animation file {1} was not found. The animation will load anyway.",graphic))
graphic = animations[animations.selected].graphic
graphic = "Graphics/Animations/#{graphic}"
if graphic && graphic != "" && !FileTest.image_exist?(graphic)
pbMessage(_INTL("The animation file {1} was not found. The animation will load anyway.", graphic))
end
canvas.loadAnimation(animations[animations.selected])
animwin.animbitmap=canvas.animbitmap
animwin.animbitmap = canvas.animbitmap
break
end
if Input.trigger?(Input::BACK)
@@ -86,12 +86,12 @@ end
# Format conversion
################################################################################
def pbConvertAnimToNewFormat(textdata)
needconverting=false
needconverting = false
for i in 0...textdata.length
next if !textdata[i]
for j in 0...PBAnimation::MAX_SPRITES
next if !textdata[i][j]
needconverting=true if textdata[i][j][AnimFrame::FOCUS]==nil
needconverting = true if textdata[i][j][AnimFrame::FOCUS] == nil
break if needconverting
end
break if needconverting
@@ -101,20 +101,20 @@ def pbConvertAnimToNewFormat(textdata)
next if !textdata[i]
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
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
textdata[i][j][AnimFrame::FOCUS]=1
textdata[i][j][AnimFrame::X]=Battle::Scene::FOCUSTARGET_X
textdata[i][j][AnimFrame::Y]=Battle::Scene::FOCUSTARGET_Y
textdata[i][j][AnimFrame::PRIORITY] = 1 if textdata[i][j][AnimFrame::PRIORITY] == nil
if j == 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
textdata[i][j][AnimFrame::FOCUS] = 1
textdata[i][j][AnimFrame::X] = Battle::Scene::FOCUSTARGET_X
textdata[i][j][AnimFrame::Y] = Battle::Scene::FOCUSTARGET_Y
else
textdata[i][j][AnimFrame::FOCUS]=(textdata.position || 4)
if textdata.position==1
textdata[i][j][AnimFrame::X]+=Battle::Scene::FOCUSTARGET_X
textdata[i][j][AnimFrame::Y]+=Battle::Scene::FOCUSTARGET_Y-2
textdata[i][j][AnimFrame::FOCUS] = (textdata.position || 4)
if textdata.position == 1
textdata[i][j][AnimFrame::X] += Battle::Scene::FOCUSTARGET_X
textdata[i][j][AnimFrame::Y] += Battle::Scene::FOCUSTARGET_Y - 2
end
end
end
@@ -125,20 +125,20 @@ end
def pbConvertAnimsToNewFormat
pbMessage(_INTL("Will convert animations now."))
count=0
animations=pbLoadBattleAnimations
count = 0
animations = pbLoadBattleAnimations
if !animations || !animations[0]
pbMessage(_INTL("No animations exist."))
return
end
for k in 0...animations.length
next if !animations[k]
ret=pbConvertAnimToNewFormat(animations[k])
count+=1 if ret
ret = pbConvertAnimToNewFormat(animations[k])
count += 1 if ret
end
if count>0
save_data(animations,"Data/PkmnAnimations.rxdata")
if count > 0
save_data(animations, "Data/PkmnAnimations.rxdata")
$game_temp.battle_animations_data = nil
end
pbMessage(_INTL("{1} animations converted to new format.",count))
pbMessage(_INTL("{1} animations converted to new format.", count))
end

View File

@@ -2,7 +2,7 @@
# Data type properties
#===============================================================================
module UndefinedProperty
def self.set(_settingname,oldsetting)
def self.set(_settingname, oldsetting)
pbMessage(_INTL("This property can't be edited here at this time."))
return oldsetting
end
@@ -15,7 +15,7 @@ end
module ReadOnlyProperty
def self.set(_settingname,oldsetting)
def self.set(_settingname, oldsetting)
pbMessage(_INTL("This property cannot be edited."))
return oldsetting
end
@@ -32,11 +32,11 @@ class UIntProperty
@maxdigits = maxdigits
end
def set(settingname,oldsetting)
def set(settingname, oldsetting)
params = ChooseNumberParams.new
params.setMaxDigits(@maxdigits)
params.setDefaultValue(oldsetting || 0)
return pbMessageChooseNumber(_INTL("Set the value for {1}.",settingname),params)
return pbMessageChooseNumber(_INTL("Set the value for {1}.", settingname), params)
end
def defaultValue
@@ -55,12 +55,12 @@ class LimitProperty
@maxvalue = maxvalue
end
def set(settingname,oldsetting)
def set(settingname, oldsetting)
oldsetting = 1 if !oldsetting
params = ChooseNumberParams.new
params.setRange(0,@maxvalue)
params.setRange(0, @maxvalue)
params.setDefaultValue(oldsetting)
return pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).",settingname),params)
return pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).", settingname), params)
end
def defaultValue
@@ -79,14 +79,14 @@ class LimitProperty2
@maxvalue = maxvalue
end
def set(settingname,oldsetting)
def set(settingname, oldsetting)
oldsetting = 0 if !oldsetting
params = ChooseNumberParams.new
params.setRange(0,@maxvalue)
params.setRange(0, @maxvalue)
params.setDefaultValue(oldsetting)
params.setCancelValue(-1)
ret = pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).",settingname),params)
return (ret>=0) ? ret : nil
ret = pbMessageChooseNumber(_INTL("Set the value for {1} (0-#{@maxvalue}).", settingname), params)
return (ret >= 0) ? ret : nil
end
def defaultValue
@@ -105,12 +105,12 @@ class NonzeroLimitProperty
@maxvalue = maxvalue
end
def set(settingname,oldsetting)
def set(settingname, oldsetting)
oldsetting = 1 if !oldsetting
params = ChooseNumberParams.new
params.setRange(1,@maxvalue)
params.setRange(1, @maxvalue)
params.setDefaultValue(oldsetting)
return pbMessageChooseNumber(_INTL("Set the value for {1}.",settingname),params)
return pbMessageChooseNumber(_INTL("Set the value for {1}.", settingname), params)
end
def defaultValue
@@ -125,8 +125,8 @@ end
module BooleanProperty
def self.set(settingname,_oldsetting)
return pbConfirmMessage(_INTL("Enable the setting {1}?",settingname)) ? true : false
def self.set(settingname, _oldsetting)
return pbConfirmMessage(_INTL("Enable the setting {1}?", settingname)) ? true : false
end
def self.format(value)
@@ -137,9 +137,9 @@ end
module BooleanProperty2
def self.set(_settingname,_oldsetting)
ret = pbShowCommands(nil,[_INTL("True"),_INTL("False")],-1)
return (ret>=0) ? (ret==0) : nil
def self.set(_settingname, _oldsetting)
ret = pbShowCommands(nil, [_INTL("True"), _INTL("False")], -1)
return (ret >= 0) ? (ret == 0) : nil
end
def self.defaultValue
@@ -147,16 +147,16 @@ module BooleanProperty2
end
def self.format(value)
return (value) ? _INTL("True") : (value!=nil) ? _INTL("False") : "-"
return (value) ? _INTL("True") : (value != nil) ? _INTL("False") : "-"
end
end
module StringProperty
def self.set(settingname,oldsetting)
return pbMessageFreeText(_INTL("Set the value for {1}.",settingname),
(oldsetting) ? oldsetting : "",false,250,Graphics.width)
def self.set(settingname, oldsetting)
return pbMessageFreeText(_INTL("Set the value for {1}.", settingname),
(oldsetting) ? oldsetting : "", false, 250, Graphics.width)
end
def self.format(value)
@@ -175,9 +175,9 @@ class LimitStringProperty
return value
end
def set(settingname,oldsetting)
return pbMessageFreeText(_INTL("Set the value for {1}.",settingname),
(oldsetting) ? oldsetting : "",false,@limit)
def set(settingname, oldsetting)
return pbMessageFreeText(_INTL("Set the value for {1}.", settingname),
(oldsetting) ? oldsetting : "", false, @limit)
end
end
@@ -188,13 +188,13 @@ class EnumProperty
@values = values
end
def set(settingname,oldsetting)
def set(settingname, oldsetting)
commands = []
for value in @values
commands.push(value)
end
cmd = pbMessage(_INTL("Choose a value for {1}.",settingname),commands,-1)
return oldsetting if cmd<0
cmd = pbMessage(_INTL("Choose a value for {1}.", settingname), commands, -1)
return oldsetting if cmd < 0
return cmd
end
@@ -215,7 +215,7 @@ class EnumProperty2
@module = value
end
def set(settingname,oldsetting)
def set(settingname, oldsetting)
commands = []
for i in 0..@module.maxValue
commands.push(getConstantName(@module, i))
@@ -357,9 +357,9 @@ end
module BGMProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MusicFileLister.new(true,oldsetting))
return (chosenmap && chosenmap!="") ? chosenmap : oldsetting
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MusicFileLister.new(true, oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting
end
def self.format(value)
@@ -370,9 +370,9 @@ end
module MEProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MusicFileLister.new(false,oldsetting))
return (chosenmap && chosenmap!="") ? chosenmap : oldsetting
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MusicFileLister.new(false, oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting
end
def self.format(value)
@@ -383,9 +383,9 @@ end
module WindowskinProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,GraphicsLister.new("Graphics/Windowskins/",oldsetting))
return (chosenmap && chosenmap!="") ? chosenmap : oldsetting
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Windowskins/", oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting
end
def self.format(value)
@@ -409,7 +409,7 @@ end
module SpeciesProperty
def self.set(_settingname,oldsetting)
def self.set(_settingname, oldsetting)
ret = pbChooseSpeciesList(oldsetting || nil)
return ret || oldsetting
end
@@ -430,7 +430,7 @@ class SpeciesFormProperty
@default_value = default_value
end
def set(_settingname,oldsetting)
def set(_settingname, oldsetting)
ret = pbChooseSpeciesFormList(oldsetting || nil)
return ret || oldsetting
end
@@ -510,9 +510,9 @@ end
module GenderProperty
def self.set(_settingname,_oldsetting)
ret = pbShowCommands(nil,[_INTL("Male"),_INTL("Female")],-1)
return (ret>=0) ? ret : nil
def self.set(_settingname, _oldsetting)
ret = pbShowCommands(nil, [_INTL("Male"), _INTL("Female")], -1)
return (ret >= 0) ? ret : nil
end
def self.defaultValue
@@ -521,7 +521,7 @@ module GenderProperty
def self.format(value)
return _INTL("-") if !value
return (value==0) ? _INTL("Male") : (value==1) ? _INTL("Female") : "-"
return (value == 0) ? _INTL("Male") : (value == 1) ? _INTL("Female") : "-"
end
end
@@ -635,7 +635,7 @@ class BallProperty
@pokemondata = pokemondata
end
def set(_settingname,oldsetting)
def set(_settingname, oldsetting)
return pbChooseBallList(oldsetting)
end
@@ -651,9 +651,9 @@ end
module CharacterProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,GraphicsLister.new("Graphics/Characters/",oldsetting))
return (chosenmap && chosenmap!="") ? chosenmap : oldsetting
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, GraphicsLister.new("Graphics/Characters/", oldsetting))
return (chosenmap && chosenmap != "") ? chosenmap : oldsetting
end
def self.format(value)
@@ -664,13 +664,13 @@ end
module MapSizeProperty
def self.set(settingname,oldsetting)
oldsetting = [0,""] if !oldsetting
def self.set(settingname, oldsetting)
oldsetting = [0, ""] if !oldsetting
properties = [
[_INTL("Width"), NonzeroLimitProperty.new(30), _INTL("The width of this map in Region Map squares.")],
[_INTL("Valid Squares"), StringProperty, _INTL("A series of 1s and 0s marking which squares are part of this map (1=part, 0=not part).")],
]
pbPropertyList(settingname,oldsetting,properties,false)
pbPropertyList(settingname, oldsetting, properties, false)
return oldsetting
end
@@ -681,29 +681,29 @@ end
def chooseMapPoint(map,rgnmap = false)
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z=99999
def chooseMapPoint(map, rgnmap = false)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
title = Window_UnformattedTextPokemon.newWithSize(_INTL("Click a point on the map."),
0, Graphics.height - 64, Graphics.width, 64, viewport)
title.z = 2
if rgnmap
sprite=RegionMapSprite.new(map,viewport)
sprite = RegionMapSprite.new(map, viewport)
else
sprite=MapSprite.new(map,viewport)
sprite = MapSprite.new(map, viewport)
end
sprite.z=2
ret=nil
sprite.z = 2
ret = nil
loop do
Graphics.update
Input.update
xy=sprite.getXY
xy = sprite.getXY
if xy
ret=xy
ret = xy
break
end
if Input.trigger?(Input::BACK)
ret=nil
ret = nil
break
end
end
@@ -715,11 +715,11 @@ end
module MapCoordsProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MapLister.new((oldsetting) ? oldsetting[0] : 0))
if chosenmap>=0
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MapLister.new((oldsetting) ? oldsetting[0] : 0))
if chosenmap >= 0
mappoint = chooseMapPoint(chosenmap)
return (mappoint) ? [chosenmap,mappoint[0],mappoint[1]] : oldsetting
return (mappoint) ? [chosenmap, mappoint[0], mappoint[1]] : oldsetting
else
return oldsetting
end
@@ -733,14 +733,14 @@ end
module MapCoordsFacingProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MapLister.new((oldsetting) ? oldsetting[0] : 0))
if chosenmap>=0
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MapLister.new((oldsetting) ? oldsetting[0] : 0))
if chosenmap >= 0
mappoint = chooseMapPoint(chosenmap)
if mappoint
facing = pbMessage(_INTL("Choose the direction to face in."),
[_INTL("Down"),_INTL("Left"),_INTL("Right"),_INTL("Up")],-1)
return (facing>=0) ? [chosenmap,mappoint[0],mappoint[1],[2,4,6,8][facing]] : oldsetting
[_INTL("Down"), _INTL("Left"), _INTL("Right"), _INTL("Up")], -1)
return (facing >= 0) ? [chosenmap, mappoint[0], mappoint[1], [2, 4, 6, 8][facing]] : oldsetting
else
return oldsetting
end
@@ -757,28 +757,28 @@ end
module RegionMapCoordsProperty
def self.set(_settingname,oldsetting)
def self.set(_settingname, oldsetting)
regions = self.getMapNameList
selregion = -1
if regions.length==0
if regions.length == 0
pbMessage(_INTL("No region maps are defined."))
return oldsetting
elsif regions.length==1
elsif regions.length == 1
selregion = regions[0][0]
else
cmds = []
for region in regions
cmds.push(region[1])
end
selcmd = pbMessage(_INTL("Choose a region map."),cmds,-1)
if selcmd>=0
selcmd = pbMessage(_INTL("Choose a region map."), cmds, -1)
if selcmd >= 0
selregion = regions[selcmd][0]
else
return oldsetting
end
end
mappoint = chooseMapPoint(selregion,true)
return (mappoint) ? [selregion,mappoint[0],mappoint[1]] : oldsetting
mappoint = chooseMapPoint(selregion, true)
return (mappoint) ? [selregion, mappoint[0], mappoint[1]] : oldsetting
end
def self.format(value)
@@ -787,11 +787,11 @@ module RegionMapCoordsProperty
def self.getMapNameList
mapdata = pbLoadTownMapData
ret=[]
ret = []
for i in 0...mapdata.length
next if !mapdata[i]
ret.push(
[i,pbGetMessage(MessageTypes::RegionNames,i)]
[i, pbGetMessage(MessageTypes::RegionNames, i)]
)
end
return ret
@@ -801,7 +801,7 @@ end
module WeatherEffectProperty
def self.set(_settingname,oldsetting)
def self.set(_settingname, oldsetting)
oldsetting = [:None, 100] if !oldsetting
options = []
ids = []
@@ -828,9 +828,9 @@ end
module MapProperty
def self.set(settingname,oldsetting)
chosenmap = pbListScreen(settingname,MapLister.new(oldsetting ? oldsetting : 0))
return (chosenmap>0) ? chosenmap : oldsetting
def self.set(settingname, oldsetting)
chosenmap = pbListScreen(settingname, MapLister.new(oldsetting ? oldsetting : 0))
return (chosenmap > 0) ? chosenmap : oldsetting
end
def self.defaultValue
@@ -846,8 +846,8 @@ end
module ItemNameProperty
def self.set(settingname, oldsetting)
return pbMessageFreeText(_INTL("Set the value for {1}.",settingname),
(oldsetting) ? oldsetting : "",false,30)
return pbMessageFreeText(_INTL("Set the value for {1}.", settingname),
(oldsetting) ? oldsetting : "", false, 30)
end
def self.defaultValue
@@ -881,7 +881,7 @@ end
module BaseStatsProperty
def self.set(settingname,oldsetting)
def self.set(settingname, oldsetting)
return oldsetting if !oldsetting
properties = []
data = []
@@ -920,7 +920,7 @@ end
module EffortValuesProperty
def self.set(settingname,oldsetting)
def self.set(settingname, oldsetting)
return oldsetting if !oldsetting
properties = []
data = []
@@ -1152,7 +1152,7 @@ module LevelUpMovesProperty
params.setRange(0, GameData::GrowthRate.max_level)
params.setDefaultValue(1)
params.setCancelValue(-1)
newlevel = pbMessageChooseNumber(_INTL("Choose a level."),params)
newlevel = pbMessageChooseNumber(_INTL("Choose a level."), params)
if newlevel >= 0
newmove = pbChooseMoveList
if newmove
@@ -1294,24 +1294,24 @@ class EvolutionsProperty
return ret
end
def set(_settingname,oldsetting)
def set(_settingname, oldsetting)
ret = oldsetting
cmdwin = pbListWindow([])
commands = []
realcmds = []
realcmds.push([-1,0,0,-1])
realcmds.push([-1, 0, 0, -1])
for i in 0...oldsetting.length
realcmds.push([oldsetting[i][0],oldsetting[i][1],oldsetting[i][2],i])
realcmds.push([oldsetting[i][0], oldsetting[i][1], oldsetting[i][2], i])
end
refreshlist = true
oldsel = -1
cmd = [0,0]
cmd = [0, 0]
loop do
if refreshlist
realcmds.sort! { |a,b| a[3]<=>b[3] }
realcmds.sort! { |a, b| a[3] <=> b[3] }
commands = []
for i in 0...realcmds.length
if realcmds[i][3]<0
if realcmds[i][3] < 0
commands.push(_INTL("[ADD EVOLUTION]"))
else
level = realcmds[i][2]
@@ -1329,47 +1329,47 @@ class EvolutionsProperty
GameData::Species.get(realcmds[i][0]).name, evo_method_data.real_name, level.to_s))
end
end
cmd[1] = i if oldsel>=0 && realcmds[i][3]==oldsel
cmd[1] = i if oldsel >= 0 && realcmds[i][3] == oldsel
end
end
refreshlist = false
oldsel = -1
cmd = pbCommands3(cmdwin,commands,-1,cmd[1],true)
if cmd[0]==1 # Swap evolution up
if cmd[1]>0 && cmd[1]<realcmds.length-1
realcmds[cmd[1]+1][3],realcmds[cmd[1]][3] = realcmds[cmd[1]][3],realcmds[cmd[1]+1][3]
cmd = pbCommands3(cmdwin, commands, -1, cmd[1], true)
if cmd[0] == 1 # Swap evolution up
if cmd[1] > 0 && cmd[1] < realcmds.length - 1
realcmds[cmd[1] + 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] + 1][3]
refreshlist = true
end
elsif cmd[0]==2 # Swap evolution down
if cmd[1]>1
realcmds[cmd[1]-1][3],realcmds[cmd[1]][3] = realcmds[cmd[1]][3],realcmds[cmd[1]-1][3]
elsif cmd[0] == 2 # Swap evolution down
if cmd[1] > 1
realcmds[cmd[1] - 1][3], realcmds[cmd[1]][3] = realcmds[cmd[1]][3], realcmds[cmd[1] - 1][3]
refreshlist = true
end
elsif cmd[0]==0
if cmd[1]>=0
elsif cmd[0] == 0
if cmd[1] >= 0
entry = realcmds[cmd[1]]
if entry[3]==-1 # Add new evolution path
if entry[3] == -1 # Add new evolution path
pbMessage(_INTL("Choose an evolved form, method and parameter."))
newspecies = pbChooseSpeciesList
if newspecies
newmethodindex = pbMessage(_INTL("Choose an evolution method."),@methods,-1)
newmethodindex = pbMessage(_INTL("Choose an evolution method."), @methods, -1)
if newmethodindex >= 0
newmethod = @evo_ids[newmethodindex]
newparam = edit_parameter(newmethod)
if newparam || GameData::Evolution.get(newmethod).parameter.nil?
existing_evo = -1
for i in 0...realcmds.length
existing_evo = realcmds[i][3] if realcmds[i][0]==newspecies &&
realcmds[i][1]==newmethod &&
realcmds[i][2]==newparam
existing_evo = realcmds[i][3] if realcmds[i][0] == newspecies &&
realcmds[i][1] == newmethod &&
realcmds[i][2] == newparam
end
if existing_evo >= 0
oldsel = existing_evo
else
maxid = -1
realcmds.each { |i| maxid = [maxid,i[3]].max }
realcmds.push([newspecies,newmethod,newparam,maxid+1])
oldsel = maxid+1
realcmds.each { |i| maxid = [maxid, i[3]].max }
realcmds.push([newspecies, newmethod, newparam, maxid + 1])
oldsel = maxid + 1
end
refreshlist = true
end
@@ -1377,16 +1377,16 @@ class EvolutionsProperty
end
else # Edit evolution
case pbMessage(_INTL("\\ts[]Do what with this evolution?"),
[_INTL("Change species"),_INTL("Change method"),
_INTL("Change parameter"),_INTL("Delete"),_INTL("Cancel")],5)
[_INTL("Change species"), _INTL("Change method"),
_INTL("Change parameter"), _INTL("Delete"), _INTL("Cancel")], 5)
when 0 # Change species
newspecies = pbChooseSpeciesList(entry[0])
if newspecies
existing_evo = -1
for i in 0...realcmds.length
existing_evo = realcmds[i][3] if realcmds[i][0]==newspecies &&
realcmds[i][1]==entry[1] &&
realcmds[i][2]==entry[2]
existing_evo = realcmds[i][3] if realcmds[i][0] == newspecies &&
realcmds[i][1] == entry[1] &&
realcmds[i][2] == entry[2]
end
if existing_evo >= 0
realcmds.delete_at(cmd[1])
@@ -1400,14 +1400,14 @@ class EvolutionsProperty
when 1 # Change method
default_index = 0
@evo_ids.each_with_index { |evo, i| default_index = i if evo == entry[1] }
newmethodindex = pbMessage(_INTL("Choose an evolution method."),@methods,-1,nil,default_index)
newmethodindex = pbMessage(_INTL("Choose an evolution method."), @methods, -1, nil, default_index)
if newmethodindex >= 0
newmethod = @evo_ids[newmethodindex]
existing_evo = -1
for i in 0...realcmds.length
existing_evo = realcmds[i][3] if realcmds[i][0]==entry[0] &&
realcmds[i][1]==newmethod &&
realcmds[i][2]==entry[2]
existing_evo = realcmds[i][3] if realcmds[i][0] == entry[0] &&
realcmds[i][1] == newmethod &&
realcmds[i][2] == entry[2]
end
if existing_evo >= 0
realcmds.delete_at(cmd[1])
@@ -1427,9 +1427,9 @@ class EvolutionsProperty
if newparam
existing_evo = -1
for i in 0...realcmds.length
existing_evo = realcmds[i][3] if realcmds[i][0]==entry[0] &&
realcmds[i][1]==entry[1] &&
realcmds[i][2]==newparam
existing_evo = realcmds[i][3] if realcmds[i][0] == entry[0] &&
realcmds[i][1] == entry[1] &&
realcmds[i][2] == newparam
end
if existing_evo >= 0
realcmds.delete_at(cmd[1])
@@ -1443,18 +1443,18 @@ class EvolutionsProperty
end
when 3 # Delete
realcmds.delete_at(cmd[1])
cmd[1] = [cmd[1],realcmds.length-1].min
cmd[1] = [cmd[1], realcmds.length - 1].min
refreshlist = true
end
end
else
cmd2 = pbMessage(_INTL("Save changes?"),
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3)
if cmd2==0 || cmd2==1
if cmd2==0
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd2 == 0 || cmd2 == 1
if cmd2 == 0
for i in 0...realcmds.length
realcmds[i].pop
realcmds[i] = nil if realcmds[i][0]==-1
realcmds[i] = nil if realcmds[i][0] == -1
end
realcmds.compact!
ret = realcmds
@@ -1546,8 +1546,8 @@ end
#===============================================================================
# Core property editor script
#===============================================================================
def pbPropertyList(title,data,properties,saveprompt = false)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
def pbPropertyList(title, data, properties, saveprompt = false)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
list = pbListWindow([], Graphics.width / 2)
list.viewport = viewport
@@ -1563,7 +1563,7 @@ def pbPropertyList(title,data,properties,saveprompt = false)
commands = []
for i in 0...properties.length
propobj = properties[i][1]
commands.push(sprintf("%s=%s",properties[i][0],propobj.format(data[i])))
commands.push(sprintf("%s=%s", properties[i][0], propobj.format(data[i])))
end
list.commands = commands
list.index = 0
@@ -1573,14 +1573,14 @@ def pbPropertyList(title,data,properties,saveprompt = false)
Input.update
list.update
desc.update
if list.index!=selectedmap
if list.index != selectedmap
desc.text = properties[list.index][2]
selectedmap = list.index
end
if Input.trigger?(Input::ACTION)
propobj = properties[selectedmap][1]
if propobj!=ReadOnlyProperty && !propobj.is_a?(ReadOnlyProperty) &&
pbConfirmMessage(_INTL("Reset the setting {1}?",properties[selectedmap][0]))
if propobj != ReadOnlyProperty && !propobj.is_a?(ReadOnlyProperty) &&
pbConfirmMessage(_INTL("Reset the setting {1}?", properties[selectedmap][0]))
if propobj.respond_to?("defaultValue")
data[selectedmap] = propobj.defaultValue
else
@@ -1590,7 +1590,7 @@ def pbPropertyList(title,data,properties,saveprompt = false)
commands.clear
for i in 0...properties.length
propobj = properties[i][1]
commands.push(sprintf("%s=%s",properties[i][0],propobj.format(data[i])))
commands.push(sprintf("%s=%s", properties[i][0], propobj.format(data[i])))
end
list.commands = commands
elsif Input.trigger?(Input::BACK)
@@ -1599,27 +1599,27 @@ def pbPropertyList(title,data,properties,saveprompt = false)
elsif Input.trigger?(Input::USE)
propobj = properties[selectedmap][1]
oldsetting = data[selectedmap]
newsetting = propobj.set(properties[selectedmap][0],oldsetting)
newsetting = propobj.set(properties[selectedmap][0], oldsetting)
data[selectedmap] = newsetting
commands.clear
for i in 0...properties.length
propobj = properties[i][1]
commands.push(sprintf("%s=%s",properties[i][0],propobj.format(data[i])))
commands.push(sprintf("%s=%s", properties[i][0], propobj.format(data[i])))
end
list.commands = commands
break
end
end
if selectedmap==-1 && saveprompt
if selectedmap == -1 && saveprompt
cmd = pbMessage(_INTL("Save changes?"),
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3)
if cmd==2
[_INTL("Yes"), _INTL("No"), _INTL("Cancel")], 3)
if cmd == 2
selectedmap = list.index
else
retval = (cmd==0)
retval = (cmd == 0)
end
end
end while selectedmap!=-1
end while selectedmap != -1
title.dispose
list.dispose
desc.dispose

View File

@@ -882,7 +882,7 @@ DebugMenuCommands.register("randomid", {
"name" => _INTL("Randomize Player ID"),
"description" => _INTL("Generate a random new ID for the player."),
"effect" => proc {
$player.id = rand(2 ** 16) | rand(2 ** 16) << 16
$player.id = rand(2**16) | rand(2**16) << 16
pbMessage(_INTL("The player's ID was changed to {1} (full ID: {2}).", $player.public_ID, $player.id))
}
})

View File

@@ -8,8 +8,8 @@ def pbDefaultMap
end
def pbWarpToMap
mapid = pbListScreen(_INTL("WARP TO MAP"),MapLister.new(pbDefaultMap))
if mapid>0
mapid = pbListScreen(_INTL("WARP TO MAP"), MapLister.new(pbDefaultMap))
if mapid > 0
map = Game_Map.new
map.setup(mapid)
success = false
@@ -18,7 +18,7 @@ def pbWarpToMap
100.times do
x = rand(map.width)
y = rand(map.height)
next if !map.passableStrict?(x,y,0,$game_player)
next if !map.passableStrict?(x, y, 0, $game_player)
blocked = false
for event in map.events.values
if event.at_coordinate?(x, y) && !event.through
@@ -33,7 +33,7 @@ def pbWarpToMap
x = rand(map.width)
y = rand(map.height)
end
return [mapid,x,y]
return [mapid, x, y]
end
return nil
end
@@ -47,11 +47,11 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
attr_reader :mode
def initialize(viewport)
super(0,0,Graphics.width,Graphics.height,viewport)
super(0, 0, Graphics.width, Graphics.height, viewport)
end
def itemCount
return (@mode==0) ? $data_system.switches.size-1 : $data_system.variables.size-1
return (@mode == 0) ? $data_system.switches.size - 1 : $data_system.variables.size - 1
end
def mode=(mode)
@@ -59,30 +59,30 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
refresh
end
def shadowtext(x,y,w,h,t,align = 0,colors = 0)
def shadowtext(x, y, w, h, t, align = 0, colors = 0)
width = self.contents.text_size(t).width
if align==1 # Right aligned
x += (w-width)
elsif align==2 # Centre aligned
x += (w/2)-(width/2)
if align == 1 # Right aligned
x += (w - width)
elsif align == 2 # Centre aligned
x += (w / 2) - (width / 2)
end
base = Color.new(12*8,12*8,12*8)
if colors==1 # Red
base = Color.new(168,48,56)
elsif colors==2 # Green
base = Color.new(0,144,0)
base = Color.new(12 * 8, 12 * 8, 12 * 8)
if colors == 1 # Red
base = Color.new(168, 48, 56)
elsif colors == 2 # Green
base = Color.new(0, 144, 0)
end
pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8))
pbDrawShadowText(self.contents, x, y, [width, w].max, h, t, base, Color.new(26 * 8, 26 * 8, 25 * 8))
end
def drawItem(index,_count,rect)
def drawItem(index, _count, rect)
pbSetNarrowFont(self.contents)
colors = 0
codeswitch = false
if @mode==0
name = $data_system.switches[index+1]
if @mode == 0
name = $data_system.switches[index + 1]
codeswitch = (name[/^s\:/])
val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index+1]
val = (codeswitch) ? (eval($~.post_match) rescue nil) : $game_switches[index + 1]
if val.nil?
status = "[-]"
colors = 0
@@ -95,31 +95,31 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
colors = 1
end
else
name = $data_system.variables[index+1]
status = $game_variables[index+1].to_s
name = $data_system.variables[index + 1]
status = $game_variables[index + 1].to_s
status = "\"__\"" if nil_or_empty?(status)
end
name = '' if name==nil
id_text = sprintf("%04d:",index+1)
rect = drawCursor(index,rect)
name = '' if name == nil
id_text = sprintf("%04d:", index + 1)
rect = drawCursor(index, rect)
totalWidth = rect.width
idWidth = totalWidth*15/100
nameWidth = totalWidth*65/100
statusWidth = totalWidth*20/100
self.shadowtext(rect.x,rect.y,idWidth,rect.height,id_text)
self.shadowtext(rect.x+idWidth,rect.y,nameWidth,rect.height,name,0,(codeswitch) ? 1 : 0)
self.shadowtext(rect.x+idWidth+nameWidth,rect.y,statusWidth,rect.height,status,1,colors)
idWidth = totalWidth * 15 / 100
nameWidth = totalWidth * 65 / 100
statusWidth = totalWidth * 20 / 100
self.shadowtext(rect.x, rect.y, idWidth, rect.height, id_text)
self.shadowtext(rect.x + idWidth, rect.y, nameWidth, rect.height, name, 0, (codeswitch) ? 1 : 0)
self.shadowtext(rect.x + idWidth + nameWidth, rect.y, statusWidth, rect.height, status, 1, colors)
end
end
def pbDebugSetVariable(id,diff)
$game_variables[id] = 0 if $game_variables[id]==nil
def pbDebugSetVariable(id, diff)
$game_variables[id] = 0 if $game_variables[id] == nil
if $game_variables[id].is_a?(Numeric)
pbPlayCursorSE
$game_variables[id] = [$game_variables[id]+diff,99999999].min
$game_variables[id] = [$game_variables[id],-99999999].max
$game_variables[id] = [$game_variables[id] + diff, 99999999].min
$game_variables[id] = [$game_variables[id], -99999999].max
$game_map.need_refresh = true
end
end
@@ -131,20 +131,20 @@ def pbDebugVariableScreen(id)
params.setDefaultValue(value)
params.setMaxDigits(8)
params.setNegativesAllowed(true)
value = pbMessageChooseNumber(_INTL("Set variable {1}.",id),params)
$game_variables[id] = [value,99999999].min
$game_variables[id] = [$game_variables[id],-99999999].max
value = pbMessageChooseNumber(_INTL("Set variable {1}.", id), params)
$game_variables[id] = [value, 99999999].min
$game_variables[id] = [$game_variables[id], -99999999].max
$game_map.need_refresh = true
elsif $game_variables[id].is_a?(String)
value = pbMessageFreeText(_INTL("Set variable {1}.",id),
$game_variables[id],false,250,Graphics.width)
value = pbMessageFreeText(_INTL("Set variable {1}.", id),
$game_variables[id], false, 250, Graphics.width)
$game_variables[id] = value
$game_map.need_refresh = true
end
end
def pbDebugVariables(mode)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
sprites = {}
sprites["right_window"] = SpriteWindow_DebugVariables.new(viewport)
@@ -159,25 +159,25 @@ def pbDebugVariables(mode)
pbPlayCancelSE
break
end
current_id = right_window.index+1
if mode==0 # Switches
current_id = right_window.index + 1
if mode == 0 # Switches
if Input.trigger?(Input::USE)
pbPlayDecisionSE
$game_switches[current_id] = !$game_switches[current_id]
right_window.refresh
$game_map.need_refresh = true
end
elsif mode==1 # Variables
elsif mode == 1 # Variables
if Input.repeat?(Input::LEFT)
pbDebugSetVariable(current_id,-1)
pbDebugSetVariable(current_id, -1)
right_window.refresh
elsif Input.repeat?(Input::RIGHT)
pbDebugSetVariable(current_id,1)
pbDebugSetVariable(current_id, 1)
right_window.refresh
elsif Input.trigger?(Input::ACTION)
if $game_variables[current_id]==0
if $game_variables[current_id] == 0
$game_variables[current_id] = ""
elsif $game_variables[current_id]==""
elsif $game_variables[current_id] == ""
$game_variables[current_id] = 0
elsif $game_variables[current_id].is_a?(Numeric)
$game_variables[current_id] = 0
@@ -353,7 +353,7 @@ end
#===============================================================================
class SpriteWindow_DebugRoamers < Window_DrawableCommand
def initialize(viewport)
super(0,0,Graphics.width,Graphics.height,viewport)
super(0, 0, Graphics.width, Graphics.height, viewport)
end
def roamerCount
@@ -361,44 +361,44 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
end
def itemCount
return self.roamerCount+2
return self.roamerCount + 2
end
def shadowtext(t,x,y,w,h,align = 0,colors = 0)
def shadowtext(t, x, y, w, h, align = 0, colors = 0)
width = self.contents.text_size(t).width
if align==1
x += (w-width) # Right aligned
elsif align==2
x += (w/2)-(width/2) # Centre aligned
if align == 1
x += (w - width) # Right aligned
elsif align == 2
x += (w / 2) - (width / 2) # Centre aligned
end
base = Color.new(12*8,12*8,12*8)
if colors==1
base = Color.new(168,48,56) # Red
elsif colors==2
base = Color.new(0,144,0) # Green
base = Color.new(12 * 8, 12 * 8, 12 * 8)
if colors == 1
base = Color.new(168, 48, 56) # Red
elsif colors == 2
base = Color.new(0, 144, 0) # Green
end
pbDrawShadowText(self.contents,x,y,[width,w].max,h,t,base,Color.new(26*8,26*8,25*8))
pbDrawShadowText(self.contents, x, y, [width, w].max, h, t, base, Color.new(26 * 8, 26 * 8, 25 * 8))
end
def drawItem(index,_count,rect)
def drawItem(index, _count, rect)
pbSetNarrowFont(self.contents)
rect = drawCursor(index,rect)
nameWidth = rect.width*50/100
statusWidth = rect.width*50/100
if index==self.itemCount-2
rect = drawCursor(index, rect)
nameWidth = rect.width * 50 / 100
statusWidth = rect.width * 50 / 100
if index == self.itemCount - 2
# Advance roaming
self.shadowtext(_INTL("[All roam to new locations]"),rect.x,rect.y,nameWidth,rect.height)
elsif index==self.itemCount-1
self.shadowtext(_INTL("[All roam to new locations]"), rect.x, rect.y, nameWidth, rect.height)
elsif index == self.itemCount - 1
# Advance roaming
self.shadowtext(_INTL("[Clear all current roamer locations]"),rect.x,rect.y,nameWidth,rect.height)
self.shadowtext(_INTL("[Clear all current roamer locations]"), rect.x, rect.y, nameWidth, rect.height)
else
pkmn = Settings::ROAMING_SPECIES[index]
name = GameData::Species.get(pkmn[0]).name + " (Lv. #{pkmn[1]})"
status = ""
statuscolor = 0
if pkmn[2]<=0 || $game_switches[pkmn[2]]
if pkmn[2] <= 0 || $game_switches[pkmn[2]]
status = $PokemonGlobal.roamPokemon[index]
if status==true
if status == true
if $PokemonGlobal.roamPokemonCaught[index]
status = "[CAUGHT]"
else
@@ -419,8 +419,8 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
else
status = "[NOT ROAMING][Switch #{pkmn[2]} is off]"
end
self.shadowtext(name,rect.x,rect.y,nameWidth,rect.height)
self.shadowtext(status,rect.x+nameWidth,rect.y,statusWidth,rect.height,1,statuscolor)
self.shadowtext(name, rect.x, rect.y, nameWidth, rect.height)
self.shadowtext(status, rect.x + nameWidth, rect.y, statusWidth, rect.height, 1, statuscolor)
end
end
end
@@ -428,23 +428,23 @@ end
def pbDebugRoamers
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
sprites = {}
sprites["cmdwindow"] = SpriteWindow_DebugRoamers.new(viewport)
cmdwindow = sprites["cmdwindow"]
cmdwindow.active = true
cmdwindow.active = true
loop do
Graphics.update
Input.update
pbUpdateSpriteHash(sprites)
if Input.trigger?(Input::ACTION) && cmdwindow.index<cmdwindow.roamerCount &&
(pkmn[2]<=0 || $game_switches[pkmn[2]]) &&
$PokemonGlobal.roamPokemon[cmdwindow.index]!=true
if Input.trigger?(Input::ACTION) && cmdwindow.index < cmdwindow.roamerCount &&
(pkmn[2] <= 0 || $game_switches[pkmn[2]]) &&
$PokemonGlobal.roamPokemon[cmdwindow.index] != true
# Roam selected Pokémon
pbPlayDecisionSE
if Input.press?(Input::CTRL) # Roam to current map
if $PokemonGlobal.roamPosition[cmdwindow.index]==pbDefaultMap
if $PokemonGlobal.roamPosition[cmdwindow.index] == pbDefaultMap
$PokemonGlobal.roamPosition[cmdwindow.index] = nil
else
$PokemonGlobal.roamPosition[cmdwindow.index] = pbDefaultMap
@@ -463,14 +463,14 @@ def pbDebugRoamers
pbPlayCancelSE
break
elsif Input.trigger?(Input::USE)
if cmdwindow.index<cmdwindow.roamerCount
if cmdwindow.index < cmdwindow.roamerCount
pbPlayDecisionSE
# Toggle through roaming, not roaming, defeated
pkmn = Settings::ROAMING_SPECIES[cmdwindow.index]
if pkmn[2]>0 && !$game_switches[pkmn[2]]
if pkmn[2] > 0 && !$game_switches[pkmn[2]]
# not roaming -> roaming
$game_switches[pkmn[2]] = true
elsif $PokemonGlobal.roamPokemon[cmdwindow.index]!=true
elsif $PokemonGlobal.roamPokemon[cmdwindow.index] != true
# roaming -> defeated
$PokemonGlobal.roamPokemon[cmdwindow.index] = true
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false
@@ -478,15 +478,15 @@ def pbDebugRoamers
!$PokemonGlobal.roamPokemonCaught[cmdwindow.index]
# defeated -> caught
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = true
elsif pkmn[2]>0
elsif pkmn[2] > 0
# caught -> not roaming (or roaming if Switch ID is 0
$game_switches[pkmn[2]] = false if pkmn[2]>0
$game_switches[pkmn[2]] = false if pkmn[2] > 0
$PokemonGlobal.roamPokemon[cmdwindow.index] = nil
$PokemonGlobal.roamPokemonCaught[cmdwindow.index] = false
end
cmdwindow.refresh
elsif cmdwindow.index==cmdwindow.itemCount-2 # All roam
if Settings::ROAMING_SPECIES.length==0
elsif cmdwindow.index == cmdwindow.itemCount - 2 # All roam
if Settings::ROAMING_SPECIES.length == 0
pbPlayBuzzerSE
else
pbPlayDecisionSE
@@ -495,7 +495,7 @@ def pbDebugRoamers
cmdwindow.refresh
end
else # Clear all roaming locations
if Settings::ROAMING_SPECIES.length==0
if Settings::ROAMING_SPECIES.length == 0
pbPlayBuzzerSE
else
pbPlayDecisionSE
@@ -524,23 +524,23 @@ def pbExtractText
pbDisposeMessageWindow(msgwindow)
return
end
pbMessageDisplay(msgwindow,_INTL("Please wait.\\wtnp[0]"))
pbMessageDisplay(msgwindow, _INTL("Please wait.\\wtnp[0]"))
MessageTypes.extract("intl.txt")
pbMessageDisplay(msgwindow,_INTL("All text in the game was extracted and saved to intl.txt.\1"))
pbMessageDisplay(msgwindow,_INTL("To localize the text for a particular language, translate every second line in the file.\1"))
pbMessageDisplay(msgwindow,_INTL("After translating, choose \"Compile Text.\""))
pbMessageDisplay(msgwindow, _INTL("All text in the game was extracted and saved to intl.txt.\1"))
pbMessageDisplay(msgwindow, _INTL("To localize the text for a particular language, translate every second line in the file.\1"))
pbMessageDisplay(msgwindow, _INTL("After translating, choose \"Compile Text.\""))
pbDisposeMessageWindow(msgwindow)
end
def pbCompileTextUI
msgwindow = pbCreateMessageWindow
pbMessageDisplay(msgwindow,_INTL("Please wait.\\wtnp[0]"))
pbMessageDisplay(msgwindow, _INTL("Please wait.\\wtnp[0]"))
begin
pbCompileText
pbMessageDisplay(msgwindow,_INTL("Successfully compiled text and saved it to intl.dat.\1"))
pbMessageDisplay(msgwindow,_INTL("To use the file in a game, place the file in the Data folder under a different name, and edit the Settings::LANGUAGES array in the scripts."))
pbMessageDisplay(msgwindow, _INTL("Successfully compiled text and saved it to intl.dat.\1"))
pbMessageDisplay(msgwindow, _INTL("To use the file in a game, place the file in the Data folder under a different name, and edit the Settings::LANGUAGES array in the scripts."))
rescue RuntimeError
pbMessageDisplay(msgwindow,_INTL("Failed to compile text: {1}",$!.message))
pbMessageDisplay(msgwindow, _INTL("Failed to compile text: {1}", $!.message))
end
pbDisposeMessageWindow(msgwindow)
end
@@ -555,28 +555,28 @@ def pbExportAllAnimations
if animations
msgwindow = pbCreateMessageWindow
for anim in animations
next if !anim || anim.length==0 || anim.name==""
pbMessageDisplay(msgwindow,anim.name,false)
next if !anim || anim.length == 0 || anim.name == ""
pbMessageDisplay(msgwindow, anim.name, false)
Graphics.update
safename = anim.name.gsub(/\W/,"_")
safename = anim.name.gsub(/\W/, "_")
Dir.mkdir("Animations/#{safename}") rescue nil
File.open("Animations/#{safename}/#{safename}.anm","wb") { |f|
File.open("Animations/#{safename}/#{safename}.anm", "wb") { |f|
f.write(dumpBase64Anim(anim))
}
if anim.graphic && anim.graphic!=""
graphicname = RTP.getImagePath("Graphics/Animations/"+anim.graphic)
pbSafeCopyFile(graphicname,"Animations/#{safename}/"+File.basename(graphicname))
if anim.graphic && anim.graphic != ""
graphicname = RTP.getImagePath("Graphics/Animations/" + anim.graphic)
pbSafeCopyFile(graphicname, "Animations/#{safename}/" + File.basename(graphicname))
end
for timing in anim.timing
if !timing.timingType || timing.timingType==0
if timing.name && timing.name!=""
audioName = RTP.getAudioPath("Audio/SE/Anim/"+timing.name)
pbSafeCopyFile(audioName,"Animations/#{safename}/"+File.basename(audioName))
if !timing.timingType || timing.timingType == 0
if timing.name && timing.name != ""
audioName = RTP.getAudioPath("Audio/SE/Anim/" + timing.name)
pbSafeCopyFile(audioName, "Animations/#{safename}/" + File.basename(audioName))
end
elsif timing.timingType==1 || timing.timingType==3
if timing.name && timing.name!=""
graphicname = RTP.getImagePath("Graphics/Animations/"+timing.name)
pbSafeCopyFile(graphicname,"Animations/#{safename}/"+File.basename(graphicname))
elsif timing.timingType == 1 || timing.timingType == 3
if timing.name && timing.name != ""
graphicname = RTP.getImagePath("Graphics/Animations/" + timing.name)
pbSafeCopyFile(graphicname, "Animations/#{safename}/" + File.basename(graphicname))
end
end
end
@@ -587,7 +587,7 @@ def pbExportAllAnimations
pbMessage(_INTL("There are no animations to export."))
end
rescue
p $!.message,$!.backtrace
p $!.message, $!.backtrace
pbMessage(_INTL("The export failed."))
end
end
@@ -596,59 +596,59 @@ def pbImportAllAnimations
animationFolders = []
if safeIsDirectory?("Animations")
Dir.foreach("Animations") { |fb|
f = "Animations/"+fb
if safeIsDirectory?(f) && fb!="." && fb!=".."
f = "Animations/" + fb
if safeIsDirectory?(f) && fb != "." && fb != ".."
animationFolders.push(f)
end
}
end
if animationFolders.length==0
if animationFolders.length == 0
pbMessage(_INTL("There are no animations to import. Put each animation in a folder within the Animations folder."))
else
msgwindow = pbCreateMessageWindow
animations = pbLoadBattleAnimations
animations = PBAnimations.new if !animations
for folder in animationFolders
pbMessageDisplay(msgwindow,folder,false)
pbMessageDisplay(msgwindow, folder, false)
Graphics.update
audios = []
files = Dir.glob(folder+"/*.*")
files = Dir.glob(folder + "/*.*")
%w[wav ogg mid wma].each { |ext| # mp3
upext = ext.upcase
audios.concat(files.find_all { |f| f[f.length-3,3]==ext })
audios.concat(files.find_all { |f| f[f.length-3,3]==upext })
audios.concat(files.find_all { |f| f[f.length - 3, 3] == ext })
audios.concat(files.find_all { |f| f[f.length - 3, 3] == upext })
}
for audio in audios
pbSafeCopyFile(audio,RTP.getAudioPath("Audio/SE/Anim/"+File.basename(audio)),"Audio/SE/Anim/"+File.basename(audio))
pbSafeCopyFile(audio, RTP.getAudioPath("Audio/SE/Anim/" + File.basename(audio)), "Audio/SE/Anim/" + File.basename(audio))
end
images = []
%w[png gif].each { |ext| # jpg jpeg bmp
upext = ext.upcase
images.concat(files.find_all { |f| f[f.length-3,3]==ext })
images.concat(files.find_all { |f| f[f.length-3,3]==upext })
images.concat(files.find_all { |f| f[f.length - 3, 3] == ext })
images.concat(files.find_all { |f| f[f.length - 3, 3] == upext })
}
for image in images
pbSafeCopyFile(image,RTP.getImagePath("Graphics/Animations/"+File.basename(image)),"Graphics/Animations/"+File.basename(image))
pbSafeCopyFile(image, RTP.getImagePath("Graphics/Animations/" + File.basename(image)), "Graphics/Animations/" + File.basename(image))
end
Dir.glob(folder+"/*.anm") { |f|
Dir.glob(folder + "/*.anm") { |f|
textdata = loadBase64Anim(IO.read(f)) rescue nil
if textdata && textdata.is_a?(PBAnimation)
index = pbAllocateAnimation(animations,textdata.name)
index = pbAllocateAnimation(animations, textdata.name)
missingFiles = []
textdata.name = File.basename(folder) if textdata.name==""
textdata.name = File.basename(folder) if textdata.name == ""
textdata.id = -1 # This is not an RPG Maker XP animation
pbConvertAnimToNewFormat(textdata)
if textdata.graphic && textdata.graphic!=""
if !safeExists?(folder+"/"+textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/"+textdata.graphic)
if textdata.graphic && textdata.graphic != ""
if !safeExists?(folder + "/" + textdata.graphic) &&
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
textdata.graphic = ""
missingFiles.push(textdata.graphic)
end
end
for timing in textdata.timing
if timing.name && timing.name!=""
if !safeExists?(folder+"/"+timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/"+timing.name)
if timing.name && timing.name != ""
if !safeExists?(folder + "/" + timing.name) &&
!FileTest.audio_exist?("Audio/SE/Anim/" + timing.name)
timing.name = ""
missingFiles.push(timing.name)
end
@@ -658,7 +658,7 @@ def pbImportAllAnimations
end
}
end
save_data(animations,"Data/PkmnAnimations.rxdata")
save_data(animations, "Data/PkmnAnimations.rxdata")
$game_temp.battle_animations_data = nil
pbDisposeMessageWindow(msgwindow)
pbMessage(_INTL("All animations were imported."))
@@ -748,17 +748,17 @@ end
#===============================================================================
class PokemonDebugPartyScreen
def initialize
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@messageBox = Window_AdvancedTextPokemon.new("")
@messageBox.viewport = @viewport
@messageBox.visible = false
@messageBox.letterbyletter = true
pbBottomLeftLines(@messageBox,2)
pbBottomLeftLines(@messageBox, 2)
@helpWindow = Window_UnformattedTextPokemon.new("")
@helpWindow.viewport = @viewport
@helpWindow.visible = true
pbBottomLeftLines(@helpWindow,1)
pbBottomLeftLines(@helpWindow, 1)
end
def pbEndScreen
@@ -796,11 +796,11 @@ class PokemonDebugPartyScreen
@messageBox.text = text
@messageBox.visible = true
@helpWindow.visible = false
using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"),_INTL("No")])) {
using(cmdwindow = Window_CommandPokemon.new([_INTL("Yes"), _INTL("No")])) {
cmdwindow.visible = false
pbBottomRight(cmdwindow)
cmdwindow.y -= @messageBox.height
cmdwindow.z = @viewport.z+1
cmdwindow.z = @viewport.z + 1
loop do
Graphics.update
Input.update
@@ -812,7 +812,7 @@ class PokemonDebugPartyScreen
ret = false
break
elsif Input.trigger?(Input::USE) && @messageBox.resume
ret = (cmdwindow.index==0)
ret = (cmdwindow.index == 0)
break
end
end
@@ -823,14 +823,14 @@ class PokemonDebugPartyScreen
return ret
end
def pbShowCommands(text,commands,index = 0)
def pbShowCommands(text, commands, index = 0)
ret = -1
@helpWindow.visible = true
using(cmdwindow = Window_CommandPokemonColor.new(commands)) {
cmdwindow.z = @viewport.z+1
cmdwindow.z = @viewport.z + 1
cmdwindow.index = index
pbBottomRight(cmdwindow)
@helpWindow.resizeHeightToFit(text,Graphics.width-cmdwindow.width)
@helpWindow.resizeHeightToFit(text, Graphics.width - cmdwindow.width)
@helpWindow.text = text
pbBottomLeft(@helpWindow)
loop do
@@ -852,16 +852,16 @@ class PokemonDebugPartyScreen
return ret
end
def pbChooseMove(pkmn,text,index = 0)
def pbChooseMove(pkmn, text, index = 0)
moveNames = []
for i in pkmn.moves
if i.total_pp<=0
moveNames.push(_INTL("{1} (PP: ---)",i.name))
if i.total_pp <= 0
moveNames.push(_INTL("{1} (PP: ---)", i.name))
else
moveNames.push(_INTL("{1} (PP: {2}/{3})",i.name,i.pp,i.total_pp))
moveNames.push(_INTL("{1} (PP: {2}/{3})", i.name, i.pp, i.total_pp))
end
end
return pbShowCommands(text,moveNames,index)
return pbShowCommands(text, moveNames, index)
end
def pbRefreshSingle(index); end

View File

@@ -354,7 +354,7 @@ PokemonDebugMenuCommands.register("hiddenvalues", {
end
end
when 2 # Randomise pID
pkmn.personalID = rand(2 ** 16) | rand(2 ** 16) << 16
pkmn.personalID = rand(2**16) | rand(2**16) << 16
pkmn.calc_stats
screen.pbRefreshSingle(pkmnid)
end

View File

@@ -154,10 +154,9 @@ BattleDebugMenuCommands.register("weather", {
msg += _INTL("Duration : Infinite")
end
end
cmd = pbMessage("\\ts[]" + msg, [
_INTL("Change type"),
_INTL("Change duration"),
_INTL("Clear weather")], -1, nil, cmd)
cmd = pbMessage("\\ts[]" + msg, [_INTL("Change type"),
_INTL("Change duration"),
_INTL("Clear weather")], -1, nil, cmd)
break if cmd < 0
case cmd
when 0 # Change type
@@ -216,10 +215,9 @@ BattleDebugMenuCommands.register("terrain", {
msg += _INTL("Duration : Infinite")
end
end
cmd = pbMessage("\\ts[]" + msg, [
_INTL("Change type"),
_INTL("Change duration"),
_INTL("Clear terrain")], -1, nil, cmd)
cmd = pbMessage("\\ts[]" + msg, [_INTL("Change type"),
_INTL("Change duration"),
_INTL("Clear terrain")], -1, nil, cmd)
break if cmd < 0
case cmd
when 0 # Change type
@@ -270,9 +268,8 @@ BattleDebugMenuCommands.register("environment", {
msg = _INTL("Environment: {1}", environment_data.name || _INTL("Unknown"))
msg += "\r\n"
msg += _INTL("Time of day: {1}", [_INTL("Day"), _INTL("Evening"), _INTL("Night")][battle.time])
cmd = pbMessage("\\ts[]" + msg, [
_INTL("Change environment"),
_INTL("Change time of day")], -1, nil, cmd)
cmd = pbMessage("\\ts[]" + msg, [_INTL("Change environment"),
_INTL("Change time of day")], -1, nil, cmd)
break if cmd < 0
case cmd
when 0 # Change environment
@@ -379,7 +376,6 @@ BattleDebugMenuCommands.register("speed_order", {
"description" => _INTL("Show all battlers in order from fastest to slowest."),
"always_show" => true,
"effect" => proc { |battle|
battlers = []
battlers = battle.allBattlers.map { |b| [b, b.pbSpeed] }
battlers.sort! { |a, b| b[1] <=> a[1] }
commands = []

View File

@@ -255,9 +255,8 @@ BattlerDebugMenuCommands.register("hiddenvalues", {
cmd = 0
loop do
persid = sprintf("0x%08X", pkmn.personalID)
cmd = pbMessage("\\ts[]" + _INTL("Personal ID is {1}.", persid), [
_INTL("Set EVs"),
_INTL("Set IVs")], -1, nil, cmd)
cmd = pbMessage("\\ts[]" + _INTL("Personal ID is {1}.", persid),
[_INTL("Set EVs"), _INTL("Set IVs")], -1, nil, cmd)
break if cmd < 0
case cmd
when 0 # Set EVs
@@ -506,10 +505,8 @@ BattlerDebugMenuCommands.register("setmovepp", {
cmd2 = 0
loop do
msg = _INTL("{1}: PP {2}/{3} (PP Up {4}/3)", move_name, move.pp, move.total_pp, move.ppup)
cmd2 = pbMessage("\\ts[]" + msg, [
_INTL("Set PP"),
_INTL("Full PP"),
_INTL("Set PP Up")], -1, nil, cmd2)
cmd2 = pbMessage("\\ts[]" + msg,
[_INTL("Set PP"), _INTL("Full PP"), _INTL("Set PP Up")], -1, nil, cmd2)
break if cmd2 < 0
case cmd2
when 0 # Change PP
@@ -680,10 +677,8 @@ BattlerDebugMenuCommands.register("setgender", {
cmd = 0
loop do
msg = [_INTL("Gender is male."), _INTL("Gender is female.")][pkmn.male? ? 0 : 1]
cmd = pbMessage("\\ts[]" + msg, [
_INTL("Make male"),
_INTL("Make female"),
_INTL("Reset")], -1, nil, cmd)
cmd = pbMessage("\\ts[]" + msg,
[_INTL("Make male"), _INTL("Make female"), _INTL("Reset")], -1, nil, cmd)
break if cmd < 0
case cmd
when 0 # Make male
@@ -747,11 +742,11 @@ BattlerDebugMenuCommands.register("setshininess", {
loop do
msg_idx = pkmn.shiny? ? (pkmn.super_shiny? ? 1 : 0) : 2
msg = [_INTL("Is shiny."), _INTL("Is super shiny."), _INTL("Is normal (not shiny).")][msg_idx]
cmd = pbMessage("\\ts[]" + msg, [
_INTL("Make shiny"),
_INTL("Make super shiny"),
_INTL("Make normal"),
_INTL("Reset")], -1, nil, cmd)
cmd = pbMessage("\\ts[]" + msg,
[_INTL("Make shiny"),
_INTL("Make super shiny"),
_INTL("Make normal"),
_INTL("Reset")], -1, nil, cmd)
break if cmd < 0
case cmd
when 0 # Make shiny

View File

@@ -10,8 +10,8 @@ def pbListWindow(cmds, width = Graphics.width / 2)
return list
end
def pbListScreen(title,lister)
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
def pbListScreen(title, lister)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
list = pbListWindow([])
list.viewport = viewport
@@ -23,7 +23,7 @@ def pbListScreen(title,lister)
selectedmap = -1
commands = lister.commands
selindex = lister.startIndex
if commands.length==0
if commands.length == 0
value = lister.value(-1)
lister.dispose
title.dispose
@@ -37,7 +37,7 @@ def pbListScreen(title,lister)
Graphics.update
Input.update
list.update
if list.index!=selectedmap
if list.index != selectedmap
lister.refresh(list.index)
selectedmap = list.index
end
@@ -57,7 +57,7 @@ def pbListScreen(title,lister)
return value
end
def pbListScreenBlock(title,lister)
def pbListScreenBlock(title, lister)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = 99999
list = pbListWindow([], Graphics.width / 2)
@@ -70,7 +70,7 @@ def pbListScreenBlock(title,lister)
selectedmap = -1
commands = lister.commands
selindex = lister.startIndex
if commands.length==0
if commands.length == 0
value = lister.value(-1)
lister.dispose
title.dispose
@@ -84,14 +84,14 @@ def pbListScreenBlock(title,lister)
Graphics.update
Input.update
list.update
if list.index!=selectedmap
if list.index != selectedmap
lister.refresh(list.index)
selectedmap = list.index
end
if Input.trigger?(Input::ACTION)
yield(Input::ACTION, lister.value(selectedmap))
list.commands = lister.commands
if list.index==list.commands.length
if list.index == list.commands.length
list.index = list.commands.length
end
lister.refresh(list.index)
@@ -100,7 +100,7 @@ def pbListScreenBlock(title,lister)
elsif Input.trigger?(Input::USE)
yield(Input::USE, lister.value(selectedmap))
list.commands = lister.commands
if list.index==list.commands.length
if list.index == list.commands.length
list.index = list.commands.length
end
lister.refresh(list.index)
@@ -117,8 +117,8 @@ end
#
#===============================================================================
class GraphicsLister
def initialize(folder,selection)
@sprite = IconSprite.new(0,0)
def initialize(folder, selection)
@sprite = IconSprite.new(0, 0)
@sprite.bitmap = nil
@sprite.x = Graphics.width * 3 / 4
@sprite.y = (Graphics.height - 64) / 2 + 64
@@ -158,26 +158,26 @@ class GraphicsLister
}
@commands.sort!
@commands.length.times do |i|
@index = i if @commands[i]==@selection
@index = i if @commands[i] == @selection
end
pbMessage(_INTL("There are no files.")) if @commands.length==0
pbMessage(_INTL("There are no files.")) if @commands.length == 0
return @commands
end
def value(index)
return (index<0) ? "" : @commands[index]
return (index < 0) ? "" : @commands[index]
end
def refresh(index)
return if index<0
@sprite.setBitmap(@folder+@commands[index])
return if index < 0
@sprite.setBitmap(@folder + @commands[index])
sprite_width = @sprite.bitmap.width
sprite_height = @sprite.bitmap.height
@sprite.ox = sprite_width/2
@sprite.oy = sprite_height/2
scale_x = (Graphics.width/2).to_f/sprite_width
scale_y = (Graphics.height-64).to_f/sprite_height
if scale_x<1.0 || scale_y<1.0
@sprite.ox = sprite_width / 2
@sprite.oy = sprite_height / 2
scale_x = (Graphics.width / 2).to_f / sprite_width
scale_y = (Graphics.height - 64).to_f / sprite_height
if scale_x < 1.0 || scale_y < 1.0
min_scale = [scale_x, scale_y].min
@sprite.zoom_x = @sprite.zoom_y = min_scale
else
@@ -190,7 +190,7 @@ end
#
#===============================================================================
class MusicFileLister
def initialize(bgm,setting)
def initialize(bgm, setting)
@oldbgm = getPlayingBGM
@commands = []
@bgm = bgm
@@ -234,22 +234,22 @@ class MusicFileLister
}
@commands.sort!
@commands.length.times do |i|
@index = i if @commands[i]==@setting
@index = i if @commands[i] == @setting
end
pbMessage(_INTL("There are no files.")) if @commands.length==0
pbMessage(_INTL("There are no files.")) if @commands.length == 0
return @commands
end
def value(index)
return (index<0) ? "" : @commands[index]
return (index < 0) ? "" : @commands[index]
end
def refresh(index)
return if index<0
return if index < 0
if @bgm
pbPlayBGM(@commands[index])
else
pbPlayBGM("../../Audio/ME/"+@commands[index])
pbPlayBGM("../../Audio/ME/" + @commands[index])
end
end
end
@@ -302,7 +302,7 @@ end
#
#===============================================================================
class MapLister
def initialize(selmap,addGlobal = false)
def initialize(selmap, addGlobal = false)
@sprite = SpriteWrapper.new
@sprite.bitmap = nil
@sprite.x = Graphics.width * 3 / 4
@@ -313,7 +313,7 @@ class MapLister
@addGlobalOffset = (addGlobal) ? 1 : 0
@index = 0
for i in 0...@maps.length
@index = i+@addGlobalOffset if @maps[i][0]==selmap
@index = i + @addGlobalOffset if @maps[i][0] == selmap
end
end
@@ -332,29 +332,29 @@ class MapLister
def commands
@commands.clear
if @addGlobalOffset==1
if @addGlobalOffset == 1
@commands.push(_INTL("[GLOBAL]"))
end
for i in 0...@maps.length
@commands.push(sprintf("%s%03d %s",(" "*@maps[i][2]),@maps[i][0],@maps[i][1]))
@commands.push(sprintf("%s%03d %s", (" " * @maps[i][2]), @maps[i][0], @maps[i][1]))
end
return @commands
end
def value(index)
if @addGlobalOffset==1
return 0 if index==0
if @addGlobalOffset == 1
return 0 if index == 0
end
return (index<0) ? -1 : @maps[index-@addGlobalOffset][0]
return (index < 0) ? -1 : @maps[index - @addGlobalOffset][0]
end
def refresh(index)
@sprite.bitmap.dispose if @sprite.bitmap
return if index<0
return if index==0 && @addGlobalOffset==1
@sprite.bitmap = createMinimap(@maps[index-@addGlobalOffset][0])
@sprite.ox = @sprite.bitmap.width/2
@sprite.oy = @sprite.bitmap.height/2
return if index < 0
return if index == 0 && @addGlobalOffset == 1
@sprite.bitmap = createMinimap(@maps[index - @addGlobalOffset][0])
@sprite.ox = @sprite.bitmap.width / 2
@sprite.oy = @sprite.bitmap.height / 2
end
end
@@ -549,7 +549,7 @@ end
#
#===============================================================================
class TrainerBattleLister
def initialize(selection,includeNew)
def initialize(selection, includeNew)
@sprite = IconSprite.new(Graphics.width * 3 / 4, (Graphics.height / 2) + 32)
@sprite.z = 2
@pkmnList = Window_UnformattedTextPokemon.newWithSize("",
@@ -653,7 +653,7 @@ class TrainerBattleLister
end
end
@pkmnList.text = text
@pkmnList.resizeHeightToFit(text,Graphics.width / 2)
@pkmnList.resizeHeightToFit(text, Graphics.width / 2)
@pkmnList.y = Graphics.height - @pkmnList.height
end
end