mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Yet more script rearranging
This commit is contained in:
1460
Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb
Normal file
1460
Data/Scripts/020_Debug/001_Editor screens/001_EditorScreens.rb
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,217 @@
|
||||
#===============================================================================
|
||||
# Edits the terrain tags of tiles in tilesets.
|
||||
#===============================================================================
|
||||
class PokemonTilesetScene
|
||||
TILE_SIZE = 32 # in pixels
|
||||
TILES_PER_ROW = 8
|
||||
TILESET_WIDTH = TILES_PER_ROW * TILE_SIZE
|
||||
TILES_PER_AUTOTILE = 48
|
||||
TILESET_START_ID = TILES_PER_ROW * TILES_PER_AUTOTILE
|
||||
CURSOR_COLOR = Color.new(255, 0, 0)
|
||||
TEXT_COLOR = Color.new(80, 80, 80)
|
||||
TEXT_SHADOW_COLOR = Color.new(192, 192, 192)
|
||||
|
||||
def initialize
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@tilesets_data = load_data("Data/Tilesets.rxdata")
|
||||
@tileset = @tilesets_data[1]
|
||||
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
|
||||
@sprites = {}
|
||||
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("Tileset Editor\r\nQ/W: SCROLL\r\nZ: MENU"),
|
||||
TILESET_WIDTH, 0, Graphics.width - TILESET_WIDTH, 128, @viewport)
|
||||
@sprites["tileset"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}")
|
||||
@sprites["tileset"].src_rect = Rect.new(0, 0, TILESET_WIDTH, Graphics.height)
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
@sprites["overlay"].x = 0
|
||||
@sprites["overlay"].y = 0
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@sprites["title"].visible = true
|
||||
@sprites["tileset"].visible = true
|
||||
@sprites["overlay"].visible = true
|
||||
@x = 0
|
||||
@y = -TILE_SIZE
|
||||
@topy = -TILE_SIZE
|
||||
@height = @sprites["tileset"].bitmap.height
|
||||
pbUpdateTileset
|
||||
end
|
||||
|
||||
def pbUpdateTileset
|
||||
@sprites["overlay"].bitmap.clear
|
||||
@sprites["tileset"].src_rect = Rect.new(0, @topy, TILESET_WIDTH, Graphics.height)
|
||||
# Draw all text over tiles, along with their coordinates (and graphics for autotiles)
|
||||
textpos = []
|
||||
tilesize = @tileset.terrain_tags.xsize
|
||||
for yy in 0...Graphics.height / TILE_SIZE
|
||||
ypos = (yy + (@topy / TILE_SIZE)) * TILES_PER_ROW + TILESET_START_ID
|
||||
next if ypos >= tilesize
|
||||
for xx in 0...TILES_PER_ROW
|
||||
if ypos < TILESET_START_ID
|
||||
@tilehelper.bltTile(@sprites["overlay"].bitmap, xx * TILE_SIZE, yy * TILE_SIZE, xx * TILES_PER_AUTOTILE)
|
||||
end
|
||||
terr = (ypos < TILESET_START_ID) ? @tileset.terrain_tags[xx * TILES_PER_AUTOTILE] : @tileset.terrain_tags[ypos + xx]
|
||||
textpos.push(["#{terr}", xx * TILE_SIZE + TILE_SIZE / 2, yy * TILE_SIZE - 6, 2, TEXT_COLOR, TEXT_SHADOW_COLOR])
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(@sprites["overlay"].bitmap, textpos)
|
||||
# Draw cursor
|
||||
@sprites["overlay"].bitmap.fill_rect(@x, @y - @topy, TILE_SIZE, 4, CURSOR_COLOR)
|
||||
@sprites["overlay"].bitmap.fill_rect(@x, @y - @topy, 4, TILE_SIZE, CURSOR_COLOR)
|
||||
@sprites["overlay"].bitmap.fill_rect(@x, @y - @topy + TILE_SIZE - 4, TILE_SIZE, 4, CURSOR_COLOR)
|
||||
@sprites["overlay"].bitmap.fill_rect(@x + TILE_SIZE - 4, @y - @topy, 4, TILE_SIZE, CURSOR_COLOR)
|
||||
pbUpdateTileInformation
|
||||
end
|
||||
|
||||
def pbUpdateTileInformation
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
tile_x = Graphics.width * 3 / 4 - TILE_SIZE
|
||||
tile_y = Graphics.height / 2 - TILE_SIZE
|
||||
tile_id = pbGetSelected(@x, @y) || 0
|
||||
# Draw tile (at 200% size)
|
||||
@tilehelper.bltSmallTile(overlay, tile_x, tile_y, TILE_SIZE * 2, TILE_SIZE * 2, tile_id)
|
||||
# Draw box around tile image
|
||||
overlay.fill_rect(tile_x - 1, tile_y - 1, TILE_SIZE * 2 + 2, 1, Color.new(255, 255, 255))
|
||||
overlay.fill_rect(tile_x - 1, tile_y - 1, 1, TILE_SIZE * 2 + 2, Color.new(255, 255, 255))
|
||||
overlay.fill_rect(tile_x - 1, tile_y + TILE_SIZE * 2, TILE_SIZE * 2 + 2, 1, Color.new(255, 255, 255))
|
||||
overlay.fill_rect(tile_x + TILE_SIZE * 2, tile_y - 1, 1, TILE_SIZE * 2 + 2, Color.new(255, 255, 255))
|
||||
# Write terrain tag info about selected tile
|
||||
terrain_tag = @tileset.terrain_tags[tile_id] || 0
|
||||
if GameData::TerrainTag.exists?(terrain_tag)
|
||||
terrain_tag_name = sprintf("%d: %s", terrain_tag, GameData::TerrainTag.get(terrain_tag).real_name)
|
||||
else
|
||||
terrain_tag_name = terrain_tag.to_s
|
||||
end
|
||||
textpos = [
|
||||
[_INTL("Terrain Tag:"), tile_x + TILE_SIZE, tile_y + TILE_SIZE * 2 + 10, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)],
|
||||
[terrain_tag_name, tile_x + TILE_SIZE, tile_y + TILE_SIZE * 2 + 42, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)]
|
||||
]
|
||||
# Draw all text
|
||||
pbDrawTextPositions(overlay, textpos)
|
||||
end
|
||||
|
||||
def pbChooseTileset
|
||||
commands = []
|
||||
for i in 1...@tilesets_data.length
|
||||
commands.push(sprintf("%03d %s", i, @tilesets_data[i].name))
|
||||
end
|
||||
ret = pbShowCommands(nil, commands, -1)
|
||||
if ret >= 0
|
||||
@tileset = @tilesets_data[ret + 1]
|
||||
@tilehelper.dispose
|
||||
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
|
||||
@sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}")
|
||||
@x = 0
|
||||
@y = -TILE_SIZE
|
||||
@topy = -TILE_SIZE
|
||||
pbUpdateTileset
|
||||
@height = @sprites["tileset"].bitmap.height
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetSelected(x, y)
|
||||
return TILES_PER_AUTOTILE * (x / TILE_SIZE) if y < 0 # Autotile
|
||||
return TILESET_START_ID + (y / TILE_SIZE) * TILES_PER_ROW + (x / TILE_SIZE)
|
||||
end
|
||||
|
||||
def pbSetSelected(i,value)
|
||||
if i < TILESET_START_ID
|
||||
for j in 0...TILES_PER_AUTOTILE
|
||||
@tileset.terrain_tags[i + j] = value
|
||||
end
|
||||
else
|
||||
@tileset.terrain_tags[i] = value
|
||||
end
|
||||
end
|
||||
|
||||
def update_cursor_position(x_offset, y_offset)
|
||||
old_x = @x
|
||||
old_y = @y
|
||||
if x_offset != 0
|
||||
@x += x_offset * TILE_SIZE
|
||||
@x = @x.clamp(0, TILESET_WIDTH - TILE_SIZE)
|
||||
end
|
||||
if y_offset != 0
|
||||
@y += y_offset * TILE_SIZE
|
||||
@y = @y.clamp(-TILE_SIZE, @height - TILE_SIZE)
|
||||
@topy = @y if @y < @topy
|
||||
@topy = @y - Graphics.height + TILE_SIZE if @y >= @topy + Graphics.height
|
||||
end
|
||||
pbUpdateTileset if @x != old_x || @y != old_y
|
||||
end
|
||||
|
||||
def pbStartScene
|
||||
pbFadeInAndShow(@sprites)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
if Input.repeat?(Input::UP)
|
||||
update_cursor_position(0, -1)
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
update_cursor_position(0, 1)
|
||||
elsif Input.repeat?(Input::LEFT)
|
||||
update_cursor_position(-1, 0)
|
||||
elsif Input.repeat?(Input::RIGHT)
|
||||
update_cursor_position(1, 0)
|
||||
elsif Input.repeat?(Input::JUMPUP)
|
||||
update_cursor_position(0, -Graphics.height / TILE_SIZE)
|
||||
elsif Input.repeat?(Input::JUMPDOWN)
|
||||
update_cursor_position(0, Graphics.height / TILE_SIZE)
|
||||
elsif Input.trigger?(Input::ACTION)
|
||||
commands = [
|
||||
_INTL("Go to bottom"),
|
||||
_INTL("Go to top"),
|
||||
_INTL("Change tileset"),
|
||||
_INTL("Cancel")
|
||||
]
|
||||
case pbShowCommands(nil,commands,-1)
|
||||
when 0
|
||||
@y = @height - TILE_SIZE
|
||||
@topy = @y - Graphics.height + TILE_SIZE if @y - @topy >= Graphics.height
|
||||
pbUpdateTileset
|
||||
when 1
|
||||
@y = -TILE_SIZE
|
||||
@topy = @y if @y < @topy
|
||||
pbUpdateTileset
|
||||
when 2
|
||||
pbChooseTileset
|
||||
end
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
if pbConfirmMessage(_INTL("Save changes?"))
|
||||
save_data("Data/Tilesets.rxdata", @tilesets_data)
|
||||
$data_tilesets = @tilesets_data
|
||||
if $game_map && $MapFactory
|
||||
$MapFactory.setup($game_map.map_id)
|
||||
$game_player.center($game_player.x, $game_player.y)
|
||||
if $scene.is_a?(Scene_Map)
|
||||
$scene.disposeSpritesets
|
||||
$scene.createSpritesets
|
||||
end
|
||||
end
|
||||
pbMessage(_INTL("To ensure that the changes remain, close and reopen RPG Maker XP."))
|
||||
end
|
||||
break if pbConfirmMessage(_INTL("Exit from the editor?"))
|
||||
elsif Input.trigger?(Input::USE)
|
||||
selected = pbGetSelected(@x, @y)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, 99)
|
||||
params.setDefaultValue(@tileset.terrain_tags[selected])
|
||||
pbSetSelected(selected,pbMessageChooseNumber(_INTL("Set the terrain tag."), params))
|
||||
pbUpdateTileset
|
||||
end
|
||||
end
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
@tilehelper.dispose
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbTilesetScreen
|
||||
pbFadeOutIn {
|
||||
scene = PokemonTilesetScene.new
|
||||
scene.pbStartScene
|
||||
}
|
||||
end
|
||||
@@ -0,0 +1,590 @@
|
||||
#===============================================================================
|
||||
# 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)
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprite.bitmap.dispose
|
||||
@sprite.dispose
|
||||
end
|
||||
|
||||
def 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
|
||||
return nil
|
||||
end
|
||||
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]
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SelectionSprite < Sprite
|
||||
def initialize(viewport=nil)
|
||||
@sprite=Sprite.new(viewport)
|
||||
@sprite.bitmap=nil
|
||||
@sprite.z=2
|
||||
@othersprite=nil
|
||||
end
|
||||
|
||||
def disposed?
|
||||
return @sprite.disposed?
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprite.bitmap.dispose if @sprite.bitmap
|
||||
@othersprite=nil
|
||||
@sprite.dispose
|
||||
end
|
||||
|
||||
def 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.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)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @othersprite && !@othersprite.disposed?
|
||||
@sprite.visible=@othersprite.visible
|
||||
@sprite.x=@othersprite.x
|
||||
@sprite.y=@othersprite.y
|
||||
else
|
||||
@sprite.visible=false
|
||||
end
|
||||
end
|
||||
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)
|
||||
end
|
||||
|
||||
def dispose
|
||||
@sprite.bitmap.dispose
|
||||
@sprite.dispose
|
||||
end
|
||||
|
||||
def 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)
|
||||
retbitmap.stretch_blt(
|
||||
Rect.new(0,0,bitmap.width/2,bitmap.height/2),
|
||||
bitmap,
|
||||
Rect.new(0,0,bitmap.width,bitmap.height)
|
||||
)
|
||||
bitmap.dispose
|
||||
return retbitmap
|
||||
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
|
||||
return nil
|
||||
end
|
||||
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]
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Visual Editor (map connections)
|
||||
#===============================================================================
|
||||
class MapScreenScene
|
||||
def getMapSprite(id)
|
||||
if !@mapsprites[id]
|
||||
@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)
|
||||
end
|
||||
return @mapsprites[id]
|
||||
end
|
||||
|
||||
def close
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
pbDisposeSpriteHash(@mapsprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
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
|
||||
for conn in conns
|
||||
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)
|
||||
sprites.push(conn[3])
|
||||
putNeighbors(conn[3],sprites)
|
||||
end
|
||||
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)
|
||||
sprites.push(conn[3])
|
||||
putNeighbors(conn[0],sprites)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def hasConnections?(conns,id)
|
||||
for conn in conns
|
||||
return true if conn[0]==id || conn[3]==id
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
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 true
|
||||
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 true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def removeOldConnections(ret,mapid)
|
||||
for i in 0...ret.length
|
||||
ret[i]=nil if ret[i][0]==mapid || ret[i][3]==mapid
|
||||
end
|
||||
ret.compact!
|
||||
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=[]
|
||||
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])
|
||||
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]
|
||||
ret.push(key)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def generateConnectionData
|
||||
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
|
||||
# Remove all connections containing any sprites on the canvas from the array
|
||||
for i in keys
|
||||
removeOldConnections(ret,i)
|
||||
end
|
||||
# Rebuild connections
|
||||
for i in keys
|
||||
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
|
||||
end
|
||||
if j==ret.length
|
||||
ret.push(conn)
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def serializeConnectionData
|
||||
conndata=generateConnectionData()
|
||||
save_data(conndata, "Data/map_connections.dat")
|
||||
Compiler.write_connections
|
||||
@mapconns=conndata
|
||||
end
|
||||
|
||||
def putSprite(id)
|
||||
addSprite(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
|
||||
end
|
||||
|
||||
def saveMapSpritePos
|
||||
@mapspritepos.clear
|
||||
for i in @mapsprites.keys
|
||||
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["background"] = ColoredPlane.new(Color.new(160, 208, 240), @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=[]
|
||||
for map_conns in conns
|
||||
next if !map_conns
|
||||
map_conns.each do |c|
|
||||
@mapconns.push(c.clone) if !@mapconns.any? { |x| x[0] == c[0] && x[3] == c[3] }
|
||||
end
|
||||
end
|
||||
if $game_map
|
||||
@currentmap=$game_map.map_id
|
||||
else
|
||||
@currentmap=($data_system) ? $data_system.edit_map_id : 1
|
||||
end
|
||||
putSprite(@currentmap)
|
||||
end
|
||||
|
||||
def setTopSprite(id)
|
||||
for i in @mapsprites.keys
|
||||
@mapsprites[i].z = (i == id) ? 1 : 0
|
||||
end
|
||||
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")
|
||||
title = Window_UnformattedTextPokemon.newWithSize(helptext,
|
||||
0, 0, Graphics.width * 8 / 10, Graphics.height, @viewport)
|
||||
title.z = 2
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
break if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
|
||||
end
|
||||
Input.update
|
||||
title.dispose
|
||||
end
|
||||
|
||||
def getMapRect(mapid)
|
||||
sprite=getMapSprite(mapid)
|
||||
if sprite
|
||||
return [
|
||||
sprite.x,
|
||||
sprite.y,
|
||||
sprite.x+sprite.bitmap.width,
|
||||
sprite.y+sprite.bitmap.height
|
||||
]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def onDoubleClick(map_id)
|
||||
pbEditMetadata(map_id) if map_id > 0
|
||||
end
|
||||
|
||||
def onClick(mapid,x,y)
|
||||
if @lastclick>0 && Graphics.frame_count - @lastclick < Graphics.frame_rate * 0.5
|
||||
onDoubleClick(mapid)
|
||||
@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
|
||||
setTopSprite(mapid)
|
||||
else
|
||||
@sprites["selsprite"].othersprite=nil
|
||||
@dragging=true
|
||||
@dragmapid=mapid
|
||||
@selmapid=-1
|
||||
@dragOffsetX=x
|
||||
@dragOffsetY=y
|
||||
saveMapSpritePos
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def onRightClick(mapid,x,y)
|
||||
# echoln("rightclick (#{mapid})")
|
||||
end
|
||||
|
||||
def onMouseUp(mapid)
|
||||
# echoln("mouseup (#{mapid})")
|
||||
@dragging=false if @dragging
|
||||
end
|
||||
|
||||
def onRightMouseUp(mapid)
|
||||
# echoln("rightmouseup (#{mapid})")
|
||||
end
|
||||
|
||||
def onMouseOver(mapid,x,y)
|
||||
# echoln("mouseover (#{mapid},#{x},#{y})")
|
||||
end
|
||||
|
||||
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)
|
||||
else
|
||||
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
|
||||
end
|
||||
@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)
|
||||
else
|
||||
@sprites["title"].text=_INTL("D: Help")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
def chooseMapScreen(title,currentmap)
|
||||
return pbListScreen(title,MapLister.new(currentmap))
|
||||
end
|
||||
|
||||
def update
|
||||
mousepos=Mouse::getMousePos
|
||||
if mousepos
|
||||
hitmap=hittest(mousepos[0],mousepos[1])
|
||||
if Input.trigger?(Input::MOUSELEFT)
|
||||
onClick(hitmap,mousepos[0],mousepos[1])
|
||||
elsif Input.trigger?(Input::MOUSERIGHT)
|
||||
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
|
||||
end
|
||||
if @oldmousex!=mousepos[0] || @oldmousey!=mousepos[1]
|
||||
onMouseMove(hitmap,mousepos[0],mousepos[1])
|
||||
@oldmousex=mousepos[0]
|
||||
@oldmousey=mousepos[1]
|
||||
end
|
||||
end
|
||||
end
|
||||
if Input.press?(Input::UP)
|
||||
for i in @mapsprites
|
||||
i[1].y += 4 if i
|
||||
end
|
||||
end
|
||||
if Input.press?(Input::DOWN)
|
||||
for i in @mapsprites
|
||||
i[1].y -= 4 if i
|
||||
end
|
||||
end
|
||||
if Input.press?(Input::LEFT)
|
||||
for i in @mapsprites
|
||||
i[1].x += 4 if i
|
||||
end
|
||||
end
|
||||
if Input.press?(Input::RIGHT)
|
||||
for i in @mapsprites
|
||||
i[1].x -= 4 if i
|
||||
end
|
||||
end
|
||||
if Input.triggerex?(:A)
|
||||
id=chooseMapScreen(_INTL("Add Map"),@currentmap)
|
||||
if id>0
|
||||
addSprite(id)
|
||||
setTopSprite(id)
|
||||
@mapconns=generateConnectionData
|
||||
end
|
||||
elsif Input.triggerex?(:S)
|
||||
id=chooseMapScreen(_INTL("Go to Map"),@currentmap)
|
||||
if id>0
|
||||
@mapconns=generateConnectionData
|
||||
pbDisposeSpriteHash(@mapsprites)
|
||||
@mapsprites.clear
|
||||
@sprites["selsprite"].othersprite=nil
|
||||
@selmapid=-1
|
||||
putSprite(id)
|
||||
@currentmap=id
|
||||
end
|
||||
elsif Input.triggerex?(:DELETE)
|
||||
if @mapsprites.keys.length>1 && @selmapid>=0
|
||||
@mapsprites[@selmapid].bitmap.dispose
|
||||
@mapsprites[@selmapid].dispose
|
||||
@mapsprites.delete(@selmapid)
|
||||
@sprites["selsprite"].othersprite=nil
|
||||
@selmapid=-1
|
||||
end
|
||||
elsif Input.triggerex?(:D)
|
||||
helpWindow
|
||||
end
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbMapScreenLoop
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
update
|
||||
if Input.trigger?(Input::BACK)
|
||||
if pbConfirmMessage(_INTL("Save changes?"))
|
||||
serializeConnectionData
|
||||
MapFactoryHelper.clear
|
||||
else
|
||||
GameData::Encounter.load
|
||||
end
|
||||
break if pbConfirmMessage(_INTL("Exit from the editor?"))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbConnectionsEditor
|
||||
pbCriticalCode {
|
||||
Graphics.resize_screen(Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288)
|
||||
pbSetResizeFactor(1)
|
||||
mapscreen = MapScreenScene.new
|
||||
mapscreen.mapScreen
|
||||
mapscreen.pbMapScreenLoop
|
||||
mapscreen.close
|
||||
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
|
||||
pbSetResizeFactor($PokemonSystem.screensize)
|
||||
}
|
||||
end
|
||||
@@ -0,0 +1,404 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def findBottom(bitmap)
|
||||
return 0 if !bitmap
|
||||
for i in 1..bitmap.height
|
||||
for j in 0..bitmap.width - 1
|
||||
return bitmap.height - i if bitmap.get_pixel(j, bitmap.height - i).alpha > 0
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def pbAutoPositionAll
|
||||
GameData::Species.each do |sp|
|
||||
Graphics.update if sp.id_number % 50 == 0
|
||||
bitmap1 = GameData::Species.sprite_bitmap(sp.species, sp.form, nil, nil, nil, true)
|
||||
bitmap2 = GameData::Species.sprite_bitmap(sp.species, sp.form)
|
||||
if bitmap1 && bitmap1.bitmap # Player's y
|
||||
sp.back_sprite_x = 0
|
||||
sp.back_sprite_y = (bitmap1.height - (findBottom(bitmap1.bitmap) + 1)) / 2
|
||||
end
|
||||
if bitmap2 && bitmap2.bitmap # Foe's y
|
||||
sp.front_sprite_x = 0
|
||||
sp.front_sprite_y = (bitmap2.height - (findBottom(bitmap2.bitmap) + 1)) / 2
|
||||
sp.front_sprite_y += 4 # Just because
|
||||
end
|
||||
sp.front_sprite_altitude = 0 # Shouldn't be used
|
||||
sp.shadow_x = 0
|
||||
sp.shadow_size = 2
|
||||
bitmap1.dispose if bitmap1
|
||||
bitmap2.dispose if bitmap2
|
||||
end
|
||||
GameData::Species.save
|
||||
Compiler.write_pokemon
|
||||
Compiler.write_pokemon_forms
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SpritePositioner
|
||||
def pbOpen
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
battlebg = "Graphics/Battlebacks/indoor1_bg"
|
||||
playerbase = "Graphics/Battlebacks/indoor1_base0"
|
||||
enemybase = "Graphics/Battlebacks/indoor1_base1"
|
||||
@sprites["battle_bg"] = AnimatedPlane.new(@viewport)
|
||||
@sprites["battle_bg"].setBitmap(battlebg)
|
||||
@sprites["battle_bg"].z = 0
|
||||
baseX, baseY = PokeBattle_SceneConstants.pbBattlerPosition(0)
|
||||
@sprites["base_0"] = IconSprite.new(baseX, baseY, @viewport)
|
||||
@sprites["base_0"].setBitmap(playerbase)
|
||||
@sprites["base_0"].x -= @sprites["base_0"].bitmap.width / 2 if @sprites["base_0"].bitmap
|
||||
@sprites["base_0"].y -= @sprites["base_0"].bitmap.height if @sprites["base_0"].bitmap
|
||||
@sprites["base_0"].z = 1
|
||||
baseX, baseY = PokeBattle_SceneConstants.pbBattlerPosition(1)
|
||||
@sprites["base_1"] = IconSprite.new(baseX, baseY, @viewport)
|
||||
@sprites["base_1"].setBitmap(enemybase)
|
||||
@sprites["base_1"].x -= @sprites["base_1"].bitmap.width / 2 if @sprites["base_1"].bitmap
|
||||
@sprites["base_1"].y -= @sprites["base_1"].bitmap.height / 2 if @sprites["base_1"].bitmap
|
||||
@sprites["base_1"].z = 1
|
||||
@sprites["messageBox"] = IconSprite.new(0, Graphics.height - 96, @viewport)
|
||||
@sprites["messageBox"].setBitmap("Graphics/Pictures/Battle/debug_message")
|
||||
@sprites["messageBox"].z = 2
|
||||
@sprites["shadow_1"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["shadow_1"].z = 3
|
||||
@sprites["pokemon_0"] = PokemonSprite.new(@viewport)
|
||||
@sprites["pokemon_0"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["pokemon_0"].z = 4
|
||||
@sprites["pokemon_1"] = PokemonSprite.new(@viewport)
|
||||
@sprites["pokemon_1"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["pokemon_1"].z = 4
|
||||
@sprites["info"] = Window_UnformattedTextPokemon.new("")
|
||||
@sprites["info"].viewport = @viewport
|
||||
@sprites["info"].visible = false
|
||||
@oldSpeciesIndex = 0
|
||||
@species = nil # This can be a species_form
|
||||
@metricsChanged = false
|
||||
refresh
|
||||
@starting = true
|
||||
end
|
||||
|
||||
def pbClose
|
||||
if @metricsChanged && pbConfirmMessage(_INTL("Some metrics have been edited. Save changes?"))
|
||||
pbSaveMetrics
|
||||
@metricsChanged = false
|
||||
else
|
||||
GameData::Species.load # Clear all changes to metrics
|
||||
end
|
||||
pbFadeOutAndHide(@sprites) { update }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbSaveMetrics
|
||||
GameData::Species.save
|
||||
Compiler.write_pokemon
|
||||
Compiler.write_pokemon_forms
|
||||
end
|
||||
|
||||
def update
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def refresh
|
||||
if !@species
|
||||
@sprites["pokemon_0"].visible = false
|
||||
@sprites["pokemon_1"].visible = false
|
||||
@sprites["shadow_1"].visible = false
|
||||
return
|
||||
end
|
||||
species_data = GameData::Species.get(@species)
|
||||
for i in 0...2
|
||||
pos = PokeBattle_SceneConstants.pbBattlerPosition(i, 1)
|
||||
@sprites["pokemon_#{i}"].x = pos[0]
|
||||
@sprites["pokemon_#{i}"].y = pos[1]
|
||||
species_data.apply_metrics_to_sprite(@sprites["pokemon_#{i}"], i)
|
||||
@sprites["pokemon_#{i}"].visible = true
|
||||
if i == 1
|
||||
@sprites["shadow_1"].x = pos[0]
|
||||
@sprites["shadow_1"].y = pos[1]
|
||||
if @sprites["shadow_1"].bitmap
|
||||
@sprites["shadow_1"].x -= @sprites["shadow_1"].bitmap.width / 2
|
||||
@sprites["shadow_1"].y -= @sprites["shadow_1"].bitmap.height / 2
|
||||
end
|
||||
species_data.apply_metrics_to_sprite(@sprites["shadow_1"], i, true)
|
||||
@sprites["shadow_1"].visible = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbAutoPosition
|
||||
species_data = GameData::Species.get(@species)
|
||||
old_back_y = species_data.back_sprite_y
|
||||
old_front_y = species_data.front_sprite_y
|
||||
old_front_altitude = species_data.front_sprite_altitude
|
||||
bitmap1 = @sprites["pokemon_0"].bitmap
|
||||
bitmap2 = @sprites["pokemon_1"].bitmap
|
||||
new_back_y = (bitmap1.height - (findBottom(bitmap1) + 1)) / 2
|
||||
new_front_y = (bitmap2.height - (findBottom(bitmap2) + 1)) / 2
|
||||
new_front_y += 4 # Just because
|
||||
if new_back_y != old_back_y || new_front_y != old_front_y || old_front_altitude != 0
|
||||
species_data.back_sprite_y = new_back_y
|
||||
species_data.front_sprite_y = new_front_y
|
||||
species_data.front_sprite_altitude = 0
|
||||
@metricsChanged = true
|
||||
refresh
|
||||
end
|
||||
end
|
||||
|
||||
def pbChangeSpecies(species)
|
||||
@species = species
|
||||
species_data = GameData::Species.try_get(@species)
|
||||
return if !species_data
|
||||
spe = species_data.species
|
||||
frm = species_data.form
|
||||
@sprites["pokemon_0"].setSpeciesBitmap(spe, 0, frm, false, false, true)
|
||||
@sprites["pokemon_1"].setSpeciesBitmap(spe, 0, frm)
|
||||
@sprites["shadow_1"].setBitmap(GameData::Species.shadow_filename(spe, frm))
|
||||
end
|
||||
|
||||
def pbShadowSize
|
||||
pbChangeSpecies(@species)
|
||||
refresh
|
||||
species_data = GameData::Species.get(@species)
|
||||
oldval = species_data.shadow_size
|
||||
cmdvals = [0]
|
||||
commands = [_INTL("None")]
|
||||
defindex = 0
|
||||
i = 0
|
||||
loop do
|
||||
i += 1
|
||||
fn = sprintf("Graphics/Pictures/Battle/battler_shadow_%d", i)
|
||||
break if !pbResolveBitmap(fn)
|
||||
cmdvals.push(i)
|
||||
commands.push(i.to_s)
|
||||
defindex = cmdvals.length - 1 if oldval == i
|
||||
end
|
||||
cw = Window_CommandPokemon.new(commands)
|
||||
cw.index = defindex
|
||||
cw.viewport = @viewport
|
||||
ret = false
|
||||
oldindex = cw.index
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
cw.update
|
||||
self.update
|
||||
if cw.index != oldindex
|
||||
oldindex = cw.index
|
||||
species_data.shadow_size = cmdvals[cw.index]
|
||||
pbChangeSpecies(@species)
|
||||
refresh
|
||||
end
|
||||
if Input.trigger?(Input::ACTION) # Cycle to next option
|
||||
pbPlayDecisionSE
|
||||
@metricsChanged = true if species_data.shadow_size != oldval
|
||||
ret = true
|
||||
break
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
species_data.shadow_size = oldval
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
end
|
||||
end
|
||||
cw.dispose
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbSetParameter(param)
|
||||
return if !@species
|
||||
return pbShadowSize if param == 2
|
||||
if param == 4
|
||||
pbAutoPosition
|
||||
return false
|
||||
end
|
||||
species_data = GameData::Species.get(@species)
|
||||
case param
|
||||
when 0
|
||||
sprite = @sprites["pokemon_0"]
|
||||
xpos = species_data.back_sprite_x
|
||||
ypos = species_data.back_sprite_y
|
||||
when 1
|
||||
sprite = @sprites["pokemon_1"]
|
||||
xpos = species_data.front_sprite_x
|
||||
ypos = species_data.front_sprite_y
|
||||
when 3
|
||||
sprite = @sprites["shadow_1"]
|
||||
xpos = species_data.shadow_x
|
||||
ypos = 0
|
||||
end
|
||||
oldxpos = xpos
|
||||
oldypos = ypos
|
||||
@sprites["info"].visible = true
|
||||
ret = false
|
||||
loop do
|
||||
sprite.visible = (Graphics.frame_count % 16) < 12 # Flash the selected sprite
|
||||
Graphics.update
|
||||
Input.update
|
||||
self.update
|
||||
case param
|
||||
when 0 then @sprites["info"].setTextToFit("Ally Position = #{xpos},#{ypos}")
|
||||
when 1 then @sprites["info"].setTextToFit("Enemy Position = #{xpos},#{ypos}")
|
||||
when 3 then @sprites["info"].setTextToFit("Shadow Position = #{xpos}")
|
||||
end
|
||||
if (Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN)) && param != 3
|
||||
ypos += (Input.repeat?(Input::DOWN)) ? 1 : -1
|
||||
case param
|
||||
when 0 then species_data.back_sprite_y = ypos
|
||||
when 1 then species_data.front_sprite_y = ypos
|
||||
end
|
||||
refresh
|
||||
end
|
||||
if Input.repeat?(Input::LEFT) || Input.repeat?(Input::RIGHT)
|
||||
xpos += (Input.repeat?(Input::RIGHT)) ? 1 : -1
|
||||
case param
|
||||
when 0 then species_data.back_sprite_x = xpos
|
||||
when 1 then species_data.front_sprite_x = xpos
|
||||
when 3 then species_data.shadow_x = xpos
|
||||
end
|
||||
refresh
|
||||
end
|
||||
if Input.repeat?(Input::ACTION) && param != 3 # Cycle to next option
|
||||
@metricsChanged = true if xpos != oldxpos || ypos != oldypos
|
||||
ret = true
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
elsif Input.repeat?(Input::BACK)
|
||||
case param
|
||||
when 0
|
||||
species_data.back_sprite_x = oldxpos
|
||||
species_data.back_sprite_y = oldypos
|
||||
when 1
|
||||
species_data.front_sprite_x = oldxpos
|
||||
species_data.front_sprite_y = oldypos
|
||||
when 3
|
||||
species_data.shadow_x = oldxpos
|
||||
end
|
||||
pbPlayCancelSE
|
||||
refresh
|
||||
break
|
||||
elsif Input.repeat?(Input::USE)
|
||||
@metricsChanged = true if xpos != oldxpos || (param != 3 && ypos != oldypos)
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
end
|
||||
end
|
||||
@sprites["info"].visible = false
|
||||
sprite.visible = true
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbMenu(species)
|
||||
pbChangeSpecies(species)
|
||||
refresh
|
||||
cw = Window_CommandPokemon.new([
|
||||
_INTL("Set Ally Position"),
|
||||
_INTL("Set Enemy Position"),
|
||||
_INTL("Set Shadow Size"),
|
||||
_INTL("Set Shadow Position"),
|
||||
_INTL("Auto-Position Sprites")
|
||||
])
|
||||
cw.x = Graphics.width - cw.width
|
||||
cw.y = Graphics.height - cw.height
|
||||
cw.viewport = @viewport
|
||||
ret = -1
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
cw.update
|
||||
self.update
|
||||
if Input.trigger?(Input::USE)
|
||||
pbPlayDecisionSE
|
||||
ret = cw.index
|
||||
break
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCancelSE
|
||||
break
|
||||
end
|
||||
end
|
||||
cw.dispose
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChooseSpecies
|
||||
if @starting
|
||||
pbFadeInAndShow(@sprites) { update }
|
||||
@starting = false
|
||||
end
|
||||
cw = Window_CommandPokemonEx.newEmpty(0, 0, 260, 32 + 24 * 6, @viewport)
|
||||
cw.rowHeight = 24
|
||||
pbSetSmallFont(cw.contents)
|
||||
cw.x = Graphics.width - cw.width
|
||||
cw.y = Graphics.height - cw.height
|
||||
allspecies = []
|
||||
GameData::Species.each do |sp|
|
||||
name = (sp.form == 0) ? sp.name : _INTL("{1} (form {2})", sp.real_name, sp.form)
|
||||
allspecies.push([sp.id, sp.species, name]) if name && !name.empty?
|
||||
end
|
||||
allspecies.sort! { |a, b| a[2] <=> b[2] }
|
||||
commands = []
|
||||
allspecies.each { |sp| commands.push(sp[2]) }
|
||||
cw.commands = commands
|
||||
cw.index = @oldSpeciesIndex
|
||||
ret = nil
|
||||
oldindex = -1
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
cw.update
|
||||
if cw.index != oldindex
|
||||
oldindex = cw.index
|
||||
pbChangeSpecies(allspecies[cw.index][0])
|
||||
refresh
|
||||
end
|
||||
self.update
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbChangeSpecies(nil)
|
||||
refresh
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
pbChangeSpecies(allspecies[cw.index][0])
|
||||
ret = allspecies[cw.index][0]
|
||||
break
|
||||
end
|
||||
end
|
||||
@oldSpeciesIndex = cw.index
|
||||
cw.dispose
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SpritePositionerScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStart
|
||||
@scene.pbOpen
|
||||
loop do
|
||||
species = @scene.pbChooseSpecies
|
||||
break if !species
|
||||
loop do
|
||||
command = @scene.pbMenu(species)
|
||||
break if command < 0
|
||||
loop do
|
||||
par = @scene.pbSetParameter(command)
|
||||
break if !par
|
||||
command = (command + 1) % 3
|
||||
end
|
||||
end
|
||||
end
|
||||
@scene.pbClose
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user