Removed redundant "\r" from various messages, removed usages of BitmapWrapper, fixed Lure Ball error in battles started in the Debug menu, improved Terrain Tag editor, fixed some Compiler errors, enabled vsync, fixed event graphics frozen to the screen when using $game_player.moveto directly.

This commit is contained in:
Maruno17
2023-05-04 21:28:00 +01:00
parent 5f20121e59
commit 48fb8dae73
44 changed files with 362 additions and 398 deletions

View File

@@ -2,14 +2,16 @@
# 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)
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
TILE_BACKGROUND = Color.magenta
CURSOR_COLOR = Color.new(255, 0, 0) # Red
CURSOR_OUTLINE_COLOR = Color.white
TEXT_COLOR = Color.white
TEXT_SHADOW_COLOR = Color.black
def initialize
@tilesets_data = load_data("Data/Tilesets.rxdata")
@@ -17,11 +19,14 @@ class PokemonTilesetScene
@viewport.z = 99999
@sprites = {}
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
_INTL("Tileset Editor\r\nA/S: SCROLL\r\nZ: MENU"),
_INTL("Tileset Editor\nA/S: SCROLL\nZ: MENU"),
TILESET_WIDTH, 0, Graphics.width - TILESET_WIDTH, 128, @viewport
)
@sprites["background"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites["tileset"] = BitmapSprite.new(TILESET_WIDTH, Graphics.height, @viewport)
@sprites["tileset"].z = 10
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
@sprites["overlay"].z = 20
pbSetSystemFont(@sprites["overlay"].bitmap)
@visible_height = @sprites["tileset"].bitmap.height / TILE_SIZE
load_tileset(1)
@@ -68,11 +73,14 @@ class PokemonTilesetScene
end
def draw_tiles
@sprites["background"].bitmap.clear
@sprites["tileset"].bitmap.clear
@visible_height.times do |yy|
autotile_row = (@top_y == 0 && yy == 0) # Autotiles
id_y_offset = (autotile_row) ? 0 : TILESET_START_ID + ((@top_y + yy - 1) * TILES_PER_ROW)
break if @top_y + yy >= @height
TILES_PER_ROW.times do |xx|
@sprites["background"].bitmap.fill_rect(xx * TILE_SIZE, yy * TILE_SIZE, TILE_SIZE, TILE_SIZE, TILE_BACKGROUND)
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)
@@ -88,33 +96,48 @@ class PokemonTilesetScene
TILES_PER_ROW.times do |xx|
tile_id = tile_ID_from_coordinates(xx, @top_y + yy)
terr = @tileset.terrain_tags[tile_id]
textpos.push([terr.to_s, (xx * TILE_SIZE) + (TILE_SIZE / 2), (yy * TILE_SIZE) + 6, :center, TEXT_COLOR, TEXT_SHADOW_COLOR])
next if terr == 0
textpos.push([terr.to_s, (xx * TILE_SIZE) + (TILE_SIZE / 2), (yy * TILE_SIZE) + 6,
:center, TEXT_COLOR, TEXT_SHADOW_COLOR, :outline])
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_cursor
# Draw information about selected tile on right side
draw_tile_details
end
def draw_cursor
cursor_x = @x * TILE_SIZE
cursor_y = (@y - @top_y) * TILE_SIZE
cursor_width = TILE_SIZE
cursor_height = TILE_SIZE
bitmap = @sprites["overlay"].bitmap
bitmap.fill_rect(cursor_x - 2, cursor_y - 2, cursor_width + 4, 8, CURSOR_OUTLINE_COLOR)
bitmap.fill_rect(cursor_x - 2, cursor_y - 2, 8, cursor_height + 4, CURSOR_OUTLINE_COLOR)
bitmap.fill_rect(cursor_x - 2, cursor_y + cursor_height - 6, cursor_width + 4, 8, CURSOR_OUTLINE_COLOR)
bitmap.fill_rect(cursor_x + cursor_width - 6, cursor_y - 2, 8, cursor_height + 4, CURSOR_OUTLINE_COLOR)
bitmap.fill_rect(cursor_x, cursor_y, cursor_width, 4, CURSOR_COLOR)
bitmap.fill_rect(cursor_x, cursor_y, 4, cursor_height, CURSOR_COLOR)
bitmap.fill_rect(cursor_x, cursor_y + cursor_height - 4, cursor_width, 4, CURSOR_COLOR)
bitmap.fill_rect(cursor_x + cursor_width - 4, cursor_y, 4, cursor_height, CURSOR_COLOR)
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_size = 4 # Size multiplier
tile_x = (Graphics.width * 3 / 4) - (TILE_SIZE * tile_size / 2)
tile_y = (Graphics.height / 2) - (TILE_SIZE * tile_size / 2)
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 tile (at 400% size)
@sprites["background"].bitmap.fill_rect(tile_x, tile_y, TILE_SIZE * tile_size, TILE_SIZE * tile_size, TILE_BACKGROUND)
@tilehelper.bltSmallTile(overlay, tile_x, tile_y, TILE_SIZE * tile_size, TILE_SIZE * tile_size, tile_id)
# Draw box around tile image
overlay.fill_rect(tile_x - 1, tile_y - 1, (TILE_SIZE * 2) + 2, 1, Color.white)
overlay.fill_rect(tile_x - 1, tile_y - 1, 1, (TILE_SIZE * 2) + 2, Color.white)
overlay.fill_rect(tile_x - 1, tile_y + (TILE_SIZE * 2), (TILE_SIZE * 2) + 2, 1, Color.white)
overlay.fill_rect(tile_x + (TILE_SIZE * 2), tile_y - 1, 1, (TILE_SIZE * 2) + 2, Color.white)
overlay.fill_rect(tile_x - 1, tile_y - 1, (TILE_SIZE * tile_size) + 2, 1, Color.white)
overlay.fill_rect(tile_x - 1, tile_y - 1, 1, (TILE_SIZE * tile_size) + 2, Color.white)
overlay.fill_rect(tile_x - 1, tile_y + (TILE_SIZE * tile_size), (TILE_SIZE * tile_size) + 2, 1, Color.white)
overlay.fill_rect(tile_x + (TILE_SIZE * tile_size), tile_y - 1, 1, (TILE_SIZE * tile_size) + 2, Color.white)
# Write terrain tag info about selected tile
terrain_tag = @tileset.terrain_tags[tile_id] || 0
if GameData::TerrainTag.exists?(terrain_tag)
@@ -123,8 +146,10 @@ class PokemonTilesetScene
terrain_tag_name = terrain_tag.to_s
end
textpos = [
[_INTL("Terrain Tag:"), tile_x + TILE_SIZE, tile_y + (TILE_SIZE * 2) + 22, :center, Color.new(248, 248, 248), Color.new(40, 40, 40)],
[terrain_tag_name, tile_x + TILE_SIZE, tile_y + (TILE_SIZE * 2) + 54, :center, Color.new(248, 248, 248), Color.new(40, 40, 40)]
[_INTL("Terrain Tag:"), Graphics.width * 3 / 4, tile_y + (TILE_SIZE * tile_size) + 22,
:center, Color.new(248, 248, 248), Color.new(40, 40, 40)],
[terrain_tag_name, Graphics.width * 3 / 4, tile_y + (TILE_SIZE * tile_size) + 54,
:center, Color.new(248, 248, 248), Color.new(40, 40, 40)]
]
# Draw all text
pbDrawTextPositions(overlay, textpos)
@@ -176,9 +201,9 @@ class PokemonTilesetScene
elsif Input.repeat?(Input::RIGHT)
update_cursor_position(1, 0)
elsif Input.repeat?(Input::JUMPUP)
update_cursor_position(0, -@visible_height)
update_cursor_position(0, -@visible_height / 2)
elsif Input.repeat?(Input::JUMPDOWN)
update_cursor_position(0, @visible_height)
update_cursor_position(0, @visible_height / 2)
elsif Input.trigger?(Input::ACTION)
commands = [
_INTL("Go to bottom"),

View File

@@ -107,7 +107,7 @@ class RegionMapSprite
def createRegionMap(map)
town_map = GameData::TownMap.get(map)
bitmap = AnimatedBitmap.new("Graphics/UI/Town Map/#{town_map.filename}").deanimate
retbitmap = BitmapWrapper.new(bitmap.width / 2, bitmap.height / 2)
retbitmap = Bitmap.new(bitmap.width / 2, bitmap.height / 2)
retbitmap.stretch_blt(
Rect.new(0, 0, bitmap.width / 2, bitmap.height / 2),
bitmap,
@@ -350,12 +350,12 @@ class MapScreenScene
end
def helpWindow
helptext = _INTL("A: Add map to canvas") + "\r\n"
helptext += _INTL("DEL: Delete map from canvas") + "\r\n"
helptext += _INTL("S: Go to another map") + "\r\n"
helptext += _INTL("Click to select a map") + "\r\n"
helptext += _INTL("Double-click: Edit map's metadata") + "\r\n"
helptext += _INTL("Drag map to move it") + "\r\n"
helptext = _INTL("A: Add map to canvas") + "\n"
helptext += _INTL("DEL: Delete map from canvas") + "\n"
helptext += _INTL("S: Go to another map") + "\n"
helptext += _INTL("Click to select a map") + "\n"
helptext += _INTL("Double-click: Edit map's metadata") + "\n"
helptext += _INTL("Drag map to move it") + "\n"
helptext += _INTL("Arrow keys/drag canvas: Move around canvas")
title = Window_UnformattedTextPokemon.newWithSize(
helptext, 0, 0, Graphics.width * 8 / 10, Graphics.height, @viewport

View File

@@ -262,21 +262,21 @@ module Battle::DebugMixin
return ret if battler.nil?
# Battler index, name
ret += sprintf("[%d] %s", battler.index, battler.pbThis)
ret += "\r\n"
ret += "\n"
# Species
ret += _INTL("Species: {1}", GameData::Species.get(battler.species).name)
ret += "\r\n"
ret += "\n"
# Form number
ret += _INTL("Form: {1}", battler.form)
ret += "\r\n"
ret += "\n"
# Level, gender, shininess
ret += _INTL("Level {1}, {2}", battler.level,
(battler.pokemon.male?) ? "" : (battler.pokemon.female?) ? "" : _INTL("genderless"))
ret += ", " + _INTL("shiny") if battler.pokemon.shiny?
ret += "\r\n"
ret += "\n"
# HP
ret += _INTL("HP: {1}/{2} ({3}%)", battler.hp, battler.totalhp, (100.0 * battler.hp / battler.totalhp).to_i)
ret += "\r\n"
ret += "\n"
# Status
ret += _INTL("Status: {1}", GameData::Status.get(battler.status).name)
case battler.status
@@ -287,7 +287,7 @@ module Battle::DebugMixin
ret += " " + _INTL("(toxic, {1}/16)", battler.effects[PBEffects::Toxic])
end
end
ret += "\r\n"
ret += "\n"
# Stat stages
stages = []
GameData::Stat.each_battle do |stat|
@@ -299,10 +299,10 @@ module Battle::DebugMixin
stages.push(stage_text)
end
ret += _INTL("Stat stages: {1}", (stages.empty?) ? "-" : stages.join(", "))
ret += "\r\n"
ret += "\n"
# Ability
ret += _INTL("Ability: {1}", (battler.ability) ? battler.abilityName : "-")
ret += "\r\n"
ret += "\n"
# Held item
ret += _INTL("Item: {1}", (battler.item) ? battler.itemName : "-")
return ret
@@ -314,18 +314,18 @@ module Battle::DebugMixin
sp_data = pkmn.species_data
# Name, species
ret += sprintf("%s (%s)", pkmn.name, sp_data.name)
ret += "\r\n"
ret += "\n"
# Form number
ret += _INTL("Form: {1}", sp_data.form)
ret += "\r\n"
ret += "\n"
# Level, gender, shininess
ret += _INTL("Level {1}, {2}", pkmn.level,
(pkmn.male?) ? "" : (pkmn.female?) ? "" : _INTL("genderless"))
ret += ", " + _INTL("shiny") if pkmn.shiny?
ret += "\r\n"
ret += "\n"
# HP
ret += _INTL("HP: {1}/{2} ({3}%)", pkmn.hp, pkmn.totalhp, (100.0 * pkmn.hp / pkmn.totalhp).to_i)
ret += "\r\n"
ret += "\n"
# Status
ret += _INTL("Status: {1}", GameData::Status.get(pkmn.status).name)
case pkmn.status
@@ -334,10 +334,10 @@ module Battle::DebugMixin
when :POISON
ret += " " + _INTL("(toxic)") if pkmn.statusCount > 0
end
ret += "\r\n"
ret += "\n"
# Ability
ret += _INTL("Ability: {1}", pkmn.ability&.name || "-")
ret += "\r\n"
ret += "\n"
# Held item
ret += _INTL("Item: {1}", pkmn.item&.name || "-")
return ret

View File

@@ -252,10 +252,10 @@ MenuHandlers.add(:battle_debug_menu, :weather, {
msg = _INTL("Current weather: {1}", weather_data.name || _INTL("Unknown"))
if weather_data.id != :None
if battle.field.weatherDuration > 0
msg += "\r\n"
msg += "\n"
msg += _INTL("Duration : {1} more round(s)", battle.field.weatherDuration)
elsif battle.field.weatherDuration < 0
msg += "\r\n"
msg += "\n"
msg += _INTL("Duration : Infinite")
end
end
@@ -314,10 +314,10 @@ MenuHandlers.add(:battle_debug_menu, :terrain, {
msg = _INTL("Current terrain: {1}", terrain_data.name || _INTL("Unknown"))
if terrain_data.id != :None
if battle.field.terrainDuration > 0
msg += "\r\n"
msg += "\n"
msg += _INTL("Duration : {1} more round(s)", battle.field.terrainDuration)
elsif battle.field.terrainDuration < 0
msg += "\r\n"
msg += "\n"
msg += _INTL("Duration : Infinite")
end
end
@@ -373,7 +373,7 @@ MenuHandlers.add(:battle_debug_menu, :environment_time, {
loop do
environment_data = GameData::Environment.try_get(battle.environment)
msg = _INTL("Environment: {1}", environment_data.name || _INTL("Unknown"))
msg += "\r\n"
msg += "\n"
msg += _INTL("Time of day: {1}", [_INTL("Day"), _INTL("Evening"), _INTL("Night")][battle.time])
cmd = pbMessage("\\ts[]" + msg, [_INTL("Change environment"),
_INTL("Change time of day")], -1, nil, cmd)

View File

@@ -431,7 +431,7 @@ MenuHandlers.add(:battle_pokemon_debug_menu, :set_types, {
commands.push(_INTL("Extra type: {1}", extra_type_name))
types.push(extra_type)
msg = _INTL("Effective types: {1}", battler.pbTypes(true).map { |t| GameData::Type.get(t).name }.join("/"))
msg += "\r\n" + _INTL("(Change a type to itself to remove it.)")
msg += "\n" + _INTL("(Change a type to itself to remove it.)")
cmd = pbMessage("\\ts[]" + msg, commands, -1, nil, cmd)
break if cmd < 0
old_type = types[cmd]

View File

@@ -632,7 +632,7 @@ class TrainerBattleLister
tr_data = GameData::Trainer.get(@ids[index][0], @ids[index][1], @ids[index][2])
if tr_data
tr_data.pokemon.each_with_index do |pkmn, i|
text += "\r\n" if i > 0
text += "\n" if i > 0
text += sprintf("%s Lv.%d", GameData::Species.get(pkmn[:species]).real_name, pkmn[:level])
end
end