mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added more information to terrain tag editor
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
# Terrain tags
|
# Terrain tags
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
module PBTerrain
|
module PBTerrain
|
||||||
|
None = 0
|
||||||
Ledge = 1
|
Ledge = 1
|
||||||
Grass = 2
|
Grass = 2
|
||||||
Sand = 3
|
Sand = 3
|
||||||
@@ -19,75 +20,61 @@ module PBTerrain
|
|||||||
Bridge = 15
|
Bridge = 15
|
||||||
Puddle = 16
|
Puddle = 16
|
||||||
|
|
||||||
def self.isSurfable?(tag)
|
module_function
|
||||||
return PBTerrain.isWater?(tag)
|
|
||||||
|
def isSurfable?(tag)
|
||||||
|
return isWater?(tag)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isWater?(tag)
|
def isWater?(tag)
|
||||||
return tag==PBTerrain::Water ||
|
return [Water, StillWater, DeepWater, WaterfallCrest, Waterfall].include?(tag)
|
||||||
tag==PBTerrain::StillWater ||
|
|
||||||
tag==PBTerrain::DeepWater ||
|
|
||||||
tag==PBTerrain::WaterfallCrest ||
|
|
||||||
tag==PBTerrain::Waterfall
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isPassableWater?(tag)
|
def isPassableWater?(tag)
|
||||||
return tag==PBTerrain::Water ||
|
return [Water, StillWater, DeepWater, WaterfallCrest].include?(tag)
|
||||||
tag==PBTerrain::StillWater ||
|
|
||||||
tag==PBTerrain::DeepWater ||
|
|
||||||
tag==PBTerrain::WaterfallCrest
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isJustWater?(tag)
|
def isJustWater?(tag)
|
||||||
return tag==PBTerrain::Water ||
|
return [Water, StillWater, DeepWater].include?(tag)
|
||||||
tag==PBTerrain::StillWater ||
|
|
||||||
tag==PBTerrain::DeepWater
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isDeepWater?(tag)
|
def isDeepWater?(tag)
|
||||||
return tag==PBTerrain::DeepWater
|
return tag == DeepWater
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isWaterfall?(tag)
|
def isWaterfall?(tag)
|
||||||
return tag==PBTerrain::WaterfallCrest ||
|
return [WaterfallCrest, Waterfall].include?(tag)
|
||||||
tag==PBTerrain::Waterfall
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isGrass?(tag)
|
def isGrass?(tag)
|
||||||
return tag==PBTerrain::Grass ||
|
return [Grass, TallGrass, UnderwaterGrass, SootGrass].include?(tag)
|
||||||
tag==PBTerrain::TallGrass ||
|
|
||||||
tag==PBTerrain::UnderwaterGrass ||
|
|
||||||
tag==PBTerrain::SootGrass
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isJustGrass?(tag) # The Poké Radar only works in these tiles
|
def isJustGrass?(tag) # The Poké Radar only works in these tiles
|
||||||
return tag==PBTerrain::Grass ||
|
return [Grass, SootGrass].include?(tag)
|
||||||
tag==PBTerrain::SootGrass
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isLedge?(tag)
|
def isLedge?(tag)
|
||||||
return tag==PBTerrain::Ledge
|
return tag == Ledge
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isIce?(tag)
|
def isIce?(tag)
|
||||||
return tag==PBTerrain::Ice
|
return tag == Ice
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isBridge?(tag)
|
def isBridge?(tag)
|
||||||
return tag==PBTerrain::Bridge
|
return tag == Bridge
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.hasReflections?(tag)
|
def hasReflections?(tag)
|
||||||
return tag==PBTerrain::StillWater ||
|
return [StillWater, Puddle].include?(tag)
|
||||||
tag==PBTerrain::Puddle
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.onlyWalk?(tag)
|
def onlyWalk?(tag)
|
||||||
return tag==PBTerrain::TallGrass ||
|
return [TallGrass, Ice].include?(tag)
|
||||||
tag==PBTerrain::Ice
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.isDoubleWildBattle?(tag)
|
def isDoubleWildBattle?(tag)
|
||||||
return tag==PBTerrain::TallGrass
|
return tag == TallGrass
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,44 +16,93 @@ end
|
|||||||
# Edits the terrain tags of tiles in tilesets.
|
# Edits the terrain tags of tiles in tilesets.
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class PokemonTilesetScene
|
class PokemonTilesetScene
|
||||||
TILESET_WIDTH = 256
|
TILE_SIZE = 32 # in pixels
|
||||||
TILE_SIZE = 32
|
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
|
||||||
|
@tilesetwrapper = pbTilesetWrapper
|
||||||
|
@tileset = @tilesetwrapper.data[1]
|
||||||
|
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
|
||||||
|
@sprites = {}
|
||||||
|
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("Tileset Editor\r\nPgUp/PgDn: 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
|
def pbUpdateTileset
|
||||||
@sprites["overlay"].bitmap.clear
|
@sprites["overlay"].bitmap.clear
|
||||||
textpos = []
|
|
||||||
@sprites["tileset"].src_rect = Rect.new(0, @topy, TILESET_WIDTH, Graphics.height)
|
@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
|
tilesize = @tileset.terrain_tags.xsize
|
||||||
for yy in 0...Graphics.height / TILE_SIZE
|
for yy in 0...Graphics.height / TILE_SIZE
|
||||||
ypos = (yy+(@topy/TILE_SIZE))*8+384
|
ypos = (yy + (@topy / TILE_SIZE)) * TILES_PER_ROW + TILESET_START_ID
|
||||||
next if ypos >= tilesize
|
next if ypos >= tilesize
|
||||||
for xx in 0...8
|
for xx in 0...TILES_PER_ROW
|
||||||
terr = ypos<384 ? @tileset.terrain_tags[xx*48] : @tileset.terrain_tags[ypos+xx]
|
if ypos < TILESET_START_ID
|
||||||
if ypos<384
|
@tilehelper.bltTile(@sprites["overlay"].bitmap, xx * TILE_SIZE, yy * TILE_SIZE, xx * TILES_PER_AUTOTILE)
|
||||||
@tilehelper.bltTile(@sprites["overlay"].bitmap,xx*TILE_SIZE,yy*TILE_SIZE,xx*48)
|
|
||||||
end
|
end
|
||||||
textpos.push(["#{terr}",xx*TILE_SIZE+TILE_SIZE/2,yy*TILE_SIZE,2,Color.new(80,80,80),Color.new(192,192,192)])
|
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, 2, TEXT_COLOR, TEXT_SHADOW_COLOR])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@sprites["overlay"].bitmap.fill_rect(@x,@y-@topy,TILE_SIZE,4,Color.new(255,0,0))
|
|
||||||
@sprites["overlay"].bitmap.fill_rect(@x,@y-@topy,4,TILE_SIZE,Color.new(255,0,0))
|
|
||||||
@sprites["overlay"].bitmap.fill_rect(@x,@y-@topy+28,TILE_SIZE,4,Color.new(255,0,0))
|
|
||||||
@sprites["overlay"].bitmap.fill_rect(@x+28,@y-@topy,4,TILE_SIZE,Color.new(255,0,0))
|
|
||||||
pbDrawTextPositions(@sprites["overlay"].bitmap, textpos)
|
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
|
end
|
||||||
|
|
||||||
def pbGetSelected(x,y)
|
def pbUpdateTileInformation
|
||||||
return (y<0) ? 48*(x/TILE_SIZE) : (y/TILE_SIZE)*8+384+(x/TILE_SIZE)
|
overlay = @sprites["overlay"].bitmap
|
||||||
end
|
tile_x = Graphics.width * 3 / 4 - TILE_SIZE
|
||||||
|
tile_y = Graphics.height / 2 - TILE_SIZE
|
||||||
def pbSetSelected(i,value)
|
tile_id = pbGetSelected(@x, @y) || 0
|
||||||
if i<384
|
# Draw tile (at 200% size)
|
||||||
for j in 0...48
|
@tilehelper.bltSmallTile(overlay, tile_x, tile_y, TILE_SIZE * 2, TILE_SIZE * 2, tile_id)
|
||||||
@tileset.terrain_tags[i+j] = value
|
# Draw box around tile image
|
||||||
end
|
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
|
||||||
|
terrain_tag_name = getConstantNameOrValue(PBTerrain, terrain_tag)
|
||||||
|
if terrain_tag_name == terrain_tag.to_s
|
||||||
|
terrain_tag_name = terrain_tag.to_s
|
||||||
else
|
else
|
||||||
@tileset.terrain_tags[i] = value
|
terrain_tag_name = sprintf("%d: %s", terrain_tag, terrain_tag_name)
|
||||||
end
|
end
|
||||||
|
textpos = [
|
||||||
|
[_INTL("Terrain Tag:"), tile_x + TILE_SIZE, tile_y + TILE_SIZE * 2 + 16, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)],
|
||||||
|
[terrain_tag_name, tile_x + TILE_SIZE, tile_y + TILE_SIZE * 2 + 48, 2, Color.new(248, 248, 248), Color.new(40, 40, 40)]
|
||||||
|
]
|
||||||
|
# Draw all text
|
||||||
|
pbDrawTextPositions(overlay, textpos)
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbChooseTileset
|
def pbChooseTileset
|
||||||
@@ -71,72 +120,58 @@ class PokemonTilesetScene
|
|||||||
@y = -TILE_SIZE
|
@y = -TILE_SIZE
|
||||||
@topy = -TILE_SIZE
|
@topy = -TILE_SIZE
|
||||||
pbUpdateTileset
|
pbUpdateTileset
|
||||||
|
@height = @sprites["tileset"].bitmap.height
|
||||||
end
|
end
|
||||||
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
|
def pbStartScene
|
||||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
|
||||||
@viewport.z = 99999
|
|
||||||
@tilesetwrapper = pbTilesetWrapper
|
|
||||||
@tileset = @tilesetwrapper.data[1]
|
|
||||||
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
|
|
||||||
@sprites = {}
|
|
||||||
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(_INTL("Tileset Editor\r\nPgUp/PgDn: 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(TILESET_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
|
|
||||||
pbFadeInAndShow(@sprites)
|
pbFadeInAndShow(@sprites)
|
||||||
########
|
|
||||||
loop do
|
loop do
|
||||||
Graphics.update
|
Graphics.update
|
||||||
Input.update
|
Input.update
|
||||||
if Input.repeat?(Input::UP)
|
if Input.repeat?(Input::UP)
|
||||||
@y -= TILE_SIZE
|
update_cursor_position(0, -1)
|
||||||
@y = -TILE_SIZE if @y<-TILE_SIZE
|
|
||||||
@topy = @y if @y<@topy
|
|
||||||
pbUpdateTileset
|
|
||||||
elsif Input.repeat?(Input::DOWN)
|
elsif Input.repeat?(Input::DOWN)
|
||||||
@y += TILE_SIZE
|
update_cursor_position(0, 1)
|
||||||
@y = height-TILE_SIZE if @y>=height-TILE_SIZE
|
|
||||||
@topy = @y-Graphics.height+TILE_SIZE if @y-@topy>=Graphics.height
|
|
||||||
pbUpdateTileset
|
|
||||||
elsif Input.repeat?(Input::LEFT)
|
elsif Input.repeat?(Input::LEFT)
|
||||||
@x -= TILE_SIZE
|
update_cursor_position(-1, 0)
|
||||||
@x = 0 if @x<0
|
|
||||||
pbUpdateTileset
|
|
||||||
elsif Input.repeat?(Input::RIGHT)
|
elsif Input.repeat?(Input::RIGHT)
|
||||||
@x += TILE_SIZE
|
update_cursor_position(1, 0)
|
||||||
@x = TILESET_WIDTH-TILE_SIZE if @x>=TILESET_WIDTH-TILE_SIZE
|
|
||||||
pbUpdateTileset
|
|
||||||
elsif Input.repeat?(Input::L)
|
elsif Input.repeat?(Input::L)
|
||||||
@y -= (Graphics.height/TILE_SIZE)*TILE_SIZE
|
update_cursor_position(0, -Graphics.height / TILE_SIZE)
|
||||||
@topy -= (Graphics.height/TILE_SIZE)*TILE_SIZE
|
|
||||||
@y = -TILE_SIZE if @y<-TILE_SIZE
|
|
||||||
@topy = @y if @y<@topy
|
|
||||||
@topy = -TILE_SIZE if @topy<-TILE_SIZE
|
|
||||||
pbUpdateTileset
|
|
||||||
elsif Input.repeat?(Input::R)
|
elsif Input.repeat?(Input::R)
|
||||||
@y += (Graphics.height/TILE_SIZE)*TILE_SIZE
|
update_cursor_position(0, Graphics.height / TILE_SIZE)
|
||||||
@topy += (Graphics.height/TILE_SIZE)*TILE_SIZE
|
|
||||||
@y = height-TILE_SIZE if @y>=height-TILE_SIZE
|
|
||||||
@topy = @y-Graphics.height+TILE_SIZE if @y-@topy>=Graphics.height
|
|
||||||
if @topy>=height-Graphics.height
|
|
||||||
@topy = height-Graphics.height
|
|
||||||
end
|
|
||||||
pbUpdateTileset
|
|
||||||
elsif Input.trigger?(Input::A)
|
elsif Input.trigger?(Input::A)
|
||||||
commands = [
|
commands = [
|
||||||
_INTL("Go to bottom"),
|
_INTL("Go to bottom"),
|
||||||
@@ -144,10 +179,9 @@ class PokemonTilesetScene
|
|||||||
_INTL("Change tileset"),
|
_INTL("Change tileset"),
|
||||||
_INTL("Cancel")
|
_INTL("Cancel")
|
||||||
]
|
]
|
||||||
ret = pbShowCommands(nil,commands,-1)
|
case pbShowCommands(nil,commands,-1)
|
||||||
case ret
|
|
||||||
when 0
|
when 0
|
||||||
@y = height-TILE_SIZE
|
@y = @height - TILE_SIZE
|
||||||
@topy = @y - Graphics.height + TILE_SIZE if @y - @topy >= Graphics.height
|
@topy = @y - Graphics.height + TILE_SIZE if @y - @topy >= Graphics.height
|
||||||
pbUpdateTileset
|
pbUpdateTileset
|
||||||
when 1
|
when 1
|
||||||
@@ -156,7 +190,6 @@ class PokemonTilesetScene
|
|||||||
pbUpdateTileset
|
pbUpdateTileset
|
||||||
when 2
|
when 2
|
||||||
pbChooseTileset
|
pbChooseTileset
|
||||||
height = @sprites["tileset"].bitmap.height
|
|
||||||
end
|
end
|
||||||
elsif Input.trigger?(Input::B)
|
elsif Input.trigger?(Input::B)
|
||||||
if pbConfirmMessage(_INTL("Save changes?"))
|
if pbConfirmMessage(_INTL("Save changes?"))
|
||||||
@@ -182,7 +215,6 @@ class PokemonTilesetScene
|
|||||||
pbUpdateTileset
|
pbUpdateTileset
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
########
|
|
||||||
pbFadeOutAndHide(@sprites)
|
pbFadeOutAndHide(@sprites)
|
||||||
pbDisposeSpriteHash(@sprites)
|
pbDisposeSpriteHash(@sprites)
|
||||||
@viewport.dispose
|
@viewport.dispose
|
||||||
|
|||||||
Reference in New Issue
Block a user