Fixed up text positioning and window sizes, fixed crash when choosing how many items to toss from the Bag

This commit is contained in:
Maruno17
2021-03-07 23:08:05 +00:00
parent 3ca08f27b8
commit 4c35a7ecfe
31 changed files with 342 additions and 438 deletions

View File

@@ -105,10 +105,9 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
idWidth = totalWidth*15/100
nameWidth = totalWidth*65/100
statusWidth = totalWidth*20/100
text_y = rect.y + 6
self.shadowtext(rect.x,text_y,idWidth,rect.height,id_text)
self.shadowtext(rect.x+idWidth,text_y,nameWidth,rect.height,name,0,(codeswitch) ? 1 : 0)
self.shadowtext(rect.x+idWidth+nameWidth,text_y,statusWidth,rect.height,status,1,colors)
self.shadowtext(rect.x,rect.y,idWidth,rect.height,id_text)
self.shadowtext(rect.x+idWidth,rect.y,nameWidth,rect.height,name,0,(codeswitch) ? 1 : 0)
self.shadowtext(rect.x+idWidth+nameWidth,rect.y,statusWidth,rect.height,status,1,colors)
end
end
@@ -234,11 +233,11 @@ def pbDebugDayCare
sprites["overlay"].bitmap.clear
textpos = []
for i in 0...2
textpos.push([_INTL("Pokémon {1}",i+1),Graphics.width/4+i*Graphics.width/2,8,2,base,shadow])
textpos.push([_INTL("Pokémon {1}",i+1),Graphics.width/4+i*Graphics.width/2,2,2,base,shadow])
end
for i in 0...pbDayCareDeposited
next if !$PokemonGlobal.daycare[i][0]
y = 40
y = 34
pkmn = $PokemonGlobal.daycare[i][0]
initlevel = $PokemonGlobal.daycare[i][1]
leveldiff = pkmn.level-initlevel
@@ -270,12 +269,12 @@ def pbDebugDayCare
textpos.push(["Cost: $#{cost}",8+i*Graphics.width/2,y,0,base,shadow])
end
if pbEggGenerated?
textpos.push(["Egg waiting for collection",Graphics.width/2,216,2,Color.new(248,248,0),shadow])
textpos.push(["Egg waiting for collection",Graphics.width/2,210,2,Color.new(248,248,0),shadow])
elsif pbDayCareDeposited==2
if pbDayCareGetCompat==0
textpos.push(["Pokémon cannot breed",Graphics.width/2,216,2,Color.new(248,96,96),shadow])
textpos.push(["Pokémon cannot breed",Graphics.width/2,210,2,Color.new(248,96,96),shadow])
else
textpos.push(["Pokémon can breed",Graphics.width/2,216,2,Color.new(64,248,64),shadow])
textpos.push(["Pokémon can breed",Graphics.width/2,210,2,Color.new(64,248,64),shadow])
end
end
pbDrawTextPositions(sprites["overlay"].bitmap,textpos)
@@ -397,13 +396,12 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
rect = drawCursor(index,rect)
nameWidth = rect.width*50/100
statusWidth = rect.width*50/100
text_y = rect.y + 6
if index==self.itemCount-2
# Advance roaming
self.shadowtext(_INTL("[All roam to new locations]"),rect.x,text_y,nameWidth,rect.height)
self.shadowtext(_INTL("[All roam to new locations]"),rect.x,rect.y,nameWidth,rect.height)
elsif index==self.itemCount-1
# Advance roaming
self.shadowtext(_INTL("[Clear all current roamer locations]"),rect.x,text_y,nameWidth,rect.height)
self.shadowtext(_INTL("[Clear all current roamer locations]"),rect.x,rect.y,nameWidth,rect.height)
else
pkmn = Settings::ROAMING_SPECIES[index]
name = GameData::Species.get(pkmn[0]).name + " (Lv. #{pkmn[1]})"
@@ -432,8 +430,8 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
else
status = "[NOT ROAMING][Switch #{pkmn[2]} is off]"
end
self.shadowtext(name,rect.x,text_y,nameWidth,rect.height)
self.shadowtext(status,rect.x+nameWidth,text_y,statusWidth,rect.height,1,statuscolor)
self.shadowtext(name,rect.x,rect.y,nameWidth,rect.height)
self.shadowtext(status,rect.x+nameWidth,rect.y,statusWidth,rect.height,1,statuscolor)
end
end
end
@@ -528,92 +526,6 @@ end
#===============================================================================
#
#===============================================================================
class PokemonDataCopy
attr_accessor :dataOldHash
attr_accessor :dataNewHash
attr_accessor :dataTime
attr_accessor :data
def crc32(x)
return Zlib::crc32(x)
end
def readfile(filename)
File.open(filename, "rb") { |f| f.read }
end
def writefile(str,filename)
File.open(filename, "wb") { |f| f.write(str) }
end
def filetime(filename)
File.open(filename, "r") { |f| f.mtime }
end
def initialize(data,datasave)
@datafile = data
@datasave = datasave
@data = readfile(@datafile)
@dataOldHash = crc32(@data)
@dataTime = filetime(@datafile)
end
def changed?
ts = readfile(@datafile)
tsDate = filetime(@datafile)
tsHash = crc32(ts)
return (tsHash!=@dataNewHash && tsHash!=@dataOldHash && tsDate>@dataTime)
end
def save(newtilesets)
newdata = Marshal.dump(newtilesets)
if !changed?
@data = newdata
@dataNewHash = crc32(newdata)
writefile(newdata,@datafile)
else
@dataOldHash = crc32(@data)
@dataNewHash = crc32(newdata)
@dataTime = filetime(@datafile)
@data = newdata
writefile(newdata,@datafile)
end
save_data(self,@datasave)
end
end
class PokemonDataWrapper
attr_reader :data
def initialize(file,savefile,prompt)
@savefile = savefile
@file = file
if pbRgssExists?(@savefile)
@ts = load_data(@savefile)
if !@ts.changed? || prompt.call==true
@data = Marshal.load(StringInput.new(@ts.data))
else
@ts = PokemonDataCopy.new(@file,@savefile)
@data = load_data(@file)
end
else
@ts = PokemonDataCopy.new(@file,@savefile)
@data = load_data(@file)
end
end
def save
@ts.save(@data)
end
end
#===============================================================================
# Text import/export for localisation
#===============================================================================

