• The Eevee Expo Game Jam #10 has concluded, congratulations to all participants! Now it's time for the judges to play through the games, and you can play along to vote who deserves the community choice spotlight.
    You can check out the submitted games here!
    Play through the games and provide some feedback to the devs while you're at it!
  • Hi, Guest!
    Some images might be missing as we move away from using embedded images, sorry for the mess!
    From now on, you'll be required to use a third party to host images. You can learn how to add images here, and if your thread is missing images you can request them here.
    Do not use Discord to host any images you post, these links expire quickly!
Westrah's Non-binary Support

Resource Westrah's Non-binary Support 1.0

sapphirechuu

Rookie
Member
Joined
Mar 13, 2023
Posts
8
any chance we can get someone to update this script for v21.1?
I just finished going through to upgrade my project to v21.1 from v20 and the code is all pretty much exactly the same. You gotta move around UI pictures because the folder setup is different but overall, everything is the same.
 

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
I'm just used this tutorial and... this error popped up. Followed everything to a T, except I changed the colors.

1699766676850.png
1699766799044.png
1699766901872.png
1699766950115.png

1699767009751.png
1699767062480.png

1699767094919.png

Far as I can tell, I've followed everything I'm supposed to, so I'm not sure what's going on, unless it needs to change for 21.1? The only thing different I've really noticed is that 21.1 has done away with HEX and only uses RGB.
 
Last edited:

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
662
The error message is telling you that there is something wrong with the UI_Pokegear script. Since it mentions line 212 and the default version of the script is only 207 lines long, I would suggest sharing the whole code to see where the error is.
 

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
The error message is telling you that there is something wrong with the UI_Pokegear script. Since it mentions line 212 and the default version of the script is only 207 lines long, I would suggest sharing the whole code to see where the error is.

#===============================================================================
#
#===============================================================================
class PokegearButton < Sprite
attr_reader :index
attr_reader :name
attr_reader :selected

TEXT_BASE_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(40, 40, 40)

def initialize(command, x, y, viewport = nil)
super(viewport)
@image = command[0]
@Name = command[1]
@selected = false

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_2"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_2")
end
end

@contents = Bitmap.new(@button.width, @button.height)
self.bitmap = @contents
self.x = x - (@button.width / 2)
self.y = y
pbSetSystemFont(self.bitmap)
refresh
end

def dispose
@button.dispose
@contents.dispose
super
end

def selected=(val)
oldsel = @selected
@selected = val
refresh if oldsel != val
end

def refresh
self.bitmap.clear
rect = Rect.new(0, 0, @button.width, @button.height / 2)
rect.y = @button.height / 2 if @selected
self.bitmap.blt(0, 0, @button.bitmap, rect)
textpos = [
[@name, rect.width / 2, (rect.height / 2) - 10, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]
]
pbDrawTextPositions(self.bitmap, textpos)
imagepos = [
[sprintf("Graphics/UI/Pokegear/icon_%s", @image), 18, 10]
]
pbDrawImagePositions(self.bitmap, imagepos)
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegear_Scene
def pbUpdate
@commands.length.times do |i|
@sprites["button#{i}"].selected = (i == @index)
end
pbUpdateSpriteHash(@sprites)
end

def pbStartScene(commands)
@commands = commands
@index = 0
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_2"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_2")
end
end

def pbScene
ret = -1
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
elsif Input.trigger?(Input::USE)
pbPlayDecisionSE
ret = @index
break
elsif Input.trigger?(Input::UP)
pbPlayCursorSE if @commands.length > 1
@index -= 1
@index = @commands.length - 1 if @index < 0
elsif Input.trigger?(Input::DOWN)
pbPlayCursorSE if @commands.length > 1
@index += 1
@index = 0 if @index >= @commands.length
end
end
return ret
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
dispose
end

def dispose
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegearScreen
def initialize(scene)
@scene = scene
end

def pbStartScreen
# Get all commands
command_list = []
commands = []
MenuHandlers.each_available(:pokegear_menu) do |option, hash, name|
command_list.push([hash["icon_name"] || "", name])
commands.push(hash)
end
@scene.pbStartScene(command_list)
# Main loop
end_scene = false
loop do
choice = @scene.pbScene
if choice < 0
end_scene = true
break
end
break if commands[choice]["effect"].call(@scene)
end
@scene.pbEndScene if end_scene
end
end

#===============================================================================
#
#===============================================================================
MenuHandlers.add(:pokegear_menu, :map, {
"name" => _INTL("Map"),
"icon_name" => "map",
"order" => 10,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
if ret
$game_temp.fly_destination = ret
menu.dispose
next 99999
end
end
next $game_temp.fly_destination
}
})

MenuHandlers.add(:pokegear_menu, :phone, {
"name" => _INTL("Phone"),
"icon_name" => "phone",
"order" => 20,
# "condition" => proc { next $PokemonGlobal.phone && $PokemonGlobal.phone.contacts.length > 0 },
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonPhone_Scene.new
screen = PokemonPhoneScreen.new(scene)
screen.pbStartScreen
end
next false
}
})

MenuHandlers.add(:pokegear_menu, :jukebox, {
"name" => _INTL("Jukebox"),
"icon_name" => "jukebox",
"order" => 30,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
end
next false
}
})

Here it is. I can also attach it to a .doc if that'd be easier?

Okay I must be tired because I just realized it doesn't have an END at the very end? I'm not sure how that happened, I'm pretty sure I never touched that area? Sorry about this. I'll fix it but, hey, if it happens to anyone else I suppose they got my message to help. ^~^'''
 

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
... well now I've got this error, jeezuz.

1699775706875.png
#===============================================================================
#
#===============================================================================
class PokemonLoadPanel < Sprite
attr_reader :selected

TEXTCOLOR = Color.new(232, 232, 232)
TEXTSHADOWCOLOR = Color.new(136, 136, 136)
MALETEXTCOLOR = Color.new(56, 160, 248)
MALETEXTSHADOWCOLOR = Color.new(43, 124, 192)
FEMALETEXTCOLOR = Color.new(219, 166, 238)
FEMALETEXTSHADOWCOLOR = Color.new(158, 109, 176)
NBTEXTCOLOR = Color.new(80, 227, 125)
NBTEXTSHADOWCOLOR = Color.new(56, 158, 87)

def initialize(index, title, isContinue, trainer, stats, mapid, viewport = nil)
super(viewport)
@index = index
@title = title
@isContinue = isContinue
@trainer = trainer
@totalsec = stats&.play_time.to_i || 0
@mapid = mapid
@selected = (index == 0)
@bgbitmap = AnimatedBitmap.new("Graphics/UI/Load/panels")
@refreshBitmap = true
@refreshing = false
refresh
end

def dispose
@bgbitmap.dispose
self.bitmap.dispose
super
end

def selected=(value)
return if @selected == value
@selected = value
@refreshBitmap = true
refresh
end

def pbRefresh
@refreshBitmap = true
refresh
end

def refresh
return if @refreshing
return if disposed?
@refreshing = true
if !self.bitmap || self.bitmap.disposed?
self.bitmap = Bitmap.new(@bgbitmap.width, 222)
pbSetSystemFont(self.bitmap)
end
if @refreshBitmap
@refreshBitmap = false
self.bitmap&.clear
if @isContinue
self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, (@selected) ? 222 : 0, @bgbitmap.width, 222))
else
self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, 444 + ((@selected) ? 46 : 0), @bgbitmap.width, 46))
end
textpos = []
if @isContinue
textpos.push([@title, 32, 16, :left, TEXT_COLOR, TEXT_SHADOW_COLOR])
textpos.push([_INTL("Badges:"), 32, 118, :left, TEXT_COLOR, TEXT_SHADOW_COLOR])
textpos.push([@trainer.badge_count.to_s, 206, 118, :right, TEXT_COLOR, TEXT_SHADOW_COLOR])
textpos.push([_INTL("Pokédex:"), 32, 150, :left, TEXT_COLOR, TEXT_SHADOW_COLOR])
textpos.push([@trainer.pokedex.seen_count.to_s, 206, 150, :right, TEXT_COLOR, TEXT_SHADOW_COLOR])
textpos.push([_INTL("Time:"), 32, 182, :left, TEXT_COLOR, TEXT_SHADOW_COLOR])
hour = @totalsec / 60 / 60
min = @totalsec / 60 % 60
if hour > 0
textpos.push([_INTL("{1}h {2}m", hour, min), 206, 182, :right, TEXT_COLOR, TEXT_SHADOW_COLOR])
else
textpos.push([_INTL("{1}m", min), 206, 182, :right, TEXT_COLOR, TEXT_SHADOW_COLOR])
end

case @trainer.gender
when 0 # Male
textpos.push([@trainer.name, 112, 70, 0, MALETEXTCOLOR, MALETEXTSHADOWCOLOR])
when 1 # Female
textpos.push([@trainer.name, 112, 70, 0, FEMALETEXTCOLOR, FEMALETEXTSHADOWCOLOR])
when 2 # Nonbinary
textpos.push([@trainer.name, 112, 70, 0, NBTEXTCOLOR, NBTEXTSHADOWCOLOR])
else # just as insurance, probably won't ever run tbh
textpos.push([@trainer.name, 112, 70, 0, TEXTCOLOR, TEXTSHADOWCOLOR])
end

mapname = pbGetMapNameFromId(@mapid)
mapname.gsub!(/\\PN/, @trainer.name)
textpos.push([mapname, 386, 16, :right, TEXT_COLOR, TEXT_SHADOW_COLOR])
else
textpos.push([@title, 32, 14, :left, TEXT_COLOR, TEXT_SHADOW_COLOR])
end
pbDrawTextPositions(self.bitmap, textpos)
end
@refreshing = false
end
end

#===============================================================================
#
#===============================================================================
class PokemonLoad_Scene
def pbStartScene(commands, show_continue, trainer, stats, map_id)
@commands = commands
@sprites = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99998
addBackgroundOrColoredPlane(@sprites, "background", "Load/bg", Color.new(248, 248, 248), @viewport)
y = 32
commands.length.times do |i|
@sprites["panel#{i}"] = PokemonLoadPanel.new(
i, commands, (show_continue) ? (i == 0) : false, trainer, stats, map_id, @viewport
)
@sprites["panel#{i}"].x = 48
@sprites["panel#{i}"].y = y
@sprites["panel#{i}"].pbRefresh
y += (show_continue && i == 0) ? 224 : 48
end
@sprites["cmdwindow"] = Window_CommandPokemon.new([])
@sprites["cmdwindow"].viewport = @viewport
@sprites["cmdwindow"].visible = false
end

def pbStartScene2
pbFadeInAndShow(@sprites) { pbUpdate }
end

def pbStartDeleteScene
@sprites = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99998
addBackgroundOrColoredPlane(@sprites, "background", "Load/bg", Color.new(248, 248, 248), @viewport)
end

def pbUpdate
oldi = @sprites["cmdwindow"].index rescue 0
pbUpdateSpriteHash(@sprites)
newi = @sprites["cmdwindow"].index rescue 0
if oldi != newi
@sprites["panel#{oldi}"].selected = false
@sprites["panel#{oldi}"].pbRefresh
@sprites["panel#{newi}"].selected = true
@sprites["panel#{newi}"].pbRefresh
while @sprites["panel#{newi}"].y > Graphics.height - 80
@commands.length.times do |i|
@sprites["panel#{i}"].y -= 48
end
6.times do |i|
break if !@sprites["party#{i}"]
@sprites["party#{i}"].y -= 48
end
@sprites["player"].y -= 48 if @sprites["player"]
end
while @sprites["panel#{newi}"].y < 32
@commands.length.times do |i|
@sprites["panel#{i}"].y += 48
end
6.times do |i|
break if !@sprites["party#{i}"]
@sprites["party#{i}"].y += 48
end
@sprites["player"].y += 48 if @sprites["player"]
end
end
end

def pbSetParty(trainer)
return if !trainer || !trainer.party
meta = GameData::PlayerMetadata.get(trainer.character_ID)
if meta
filename = pbGetPlayerCharset(meta.walk_charset, trainer, true)
@sprites["player"] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites["player"].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").", trainer.character_ID, filename)
end
charwidth = @sprites["player"].bitmap.width
charheight = @sprites["player"].bitmap.height
@sprites["player"].x = 112 - (charwidth / 8)
@sprites["player"].y = 112 - (charheight / 8)
@sprites["player"].z = 99999
end
trainer.party.each_with_index do |pkmn, i|
@sprites["party#{i}"] = PokemonIconSprite.new(pkmn, @viewport)
@sprites["party#{i}"].setOffset(PictureOrigin::CENTER)
@sprites["party#{i}"].x = 334 + (66 * (i % 2))
@sprites["party#{i}"].y = 112 + (50 * (i / 2))
@sprites["party#{i}"].z = 99999
end
end

def pbChoose(commands)
@sprites["cmdwindow"].commands = commands
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::USE)
return @sprites["cmdwindow"].index
end
end
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end

def pbCloseScene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonLoadScreen
def initialize(scene)
@scene = scene
if SaveData.exists?
@save_data = load_save_file(SaveData::FILE_PATH)
else
@save_data = {}
end
end

# @param file_path [String] file to load save data from
# @return [Hash] save data
def load_save_file(file_path)
save_data = SaveData.read_from_file(file_path)
unless SaveData.valid?(save_data)
if File.file?(file_path + ".bak")
pbMessage(_INTL("The save file is corrupt. A backup will be loaded."))
save_data = load_save_file(file_path + ".bak")
else
self.prompt_save_deletion
return {}
end
end
return save_data
end

# Called if all save data is invalid.
# Prompts the player to delete the save files.
def prompt_save_deletion
pbMessage(_INTL("The save file is corrupt, or is incompatible with this game.") + "\1")
exit unless pbConfirmMessageSerious(
_INTL("Do you want to delete the save file and start anew?")
)
self.delete_save_data
$game_system = Game_System.new
$PokemonSystem = PokemonSystem.new
end

def pbStartDeleteScreen
@scene.pbStartDeleteScene
@scene.pbStartScene2
if SaveData.exists?
if pbConfirmMessageSerious(_INTL("Delete all saved data?"))
pbMessage(_INTL("Once data has been deleted, there is no way to recover it.") + "\1")
if pbConfirmMessageSerious(_INTL("Delete the saved data anyway?"))
pbMessage(_INTL("Deleting all data. Don't turn off the power.") + "\\wtnp[0]")
self.delete_save_data
end
end
else
pbMessage(_INTL("No save file was found."))
end
@scene.pbEndScene
$scene = pbCallTitle
end

def delete_save_data
begin
SaveData.delete_file
pbMessage(_INTL("The saved data was deleted."))
rescue SystemCallError
pbMessage(_INTL("All saved data could not be deleted."))
end
end

def pbStartLoadScreen
commands = []
cmd_continue = -1
cmd_new_game = -1
cmd_options = -1
cmd_language = -1
cmd_mystery_gift = -1
cmd_debug = -1
cmd_quit = -1
show_continue = !@save_data.empty?
if show_continue
commands[cmd_continue = commands.length] = _INTL("Continue")
if @save_data[:player].mystery_gift_unlocked
commands[cmd_mystery_gift = commands.length] = _INTL("Mystery Gift")
end
end
commands[cmd_new_game = commands.length] = _INTL("New Game")
commands[cmd_options = commands.length] = _INTL("Options")
commands[cmd_language = commands.length] = _INTL("Language") if Settings::LANGUAGES.length >= 2
commands[cmd_debug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmd_quit = commands.length] = _INTL("Quit Game")
map_id = show_continue ? @save_data[:map_factory].map.map_id : 0
@scene.pbStartScene(commands, show_continue, @save_data[:player], @save_data[:stats], map_id)
@scene.pbSetParty(@save_data[:player]) if show_continue
@scene.pbStartScene2
loop do
command = @scene.pbChoose(commands)
pbPlayDecisionSE if command != cmd_quit
case command
when cmd_continue
@scene.pbEndScene
Game.load(@save_data)
return
when cmd_new_game
@scene.pbEndScene
Game.start_new
return
when cmd_mystery_gift
pbFadeOutIn { pbDownloadMysteryGift(@save_data[:player]) }
when cmd_options
pbFadeOutIn do
scene = PokemonOption_Scene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen(true)
end
when cmd_language
@scene.pbEndScene
$PokemonSystem.language = pbChooseLanguage
MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1])
if show_continue
@save_data[:pokemon_system] = $PokemonSystem
File.open(SaveData::FILE_PATH, "wb") { |file| Marshal.dump(@save_data, file) }
end
$scene = pbCallTitle
return
when cmd_debug
pbFadeOutIn { pbDebugMenu(false) }
when cmd_quit
pbPlayCloseMenuSE
@scene.pbEndScene
$scene = nil
return
else
pbPlayBuzzerSE
end
end
end
end

At least this might help others who are struggling...
 

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
662
#===============================================================================
#
#===============================================================================
class PokegearButton < Sprite
attr_reader :index
attr_reader :name
attr_reader :selected

TEXT_BASE_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(40, 40, 40)

def initialize(command, x, y, viewport = nil)
super(viewport)
@image = command[0]
@Name = command[1]
@selected = false

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_2"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_2")
end
end

@contents = Bitmap.new(@button.width, @button.height)
self.bitmap = @contents
self.x = x - (@button.width / 2)
self.y = y
pbSetSystemFont(self.bitmap)
refresh
end

def dispose
@button.dispose
@contents.dispose
super
end

def selected=(val)
oldsel = @selected
@selected = val
refresh if oldsel != val
end

def refresh
self.bitmap.clear
rect = Rect.new(0, 0, @button.width, @button.height / 2)
rect.y = @button.height / 2 if @selected
self.bitmap.blt(0, 0, @button.bitmap, rect)
textpos = [
[@name, rect.width / 2, (rect.height / 2) - 10, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]
]
pbDrawTextPositions(self.bitmap, textpos)
imagepos = [
[sprintf("Graphics/UI/Pokegear/icon_%s", @image), 18, 10]
]
pbDrawImagePositions(self.bitmap, imagepos)
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegear_Scene
def pbUpdate
@commands.length.times do |i|
@sprites["button#{i}"].selected = (i == @index)
end
pbUpdateSpriteHash(@sprites)
end

def pbStartScene(commands)
@commands = commands
@index = 0
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_2"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_2")
end
end

def pbScene
ret = -1
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
elsif Input.trigger?(Input::USE)
pbPlayDecisionSE
ret = @index
break
elsif Input.trigger?(Input::UP)
pbPlayCursorSE if @commands.length > 1
@index -= 1
@index = @commands.length - 1 if @index < 0
elsif Input.trigger?(Input::DOWN)
pbPlayCursorSE if @commands.length > 1
@index += 1
@index = 0 if @index >= @commands.length
end
end
return ret
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
dispose
end

def dispose
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegearScreen
def initialize(scene)
@scene = scene
end

def pbStartScreen
# Get all commands
command_list = []
commands = []
MenuHandlers.each_available(:pokegear_menu) do |option, hash, name|
command_list.push([hash["icon_name"] || "", name])
commands.push(hash)
end
@scene.pbStartScene(command_list)
# Main loop
end_scene = false
loop do
choice = @scene.pbScene
if choice < 0
end_scene = true
break
end
break if commands[choice]["effect"].call(@scene)
end
@scene.pbEndScene if end_scene
end
end

#===============================================================================
#
#===============================================================================
MenuHandlers.add(:pokegear_menu, :map, {
"name" => _INTL("Map"),
"icon_name" => "map",
"order" => 10,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
if ret
$game_temp.fly_destination = ret
menu.dispose
next 99999
end
end
next $game_temp.fly_destination
}
})

MenuHandlers.add(:pokegear_menu, :phone, {
"name" => _INTL("Phone"),
"icon_name" => "phone",
"order" => 20,
# "condition" => proc { next $PokemonGlobal.phone && $PokemonGlobal.phone.contacts.length > 0 },
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonPhone_Scene.new
screen = PokemonPhoneScreen.new(scene)
screen.pbStartScreen
end
next false
}
})

MenuHandlers.add(:pokegear_menu, :jukebox, {
"name" => _INTL("Jukebox"),
"icon_name" => "jukebox",
"order" => 30,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
end
next false
}
})

Here it is. I can also attach it to a .doc if that'd be easier?

Okay I must be tired because I just realized it doesn't have an END at the very end? I'm not sure how that happened, I'm pretty sure I never touched that area? Sorry about this. I'll fix it but, hey, if it happens to anyone else I suppose they got my message to help. ^~^'''
Not really the very end.
1699775896370.png

