mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
Remove Scripts folder to convert to submodule
This commit is contained in:
@@ -1,320 +0,0 @@
|
||||
|
||||
|
||||
#===
|
||||
|
||||
#===============================================================================
|
||||
# Metadata editor
|
||||
#===============================================================================
|
||||
def pbMetadataScreen(map_id = 0)
|
||||
loop do
|
||||
map_id = pbListScreen(_INTL("SET METADATA"), MapLister.new(map_id, true))
|
||||
break if map_id < 0
|
||||
pbEditMetadata(map_id)
|
||||
end
|
||||
end
|
||||
|
||||
def pbEditMetadata(map_id = 0)
|
||||
mapinfos = pbLoadMapInfos
|
||||
data = []
|
||||
if map_id == 0 # Global metadata
|
||||
map_name = _INTL("Global Metadata")
|
||||
metadata = GameData::Metadata.get
|
||||
properties = GameData::Metadata.editor_properties
|
||||
else # Map metadata
|
||||
map_name = mapinfos[map_id].name
|
||||
metadata = GameData::MapMetadata.try_get(map_id)
|
||||
metadata = GameData::Metadata.new({}) if !metadata
|
||||
properties = GameData::MapMetadata.editor_properties
|
||||
end
|
||||
properties.each do |property|
|
||||
data.push(metadata.property_from_string(property[0]))
|
||||
end
|
||||
if pbPropertyList(map_name, data, properties, true)
|
||||
if map_id == 0 # Global metadata
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:home => data[0],
|
||||
:wild_battle_BGM => data[1],
|
||||
:trainer_battle_BGM => data[2],
|
||||
:wild_victory_ME => data[3],
|
||||
:trainer_victory_ME => data[4],
|
||||
:wild_capture_ME => data[5],
|
||||
:surf_BGM => data[6],
|
||||
:bicycle_BGM => data[7],
|
||||
:player_A => data[8],
|
||||
:player_B => data[9],
|
||||
:player_C => data[10],
|
||||
:player_D => data[11],
|
||||
:player_E => data[12],
|
||||
:player_F => data[13],
|
||||
:player_G => data[14],
|
||||
:player_H => data[15]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::Metadata.register(metadata_hash)
|
||||
GameData::Metadata.save
|
||||
else # Map metadata
|
||||
# Construct metadata hash
|
||||
metadata_hash = {
|
||||
:id => map_id,
|
||||
:outdoor_map => data[0],
|
||||
:announce_location => data[1],
|
||||
:can_bicycle => data[2],
|
||||
:always_bicycle => data[3],
|
||||
:teleport_destination => data[4],
|
||||
:weather => data[5],
|
||||
:town_map_position => data[6],
|
||||
:dive_map_id => data[7],
|
||||
:dark_map => data[8],
|
||||
:safari_map => data[9],
|
||||
:snap_edges => data[10],
|
||||
:random_dungeon => data[11],
|
||||
:battle_background => data[12],
|
||||
:wild_battle_BGM => data[13],
|
||||
:trainer_battle_BGM => data[14],
|
||||
:wild_victory_ME => data[15],
|
||||
:trainer_victory_ME => data[16],
|
||||
:wild_capture_ME => data[17],
|
||||
:town_map_size => data[18],
|
||||
:battle_environment => data[19]
|
||||
}
|
||||
# Add metadata's data to records
|
||||
GameData::MapMetadata.register(metadata_hash)
|
||||
GameData::MapMetadata.save
|
||||
end
|
||||
Compiler.write_metadata
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Regional Dexes editor
|
||||
#===============================================================================
|
||||
def pbRegionalDexEditor(dex)
|
||||
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
viewport.z = 99999
|
||||
cmd_window = pbListWindow([])
|
||||
info = Window_AdvancedTextPokemon.newWithSize(
|
||||
_INTL("Z+Up/Down: Rearrange entries\nZ+Right: Insert new entry\nZ+Left: Delete entry\nD: Clear entry"),
|
||||
Graphics.width / 2, 64, Graphics.width / 2, Graphics.height - 64, viewport)
|
||||
info.z = 2
|
||||
dex.compact!
|
||||
ret = dex.clone
|
||||
commands = []
|
||||
refresh_list = true
|
||||
cmd = [0, 0] # [action, index in list]
|
||||
loop do
|
||||
# Populate commands
|
||||
if refresh_list
|
||||
loop do
|
||||
break if dex.length == 0 || dex[-1]
|
||||
dex.slice!(-1)
|
||||
end
|
||||
commands = []
|
||||
dex.each_with_index do |species, i|
|
||||
text = (species) ? GameData::Species.get(species).real_name : "----------"
|
||||
commands.push(sprintf("%03d: %s", i + 1, text))
|
||||
end
|
||||
commands.push(sprintf("%03d: ----------", commands.length + 1))
|
||||
cmd[1] = [cmd[1], commands.length - 1].min
|
||||
refresh_list = false
|
||||
end
|
||||
# Choose to do something
|
||||
cmd = pbCommands3(cmd_window, commands, -1, cmd[1], true)
|
||||
case cmd[0]
|
||||
when 1 # Swap entry up
|
||||
if cmd[1] < dex.length - 1
|
||||
dex[cmd[1] + 1], dex[cmd[1]] = dex[cmd[1]], dex[cmd[1] + 1]
|
||||
refresh_list = true
|
||||
end
|
||||
when 2 # Swap entry down
|
||||
if cmd[1] > 0
|
||||
dex[cmd[1] - 1], dex[cmd[1]] = dex[cmd[1]], dex[cmd[1] - 1]
|
||||
refresh_list = true
|
||||
end
|
||||
when 3 # Delete spot
|
||||
if cmd[1] < dex.length
|
||||
dex.delete_at(cmd[1])
|
||||
refresh_list = true
|
||||
end
|
||||
when 4 # Insert spot
|
||||
if cmd[1] < dex.length
|
||||
dex.insert(cmd[1], nil)
|
||||
refresh_list = true
|
||||
end
|
||||
when 5 # Clear spot
|
||||
if dex[cmd[1]]
|
||||
dex[cmd[1]] = nil
|
||||
refresh_list = true
|
||||
end
|
||||
when 0
|
||||
if cmd[1] >= 0 # Edit entry
|
||||
case pbMessage(_INTL("\\ts[]Do what with this entry?"),
|
||||
[_INTL("Change species"), _INTL("Clear"), _INTL("Insert entry"), _INTL("Delete entry"), _INTL("Cancel")], 5)
|
||||
when 0 # Change species
|
||||
species = pbChooseSpeciesList(dex[cmd[1]])
|
||||
if species
|
||||
dex[cmd[1]] = species
|
||||
dex.each_with_index { |s, i| dex[i] = nil if i != cmd[1] && s == species }
|
||||
refresh_list = true
|
||||
end
|
||||
when 1 # Clear spot
|
||||
if dex[cmd[1]]
|
||||
dex[cmd[1]] = nil
|
||||
refresh_list = true
|
||||
end
|
||||
when 2 # Insert spot
|
||||
if cmd[1] < dex.length
|
||||
dex.insert(cmd[1], nil)
|
||||
refresh_list = true
|
||||
end
|
||||
when 3 # Delete spot
|
||||
if cmd[1] < dex.length
|
||||
dex.delete_at(cmd[1])
|
||||
refresh_list = true
|
||||
end
|
||||
end
|
||||
else # Cancel
|
||||
case pbMessage(_INTL("Save changes?"),
|
||||
[_INTL("Yes"),_INTL("No"),_INTL("Cancel")],3)
|
||||
when 0 # Save all changes to Dex
|
||||
dex.slice!(-1) while !dex[-1]
|
||||
ret = dex
|
||||
break
|
||||
when 1 # Just quit
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
info.dispose
|
||||
cmd_window.dispose
|
||||
viewport.dispose
|
||||
ret.compact!
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbAppendEvoToFamilyArray(species, array, seenarray)
|
||||
return if seenarray[species]
|
||||
array.push(species)
|
||||
seenarray[species] = true
|
||||
evos = GameData::Species.get(species).get_evolutions
|
||||
if evos.length > 0
|
||||
evos.sort! { |a, b| GameData::Species.get(a[0]).id_number <=> GameData::Species.get(b[0]).id_number }
|
||||
subarray = []
|
||||
for i in evos
|
||||
pbAppendEvoToFamilyArray(i[0], subarray, seenarray)
|
||||
end
|
||||
array.push(subarray) if subarray.length > 0
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetEvoFamilies
|
||||
seen = []
|
||||
ret = []
|
||||
GameData::Species.each do |sp|
|
||||
next if sp.form > 0
|
||||
species = sp.get_baby_species
|
||||
next if seen[species]
|
||||
subret = []
|
||||
pbAppendEvoToFamilyArray(species, subret, seen)
|
||||
ret.push(subret.flatten) if subret.length > 0
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEvoFamiliesToStrings
|
||||
ret = []
|
||||
families = pbGetEvoFamilies
|
||||
for fam in 0...families.length
|
||||
string = ""
|
||||
for p in 0...families[fam].length
|
||||
if p>=3
|
||||
string += " + #{families[fam].length - 3} more"
|
||||
break
|
||||
end
|
||||
string += "/" if p > 0
|
||||
string += GameData::Species.get(families[fam][p]).name
|
||||
end
|
||||
ret[fam] = string
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Battle animations rearranger
|
||||
#===============================================================================
|
||||
def pbAnimationsOrganiser
|
||||
list = pbLoadBattleAnimations
|
||||
if !list || !list[0]
|
||||
pbMessage(_INTL("No animations exist."))
|
||||
return
|
||||
end
|
||||
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
viewport.z = 99999
|
||||
cmdwin = pbListWindow([])
|
||||
cmdwin.viewport = viewport
|
||||
cmdwin.z = 2
|
||||
title = Window_UnformattedTextPokemon.newWithSize(_INTL("Animations Organiser"),
|
||||
Graphics.width / 2, 0, Graphics.width / 2, 64, viewport)
|
||||
title.z = 2
|
||||
info = Window_AdvancedTextPokemon.newWithSize(_INTL("Z+Up/Down: Swap\nZ+Left: Delete\nZ+Right: Insert"),
|
||||
Graphics.width / 2, 64, Graphics.width / 2, Graphics.height - 64, viewport)
|
||||
info.z = 2
|
||||
commands = []
|
||||
refreshlist = true; oldsel = -1
|
||||
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 : "???"))
|
||||
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]
|
||||
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]
|
||||
refreshlist = true
|
||||
end
|
||||
elsif cmd[0]==3 # Delete spot
|
||||
list.delete_at(cmd[1])
|
||||
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)
|
||||
refreshlist = true
|
||||
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
|
||||
# Save animations here
|
||||
save_data(list,"Data/PkmnAnimations.rxdata")
|
||||
$PokemonTemp.battleAnims = nil
|
||||
pbMessage(_INTL("Data saved."))
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
title.dispose
|
||||
info.dispose
|
||||
cmdwin.dispose
|
||||
viewport.dispose
|
||||
end
|
||||
@@ -1,234 +0,0 @@
|
||||
#===============================================================================
|
||||
# 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
|
||||
@tilesets_data = load_data("Data/Tilesets.rxdata")
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Tileset Editor\r\nA/S: SCROLL\r\nZ: MENU"),
|
||||
TILESET_WIDTH, 0, Graphics.width - TILESET_WIDTH, 128, @viewport)
|
||||
@sprites["tileset"] = BitmapSprite.new(TILESET_WIDTH, Graphics.height, @viewport)
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@visible_height = @sprites["tileset"].bitmap.height / TILE_SIZE
|
||||
load_tileset(1)
|
||||
end
|
||||
|
||||
def open_screen
|
||||
pbFadeInAndShow(@sprites)
|
||||
end
|
||||
|
||||
def close_screen
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
@tilehelper.dispose
|
||||
if $game_map && $map_factory
|
||||
$map_factory.setup($game_map.map_id)
|
||||
$game_player.center($game_player.x, $game_player.y)
|
||||
if $scene.is_a?(Scene_Map)
|
||||
$scene.dispose
|
||||
$scene.createSpritesets
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def load_tileset(id)
|
||||
@tileset = @tilesets_data[id]
|
||||
@tilehelper.dispose if @tilehelper
|
||||
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
|
||||
@x = 0
|
||||
@y = 0
|
||||
@top_y = 0
|
||||
@height = (@tileset.terrain_tags.xsize - TILESET_START_ID) / TILES_PER_ROW + 1
|
||||
draw_tiles
|
||||
draw_overlay
|
||||
end
|
||||
|
||||
def choose_tileset
|
||||
commands = []
|
||||
for i in 1...@tilesets_data.length
|
||||
commands.push(sprintf("%03d %s", i, @tilesets_data[i].name))
|
||||
end
|
||||
ret = pbShowCommands(nil, commands, -1)
|
||||
load_tileset(ret + 1) if ret >= 0
|
||||
end
|
||||
|
||||
def draw_tiles
|
||||
@sprites["tileset"].bitmap.clear
|
||||
for yy in 0...@visible_height
|
||||
autotile_row = (@top_y == 0 && yy == 0) # Autotiles
|
||||
id_y_offset = (autotile_row) ? 0 : TILESET_START_ID + (@top_y + yy - 1) * TILES_PER_ROW
|
||||
for xx in 0...TILES_PER_ROW
|
||||
id_x_offset = (autotile_row) ? xx * TILES_PER_AUTOTILE : xx
|
||||
@tilehelper.bltTile(@sprites["tileset"].bitmap, xx * TILE_SIZE, yy * TILE_SIZE,
|
||||
id_y_offset + id_x_offset)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def draw_overlay
|
||||
@sprites["overlay"].bitmap.clear
|
||||
# Draw all text over tiles (terrain tag numbers)
|
||||
textpos = []
|
||||
for yy in 0...@visible_height
|
||||
for xx in 0...TILES_PER_ROW
|
||||
tile_id = tile_ID_from_coordinates(xx, @top_y + yy)
|
||||
terr = @tileset.terrain_tags[tile_id]
|
||||
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
|
||||
cursor_x = @x * TILE_SIZE
|
||||
cursor_y = (@y - @top_y) * TILE_SIZE
|
||||
@sprites["overlay"].bitmap.fill_rect(cursor_x, cursor_y, TILE_SIZE, 4, CURSOR_COLOR)
|
||||
@sprites["overlay"].bitmap.fill_rect(cursor_x, cursor_y, 4, TILE_SIZE, CURSOR_COLOR)
|
||||
@sprites["overlay"].bitmap.fill_rect(cursor_x, cursor_y + TILE_SIZE - 4, TILE_SIZE, 4, CURSOR_COLOR)
|
||||
@sprites["overlay"].bitmap.fill_rect(cursor_x + TILE_SIZE - 4, cursor_y, 4, TILE_SIZE, CURSOR_COLOR)
|
||||
# Draw information about selected tile on right side
|
||||
draw_tile_details
|
||||
end
|
||||
|
||||
def draw_tile_details
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
tile_x = Graphics.width * 3 / 4 - TILE_SIZE
|
||||
tile_y = Graphics.height / 2 - TILE_SIZE
|
||||
tile_id = tile_ID_from_coordinates(@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 tile_ID_from_coordinates(x, y)
|
||||
return x * TILES_PER_AUTOTILE if y == 0 # Autotile
|
||||
return TILESET_START_ID + (y - 1) * TILES_PER_ROW + x
|
||||
end
|
||||
|
||||
def set_terrain_tag_for_tile_ID(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
|
||||
old_top_y = @top_y
|
||||
if x_offset != 0
|
||||
@x += x_offset
|
||||
@x = @x.clamp(0, TILES_PER_ROW - 1)
|
||||
end
|
||||
if y_offset != 0
|
||||
@y += y_offset
|
||||
@y = @y.clamp(0, @height - 1)
|
||||
@top_y = @y if @y < @top_y
|
||||
@top_y = @y - @visible_height + 1 if @y >= @top_y + @visible_height
|
||||
@top_y = 0 if @top_y < 0
|
||||
end
|
||||
draw_tiles if @top_y != old_top_y
|
||||
draw_overlay if @x != old_x || @y != old_y
|
||||
end
|
||||
|
||||
def pbStartScene
|
||||
open_screen
|
||||
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, -@visible_height)
|
||||
elsif Input.repeat?(Input::JUMPDOWN)
|
||||
update_cursor_position(0, @visible_height)
|
||||
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
|
||||
update_cursor_position(0, 99999)
|
||||
when 1
|
||||
update_cursor_position(0, -99999)
|
||||
when 2
|
||||
choose_tileset
|
||||
end
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
if pbConfirmMessage(_INTL("Save changes?"))
|
||||
save_data(@tilesets_data, "Data/Tilesets.rxdata")
|
||||
$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 = tile_ID_from_coordinates(@x, @y)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, 99)
|
||||
params.setDefaultValue(@tileset.terrain_tags[selected])
|
||||
set_terrain_tag_for_tile_ID(selected, pbMessageChooseNumber(_INTL("Set the terrain tag."), params))
|
||||
draw_overlay
|
||||
end
|
||||
end
|
||||
close_screen
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbTilesetScreen
|
||||
pbFadeOutIn {
|
||||
scene = PokemonTilesetScene.new
|
||||
scene.pbStartScene
|
||||
}
|
||||
end
|
||||
@@ -1,590 +0,0 @@
|
||||
#===============================================================================
|
||||
# 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
|
||||
@@ -1,421 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
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/battlebg/indoorc"
|
||||
enemybase = "Graphics/Battlebacks/enemybase/indoorc"
|
||||
playerbase = "Graphics/Battlebacks/playerbase/indoorc"
|
||||
@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"].zoom_x = Settings::BACKRPSPRITE_SCALE
|
||||
@sprites["pokemon_0"].zoom_y = Settings::BACKRPSPRITE_SCALE
|
||||
@sprites["pokemon_0"].mirror = true
|
||||
|
||||
@sprites["pokemon_0"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["pokemon_0"].z = 1
|
||||
@sprites["pokemon_1"] = PokemonSprite.new(@viewport)
|
||||
@sprites["pokemon_1"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["pokemon_1"].z = 4
|
||||
# @sprites["pokemon_1"] = PokemonSprite.new(@viewport)
|
||||
@sprites["pokemon_1"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["pokemon_1"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
|
||||
@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
|
||||
next 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
|
||||
|
||||
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["pokemon_0"].setPokemonBitmapFromId(spe, true)
|
||||
@sprites["pokemon_1"].setPokemonBitmapFromId(spe)
|
||||
@sprites["shadow_1"].setBitmap(GameData::Species.shadow_filename(spe, frm))
|
||||
end
|
||||
|
||||
def pbShadowSize
|
||||
pbChangeSpecies(@species)
|
||||
refresh
|
||||
species_data = GameData::Species.get(@species)
|
||||
if pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s_%d", species_data.species, species_data.form)) ||
|
||||
pbResolveBitmap(sprintf("Graphics/Pokemon/Shadow/%s", species_data.species))
|
||||
pbMessage("This species has its own shadow sprite in Graphics/Pokemon/Shadow/. The shadow size metric cannot be edited.")
|
||||
return false
|
||||
end
|
||||
oldval = species_data.shadow_size
|
||||
cmdvals = [0]
|
||||
commands = [_INTL("None")]
|
||||
defindex = 0
|
||||
i = 0
|
||||
loop do
|
||||
i += 1
|
||||
fn = sprintf("Graphics/Pokemon/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
|
||||
@metricsChanged = true if species_data.shadow_size != oldval
|
||||
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
|
||||
# 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?
|
||||
allspecies.push([sp.id, sp.id_number, name]) if name && !name.empty? # Switched to descending order using the ID of the Pokemon
|
||||
end
|
||||
# allspecies.sort! { |a, b| a[2] <=> b[2] }
|
||||
allspecies.sort! { |a, b| b[1] <=> a[1] } # Switched to descending order using the ID of the Pokemon
|
||||
commands = []
|
||||
allspecies.each { |sp| commands.push(sp[2]) }
|
||||
cw.commands = commands
|
||||
cw.index = @oldSpeciesIndex
|
||||
ret = false
|
||||
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 = true
|
||||
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
|
||||
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