View File

@@ -6,7 +6,7 @@ module ShadowText
elsif align==1
x+=(w/2)-(width/2)
end
pbDrawShadowText(bitmap,x,y+6,w,h,t,
pbDrawShadowText(bitmap,x,y,w,h,t,
disabled ? Color.new(26*8,26*8,25*8) : Color.new(12*8,12*8,12*8),
Color.new(26*8,26*8,25*8))
end

View File

@@ -1,17 +1,3 @@
#===============================================================================
#
#===============================================================================
def pbTilesetWrapper
return PokemonDataWrapper.new(
"Data/Tilesets.rxdata",
"Data/TilesetsTemp.rxdata",
Proc.new{
pbMessage(_INTL("The editor has detected that the tileset data was recently edited in RPG Maker XP."))
next !pbConfirmMessage(_INTL("Do you want to load those recent edits?"))
}
)
end
#===============================================================================
# Edits the terrain tags of tiles in tilesets.
#===============================================================================
@@ -28,8 +14,8 @@ class PokemonTilesetScene
def initialize
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@tilesetwrapper = pbTilesetWrapper
@tileset = @tilesetwrapper.data[1]
@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\nPgUp/PgDn: SCROLL\r\nZ: MENU"),
@@ -65,7 +51,7 @@ class PokemonTilesetScene
@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, 2, TEXT_COLOR, TEXT_SHADOW_COLOR])
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)
@@ -98,8 +84,8 @@ class PokemonTilesetScene
terrain_tag_name = sprintf("%d: %s", terrain_tag, terrain_tag_name)
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)]
[_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)
@@ -107,12 +93,12 @@ class PokemonTilesetScene
def pbChooseTileset
commands = []
for i in 1...@tilesetwrapper.data.length
commands.push(sprintf("%03d %s", i, @tilesetwrapper.data[i].name))
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 = @tilesetwrapper.data[ret + 1]
@tileset = @tilesets_data[ret + 1]
@tilehelper.dispose
@tilehelper = TileDrawingHelper.fromTileset(@tileset)
@sprites["tileset"].setBitmap("Graphics/Tilesets/#{@tileset.tileset_name}")
@@ -193,8 +179,8 @@ class PokemonTilesetScene
end
elsif Input.trigger?(Input::BACK)
if pbConfirmMessage(_INTL("Save changes?"))
@tilesetwrapper.save
$data_tilesets = @tilesetwrapper.data
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)