As you can see in this image, you are missing an "end" in def pbStartScene(commands). It should end with 3 end instead of the 2 you have.

As for the other error you are having. You defined the colors as "TEXTCOLOR" and "TEXTSHADOWCOLOR" but then called for them using "TEXT_COLOR" and "TEXT_SHADOW_COLOR". You see the errors here, right?
 

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
Not really the very end.
View attachment 22575
As you can see in this image, you are missing an "end" in def pbStartScene(commands). It should end with 3 end instead of the 2 you have.

As for the other error you are having. You defined the colors as "TEXTCOLOR" and "TEXTSHADOWCOLOR" but then called for them using "TEXT_COLOR" and "TEXT_SHADOW_COLOR". You see the errors here, right?
I removed the underscores and added the end but...

1699780401602.png

#===============================================================================
#
#===============================================================================
class PokegearButton < Sprite
attr_reader :index
attr_reader :name
attr_reader :selected

TEXT_BASE_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(40, 40, 40)

def initialize(command, x, y, viewport = nil)
super(viewport)
@image = command[0]
@Name = command[1]
@selected = false

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_2"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_2")
end
end

@contents = Bitmap.new(@button.width, @button.height)
self.bitmap = @contents
self.x = x - (@button.width / 2)
self.y = y
pbSetSystemFont(self.bitmap)
refresh
end

def dispose
@button.dispose
@contents.dispose
super
end

def selected=(val)
oldsel = @selected
@selected = val
refresh if oldsel != val
end

def refresh
self.bitmap.clear
rect = Rect.new(0, 0, @button.width, @button.height / 2)
rect.y = @button.height / 2 if @selected
self.bitmap.blt(0, 0, @button.bitmap, rect)
textpos = [
[@name, rect.width / 2, (rect.height / 2) - 10, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]
]
pbDrawTextPositions(self.bitmap, textpos)
imagepos = [
[sprintf("Graphics/UI/Pokegear/icon_%s", @image), 18, 10]
]
pbDrawImagePositions(self.bitmap, imagepos)
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegear_Scene
def pbUpdate
@commands.length.times do |i|
@sprites["button#{i}"].selected = (i == @index)
end
pbUpdateSpriteHash(@sprites)
end

def pbStartScene(commands)
@commands = commands
@index = 0
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_2"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_2")
end
end
end

def pbScene
ret = -1
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
elsif Input.trigger?(Input::USE)
pbPlayDecisionSE
ret = @index
break
elsif Input.trigger?(Input::UP)
pbPlayCursorSE if @commands.length > 1
@index -= 1
@index = @commands.length - 1 if @index < 0
elsif Input.trigger?(Input::DOWN)
pbPlayCursorSE if @commands.length > 1
@index += 1
@index = 0 if @index >= @commands.length
end
end
return ret
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
dispose
end

def dispose
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegearScreen
def initialize(scene)
@scene = scene
end

def pbStartScreen
# Get all commands
command_list = []
commands = []
MenuHandlers.each_available(:pokegear_menu) do |option, hash, name|
command_list.push([hash["icon_name"] || "", name])
commands.push(hash)
end
@scene.pbStartScene(command_list)
# Main loop
end_scene = false
loop do
choice = @scene.pbScene
if choice < 0
end_scene = true
break
end
break if commands[choice]["effect"].call(@scene)
end
@scene.pbEndScene if end_scene
end
end

#===============================================================================
#
#===============================================================================
MenuHandlers.add(:pokegear_menu, :map, {
"name" => _INTL("Map"),
"icon_name" => "map",
"order" => 10,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
if ret
$game_temp.fly_destination = ret
menu.dispose
next 99999
end
end
next $game_temp.fly_destination
}
})

MenuHandlers.add(:pokegear_menu, :phone, {
"name" => _INTL("Phone"),
"icon_name" => "phone",
"order" => 20,
# "condition" => proc { next $PokemonGlobal.phone && $PokemonGlobal.phone.contacts.length > 0 },
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonPhone_Scene.new
screen = PokemonPhoneScreen.new(scene)
screen.pbStartScreen
end
next false
}
})

MenuHandlers.add(:pokegear_menu, :jukebox, {
"name" => _INTL("Jukebox"),
"icon_name" => "jukebox",
"order" => 30,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
end
next false
}
})
 

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
I removed the underscores and added the end but...


#===============================================================================
#
#===============================================================================
class PokegearButton < Sprite
attr_reader :index
attr_reader :name
attr_reader :selected

TEXT_BASE_COLOR = Color.new(248, 248, 248)
TEXT_SHADOW_COLOR = Color.new(40, 40, 40)

def initialize(command, x, y, viewport = nil)
super(viewport)
@image = command[0]
@Name = command[1]
@selected = false

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_2"))
@Button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_2")
end
end

@contents = Bitmap.new(@button.width, @button.height)
self.bitmap = @contents
self.x = x - (@button.width / 2)
self.y = y
pbSetSystemFont(self.bitmap)
refresh
end

def dispose
@button.dispose
@contents.dispose
super
end

def selected=(val)
oldsel = @selected
@selected = val
refresh if oldsel != val
end

def refresh
self.bitmap.clear
rect = Rect.new(0, 0, @button.width, @button.height / 2)
rect.y = @button.height / 2 if @selected
self.bitmap.blt(0, 0, @button.bitmap, rect)
textpos = [
[@name, rect.width / 2, (rect.height / 2) - 10, :center, TEXT_BASE_COLOR, TEXT_SHADOW_COLOR]
]
pbDrawTextPositions(self.bitmap, textpos)
imagepos = [
[sprintf("Graphics/UI/Pokegear/icon_%s", @image), 18, 10]
]
pbDrawImagePositions(self.bitmap, imagepos)
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegear_Scene
def pbUpdate
@commands.length.times do |i|
@sprites["button#{i}"].selected = (i == @index)
end
pbUpdateSpriteHash(@sprites)
end

def pbStartScene(commands)
@commands = commands
@index = 0
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99999
@sprites = {}
@sprites["background"] = IconSprite.new(0, 0, @viewport)

if $player.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
else
if $player.male? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
else
pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_2"))
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_2")
end
end
end

def pbScene
ret = -1
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::BACK)
pbPlayCloseMenuSE
break
elsif Input.trigger?(Input::USE)
pbPlayDecisionSE
ret = @index
break
elsif Input.trigger?(Input::UP)
pbPlayCursorSE if @commands.length > 1
@index -= 1
@index = @commands.length - 1 if @index < 0
elsif Input.trigger?(Input::DOWN)
pbPlayCursorSE if @commands.length > 1
@index += 1
@index = 0 if @index >= @commands.length
end
end
return ret
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
dispose
end

def dispose
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonPokegearScreen
def initialize(scene)
@scene = scene
end

def pbStartScreen
# Get all commands
command_list = []
commands = []
MenuHandlers.each_available(:pokegear_menu) do |option, hash, name|
command_list.push([hash["icon_name"] || "", name])
commands.push(hash)
end
@scene.pbStartScene(command_list)
# Main loop
end_scene = false
loop do
choice = @scene.pbScene
if choice < 0
end_scene = true
break
end
break if commands[choice]["effect"].call(@scene)
end
@scene.pbEndScene if end_scene
end
end

#===============================================================================
#
#===============================================================================
MenuHandlers.add(:pokegear_menu, :map, {
"name" => _INTL("Map"),
"icon_name" => "map",
"order" => 10,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonRegionMap_Scene.new(-1, false)
screen = PokemonRegionMapScreen.new(scene)
ret = screen.pbStartScreen
if ret
$game_temp.fly_destination = ret
menu.dispose
next 99999
end
end
next $game_temp.fly_destination
}
})

MenuHandlers.add(:pokegear_menu, :phone, {
"name" => _INTL("Phone"),
"icon_name" => "phone",
"order" => 20,
# "condition" => proc { next $PokemonGlobal.phone && $PokemonGlobal.phone.contacts.length > 0 },
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonPhone_Scene.new
screen = PokemonPhoneScreen.new(scene)
screen.pbStartScreen
end
next false
}
})

MenuHandlers.add(:pokegear_menu, :jukebox, {
"name" => _INTL("Jukebox"),
"icon_name" => "jukebox",
"order" => 30,
"effect" => proc { |menu|
pbFadeOutIn do
scene = PokemonJukebox_Scene.new
screen = PokemonJukeboxScreen.new(scene)
screen.pbStartScreen
end
next false
}
})
So apparently I forgot to comment out the OG pokegear script (I'm working with copies so I can revert if needed). I just did that and now I got the text issue again so... time to comb again.

Hopefully someone else will get something out of my idiocy as well.

1699780718473.png

#===============================================================================
#
#===============================================================================
class PokemonLoadPanel < Sprite
attr_reader :selected

TEXTCOLOR = Color.new(232, 232, 232)
TEXTSHADOWCOLOR = Color.new(136, 136, 136)
MALETEXTCOLOR = Color.new(56, 160, 248)
MALETEXTSHADOWCOLOR = Color.new(43, 124, 192)
FEMALETEXTCOLOR = Color.new(219, 166, 238)
FEMALETEXTSHADOWCOLOR = Color.new(158, 109, 176)
NBTEXTCOLOR = Color.new(80, 227, 125)
NBTEXTSHADOWCOLOR = Color.new(56, 158, 87)

def initialize(index, title, isContinue, trainer, stats, mapid, viewport = nil)
super(viewport)
@index = index
@title = title
@isContinue = isContinue
@trainer = trainer
@totalsec = stats&.play_time.to_i || 0
@mapid = mapid
@selected = (index == 0)
@bgbitmap = AnimatedBitmap.new("Graphics/UI/Load/panels")
@refreshBitmap = true
@refreshing = false
refresh
end

def dispose
@bgbitmap.dispose
self.bitmap.dispose
super
end

def selected=(value)
return if @selected == value
@selected = value
@refreshBitmap = true
refresh
end

def pbRefresh
@refreshBitmap = true
refresh
end

def refresh
return if @refreshing
return if disposed?
@refreshing = true
if !self.bitmap || self.bitmap.disposed?
self.bitmap = Bitmap.new(@bgbitmap.width, 222)
pbSetSystemFont(self.bitmap)
end
if @refreshBitmap
@refreshBitmap = false
self.bitmap&.clear
if @isContinue
self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, (@selected) ? 222 : 0, @bgbitmap.width, 222))
else
self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, 444 + ((@selected) ? 46 : 0), @bgbitmap.width, 46))
end
textpos = []
if @isContinue
textpos.push([@title, 32, 16, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([_INTL("Badges:"), 32, 118, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([@trainer.badge_count.to_s, 206, 118, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([_INTL("Pokédex:"), 32, 150, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([@trainer.pokedex.seen_count.to_s, 206, 150, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([_INTL("Time:"), 32, 182, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
hour = @totalsec / 60 / 60
min = @totalsec / 60 % 60
if hour > 0
textpos.push([_INTL("{1}h {2}m", hour, min), 206, 182, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
else
textpos.push([_INTL("{1}m", min), 206, 182, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
end

case @trainer.gender
when 0 # Male
textpos.push([@trainer.name, 112, 70, 0, MALETEXTCOLOR, MALETEXTSHADOWCOLOR])
when 1 # Female
textpos.push([@trainer.name, 112, 70, 0, FEMALETEXTCOLOR, FEMALETEXTSHADOWCOLOR])
when 2 # Nonbinary
textpos.push([@trainer.name, 112, 70, 0, NBTEXTCOLOR, NBTEXTSHADOWCOLOR])
else # just as insurance, probably won't ever run tbh
textpos.push([@trainer.name, 112, 70, 0, TEXTCOLOR, TEXTSHADOWCOLOR])
end

mapname = pbGetMapNameFromId(@mapid)
mapname.gsub!(/\\PN/, @trainer.name)
textpos.push([mapname, 386, 16, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
else
textpos.push([@title, 32, 14, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
end
pbDrawTextPositions(self.bitmap, textpos)
end
@refreshing = false
end
end

#===============================================================================
#
#===============================================================================
class PokemonLoad_Scene
def pbStartScene(commands, show_continue, trainer, stats, map_id)
@commands = commands
@sprites = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99998
addBackgroundOrColoredPlane(@sprites, "background", "Load/bg", Color.new(248, 248, 248), @viewport)
y = 32
commands.length.times do |i|
@sprites["panel#{i}"] = PokemonLoadPanel.new(
i, commands, (show_continue) ? (i == 0) : false, trainer, stats, map_id, @viewport
)
@sprites["panel#{i}"].x = 48
@sprites["panel#{i}"].y = y
@sprites["panel#{i}"].pbRefresh
y += (show_continue && i == 0) ? 224 : 48
end
@sprites["cmdwindow"] = Window_CommandPokemon.new([])
@sprites["cmdwindow"].viewport = @viewport
@sprites["cmdwindow"].visible = false
end

def pbStartScene2
pbFadeInAndShow(@sprites) { pbUpdate }
end

def pbStartDeleteScene
@sprites = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99998
addBackgroundOrColoredPlane(@sprites, "background", "Load/bg", Color.new(248, 248, 248), @viewport)
end

def pbUpdate
oldi = @sprites["cmdwindow"].index rescue 0
pbUpdateSpriteHash(@sprites)
newi = @sprites["cmdwindow"].index rescue 0
if oldi != newi
@sprites["panel#{oldi}"].selected = false
@sprites["panel#{oldi}"].pbRefresh
@sprites["panel#{newi}"].selected = true
@sprites["panel#{newi}"].pbRefresh
while @sprites["panel#{newi}"].y > Graphics.height - 80
@commands.length.times do |i|
@sprites["panel#{i}"].y -= 48
end
6.times do |i|
break if !@sprites["party#{i}"]
@sprites["party#{i}"].y -= 48
end
@sprites["player"].y -= 48 if @sprites["player"]
end
while @sprites["panel#{newi}"].y < 32
@commands.length.times do |i|
@sprites["panel#{i}"].y += 48
end
6.times do |i|
break if !@sprites["party#{i}"]
@sprites["party#{i}"].y += 48
end
@sprites["player"].y += 48 if @sprites["player"]
end
end
end

def pbSetParty(trainer)
return if !trainer || !trainer.party
meta = GameData::PlayerMetadata.get(trainer.character_ID)
if meta
filename = pbGetPlayerCharset(meta.walk_charset, trainer, true)
@sprites["player"] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites["player"].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").", trainer.character_ID, filename)
end
charwidth = @sprites["player"].bitmap.width
charheight = @sprites["player"].bitmap.height
@sprites["player"].x = 112 - (charwidth / 8)
@sprites["player"].y = 112 - (charheight / 8)
@sprites["player"].z = 99999
end
trainer.party.each_with_index do |pkmn, i|
@sprites["party#{i}"] = PokemonIconSprite.new(pkmn, @viewport)
@sprites["party#{i}"].setOffset(PictureOrigin::CENTER)
@sprites["party#{i}"].x = 334 + (66 * (i % 2))
@sprites["party#{i}"].y = 112 + (50 * (i / 2))
@sprites["party#{i}"].z = 99999
end
end

def pbChoose(commands)
@sprites["cmdwindow"].commands = commands
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::USE)
return @sprites["cmdwindow"].index
end
end
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end

def pbCloseScene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonLoadScreen
def initialize(scene)
@scene = scene
if SaveData.exists?
@save_data = load_save_file(SaveData::FILE_PATH)
else
@save_data = {}
end
end

# @param file_path [String] file to load save data from
# @return [Hash] save data
def load_save_file(file_path)
save_data = SaveData.read_from_file(file_path)
unless SaveData.valid?(save_data)
if File.file?(file_path + ".bak")
pbMessage(_INTL("The save file is corrupt. A backup will be loaded."))
save_data = load_save_file(file_path + ".bak")
else
self.prompt_save_deletion
return {}
end
end
return save_data
end

# Called if all save data is invalid.
# Prompts the player to delete the save files.
def prompt_save_deletion
pbMessage(_INTL("The save file is corrupt, or is incompatible with this game.") + "\1")
exit unless pbConfirmMessageSerious(
_INTL("Do you want to delete the save file and start anew?")
)
self.delete_save_data
$game_system = Game_System.new
$PokemonSystem = PokemonSystem.new
end

def pbStartDeleteScreen
@scene.pbStartDeleteScene
@scene.pbStartScene2
if SaveData.exists?
if pbConfirmMessageSerious(_INTL("Delete all saved data?"))
pbMessage(_INTL("Once data has been deleted, there is no way to recover it.") + "\1")
if pbConfirmMessageSerious(_INTL("Delete the saved data anyway?"))
pbMessage(_INTL("Deleting all data. Don't turn off the power.") + "\\wtnp[0]")
self.delete_save_data
end
end
else
pbMessage(_INTL("No save file was found."))
end
@scene.pbEndScene
$scene = pbCallTitle
end

def delete_save_data
begin
SaveData.delete_file
pbMessage(_INTL("The saved data was deleted."))
rescue SystemCallError
pbMessage(_INTL("All saved data could not be deleted."))
end
end

def pbStartLoadScreen
commands = []
cmd_continue = -1
cmd_new_game = -1
cmd_options = -1
cmd_language = -1
cmd_mystery_gift = -1
cmd_debug = -1
cmd_quit = -1
show_continue = !@save_data.empty?
if show_continue
commands[cmd_continue = commands.length] = _INTL("Continue")
if @save_data[:player].mystery_gift_unlocked
commands[cmd_mystery_gift = commands.length] = _INTL("Mystery Gift")
end
end
commands[cmd_new_game = commands.length] = _INTL("New Game")
commands[cmd_options = commands.length] = _INTL("Options")
commands[cmd_language = commands.length] = _INTL("Language") if Settings::LANGUAGES.length >= 2
commands[cmd_debug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmd_quit = commands.length] = _INTL("Quit Game")
map_id = show_continue ? @save_data[:map_factory].map.map_id : 0
@scene.pbStartScene(commands, show_continue, @save_data[:player], @save_data[:stats], map_id)
@scene.pbSetParty(@save_data[:player]) if show_continue
@scene.pbStartScene2
loop do
command = @scene.pbChoose(commands)
pbPlayDecisionSE if command != cmd_quit
case command
when cmd_continue
@scene.pbEndScene
Game.load(@save_data)
return
when cmd_new_game
@scene.pbEndScene
Game.start_new
return
when cmd_mystery_gift
pbFadeOutIn { pbDownloadMysteryGift(@save_data[:player]) }
when cmd_options
pbFadeOutIn do
scene = PokemonOption_Scene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen(true)
end
when cmd_language
@scene.pbEndScene
$PokemonSystem.language = pbChooseLanguage
MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1])
if show_continue
@save_data[:pokemon_system] = $PokemonSystem
File.open(SaveData::FILE_PATH, "wb") { |file| Marshal.dump(@save_data, file) }
end
$scene = pbCallTitle
return
when cmd_debug
pbFadeOutIn { pbDebugMenu(false) }
when cmd_quit
pbPlayCloseMenuSE
@scene.pbEndScene
$scene = nil
return
else
pbPlayBuzzerSE
end
end
end
end

... just realized what it was and I think I should sleep. Gods. At least it loads now.
 
Last edited:

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
So apparently I forgot to comment out the OG pokegear script (I'm working with copies so I can revert if needed). I just did that and now I got the text issue again so... time to comb again.

Hopefully someone else will get something out of my idiocy as well.


#===============================================================================
#
#===============================================================================
class PokemonLoadPanel < Sprite
attr_reader :selected

TEXTCOLOR = Color.new(232, 232, 232)
TEXTSHADOWCOLOR = Color.new(136, 136, 136)
MALETEXTCOLOR = Color.new(56, 160, 248)
MALETEXTSHADOWCOLOR = Color.new(43, 124, 192)
FEMALETEXTCOLOR = Color.new(219, 166, 238)
FEMALETEXTSHADOWCOLOR = Color.new(158, 109, 176)
NBTEXTCOLOR = Color.new(80, 227, 125)
NBTEXTSHADOWCOLOR = Color.new(56, 158, 87)

def initialize(index, title, isContinue, trainer, stats, mapid, viewport = nil)
super(viewport)
@index = index
@title = title
@isContinue = isContinue
@trainer = trainer
@totalsec = stats&.play_time.to_i || 0
@mapid = mapid
@selected = (index == 0)
@bgbitmap = AnimatedBitmap.new("Graphics/UI/Load/panels")
@refreshBitmap = true
@refreshing = false
refresh
end

def dispose
@bgbitmap.dispose
self.bitmap.dispose
super
end

def selected=(value)
return if @selected == value
@selected = value
@refreshBitmap = true
refresh
end

def pbRefresh
@refreshBitmap = true
refresh
end

def refresh
return if @refreshing
return if disposed?
@refreshing = true
if !self.bitmap || self.bitmap.disposed?
self.bitmap = Bitmap.new(@bgbitmap.width, 222)
pbSetSystemFont(self.bitmap)
end
if @refreshBitmap
@refreshBitmap = false
self.bitmap&.clear
if @isContinue
self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, (@selected) ? 222 : 0, @bgbitmap.width, 222))
else
self.bitmap.blt(0, 0, @bgbitmap.bitmap, Rect.new(0, 444 + ((@selected) ? 46 : 0), @bgbitmap.width, 46))
end
textpos = []
if @isContinue
textpos.push([@title, 32, 16, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([_INTL("Badges:"), 32, 118, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([@trainer.badge_count.to_s, 206, 118, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([_INTL("Pokédex:"), 32, 150, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([@trainer.pokedex.seen_count.to_s, 206, 150, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
textpos.push([_INTL("Time:"), 32, 182, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
hour = @totalsec / 60 / 60
min = @totalsec / 60 % 60
if hour > 0
textpos.push([_INTL("{1}h {2}m", hour, min), 206, 182, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
else
textpos.push([_INTL("{1}m", min), 206, 182, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
end

case @trainer.gender
when 0 # Male
textpos.push([@trainer.name, 112, 70, 0, MALETEXTCOLOR, MALETEXTSHADOWCOLOR])
when 1 # Female
textpos.push([@trainer.name, 112, 70, 0, FEMALETEXTCOLOR, FEMALETEXTSHADOWCOLOR])
when 2 # Nonbinary
textpos.push([@trainer.name, 112, 70, 0, NBTEXTCOLOR, NBTEXTSHADOWCOLOR])
else # just as insurance, probably won't ever run tbh
textpos.push([@trainer.name, 112, 70, 0, TEXTCOLOR, TEXTSHADOWCOLOR])
end

mapname = pbGetMapNameFromId(@mapid)
mapname.gsub!(/\\PN/, @trainer.name)
textpos.push([mapname, 386, 16, :right, TEXTCOLOR, TEXTSHADOW_COLOR])
else
textpos.push([@title, 32, 14, :left, TEXTCOLOR, TEXTSHADOW_COLOR])
end
pbDrawTextPositions(self.bitmap, textpos)
end
@refreshing = false
end
end

#===============================================================================
#
#===============================================================================
class PokemonLoad_Scene
def pbStartScene(commands, show_continue, trainer, stats, map_id)
@commands = commands
@sprites = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99998
addBackgroundOrColoredPlane(@sprites, "background", "Load/bg", Color.new(248, 248, 248), @viewport)
y = 32
commands.length.times do |i|
@sprites["panel#{i}"] = PokemonLoadPanel.new(
i, commands, (show_continue) ? (i == 0) : false, trainer, stats, map_id, @viewport
)
@sprites["panel#{i}"].x = 48
@sprites["panel#{i}"].y = y
@sprites["panel#{i}"].pbRefresh
y += (show_continue && i == 0) ? 224 : 48
end
@sprites["cmdwindow"] = Window_CommandPokemon.new([])
@sprites["cmdwindow"].viewport = @viewport
@sprites["cmdwindow"].visible = false
end

def pbStartScene2
pbFadeInAndShow(@sprites) { pbUpdate }
end

def pbStartDeleteScene
@sprites = {}
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
@viewport.z = 99998
addBackgroundOrColoredPlane(@sprites, "background", "Load/bg", Color.new(248, 248, 248), @viewport)
end

def pbUpdate
oldi = @sprites["cmdwindow"].index rescue 0
pbUpdateSpriteHash(@sprites)
newi = @sprites["cmdwindow"].index rescue 0
if oldi != newi
@sprites["panel#{oldi}"].selected = false
@sprites["panel#{oldi}"].pbRefresh
@sprites["panel#{newi}"].selected = true
@sprites["panel#{newi}"].pbRefresh
while @sprites["panel#{newi}"].y > Graphics.height - 80
@commands.length.times do |i|
@sprites["panel#{i}"].y -= 48
end
6.times do |i|
break if !@sprites["party#{i}"]
@sprites["party#{i}"].y -= 48
end
@sprites["player"].y -= 48 if @sprites["player"]
end
while @sprites["panel#{newi}"].y < 32
@commands.length.times do |i|
@sprites["panel#{i}"].y += 48
end
6.times do |i|
break if !@sprites["party#{i}"]
@sprites["party#{i}"].y += 48
end
@sprites["player"].y += 48 if @sprites["player"]
end
end
end

def pbSetParty(trainer)
return if !trainer || !trainer.party
meta = GameData::PlayerMetadata.get(trainer.character_ID)
if meta
filename = pbGetPlayerCharset(meta.walk_charset, trainer, true)
@sprites["player"] = TrainerWalkingCharSprite.new(filename, @viewport)
if !@sprites["player"].bitmap
raise _INTL("Player character {1}'s walking charset was not found (filename: \"{2}\").", trainer.character_ID, filename)
end
charwidth = @sprites["player"].bitmap.width
charheight = @sprites["player"].bitmap.height
@sprites["player"].x = 112 - (charwidth / 8)
@sprites["player"].y = 112 - (charheight / 8)
@sprites["player"].z = 99999
end
trainer.party.each_with_index do |pkmn, i|
@sprites["party#{i}"] = PokemonIconSprite.new(pkmn, @viewport)
@sprites["party#{i}"].setOffset(PictureOrigin::CENTER)
@sprites["party#{i}"].x = 334 + (66 * (i % 2))
@sprites["party#{i}"].y = 112 + (50 * (i / 2))
@sprites["party#{i}"].z = 99999
end
end

def pbChoose(commands)
@sprites["cmdwindow"].commands = commands
loop do
Graphics.update
Input.update
pbUpdate
if Input.trigger?(Input::USE)
return @sprites["cmdwindow"].index
end
end
end

def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end

def pbCloseScene
pbDisposeSpriteHash(@sprites)
@viewport.dispose
end
end

#===============================================================================
#
#===============================================================================
class PokemonLoadScreen
def initialize(scene)
@scene = scene
if SaveData.exists?
@save_data = load_save_file(SaveData::FILE_PATH)
else
@save_data = {}
end
end

# @param file_path [String] file to load save data from
# @return [Hash] save data
def load_save_file(file_path)
save_data = SaveData.read_from_file(file_path)
unless SaveData.valid?(save_data)
if File.file?(file_path + ".bak")
pbMessage(_INTL("The save file is corrupt. A backup will be loaded."))
save_data = load_save_file(file_path + ".bak")
else
self.prompt_save_deletion
return {}
end
end
return save_data
end

# Called if all save data is invalid.
# Prompts the player to delete the save files.
def prompt_save_deletion
pbMessage(_INTL("The save file is corrupt, or is incompatible with this game.") + "\1")
exit unless pbConfirmMessageSerious(
_INTL("Do you want to delete the save file and start anew?")
)
self.delete_save_data
$game_system = Game_System.new
$PokemonSystem = PokemonSystem.new
end

def pbStartDeleteScreen
@scene.pbStartDeleteScene
@scene.pbStartScene2
if SaveData.exists?
if pbConfirmMessageSerious(_INTL("Delete all saved data?"))
pbMessage(_INTL("Once data has been deleted, there is no way to recover it.") + "\1")
if pbConfirmMessageSerious(_INTL("Delete the saved data anyway?"))
pbMessage(_INTL("Deleting all data. Don't turn off the power.") + "\\wtnp[0]")
self.delete_save_data
end
end
else
pbMessage(_INTL("No save file was found."))
end
@scene.pbEndScene
$scene = pbCallTitle
end

def delete_save_data
begin
SaveData.delete_file
pbMessage(_INTL("The saved data was deleted."))
rescue SystemCallError
pbMessage(_INTL("All saved data could not be deleted."))
end
end

def pbStartLoadScreen
commands = []
cmd_continue = -1
cmd_new_game = -1
cmd_options = -1
cmd_language = -1
cmd_mystery_gift = -1
cmd_debug = -1
cmd_quit = -1
show_continue = !@save_data.empty?
if show_continue
commands[cmd_continue = commands.length] = _INTL("Continue")
if @save_data[:player].mystery_gift_unlocked
commands[cmd_mystery_gift = commands.length] = _INTL("Mystery Gift")
end
end
commands[cmd_new_game = commands.length] = _INTL("New Game")
commands[cmd_options = commands.length] = _INTL("Options")
commands[cmd_language = commands.length] = _INTL("Language") if Settings::LANGUAGES.length >= 2
commands[cmd_debug = commands.length] = _INTL("Debug") if $DEBUG
commands[cmd_quit = commands.length] = _INTL("Quit Game")
map_id = show_continue ? @save_data[:map_factory].map.map_id : 0
@scene.pbStartScene(commands, show_continue, @save_data[:player], @save_data[:stats], map_id)
@scene.pbSetParty(@save_data[:player]) if show_continue
@scene.pbStartScene2
loop do
command = @scene.pbChoose(commands)
pbPlayDecisionSE if command != cmd_quit
case command
when cmd_continue
@scene.pbEndScene
Game.load(@save_data)
return
when cmd_new_game
@scene.pbEndScene
Game.start_new
return
when cmd_mystery_gift
pbFadeOutIn { pbDownloadMysteryGift(@save_data[:player]) }
when cmd_options
pbFadeOutIn do
scene = PokemonOption_Scene.new
screen = PokemonOptionScreen.new(scene)
screen.pbStartScreen(true)
end
when cmd_language
@scene.pbEndScene
$PokemonSystem.language = pbChooseLanguage
MessageTypes.load_message_files(Settings::LANGUAGES[$PokemonSystem.language][1])
if show_continue
@save_data[:pokemon_system] = $PokemonSystem
File.open(SaveData::FILE_PATH, "wb") { |file| Marshal.dump(@save_data, file) }
end
$scene = pbCallTitle
return
when cmd_debug
pbFadeOutIn { pbDebugMenu(false) }
when cmd_quit
pbPlayCloseMenuSE
@scene.pbEndScene
$scene = nil
return
else
pbPlayBuzzerSE
end
end
end
end

... just realized what it was and I think I should sleep. Gods. At least it loads now.
WELL

The game crashed.

It didn't like that my messages used male_text_main_color and stuff and now...
1699782707026.png
#===============================================================================
#
#===============================================================================
def pbMapInterpreter
return $game_system&.map_interpreter
end

def pbMapInterpreterRunning?
interp = pbMapInterpreter
return interp&.running?
end

# Unused
def pbRefreshSceneMap
$scene.miniupdate if $scene.is_a?(Scene_Map)
end

def pbUpdateSceneMap
$scene.miniupdate if $scene.is_a?(Scene_Map) && !pbIsFaded?
end

#===============================================================================
#
#===============================================================================
def pbEventCommentInput(*args)
parameters = []
list = args[0].list # List of commands for event or event page
elements = args[1] # Number of elements
trigger = args[2] # Trigger
return nil if list.nil?
return nil unless list.is_a?(Array)
list.each do |item|
next if ![108, 408].include?(item.code)
next if item.parameters[0] != trigger
start = list.index(item) + 1
finish = start + elements
(start...finish).each do |id|
parameters.push(list[id].parameters[0]) if list[id]
end
return parameters
end
return nil
end

def pbCurrentEventCommentInput(elements, trigger)
return nil if !pbMapInterpreterRunning?
event = pbMapInterpreter.get_self
return nil if !event
return pbEventCommentInput(event, elements, trigger)
end

#===============================================================================
#
#===============================================================================
class ChooseNumberParams
attr_reader :messageSkin # Set the full path for the message's window skin
attr_reader :skin

def initialize
@maxDigits = 0
@minNumber = 0
@maxNumber = 0
@skin = nil
@messageSkin = nil
@negativesAllowed = false
@initialNumber = 0
@cancelNumber = nil
end

def setMessageSkin(value)
@messageSkin = value
end

def setSkin(value)
@skin = value
end

def setNegativesAllowed(value)
@negativeAllowed = value
end

def negativesAllowed
@negativeAllowed ? true : false
end

def setRange(minNumber, maxNumber)
maxNumber = minNumber if minNumber > maxNumber
@maxDigits = 0
@minNumber = minNumber
@maxNumber = maxNumber
end

def setDefaultValue(number)
@initialNumber = number
@cancelNumber = nil
end

def setInitialValue(number)
@initialNumber = number
end

def setCancelValue(number)
@cancelNumber = number
end

def initialNumber
return @initialNumber.clamp(self.minNumber, self.maxNumber)
end

def cancelNumber
return @cancelNumber || self.initialNumber
end

def minNumber
ret = 0
if @maxDigits > 0
ret = -((10**@maxDigits) - 1)
else
ret = @minNumber
end
ret = 0 if !@negativeAllowed && ret < 0
return ret
end

def maxNumber
ret = 0
if @maxDigits > 0
ret = ((10**@maxDigits) - 1)
else
ret = @maxNumber
end
ret = 0 if !@negativeAllowed && ret < 0
return ret
end

def setMaxDigits(value)
@maxDigits = [1, value].max
end

def maxDigits
if @maxDigits > 0
return @maxDigits
else
return [numDigits(self.minNumber), numDigits(self.maxNumber)].max
end
end

#-----------------------------------------------------------------------------

private

def numDigits(number)
ans = 1
number = number.abs
while number >= 10
ans += 1
number /= 10
end
return ans
end
end

#===============================================================================
#
#===============================================================================
def pbChooseNumber(msgwindow, params)
return 0 if !params
ret = 0
maximum = params.maxNumber
minimum = params.minNumber
defaultNumber = params.initialNumber
cancelNumber = params.cancelNumber
cmdwindow = Window_InputNumberPokemon.new(params.maxDigits)
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.setSkin(params.skin) if params.skin
cmdwindow.sign = params.negativesAllowed # must be set before number
cmdwindow.number = defaultNumber
pbPositionNearMsgWindow(cmdwindow, msgwindow, :right)
loop do
Graphics.update
Input.update
pbUpdateSceneMap
cmdwindow.update
msgwindow&.update
yield if block_given?
if Input.trigger?(Input::USE)
ret = cmdwindow.number
if ret > maximum
pbPlayBuzzerSE
elsif ret < minimum
pbPlayBuzzerSE
else
pbPlayDecisionSE
break
end
elsif Input.trigger?(Input::BACK)
pbPlayCancelSE
ret = cancelNumber
break
end
end
cmdwindow.dispose
Input.update
return ret
end

#===============================================================================
#
#===============================================================================
class FaceWindowVX < SpriteWindow_Base
def initialize(face)
super(0, 0, 128, 128)
faceinfo = face.split(",")
facefile = pbResolveBitmap("Graphics/Faces/" + faceinfo[0])
facefile = pbResolveBitmap("Graphics/Pictures/" + faceinfo[0]) if !facefile
self.contents&.dispose
@faceIndex = faceinfo[1].to_i
@facebitmaptmp = AnimatedBitmap.new(facefile)
@facebitmap = Bitmap.new(96, 96)
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96))
self.contents = @facebitmap
end

def update
super
if @facebitmaptmp.totalFrames > 1
@facebitmaptmp.update
@facebitmap.blt(0, 0, @facebitmaptmp.bitmap,
Rect.new((@faceIndex % 4) * 96, (@faceIndex / 4) * 96, 96, 96))
end
end

def dispose
@facebitmaptmp.dispose
@facebitmap&.dispose
super
end
end

#===============================================================================
#
#===============================================================================
def pbGetBasicMapNameFromId(id)
begin
map = pbLoadMapInfos
return "" if !map
return map[id].name
rescue
return ""
end
end

def pbGetMapNameFromId(id)
name = GameData::MapMetadata.try_get(id)&.name
if nil_or_empty?(name)
name = pbGetBasicMapNameFromId(id)
name.gsub!(/\\PN/, $player.name) if $player
end
return name
end

def pbCsvField!(str)
ret = ""
str.sub!(/\A\s*/, "")
if str[0, 1] == "\""
str[0, 1] = ""
escaped = false
fieldbytes = 0
str.scan(/./) do |s|
fieldbytes += s.length
break if s == "\"" && !escaped
if s == "\\" && !escaped
escaped = true
else
ret += s
escaped = false
end
end
str[0, fieldbytes] = ""
if !str[/\A\s*,/] && !str[/\A\s*$/]
raise _INTL("Invalid quoted field (in: {1})", ret)
end
str[0, str.length] = $~.post_match
else
if str[/,/]
str[0, str.length] = $~.post_match
ret = $~.pre_match
else
ret = str.clone
str[0, str.length] = ""
end
ret.gsub!(/\s+$/, "")
end
return ret
end

def pbCsvPosInt!(str)
ret = pbCsvField!(str)
if !ret[/\A\d+$/]
raise _INTL("Field {1} is not a positive integer", ret)
end
return ret.to_i
end

#===============================================================================
# Money and coins windows
#===============================================================================
def pbGetGoldString
return _INTL("${1}", $player.money.to_s_formatted)
end

def pbDisplayGoldWindow(msgwindow)
moneyString = pbGetGoldString
goldwindow = Window_AdvancedTextPokemon.new(_INTL("Money:\n<ar>{1}</ar>", moneyString))
goldwindow.setSkin("Graphics/Windowskins/goldskin")
goldwindow.resizeToFit(goldwindow.text, Graphics.width)
goldwindow.width = 160 if goldwindow.width <= 160
if msgwindow.y == 0
goldwindow.y = Graphics.height - goldwindow.height
else
goldwindow.y = 0
end
goldwindow.viewport = msgwindow.viewport
goldwindow.z = msgwindow.z
return goldwindow
end

def pbDisplayCoinsWindow(msgwindow, goldwindow)
coinString = ($player) ? $player.coins.to_s_formatted : "0"
coinwindow = Window_AdvancedTextPokemon.new(_INTL("Coins:\n<ar>{1}</ar>", coinString))
coinwindow.setSkin("Graphics/Windowskins/goldskin")
coinwindow.resizeToFit(coinwindow.text, Graphics.width)
coinwindow.width = 160 if coinwindow.width <= 160
if msgwindow.y == 0
coinwindow.y = (goldwindow) ? goldwindow.y - coinwindow.height : Graphics.height - coinwindow.height
else
coinwindow.y = (goldwindow) ? goldwindow.height : 0
end
coinwindow.viewport = msgwindow.viewport
coinwindow.z = msgwindow.z
return coinwindow
end

def pbDisplayBattlePointsWindow(msgwindow)
pointsString = ($player) ? $player.battle_points.to_s_formatted : "0"
pointswindow = Window_AdvancedTextPokemon.new(_INTL("Battle Points:\n<ar>{1}</ar>", pointsString))
pointswindow.setSkin("Graphics/Windowskins/goldskin")
pointswindow.resizeToFit(pointswindow.text, Graphics.width)
pointswindow.width = 160 if pointswindow.width <= 160
if msgwindow.y == 0
pointswindow.y = Graphics.height - pointswindow.height
else
pointswindow.y = 0
end
pointswindow.viewport = msgwindow.viewport
pointswindow.z = msgwindow.z
return pointswindow
end

#===============================================================================
#
#===============================================================================
def pbCreateStatusWindow(viewport = nil)
msgwindow = Window_AdvancedTextPokemon.new("")
if viewport
msgwindow.viewport = viewport
else
msgwindow.z = 99999
end
msgwindow.visible = false
msgwindow.letterbyletter = false
pbBottomLeftLines(msgwindow, 2)
skinfile = MessageConfig.pbGetSpeechFrame
msgwindow.setSkin(skinfile)
return msgwindow
end

def pbCreateMessageWindow(viewport = nil, skin = nil)
msgwindow = Window_AdvancedTextPokemon.new("")
if viewport
msgwindow.viewport = viewport
else
msgwindow.z = 99999
end
msgwindow.visible = true
msgwindow.letterbyletter = true
msgwindow.back_opacity = MessageConfig::WINDOW_OPACITY
pbBottomLeftLines(msgwindow, 2)
$game_temp.message_window_showing = true if $game_temp
skin = MessageConfig.pbGetSpeechFrame if !skin
msgwindow.setSkin(skin)
return msgwindow
end

def pbDisposeMessageWindow(msgwindow)
$game_temp.message_window_showing = false if $game_temp
msgwindow.dispose
end

#===============================================================================
# Main message-displaying function
#===============================================================================
def pbMessageDisplay(msgwindow, message, letterbyletter = true, commandProc = nil)
return if !msgwindow
oldletterbyletter = msgwindow.letterbyletter
msgwindow.letterbyletter = (letterbyletter) ? true : false
ret = nil
commands = nil
facewindow = nil
goldwindow = nil
coinwindow = nil
battlepointswindow = nil
cmdvariable = 0
cmdIfCancel = 0
msgwindow.waitcount = 0
autoresume = false
text = message.clone
linecount = (Graphics.height > 400) ? 3 : 2
### Text replacement
text.gsub!(/\\sign\[([^\]]*)\]/i) do # \sign[something] gets turned into
next "\\op\\cl\\ts[]\\w[" + $1 + "]" # \op\cl\ts[]\w[something]
end
text.gsub!(/\\\\/, "\5")
text.gsub!(/\\1/, "\1")
if $game_actors
text.gsub!(/\\n\[([1-8])\]/i) { next $game_actors[$1.to_i].name }
end
text.gsub!(/\\pn/i, $player.name) if $player
text.gsub!(/\\pm/i, _INTL("${1}", $player.money.to_s_formatted)) if $player
text.gsub!(/\\n/i, "\n")
text.gsub!(/\\\[([0-9a-f]{8,8})\]/i) { "<c2=" + $1 + ">" }
text.gsub!(/\\pg/i, "\\b") if $player&.male?
text.gsub!(/\\pg/i, "\\r") if $player&.female?
text.gsub!(/\\pog/i, "\\r") if $player&.male?
text.gsub!(/\\pog/i, "\\b") if $player&.female?
text.gsub!(/\\pg/i, "")
text.gsub!(/\\pog/i, "")
male_text_tag = shadowc3tag(MessageConfig::MALETEXTMAINCOLOR, MessageConfig::MALETEXTSHADOWCOLOR)
female_text_tag = shadowc3tag(MessageConfig::FEMALETEXTMAINCOLOR, MessageConfig::FEMALETEXTSHADOWCOLOR)
nb_text_tag = shadowc3tag(MessageConfig::NBTEXTMAINCOLOR, MessageConfig::NBTEXTSHADOWCOLOR)

text.gsub!(/\\by/i, male_text_tag)
text.gsub!(/\\gr/i, female_text_tag)
text.gsub!(/\\nb/i, female_text_tag)
text.gsub!(/\\[Ww]\[([^\]]*)\]/) do
w = $1.to_s
if w == ""
msgwindow.windowskin = nil
else
msgwindow.setSkin("Graphics/Windowskins/#{w}", false)
end
next ""
end
isDarkSkin = isDarkWindowskin(msgwindow.windowskin)
text.gsub!(/\\c\[([0-9]+)\]/i) do
next getSkinColor(msgwindow.windowskin, $1.to_i, isDarkSkin)
end
loop do
last_text = text.clone
text.gsub!(/\\v\[([0-9]+)\]/i) { $game_variables[$1.to_i] }
break if text == last_text
end
loop do
last_text = text.clone
text.gsub!(/\\l\[([0-9]+)\]/i) do
linecount = [1, $1.to_i].max
next ""
end
break if text == last_text
end
colortag = ""
if $game_system && $game_system.message_frame != 0
colortag = getSkinColor(msgwindow.windowskin, 0, true)
else
colortag = getSkinColor(msgwindow.windowskin, 0, isDarkSkin)
end
text = colortag + text
### Controls
textchunks = []
controls = []
while text[/(?:\\(f|ff|ts|cl|me|se|wt|wtnp|ch)\[([^\]]*)\]|\\(g|cn|pt|wd|wm|op|cl|wu|\.|\||\!|\^))/i]
textchunks.push($~.pre_match)
if $~[1]
controls.push([$~[1].downcase, $~[2], -1])
else
controls.push([$~[3].downcase, "", -1])
end
text = $~.post_match
end
textchunks.push(text)
textchunks.each do |chunk|
chunk.gsub!(/\005/, "\\")
end
textlen = 0
controls.length.times do |i|
control = controls[0]
case control
when "wt", "wtnp", ".", "|"
textchunks += "\2"
when "!"
textchunks += "\1"
end
textlen += toUnformattedText(textchunks).scan(/./m).length
controls[2] = textlen
end
text = textchunks.join
appear_timer_start = nil
appear_duration = 0.5 # In seconds
haveSpecialClose = false
specialCloseSE = ""
startSE = nil
controls.length.times do |i|
control = controls[0]
param = controls[1]
case control
when "op"
appear_timer_start = System.uptime
when "cl"
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
haveSpecialClose = true
specialCloseSE = param
when "f"
facewindow&.dispose
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
when "ff"
facewindow&.dispose
facewindow = FaceWindowVX.new(param)
when "ch"
cmds = param.clone
cmdvariable = pbCsvPosInt!(cmds)
cmdIfCancel = pbCsvField!(cmds).to_i
commands = []
while cmds.length > 0
commands.push(pbCsvField!(cmds))
end
when "wtnp", "^"
text = text.sub(/\001\z/, "") # fix: '$' can match end of line as well
when "se"
if controls[2] == 0
startSE = param
controls = nil
end
end
end
if startSE
pbSEPlay(pbStringToAudioFile(startSE))
elsif !appear_timer_start && letterbyletter
pbPlayDecisionSE
end
# Position message window
pbRepositionMessageWindow(msgwindow, linecount)
if facewindow
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
facewindow.viewport = msgwindow.viewport
facewindow.z = msgwindow.z
end
atTop = (msgwindow.y == 0)
# Show text
msgwindow.text = text
loop do
if appear_timer_start
y_start = (atTop) ? -msgwindow.height : Graphics.height
y_end = (atTop) ? 0 : Graphics.height - msgwindow.height
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
appear_timer_start = nil if msgwindow.y == y_end
end
controls.length.times do |i|
next if !controls
next if controls[2] > msgwindow.position || msgwindow.waitcount != 0
control = controls[0]
param = controls[1]
case control
when "f"
facewindow&.dispose
facewindow = PictureWindow.new("Graphics/Pictures/#{param}")
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
facewindow.viewport = msgwindow.viewport
facewindow.z = msgwindow.z
when "ff"
facewindow&.dispose
facewindow = FaceWindowVX.new(param)
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
facewindow.viewport = msgwindow.viewport
facewindow.z = msgwindow.z
when "g" # Display gold window
goldwindow&.dispose
goldwindow = pbDisplayGoldWindow(msgwindow)
when "cn" # Display coins window
coinwindow&.dispose
coinwindow = pbDisplayCoinsWindow(msgwindow, goldwindow)
when "pt" # Display battle points window
battlepointswindow&.dispose
battlepointswindow = pbDisplayBattlePointsWindow(msgwindow)
when "wu"
atTop = true
msgwindow.y = 0
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
if appear_timer_start
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
end
when "wm"
atTop = false
msgwindow.y = (Graphics.height - msgwindow.height) / 2
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
when "wd"
atTop = false
msgwindow.y = Graphics.height - msgwindow.height
pbPositionNearMsgWindow(facewindow, msgwindow, :left)
if appear_timer_start
msgwindow.y = lerp(y_start, y_end, appear_duration, appear_timer_start, System.uptime)
end
when "ts" # Change text speed
msgwindow.textspeed = (param == "") ? 0 : param.to_i / 80.0
when "." # Wait 0.25 seconds
msgwindow.waitcount += 0.25
when "|" # Wait 1 second
msgwindow.waitcount += 1.0
when "wt" # Wait X/20 seconds
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
msgwindow.waitcount += param.to_i / 20.0
when "wtnp" # Wait X/20 seconds, no pause
param = param.sub(/\A\s+/, "").sub(/\s+\z/, "")
msgwindow.waitcount = param.to_i / 20.0
autoresume = true
when "^" # Wait, no pause
autoresume = true
when "se" # Play SE
pbSEPlay(pbStringToAudioFile(param))
when "me" # Play ME
pbMEPlay(pbStringToAudioFile(param))
end
controls = nil
end
break if !letterbyletter
Graphics.update
Input.update
facewindow&.update
if autoresume && msgwindow.waitcount == 0
msgwindow.resume if msgwindow.busy?
break if !msgwindow.busy?
end
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
if msgwindow.busy?
pbPlayDecisionSE if msgwindow.pausing?
msgwindow.resume
elsif !appear_timer_start
break
end
end
pbUpdateSceneMap
msgwindow.update
yield if block_given?
break if (!letterbyletter || commandProc || commands) && !msgwindow.busy?
end
Input.update # Must call Input.update again to avoid extra triggers
msgwindow.letterbyletter = oldletterbyletter
if commands
$game_variables[cmdvariable] = pbShowCommands(msgwindow, commands, cmdIfCancel)
$game_map.need_refresh = true if $game_map
end
ret = commandProc.call(msgwindow) if commandProc
goldwindow&.dispose
coinwindow&.dispose
battlepointswindow&.dispose
facewindow&.dispose
if haveSpecialClose
pbSEPlay(pbStringToAudioFile(specialCloseSE))
atTop = (msgwindow.y == 0)
y_start = (atTop) ? 0 : Graphics.height - msgwindow.height
y_end = (atTop) ? -msgwindow.height : Graphics.height
disappear_duration = 0.5 # In seconds
disappear_timer_start = System.uptime
loop do
msgwindow.y = lerp(y_start, y_end, disappear_duration, disappear_timer_start, System.uptime)
Graphics.update
Input.update
pbUpdateSceneMap
msgwindow.update
break if msgwindow.y == y_end
end
end
return ret
end

#===============================================================================
# Message-displaying functions
#===============================================================================
def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd = 0, &block)
ret = 0
msgwindow = pbCreateMessageWindow(nil, skin)
if commands
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwndw|
next Kernel.pbShowCommands(msgwndw, commands, cmdIfCancel, defaultCmd, &block)
}, &block)
else
pbMessageDisplay(msgwindow, message, &block)
end
pbDisposeMessageWindow(msgwindow)
Input.update
return ret
end

def pbConfirmMessage(message, &block)
return (pbMessage(message, [_INTL("Yes"), _INTL("No")], 2, &block) == 0)
end

def pbConfirmMessageSerious(message, &block)
return (pbMessage(message, [_INTL("No"), _INTL("Yes")], 1, &block) == 1)
end

def pbMessageChooseNumber(message, params, &block)
msgwindow = pbCreateMessageWindow(nil, params.messageSkin)
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwndw|
next pbChooseNumber(msgwndw, params, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return ret
end

def pbShowCommands(msgwindow, commands = nil, cmdIfCancel = 0, defaultCmd = 0)
return 0 if !commands
cmdwindow = Window_CommandPokemonEx.new(commands)
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.resizeToFit(cmdwindow.commands)
pbPositionNearMsgWindow(cmdwindow, msgwindow, :right)
cmdwindow.index = defaultCmd
command = 0
loop do
Graphics.update
Input.update
cmdwindow.update
msgwindow&.update
yield if block_given?
if Input.trigger?(Input::BACK)
if cmdIfCancel > 0
command = cmdIfCancel - 1
break
elsif cmdIfCancel < 0
command = cmdIfCancel
break
end
end
if Input.trigger?(Input::USE)
command = cmdwindow.index
break
end
pbUpdateSceneMap
end
ret = command
cmdwindow.dispose
Input.update
return ret
end

def pbShowCommandsWithHelp(msgwindow, commands, help, cmdIfCancel = 0, defaultCmd = 0)
msgwin = msgwindow
msgwin = pbCreateMessageWindow(nil) if !msgwindow
oldlbl = msgwin.letterbyletter
msgwin.letterbyletter = false
if commands
cmdwindow = Window_CommandPokemonEx.new(commands)
cmdwindow.z = 99999
cmdwindow.visible = true
cmdwindow.resizeToFit(cmdwindow.commands)
cmdwindow.height = msgwin.y if cmdwindow.height > msgwin.y
cmdwindow.index = defaultCmd
command = 0
msgwin.text = help[cmdwindow.index]
msgwin.width = msgwin.width # Necessary evil to make it use the proper margins
loop do
Graphics.update
Input.update
oldindex = cmdwindow.index
cmdwindow.update
msgwin.text = help[cmdwindow.index] if oldindex != cmdwindow.index
msgwin.update
yield if block_given?
if Input.trigger?(Input::BACK)
if cmdIfCancel > 0
command = cmdIfCancel - 1
break
elsif cmdIfCancel < 0
command = cmdIfCancel
break
end
end
if Input.trigger?(Input::USE)
command = cmdwindow.index
break
end
pbUpdateSceneMap
end
ret = command
cmdwindow.dispose
Input.update
end
msgwin.letterbyletter = oldlbl
pbDisposeMessageWindow(msgwin) if !msgwindow
return ret
end

# frames is the number of 1/20 seconds to wait for
def pbMessageWaitForInput(msgwindow, frames, showPause = false)
return if !frames || frames <= 0
msgwindow.startPause if msgwindow && showPause
timer_start = System.uptime
loop do
Graphics.update
Input.update
msgwindow&.update
pbUpdateSceneMap
yield if block_given?
break if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
break if System.uptime - timer_start >= frames / 20.0
end
msgwindow.stopPause if msgwindow && showPause
end

def pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width = 240)
window = Window_TextEntry_Keyboard.new(currenttext, 0, 0, width, 64)
ret = ""
window.maxlength = maxlength
window.visible = true
window.z = 99999
pbPositionNearMsgWindow(window, msgwindow, :right)
window.text = currenttext
window.passwordChar = "*" if passwordbox
Input.text_input = true
loop do
Graphics.update
Input.update
if Input.triggerex?(:ESCAPE)
ret = currenttext
break
elsif Input.triggerex?(:RETURN)
ret = window.text
break
end
window.update
msgwindow&.update
yield if block_given?
end
Input.text_input = false
window.dispose
Input.update
return ret
end

def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block)
msgwindow = pbCreateMessageWindow
retval = pbMessageDisplay(msgwindow, message, true,
proc { |msgwndw|
next pbFreeText(msgwndw, currenttext, passwordbox, maxlength, width, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return retval
end
#===============================================================================
#
#===============================================================================
module MessageConfig
LIGHTTEXTMAINCOLOR = Color.new(248, 248, 248)
LIGHTTEXTSHADOWCOLOR = Color.new(72, 80, 88)
DARKTEXTMAINCOLOR = Color.new(80, 80, 88)
DARKTEXTSHADOWCOLOR = Color.new(160, 160, 168)

MALETEXTBASE = Color.new(56, 160, 248) # Blue
MALETEXTSHADOW = Color.new(43, 124, 192) # /b

FEMALETEXTBASE = Color.new(219, 166, 238) # Purple
FEMALETEXTSHADOW = Color.new(158, 109, 176) #/r

NBTEXTBASE = Color.new(232, 32, 16) # Green
NBTEXTSHADOW = Color.new(56, 158, 87)

OTHERTEXTBASE = Color.new(80, 227, 125) # Blue
OTHERTEXTSHADOW = Color.new(56, 158, 87)

FONT_NAME = "Power Green"
FONT_SIZE = 27
FONT_Y_OFFSET = 8
SMALL_FONT_NAME = "Power Green Small"
SMALL_FONT_SIZE = 21
SMALL_FONT_Y_OFFSET = 8
NARROW_FONT_NAME = "Power Green Narrow"
NARROW_FONT_SIZE = 27
NARROW_FONT_Y_OFFSET = 8
# 0 = Pause cursor is displayed at end of text
# 1 = Pause cursor is displayed at bottom right
# 2 = Pause cursor is displayed at lower middle side
CURSOR_POSITION = 1
WINDOW_OPACITY = 255
TEXT_SPEED = nil # Time in seconds between two characters
@@systemFrame = nil
@@defaultTextSkin = nil
@@textSpeed = nil
@@systemFont = nil
@@smallFont = nil
@@narrowFont = nil

def self.pbDefaultSystemFrame
if $PokemonSystem
return pbResolveBitmap("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[$PokemonSystem.frame]) || ""
else
return pbResolveBitmap("Graphics/Windowskins/" + Settings::MENU_WINDOWSKINS[0]) || ""
end
end

def self.pbDefaultSpeechFrame
if $PokemonSystem
return pbResolveBitmap("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[$PokemonSystem.textskin]) || ""
else
return pbResolveBitmap("Graphics/Windowskins/" + Settings::SPEECH_WINDOWSKINS[0]) || ""
end
end

def self.pbDefaultWindowskin
skin = ($data_system) ? $data_system.windowskin_name : nil
if skin && skin != ""
skin = pbResolveBitmap("Graphics/Windowskins/" + skin) || ""
end
skin = pbResolveBitmap("Graphics/System/Window") if nil_or_empty?(skin)
skin = pbResolveBitmap("Graphics/Windowskins/001-Blue01") if nil_or_empty?(skin)
return skin || ""
end

def self.pbGetSystemFrame
if !@@systemFrame
skin = MessageConfig.pbDefaultSystemFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@systemFrame = skin || ""
end
return @@systemFrame
end

def self.pbGetSpeechFrame
if !@@defaultTextSkin
skin = MessageConfig.pbDefaultSpeechFrame
skin = MessageConfig.pbDefaultWindowskin if nil_or_empty?(skin)
@@defaultTextSkin = skin || ""
end
return @@defaultTextSkin
end

def self.pbSetSystemFrame(value)
@@systemFrame = pbResolveBitmap(value) || ""
end

def self.pbSetSpeechFrame(value)
@@defaultTextSkin = pbResolveBitmap(value) || ""
end

#-----------------------------------------------------------------------------

def self.pbDefaultTextSpeed
return ($PokemonSystem) ? pbSettingToTextSpeed($PokemonSystem.textspeed) : pbSettingToTextSpeed(nil)
end

def self.pbGetTextSpeed
@@textSpeed = pbDefaultTextSpeed if !@@textSpeed
return @@textSpeed
end

def self.pbSetTextSpeed(value)
@@textSpeed = value
end

# Text speed is the delay in seconds between two adjacent characters being
# shown.
def self.pbSettingToTextSpeed(speed)
case speed
when 0 then return 4 / 80.0 # Slow
when 1 then return 2 / 80.0 # Medium
when 2 then return 1 / 80.0 # Fast
when 3 then return 0 # Instant
end
return TEXT_SPEED || (2 / 80.0) # Normal
end

#-----------------------------------------------------------------------------

def self.pbDefaultSystemFontName
return MessageConfig.pbTryFonts(FONT_NAME)
end

def self.pbDefaultSmallFontName
return MessageConfig.pbTryFonts(SMALL_FONT_NAME)
end

def self.pbDefaultNarrowFontName
return MessageConfig.pbTryFonts(NARROW_FONT_NAME)
end

def self.pbGetSystemFontName
@@systemFont = pbDefaultSystemFontName if !@@systemFont
return @@systemFont
end

def self.pbGetSmallFontName
@@smallFont = pbDefaultSmallFontName if !@@smallFont
return @@smallFont
end

def self.pbGetNarrowFontName
@@narrowFont = pbDefaultNarrowFontName if !@@narrowFont
return @@narrowFont
end

def self.pbSetSystemFontName(value)
@@systemFont = MessageConfig.pbTryFonts(value)
@@systemFont = MessageConfig.pbDefaultSystemFontName if @@systemFont == ""
end

def self.pbSetSmallFontName(value)
@@smallFont = MessageConfig.pbTryFonts(value)
@@smallFont = MessageConfig.pbDefaultSmallFontName if @@smallFont == ""
end

def self.pbSetNarrowFontName(value)
@@narrowFont = MessageConfig.pbTryFonts(value)
@@narrowFont = MessageConfig.pbDefaultNarrowFontName if @@narrowFont == ""
end

def self.pbTryFonts(*args)
args.each do |a|
next if !a
case a
when String
return a if Font.exist?(a)
when Array
a.each do |aa|
ret = MessageConfig.pbTryFonts(aa)
return ret if ret != ""
end
end
end
return ""
end
end

#===============================================================================
# Position a window
#===============================================================================
def pbBottomRight(window)
window.x = Graphics.width - window.width
window.y = Graphics.height - window.height
end

def pbBottomLeft(window)
window.x = 0
window.y = Graphics.height - window.height
end

def pbBottomLeftLines(window, lines, width = nil)
window.x = 0
window.width = width || Graphics.width
window.height = (window.borderY rescue 32) + (lines * 32)
window.y = Graphics.height - window.height
end

def pbPositionFaceWindow(facewindow, msgwindow)
return if !facewindow
if msgwindow
if facewindow.height <= msgwindow.height
facewindow.y = msgwindow.y
else
facewindow.y = msgwindow.y + msgwindow.height - facewindow.height
end
facewindow.x = Graphics.width - facewindow.width
msgwindow.x = 0
msgwindow.width = Graphics.width - facewindow.width
else
facewindow.height = Graphics.height if facewindow.height > Graphics.height
facewindow.x = 0
facewindow.y = 0
end
end

def pbPositionNearMsgWindow(cmdwindow, msgwindow, side)
return if !cmdwindow
if msgwindow
height = [cmdwindow.height, Graphics.height - msgwindow.height].min
cmdwindow.height = height if cmdwindow.height != height
cmdwindow.y = msgwindow.y - cmdwindow.height
if cmdwindow.y < 0
cmdwindow.y = msgwindow.y + msgwindow.height
if cmdwindow.y + cmdwindow.height > Graphics.height
cmdwindow.y = msgwindow.y - cmdwindow.height
end
end
case side
when :left
cmdwindow.x = msgwindow.x
when :right
cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width
else
cmdwindow.x = msgwindow.x + msgwindow.width - cmdwindow.width
end
else
cmdwindow.height = Graphics.height if cmdwindow.height > Graphics.height
cmdwindow.x = 0
cmdwindow.y = 0
end
end

# internal function
def pbRepositionMessageWindow(msgwindow, linecount = 2)
msgwindow.height = (32 * linecount) + msgwindow.borderY
msgwindow.y = (Graphics.height) - (msgwindow.height)
if $game_system
case $game_system.message_position
when 0 # up
msgwindow.y = 0
when 1 # middle
msgwindow.y = (Graphics.height / 2) - (msgwindow.height / 2)
when 2
msgwindow.y = (Graphics.height) - (msgwindow.height)
end
msgwindow.opacity = 0 if $game_system.message_frame != 0
end
end

# internal function
def pbUpdateMsgWindowPos(msgwindow, event, eventChanged = false)
if event
if eventChanged
msgwindow.resizeToFit2(msgwindow.text, Graphics.width * 2 / 3, msgwindow.height)
end
msgwindow.y = event.screen_y - 48 - msgwindow.height
msgwindow.y = event.screen_y + 24 if msgwindow.y < 0
msgwindow.x = event.screen_x - (msgwindow.width / 2)
msgwindow.x = 0 if msgwindow.x < 0
if msgwindow.x > Graphics.width - msgwindow.width
msgwindow.x = Graphics.width - msgwindow.width
end
else
curwidth = msgwindow.width
if curwidth != Graphics.width
msgwindow.width = Graphics.width
msgwindow.width = Graphics.width
end
end
end

#===============================================================================
# Determine the colour of a background
#===============================================================================
def isDarkBackground(background, rect = nil)
return true if !background || background.disposed?
rect = background.rect if !rect
return true if rect.width <= 0 || rect.height <= 0
xSeg = (rect.width / 16)
xLoop = (xSeg == 0) ? 1 : 16
xStart = (xSeg == 0) ? rect.x + (rect.width / 2) : rect.x + (xSeg / 2)
ySeg = (rect.height / 16)
yLoop = (ySeg == 0) ? 1 : 16
yStart = (ySeg == 0) ? rect.y + (rect.height / 2) : rect.y + (ySeg / 2)
count = 0
y = yStart
r = g = b = 0
yLoop.times do
x = xStart
xLoop.times do
clr = background.get_pixel(x, y)
if clr.alpha != 0
r += clr.red
g += clr.green
b += clr.blue
count += 1
end
x += xSeg
end
y += ySeg
end
return true if count == 0
r /= count
g /= count
b /= count
return ((r * 0.299) + (g * 0.587) + (b * 0.114)) < 160
end

def isDarkWindowskin(windowskin)
return true if !windowskin || windowskin.disposed?
if windowskin.width == 192 && windowskin.height == 128
return isDarkBackground(windowskin, Rect.new(0, 0, 128, 128))
elsif windowskin.width == 128 && windowskin.height == 128
return isDarkBackground(windowskin, Rect.new(0, 0, 64, 64))
elsif windowskin.width == 96 && windowskin.height == 48
return isDarkBackground(windowskin, Rect.new(32, 16, 16, 16))
else
clr = windowskin.get_pixel(windowskin.width / 2, windowskin.height / 2)
return ((clr.red * 0.299) + (clr.green * 0.587) + (clr.blue * 0.114)) < 160
end
end

#===============================================================================
# Determine which text colours to use based on the darkness of the background
#===============================================================================
def getSkinColor(windowskin, color, isDarkSkin)
if !windowskin || windowskin.disposed? ||
windowskin.width != 128 || windowskin.height != 128
# Base color, shadow color (these are reversed on dark windowskins)
# Values in arrays are RGB numbers
textcolors = [
[232, 32, 16], [248, 168, 184], # 1 Red
[248, 152, 24], [248, 200, 152], # 2 Orange
[232, 208, 32], [248, 232, 136], # 3 Yellow
[ 96, 176, 72], [174, 208, 144], # 4 Green
[ 72, 216, 216], [168, 224, 224], # 5 Cyan
[ 0, 112, 248], [120, 184, 232], # 6 Blue
[114, 64, 232], [184, 168, 224], # 7 Purple
[208, 56, 184], [232, 160, 224], # 8 Magenta
[160, 160, 168], [208, 208, 216], # 9 Gray
[240, 240, 248], [200, 200, 208], # 10 White
MessageConfig::DARKTEXTMAINCOLOR,
MessageConfig::DARKTEXTSHADOWCOLOR, # 11 Dark default
MessageConfig::LIGHTTEXTMAINCOLOR,
MessageConfig::LIGHTTEXTSHADOWCOLOR # 12 Light default
]
if color == 0 || color > textcolors.length / 2 # No special colour, use default
if isDarkSkin # Dark background, light text
return shadowc3tag(MessageConfig::LIGHTTEXTMAINCOLOR, MessageConfig::LIGHTTEXTSHADOWCOLOR)
end
# Light background, dark text
return shadowc3tag(MessageConfig::DARKTEXTMAINCOLOR, MessageConfig::DARKTEXTSHADOWCOLOR)
end
# Special colour as listed above
if isDarkSkin && color != 12 # Dark background, light text
return shadowc3tag(textcolors[(2 * (color - 1)) + 1], textcolors[2 * (color - 1)])
end
# Light background, dark text
return shadowc3tag(textcolors[2 * (color - 1)], textcolors[(2 * (color - 1)) + 1])
else # VX windowskin
color = 0 if color >= 32
x = 64 + ((color % 8) * 8)
y = 96 + ((color / 8) * 8)
pixel = windowskin.get_pixel(x, y)
return shadowc3tag(pixel, pixel.get_contrast_color)
end
end

def getDefaultTextColors(windowskin)
if !windowskin || windowskin.disposed? ||
windowskin.width != 128 || windowskin.height != 128
if isDarkWindowskin(windowskin)
return [MessageConfig::LIGHTTEXTMAINCOLOR, MessageConfig::LIGHTTEXTSHADOWCOLOR] # White
else
return [MessageConfig::DARKTEXTMAINCOLOR, MessageConfig::DARKTEXTSHADOWCOLOR] # Dark gray
end
else # VX windowskin
color = windowskin.get_pixel(64, 96)
shadow = nil
isDark = (color.red + color.green + color.blue) / 3 < 128
if isDark
shadow = Color.new(color.red + 64, color.green + 64, color.blue + 64)
else
shadow = Color.new(color.red - 64, color.green - 64, color.blue - 64)
end
return [color, shadow]
end
end

#===============================================================================
# Makes sure a bitmap exists
#===============================================================================
def pbDoEnsureBitmap(bitmap, dwidth, dheight)
if !bitmap || bitmap.disposed? || bitmap.width < dwidth || bitmap.height < dheight
oldfont = (bitmap && !bitmap.disposed?) ? bitmap.font : nil
bitmap&.dispose
bitmap = Bitmap.new([1, dwidth].max, [1, dheight].max)
(oldfont) ? bitmap.font = oldfont : pbSetSystemFont(bitmap)
bitmap.font.shadow = false if bitmap.font.respond_to?("shadow")
end
return bitmap
end

#===============================================================================
# Set a bitmap's font
#===============================================================================
# Sets a bitmap's font to the system font.
def pbSetSystemFont(bitmap)
bitmap.font.name = MessageConfig.pbGetSystemFontName
bitmap.font.size = MessageConfig::FONT_SIZE
bitmap.text_offset_y = MessageConfig::FONT_Y_OFFSET
end

# Sets a bitmap's font to the system small font.
def pbSetSmallFont(bitmap)
bitmap.font.name = MessageConfig.pbGetSmallFontName
bitmap.font.size = MessageConfig::SMALL_FONT_SIZE
bitmap.text_offset_y = MessageConfig::SMALL_FONT_Y_OFFSET
end

# Sets a bitmap's font to the system narrow font.
def pbSetNarrowFont(bitmap)
bitmap.font.name = MessageConfig.pbGetNarrowFontName
bitmap.font.size = MessageConfig::NARROW_FONT_SIZE
bitmap.text_offset_y = MessageConfig::NARROW_FONT_Y_OFFSET
end

#===============================================================================
# Blend colours, set the colour of all bitmaps in a sprite hash
#===============================================================================
def pbAlphaBlend(dstColor, srcColor)
r = (255 * (srcColor.red - dstColor.red) / 255) + dstColor.red
g = (255 * (srcColor.green - dstColor.green) / 255) + dstColor.green
b = (255 * (srcColor.blue - dstColor.blue) / 255) + dstColor.blue
a = (255 * (srcColor.alpha - dstColor.alpha) / 255) + dstColor.alpha
return Color.new(r, g, b, a)
end

def pbSrcOver(dstColor, srcColor)
er = srcColor.red * srcColor.alpha / 255
eg = srcColor.green * srcColor.alpha / 255
eb = srcColor.blue * srcColor.alpha / 255
iea = 255 - srcColor.alpha
cr = dstColor.red * dstColor.alpha / 255
cg = dstColor.green * dstColor.alpha / 255
cb = dstColor.blue * dstColor.alpha / 255
ica = 255 - dstColor.alpha
a = 255 - ((iea * ica) / 255)
r = ((iea * cr) / 255) + er
g = ((iea * cg) / 255) + eg
b = ((iea * cb) / 255) + eb
r = (a == 0) ? 0 : r * 255 / a
g = (a == 0) ? 0 : g * 255 / a
b = (a == 0) ? 0 : b * 255 / a
return Color.new(r, g, b, a)
end

def pbSetSpritesToColor(sprites, color)
return if !sprites || !color
colors = {}
sprites.each do |i|
next if !i[1] || pbDisposed?(i[1])
colors[i[0]] = i[1].color.clone
i[1].color = pbSrcOver(i[1].color, color)
end
Graphics.update
Input.update
colors.each do |i|
next if !sprites[i[0]]
sprites[i[0]].color = i[1]
end
end

#===============================================================================
# Update and dispose sprite hashes
#===============================================================================
def using(window)
begin
yield if block_given?
ensure
window.dispose
end
end

def pbUpdateSpriteHash(windows)
windows.each do |i|
window = i[1]
if window
if window.is_a?(Sprite) || window.is_a?(Window)
window.update if !pbDisposed?(window)
elsif window.is_a?(Plane)
begin
window.update if !window.disposed?
rescue NoMethodError
end
elsif window.respond_to?("update")
begin
window.update
rescue RGSSError
end
end
end
end
end

# Disposes all objects in the specified hash.
def pbDisposeSpriteHash(sprites)
return if !sprites
sprites.each_key do |i|
pbDisposeSprite(sprites, i)
end
sprites.clear
end

# Disposes the specified graphics object within the specified hash. Basically
# like: sprites[id].dispose
def pbDisposeSprite(sprites, id)
sprite = sprites[id]
sprite.dispose if sprite && !pbDisposed?(sprite)
sprites[id] = nil
end

def pbDisposed?(x)
return true if !x
return x.disposed? if !x.is_a?(Viewport)
begin
x.rect = x.rect
rescue
return true
end
return false
end

#===============================================================================
# Fades and window activations for sprite hashes
#===============================================================================
def pbPushFade
$game_temp.fadestate = [$game_temp.fadestate + 1, 0].max if $game_temp
end

def pbPopFade
$game_temp.fadestate = [$game_temp.fadestate - 1, 0].max if $game_temp
end

def pbIsFaded?
return ($game_temp) ? $game_temp.fadestate > 0 : false
end

# pbFadeOutIn(z) { block }
# Fades out the screen before a block is run and fades it back in after the
# block exits. z indicates the z-coordinate of the viewport used for this effect
def pbFadeOutIn(z = 99999, nofadeout = false)
duration = 0.4 # In seconds
col = Color.new(0, 0, 0, 0)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = z
timer_start = System.uptime
loop do
col.set(0, 0, 0, lerp(0, 255, duration, timer_start, System.uptime))
viewport.color = col
Graphics.update
Input.update
break if col.alpha == 255
end
pbPushFade
begin
val = 0
val = yield if block_given?
nofadeout = true if val == 99999 # Ugly hack used by Town Map in the Bag/Pokégear
ensure
pbPopFade
if !nofadeout
timer_start = System.uptime
loop do
col.set(0, 0, 0, lerp(255, 0, duration, timer_start, System.uptime))
viewport.color = col
Graphics.update
Input.update
break if col.alpha == 0
end
end
viewport.dispose
end
end

def pbFadeOutInWithUpdate(z, sprites, nofadeout = false)
duration = 0.4 # In seconds
col = Color.new(0, 0, 0, 0)
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
viewport.z = z
timer_start = System.uptime
loop do
col.set(0, 0, 0, lerp(0, 255, duration, timer_start, System.uptime))
viewport.color = col
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
break if col.alpha == 255
end
pbPushFade
begin
yield if block_given?
ensure
pbPopFade
if !nofadeout
timer_start = System.uptime
loop do
col.set(0, 0, 0, lerp(255, 0, duration, timer_start, System.uptime))
viewport.color = col
pbUpdateSpriteHash(sprites)
Graphics.update
Input.update
break if col.alpha == 0
end
end
viewport.dispose
end
end

# Similar to pbFadeOutIn, but pauses the music as it fades out.
# Requires scripts "Audio" (for bgm_pause) and "SpriteWindow" (for pbFadeOutIn).
def pbFadeOutInWithMusic(zViewport = 99999)
playingBGS = $game_system.getPlayingBGS
playingBGM = $game_system.getPlayingBGM
$game_system.bgm_pause(1.0)
$game_system.bgs_pause(1.0)
pos = $game_system.bgm_position
pbFadeOutIn(zViewport) do
yield
$game_system.bgm_position = pos
$game_system.bgm_resume(playingBGM)
$game_system.bgs_resume(playingBGS)
end
end

def pbFadeOutAndHide(sprites)
duration = 0.4 # In seconds
col = Color.new(0, 0, 0, 0)
visiblesprites = {}
pbDeactivateWindows(sprites) do
timer_start = System.uptime
loop do
col.alpha = lerp(0, 255, duration, timer_start, System.uptime)
pbSetSpritesToColor(sprites, col)
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
break if col.alpha == 255
end
end
sprites.each do |i|
next if !i[1]
next if pbDisposed?(i[1])
visiblesprites[i[0]] = true if i[1].visible
i[1].visible = false
end
return visiblesprites
end

def pbFadeInAndShow(sprites, visiblesprites = nil)
duration = 0.4 # In seconds
col = Color.new(0, 0, 0, 0)
if visiblesprites
visiblesprites.each do |i|
if i[1] && sprites[i[0]] && !pbDisposed?(sprites[i[0]])
sprites[i[0]].visible = true
end
end
end
pbDeactivateWindows(sprites) do
timer_start = System.uptime
loop do
col.alpha = lerp(255, 0, duration, timer_start, System.uptime)
pbSetSpritesToColor(sprites, col)
(block_given?) ? yield : pbUpdateSpriteHash(sprites)
break if col.alpha == 0
end
end
end

# Restores which windows are active for the given sprite hash.
# activeStatuses is the result of a previous call to pbActivateWindows
def pbRestoreActivations(sprites, activeStatuses)
return if !sprites || !activeStatuses
activeStatuses.each_key do |k|
if sprites[k].is_a?(Window) && !pbDisposed?(sprites[k])
sprites[k].active = activeStatuses[k] ? true : false
end
end
end

# Deactivates all windows. If a code block is given, deactivates all windows,
# runs the code in the block, and reactivates them.
def pbDeactivateWindows(sprites)
if block_given?
pbActivateWindow(sprites, nil) { yield }
else
pbActivateWindow(sprites, nil)
end
end

# Activates a specific window of a sprite hash. key is the key of the window
# in the sprite hash. If a code block is given, deactivates all windows except
# the specified window, runs the code in the block, and reactivates them.
def pbActivateWindow(sprites, key)
return if !sprites
activeStatuses = {}
sprites.each do |i|
if i[1].is_a?(Window) && !pbDisposed?(i[1])
activeStatuses[i[0]] = i[1].active
i[1].active = (i[0] == key)
end
end
if block_given?
begin
yield
ensure
pbRestoreActivations(sprites, activeStatuses)
end
return {}
else
return activeStatuses
end
end

#===============================================================================
# Create background planes for a sprite hash
#===============================================================================
# Adds a background to the sprite hash.
# planename is the hash key of the background.
# background is a filename within the Graphics/UI/ folder and can be
# an animated image.
# viewport is a viewport to place the background in.
def addBackgroundPlane(sprites, planename, background, viewport = nil)
sprites[planename] = AnimatedPlane.new(viewport)
bitmapName = pbResolveBitmap("Graphics/UI/#{background}")
if bitmapName.nil?
# Plane should exist in any case
sprites[planename].bitmap = nil
sprites[planename].visible = false
else
sprites[planename].setBitmap(bitmapName)
sprites.each_value do |spr|
spr.windowskin = nil if spr.is_a?(Window)
end
end
end

# Adds a background to the sprite hash.
# planename is the hash key of the background.
# background is a filename within the Graphics/UI/ folder and can be
# an animated image.
# color is the color to use if the background can't be found.
# viewport is a viewport to place the background in.
def addBackgroundOrColoredPlane(sprites, planename, background, color, viewport = nil)
bitmapName = pbResolveBitmap("Graphics/UI/#{background}")
if bitmapName.nil?
# Plane should exist in any case
sprites[planename] = ColoredPlane.new(color, viewport)
else
sprites[planename] = AnimatedPlane.new(viewport)
sprites[planename].setBitmap(bitmapName)
sprites.each_value do |spr|
spr.windowskin = nil if spr.is_a?(Window)
end
end
end

#===============================================================================
# Ensure required method definitions.
#===============================================================================
module Graphics
if !self.respond_to?("width")
def self.width; return 640; end
end

if !self.respond_to?("height")
def self.height; return 480; end
end
end

#===============================================================================
# Ensure required method definitions.
#===============================================================================
if !defined?(_INTL)
def _INTL(*args)
string = args[0].clone
(1...args.length).each { |i| string.gsub!(/\{#{i}\}/, args.to_s) }
return string
end
end

if !defined?(_ISPRINTF)
def _ISPRINTF(*args)
string = args[0].clone
(1...args.length).each do |i|
string.gsub!(/\{#{i}\:([^\}]+?)\}/) { |m| next sprintf("%" + $1, args) }
end
return string
end
end

if !defined?(_MAPINTL)
def _MAPINTL(*args)
string = args[1].clone
(2...args.length).each { |i| string.gsub!(/\{#{i}\}/, args[i + 1].to_s) }
return string
end
end

I'm about to just drop this on discord, @LinKazamine , and see what happens, cause this is driving me up the wall, and I don't wanna take up too much discussion space (is that a thing? I feel like I'm just spamming errors. -~-' )

...................

So first time I loaded the game it had an error when I didn't have that edit, and now it's fine? But I'm pretty sure I still need to add the NB text thing. -_-'
 
Last edited:

LinKazamine

Champion
Member
Joined
May 24, 2023
Posts
662
Of course it's throwing errors to you. You are asking the game to load "MALETEXTMAINCOLOR", "MALETEXTSHADOWCOLOR", "FEMALETEXTMAINCOLOR", "FEMALETEXTSHADOWCOLOR", "NBTEXTMAINCOLOR" and "NBTEXTSHADOWCOLOR" without defining them in the MessageConfig module.

You HAVE to make sure to use the same name when defining a variable AND when calling it. Otherwise, the game will constantly tell you that you haven't defined it.

So you have two options to solve this:
  1. Change the variables names in Message Script to "MALETEXTBASE", "MALETEXTSHADOW", "FEMALETEXTBASE", "FEMALETEXTSHADOW", "NBTEXTBASE", "NBTEXTSHADOW", "OTHERTEXTBASE" and "OTHERTEXTSHADOW".
  2. Change the variables names in MessageConfig Script to "MALETEXTMAINCOLOR", "MALETEXTSHADOWCOLOR", "FEMALETEXTMAINCOLOR", "FEMALETEXTSHADOWCOLOR", "NBTEXTMAINCOLOR" and "NBTEXTSHADOWCOLOR".
 

Zia222

Ivory Games
Member
Joined
Nov 4, 2023
Posts
11
So I ended up figuring something out not exactly sure what I did but it works now and that's the good part. Still figuring it out a couple other scripts though.

Thank you for your help.
 

RoyJohnson49

Novice
Member
Joined
Mar 11, 2023
Posts
30
I tried incorporating this script into v21. There was some error with UI_Load that prevented me from starting the game. If this script could get updated for v21, that'd be cool.
 
Back
Top