mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 13:44:59 +00:00
Remove Scripts folder to convert to submodule
This commit is contained in:
@@ -1,122 +0,0 @@
|
||||
class IntroEventScene < EventScene
|
||||
# Splash screen images that appear for a few seconds and then disappear.
|
||||
SPLASH_IMAGES = ['splash1']
|
||||
# The main title screen background image.
|
||||
TITLE_BG_IMAGE = 'title'
|
||||
TITLE_START_IMAGE = 'start'
|
||||
TITLE_START_IMAGE_X = 0
|
||||
TITLE_START_IMAGE_Y = 322
|
||||
SECONDS_PER_SPLASH = 2
|
||||
TICKS_PER_ENTER_FLASH = 40 # 20 ticks per second
|
||||
FADE_TICKS = 8 # 20 ticks per second
|
||||
|
||||
def initialize(viewport = nil)
|
||||
super(viewport)
|
||||
@pic = addImage(0, 0, "")
|
||||
@pic.setOpacity(0, 0) # set opacity to 0 after waiting 0 frames
|
||||
@pic2 = addImage(0, 0, "") # flashing "Press Enter" picture
|
||||
@pic2.setOpacity(0, 0) # set opacity to 0 after waiting 0 frames
|
||||
@index = 0
|
||||
pbBGMPlay($data_system.title_bgm)
|
||||
open_splash(self, nil)
|
||||
end
|
||||
|
||||
def open_splash(_scene, *args)
|
||||
onCTrigger.clear
|
||||
@pic.name = "Graphics/Titles/" + SPLASH_IMAGES[@index]
|
||||
# fade to opacity 255 in FADE_TICKS ticks after waiting 0 frames
|
||||
@pic.moveOpacity(0, FADE_TICKS, 255)
|
||||
pictureWait
|
||||
@timer = 0.0 # reset the timer
|
||||
onUpdate.set(method(:splash_update)) # called every frame
|
||||
onCTrigger.set(method(:close_splash)) # called when C key is pressed
|
||||
end
|
||||
|
||||
def close_splash(scene, args)
|
||||
onUpdate.clear
|
||||
onCTrigger.clear
|
||||
@pic.moveOpacity(0, FADE_TICKS, 0)
|
||||
pictureWait
|
||||
@index += 1 # Move to the next picture
|
||||
if @index >= SPLASH_IMAGES.length
|
||||
open_title_screen(scene, args)
|
||||
else
|
||||
open_splash(scene, args)
|
||||
end
|
||||
end
|
||||
|
||||
def splash_update(scene, args)
|
||||
@timer += Graphics.delta_s
|
||||
close_splash(scene, args) if @timer > SECONDS_PER_SPLASH
|
||||
end
|
||||
|
||||
def open_title_screen(_scene, *args)
|
||||
onUpdate.clear
|
||||
onCTrigger.clear
|
||||
@pic.name = "Graphics/Titles/" + TITLE_BG_IMAGE
|
||||
@pic.moveOpacity(0, FADE_TICKS, 255)
|
||||
@pic2.name = "Graphics/Titles/" + TITLE_START_IMAGE
|
||||
@pic2.setXY(0, TITLE_START_IMAGE_X, TITLE_START_IMAGE_Y)
|
||||
@pic2.setVisible(0, true)
|
||||
@pic2.moveOpacity(0, FADE_TICKS, 255)
|
||||
pictureWait
|
||||
onUpdate.set(method(:title_screen_update)) # called every frame
|
||||
onCTrigger.set(method(:close_title_screen)) # called when C key is pressed
|
||||
end
|
||||
|
||||
def fade_out_title_screen(scene)
|
||||
onUpdate.clear
|
||||
onCTrigger.clear
|
||||
# Play random cry
|
||||
species_keys = GameData::Species::DATA.keys
|
||||
species_data = GameData::Species.get(species_keys[rand(species_keys.length)])
|
||||
Pokemon.play_cry(species_data.species, species_data.form)
|
||||
@pic.moveXY(0, 20, 0, 0) # Adds 20 ticks (1 second) pause
|
||||
pictureWait
|
||||
# Fade out
|
||||
@pic.moveOpacity(0, FADE_TICKS, 0)
|
||||
@pic2.clearProcesses
|
||||
@pic2.moveOpacity(0, FADE_TICKS, 0)
|
||||
pbBGMStop(1.0)
|
||||
pictureWait
|
||||
scene.dispose # Close the scene
|
||||
end
|
||||
|
||||
def close_title_screen(scene, *args)
|
||||
fade_out_title_screen(scene)
|
||||
sscene = PokemonLoad_Scene.new
|
||||
sscreen = PokemonLoadScreen.new(sscene)
|
||||
sscreen.pbStartLoadScreen
|
||||
end
|
||||
|
||||
def close_title_screen_delete(scene, *args)
|
||||
fade_out_title_screen(scene)
|
||||
sscene = PokemonLoad_Scene.new
|
||||
sscreen = PokemonLoadScreen.new(sscene)
|
||||
sscreen.pbStartDeleteScreen
|
||||
end
|
||||
|
||||
def title_screen_update(scene, args)
|
||||
# Flashing of "Press Enter" picture
|
||||
if !@pic2.running?
|
||||
@pic2.moveOpacity(TICKS_PER_ENTER_FLASH * 2 / 10, TICKS_PER_ENTER_FLASH * 4 / 10, 0)
|
||||
@pic2.moveOpacity(TICKS_PER_ENTER_FLASH * 6 / 10, TICKS_PER_ENTER_FLASH * 4 / 10, 255)
|
||||
end
|
||||
if Input.press?(Input::DOWN) &&
|
||||
Input.press?(Input::BACK) &&
|
||||
Input.press?(Input::CTRL)
|
||||
close_title_screen_delete(scene, args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
class Scene_Intro
|
||||
def main
|
||||
Graphics.transition(0)
|
||||
@eventscene = IntroEventScene.new
|
||||
@eventscene.main
|
||||
Graphics.freeze
|
||||
end
|
||||
end
|
||||
@@ -1,80 +0,0 @@
|
||||
#==============================================================================
|
||||
# * Scene_Controls
|
||||
#------------------------------------------------------------------------------
|
||||
# Shows a help screen listing the keyboard controls.
|
||||
# Display with:
|
||||
# pbEventScreen(ButtonEventScene)
|
||||
#==============================================================================
|
||||
class ButtonEventScene < EventScene
|
||||
def initialize(viewport = nil)
|
||||
super
|
||||
Graphics.freeze
|
||||
@current_screen = 1
|
||||
addImage(0, 0, "Graphics/Pictures/Controls help/help_bg")
|
||||
@labels = []
|
||||
@label_screens = []
|
||||
@keys = []
|
||||
@key_screens = []
|
||||
|
||||
addImageForScreen(1, 44, 122, "Graphics/Pictures/Controls help/help_f1")
|
||||
addImageForScreen(1, 44, 252, "Graphics/Pictures/Controls help/help_f8")
|
||||
addLabelForScreen(1, 134, 84, 352, _INTL("Opens the Key Bindings window, where you can choose which keyboard keys to use for each control."))
|
||||
addLabelForScreen(1, 134, 244, 352, _INTL("Take a screenshot. It is put in the same folder as the save file."))
|
||||
|
||||
addImageForScreen(2, 16, 158, "Graphics/Pictures/Controls help/help_arrows")
|
||||
addLabelForScreen(2, 134, 100, 352, _INTL("Use the Arrow keys to move the main character.\r\n\r\nYou can also use the Arrow keys to select entries and navigate menus."))
|
||||
|
||||
addImageForScreen(3, 16, 106, "Graphics/Pictures/Controls help/help_usekey")
|
||||
addImageForScreen(3, 16, 236, "Graphics/Pictures/Controls help/help_backkey")
|
||||
addLabelForScreen(3, 134, 84, 352, _INTL("Used to confirm a choice, interact with people and things, and move through text. (Default: C)"))
|
||||
addLabelForScreen(3, 134, 212, 352, _INTL("Used to exit, cancel a choice, and cancel a mode. Also used to open the Pause Menu. (Default: X)"))
|
||||
|
||||
addImageForScreen(4, 16, 90, "Graphics/Pictures/Controls help/help_actionkey")
|
||||
addImageForScreen(4, 16, 252, "Graphics/Pictures/Controls help/help_specialkey")
|
||||
addLabelForScreen(4, 134, 52, 352, _INTL("Has various functions depending on context. While moving around, hold to move at a different speed. (Default: Z)"))
|
||||
addLabelForScreen(4, 134, 212, 352, _INTL("Press to open the Ready Menu, where registered items and available field moves can be used. (Default: D)"))
|
||||
|
||||
set_up_screen(@current_screen)
|
||||
Graphics.transition(20)
|
||||
# Go to next screen when user presses USE
|
||||
onCTrigger.set(method(:pbOnScreenEnd))
|
||||
end
|
||||
|
||||
def addLabelForScreen(number, x, y, width, text)
|
||||
@labels.push(addLabel(x, y, width, text))
|
||||
@label_screens.push(number)
|
||||
@picturesprites[@picturesprites.length - 1].opacity = 0
|
||||
end
|
||||
|
||||
def addImageForScreen(number, x, y, filename)
|
||||
@keys.push(addImage(x, y, filename))
|
||||
@key_screens.push(number)
|
||||
@picturesprites[@picturesprites.length - 1].opacity = 0
|
||||
end
|
||||
|
||||
def set_up_screen(number)
|
||||
@label_screens.each_with_index do |screen, i|
|
||||
@labels[i].moveOpacity((screen == number) ? 10 : 0, 10, (screen == number) ? 255 : 0)
|
||||
end
|
||||
@key_screens.each_with_index do |screen, i|
|
||||
@keys[i].moveOpacity((screen == number) ? 10 : 0, 10, (screen == number) ? 255 : 0)
|
||||
end
|
||||
pictureWait # Update event scene with the changes
|
||||
end
|
||||
|
||||
def pbOnScreenEnd(scene, *args)
|
||||
last_screen = [@label_screens.max, @key_screens.max].max
|
||||
if @current_screen >= last_screen
|
||||
# End scene
|
||||
Graphics.freeze
|
||||
Graphics.transition(20, "fadetoblack")
|
||||
scene.dispose
|
||||
else
|
||||
# Next screen
|
||||
@current_screen += 1
|
||||
onCTrigger.clear
|
||||
set_up_screen(@current_screen)
|
||||
onCTrigger.set(method(:pbOnScreenEnd))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,248 +0,0 @@
|
||||
#===============================================================================
|
||||
# * Egg Hatch Animation - by FL (Credits will be apreciated)
|
||||
# Tweaked by Maruno
|
||||
#===============================================================================
|
||||
# This script is for Pokémon Essentials. It's an egg hatch animation that
|
||||
# works even with special eggs like Manaphy egg.
|
||||
#===============================================================================
|
||||
# To this script works, put it above Main and put a picture (a 5 frames
|
||||
# sprite sheet) with egg sprite height and 5 times the egg sprite width at
|
||||
# Graphics/Battlers/eggCracks.
|
||||
#===============================================================================
|
||||
class PokemonEggHatch_Scene
|
||||
def pbStartScene(pokemon)
|
||||
@sprites={}
|
||||
@pokemon=pokemon
|
||||
@nicknamed=false
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
# Create background image
|
||||
addBackgroundOrColoredPlane(@sprites,"background","hatchbg",
|
||||
Color.new(248,248,248),@viewport)
|
||||
# Create egg sprite/Pokémon sprite
|
||||
@sprites["pokemon"]=PokemonSprite.new(@viewport)
|
||||
@sprites["pokemon"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["pokemon"].x = Graphics.width/2
|
||||
@sprites["pokemon"].y = 264+56 # 56 to offset the egg sprite
|
||||
@sprites["pokemon"].setSpeciesBitmap(@pokemon.species, @pokemon.gender,
|
||||
@pokemon.form, @pokemon.shiny?,
|
||||
false, false, true) # Egg sprite
|
||||
# Load egg cracks bitmap
|
||||
crackfilename = sprintf("Graphics/Battlers/Eggs/%s_cracks", @pokemon.species)
|
||||
crackfilename = sprintf("Graphics/Battlers/Eggs/000_cracks") if !pbResolveBitmap(crackfilename)
|
||||
crackfilename=pbResolveBitmap(crackfilename)
|
||||
@hatchSheet=AnimatedBitmap.new(crackfilename)
|
||||
# Create egg cracks sprite
|
||||
@sprites["hatch"]=SpriteWrapper.new(@viewport)
|
||||
@sprites["hatch"].x = @sprites["pokemon"].x
|
||||
@sprites["hatch"].y = @sprites["pokemon"].y
|
||||
@sprites["hatch"].ox = @sprites["pokemon"].ox
|
||||
@sprites["hatch"].oy = @sprites["pokemon"].oy
|
||||
@sprites["hatch"].bitmap = @hatchSheet.bitmap
|
||||
@sprites["hatch"].src_rect = Rect.new(0,0,@hatchSheet.width/5,@hatchSheet.height)
|
||||
@sprites["hatch"].visible = false
|
||||
# Create flash overlay
|
||||
@sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
@sprites["overlay"].z=200
|
||||
@sprites["overlay"].bitmap=Bitmap.new(Graphics.width,Graphics.height)
|
||||
@sprites["overlay"].bitmap.fill_rect(0,0,Graphics.width,Graphics.height,
|
||||
Color.new(255,255,255))
|
||||
@sprites["overlay"].opacity=0
|
||||
# Start up scene
|
||||
pbFadeInAndShow(@sprites)
|
||||
end
|
||||
|
||||
def pbMain
|
||||
pbBGMPlay("Evolution")
|
||||
# Egg animation
|
||||
updateScene(Graphics.frame_rate*15/10)
|
||||
pbPositionHatchMask(0)
|
||||
pbSEPlay("Battle ball shake")
|
||||
swingEgg(4)
|
||||
updateScene(Graphics.frame_rate*2/10)
|
||||
pbPositionHatchMask(1)
|
||||
pbSEPlay("Battle ball shake")
|
||||
swingEgg(4)
|
||||
updateScene(Graphics.frame_rate*4/10)
|
||||
pbPositionHatchMask(2)
|
||||
pbSEPlay("Battle ball shake")
|
||||
swingEgg(8,2)
|
||||
updateScene(Graphics.frame_rate*4/10)
|
||||
pbPositionHatchMask(3)
|
||||
pbSEPlay("Battle ball shake")
|
||||
swingEgg(16,4)
|
||||
updateScene(Graphics.frame_rate*2/10)
|
||||
pbPositionHatchMask(4)
|
||||
pbSEPlay("Battle recall")
|
||||
# Fade and change the sprite
|
||||
fadeTime = Graphics.frame_rate*4/10
|
||||
toneDiff = (255.0/fadeTime).ceil
|
||||
for i in 1..fadeTime
|
||||
@sprites["pokemon"].tone=Tone.new(i*toneDiff,i*toneDiff,i*toneDiff)
|
||||
@sprites["overlay"].opacity=i*toneDiff
|
||||
updateScene
|
||||
end
|
||||
updateScene(Graphics.frame_rate*3/4)
|
||||
@sprites["pokemon"].setPokemonBitmap(@pokemon) # Pokémon sprite
|
||||
@sprites["pokemon"].x = Graphics.width/2
|
||||
@sprites["pokemon"].y = 264
|
||||
@sprites["pokemon"].zoom_x=Settings::FRONTSPRITE_SCALE
|
||||
@sprites["pokemon"].zoom_y=Settings::FRONTSPRITE_SCALE
|
||||
|
||||
@pokemon.species_data.apply_metrics_to_sprite(@sprites["pokemon"], 1)
|
||||
@sprites["hatch"].visible=false
|
||||
for i in 1..fadeTime
|
||||
@sprites["pokemon"].tone=Tone.new(255-i*toneDiff,255-i*toneDiff,255-i*toneDiff)
|
||||
@sprites["overlay"].opacity=255-i*toneDiff
|
||||
updateScene
|
||||
end
|
||||
@sprites["pokemon"].tone=Tone.new(0,0,0)
|
||||
@sprites["overlay"].opacity=0
|
||||
# Finish scene
|
||||
frames = GameData::Species.cry_length(@pokemon)
|
||||
@pokemon.play_cry
|
||||
updateScene(frames)
|
||||
pbBGMStop()
|
||||
pbMEPlay("Evolution success")
|
||||
@pokemon.name = nil
|
||||
pbMessage(_INTL("\\se[]{1} hatched from the Egg!\\wt[80]", @pokemon.name)) { update }
|
||||
if pbConfirmMessage(
|
||||
_INTL("Would you like to nickname the newly hatched {1}?", @pokemon.name)) { update }
|
||||
nickname = pbEnterPokemonName(_INTL("{1}'s nickname?", @pokemon.name),
|
||||
0, Pokemon::MAX_NAME_SIZE, "", @pokemon, true)
|
||||
@pokemon.name = nickname
|
||||
@nicknamed = true
|
||||
end
|
||||
|
||||
if !$Trainer.pokedex.owned?(@pokemon.species)
|
||||
$Trainer.pokedex.register(@pokemon)
|
||||
$Trainer.pokedex.set_owned(@pokemon.species)
|
||||
pbMessage(_INTL("{1}'s data was added to the Pokédex", @pokemon.name))
|
||||
pbShowPokedex(@pokemon.species)
|
||||
end
|
||||
nb_eggs_hatched = pbGet(VAR_NB_EGGS_HATCHED)
|
||||
pbSet(VAR_NB_EGGS_HATCHED,nb_eggs_hatched+1)
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { update } if !@nicknamed
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@hatchSheet.dispose
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbPositionHatchMask(index)
|
||||
@sprites["hatch"].src_rect.x = index*@sprites["hatch"].src_rect.width
|
||||
end
|
||||
|
||||
def swingEgg(speed,swingTimes=1)
|
||||
@sprites["hatch"].visible = true
|
||||
speed = speed.to_f*20/Graphics.frame_rate
|
||||
amplitude = 8
|
||||
targets = []
|
||||
swingTimes.times do
|
||||
targets.push(@sprites["pokemon"].x+amplitude)
|
||||
targets.push(@sprites["pokemon"].x-amplitude)
|
||||
end
|
||||
targets.push(@sprites["pokemon"].x)
|
||||
targets.each_with_index do |target,i|
|
||||
loop do
|
||||
break if i%2==0 && @sprites["pokemon"].x>=target
|
||||
break if i%2==1 && @sprites["pokemon"].x<=target
|
||||
@sprites["pokemon"].x += speed
|
||||
@sprites["hatch"].x = @sprites["pokemon"].x
|
||||
updateScene
|
||||
end
|
||||
speed *= -1
|
||||
end
|
||||
@sprites["pokemon"].x = targets[targets.length-1]
|
||||
@sprites["hatch"].x = @sprites["pokemon"].x
|
||||
end
|
||||
|
||||
def updateScene(frames=1) # Can be used for "wait" effect
|
||||
frames.times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
self.update
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonEggHatchScreen
|
||||
def initialize(scene)
|
||||
@scene=scene
|
||||
end
|
||||
|
||||
def pbStartScreen(pokemon)
|
||||
@scene.pbStartScene(pokemon)
|
||||
@scene.pbMain
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbHatchAnimation(pokemon)
|
||||
pbMessage(_INTL("Huh?\1"))
|
||||
pbFadeOutInWithMusic {
|
||||
scene=PokemonEggHatch_Scene.new
|
||||
screen=PokemonEggHatchScreen.new(scene)
|
||||
screen.pbStartScreen(pokemon)
|
||||
}
|
||||
return true
|
||||
end
|
||||
|
||||
def pbHatch(pokemon)
|
||||
speciesname = pokemon.speciesName
|
||||
pokemon.name = nil
|
||||
pokemon.owner = Pokemon::Owner.new_from_trainer($Trainer)
|
||||
pokemon.happiness = 120
|
||||
pokemon.timeEggHatched = pbGetTimeNow
|
||||
pokemon.obtain_method = 1 # hatched from egg
|
||||
pokemon.hatched_map = $game_map.map_id
|
||||
if player_on_hidden_ability_map
|
||||
chosenAbility = pokemon.getAbilityList.sample #format: [[:ABILITY, index],...]
|
||||
#pokemon.ability = chosenAbility[0]
|
||||
pokemon.ability_index = chosenAbility[1]
|
||||
end
|
||||
|
||||
|
||||
pokemon.record_first_moves
|
||||
if !pbHatchAnimation(pokemon)
|
||||
pbMessage(_INTL("Huh?\1"))
|
||||
pbMessage(_INTL("...\1"))
|
||||
pbMessage(_INTL("... .... .....\1"))
|
||||
pbMessage(_INTL("{1} hatched from the Egg!", speciesname))
|
||||
if pbConfirmMessage(_INTL("Would you like to nickname the newly hatched {1}?", speciesname))
|
||||
nickname = pbEnterPokemonName(_INTL("{1}'s nickname?", speciesname),
|
||||
0, Pokemon::MAX_NAME_SIZE, "", pokemon)
|
||||
pokemon.name = nickname
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Events.onStepTaken += proc { |_sender,_e|
|
||||
for egg in $Trainer.party
|
||||
next if egg.steps_to_hatch <= 0
|
||||
egg.steps_to_hatch -= 1
|
||||
egg.steps_to_hatch -= 1 if isWearingClothes(CLOTHES_BREEDER)
|
||||
for i in $Trainer.pokemon_party
|
||||
next if !i.hasAbility?(:FLAMEBODY) && !i.hasAbility?(:MAGMAARMOR)
|
||||
egg.steps_to_hatch -= 1
|
||||
break
|
||||
end
|
||||
if egg.steps_to_hatch <= 0
|
||||
egg.steps_to_hatch = 0
|
||||
pbHatch(egg)
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -1,666 +0,0 @@
|
||||
#===============================================================================
|
||||
# Evolution animation metafiles and related methods
|
||||
#===============================================================================
|
||||
class SpriteMetafile
|
||||
VIEWPORT = 0
|
||||
TONE = 1
|
||||
SRC_RECT = 2
|
||||
VISIBLE = 3
|
||||
X = 4
|
||||
Y = 5
|
||||
Z = 6
|
||||
OX = 7
|
||||
OY = 8
|
||||
ZOOM_X = 9
|
||||
ZOOM_Y = 10
|
||||
ANGLE = 11
|
||||
MIRROR = 12
|
||||
BUSH_DEPTH = 13
|
||||
OPACITY = 14
|
||||
BLEND_TYPE = 15
|
||||
COLOR = 16
|
||||
FLASHCOLOR = 17
|
||||
FLASHDURATION = 18
|
||||
BITMAP = 19
|
||||
|
||||
def length
|
||||
return @metafile.length
|
||||
end
|
||||
|
||||
def [](i)
|
||||
return @metafile[i]
|
||||
end
|
||||
|
||||
def initialize(viewport=nil)
|
||||
@metafile=[]
|
||||
@values=[
|
||||
viewport,
|
||||
Tone.new(0,0,0,0),Rect.new(0,0,0,0),
|
||||
true,
|
||||
0,0,0,0,0,100,100,
|
||||
0,false,0,255,0,
|
||||
Color.new(0,0,0,0),Color.new(0,0,0,0),
|
||||
0
|
||||
]
|
||||
end
|
||||
|
||||
def disposed?
|
||||
return false
|
||||
end
|
||||
|
||||
def dispose; end
|
||||
|
||||
def flash(color,duration)
|
||||
if duration>0
|
||||
@values[FLASHCOLOR]=color.clone
|
||||
@values[FLASHDURATION]=duration
|
||||
@metafile.push([FLASHCOLOR,color])
|
||||
@metafile.push([FLASHDURATION,duration])
|
||||
end
|
||||
end
|
||||
|
||||
def x
|
||||
return @values[X]
|
||||
end
|
||||
|
||||
def x=(value)
|
||||
@values[X]=value
|
||||
@metafile.push([X,value])
|
||||
end
|
||||
|
||||
def y
|
||||
return @values[Y]
|
||||
end
|
||||
|
||||
def y=(value)
|
||||
@values[Y]=value
|
||||
@metafile.push([Y,value])
|
||||
end
|
||||
|
||||
def bitmap
|
||||
return nil
|
||||
end
|
||||
|
||||
def bitmap=(value)
|
||||
if value && !value.disposed?
|
||||
@values[SRC_RECT].set(0,0,value.width,value.height)
|
||||
@metafile.push([SRC_RECT,@values[SRC_RECT].clone])
|
||||
end
|
||||
end
|
||||
|
||||
def src_rect
|
||||
return @values[SRC_RECT]
|
||||
end
|
||||
|
||||
def src_rect=(value)
|
||||
@values[SRC_RECT]=value
|
||||
@metafile.push([SRC_RECT,value])
|
||||
end
|
||||
|
||||
def visible
|
||||
return @values[VISIBLE]
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
@values[VISIBLE]=value
|
||||
@metafile.push([VISIBLE,value])
|
||||
end
|
||||
|
||||
def z
|
||||
return @values[Z]
|
||||
end
|
||||
|
||||
def z=(value)
|
||||
@values[Z]=value
|
||||
@metafile.push([Z,value])
|
||||
end
|
||||
|
||||
def ox
|
||||
return @values[OX]
|
||||
end
|
||||
|
||||
def ox=(value)
|
||||
@values[OX]=value
|
||||
@metafile.push([OX,value])
|
||||
end
|
||||
|
||||
def oy
|
||||
return @values[OY]
|
||||
end
|
||||
|
||||
def oy=(value)
|
||||
@values[OY]=value
|
||||
@metafile.push([OY,value])
|
||||
end
|
||||
|
||||
def zoom_x
|
||||
return @values[ZOOM_X]
|
||||
end
|
||||
|
||||
def zoom_x=(value)
|
||||
@values[ZOOM_X]=value
|
||||
@metafile.push([ZOOM_X,value])
|
||||
end
|
||||
|
||||
def zoom_y
|
||||
return @values[ZOOM_Y]
|
||||
end
|
||||
|
||||
def zoom_y=(value)
|
||||
@values[ZOOM_Y]=value
|
||||
@metafile.push([ZOOM_Y,value])
|
||||
end
|
||||
|
||||
def zoom=(value)
|
||||
@values[ZOOM_X]=value
|
||||
@metafile.push([ZOOM_X,value])
|
||||
@values[ZOOM_Y]=value
|
||||
@metafile.push([ZOOM_Y,value])
|
||||
end
|
||||
|
||||
def angle
|
||||
return @values[ANGLE]
|
||||
end
|
||||
|
||||
def angle=(value)
|
||||
@values[ANGLE]=value
|
||||
@metafile.push([ANGLE,value])
|
||||
end
|
||||
|
||||
def mirror
|
||||
return @values[MIRROR]
|
||||
end
|
||||
|
||||
def mirror=(value)
|
||||
@values[MIRROR]=value
|
||||
@metafile.push([MIRROR,value])
|
||||
end
|
||||
|
||||
def bush_depth
|
||||
return @values[BUSH_DEPTH]
|
||||
end
|
||||
|
||||
def bush_depth=(value)
|
||||
@values[BUSH_DEPTH]=value
|
||||
@metafile.push([BUSH_DEPTH,value])
|
||||
end
|
||||
|
||||
def opacity
|
||||
return @values[OPACITY]
|
||||
end
|
||||
|
||||
def opacity=(value)
|
||||
@values[OPACITY]=value
|
||||
@metafile.push([OPACITY,value])
|
||||
end
|
||||
|
||||
def blend_type
|
||||
return @values[BLEND_TYPE]
|
||||
end
|
||||
|
||||
def blend_type=(value)
|
||||
@values[BLEND_TYPE]=value
|
||||
@metafile.push([BLEND_TYPE,value])
|
||||
end
|
||||
|
||||
def color
|
||||
return @values[COLOR]
|
||||
end
|
||||
|
||||
def color=(value)
|
||||
@values[COLOR]=value.clone
|
||||
@metafile.push([COLOR,@values[COLOR]])
|
||||
end
|
||||
|
||||
def tone
|
||||
return @values[TONE]
|
||||
end
|
||||
|
||||
def tone=(value)
|
||||
@values[TONE]=value.clone
|
||||
@metafile.push([TONE,@values[TONE]])
|
||||
end
|
||||
|
||||
def update
|
||||
@metafile.push([-1,nil])
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SpriteMetafilePlayer
|
||||
def initialize(metafile,sprite=nil)
|
||||
@metafile=metafile
|
||||
@sprites=[]
|
||||
@playing=false
|
||||
@index=0
|
||||
@sprites.push(sprite) if sprite
|
||||
end
|
||||
|
||||
def add(sprite)
|
||||
@sprites.push(sprite)
|
||||
end
|
||||
|
||||
def playing?
|
||||
return @playing
|
||||
end
|
||||
|
||||
def play
|
||||
@playing=true
|
||||
@index=0
|
||||
end
|
||||
|
||||
def update
|
||||
if @playing
|
||||
for j in @index...@metafile.length
|
||||
@index=j+1
|
||||
break if @metafile[j][0]<0
|
||||
code=@metafile[j][0]
|
||||
value=@metafile[j][1]
|
||||
for sprite in @sprites
|
||||
case code
|
||||
when SpriteMetafile::X then sprite.x = value
|
||||
when SpriteMetafile::Y then sprite.y = value
|
||||
when SpriteMetafile::OX then sprite.ox = value
|
||||
when SpriteMetafile::OY then sprite.oy = value
|
||||
when SpriteMetafile::ZOOM_X then sprite.zoom_x = value
|
||||
when SpriteMetafile::ZOOM_Y then sprite.zoom_y = value
|
||||
when SpriteMetafile::SRC_RECT then sprite.src_rect = value
|
||||
when SpriteMetafile::VISIBLE then sprite.visible = value
|
||||
when SpriteMetafile::Z then sprite.z = value # prevent crashes
|
||||
when SpriteMetafile::ANGLE then sprite.angle = (value == 180) ? 179.9 : value
|
||||
when SpriteMetafile::MIRROR then sprite.mirror = value
|
||||
when SpriteMetafile::BUSH_DEPTH then sprite.bush_depth = value
|
||||
when SpriteMetafile::OPACITY then sprite.opacity = value
|
||||
when SpriteMetafile::BLEND_TYPE then sprite.blend_type = value
|
||||
when SpriteMetafile::COLOR then sprite.color = value
|
||||
when SpriteMetafile::TONE then sprite.tone = value
|
||||
end
|
||||
end
|
||||
end
|
||||
@playing=false if @index==@metafile.length
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbSaveSpriteState(sprite)
|
||||
state=[]
|
||||
return state if !sprite || sprite.disposed?
|
||||
state[SpriteMetafile::BITMAP] = sprite.x
|
||||
state[SpriteMetafile::X] = sprite.x
|
||||
state[SpriteMetafile::Y] = sprite.y
|
||||
state[SpriteMetafile::SRC_RECT] = sprite.src_rect.clone
|
||||
state[SpriteMetafile::VISIBLE] = sprite.visible
|
||||
state[SpriteMetafile::Z] = sprite.z
|
||||
state[SpriteMetafile::OX] = sprite.ox
|
||||
state[SpriteMetafile::OY] = sprite.oy
|
||||
state[SpriteMetafile::ZOOM_X] = sprite.zoom_x
|
||||
state[SpriteMetafile::ZOOM_Y] = sprite.zoom_y
|
||||
state[SpriteMetafile::ANGLE] = sprite.angle
|
||||
state[SpriteMetafile::MIRROR] = sprite.mirror
|
||||
state[SpriteMetafile::BUSH_DEPTH] = sprite.bush_depth
|
||||
state[SpriteMetafile::OPACITY] = sprite.opacity
|
||||
state[SpriteMetafile::BLEND_TYPE] = sprite.blend_type
|
||||
state[SpriteMetafile::COLOR] = sprite.color.clone
|
||||
state[SpriteMetafile::TONE] = sprite.tone.clone
|
||||
return state
|
||||
end
|
||||
|
||||
def pbRestoreSpriteState(sprite,state)
|
||||
return if !state || !sprite || sprite.disposed?
|
||||
sprite.x = state[SpriteMetafile::X]
|
||||
sprite.y = state[SpriteMetafile::Y]
|
||||
sprite.src_rect = state[SpriteMetafile::SRC_RECT]
|
||||
sprite.visible = state[SpriteMetafile::VISIBLE]
|
||||
sprite.z = state[SpriteMetafile::Z]
|
||||
sprite.ox = state[SpriteMetafile::OX]
|
||||
sprite.oy = state[SpriteMetafile::OY]
|
||||
sprite.zoom_x = state[SpriteMetafile::ZOOM_X]
|
||||
sprite.zoom_y = state[SpriteMetafile::ZOOM_Y]
|
||||
sprite.angle = state[SpriteMetafile::ANGLE]
|
||||
sprite.mirror = state[SpriteMetafile::MIRROR]
|
||||
sprite.bush_depth = state[SpriteMetafile::BUSH_DEPTH]
|
||||
sprite.opacity = state[SpriteMetafile::OPACITY]
|
||||
sprite.blend_type = state[SpriteMetafile::BLEND_TYPE]
|
||||
sprite.color = state[SpriteMetafile::COLOR]
|
||||
sprite.tone = state[SpriteMetafile::TONE]
|
||||
end
|
||||
|
||||
def pbSaveSpriteStateAndBitmap(sprite)
|
||||
return [] if !sprite || sprite.disposed?
|
||||
state=pbSaveSpriteState(sprite)
|
||||
state[SpriteMetafile::BITMAP]=sprite.bitmap
|
||||
return state
|
||||
end
|
||||
|
||||
def pbRestoreSpriteStateAndBitmap(sprite,state)
|
||||
return if !state || !sprite || sprite.disposed?
|
||||
sprite.bitmap=state[SpriteMetafile::BITMAP]
|
||||
pbRestoreSpriteState(sprite,state)
|
||||
return state
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Evolution screen
|
||||
#===============================================================================
|
||||
class PokemonEvolutionScene
|
||||
private
|
||||
|
||||
def pbGenerateMetafiles(s1x,s1y,s2x,s2y)
|
||||
sprite = SpriteMetafile.new
|
||||
sprite.ox = s1x
|
||||
sprite.oy = s1y
|
||||
sprite.opacity = 255
|
||||
sprite2 = SpriteMetafile.new
|
||||
sprite2.ox = s2x
|
||||
sprite2.oy = s2y
|
||||
sprite2.zoom = 0.0
|
||||
sprite2.opacity = 255
|
||||
alpha = 0
|
||||
alphaDiff = 10*20/Graphics.frame_rate
|
||||
loop do
|
||||
sprite.color.red = 255
|
||||
sprite.color.green = 255
|
||||
sprite.color.blue = 255
|
||||
sprite.color.alpha = alpha
|
||||
sprite.color = sprite.color
|
||||
sprite2.color = sprite.color
|
||||
sprite2.color.alpha = 255
|
||||
sprite.update
|
||||
sprite2.update
|
||||
break if alpha>=255
|
||||
alpha += alphaDiff
|
||||
end
|
||||
totaltempo = 0
|
||||
currenttempo = 25
|
||||
maxtempo = 7*Graphics.frame_rate
|
||||
while totaltempo<maxtempo
|
||||
for j in 0...currenttempo
|
||||
if alpha<255
|
||||
sprite.color.red = 255
|
||||
sprite.color.green = 255
|
||||
sprite.color.blue = 255
|
||||
sprite.color.alpha = alpha
|
||||
sprite.color = sprite.color
|
||||
alpha += 10
|
||||
end
|
||||
sprite.zoom = [1.1*(currenttempo-j-1)/currenttempo,1.0].min
|
||||
sprite2.zoom = [1.1*(j+1)/currenttempo,1.0].min
|
||||
sprite.update
|
||||
sprite2.update
|
||||
end
|
||||
totaltempo += currenttempo
|
||||
if totaltempo+currenttempo<maxtempo
|
||||
for j in 0...currenttempo
|
||||
sprite.zoom = [1.1*(j+1)/currenttempo,1.0].min
|
||||
sprite2.zoom = [1.1*(currenttempo-j-1)/currenttempo,1.0].min
|
||||
sprite.update
|
||||
sprite2.update
|
||||
end
|
||||
end
|
||||
totaltempo += currenttempo
|
||||
currenttempo = [(currenttempo/1.5).floor,5].max
|
||||
end
|
||||
@metafile1 = sprite
|
||||
@metafile2 = sprite2
|
||||
end
|
||||
|
||||
public
|
||||
|
||||
def pbUpdate(animating=false)
|
||||
if animating # Pokémon shouldn't animate during the evolution animation
|
||||
@sprites["background"].update
|
||||
else
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
end
|
||||
|
||||
def pbUpdateNarrowScreen
|
||||
halfResizeDiff = 8*20/Graphics.frame_rate
|
||||
if @bgviewport.rect.y<80
|
||||
@bgviewport.rect.height -= halfResizeDiff*2
|
||||
if @bgviewport.rect.height<Graphics.height-64
|
||||
@bgviewport.rect.y += halfResizeDiff
|
||||
@sprites["background"].oy = @bgviewport.rect.y
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbUpdateExpandScreen
|
||||
halfResizeDiff = 8*20/Graphics.frame_rate
|
||||
if @bgviewport.rect.y>0
|
||||
@bgviewport.rect.y -= halfResizeDiff
|
||||
@sprites["background"].oy = @bgviewport.rect.y
|
||||
end
|
||||
if @bgviewport.rect.height<Graphics.height
|
||||
@bgviewport.rect.height += halfResizeDiff*2
|
||||
end
|
||||
end
|
||||
|
||||
def pbFlashInOut(canceled,oldstate,oldstate2)
|
||||
tone = 0
|
||||
toneDiff = 20*20/Graphics.frame_rate
|
||||
loop do
|
||||
Graphics.update
|
||||
pbUpdate(true)
|
||||
pbUpdateExpandScreen
|
||||
tone += toneDiff
|
||||
@viewport.tone.set(tone,tone,tone,0)
|
||||
break if tone>=255
|
||||
end
|
||||
@bgviewport.rect.y = 0
|
||||
@bgviewport.rect.height = Graphics.height
|
||||
@sprites["background"].oy = 0
|
||||
if canceled
|
||||
pbRestoreSpriteState(@sprites["rsprite1"],oldstate)
|
||||
pbRestoreSpriteState(@sprites["rsprite2"],oldstate2)
|
||||
@sprites["rsprite1"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite1"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite1"].color.alpha = 0
|
||||
@sprites["rsprite1"].visible = true
|
||||
@sprites["rsprite2"].visible = false
|
||||
else
|
||||
@sprites["rsprite1"].visible = false
|
||||
@sprites["rsprite2"].visible = true
|
||||
@sprites["rsprite1"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite1"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].color.alpha = 0
|
||||
end
|
||||
(Graphics.frame_rate/4).times do
|
||||
Graphics.update
|
||||
pbUpdate(true)
|
||||
end
|
||||
tone = 255
|
||||
toneDiff = 40*20/Graphics.frame_rate
|
||||
loop do
|
||||
Graphics.update
|
||||
pbUpdate
|
||||
tone -= toneDiff
|
||||
@viewport.tone.set(tone,tone,tone,0)
|
||||
break if tone<=0
|
||||
end
|
||||
end
|
||||
|
||||
def pbStartScreen(pokemon,newspecies,reversing=false)
|
||||
@pokemon = pokemon
|
||||
@newspecies = newspecies
|
||||
@sprites = {}
|
||||
@bgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@bgviewport.z = 99999
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@msgviewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@msgviewport.z = 99999
|
||||
background_file = reversing ? "DNAbg": "evolutionbg"
|
||||
|
||||
addBackgroundOrColoredPlane(@sprites,"background",background_file,
|
||||
Color.new(248,248,248),@bgviewport)
|
||||
rsprite1 = PokemonSprite.new(@viewport)
|
||||
rsprite1.setOffset(PictureOrigin::Center)
|
||||
rsprite1.setPokemonBitmap(@pokemon,false)
|
||||
rsprite1.x = Graphics.width/2
|
||||
rsprite1.y = (Graphics.height-64)/2
|
||||
rsprite2 = PokemonSprite.new(@viewport)
|
||||
rsprite2.setOffset(PictureOrigin::Center)
|
||||
rsprite2.setPokemonBitmapSpecies(@pokemon,@newspecies,false)
|
||||
rsprite2.x = rsprite1.x
|
||||
rsprite2.y = rsprite1.y
|
||||
rsprite2.opacity = 0
|
||||
@sprites["rsprite1"] = rsprite1
|
||||
@sprites["rsprite2"] = rsprite2
|
||||
pbGenerateMetafiles(rsprite1.ox,rsprite1.oy,rsprite2.ox,rsprite2.oy)
|
||||
@sprites["rsprite1"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite1"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["msgwindow"] = pbCreateMessageWindow(@msgviewport)
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
# Closes the evolution screen.
|
||||
def pbEndScreen
|
||||
pbDisposeMessageWindow(@sprites["msgwindow"])
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
@bgviewport.dispose
|
||||
@msgviewport.dispose
|
||||
end
|
||||
|
||||
# Opens the evolution screen
|
||||
def pbEvolution(cancancel=true,reversing=false)
|
||||
metaplayer1 = SpriteMetafilePlayer.new(@metafile1,@sprites["rsprite1"])
|
||||
metaplayer2 = SpriteMetafilePlayer.new(@metafile2,@sprites["rsprite2"])
|
||||
metaplayer1.play
|
||||
metaplayer2.play
|
||||
pbBGMStop
|
||||
@pokemon.play_cry
|
||||
if !reversing
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("\\se[]What? {1} is evolving!\\^",@pokemon.name)) { pbUpdate }
|
||||
pbMessageWaitForInput(@sprites["msgwindow"],50,true) { pbUpdate }
|
||||
end
|
||||
pbPlayDecisionSE
|
||||
oldstate = pbSaveSpriteState(@sprites["rsprite1"])
|
||||
oldstate2 = pbSaveSpriteState(@sprites["rsprite2"])
|
||||
pbMEPlay("Evolution start")
|
||||
pbBGMPlay("Evolution")
|
||||
canceled = false
|
||||
begin
|
||||
pbUpdateNarrowScreen
|
||||
metaplayer1.update
|
||||
metaplayer2.update
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate(true)
|
||||
if Input.trigger?(Input::BACK) && cancancel
|
||||
pbBGMStop
|
||||
pbPlayCancelSE
|
||||
canceled = true
|
||||
break
|
||||
end
|
||||
end while metaplayer1.playing? && metaplayer2.playing?
|
||||
pbFlashInOut(canceled,oldstate,oldstate2)
|
||||
if canceled
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("Huh? {1} stopped evolving!",@pokemon.name)) { pbUpdate }
|
||||
else
|
||||
pbEvolutionSuccess(reversing)
|
||||
end
|
||||
end
|
||||
|
||||
def pbEvolutionSuccess(reversing=false)
|
||||
# Play cry of evolved species
|
||||
frames = GameData::Species.cry_length(@newspecies, @pokemon.form)
|
||||
pbBGMStop
|
||||
Pokemon.play_cry(@newspecies, @pokemon.form)
|
||||
frames.times do
|
||||
Graphics.update
|
||||
pbUpdate
|
||||
end
|
||||
# Success jingle/message
|
||||
pbMEPlay("Evolution success")
|
||||
sprite_bitmap=@sprites["rsprite2"].getBitmap
|
||||
|
||||
#drawSpriteCredits(sprite_bitmap.filename,sprite_bitmap.path, @viewport)
|
||||
|
||||
newspeciesname = GameData::Species.get(@newspecies).name
|
||||
if !reversing
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("\\se[]Congratulations! Your {1} evolved into {2}!\\wt[80]",
|
||||
@pokemon.name,newspeciesname)) { pbUpdate }
|
||||
else
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("\\se[]{1} has been turned into {2}!\\wt[80]",
|
||||
@pokemon.name,newspeciesname)) { pbUpdate }
|
||||
end
|
||||
|
||||
|
||||
@sprites["msgwindow"].text = ""
|
||||
# Check for consumed item and check if Pokémon should be duplicated
|
||||
pbEvolutionMethodAfterEvolution if !reversing
|
||||
|
||||
|
||||
#oldAbility = @pokemon.ability.id if @pokemon.ability
|
||||
newSpecies = GameData::Species.get(@newspecies)
|
||||
|
||||
#allNewPossibleAbilities = newSpecies.abilities + newSpecies.hidden_abilities
|
||||
|
||||
# Modify Pokémon to make it evolved
|
||||
@pokemon.species = @newspecies
|
||||
@pokemon.form = 0 if @pokemon.isSpecies?(:MOTHIM)
|
||||
@pokemon.calc_stats
|
||||
# See and own evolved species
|
||||
#
|
||||
|
||||
if !$Trainer.pokedex.owned?(@newspecies)
|
||||
$Trainer.pokedex.register(@pokemon)
|
||||
$Trainer.pokedex.set_owned(@newspecies)
|
||||
Kernel.pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("{1}'s data was added to the Pokédex", newspeciesname))
|
||||
@scene.pbShowPokedex(@newspecies)
|
||||
end
|
||||
|
||||
|
||||
|
||||
# if allNewPossibleAbilities.include?(oldAbility)
|
||||
# @pokemon.ability=oldAbility
|
||||
# end
|
||||
|
||||
# Learn moves upon evolution for evolved species
|
||||
movelist = @pokemon.getMoveList
|
||||
for i in movelist
|
||||
next if i[0]!=0 && i[0]!=@pokemon.level # 0 is "learn upon evolution"
|
||||
pbLearnMove(@pokemon,i[1],true) { pbUpdate }
|
||||
end
|
||||
end
|
||||
|
||||
def pbEvolutionMethodAfterEvolution
|
||||
@pokemon.action_after_evolution(@newspecies)
|
||||
end
|
||||
|
||||
def self.pbDuplicatePokemon(pkmn, new_species)
|
||||
new_pkmn = pkmn.clone
|
||||
new_pkmn.species = new_species
|
||||
new_pkmn.name = nil
|
||||
new_pkmn.markings = 0
|
||||
new_pkmn.poke_ball = :POKEBALL
|
||||
new_pkmn.item = nil
|
||||
new_pkmn.clearAllRibbons
|
||||
new_pkmn.calc_stats
|
||||
new_pkmn.heal
|
||||
# Add duplicate Pokémon to party
|
||||
$Trainer.party.push(new_pkmn)
|
||||
# See and own duplicate Pokémon
|
||||
$Trainer.pokedex.register(new_pkmn)
|
||||
$Trainer.pokedex.set_owned(new_species)
|
||||
end
|
||||
end
|
||||
@@ -1,252 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonTrade_Scene
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbRunPictures(pictures,sprites)
|
||||
loop do
|
||||
for i in 0...pictures.length
|
||||
pictures[i].update
|
||||
end
|
||||
for i in 0...sprites.length
|
||||
if sprites[i].is_a?(IconSprite)
|
||||
setPictureIconSprite(sprites[i],pictures[i])
|
||||
else
|
||||
setPictureSprite(sprites[i],pictures[i])
|
||||
end
|
||||
end
|
||||
Graphics.update
|
||||
Input.update
|
||||
running = false
|
||||
for i in 0...pictures.length
|
||||
running = true if pictures[i].running?
|
||||
end
|
||||
break if !running
|
||||
end
|
||||
end
|
||||
|
||||
def pbStartScreen(pokemon,pokemon2,trader1,trader2)
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@pokemon = pokemon
|
||||
@pokemon2 = pokemon2
|
||||
@trader1 = trader1
|
||||
@trader2 = trader2
|
||||
addBackgroundOrColoredPlane(@sprites,"background","tradebg",
|
||||
Color.new(248,248,248),@viewport)
|
||||
@sprites["rsprite1"] = PokemonSprite.new(@viewport)
|
||||
@sprites["rsprite1"].setPokemonBitmap(@pokemon,false)
|
||||
@sprites["rsprite1"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["rsprite1"].x = Graphics.width/2
|
||||
@sprites["rsprite1"].y = 264
|
||||
@sprites["rsprite1"].z = 10
|
||||
@sprites["rsprite1"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite1"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
|
||||
|
||||
@pokemon.species_data.apply_metrics_to_sprite(@sprites["rsprite1"], 1)
|
||||
@sprites["rsprite2"] = PokemonSprite.new(@viewport)
|
||||
@sprites["rsprite2"].setPokemonBitmap(@pokemon2,false)
|
||||
@sprites["rsprite2"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["rsprite2"].x = Graphics.width/2
|
||||
@sprites["rsprite2"].y = 264
|
||||
@sprites["rsprite2"].z = 10
|
||||
@sprites["rsprite2"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["rsprite2"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
|
||||
@pokemon2.species_data.apply_metrics_to_sprite(@sprites["rsprite2"], 1)
|
||||
@sprites["rsprite2"].visible = false
|
||||
@sprites["msgwindow"] = pbCreateMessageWindow(@viewport)
|
||||
pbFadeInAndShow(@sprites)
|
||||
end
|
||||
|
||||
def pbScene1
|
||||
spriteBall = IconSprite.new(0,0,@viewport)
|
||||
pictureBall = PictureEx.new(0)
|
||||
picturePoke = PictureEx.new(0)
|
||||
ballimage = sprintf("Graphics/Battle animations/ball_%s", @pokemon.poke_ball)
|
||||
if !pbResolveBitmap(ballimage)
|
||||
ballimage = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(@pokemon.poke_ball))
|
||||
end
|
||||
ballopenimage = sprintf("Graphics/Battle animations/ball_%s_open", @pokemon.poke_ball)
|
||||
if !pbResolveBitmap(ballimage)
|
||||
ballopenimage = sprintf("Graphics/Battle animations/ball_%02d_open", pbGetBallType(@pokemon.poke_ball))
|
||||
end
|
||||
# Starting position of ball
|
||||
pictureBall.setXY(0,Graphics.width/2,48)
|
||||
pictureBall.setName(0,ballimage)
|
||||
pictureBall.setSrcSize(0,32,64)
|
||||
pictureBall.setOrigin(0,PictureOrigin::Center)
|
||||
pictureBall.setVisible(0,true)
|
||||
# Starting position of sprite
|
||||
picturePoke.setXY(0,@sprites["rsprite1"].x,@sprites["rsprite1"].y)
|
||||
picturePoke.setOrigin(0,PictureOrigin::Bottom)
|
||||
picturePoke.setVisible(0,true)
|
||||
# Change Pokémon color
|
||||
picturePoke.moveColor(2,5,Color.new(31*8,22*8,30*8,255))
|
||||
# Recall
|
||||
delay = picturePoke.totalDuration
|
||||
picturePoke.setSE(delay,"Battle recall")
|
||||
pictureBall.setName(delay,ballopenimage)
|
||||
pictureBall.setSrcSize(delay,32,64)
|
||||
# Move sprite to ball
|
||||
picturePoke.moveZoom(delay,8,0)
|
||||
picturePoke.moveXY(delay,8,Graphics.width/2,48)
|
||||
picturePoke.setSE(delay+5,"Battle jump to ball")
|
||||
picturePoke.setVisible(delay+8,false)
|
||||
delay = picturePoke.totalDuration+1
|
||||
pictureBall.setName(delay,ballimage)
|
||||
pictureBall.setSrcSize(delay,32,64)
|
||||
# Make Poké Ball go off the top of the screen
|
||||
delay = picturePoke.totalDuration+10
|
||||
pictureBall.moveXY(delay,6,Graphics.width/2,-32)
|
||||
# Play animation
|
||||
pbRunPictures(
|
||||
[picturePoke,pictureBall],
|
||||
[@sprites["rsprite1"],spriteBall]
|
||||
)
|
||||
spriteBall.dispose
|
||||
end
|
||||
|
||||
def pbScene2
|
||||
spriteBall = IconSprite.new(0,0,@viewport)
|
||||
pictureBall = PictureEx.new(0)
|
||||
picturePoke = PictureEx.new(0)
|
||||
ballimage = sprintf("Graphics/Battle animations/ball_%s", @pokemon2.poke_ball)
|
||||
if !pbResolveBitmap(ballimage)
|
||||
ballimage = sprintf("Graphics/Battle animations/ball_%02d", pbGetBallType(@pokemon2.poke_ball))
|
||||
end
|
||||
ballopenimage = sprintf("Graphics/Battle animations/ball_%s_open", @pokemon2.poke_ball)
|
||||
if !pbResolveBitmap(ballimage)
|
||||
ballopenimage = sprintf("Graphics/Battle animations/ball_%02d_open", pbGetBallType(@pokemon2.poke_ball))
|
||||
end
|
||||
# Starting position of ball
|
||||
pictureBall.setXY(0,Graphics.width/2,-32)
|
||||
pictureBall.setName(0,ballimage)
|
||||
pictureBall.setSrcSize(0,32,64)
|
||||
pictureBall.setOrigin(0,PictureOrigin::Center)
|
||||
pictureBall.setVisible(0,true)
|
||||
# Starting position of sprite
|
||||
picturePoke.setOrigin(0,PictureOrigin::Bottom)
|
||||
picturePoke.setZoom(0,0)
|
||||
picturePoke.setColor(0,Color.new(31*8,22*8,30*8,255))
|
||||
picturePoke.setVisible(0,false)
|
||||
# Dropping ball
|
||||
y = Graphics.height-96-16-16 # end point of Poké Ball
|
||||
delay = picturePoke.totalDuration+2
|
||||
for i in 0...4
|
||||
t = [4,4,3,2][i] # Time taken to rise or fall for each bounce
|
||||
d = [1,2,4,8][i] # Fraction of the starting height each bounce rises to
|
||||
delay -= t if i==0
|
||||
if i>0
|
||||
pictureBall.setZoomXY(delay,100+5*(5-i),100-5*(5-i)) # Squish
|
||||
pictureBall.moveZoom(delay,2,100) # Unsquish
|
||||
pictureBall.moveXY(delay,t,Graphics.width/2,y-100/d)
|
||||
end
|
||||
pictureBall.moveXY(delay+t,t,Graphics.width/2,y)
|
||||
pictureBall.setSE(delay+2*t,"Battle ball drop")
|
||||
delay = pictureBall.totalDuration
|
||||
end
|
||||
picturePoke.setXY(delay,Graphics.width/2,y)
|
||||
# Open Poké Ball
|
||||
delay = pictureBall.totalDuration+15
|
||||
pictureBall.setSE(delay,"Battle recall")
|
||||
pictureBall.setName(delay,ballopenimage)
|
||||
pictureBall.setSrcSize(delay,32,64)
|
||||
pictureBall.setVisible(delay+5,false)
|
||||
# Pokémon appears and enlarges
|
||||
picturePoke.setVisible(delay,true)
|
||||
picturePoke.moveZoom(delay,8,100)
|
||||
picturePoke.moveXY(delay,8,Graphics.width/2,@sprites["rsprite2"].y)
|
||||
# Return Pokémon's color to normal and play cry
|
||||
delay = picturePoke.totalDuration
|
||||
picturePoke.moveColor(delay,5,Color.new(31*8,22*8,30*8,0))
|
||||
cry = GameData::Species.cry_filename_from_pokemon(@pokemon2)
|
||||
picturePoke.setSE(delay,cry) if cry
|
||||
# Play animation
|
||||
pbRunPictures(
|
||||
[picturePoke,pictureBall],
|
||||
[@sprites["rsprite2"],spriteBall]
|
||||
)
|
||||
spriteBall.dispose
|
||||
end
|
||||
|
||||
def pbEndScreen
|
||||
pbDisposeMessageWindow(@sprites["msgwindow"])
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
newspecies = @pokemon2.check_evolution_on_trade(@pokemon)
|
||||
if newspecies
|
||||
evo = PokemonEvolutionScene.new
|
||||
evo.pbStartScreen(@pokemon2,newspecies)
|
||||
evo.pbEvolution(false)
|
||||
evo.pbEndScreen
|
||||
end
|
||||
end
|
||||
|
||||
def pbTrade
|
||||
pbBGMStop
|
||||
@pokemon.play_cry
|
||||
speciesname1=GameData::Species.get(@pokemon.species).name
|
||||
speciesname2=GameData::Species.get(@pokemon2.species).name
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_ISPRINTF("{1:s}\r\nID: {2:05d} OT: {3:s}\\wtnp[0]",
|
||||
@pokemon.name,@pokemon.owner.public_id,@pokemon.owner.name)) { pbUpdate }
|
||||
pbMessageWaitForInput(@sprites["msgwindow"],50,true) { pbUpdate }
|
||||
pbPlayDecisionSE
|
||||
pbScene1
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("For {1}'s {2},\r\n{3} sends {4}.\1",@trader1,@pokemon.name,@trader2,@pokemon2.name)) { pbUpdate }
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("{1} bids farewell to {2}.",@trader2,@pokemon2.name)) { pbUpdate }
|
||||
pbScene2
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_ISPRINTF("{1:s}\r\nNN: {2:s} OT: {3:s}\1", speciesname2,@pokemon2.name,@pokemon2.owner.name)) { pbUpdate }
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("Take good care of {1}.",@pokemon2.name)) { pbUpdate }
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbStartTrade(pokemonIndex,newpoke,nickname,trainerName,trainerGender=0,savegame=false)
|
||||
Kernel.Autosave if savegame
|
||||
|
||||
myPokemon = $Trainer.party[pokemonIndex]
|
||||
heldItem = myPokemon.item
|
||||
echoln heldItem
|
||||
$PokemonBag.pbStoreItem(heldItem, 1) if heldItem
|
||||
|
||||
opponent = NPCTrainer.new(trainerName,trainerGender)
|
||||
opponent.id = $Trainer.make_foreign_ID
|
||||
yourPokemon = nil
|
||||
resetmoves = true
|
||||
if newpoke.is_a?(Pokemon)
|
||||
newpoke.owner = Pokemon::Owner.new_from_trainer(opponent)
|
||||
yourPokemon = newpoke
|
||||
resetmoves = false
|
||||
else
|
||||
species_data = GameData::Species.try_get(newpoke)
|
||||
raise _INTL("Species does not exist ({1}).", newpoke) if !species_data
|
||||
yourPokemon = Pokemon.new(species_data.id, myPokemon.level, opponent)
|
||||
end
|
||||
yourPokemon.name = nickname
|
||||
yourPokemon.obtain_method = 2 # traded
|
||||
yourPokemon.reset_moves if resetmoves
|
||||
yourPokemon.record_first_moves
|
||||
$Trainer.pokedex.register(yourPokemon)
|
||||
$Trainer.pokedex.set_owned(yourPokemon.species)
|
||||
pbFadeOutInWithMusic {
|
||||
evo = PokemonTrade_Scene.new
|
||||
evo.pbStartScreen(myPokemon,yourPokemon,$Trainer.name,opponent.name)
|
||||
evo.pbTrade
|
||||
evo.pbEndScreen
|
||||
}
|
||||
$Trainer.party[pokemonIndex] = yourPokemon
|
||||
end
|
||||
@@ -1,673 +0,0 @@
|
||||
#===============================================================================
|
||||
# * Hall of Fame - by FL (Credits will be apreciated)
|
||||
#===============================================================================
|
||||
#
|
||||
# This script is for Pokémon Essentials. It makes a recordable Hall of Fame
|
||||
# like the Gen 3 games.
|
||||
#
|
||||
#===============================================================================
|
||||
#
|
||||
# To this scripts works, put it above main, put a 512x384 picture in
|
||||
# hallfamebars and a 8x24 background picture in hallfamebg. To call this script,
|
||||
# use 'pbHallOfFameEntry'. After you recorder the first entry, you can access
|
||||
# the hall teams using a PC. You can also check the player Hall of Fame last
|
||||
# number using '$PokemonGlobal.hallOfFameLastNumber'.
|
||||
#
|
||||
#===============================================================================
|
||||
class HallOfFame_Scene
|
||||
# When true, all pokémon will be in one line
|
||||
# When false, all pokémon will be in two lines
|
||||
@singlerow = true
|
||||
# Make the pokémon movement ON in hall entry
|
||||
ANIMATION = true
|
||||
# Speed in pokémon movement in hall entry. Don't use less than 2!
|
||||
ANIMATIONSPEED = 32
|
||||
# Entry wait time (in 1/20 seconds) between showing each Pokémon (and trainer)
|
||||
ENTRYWAITTIME = 64
|
||||
# Maximum number limit of simultaneous hall entries saved.
|
||||
# 0 = Doesn't save any hall. -1 = no limit
|
||||
# Prefer to use larger numbers (like 500 and 1000) than don't put a limit
|
||||
# If a player exceed this limit, the first one will be removed
|
||||
HALLLIMIT = 50
|
||||
# The entry music name. Put "" to doesn't play anything
|
||||
ENTRYMUSIC = "Hall of Fame"
|
||||
# Allow eggs to be show and saved in hall
|
||||
ALLOWEGGS = true
|
||||
# Remove the hallbars when the trainer sprite appears
|
||||
REMOVEBARS = false
|
||||
# The final fade speed on entry
|
||||
FINALFADESPEED = 16
|
||||
# Sprites opacity value when them aren't selected
|
||||
OPACITY = 64
|
||||
BASECOLOR = Color.new(248, 248, 248)
|
||||
SHADOWCOLOR = Color.new(0, 0, 0)
|
||||
|
||||
# Placement for pokemon icons
|
||||
def pbStartScene
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
# Comment the below line to doesn't use a background
|
||||
bgFile = @singlerow ? "hallfamebg" : "hallfamebg_multiline"
|
||||
addBackgroundPlane(@sprites, "bg", bgFile, @viewport)
|
||||
@sprites["hallbars"] = IconSprite.new(@viewport)
|
||||
@sprites["hallbars"].setBitmap("Graphics/Pictures/hallfamebars")
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
@sprites["overlay"].z = 10
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@alreadyFadedInEnd = false
|
||||
@useMusic = false
|
||||
@battlerIndex = 0
|
||||
@hallEntry = []
|
||||
end
|
||||
|
||||
def pbStartSceneEntry
|
||||
@singlerow = true
|
||||
pbStartScene
|
||||
@useMusic = (ENTRYMUSIC && ENTRYMUSIC != "")
|
||||
pbBGMPlay(ENTRYMUSIC) if @useMusic
|
||||
saveHallEntry
|
||||
@xmovement = []
|
||||
@ymovement = []
|
||||
createBattlers
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbStartScenePC
|
||||
@singlerow = false
|
||||
pbStartScene
|
||||
@hallIndex = $PokemonGlobal.hallOfFame.size - 1
|
||||
|
||||
echoln $PokemonGlobal.hallOfFame[-1]
|
||||
@hallEntry = $PokemonGlobal.hallOfFame[-1][:TEAM]
|
||||
createBattlers(false)
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
pbUpdatePC
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
$game_map.autoplay if @useMusic
|
||||
pbDisposeMessageWindow(@sprites["msgwindow"]) if @sprites.include?("msgwindow")
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate } if !@alreadyFadedInEnd
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def slowFadeOut(sprites, exponent)
|
||||
# 2 exponent
|
||||
# To handle values above 8
|
||||
extraWaitExponent = exponent - 9
|
||||
exponent = 8 if 8 < exponent
|
||||
max = 2 ** exponent
|
||||
speed = (2 ** 8) / max
|
||||
for j in 0..max
|
||||
if extraWaitExponent > -1
|
||||
(2 ** extraWaitExponent).times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
end
|
||||
end
|
||||
pbSetSpritesToColor(sprites, Color.new(0, 0, 0, j * speed))
|
||||
block_given? ? yield : pbUpdateSpriteHash(sprites)
|
||||
end
|
||||
end
|
||||
|
||||
# Dispose the sprite if the sprite exists and make it null
|
||||
def restartSpritePosition(sprites, spritename)
|
||||
sprites[spritename].dispose if sprites.include?(spritename) && sprites[spritename]
|
||||
sprites[spritename] = nil
|
||||
end
|
||||
|
||||
# Change the pokémon sprites opacity except the index one
|
||||
def setPokemonSpritesOpacity(index, opacity = 255)
|
||||
for n in 0...@hallEntry.size
|
||||
@sprites["pokemon#{n}"].opacity = (n == index) ? 255 : opacity if @sprites["pokemon#{n}"]
|
||||
end
|
||||
end
|
||||
|
||||
def saveHallEntry
|
||||
for i in 0...$Trainer.party.length
|
||||
# Clones every pokémon object
|
||||
@hallEntry.push($Trainer.party[i].clone) if !$Trainer.party[i].egg? || ALLOWEGGS
|
||||
end
|
||||
entryData = {}
|
||||
entryData[:TEAM] = @hallEntry
|
||||
entryData[:DIFFICULTY] = getDifficulty
|
||||
entryData[:MODE] = getCurrentGameMode()
|
||||
entryData[:DATE] = getCurrentDate()
|
||||
|
||||
#Save trainer data (unused for now)
|
||||
entryData[:TRAINER_HAT] = $Trainer.hat
|
||||
entryData[:TRAINER_HAT_COLOR] = $Trainer.hat_color
|
||||
entryData[:TRAINER_HAIR] = $Trainer.hair
|
||||
entryData[:TRAINER_HAIR_COLOR] = $Trainer.hair_color
|
||||
entryData[:TRAINER_CLOTHES] = $Trainer.clothes
|
||||
entryData[:TRAINER_CLOTHES_COLOR] = $Trainer.clothes_color
|
||||
entryData[:TRAINER_SKIN] = $Trainer.skin_tone
|
||||
|
||||
# Update the global variables
|
||||
$PokemonGlobal.hallOfFame.push(entryData)
|
||||
$PokemonGlobal.hallOfFameLastNumber += 1
|
||||
$PokemonGlobal.hallOfFame.delete_at(0) if HALLLIMIT > -1 &&
|
||||
$PokemonGlobal.hallOfFame.size > HALLLIMIT
|
||||
end
|
||||
|
||||
# Return the x/y point position in screen for battler index number
|
||||
# Don't use odd numbers!
|
||||
def xpointformula(battlernumber)
|
||||
ret = 0
|
||||
if !@singlerow
|
||||
ret = 92 + 160 * xpositionformula(battlernumber) #32
|
||||
else
|
||||
start_position = -16 #-56
|
||||
spacing = 70 # spacing between mons
|
||||
ret = (spacing * (battlernumber / 2) + 48) * (xpositionformula(battlernumber) - 1)
|
||||
|
||||
gap_size = 40 #gap for the trainer sprite in the middle
|
||||
if battlernumber % 2 == 0 #left side
|
||||
ret -= gap_size / 2
|
||||
else
|
||||
ret += gap_size / 2
|
||||
end
|
||||
ret += Graphics.width / 2 + start_position
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def ypointformula(battlernumber)
|
||||
ret = 0
|
||||
if !@singlerow
|
||||
ret = 92 + 128 * ypositionformula(battlernumber) / 2
|
||||
else
|
||||
y_position_base = 125
|
||||
height_increase = 20
|
||||
# Calculate the decrement based on the battlernumber:
|
||||
# Each pair (1-2, 3-4, etc.) will decrease y by 20
|
||||
y_decrement = 40 - height_increase * (battlernumber / 2)
|
||||
ret = y_position_base + y_decrement
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
# Returns 0, 1 or 2 as the x/y column value
|
||||
def xpositionformula(battlernumber)
|
||||
ret = 0
|
||||
if !@singlerow
|
||||
ret = (battlernumber / 3 % 2 == 0) ? (19 - battlernumber) % 3 : (19 + battlernumber) % 3
|
||||
else
|
||||
ret = battlernumber % 2 * 2
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def ypositionformula(battlernumber)
|
||||
ret = 0
|
||||
if !@singlerow
|
||||
ret = (battlernumber / 3) % 2 * 2
|
||||
else
|
||||
ret = 1
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def moveSprite(i)
|
||||
spritename = (i > -1) ? "pokemon#{i}" : "trainer"
|
||||
speed = (i > -1) ? ANIMATIONSPEED : 2
|
||||
if (!ANIMATION) # Skips animation
|
||||
@sprites[spritename].x -= speed * @xmovement[i]
|
||||
@xmovement[i] = 0
|
||||
@sprites[spritename].y -= speed * @ymovement[i]
|
||||
@ymovement[i] = 0
|
||||
end
|
||||
if (@xmovement[i] != 0)
|
||||
direction = (@xmovement[i] > 0) ? -1 : 1
|
||||
@sprites[spritename].x += speed * direction
|
||||
@xmovement[i] += direction
|
||||
end
|
||||
if (@ymovement[i] != 0)
|
||||
direction = (@ymovement[i] > 0) ? -1 : 1
|
||||
@sprites[spritename].y += speed * direction
|
||||
@ymovement[i] += direction
|
||||
end
|
||||
end
|
||||
|
||||
def createBattlers(hide = true)
|
||||
# Movement in animation
|
||||
for i in 0...6
|
||||
# Clear all 6 pokémon sprites and dispose the ones that exists every time
|
||||
# that this method is call
|
||||
restartSpritePosition(@sprites, "pokemon#{i}")
|
||||
next if i >= @hallEntry.size
|
||||
xpoint = xpointformula(i)
|
||||
ypoint = ypointformula(i)
|
||||
pok = @hallEntry[i]
|
||||
@sprites["pokemon#{i}"] = PokemonSprite.new(@viewport)
|
||||
@sprites["pokemon#{i}"].setOffset(PictureOrigin::TopLeft)
|
||||
@sprites["pokemon#{i}"].setPokemonBitmap(pok)
|
||||
@sprites["pokemon#{i}"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["pokemon#{i}"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
|
||||
# This method doesn't put the exact coordinates
|
||||
@sprites["pokemon#{i}"].x = xpoint
|
||||
@sprites["pokemon#{i}"].y = ypoint
|
||||
if @sprites["pokemon#{i}"].bitmap && !@sprites["pokemon#{i}"].disposed?
|
||||
@sprites["pokemon#{i}"].x += (128 - @sprites["pokemon#{i}"].bitmap.width) / 2
|
||||
@sprites["pokemon#{i}"].y += (128 - @sprites["pokemon#{i}"].bitmap.height) / 2
|
||||
end
|
||||
@sprites["pokemon#{i}"].z = 7 - i if @singlerow
|
||||
next if !hide
|
||||
# Animation distance calculation
|
||||
horizontal = 1 - xpositionformula(i)
|
||||
vertical = 1 - ypositionformula(i)
|
||||
xdistance = (horizontal == -1) ? -@sprites["pokemon#{i}"].bitmap.width : Graphics.width
|
||||
ydistance = (vertical == -1) ? -@sprites["pokemon#{i}"].bitmap.height : Graphics.height
|
||||
xdistance = ((xdistance - @sprites["pokemon#{i}"].x) / ANIMATIONSPEED).abs + 1
|
||||
ydistance = ((ydistance - @sprites["pokemon#{i}"].y) / ANIMATIONSPEED).abs + 1
|
||||
biggerdistance = (xdistance > ydistance) ? xdistance : ydistance
|
||||
@xmovement[i] = biggerdistance
|
||||
@xmovement[i] *= -1 if horizontal == -1
|
||||
@xmovement[i] = 0 if horizontal == 0
|
||||
@ymovement[i] = biggerdistance
|
||||
@ymovement[i] *= -1 if vertical == -1
|
||||
@ymovement[i] = 0 if vertical == 0
|
||||
# Hide the battlers
|
||||
@sprites["pokemon#{i}"].x += @xmovement[i] * ANIMATIONSPEED
|
||||
@sprites["pokemon#{i}"].y += @ymovement[i] * ANIMATIONSPEED
|
||||
end
|
||||
end
|
||||
|
||||
def createTrainerBattler
|
||||
@sprites["trainer"] = IconSprite.new(@viewport)
|
||||
@sprites["trainer"].setBitmapDirectly(generate_front_trainer_sprite_bitmap())
|
||||
if !@singlerow
|
||||
@sprites["trainer"].x = Graphics.width - 96
|
||||
@sprites["trainer"].y = 160
|
||||
else
|
||||
@sprites["trainer"].x = Graphics.width / 2 # - 96
|
||||
@sprites["trainer"].y = 178
|
||||
end
|
||||
@sprites["trainer"].opacity = 255
|
||||
@sprites["trainer"].z = 9
|
||||
@sprites["trainer"].ox = @sprites["trainer"].bitmap.width / 2
|
||||
@sprites["trainer"].oy = @sprites["trainer"].bitmap.height / 2
|
||||
if REMOVEBARS
|
||||
@sprites["overlay"].bitmap.clear
|
||||
@sprites["hallbars"].visible = false
|
||||
end
|
||||
@xmovement[@battlerIndex] = 0
|
||||
@ymovement[@battlerIndex] = 0
|
||||
#if (ANIMATION)#) && !@singlerow) # Trainer Animation
|
||||
startpoint = (Graphics.width / 2) - 200
|
||||
# 2 is the trainer speed
|
||||
@xmovement[@battlerIndex] = (startpoint - @sprites["trainer"].x) / 2
|
||||
@sprites["trainer"].x = startpoint
|
||||
# else
|
||||
# ENTRYWAITTIME.times do
|
||||
# Graphics.update
|
||||
# Input.update
|
||||
# pbUpdate
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
#Get difficulty for displaying in-game
|
||||
def getDifficulty
|
||||
return getDisplayDifficulty()
|
||||
end
|
||||
|
||||
def writeTrainerData
|
||||
totalsec = Graphics.frame_count / Graphics.frame_rate
|
||||
hour = totalsec / 60 / 60
|
||||
min = totalsec / 60 % 60
|
||||
pubid = sprintf("%05d", $Trainer.public_ID)
|
||||
lefttext = _INTL("Name<r>{1}<br>", $Trainer.name)
|
||||
lefttext += _INTL("IDNo.<r>{1}<br>", pubid)
|
||||
lefttext += _ISPRINTF("Time<r>{1:02d}:{2:02d}<br>", hour, min)
|
||||
lefttext += _INTL("Pokédex<r>{1}/{2}<br>",
|
||||
$Trainer.pokedex.owned_count, $Trainer.pokedex.seen_count)
|
||||
lefttext += _INTL("Difficulty<r>{1}<br>", getDifficulty())
|
||||
@sprites["messagebox"] = Window_AdvancedTextPokemon.new(lefttext)
|
||||
@sprites["messagebox"].viewport = @viewport
|
||||
@sprites["messagebox"].width = 192 if @sprites["messagebox"].width < 192
|
||||
@sprites["msgwindow"] = pbCreateMessageWindow(@viewport)
|
||||
pbMessageDisplay(@sprites["msgwindow"],
|
||||
_INTL("League champion!\nCongratulations!\\^"))
|
||||
end
|
||||
|
||||
def writePokemonData(pokemon, hallNumber = -1)
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
pokename = pokemon.name
|
||||
speciesname = pokemon.speciesName
|
||||
if pokemon.male?
|
||||
speciesname += "♂"
|
||||
elsif pokemon.female?
|
||||
speciesname += "♀"
|
||||
end
|
||||
pokename += "/" + speciesname
|
||||
pokename = _INTL("Egg") + "/" + _INTL("Egg") if pokemon.egg?
|
||||
idno = (pokemon.owner.name.empty? || pokemon.egg?) ? "?????" : sprintf("%05d", pokemon.owner.public_id)
|
||||
dexnumber = _INTL("No. ???")
|
||||
if !pokemon.egg?
|
||||
species_data = GameData::Species.get(pokemon.species)
|
||||
dexnumber = _ISPRINTF("No. {1:03d}", species_data.id_number)
|
||||
end
|
||||
textPositions = [
|
||||
[dexnumber, 32, Graphics.height - 86, 0, BASECOLOR, SHADOWCOLOR],
|
||||
[pokename, Graphics.width - 192, Graphics.height - 86, 2, BASECOLOR, SHADOWCOLOR],
|
||||
[_INTL("Lv. {1}", pokemon.egg? ? "?" : pokemon.level),
|
||||
64, Graphics.height - 54, 0, BASECOLOR, SHADOWCOLOR],
|
||||
[_INTL("IDNo.{1}", pokemon.egg? ? "?????" : idno),
|
||||
Graphics.width - 192, Graphics.height - 54, 2, BASECOLOR, SHADOWCOLOR]
|
||||
]
|
||||
if (hallNumber > -1)
|
||||
textPositions.push([_INTL("Hall of Fame No."), Graphics.width / 2 - 104, -6, 0, BASECOLOR, SHADOWCOLOR])
|
||||
textPositions.push([hallNumber.to_s, Graphics.width / 2 + 104, -6, 1, BASECOLOR, SHADOWCOLOR])
|
||||
end
|
||||
pbDrawTextPositions(overlay, textPositions)
|
||||
end
|
||||
|
||||
def writeWelcome
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
pbDrawTextPositions(overlay, [[_INTL("Welcome to the Hall of Fame!"),
|
||||
Graphics.width / 2, Graphics.height - 80, 2, BASECOLOR, SHADOWCOLOR]])
|
||||
|
||||
writeDate(overlay, 120, Graphics.height - 50)
|
||||
writeGameMode(overlay, (Graphics.width / 2) + 100, Graphics.height - 50)
|
||||
end
|
||||
|
||||
def writeWelcomePC
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
pbDrawTextPositions(overlay, [[_INTL("Entered the Hall of Fame!"),
|
||||
Graphics.width / 2, Graphics.height - 80, 2, BASECOLOR, SHADOWCOLOR]])
|
||||
|
||||
date = $PokemonGlobal.hallOfFame[@hallIndex][:DATE]
|
||||
mode = $PokemonGlobal.hallOfFame[@hallIndex][:MODE]
|
||||
difficulty = $PokemonGlobal.hallOfFame[@hallIndex][:DIFFICULTY]
|
||||
|
||||
writeDate(overlay, 120, Graphics.height - 50,date) if date
|
||||
writeGameMode(overlay, (Graphics.width / 2) + 100, Graphics.height - 50, mode, difficulty) if mode && difficulty
|
||||
end
|
||||
|
||||
def writeDate(overlay, x, y, timeString = nil)
|
||||
timeString = getCurrentDate() if !timeString
|
||||
pbDrawTextPositions(overlay, [[_INTL("{1}", timeString), x, y, 2, BASECOLOR, SHADOWCOLOR]])
|
||||
end
|
||||
|
||||
def getCurrentDate()
|
||||
currentTime = Time.new
|
||||
return currentTime.year.to_s + "-" + ("%02d" % currentTime.month) + "-" + ("%02d" % currentTime.day)
|
||||
end
|
||||
|
||||
def getCurrentGameMode()
|
||||
gameMode = "Classic mode"
|
||||
if $game_switches[SWITCH_MODERN_MODE]
|
||||
gameMode = "Remix mode"
|
||||
end
|
||||
if $game_switches[SWITCH_EXPERT_MODE]
|
||||
gameMode = "Expert mode"
|
||||
end
|
||||
if $game_switches[SWITCH_SINGLE_POKEMON_MODE]
|
||||
pokemon_number = pbGet(VAR_SINGLE_POKEMON_MODE)
|
||||
if pokemon_number.is_a?(Integer) && pokemon_number > 0
|
||||
pokemon = GameData::Species.get(pokemon_number)
|
||||
gameMode = pokemon.real_name + " mode"
|
||||
else
|
||||
gameMode = "Debug mode"
|
||||
end
|
||||
end
|
||||
if $game_switches[SWITCH_RANDOMIZED_AT_LEAST_ONCE]
|
||||
gameMode = "Randomized mode"
|
||||
end
|
||||
if $game_switches[ENABLED_DEBUG_MODE_AT_LEAST_ONCE] || $DEBUG
|
||||
gameMode = "Debug mode"
|
||||
end
|
||||
return gameMode
|
||||
end
|
||||
|
||||
def writeGameMode(overlay, x, y, gameMode = nil, difficulty = nil)
|
||||
gameMode = getCurrentGameMode() if !gameMode
|
||||
difficulty = getDifficulty() if !difficulty
|
||||
pbDrawTextPositions(overlay, [[_INTL("{1} ({2})", gameMode, difficulty), x, y, 2, BASECOLOR, SHADOWCOLOR]])
|
||||
end
|
||||
|
||||
def pbAnimationLoop
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
pbUpdateAnimation
|
||||
break if @battlerIndex == @hallEntry.size + 2
|
||||
end
|
||||
end
|
||||
|
||||
def pbPCSelection
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
continueScene = true
|
||||
break if Input.trigger?(Input::BACK) # Exits
|
||||
if Input.trigger?(Input::USE) # Moves the selection one entry backward
|
||||
@battlerIndex += 10
|
||||
continueScene = pbUpdatePC
|
||||
end
|
||||
if Input.trigger?(Input::LEFT) # Moves the selection one pokémon forward
|
||||
@battlerIndex -= 1
|
||||
continueScene = pbUpdatePC
|
||||
end
|
||||
if Input.trigger?(Input::RIGHT) # Moves the selection one pokémon backward
|
||||
@battlerIndex += 1
|
||||
continueScene = pbUpdatePC
|
||||
end
|
||||
break if !continueScene
|
||||
end
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbUpdateAnimation
|
||||
if @battlerIndex <= @hallEntry.size
|
||||
if @xmovement[@battlerIndex] != 0 || @ymovement[@battlerIndex] != 0
|
||||
spriteIndex = (@battlerIndex < @hallEntry.size) ? @battlerIndex : -1
|
||||
moveSprite(spriteIndex)
|
||||
else
|
||||
@battlerIndex += 1
|
||||
if @battlerIndex <= @hallEntry.size
|
||||
# If it is a pokémon, write the pokémon text, wait the
|
||||
# ENTRYWAITTIME and goes to the next battler
|
||||
@hallEntry[@battlerIndex - 1].play_cry
|
||||
writePokemonData(@hallEntry[@battlerIndex - 1])
|
||||
(ENTRYWAITTIME * Graphics.frame_rate / 20).times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
end
|
||||
if @battlerIndex < @hallEntry.size # Preparates the next battler
|
||||
setPokemonSpritesOpacity(@battlerIndex, OPACITY)
|
||||
@sprites["overlay"].bitmap.clear
|
||||
else
|
||||
# Show the welcome message and preparates the trainer
|
||||
setPokemonSpritesOpacity(-1)
|
||||
writeWelcome
|
||||
createTrainerBattler
|
||||
(ENTRYWAITTIME * 2 * Graphics.frame_rate / 20).times do
|
||||
moveSprite(-1)
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
end
|
||||
|
||||
while !(waitForInput)
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
end
|
||||
setPokemonSpritesOpacity(-1, OPACITY) # if !@singlerow
|
||||
end
|
||||
end
|
||||
end
|
||||
elsif @battlerIndex > @hallEntry.size
|
||||
# Write the trainer data and fade
|
||||
writeTrainerData
|
||||
(ENTRYWAITTIME * Graphics.frame_rate / 20).times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
end
|
||||
fadeSpeed = ((Math.log(2 ** 12) - Math.log(FINALFADESPEED)) / Math.log(2)).floor
|
||||
pbBGMFade((2 ** fadeSpeed).to_f / 20) if @useMusic
|
||||
slowFadeOut(@sprites, fadeSpeed) { pbUpdate }
|
||||
@alreadyFadedInEnd = true
|
||||
@battlerIndex += 1
|
||||
end
|
||||
end
|
||||
|
||||
def waitForInput
|
||||
if Input.trigger?(Input::USE) || Input.trigger?(Input::BACK)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def pbUpdatePC
|
||||
# Change the team
|
||||
if @battlerIndex >= @hallEntry.size + 1
|
||||
@hallIndex -= 1
|
||||
return false if @hallIndex == -1
|
||||
@hallEntry = $PokemonGlobal.hallOfFame[@hallIndex][:TEAM]
|
||||
@battlerIndex = 0
|
||||
createBattlers(false)
|
||||
elsif @battlerIndex == @hallEntry.size
|
||||
for n in 0...@hallEntry.size
|
||||
@sprites["pokemon#{n}"].opacity = 255
|
||||
end
|
||||
echoln @hallEntry
|
||||
writeWelcomePC
|
||||
return true
|
||||
elsif @battlerIndex < 0
|
||||
@hallIndex += 1
|
||||
return false if @hallIndex >= $PokemonGlobal.hallOfFame.size
|
||||
@hallEntry = $PokemonGlobal.hallOfFame[@hallIndex][:TEAM]
|
||||
@battlerIndex = @hallEntry.size - 1
|
||||
createBattlers(false)
|
||||
end
|
||||
# Change the pokemon
|
||||
@hallEntry[@battlerIndex].play_cry
|
||||
setPokemonSpritesOpacity(@battlerIndex, OPACITY)
|
||||
hallNumber = $PokemonGlobal.hallOfFameLastNumber + @hallIndex -
|
||||
$PokemonGlobal.hallOfFame.size + 1
|
||||
writePokemonData(@hallEntry[@battlerIndex], hallNumber)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class HallOfFameScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreenEntry
|
||||
@scene.pbStartSceneEntry
|
||||
@scene.pbAnimationLoop
|
||||
@scene.pbEndScene
|
||||
end
|
||||
|
||||
def pbStartScreenPC
|
||||
@scene.pbStartScenePC
|
||||
@scene.pbPCSelection
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class HallOfFamePC
|
||||
def shouldShow?
|
||||
return $PokemonGlobal.hallOfFameLastNumber > 0
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("Hall of Fame")
|
||||
end
|
||||
|
||||
def access
|
||||
pbMessage(_INTL("\\se[PC access]Accessed the Hall of Fame."))
|
||||
pbHallOfFamePC
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
PokemonPCList.registerPC(HallOfFamePC.new)
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonGlobalMetadata
|
||||
attr_writer :hallOfFame
|
||||
# Number necessary if hallOfFame array reach in its size limit
|
||||
attr_writer :hallOfFameLastNumber
|
||||
|
||||
#
|
||||
# [{:TEAM:[], :DATE:string, :MODE:string, :DIFFICULTY:string}]
|
||||
#
|
||||
def hallOfFame
|
||||
@hallOfFame = [] if !@hallOfFame
|
||||
if @hallOfFame.size > 0 && @hallOfFame[0].is_a?(Array)
|
||||
echoln "converting hall of fame"
|
||||
convertedHallOfFame = []
|
||||
@hallOfFame.each do |team|
|
||||
hallOfFame = {}
|
||||
hallOfFame[:TEAM] = team
|
||||
hallOfFame[:DATE] = nil
|
||||
hallOfFame[:MODE] = nil
|
||||
hallOfFame[:DIFFICULTY] = nil
|
||||
|
||||
hallOfFame[:TRAINER_HAT] = nil
|
||||
hallOfFame[:TRAINER_HAT_COLOR] = nil
|
||||
hallOfFame[:TRAINER_HAIR] = nil
|
||||
hallOfFame[:TRAINER_HAIR_COLOR] = nil
|
||||
hallOfFame[:TRAINER_CLOTHES] = nil
|
||||
hallOfFame[:TRAINER_CLOTHES_COLOR] = nil
|
||||
hallOfFame[:TRAINER_SKIN] = nil
|
||||
|
||||
convertedHallOfFame << hallOfFame
|
||||
end
|
||||
@hallOfFame = convertedHallOfFame
|
||||
echoln @hallOfFame
|
||||
end
|
||||
return @hallOfFame
|
||||
# @hallOfFame = [] if !@hallOfFame
|
||||
# return @hallOfFame
|
||||
end
|
||||
|
||||
def hallOfFameLastNumber
|
||||
return @hallOfFameLastNumber || 0
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbHallOfFameEntry
|
||||
scene = HallOfFame_Scene.new
|
||||
screen = HallOfFameScreen.new(scene)
|
||||
screen.pbStartScreenEntry
|
||||
end
|
||||
|
||||
def pbHallOfFamePC
|
||||
scene = HallOfFame_Scene.new
|
||||
screen = HallOfFameScreen.new(scene)
|
||||
screen.pbStartScreenPC
|
||||
end
|
||||
@@ -1,374 +0,0 @@
|
||||
#==============================================================================
|
||||
# * Scene_Credits
|
||||
#------------------------------------------------------------------------------
|
||||
# Scrolls the credits you make below. Original Author unknown.
|
||||
#
|
||||
## Edited by MiDas Mike so it doesn't play over the Title, but runs by calling
|
||||
# the following:
|
||||
# $scene = Scene_Credits.new
|
||||
#
|
||||
## New Edit 3/6/2007 11:14 PM by AvatarMonkeyKirby.
|
||||
# Ok, what I've done is changed the part of the script that was supposed to make
|
||||
# the credits automatically end so that way they actually end! Yes, they will
|
||||
# actually end when the credits are finished! So, that will make the people you
|
||||
# should give credit to now is: Unknown, MiDas Mike, and AvatarMonkeyKirby.
|
||||
# -sincerly yours,
|
||||
# Your Beloved
|
||||
# Oh yea, and I also added a line of code that fades out the BGM so it fades
|
||||
# sooner and smoother.
|
||||
#
|
||||
## New Edit 24/1/2012 by Maruno.
|
||||
# Added the ability to split a line into two halves with <s>, with each half
|
||||
# aligned towards the centre. Please also credit me if used.
|
||||
#
|
||||
## New Edit 22/2/2012 by Maruno.
|
||||
# Credits now scroll properly when played with a zoom factor of 0.5. Music can
|
||||
# now be defined. Credits can't be skipped during their first play.
|
||||
#
|
||||
## New Edit 25/3/2020 by Maruno.
|
||||
# Scroll speed is now independent of frame rate. Now supports non-integer values
|
||||
# for SCROLL_SPEED.
|
||||
#
|
||||
## New Edit 21/8/2020 by Marin.
|
||||
# Now automatically inserts the credits from the plugins that have been
|
||||
# registered through the PluginManager module.
|
||||
#==============================================================================
|
||||
class Scene_Credits
|
||||
# Backgrounds to show in credits. Found in Graphics/Titles/ folder
|
||||
BACKGROUNDS_LIST = ["credits1", "credits2", "credits3", "credits4", "credits5"]
|
||||
BGM = "Credits"
|
||||
SCROLL_SPEED = 62 # Pixels per second , ajuster pour fitter avec la musique
|
||||
SECONDS_PER_BACKGROUND = 4
|
||||
TEXT_OUTLINE_COLOR = Color.new(0, 0, 128, 255)
|
||||
TEXT_BASE_COLOR = Color.new(255, 255, 255, 255)
|
||||
TEXT_SHADOW_COLOR = Color.new(0, 0, 0, 100)
|
||||
NB_SPRITES_TO_PRELOAD = 30
|
||||
|
||||
TOTAL_NB_FRAMES = 4000 #set manually, depends on music length
|
||||
|
||||
FUSION_SPRITES_MAX_OPACITY=200
|
||||
NB_FRAMES_AT_MAX_OPACITY=30
|
||||
|
||||
# This next piece of code is the credits.
|
||||
# Start Editing
|
||||
CREDIT = <<_END_
|
||||
|
||||
Pokémon Infinite Fusion
|
||||
By Chardub (Frogzilla)
|
||||
|
||||
Programming / Game design:
|
||||
Chardub
|
||||
|
||||
Fused Pokemon Sprites :
|
||||
Japeal - Pokefusion 2
|
||||
http://japeal.com/pkm
|
||||
|
||||
Special thanks to Aegide and Reizod for
|
||||
helping to download the autogenerated sprites
|
||||
and to the owners of Japeal for accepting to
|
||||
share their sprites.
|
||||
|
||||
Maps:
|
||||
Chardub
|
||||
Kiwikelly
|
||||
Some of the maps were based on work by:
|
||||
BenGames, Zeak6464
|
||||
|
||||
Gameplay / Story :
|
||||
Chardub
|
||||
Kiwikelly
|
||||
|
||||
Custom sprites collecting and handling
|
||||
Kiwikelly, Payapon, Thornsoflight
|
||||
|
||||
Discord custom sprites coordination
|
||||
avianAnnihilator<s>Blaquaza
|
||||
BéBoutton<s>CaBiNE
|
||||
CoramSun<s>hero.drawing
|
||||
Howls<s>Ignus
|
||||
Kiwi<s>Maelmc
|
||||
Milchik the Miltank<s>Payapon
|
||||
Pix<s>Rosemagwin
|
||||
Thornsoflight
|
||||
|
||||
All of the custom fused Pokémon sprites
|
||||
were made by various members of the
|
||||
Pokémon Infinite Fusion Discord
|
||||
|
||||
Including significant contributions from:
|
||||
|
||||
{SPRITER_CREDITS}
|
||||
|
||||
Other custom graphics:
|
||||
Kiwikelly<s>Knuckles
|
||||
UnworthyPie<s>Doctor Miawoo
|
||||
Chardub<s>TCGrunler#4583
|
||||
|
||||
The following free ressources were also used
|
||||
with their respective authors' consent:
|
||||
|
||||
Public use tileset graphics:
|
||||
Alucus BoOmxBiG<s>chimcharsfireworkd
|
||||
EpicDay<s>EternalTakai
|
||||
Gallanty Heavy-Metal-Lover<s>Hek-el-grande
|
||||
DirtyWiggles<s>iametrine
|
||||
Jorginho<s>kizemaru-kurunosuke
|
||||
KKKaito<s>kyle-dove
|
||||
Minorthreat0987<s>Phyromatical
|
||||
Pokemon-Diamond<s>rayd12smitty
|
||||
Rossay<s>Shiney570
|
||||
Spacemotion<s>Speedialga
|
||||
ThatsSoWitty Thurpok<s>TyranitarDark
|
||||
UltimoSpriter<s>WesleyFG
|
||||
|
||||
Public use music:
|
||||
Pokeli, TailDoll666100
|
||||
Kazune Sawatari, sentsinkantéun,
|
||||
Nanashima, CharizardTheMaster, The Zame Jack
|
||||
|
||||
{INSERTS_PLUGIN_CREDITS_DO_NOT_REMOVE}
|
||||
|
||||
"Pokémon Essentials" was created by:
|
||||
Flameguru
|
||||
Poccil (Peter O.)
|
||||
Maruno
|
||||
|
||||
With contributions from:
|
||||
AvatarMonkeyKirby<s>MiDas Mike
|
||||
Boushy<s>Near Fantastica
|
||||
Brother1440<s>PinkMan
|
||||
FL.<s>Popper
|
||||
Genzai Kawakami<s>Rataime
|
||||
Harshboy<s>SoundSpawn
|
||||
help-14<s>the__end
|
||||
IceGod64<s>Venom12
|
||||
Jacob O. Wobbrock<s>Wachunga
|
||||
KitsuneKouta<s>xLeD
|
||||
Lisa Anthony<s>
|
||||
and everyone else who helped out
|
||||
|
||||
"mkxp-z" by:
|
||||
Roza
|
||||
Based on MKXP by Ancurio et al.
|
||||
|
||||
"RPG Maker XP" by:
|
||||
Enterbrain
|
||||
|
||||
This game was inspired by the original
|
||||
fusion generator:
|
||||
alexonsager.alexonsager.net
|
||||
|
||||
All generated fusion sprites in this game
|
||||
come from the Pokémon Fusion Generator:
|
||||
https://japeal.com/pkm/
|
||||
|
||||
Pokémon is owned by:
|
||||
The Pokémon Company
|
||||
Nintendo
|
||||
Affiliated with Game Freak
|
||||
|
||||
This is a non-profit fan-made game.
|
||||
No copyright infringements intended.
|
||||
_END_
|
||||
# Stop Editing
|
||||
|
||||
def main
|
||||
endCredits() if $PokemonSystem.on_mobile
|
||||
#-------------------------------
|
||||
# Animated Background Setup
|
||||
#-------------------------------
|
||||
@counter = 0.0 # Counts time elapsed since the background image changed
|
||||
@bg_index = 0
|
||||
@bitmap_height = Graphics.height # For a single credits text bitmap
|
||||
@trim = Graphics.height / 10
|
||||
# Number of game frames per background frame
|
||||
@realOY = -(Graphics.height - @trim)
|
||||
@customSpritesList = getSpritesList()
|
||||
#-------------------------------
|
||||
# Credits text Setup
|
||||
#-------------------------------
|
||||
plugin_credits = ""
|
||||
PluginManager.plugins.each do |plugin|
|
||||
pcred = PluginManager.credits(plugin)
|
||||
plugin_credits << "\"#{plugin}\" v.#{PluginManager.version(plugin)} by:\n"
|
||||
if pcred.size >= 5
|
||||
plugin_credits << pcred[0] + "\n"
|
||||
i = 1
|
||||
until i >= pcred.size
|
||||
plugin_credits << pcred[i] + "<s>" + (pcred[i + 1] || "") + "\n"
|
||||
i += 2
|
||||
end
|
||||
else
|
||||
pcred.each { |name| plugin_credits << name + "\n" }
|
||||
end
|
||||
plugin_credits << "\n"
|
||||
end
|
||||
CREDIT.gsub!(/\{INSERTS_PLUGIN_CREDITS_DO_NOT_REMOVE\}/, plugin_credits)
|
||||
CREDIT.gsub!(/{SPRITER_CREDITS}/, format_names_for_game_credits())
|
||||
|
||||
credit_lines = CREDIT.split(/\n/)
|
||||
|
||||
#-------------------------------
|
||||
# Make background and text sprites
|
||||
#-------------------------------
|
||||
viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
viewport.z = 99999
|
||||
text_viewport = Viewport.new(0, @trim, Graphics.width, Graphics.height - (@trim * 2))
|
||||
text_viewport.z = 99999
|
||||
@background_sprite = IconSprite.new(0, 0)
|
||||
@background_sprite.setBitmap("Graphics/Titles/" + BACKGROUNDS_LIST[0])
|
||||
@credit_sprites = []
|
||||
@total_height = credit_lines.size * 32
|
||||
lines_per_bitmap = @bitmap_height / 32
|
||||
num_bitmaps = (credit_lines.size.to_f / lines_per_bitmap).ceil
|
||||
for i in 0...num_bitmaps
|
||||
credit_bitmap = Bitmap.new(Graphics.width, @bitmap_height)
|
||||
pbSetSystemFont(credit_bitmap)
|
||||
for j in 0...lines_per_bitmap
|
||||
line = credit_lines[i * lines_per_bitmap + j]
|
||||
next if !line
|
||||
line = line.split("<s>")
|
||||
xpos = 0
|
||||
align = 1 # Centre align
|
||||
linewidth = Graphics.width
|
||||
for k in 0...line.length
|
||||
if line.length > 1
|
||||
xpos = (k == 0) ? 0 : 20 + Graphics.width / 2
|
||||
align = (k == 0) ? 2 : 0 # Right align : left align
|
||||
linewidth = Graphics.width / 2 - 20
|
||||
end
|
||||
credit_bitmap.font.color = TEXT_SHADOW_COLOR
|
||||
credit_bitmap.draw_text(xpos, j * 32 + 8, linewidth, 32, line[k], align)
|
||||
credit_bitmap.font.color = TEXT_OUTLINE_COLOR
|
||||
credit_bitmap.draw_text(xpos + 2, j * 32 - 2, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos, j * 32 - 2, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos - 2, j * 32 - 2, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos + 2, j * 32, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos - 2, j * 32, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos + 2, j * 32 + 2, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos, j * 32 + 2, linewidth, 32, line[k], align)
|
||||
credit_bitmap.draw_text(xpos - 2, j * 32 + 2, linewidth, 32, line[k], align)
|
||||
credit_bitmap.font.color = TEXT_BASE_COLOR
|
||||
credit_bitmap.draw_text(xpos, j * 32, linewidth, 32, line[k], align)
|
||||
end
|
||||
end
|
||||
credit_sprite = Sprite.new(text_viewport)
|
||||
credit_sprite.bitmap = credit_bitmap
|
||||
credit_sprite.z = 9998
|
||||
credit_sprite.oy = @realOY - @bitmap_height * i
|
||||
@credit_sprites[i] = credit_sprite
|
||||
end
|
||||
#-------------------------------
|
||||
# Setup
|
||||
#-------------------------------
|
||||
# Stops all audio but background music
|
||||
previousBGM = $game_system.getPlayingBGM
|
||||
pbMEStop
|
||||
pbBGSStop
|
||||
pbSEStop
|
||||
pbBGMFade(2.0)
|
||||
pbBGMPlay(BGM)
|
||||
Graphics.transition(20)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
update
|
||||
break if $scene != self
|
||||
end
|
||||
pbBGMFade(2.0)
|
||||
Graphics.freeze
|
||||
viewport.color = Color.new(0, 0, 0, 255) # Ensure screen is black
|
||||
Graphics.transition(20, "fadetoblack")
|
||||
@background_sprite.dispose
|
||||
@credit_sprites.each { |s| s.dispose if s }
|
||||
text_viewport.dispose
|
||||
viewport.dispose
|
||||
$PokemonGlobal.creditsPlayed = true
|
||||
pbBGMPlay(previousBGM)
|
||||
end
|
||||
|
||||
def getSpritesList()
|
||||
spritesList = []
|
||||
$PokemonGlobal.alt_sprite_substitutions.each_value do |value|
|
||||
if value.is_a?(PIFSprite)
|
||||
spritesList << value
|
||||
end
|
||||
end
|
||||
selected_spritesList = spritesList.sample(NB_SPRITES_TO_PRELOAD)
|
||||
spriteLoader = BattleSpriteLoader.new
|
||||
for sprite in selected_spritesList
|
||||
spriteLoader.preload(sprite)
|
||||
end
|
||||
|
||||
return selected_spritesList
|
||||
end
|
||||
|
||||
# Check if the credits should be cancelled
|
||||
def cancel?
|
||||
if Input.trigger?(Input::USE) && $PokemonGlobal.creditsPlayed
|
||||
endCredits
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def endCredits
|
||||
$scene = Scene_Map.new
|
||||
pbBGMFade(1.0)
|
||||
end
|
||||
|
||||
# Checks if credits bitmap has reached its ending point
|
||||
def last?
|
||||
if @realOY > @total_height + @trim
|
||||
$scene = ($game_map) ? Scene_Map.new : nil
|
||||
pbBGMFade(2.0)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def update
|
||||
delta = Graphics.delta_s
|
||||
@counter += delta
|
||||
@sprites_counter = 0 if !@sprites_counter
|
||||
#@background_sprite.setBitmap("Graphics/Titles/" + BACKGROUNDS_LIST[@bg_index])
|
||||
# # Go to next slide
|
||||
@frames_counter = 0 if !@frames_counter
|
||||
@frames_counter+=1
|
||||
|
||||
stopShowingSprites = @frames_counter >= (TOTAL_NB_FRAMES-300)
|
||||
pbBGSStop if @frames_counter > TOTAL_NB_FRAMES
|
||||
|
||||
spriteLoader = BattleSpriteLoader.new
|
||||
if @counter >= SECONDS_PER_BACKGROUND && @customSpritesList.length > 0 && !stopShowingSprites
|
||||
@sprites_counter=0
|
||||
randomSprite = @customSpritesList.sample
|
||||
@customSpritesList.delete(randomSprite)
|
||||
@background_sprite.setBitmapDirectly(spriteLoader.load_pif_sprite(randomSprite))
|
||||
@background_sprite.x = rand(0..300)
|
||||
@background_sprite.y = rand(0..200)
|
||||
@counter -= SECONDS_PER_BACKGROUND
|
||||
@background_sprite.opacity = 50
|
||||
@fadingIn=true
|
||||
end
|
||||
if @fadingIn
|
||||
if @background_sprite.opacity < FUSION_SPRITES_MAX_OPACITY
|
||||
@background_sprite.opacity +=5
|
||||
else
|
||||
@fadingIn=false
|
||||
end
|
||||
|
||||
else
|
||||
@sprites_counter += 1
|
||||
if @sprites_counter >= NB_FRAMES_AT_MAX_OPACITY
|
||||
@background_sprite.opacity-=3
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return if cancel?
|
||||
return if last?
|
||||
@realOY += SCROLL_SPEED * delta
|
||||
@credit_sprites.each_with_index { |s, i| s.oy = @realOY - @bitmap_height * i }
|
||||
end
|
||||
end
|
||||
@@ -1,289 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPauseMenu_Scene
|
||||
def pbStartScene
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["cmdwindow"] = Window_CommandPokemon.new([])
|
||||
@sprites["cmdwindow"].visible = false
|
||||
@sprites["cmdwindow"].viewport = @viewport
|
||||
@sprites["infowindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 32, 32, @viewport)
|
||||
@sprites["infowindow"].visible = false
|
||||
@sprites["helpwindow"] = Window_UnformattedTextPokemon.newWithSize("", 0, 0, 32, 32, @viewport)
|
||||
@sprites["helpwindow"].visible = false
|
||||
@infostate = false
|
||||
@helpstate = false
|
||||
pbSEPlay("GUI menu open")
|
||||
end
|
||||
|
||||
def pbShowInfo(text)
|
||||
@sprites["infowindow"].resizeToFit(text, Graphics.height)
|
||||
@sprites["infowindow"].text = text
|
||||
@sprites["infowindow"].visible = true
|
||||
@infostate = true
|
||||
end
|
||||
|
||||
def pbShowHelp(text)
|
||||
@sprites["helpwindow"].resizeToFit(text, Graphics.height)
|
||||
@sprites["helpwindow"].text = text
|
||||
@sprites["helpwindow"].visible = true
|
||||
pbBottomLeft(@sprites["helpwindow"])
|
||||
@helpstate = true
|
||||
end
|
||||
|
||||
def pbShowMenu
|
||||
@sprites["cmdwindow"].visible = true
|
||||
@sprites["infowindow"].visible = @infostate
|
||||
@sprites["helpwindow"].visible = @helpstate
|
||||
end
|
||||
|
||||
def pbHideMenu
|
||||
@sprites["cmdwindow"].visible = false
|
||||
@sprites["infowindow"].visible = false
|
||||
@sprites["helpwindow"].visible = false
|
||||
end
|
||||
|
||||
def pbShowCommands(commands)
|
||||
ret = -1
|
||||
cmdwindow = @sprites["cmdwindow"]
|
||||
cmdwindow.commands = commands
|
||||
cmdwindow.index = $PokemonTemp.menuLastChoice
|
||||
cmdwindow.resizeToFit(commands)
|
||||
cmdwindow.x = Graphics.width - cmdwindow.width
|
||||
cmdwindow.y = 0
|
||||
cmdwindow.visible = true
|
||||
loop do
|
||||
cmdwindow.update
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
if Input.trigger?(Input::BACK)
|
||||
ret = -1
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
ret = cmdwindow.index
|
||||
$PokemonTemp.menuLastChoice = ret
|
||||
break
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbRefresh; end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPauseMenu
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbShowMenu
|
||||
@scene.pbRefresh
|
||||
@scene.pbShowMenu
|
||||
end
|
||||
|
||||
def pbStartPokemonMenu
|
||||
if !$Trainer
|
||||
if $DEBUG
|
||||
pbMessage(_INTL("The player trainer was not defined, so the pause menu can't be displayed."))
|
||||
pbMessage(_INTL("Please see the documentation to learn how to set up the trainer player."))
|
||||
end
|
||||
return
|
||||
end
|
||||
@scene.pbStartScene
|
||||
endscene = true
|
||||
commands = []
|
||||
cmdPokedex = -1
|
||||
cmdPokemon = -1
|
||||
cmdBag = -1
|
||||
cmdTrainer = -1
|
||||
cmdSave = -1
|
||||
cmdOption = -1
|
||||
cmdPokegear = -1
|
||||
cmdDebug = -1
|
||||
cmdQuit = -1
|
||||
cmdEndGame = -1
|
||||
if $Trainer.has_pokedex && $Trainer.pokedex.accessible_dexes.length > 0
|
||||
commands[cmdPokedex = commands.length] = _INTL("Pokédex")
|
||||
end
|
||||
commands[cmdPokemon = commands.length] = _INTL("Pokémon") if $Trainer.party_count > 0
|
||||
commands[cmdBag = commands.length] = _INTL("Bag") if !pbInBugContest?
|
||||
commands[cmdPokegear = commands.length] = _INTL("Pokégear") if $Trainer.has_pokegear
|
||||
commands[cmdTrainer = commands.length] = $Trainer.name
|
||||
commands[cmdOutfit = commands.length] = _INTL("Outfit") if $Trainer.can_change_outfit
|
||||
if pbInSafari?
|
||||
if Settings::SAFARI_STEPS <= 0
|
||||
@scene.pbShowInfo(_INTL("Balls: {1}", pbSafariState.ballcount))
|
||||
else
|
||||
@scene.pbShowInfo(_INTL("Steps: {1}/{2}\nBalls: {3}",
|
||||
pbSafariState.steps, Settings::SAFARI_STEPS, pbSafariState.ballcount))
|
||||
end
|
||||
commands[cmdQuit = commands.length] = _INTL("Quit")
|
||||
elsif pbInBugContest?
|
||||
if pbBugContestState.lastPokemon
|
||||
@scene.pbShowInfo(_INTL("Caught: {1}\nLevel: {2}\nBalls: {3}",
|
||||
pbBugContestState.lastPokemon.speciesName,
|
||||
pbBugContestState.lastPokemon.level,
|
||||
pbBugContestState.ballcount))
|
||||
else
|
||||
@scene.pbShowInfo(_INTL("Caught: None\nBalls: {1}", pbBugContestState.ballcount))
|
||||
end
|
||||
commands[cmdQuit = commands.length] = _INTL("Quit Contest")
|
||||
else
|
||||
commands[cmdSave = commands.length] = _INTL("Save") if $game_system && !$game_system.save_disabled
|
||||
end
|
||||
commands[cmdOption = commands.length] = _INTL("Options")
|
||||
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
|
||||
commands[cmdEndGame = commands.length] = _INTL("Title screen")
|
||||
loop do
|
||||
command = @scene.pbShowCommands(commands)
|
||||
if cmdPokedex >= 0 && command == cmdPokedex
|
||||
pbPlayDecisionSE
|
||||
if Settings::USE_CURRENT_REGION_DEX
|
||||
pbFadeOutIn {
|
||||
scene = PokemonPokedex_Scene.new
|
||||
screen = PokemonPokedexScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
@scene.pbRefresh
|
||||
}
|
||||
else
|
||||
#if $Trainer.pokedex.accessible_dexes.length == 1
|
||||
$PokemonGlobal.pokedexDex = $Trainer.pokedex.accessible_dexes[0]
|
||||
# pbFadeOutIn {
|
||||
# scene = PokemonPokedex_Scene.new
|
||||
# screen = PokemonPokedexScreen.new(scene)
|
||||
# screen.pbStartScreen
|
||||
# @scene.pbRefresh
|
||||
# }
|
||||
# else
|
||||
pbFadeOutIn {
|
||||
scene = PokemonPokedexMenu_Scene.new
|
||||
screen = PokemonPokedexMenuScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
@scene.pbRefresh
|
||||
}
|
||||
# end
|
||||
end
|
||||
elsif cmdPokemon >= 0 && command == cmdPokemon
|
||||
pbPlayDecisionSE
|
||||
hiddenmove = nil
|
||||
pbFadeOutIn {
|
||||
sscene = PokemonParty_Scene.new
|
||||
sscreen = PokemonPartyScreen.new(sscene, $Trainer.party)
|
||||
hiddenmove = sscreen.pbPokemonScreen
|
||||
(hiddenmove) ? @scene.pbEndScene : @scene.pbRefresh
|
||||
}
|
||||
if hiddenmove
|
||||
$game_temp.in_menu = false
|
||||
pbUseHiddenMove(hiddenmove[0], hiddenmove[1])
|
||||
return
|
||||
end
|
||||
elsif cmdBag >= 0 && command == cmdBag
|
||||
pbPlayDecisionSE
|
||||
item = nil
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene, $PokemonBag)
|
||||
item = screen.pbStartScreen
|
||||
(item) ? @scene.pbEndScene : @scene.pbRefresh
|
||||
}
|
||||
if item
|
||||
$game_temp.in_menu = false
|
||||
pbUseKeyItemInField(item)
|
||||
return
|
||||
end
|
||||
elsif cmdPokegear >= 0 && command == cmdPokegear
|
||||
pbPlayDecisionSE
|
||||
pbFadeOutIn {
|
||||
scene = PokemonPokegear_Scene.new
|
||||
screen = PokemonPokegearScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
@scene.pbRefresh
|
||||
}
|
||||
elsif cmdTrainer >= 0 && command == cmdTrainer
|
||||
pbPlayDecisionSE
|
||||
pbFadeOutIn {
|
||||
scene = PokemonTrainerCard_Scene.new
|
||||
screen = PokemonTrainerCardScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
@scene.pbRefresh
|
||||
}
|
||||
elsif cmdOutfit && cmdOutfit >= 0 && command == cmdOutfit
|
||||
@scene.pbHideMenu
|
||||
pbCommonEvent(COMMON_EVENT_OUTFIT)
|
||||
|
||||
elsif cmdQuit >= 0 && command == cmdQuit
|
||||
@scene.pbHideMenu
|
||||
if pbInSafari?
|
||||
if pbConfirmMessage(_INTL("Would you like to leave the Safari Game right now?"))
|
||||
@scene.pbEndScene
|
||||
pbSafariState.decision = 1
|
||||
pbSafariState.pbGoToStart
|
||||
return
|
||||
else
|
||||
pbShowMenu
|
||||
end
|
||||
else
|
||||
if pbConfirmMessage(_INTL("Would you like to end the Contest now?"))
|
||||
@scene.pbEndScene
|
||||
pbBugContestState.pbStartJudging
|
||||
return
|
||||
else
|
||||
pbShowMenu
|
||||
end
|
||||
end
|
||||
elsif cmdSave >= 0 && command == cmdSave
|
||||
@scene.pbHideMenu
|
||||
scene = PokemonSave_Scene.new
|
||||
screen = PokemonSaveScreen.new(scene)
|
||||
if screen.pbSaveScreen
|
||||
@scene.pbEndScene
|
||||
endscene = false
|
||||
break
|
||||
else
|
||||
pbShowMenu
|
||||
end
|
||||
elsif cmdOption >= 0 && command == cmdOption
|
||||
pbPlayDecisionSE
|
||||
pbFadeOutIn {
|
||||
scene = PokemonGameOption_Scene.new
|
||||
screen = PokemonOptionScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
pbUpdateSceneMap
|
||||
@scene.pbRefresh
|
||||
}
|
||||
elsif cmdDebug >= 0 && command == cmdDebug
|
||||
pbPlayDecisionSE
|
||||
pbFadeOutIn {
|
||||
pbDebugMenu
|
||||
@scene.pbRefresh
|
||||
}
|
||||
elsif cmdEndGame >= 0 && command == cmdEndGame
|
||||
@scene.pbHideMenu
|
||||
if pbConfirmMessage(_INTL("Are you sure you want to quit the game and return to the main menu?"))
|
||||
scene = PokemonSave_Scene.new
|
||||
screen = PokemonSaveScreen.new(scene)
|
||||
screen.pbSaveScreen
|
||||
$game_temp.to_title = true
|
||||
return
|
||||
else
|
||||
pbShowMenu
|
||||
end
|
||||
else
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene if endscene
|
||||
end
|
||||
end
|
||||
@@ -1,127 +0,0 @@
|
||||
#===============================================================================
|
||||
# Pokédex Regional Dexes list menu screen
|
||||
# * For choosing which region list to view. Only appears when there is more
|
||||
# than one accessible region list to choose from, and if
|
||||
# Settings::USE_CURRENT_REGION_DEX is false.
|
||||
#===============================================================================
|
||||
class Window_DexesList < Window_CommandPokemon
|
||||
def initialize(commands,commands2,width)
|
||||
@commands2 = commands2
|
||||
super(commands,width)
|
||||
@selarrow = AnimatedBitmap.new("Graphics/Pictures/selarrow_white")
|
||||
self.baseColor = Color.new(248,248,248)
|
||||
self.shadowColor = Color.new(0,0,0)
|
||||
self.windowskin = nil
|
||||
end
|
||||
|
||||
def drawItem(index,count,rect)
|
||||
super(index,count,rect)
|
||||
if index>=0 && index<@commands2.length
|
||||
pbDrawShadowText(self.contents,rect.x+254,rect.y,64,rect.height,
|
||||
sprintf("%d",@commands2[index][0]),self.baseColor,self.shadowColor,1)
|
||||
pbDrawShadowText(self.contents,rect.x+350,rect.y,64,rect.height,
|
||||
sprintf("%d",@commands2[index][1]),self.baseColor,self.shadowColor,1)
|
||||
allseen = (@commands2[index][0]>=@commands2[index][2])
|
||||
allown = (@commands2[index][1]>=@commands2[index][2])
|
||||
pbDrawImagePositions(self.contents,[
|
||||
["Graphics/Pictures/Pokedex/icon_menuseenown",rect.x+236,rect.y+2,(allseen) ? 24 : 0,0,24,24],
|
||||
["Graphics/Pictures/Pokedex/icon_menuseenown",rect.x+332,rect.y+2,(allown) ? 24 : 0,24,24,24]
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPokedexMenu_Scene
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbStartScene(commands,commands2)
|
||||
@commands = commands
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_menu"))
|
||||
@sprites["headings"]=Window_AdvancedTextPokemon.newWithSize(
|
||||
_INTL("<c3=F8F8F8,C02028>SEEN<r>OBTAINED</c3>"),286,136,208,64,@viewport)
|
||||
@sprites["headings"].windowskin = nil
|
||||
@sprites["commands"] = Window_DexesList.new(commands,commands2,Graphics.width-84)
|
||||
@sprites["commands"].x = 40
|
||||
@sprites["commands"].y = 192
|
||||
@sprites["commands"].height = 192
|
||||
@sprites["commands"].viewport = @viewport
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbScene
|
||||
ret = -1
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
ret = @sprites["commands"].index
|
||||
(ret==@commands.length-1) ? pbPlayCloseMenuSE : pbPlayDecisionSE
|
||||
break
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPokedexMenuScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
commands = []
|
||||
commands2 = []
|
||||
dexnames = Settings.pokedex_names
|
||||
$Trainer.pokedex.accessible_dexes.each do |dex|
|
||||
if dexnames[dex].nil?
|
||||
commands.push(_INTL("Full Pokédex"))
|
||||
elsif dexnames[dex].is_a?(Array)
|
||||
commands.push(dexnames[dex][0])
|
||||
else
|
||||
commands.push(dexnames[dex])
|
||||
end
|
||||
commands2.push([$Trainer.pokedex.seen_count(dex),
|
||||
$Trainer.pokedex.owned_count(dex),
|
||||
pbGetRegionalDexLength(dex)])
|
||||
end
|
||||
|
||||
commands.push(_INTL("Owned Pokémon"))
|
||||
|
||||
commands.push(_INTL("Exit"))
|
||||
@scene.pbStartScene(commands,commands2)
|
||||
loop do
|
||||
cmd = @scene.pbScene
|
||||
break if cmd<0 || cmd>1 # Cancel/Exit
|
||||
$PokemonGlobal.pokedexDex = $Trainer.pokedex.accessible_dexes[0]
|
||||
only_owned = cmd == 1
|
||||
pbFadeOutIn {
|
||||
scene = PokemonPokedex_Scene.new
|
||||
screen = PokemonPokedexScreen.new(scene)
|
||||
screen.pbStartScreen(only_owned)
|
||||
}
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,825 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPokedexInfo_Scene
|
||||
def pbStartScene(dexlist, index, region)
|
||||
@endscene = false
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@dexlist = dexlist
|
||||
@index = index
|
||||
@region = region
|
||||
@page = 1
|
||||
@entry_page = 0
|
||||
@typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_types"))
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["infosprite"] = PokemonSprite.new(@viewport)
|
||||
@sprites["infosprite"].setOffset(PictureOrigin::Center)
|
||||
@sprites["infosprite"].x = 104
|
||||
@sprites["infosprite"].y = 136
|
||||
@sprites["infosprite"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["infosprite"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@spritesLoader = BattleSpriteLoader.new
|
||||
@randomEntryText = nil
|
||||
# @mapdata = pbLoadTownMapData
|
||||
# map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
# mappos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
# if @region < 0 # Use player's current region
|
||||
# @region = (mappos) ? mappos[0] : 0 # Region 0 default
|
||||
# end
|
||||
# @sprites["areamap"] = IconSprite.new(0,0,@viewport)
|
||||
# @sprites["areamap"].setBitmap("Graphics/Pictures/#{@mapdata[@region][1]}")
|
||||
# @sprites["areamap"].x += (Graphics.width-@sprites["areamap"].bitmap.width)/2
|
||||
# @sprites["areamap"].y += (Graphics.height+32-@sprites["areamap"].bitmap.height)/2
|
||||
# for hidden in Settings::REGION_MAP_EXTRAS
|
||||
# if hidden[0]==@region && hidden[1]>0 && $game_switches[hidden[1]]
|
||||
# pbDrawImagePositions(@sprites["areamap"].bitmap,[
|
||||
# ["Graphics/Pictures/#{hidden[4]}",
|
||||
# hidden[2]*PokemonRegionMap_Scene::SQUAREWIDTH,
|
||||
# hidden[3]*PokemonRegionMap_Scene::SQUAREHEIGHT]
|
||||
# ])
|
||||
# end
|
||||
# end
|
||||
# @sprites["areahighlight"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
# @sprites["areaoverlay"] = IconSprite.new(0,0,@viewport)
|
||||
# @sprites["areaoverlay"].setBitmap("Graphics/Pictures/Pokedex/overlay_area")
|
||||
@sprites["formfront"] = PokemonSprite.new(@viewport)
|
||||
@sprites["formfront"].setOffset(PictureOrigin::Center)
|
||||
@sprites["formfront"].x = 130
|
||||
@sprites["formfront"].y = 158
|
||||
@sprites["formfront"].zoom_y = Settings::FRONTSPRITE_SCALE
|
||||
@sprites["formfront"].zoom_x = Settings::FRONTSPRITE_SCALE
|
||||
|
||||
@sprites["formback"] = PokemonSprite.new(@viewport)
|
||||
@sprites["formback"].setOffset(PictureOrigin::Bottom)
|
||||
@sprites["formback"].x = 382 # y is set below as it depends on metrics
|
||||
@sprites["formicon"] = PokemonSpeciesIconSprite.new(nil, @viewport)
|
||||
@sprites["formicon"].setOffset(PictureOrigin::Center)
|
||||
@sprites["formicon"].x = 82
|
||||
@sprites["formicon"].y = 328
|
||||
@sprites["formicon"].visible = false
|
||||
initializeSpritesPageGraphics
|
||||
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
pbUpdateDummyPokemon
|
||||
@available = pbGetAvailableForms
|
||||
initializeSpritesPage(@available)
|
||||
drawPage(@page)
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def initializeSpritesPageGraphics()
|
||||
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["leftarrow"].x = 20
|
||||
@sprites["leftarrow"].y = 250 #268
|
||||
@sprites["leftarrow"].play
|
||||
@sprites["leftarrow"].visible = false
|
||||
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["rightarrow"].x = 440
|
||||
@sprites["rightarrow"].y = 250
|
||||
@sprites["rightarrow"].play
|
||||
@sprites["rightarrow"].visible = false
|
||||
|
||||
@sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow", 8, 28, 40, 2, @viewport)
|
||||
@sprites["uparrow"].x = 250
|
||||
@sprites["uparrow"].y = 50 #268
|
||||
@sprites["uparrow"].play
|
||||
@sprites["uparrow"].visible = false
|
||||
@sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow", 8, 28, 40, 2, @viewport)
|
||||
@sprites["downarrow"].x = 250
|
||||
@sprites["downarrow"].y = 350
|
||||
@sprites["downarrow"].play
|
||||
@sprites["downarrow"].visible = false
|
||||
end
|
||||
|
||||
def pbStartSpritesSelectSceneBrief(species, alts_list)
|
||||
@available = alts_list
|
||||
@species = species
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@index = 0
|
||||
@page = 3
|
||||
@brief = true
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
@sprites["infosprite"] = PokemonSprite.new(@viewport)
|
||||
@spritesLoader = BattleSpriteLoader.new
|
||||
@page = 3
|
||||
initializeSpritesPageGraphics
|
||||
initializeSpritesPage(@available)
|
||||
drawPage(@page)
|
||||
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbStartSceneBrief(species)
|
||||
# For standalone access, shows first page only
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
dexnum = 0
|
||||
dexnumshift = false
|
||||
if $Trainer.pokedex.unlocked?(-1) # National Dex is unlocked
|
||||
species_data = GameData::Species.try_get(species)
|
||||
dexnum = species_data.id_number if species_data
|
||||
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(-1)
|
||||
else
|
||||
dexnum = 0
|
||||
for i in 0...$Trainer.pokedex.dexes_count - 1 # Regional Dexes
|
||||
next if !$Trainer.pokedex.unlocked?(i)
|
||||
num = pbGetRegionalNumber(i, species)
|
||||
next if num <= 0
|
||||
dexnum = num
|
||||
dexnumshift = true if Settings::DEXES_WITH_OFFSETS.include?(i)
|
||||
break
|
||||
end
|
||||
end
|
||||
@dexlist = [[species, "", 0, 0, dexnum, dexnumshift]]
|
||||
@index = 0
|
||||
@page = 1
|
||||
@brief = true
|
||||
@typebitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Pokedex/icon_types"))
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["infosprite"] = PokemonSprite.new(@viewport)
|
||||
@sprites["infosprite"].setOffset(PictureOrigin::Center)
|
||||
@sprites["infosprite"].x = 104
|
||||
@sprites["infosprite"].y = 136
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
pbUpdateDummyPokemon
|
||||
@page = 1
|
||||
drawPage(@page)
|
||||
sprite_bitmap = @sprites["infosprite"].getBitmap
|
||||
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbStartSpritesPageBrief(species) end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@typebitmap.dispose if @typebitmap
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
if @page == 2
|
||||
intensity = (Graphics.frame_count % 40) * 12
|
||||
intensity = 480 - intensity if intensity > 240
|
||||
@sprites["areahighlight"].opacity = intensity
|
||||
end
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbUpdateDummyPokemon
|
||||
@species = @dexlist[@index][0]
|
||||
@gender, @form = $Trainer.pokedex.last_form_seen(@species)
|
||||
|
||||
if @sprites["selectedSprite"]
|
||||
@sprites["selectedSprite"].visible = false
|
||||
end
|
||||
if @sprites["nextSprite"]
|
||||
@sprites["nextSprite"].visible = false
|
||||
end
|
||||
if @sprites["previousSprite"]
|
||||
@sprites["previousSprite"].visible = false
|
||||
end
|
||||
|
||||
|
||||
# species_data = pbGetSpeciesData(@species)
|
||||
species_data = GameData::Species.get_species_form(@species, @form)
|
||||
@sprites["infosprite"].setSpeciesBitmap(@species) #, @gender, @form)
|
||||
|
||||
# if @sprites["formfront"]
|
||||
# @sprites["formfront"].setSpeciesBitmap(@species,@gender,@form)
|
||||
# end
|
||||
# if @sprites["formback"]
|
||||
# @sprites["formback"].setSpeciesBitmap(@species,@gender,@form,false,false,true)
|
||||
# @sprites["formback"].y = 256
|
||||
# @sprites["formback"].y += species_data.back_sprite_y * 2
|
||||
# end
|
||||
# if @sprites["formicon"]
|
||||
# @sprites["formicon"].pbSetParams(@species,@gender,@form)
|
||||
# end
|
||||
end
|
||||
|
||||
# def pbGetAvailableForms
|
||||
# ret = []
|
||||
# return ret
|
||||
# # multiple_forms = false
|
||||
# # # Find all genders/forms of @species that have been seen
|
||||
# # GameData::Species.each do |sp|
|
||||
# # next if sp.species != @species
|
||||
# # next if sp.form != 0 && (!sp.real_form_name || sp.real_form_name.empty?)
|
||||
# # next if sp.pokedex_form != sp.form
|
||||
# # multiple_forms = true if sp.form > 0
|
||||
# # case sp.gender_ratio
|
||||
# # when :AlwaysMale, :AlwaysFemale, :Genderless
|
||||
# # real_gender = (sp.gender_ratio == :AlwaysFemale) ? 1 : 0
|
||||
# # next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
|
||||
# # real_gender = 2 if sp.gender_ratio == :Genderless
|
||||
# # ret.push([sp.form_name, real_gender, sp.form])
|
||||
# # else # Both male and female
|
||||
# # for real_gender in 0...2
|
||||
# # next if !$Trainer.pokedex.seen_form?(@species, real_gender, sp.form) && !Settings::DEX_SHOWS_ALL_FORMS
|
||||
# # ret.push([sp.form_name, real_gender, sp.form])
|
||||
# # break if sp.form_name && !sp.form_name.empty? # Only show 1 entry for each non-0 form
|
||||
# # end
|
||||
# # end
|
||||
# # end
|
||||
# # # Sort all entries
|
||||
# # ret.sort! { |a, b| (a[2] == b[2]) ? a[1] <=> b[1] : a[2] <=> b[2] }
|
||||
# # # Create form names for entries if they don't already exist
|
||||
# # ret.each do |entry|
|
||||
# # if !entry[0] || entry[0].empty? # Necessarily applies only to form 0
|
||||
# # case entry[1]
|
||||
# # when 0 then entry[0] = _INTL("Male")
|
||||
# # when 1 then entry[0] = _INTL("Female")
|
||||
# # else
|
||||
# # entry[0] = (multiple_forms) ? _INTL("One Form") : _INTL("Genderless")
|
||||
# # end
|
||||
# # end
|
||||
# # entry[1] = 0 if entry[1] == 2 # Genderless entries are treated as male
|
||||
# # end
|
||||
# # return ret
|
||||
# end
|
||||
|
||||
def drawPage(page)
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
# Make certain sprites visible
|
||||
@sprites["infosprite"].visible = (@page == 1)
|
||||
@sprites["areamap"].visible = (@page == 2) if @sprites["areamap"]
|
||||
@sprites["areahighlight"].visible = (@page == 2) if @sprites["areahighlight"]
|
||||
@sprites["areaoverlay"].visible = (@page == 2) if @sprites["areaoverlay"]
|
||||
# @sprites["formfront"].visible = (@page==3) if @sprites["formfront"]
|
||||
#@sprites["formback"].visible = (@page==3) if @sprites["formback"]
|
||||
#@sprites["formicon"].visible = (@page==3) if @sprites["formicon"]
|
||||
|
||||
@sprites["previousSprite"].visible = (@page == 3) if @sprites["previousSprite"]
|
||||
@sprites["selectedSprite"].visible = (@page == 3) if @sprites["selectedSprite"]
|
||||
@sprites["nextSprite"].visible = (@page == 3) if @sprites["nextSprite"]
|
||||
|
||||
hide_all_selected_windows
|
||||
# Draw page-specific information
|
||||
case page
|
||||
when 1 then
|
||||
drawPageInfo
|
||||
when 2 then
|
||||
drawPageArea
|
||||
when 3 then
|
||||
drawPageForms
|
||||
end
|
||||
end
|
||||
|
||||
def drawPageInfo(reloading=false)
|
||||
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_info"))
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
base = Color.new(88, 88, 80)
|
||||
shadow = Color.new(168, 184, 184)
|
||||
|
||||
imagepos = []
|
||||
if @brief
|
||||
imagepos.push([_INTL("Graphics/Pictures/Pokedex/overlay_info"), 0, 0])
|
||||
end
|
||||
species_data = GameData::Species.get_species_form(@species, @form)
|
||||
# Write various bits of text
|
||||
indexText = "???"
|
||||
#if @dexlist[@index][4] > 0
|
||||
indexNumber = @dexlist[@index][4]
|
||||
indexNumber -= 1 if @dexlist[@index][5]
|
||||
indexNumber = GameData::Species.get(@species).id_number
|
||||
indexText = sprintf("%03d", indexNumber)
|
||||
# end
|
||||
textpos = [
|
||||
[_INTL("{1}{2} {3}", indexText, " ", species_data.name),
|
||||
246, 36, 0, Color.new(248, 248, 248), Color.new(0, 0, 0)],
|
||||
[_INTL("Height"), 314, 152, 0, base, shadow],
|
||||
[_INTL("Weight"), 314, 184, 0, base, shadow]
|
||||
]
|
||||
if $Trainer.owned?(@species)
|
||||
# Write the category
|
||||
textpos.push([_INTL("{1} Pokémon", species_data.category), 246, 68, 0, base, shadow])
|
||||
# Write the height and weight
|
||||
height = species_data.height
|
||||
weight = species_data.weight
|
||||
if System.user_language[3..4] == "US" # If the user is in the United States
|
||||
inches = (height / 0.254).round
|
||||
pounds = (weight / 0.45359).round
|
||||
textpos.push([_ISPRINTF("{1:d}'{2:02d}\"", inches / 12, inches % 12), 460, 152, 1, base, shadow])
|
||||
textpos.push([_ISPRINTF("{1:4.1f} lbs.", pounds / 10.0), 494, 184, 1, base, shadow])
|
||||
else
|
||||
textpos.push([_ISPRINTF("{1:.1f} m", height / 10.0), 470, 152, 1, base, shadow])
|
||||
textpos.push([_ISPRINTF("{1:.1f} kg", weight / 10.0), 482, 184, 1, base, shadow])
|
||||
end
|
||||
# Draw the Pokédex entry text
|
||||
# drawTextEx(overlay, 40, 244, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
|
||||
# species_data.pokedex_entry, base, shadow)
|
||||
#
|
||||
#
|
||||
#$PokemonSystem.use_generated_dex_entries=true if $PokemonSystem.use_generated_dex_entries ==nil
|
||||
drawEntryText(overlay, species_data,reloading)
|
||||
|
||||
# Draw the footprint
|
||||
footprintfile = GameData::Species.footprint_filename(@species, @form)
|
||||
if footprintfile
|
||||
footprint = RPG::Cache.load_bitmap("", footprintfile)
|
||||
overlay.blt(226, 138, footprint, footprint.rect)
|
||||
footprint.dispose
|
||||
end
|
||||
# Show the owned icon
|
||||
imagepos.push(["Graphics/Pictures/Pokedex/icon_own", 212, 44])
|
||||
# Draw the type icon(s)
|
||||
type1 = species_data.type1
|
||||
type2 = species_data.type2
|
||||
type1_number = GameData::Type.get(type1).id_number
|
||||
type2_number = GameData::Type.get(type2).id_number
|
||||
type1rect = Rect.new(0, type1_number * 32, 96, 32)
|
||||
type2rect = Rect.new(0, type2_number * 32, 96, 32)
|
||||
overlay.blt(296, 120, @typebitmap.bitmap, type1rect)
|
||||
overlay.blt(396, 120, @typebitmap.bitmap, type2rect) if type1 != type2
|
||||
else
|
||||
# Write the category
|
||||
textpos.push([_INTL("????? Pokémon"), 246, 68, 0, base, shadow])
|
||||
# Write the height and weight
|
||||
if System.user_language[3..4] == "US" # If the user is in the United States
|
||||
textpos.push([_INTL("???'??\""), 460, 152, 1, base, shadow])
|
||||
textpos.push([_INTL("????.? lbs."), 494, 184, 1, base, shadow])
|
||||
else
|
||||
textpos.push([_INTL("????.? m"), 470, 152, 1, base, shadow])
|
||||
textpos.push([_INTL("????.? kg"), 482, 184, 1, base, shadow])
|
||||
end
|
||||
end
|
||||
# Draw all text
|
||||
pbDrawTextPositions(overlay, textpos)
|
||||
# Draw all images
|
||||
pbDrawImagePositions(overlay, imagepos)
|
||||
end
|
||||
|
||||
|
||||
def drawEntryText(overlay, species_data, reloading=false)
|
||||
baseColor = Color.new(88, 88, 80)
|
||||
shadow = Color.new(168, 184, 184)
|
||||
shadowCustom = Color.new(160, 200, 150)
|
||||
shadowAI = Color.new(168, 184, 220)
|
||||
|
||||
if species_data.is_fusion
|
||||
customEntry = getCustomEntryText(species_data)
|
||||
if customEntry
|
||||
entryText = customEntry
|
||||
shadowColor = shadowCustom
|
||||
else
|
||||
if $PokemonSystem.use_generated_dex_entries && species_data.is_a?(GameData::FusedSpecies)
|
||||
@randomEntryText = species_data.get_random_dex_entry if !reloading
|
||||
entryText = @randomEntryText
|
||||
shadowColor = shadow
|
||||
else
|
||||
entryText = "No custom Pokédex entry available for this Pokémon. Please consider submitting an entry for this Pokémon on the game's Discord."
|
||||
shadowColor = shadow
|
||||
end
|
||||
end
|
||||
else
|
||||
entryText = species_data.pokedex_entry
|
||||
shadowColor = shadow
|
||||
end
|
||||
|
||||
max_chars_per_page = 150
|
||||
pages = splitTextIntoPages(entryText, max_chars_per_page)
|
||||
@entry_page = 0 if !@entry_page || pages.length == 1
|
||||
displayedText = pages[@entry_page]
|
||||
if pages.length > 1
|
||||
page_indicator_text = "#{@entry_page + 1}/#{pages.length}"
|
||||
drawTextEx(overlay, 425, 340, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
|
||||
page_indicator_text, baseColor, shadow)
|
||||
end
|
||||
|
||||
drawTextEx(overlay, 40, 244, Graphics.width - (40 * 2), 4, # overlay, x, y, width, num lines
|
||||
displayedText, baseColor, shadowColor)
|
||||
end
|
||||
|
||||
def splitTextIntoPages(text, max_chars_per_page)
|
||||
words = text.split
|
||||
pages = []
|
||||
current_page = ""
|
||||
|
||||
words.each do |word|
|
||||
if current_page.length + word.length + 1 > max_chars_per_page
|
||||
pages << current_page.strip
|
||||
current_page = word
|
||||
else
|
||||
current_page += " " unless current_page.empty?
|
||||
current_page += word
|
||||
end
|
||||
end
|
||||
|
||||
pages << current_page.strip unless current_page.empty?
|
||||
pages
|
||||
end
|
||||
|
||||
def reloadDexEntry()
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
drawPageInfo(true)
|
||||
end
|
||||
|
||||
def changeEntryPage()
|
||||
pbSEPlay("GUI sel cursor")
|
||||
@entry_page = @entry_page == 1 ? 0 : 1
|
||||
reloadDexEntry
|
||||
end
|
||||
|
||||
def isAutogenSprite(sprite_path)
|
||||
return !sprite_path.include?(Settings::CUSTOM_BATTLERS_FOLDER)
|
||||
end
|
||||
|
||||
def getCustomEntryText(species_data)
|
||||
spriteLoader = BattleSpriteLoader.new
|
||||
pif_sprite=spriteLoader.get_pif_sprite_from_species(species_data)
|
||||
return nil if pif_sprite.type != :CUSTOM
|
||||
possibleCustomEntries = getCustomDexEntry(pif_sprite)
|
||||
if possibleCustomEntries && possibleCustomEntries.length > 0
|
||||
customEntry = possibleCustomEntries.sample
|
||||
customEntry = customEntry.gsub(Settings::CUSTOM_ENTRIES_NAME_PLACEHOLDER, species_data.name)
|
||||
end
|
||||
return customEntry
|
||||
end
|
||||
|
||||
def getCustomDexEntry(pif_sprite)
|
||||
sprite = pif_sprite.to_filename()
|
||||
json_data = File.read(Settings::CUSTOM_DEX_ENTRIES_PATH)
|
||||
parsed_data = HTTPLite::JSON.parse(json_data)
|
||||
|
||||
entries = parsed_data.select { |entry| entry["sprite"] == sprite }
|
||||
if entries.any?
|
||||
return entries.map { |entry| entry["entry"] }
|
||||
else
|
||||
echoln "No custom entry found for sprite " + sprite.to_s
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
#unused
|
||||
def getAIDexEntry(pokemonID, name)
|
||||
begin
|
||||
head_number = get_head_number_from_symbol(pokemonID).to_s
|
||||
body_number = get_body_number_from_symbol(pokemonID).to_s
|
||||
|
||||
# Ensure the file exists, if not, create it
|
||||
unless File.exist?(Settings::AI_DEX_ENTRIES_PATH)
|
||||
File.write(Settings::AI_DEX_ENTRIES_PATH, '{}')
|
||||
end
|
||||
|
||||
json_data = File.read(Settings::AI_DEX_ENTRIES_PATH)
|
||||
data = HTTPLite::JSON.parse(json_data)
|
||||
|
||||
# Check if the entry exists
|
||||
unless data[head_number] && data[head_number][body_number]
|
||||
# If not, fetch it from the API
|
||||
url = Settings::AI_ENTRIES_URL + "?head=#{head_number}&body=#{body_number}"
|
||||
if !requestRateExceeded?(Settings::AI_ENTRIES_RATE_LOG_FILE, Settings::AI_ENTRIES_RATE_TIME_WINDOW, Settings::AI_ENTRIES_RATE_MAX_NB_REQUESTS)
|
||||
fetched_entry = clean_json_string(pbDownloadToString(url))
|
||||
else
|
||||
echoln "API rate exceeded for AI entries"
|
||||
end
|
||||
return nil if !fetched_entry || fetched_entry.empty?
|
||||
# If the fetched entry is valid, update the JSON and save it
|
||||
unless fetched_entry.empty?
|
||||
data[head_number] ||= {}
|
||||
data[head_number][body_number] = fetched_entry
|
||||
serialized_data = serialize_json(data)
|
||||
File.write(Settings::AI_DEX_ENTRIES_PATH, serialized_data)
|
||||
else
|
||||
echoln "No AI entry found for Pokemon " + pokemonID.to_s
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
entry = data[head_number][body_number]
|
||||
entry = entry.gsub(Settings::CUSTOM_ENTRIES_NAME_PLACEHOLDER, name)
|
||||
entry = entry.gsub("\n", "")
|
||||
|
||||
# Unescape any escaped quotes before returning the entry
|
||||
entry = entry.gsub('\\"', '"')
|
||||
return clean_json_string(entry)
|
||||
rescue MKXPError
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def pbFindEncounter(enc_types, species)
|
||||
return false if !enc_types
|
||||
enc_types.each_value do |slots|
|
||||
next if !slots
|
||||
slots.each { |slot| return true if GameData::Species.get(slot[1]).species == species }
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def drawPageArea
|
||||
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_area"))
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
base = Color.new(88, 88, 80)
|
||||
shadow = Color.new(168, 184, 184)
|
||||
@sprites["areahighlight"].bitmap.clear
|
||||
# Fill the array "points" with all squares of the region map in which the
|
||||
# species can be found
|
||||
points = []
|
||||
mapwidth = 1 + PokemonRegionMap_Scene::RIGHT - PokemonRegionMap_Scene::LEFT
|
||||
GameData::Encounter.each_of_version($PokemonGlobal.encounter_version) do |enc_data|
|
||||
next if !pbFindEncounter(enc_data.types, @species)
|
||||
map_metadata = GameData::MapMetadata.try_get(enc_data.map)
|
||||
mappos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
next if !mappos || mappos[0] != @region
|
||||
showpoint = true
|
||||
for loc in @mapdata[@region][2]
|
||||
showpoint = false if loc[0] == mappos[1] && loc[1] == mappos[2] &&
|
||||
loc[7] && !$game_switches[loc[7]]
|
||||
end
|
||||
next if !showpoint
|
||||
mapsize = map_metadata.town_map_size
|
||||
if mapsize && mapsize[0] && mapsize[0] > 0
|
||||
sqwidth = mapsize[0]
|
||||
sqheight = (mapsize[1].length * 1.0 / mapsize[0]).ceil
|
||||
for i in 0...sqwidth
|
||||
for j in 0...sqheight
|
||||
if mapsize[1][i + j * sqwidth, 1].to_i > 0
|
||||
points[mappos[1] + i + (mappos[2] + j) * mapwidth] = true
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
points[mappos[1] + mappos[2] * mapwidth] = true
|
||||
end
|
||||
end
|
||||
# Draw coloured squares on each square of the region map with a nest
|
||||
pointcolor = Color.new(0, 248, 248)
|
||||
pointcolorhl = Color.new(192, 248, 248)
|
||||
sqwidth = PokemonRegionMap_Scene::SQUAREWIDTH
|
||||
sqheight = PokemonRegionMap_Scene::SQUAREHEIGHT
|
||||
for j in 0...points.length
|
||||
if points[j]
|
||||
x = (j % mapwidth) * sqwidth
|
||||
x += (Graphics.width - @sprites["areamap"].bitmap.width) / 2
|
||||
y = (j / mapwidth) * sqheight
|
||||
y += (Graphics.height + 32 - @sprites["areamap"].bitmap.height) / 2
|
||||
@sprites["areahighlight"].bitmap.fill_rect(x, y, sqwidth, sqheight, pointcolor)
|
||||
if j - mapwidth < 0 || !points[j - mapwidth]
|
||||
@sprites["areahighlight"].bitmap.fill_rect(x, y - 2, sqwidth, 2, pointcolorhl)
|
||||
end
|
||||
if j + mapwidth >= points.length || !points[j + mapwidth]
|
||||
@sprites["areahighlight"].bitmap.fill_rect(x, y + sqheight, sqwidth, 2, pointcolorhl)
|
||||
end
|
||||
if j % mapwidth == 0 || !points[j - 1]
|
||||
@sprites["areahighlight"].bitmap.fill_rect(x - 2, y, 2, sqheight, pointcolorhl)
|
||||
end
|
||||
if (j + 1) % mapwidth == 0 || !points[j + 1]
|
||||
@sprites["areahighlight"].bitmap.fill_rect(x + sqwidth, y, 2, sqheight, pointcolorhl)
|
||||
end
|
||||
end
|
||||
end
|
||||
# Set the text
|
||||
textpos = []
|
||||
if points.length == 0
|
||||
pbDrawImagePositions(overlay, [
|
||||
[sprintf("Graphics/Pictures/Pokedex/overlay_areanone"), 108, 188]
|
||||
])
|
||||
textpos.push([_INTL("Area unknown"), Graphics.width / 2, Graphics.height / 2 - 6, 2, base, shadow])
|
||||
end
|
||||
textpos.push([pbGetMessage(MessageTypes::RegionNames, @region), 414, 38, 2, base, shadow])
|
||||
textpos.push([_INTL("{1}'s area", GameData::Species.get(@species).name),
|
||||
Graphics.width / 2, 346, 2, base, shadow])
|
||||
pbDrawTextPositions(overlay, textpos)
|
||||
end
|
||||
|
||||
def drawPageForms
|
||||
@sprites["background"].setBitmap(_INTL("Graphics/Pictures/Pokedex/bg_forms"))
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
base = Color.new(88, 88, 80)
|
||||
shadow = Color.new(168, 184, 184)
|
||||
# Write species and form name
|
||||
formname = ""
|
||||
for i in @available
|
||||
if i[1] == @gender && i[2] == @form
|
||||
formname = i[0]; break
|
||||
end
|
||||
end
|
||||
textpos = [
|
||||
[GameData::Species.get(@species).name, Graphics.width / 2, Graphics.height - 94, 2, base, shadow],
|
||||
[formname, Graphics.width / 2, Graphics.height - 62, 2, base, shadow],
|
||||
]
|
||||
# Draw all text
|
||||
pbDrawTextPositions(overlay, textpos)
|
||||
end
|
||||
|
||||
def pbGoToPrevious
|
||||
@entry_page = 0
|
||||
newindex = @index
|
||||
while newindex > 0
|
||||
newindex -= 1
|
||||
if $Trainer.seen?(@dexlist[newindex][0])
|
||||
@index = newindex
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbGoToNext
|
||||
@entry_page = 0
|
||||
newindex = @index
|
||||
while newindex < @dexlist.length - 1
|
||||
newindex += 1
|
||||
if $Trainer.seen?(@dexlist[newindex][0])
|
||||
@index = newindex
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbChooseAlt(brief = false)
|
||||
index = 0
|
||||
for i in 0...@available.length
|
||||
if @available[i][1] == @gender && @available[i][2] == @form
|
||||
index = i
|
||||
break
|
||||
end
|
||||
end
|
||||
oldindex = -1
|
||||
loop do
|
||||
if oldindex != index
|
||||
$Trainer.pokedex.set_last_form_seen(@species, @available[index][1], @available[index][2])
|
||||
pbUpdateDummyPokemon
|
||||
drawPage(@page)
|
||||
@sprites["uparrow"].visible = (index > 0)
|
||||
@sprites["downarrow"].visible = (index < @available.length - 1)
|
||||
oldindex = index
|
||||
end
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::UP)
|
||||
pbPlayCursorSE
|
||||
index = (index + @available.length - 1) % @available.length
|
||||
elsif Input.trigger?(Input::DOWN)
|
||||
pbPlayCursorSE
|
||||
index = (index + 1) % @available.length
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
end
|
||||
end
|
||||
@sprites["uparrow"].visible = false
|
||||
@sprites["downarrow"].visible = false
|
||||
end
|
||||
|
||||
def pbScene
|
||||
Pokemon.play_cry(@species, @form)
|
||||
until @endscene
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
dorefresh = false
|
||||
if Input.trigger?(Input::ACTION)
|
||||
#changeEntryPage()
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
if @page == 1 # entry
|
||||
changeEntryPage()
|
||||
elsif @page == 3 # Forms
|
||||
#if @available.length > 1
|
||||
pbPlayDecisionSE
|
||||
pbChooseAlt
|
||||
dorefresh = true
|
||||
# end
|
||||
end
|
||||
elsif Input.trigger?(Input::UP)
|
||||
oldindex = @index
|
||||
pbGoToPrevious
|
||||
if @index != oldindex
|
||||
@selected_index = 0
|
||||
pbUpdateDummyPokemon
|
||||
@available = pbGetAvailableForms
|
||||
pbSEStop
|
||||
(@page == 1) ? Pokemon.play_cry(@species, @form) : pbPlayCursorSE
|
||||
dorefresh = true
|
||||
end
|
||||
elsif Input.trigger?(Input::DOWN)
|
||||
oldindex = @index
|
||||
pbGoToNext
|
||||
if @index != oldindex
|
||||
@selected_index = 0
|
||||
pbUpdateDummyPokemon
|
||||
@available = pbGetAvailableForms
|
||||
pbSEStop
|
||||
(@page == 1) ? Pokemon.play_cry(@species, @form) : pbPlayCursorSE
|
||||
dorefresh = true
|
||||
end
|
||||
elsif Input.trigger?(Input::LEFT)
|
||||
oldpage = @page
|
||||
@page -= 2
|
||||
@page = 1 if @page < 1
|
||||
@page = 3 if @page > 3
|
||||
if @page != oldpage
|
||||
pbPlayCursorSE
|
||||
dorefresh = true
|
||||
end
|
||||
elsif Input.trigger?(Input::RIGHT)
|
||||
oldpage = @page
|
||||
@page += 2
|
||||
@page = 1 if @page < 1
|
||||
@page = 3 if @page > 3
|
||||
if @page != oldpage
|
||||
pbPlayCursorSE
|
||||
dorefresh = true
|
||||
end
|
||||
end
|
||||
if dorefresh
|
||||
drawPage(@page)
|
||||
end
|
||||
end
|
||||
return @index
|
||||
end
|
||||
|
||||
def pbSceneBrief
|
||||
Pokemon.play_cry(@species, @form)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::ACTION)
|
||||
changeEntryPage()
|
||||
Pokemon.play_cry(@species, @form)
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
elsif Input.trigger?(Input::RIGHT) || Input.trigger?(Input::LEFT)
|
||||
changeEntryPage()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbSelectSpritesSceneBrief
|
||||
pbChooseAlt(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPokedexInfoScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen(dexlist, index, region)
|
||||
@scene.pbStartScene(dexlist, index, region)
|
||||
ret = @scene.pbScene
|
||||
@scene.pbEndScene
|
||||
return ret # Index of last species viewed in dexlist
|
||||
end
|
||||
|
||||
def pbStartSceneSingle(species)
|
||||
# For use from a Pokémon's summary screen
|
||||
region = -1
|
||||
if Settings::USE_CURRENT_REGION_DEX
|
||||
region = pbGetCurrentRegion
|
||||
region = -1 if region >= $Trainer.pokedex.dexes_count - 1
|
||||
else
|
||||
region = $PokemonGlobal.pokedexDex # National Dex -1, regional Dexes 0, 1, etc.
|
||||
end
|
||||
dexnum = GameData::Species.get(species).id_number #pbGetRegionalNumber(region,species)
|
||||
dexnumshift = Settings::DEXES_WITH_OFFSETS.include?(region)
|
||||
dexlist = [[species, GameData::Species.get(species).name, 0, 0, dexnum, dexnumshift]]
|
||||
@scene.pbStartScene(dexlist, 0, region)
|
||||
@scene.pbScene
|
||||
@scene.pbEndScene
|
||||
end
|
||||
|
||||
def pbDexEntry(species)
|
||||
# For use when capturing a new species
|
||||
nb_sprites_for_alts_page = isSpeciesFusion(species) ? 2 : 1
|
||||
alts_list = @scene.pbGetAvailableForms(species)
|
||||
if alts_list.length > nb_sprites_for_alts_page
|
||||
@scene.pbStartSpritesSelectSceneBrief(species, alts_list)
|
||||
@scene.pbSelectSpritesSceneBrief
|
||||
@scene.pbEndScene
|
||||
end
|
||||
@scene.pbStartSceneBrief(species)
|
||||
@scene.pbSceneBrief
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,716 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class Window_PokemonBag < Window_DrawableCommand
|
||||
attr_reader :pocket
|
||||
attr_accessor :sorting
|
||||
|
||||
def initialize(bag,filterlist,pocket,x,y,width,height)
|
||||
@bag = bag
|
||||
@filterlist = filterlist
|
||||
@pocket = pocket
|
||||
@sorting = false
|
||||
@adapter = PokemonMartAdapter.new
|
||||
super(x,y,width,height)
|
||||
@selarrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor")
|
||||
@swaparrow = AnimatedBitmap.new("Graphics/Pictures/Bag/cursor_swap")
|
||||
self.windowskin = nil
|
||||
end
|
||||
|
||||
def dispose
|
||||
@swaparrow.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def pocket=(value)
|
||||
@pocket = value
|
||||
@item_max = (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1
|
||||
self.index = @bag.getChoice(@pocket)
|
||||
end
|
||||
|
||||
def page_row_max; return PokemonBag_Scene::ITEMSVISIBLE; end
|
||||
def page_item_max; return PokemonBag_Scene::ITEMSVISIBLE; end
|
||||
|
||||
def item
|
||||
return nil if @filterlist && !@filterlist[@pocket][self.index]
|
||||
thispocket = @bag.pockets[@pocket]
|
||||
item = (@filterlist) ? thispocket[@filterlist[@pocket][self.index]] : thispocket[self.index]
|
||||
return (item) ? item[0] : nil
|
||||
end
|
||||
|
||||
def itemCount
|
||||
return (@filterlist) ? @filterlist[@pocket].length+1 : @bag.pockets[@pocket].length+1
|
||||
end
|
||||
|
||||
def itemRect(item)
|
||||
if item<0 || item>=@item_max || item<self.top_item-1 ||
|
||||
item>self.top_item+self.page_item_max
|
||||
return Rect.new(0,0,0,0)
|
||||
else
|
||||
cursor_width = (self.width-self.borderX-(@column_max-1)*@column_spacing) / @column_max
|
||||
x = item % @column_max * (cursor_width + @column_spacing)
|
||||
y = item / @column_max * @row_height - @virtualOy
|
||||
return Rect.new(x, y, cursor_width, @row_height)
|
||||
end
|
||||
end
|
||||
|
||||
def drawCursor(index,rect)
|
||||
if self.index==index
|
||||
bmp = (@sorting) ? @swaparrow.bitmap : @selarrow.bitmap
|
||||
pbCopyBitmap(self.contents,bmp,rect.x,rect.y+2)
|
||||
end
|
||||
end
|
||||
|
||||
def drawItem(index,_count,rect)
|
||||
textpos = []
|
||||
rect = Rect.new(rect.x+16,rect.y+16,rect.width-16,rect.height)
|
||||
thispocket = @bag.pockets[@pocket]
|
||||
if index==self.itemCount-1
|
||||
textpos.push([_INTL("CLOSE BAG"),rect.x,rect.y-2,false,self.baseColor,self.shadowColor])
|
||||
else
|
||||
item = (@filterlist) ? thispocket[@filterlist[@pocket][index]][0] : thispocket[index][0]
|
||||
baseColor = self.baseColor
|
||||
shadowColor = self.shadowColor
|
||||
if @sorting && index==self.index
|
||||
baseColor = Color.new(224,0,0)
|
||||
shadowColor = Color.new(248,144,144)
|
||||
end
|
||||
textpos.push(
|
||||
[@adapter.getDisplayName(item),rect.x,rect.y-2,false,baseColor,shadowColor]
|
||||
)
|
||||
if GameData::Item.get(item).is_important?
|
||||
if @bag.pbIsRegistered?(item)
|
||||
pbDrawImagePositions(self.contents,[
|
||||
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,0,-1,24]
|
||||
])
|
||||
elsif pbCanRegisterItem?(item)
|
||||
pbDrawImagePositions(self.contents,[
|
||||
["Graphics/Pictures/Bag/icon_register",rect.x+rect.width-72,rect.y+8,0,24,-1,24]
|
||||
])
|
||||
end
|
||||
else
|
||||
qty = (@filterlist) ? thispocket[@filterlist[@pocket][index]][1] : thispocket[index][1]
|
||||
qtytext = _ISPRINTF("x{1: 3d}",qty)
|
||||
xQty = rect.x+rect.width-self.contents.text_size(qtytext).width-16
|
||||
textpos.push([qtytext,xQty,rect.y-2,false,baseColor,shadowColor])
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(self.contents,textpos)
|
||||
end
|
||||
|
||||
def refresh
|
||||
@item_max = itemCount()
|
||||
self.update_cursor_rect
|
||||
dwidth = self.width-self.borderX
|
||||
dheight = self.height-self.borderY
|
||||
self.contents = pbDoEnsureBitmap(self.contents,dwidth,dheight)
|
||||
self.contents.clear
|
||||
for i in 0...@item_max
|
||||
next if i<self.top_item-1 || i>self.top_item+self.page_item_max
|
||||
drawItem(i,@item_max,itemRect(i))
|
||||
end
|
||||
drawCursor(self.index,itemRect(self.index))
|
||||
end
|
||||
|
||||
def update
|
||||
super
|
||||
@uparrow.visible = false
|
||||
@downarrow.visible = false
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Bag visuals
|
||||
#===============================================================================
|
||||
class PokemonBag_Scene
|
||||
ITEMLISTBASECOLOR = Color.new(88,88,80)
|
||||
ITEMLISTSHADOWCOLOR = Color.new(168,184,184)
|
||||
ITEMTEXTBASECOLOR = Color.new(248,248,248)
|
||||
ITEMTEXTSHADOWCOLOR = Color.new(0,0,0)
|
||||
POCKETNAMEBASECOLOR = Color.new(88,88,80)
|
||||
POCKETNAMESHADOWCOLOR = Color.new(168,184,184)
|
||||
ITEMSVISIBLE = 7
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbStartScene(bag,choosing=false,filterproc=nil,resetpocket=true)
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@bag = bag
|
||||
@choosing = choosing
|
||||
@filterproc = filterproc
|
||||
pbRefreshFilter
|
||||
lastpocket = @bag.lastpocket
|
||||
numfilledpockets = @bag.pockets.length-1
|
||||
if @choosing
|
||||
numfilledpockets = 0
|
||||
if @filterlist!=nil
|
||||
for i in 1...@bag.pockets.length
|
||||
numfilledpockets += 1 if @filterlist[i].length>0
|
||||
end
|
||||
else
|
||||
for i in 1...@bag.pockets.length
|
||||
numfilledpockets += 1 if @bag.pockets[i].length>0
|
||||
end
|
||||
end
|
||||
lastpocket = (resetpocket) ? 1 : @bag.lastpocket
|
||||
if (@filterlist && @filterlist[lastpocket].length==0) ||
|
||||
(!@filterlist && @bag.pockets[lastpocket].length==0)
|
||||
for i in 1...@bag.pockets.length
|
||||
if @filterlist && @filterlist[i].length>0
|
||||
lastpocket = i; break
|
||||
elsif !@filterlist && @bag.pockets[i].length>0
|
||||
lastpocket = i; break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@bag.lastpocket = lastpocket
|
||||
@sliderbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Bag/icon_slider"))
|
||||
@pocketbitmap = AnimatedBitmap.new(_INTL("Graphics/Pictures/Bag/icon_pocket"))
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@sprites["bagsprite"] = IconSprite.new(30,20,@viewport)
|
||||
@sprites["pocketicon"] = BitmapSprite.new(186,32,@viewport)
|
||||
@sprites["pocketicon"].x = 0
|
||||
@sprites["pocketicon"].y = 224
|
||||
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow",8,40,28,2,@viewport)
|
||||
@sprites["leftarrow"].x = -4
|
||||
@sprites["leftarrow"].y = 76
|
||||
@sprites["leftarrow"].visible = (!@choosing || numfilledpockets>1)
|
||||
@sprites["leftarrow"].play
|
||||
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow",8,40,28,2,@viewport)
|
||||
@sprites["rightarrow"].x = 150
|
||||
@sprites["rightarrow"].y = 76
|
||||
@sprites["rightarrow"].visible = (!@choosing || numfilledpockets>1)
|
||||
@sprites["rightarrow"].play
|
||||
@sprites["itemlist"] = Window_PokemonBag.new(@bag,@filterlist,lastpocket,168,-8,314,40+32+ITEMSVISIBLE*32)
|
||||
@sprites["itemlist"].viewport = @viewport
|
||||
@sprites["itemlist"].pocket = lastpocket
|
||||
@sprites["itemlist"].index = @bag.getChoice(lastpocket)
|
||||
@sprites["itemlist"].baseColor = ITEMLISTBASECOLOR
|
||||
@sprites["itemlist"].shadowColor = ITEMLISTSHADOWCOLOR
|
||||
@sprites["itemicon"] = ItemIconSprite.new(48,Graphics.height-48,nil,@viewport)
|
||||
@sprites["itemtext"] = Window_UnformattedTextPokemon.newWithSize("",
|
||||
72, 270, Graphics.width - 72 - 24, 128, @viewport)
|
||||
@sprites["itemtext"].baseColor = ITEMTEXTBASECOLOR
|
||||
@sprites["itemtext"].shadowColor = ITEMTEXTSHADOWCOLOR
|
||||
@sprites["itemtext"].visible = true
|
||||
@sprites["itemtext"].windowskin = nil
|
||||
@sprites["helpwindow"] = Window_UnformattedTextPokemon.new("")
|
||||
@sprites["helpwindow"].visible = false
|
||||
@sprites["helpwindow"].viewport = @viewport
|
||||
@sprites["msgwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
@sprites["msgwindow"].visible = false
|
||||
@sprites["msgwindow"].viewport = @viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"],1)
|
||||
pbDeactivateWindows(@sprites)
|
||||
pbRefresh
|
||||
pbFadeInAndShow(@sprites)
|
||||
end
|
||||
|
||||
def pbFadeOutScene
|
||||
@oldsprites = pbFadeOutAndHide(@sprites)
|
||||
end
|
||||
|
||||
def pbFadeInScene
|
||||
pbFadeInAndShow(@sprites,@oldsprites)
|
||||
@oldsprites = nil
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) if !@oldsprites
|
||||
@oldsprites = nil
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@sliderbitmap.dispose
|
||||
@pocketbitmap.dispose
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbDisplay(msg,brief=false)
|
||||
UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbChooseNumber(helptext,maximum,initnum=1)
|
||||
return UIHelper.pbChooseNumber(@sprites["helpwindow"],helptext,maximum,initnum) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbShowCommands(helptext,commands,index=0)
|
||||
return UIHelper.pbShowCommands(@sprites["helpwindow"],helptext,commands,index) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbRefresh
|
||||
# Set the background image
|
||||
@sprites["background"].setBitmap(sprintf("Graphics/Pictures/Bag/bg_#{@bag.lastpocket}"))
|
||||
# Set the bag sprite
|
||||
fbagexists = pbResolveBitmap(sprintf("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f"))
|
||||
if $Trainer.female? && fbagexists
|
||||
@sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}_f")
|
||||
else
|
||||
@sprites["bagsprite"].setBitmap("Graphics/Pictures/Bag/bag_#{@bag.lastpocket}")
|
||||
end
|
||||
# Draw the pocket icons
|
||||
@sprites["pocketicon"].bitmap.clear
|
||||
if @choosing && @filterlist
|
||||
for i in 1...@bag.pockets.length
|
||||
if @filterlist[i].length==0
|
||||
@sprites["pocketicon"].bitmap.blt(6+(i-1)*22,6,
|
||||
@pocketbitmap.bitmap,Rect.new((i-1)*20,28,20,20))
|
||||
end
|
||||
end
|
||||
end
|
||||
@sprites["pocketicon"].bitmap.blt(2+(@sprites["itemlist"].pocket-1)*22,2,
|
||||
@pocketbitmap.bitmap,Rect.new((@sprites["itemlist"].pocket-1)*28,0,28,28))
|
||||
# Refresh the item window
|
||||
@sprites["itemlist"].refresh
|
||||
# Refresh more things
|
||||
pbRefreshIndexChanged
|
||||
end
|
||||
|
||||
def pbRefreshIndexChanged
|
||||
itemlist = @sprites["itemlist"]
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
# Draw the pocket name
|
||||
pbDrawTextPositions(overlay,[
|
||||
[PokemonBag.pocketNames[@bag.lastpocket],94,176,2,POCKETNAMEBASECOLOR,POCKETNAMESHADOWCOLOR]
|
||||
])
|
||||
# Draw slider arrows
|
||||
showslider = false
|
||||
if itemlist.top_row>0
|
||||
overlay.blt(470,16,@sliderbitmap.bitmap,Rect.new(0,0,36,38))
|
||||
showslider = true
|
||||
end
|
||||
if itemlist.top_item+itemlist.page_item_max<itemlist.itemCount
|
||||
overlay.blt(470,228,@sliderbitmap.bitmap,Rect.new(0,38,36,38))
|
||||
showslider = true
|
||||
end
|
||||
# Draw slider box
|
||||
if showslider
|
||||
sliderheight = 174
|
||||
boxheight = (sliderheight*itemlist.page_row_max/itemlist.row_max).floor
|
||||
boxheight += [(sliderheight-boxheight)/2,sliderheight/6].min
|
||||
boxheight = [boxheight.floor,38].max
|
||||
y = 54
|
||||
y += ((sliderheight-boxheight)*itemlist.top_row/(itemlist.row_max-itemlist.page_row_max)).floor
|
||||
overlay.blt(470,y,@sliderbitmap.bitmap,Rect.new(36,0,36,4))
|
||||
i = 0
|
||||
while i*16<boxheight-4-18
|
||||
height = [boxheight-4-18-i*16,16].min
|
||||
overlay.blt(470,y+4+i*16,@sliderbitmap.bitmap,Rect.new(36,4,36,height))
|
||||
i += 1
|
||||
end
|
||||
overlay.blt(470,y+boxheight-18,@sliderbitmap.bitmap,Rect.new(36,20,36,18))
|
||||
end
|
||||
# Set the selected item's icon
|
||||
@sprites["itemicon"].item = itemlist.item
|
||||
# Set the selected item's description
|
||||
@sprites["itemtext"].text =
|
||||
(itemlist.item) ? GameData::Item.get(itemlist.item).description : _INTL("Close bag.")
|
||||
end
|
||||
|
||||
def pbRefreshFilter
|
||||
@filterlist = nil
|
||||
return if !@choosing
|
||||
return if @filterproc==nil
|
||||
@filterlist = []
|
||||
for i in 1...@bag.pockets.length
|
||||
@filterlist[i] = []
|
||||
for j in 0...@bag.pockets[i].length
|
||||
@filterlist[i].push(j) if @filterproc.call(@bag.pockets[i][j][0])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_pocket
|
||||
itemwindow = @sprites["itemlist"]
|
||||
return @bag.pockets[itemwindow.pocket]
|
||||
end
|
||||
|
||||
# Called when the item screen wants an item to be chosen from the screen
|
||||
def pbChooseItem
|
||||
@sprites["helpwindow"].visible = false
|
||||
itemwindow = @sprites["itemlist"]
|
||||
thispocket = @bag.pockets[itemwindow.pocket]
|
||||
swapinitialpos = -1
|
||||
pbActivateWindow(@sprites,"itemlist") {
|
||||
loop do
|
||||
oldindex = itemwindow.index
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if itemwindow.sorting && itemwindow.index>=thispocket.length
|
||||
itemwindow.index = (oldindex==thispocket.length-1) ? 0 : thispocket.length-1
|
||||
end
|
||||
if itemwindow.index!=oldindex
|
||||
# Move the item being switched
|
||||
if itemwindow.sorting
|
||||
thispocket.insert(itemwindow.index,thispocket.delete_at(oldindex))
|
||||
end
|
||||
# Update selected item for current pocket
|
||||
@bag.setChoice(itemwindow.pocket,itemwindow.index)
|
||||
pbRefresh
|
||||
end
|
||||
if itemwindow.sorting
|
||||
if Input.trigger?(Input::ACTION) ||
|
||||
Input.trigger?(Input::USE)
|
||||
itemwindow.sorting = false
|
||||
pbPlayDecisionSE
|
||||
pbRefresh
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
thispocket.insert(swapinitialpos,thispocket.delete_at(itemwindow.index))
|
||||
itemwindow.index = swapinitialpos
|
||||
itemwindow.sorting = false
|
||||
pbPlayCancelSE
|
||||
pbRefresh
|
||||
end
|
||||
else
|
||||
# Change pockets
|
||||
if Input.trigger?(Input::LEFT)
|
||||
newpocket = itemwindow.pocket
|
||||
loop do
|
||||
newpocket = (newpocket==1) ? PokemonBag.numPockets : newpocket-1
|
||||
break if !@choosing || newpocket==itemwindow.pocket
|
||||
if @filterlist
|
||||
break if @filterlist[newpocket].length>0
|
||||
else
|
||||
break if @bag.pockets[newpocket].length>0
|
||||
end
|
||||
end
|
||||
if itemwindow.pocket!=newpocket
|
||||
itemwindow.pocket = newpocket
|
||||
@bag.lastpocket = itemwindow.pocket
|
||||
thispocket = @bag.pockets[itemwindow.pocket]
|
||||
pbPlayCursorSE
|
||||
pbRefresh
|
||||
end
|
||||
elsif Input.trigger?(Input::RIGHT)
|
||||
newpocket = itemwindow.pocket
|
||||
loop do
|
||||
newpocket = (newpocket==PokemonBag.numPockets) ? 1 : newpocket+1
|
||||
break if !@choosing || newpocket==itemwindow.pocket
|
||||
if @filterlist
|
||||
break if @filterlist[newpocket].length>0
|
||||
else
|
||||
break if @bag.pockets[newpocket].length>0
|
||||
end
|
||||
end
|
||||
if itemwindow.pocket!=newpocket
|
||||
itemwindow.pocket = newpocket
|
||||
@bag.lastpocket = itemwindow.pocket
|
||||
thispocket = @bag.pockets[itemwindow.pocket]
|
||||
pbPlayCursorSE
|
||||
pbRefresh
|
||||
end
|
||||
# elsif Input.trigger?(Input::SPECIAL) # Register/unregister selected item
|
||||
# if !@choosing && itemwindow.index<thispocket.length
|
||||
# if @bag.pbIsRegistered?(itemwindow.item)
|
||||
# @bag.pbUnregisterItem(itemwindow.item)
|
||||
# elsif pbCanRegisterItem?(itemwindow.item)
|
||||
# @bag.pbRegisterItem(itemwindow.item)
|
||||
# end
|
||||
# pbPlayDecisionSE
|
||||
# pbRefresh
|
||||
# end
|
||||
elsif Input.trigger?(Input::ACTION) # Start switching the selected item
|
||||
if !@choosing
|
||||
if thispocket.length>1 && itemwindow.index<thispocket.length &&
|
||||
!Settings::BAG_POCKET_AUTO_SORT[itemwindow.pocket]
|
||||
itemwindow.sorting = true
|
||||
swapinitialpos = itemwindow.index
|
||||
pbPlayDecisionSE
|
||||
pbRefresh
|
||||
end
|
||||
end
|
||||
elsif Input.trigger?(Input::BACK) # Cancel the item screen
|
||||
pbPlayCloseMenuSE
|
||||
return nil
|
||||
elsif Input.trigger?(Input::USE) # Choose selected item
|
||||
(itemwindow.item) ? pbPlayDecisionSE : pbPlayCloseMenuSE
|
||||
return itemwindow.item
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Bag mechanics
|
||||
#===============================================================================
|
||||
class PokemonBagScreen
|
||||
def initialize(scene,bag)
|
||||
@bag = bag
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
@scene.pbStartScene(@bag)
|
||||
item = nil
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
cmdRead = -1
|
||||
cmdUse = -1
|
||||
cmdRegister = -1
|
||||
cmdGive = -1
|
||||
cmdToss = -1
|
||||
cmdSort = -1
|
||||
cmdDebug = -1
|
||||
commands = []
|
||||
# Generate command list
|
||||
commands[cmdRead = commands.length] = _INTL("Read") if itm.is_mail?
|
||||
if ItemHandlers.hasOutHandler(item) || (itm.is_machine? && $Trainer.party.length>0)
|
||||
if ItemHandlers.hasUseText(item)
|
||||
commands[cmdUse = commands.length] = ItemHandlers.getUseText(item)
|
||||
else
|
||||
commands[cmdUse = commands.length] = _INTL("Use")
|
||||
end
|
||||
end
|
||||
commands[cmdGive = commands.length] = _INTL("Give") if $Trainer.pokemon_party.length > 0 && itm.can_hold?
|
||||
commands[cmdToss = commands.length] = _INTL("Toss") if !itm.is_important? || $DEBUG
|
||||
if @bag.pbIsRegistered?(item)
|
||||
commands[cmdRegister = commands.length] = _INTL("Deselect")
|
||||
elsif pbCanRegisterItem?(item)
|
||||
commands[cmdRegister = commands.length] = _INTL("Register")
|
||||
end
|
||||
commands[cmdSort = commands.length] = _INTL("Sort bag")
|
||||
commands[cmdDebug = commands.length] = _INTL("Debug") if $DEBUG
|
||||
commands[commands.length] = _INTL("Cancel")
|
||||
# Show commands generated above
|
||||
itemname = itm.name
|
||||
command = @scene.pbShowCommands(_INTL("{1} is selected.",itemname),commands)
|
||||
if cmdRead>=0 && command==cmdRead # Read mail
|
||||
pbFadeOutIn {
|
||||
pbDisplayMail(Mail.new(item, "", ""))
|
||||
}
|
||||
elsif cmdUse>=0 && command==cmdUse # Use item
|
||||
ret = pbUseItem(@bag,item,@scene)
|
||||
# ret: 0=Item wasn't used; 1=Item used; 2=Close Bag to use in field
|
||||
break if ret==2 # End screen
|
||||
@scene.pbRefresh
|
||||
next
|
||||
elsif cmdGive>=0 && command==cmdGive # Give item to Pokémon
|
||||
if $Trainer.pokemon_count == 0
|
||||
@scene.pbDisplay(_INTL("There is no Pokémon."))
|
||||
elsif itm.is_important?
|
||||
@scene.pbDisplay(_INTL("The {1} can't be held.",itemname))
|
||||
else
|
||||
pbFadeOutIn {
|
||||
sscene = PokemonParty_Scene.new
|
||||
sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
|
||||
sscreen.pbPokemonGiveScreen(item)
|
||||
@scene.pbRefresh
|
||||
}
|
||||
end
|
||||
elsif cmdToss>=0 && command==cmdToss # Toss item
|
||||
qty = @bag.pbQuantity(item)
|
||||
if qty>1
|
||||
helptext = _INTL("Toss out how many {1}?",itm.name_plural)
|
||||
qty = @scene.pbChooseNumber(helptext,qty)
|
||||
end
|
||||
if qty>0
|
||||
itemname = itm.name_plural if qty>1
|
||||
if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
|
||||
pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
|
||||
qty.times { @bag.pbDeleteItem(item) }
|
||||
@scene.pbRefresh
|
||||
end
|
||||
end
|
||||
elsif cmdRegister>=0 && command==cmdRegister # Register item
|
||||
if @bag.pbIsRegistered?(item)
|
||||
@bag.pbUnregisterItem(item)
|
||||
else
|
||||
@bag.pbRegisterItem(item)
|
||||
end
|
||||
@scene.pbRefresh
|
||||
elsif cmdSort >=0 && command == cmdSort # Sort bag
|
||||
command = @scene.pbShowCommands(_INTL("How to sort?",itemname),[
|
||||
_INTL("Alphabetically"),
|
||||
_INTL("By quantity"),
|
||||
# _INTL("Recently used"),
|
||||
# _INTL("Recently obtained"),
|
||||
_INTL("Cancel")
|
||||
],0)
|
||||
case command
|
||||
### Cancel ###
|
||||
when -1, 3
|
||||
next
|
||||
when 0
|
||||
@bag.sort_pocket_alphabetically()
|
||||
when 1
|
||||
@bag.sort_pocket_by_quantity()
|
||||
end
|
||||
@scene.pbRefresh
|
||||
elsif cmdDebug>=0 && command==cmdDebug # Debug
|
||||
command = 0
|
||||
loop do
|
||||
command = @scene.pbShowCommands(_INTL("Do what with {1}?",itemname),[
|
||||
_INTL("Change quantity"),
|
||||
_INTL("Make Mystery Gift"),
|
||||
_INTL("Cancel")
|
||||
],command)
|
||||
case command
|
||||
### Cancel ###
|
||||
when -1, 2
|
||||
break
|
||||
### Change quantity ###
|
||||
when 0
|
||||
qty = @bag.pbQuantity(item)
|
||||
itemplural = itm.name_plural
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, Settings::BAG_MAX_PER_SLOT)
|
||||
params.setDefaultValue(qty)
|
||||
newqty = pbMessageChooseNumber(
|
||||
_INTL("Choose new quantity of {1} (max. #{Settings::BAG_MAX_PER_SLOT}).",itemplural),params) { @scene.pbUpdate }
|
||||
if newqty>qty
|
||||
@bag.pbStoreItem(item,newqty-qty)
|
||||
elsif newqty<qty
|
||||
@bag.pbDeleteItem(item,qty-newqty)
|
||||
end
|
||||
@scene.pbRefresh
|
||||
break if newqty==0
|
||||
### Make Mystery Gift ###
|
||||
when 1
|
||||
pbCreateMysteryGift(1,item)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
return item
|
||||
end
|
||||
|
||||
def pbDisplay(text)
|
||||
@scene.pbDisplay(text)
|
||||
end
|
||||
|
||||
def pbConfirm(text)
|
||||
return @scene.pbConfirm(text)
|
||||
end
|
||||
|
||||
# UI logic for the item screen for choosing an item.
|
||||
def pbChooseItemScreen(proc=nil)
|
||||
oldlastpocket = @bag.lastpocket
|
||||
oldchoices = @bag.getAllChoices
|
||||
@scene.pbStartScene(@bag,true,proc)
|
||||
item = @scene.pbChooseItem
|
||||
@scene.pbEndScene
|
||||
@bag.lastpocket = oldlastpocket
|
||||
@bag.setAllChoices(oldchoices)
|
||||
return item
|
||||
end
|
||||
|
||||
# UI logic for withdrawing an item in the item storage screen.
|
||||
def pbWithdrawItemScreen
|
||||
if !$PokemonGlobal.pcItemStorage
|
||||
$PokemonGlobal.pcItemStorage = PCItemStorage.new
|
||||
end
|
||||
storage = $PokemonGlobal.pcItemStorage
|
||||
@scene.pbStartScene(storage)
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
qty = storage.pbQuantity(item)
|
||||
if qty>1 && !itm.is_important?
|
||||
qty = @scene.pbChooseNumber(_INTL("How many do you want to withdraw?"),qty)
|
||||
end
|
||||
next if qty<=0
|
||||
if @bag.pbCanStore?(item,qty)
|
||||
if !storage.pbDeleteItem(item,qty)
|
||||
raise "Can't delete items from storage"
|
||||
end
|
||||
if !@bag.pbStoreItem(item,qty)
|
||||
raise "Can't withdraw items from storage"
|
||||
end
|
||||
@scene.pbRefresh
|
||||
dispqty = (itm.is_important?) ? 1 : qty
|
||||
itemname = (dispqty>1) ? itm.name_plural : itm.name
|
||||
pbDisplay(_INTL("Withdrew {1} {2}.",dispqty,itemname))
|
||||
else
|
||||
pbDisplay(_INTL("There's no more room in the Bag."))
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
|
||||
# UI logic for depositing an item in the item storage screen.
|
||||
def pbDepositItemScreen
|
||||
@scene.pbStartScene(@bag)
|
||||
if !$PokemonGlobal.pcItemStorage
|
||||
$PokemonGlobal.pcItemStorage = PCItemStorage.new
|
||||
end
|
||||
storage = $PokemonGlobal.pcItemStorage
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
qty = @bag.pbQuantity(item)
|
||||
if qty>1 && !itm.is_important?
|
||||
qty = @scene.pbChooseNumber(_INTL("How many do you want to deposit?"),qty)
|
||||
end
|
||||
if qty>0
|
||||
if !storage.pbCanStore?(item,qty)
|
||||
pbDisplay(_INTL("There's no room to store items."))
|
||||
else
|
||||
if !@bag.pbDeleteItem(item,qty)
|
||||
raise "Can't delete items from Bag"
|
||||
end
|
||||
if !storage.pbStoreItem(item,qty)
|
||||
raise "Can't deposit items to storage"
|
||||
end
|
||||
@scene.pbRefresh
|
||||
dispqty = (itm.is_important?) ? 1 : qty
|
||||
itemname = (dispqty>1) ? itm.name_plural : itm.name
|
||||
pbDisplay(_INTL("Deposited {1} {2}.",dispqty,itemname))
|
||||
end
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
|
||||
# UI logic for tossing an item in the item storage screen.
|
||||
def pbTossItemScreen
|
||||
if !$PokemonGlobal.pcItemStorage
|
||||
$PokemonGlobal.pcItemStorage = PCItemStorage.new
|
||||
end
|
||||
storage = $PokemonGlobal.pcItemStorage
|
||||
@scene.pbStartScene(storage)
|
||||
loop do
|
||||
item = @scene.pbChooseItem
|
||||
break if !item
|
||||
itm = GameData::Item.get(item)
|
||||
if itm.is_important?
|
||||
@scene.pbDisplay(_INTL("That's too important to toss out!"))
|
||||
next
|
||||
end
|
||||
qty = storage.pbQuantity(item)
|
||||
itemname = itm.name
|
||||
itemnameplural = itm.name_plural
|
||||
if qty>1
|
||||
qty=@scene.pbChooseNumber(_INTL("Toss out how many {1}?",itemnameplural),qty)
|
||||
end
|
||||
if qty>0
|
||||
itemname = itemnameplural if qty>1
|
||||
if pbConfirm(_INTL("Is it OK to throw away {1} {2}?",qty,itemname))
|
||||
if !storage.pbDeleteItem(item,qty)
|
||||
raise "Can't delete items from storage"
|
||||
end
|
||||
@scene.pbRefresh
|
||||
pbDisplay(_INTL("Threw away {1} {2}.",qty,itemname))
|
||||
end
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
@@ -1,157 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokegearButton < SpriteWrapper
|
||||
attr_reader :index
|
||||
attr_reader :name
|
||||
attr_reader :selected
|
||||
|
||||
def initialize(command,x,y,viewport=nil)
|
||||
super(viewport)
|
||||
@image = command[0]
|
||||
@name = command[1]
|
||||
@selected = false
|
||||
if $Trainer.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/icon_button_f"))
|
||||
@button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button_f")
|
||||
else
|
||||
@button = AnimatedBitmap.new("Graphics/Pictures/Pokegear/icon_button")
|
||||
end
|
||||
@contents = BitmapWrapper.new(@button.width,@button.height)
|
||||
self.bitmap = @contents
|
||||
self.x = x
|
||||
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,self.bitmap.width/2,4,2,Color.new(248,248,248),Color.new(40,40,40)],
|
||||
]
|
||||
pbDrawTextPositions(self.bitmap,textpos)
|
||||
imagepos = [
|
||||
[sprintf("Graphics/Pictures/Pokegear/icon_"+@image),18,10]
|
||||
]
|
||||
pbDrawImagePositions(self.bitmap,imagepos)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPokegear_Scene
|
||||
def pbUpdate
|
||||
for i in 0...@commands.length
|
||||
@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 $Trainer.female? && pbResolveBitmap(sprintf("Graphics/Pictures/Pokegear/bg_f"))
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg_f")
|
||||
else
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/Pokegear/bg")
|
||||
end
|
||||
for i in 0...@commands.length
|
||||
y = 196 - (@commands.length*24) + (i*48)
|
||||
@sprites["button#{i}"] = PokegearButton.new(@commands[i],118,y,@viewport)
|
||||
end
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
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 }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPokegearScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
commands = []
|
||||
cmdMap = -1
|
||||
cmdPhone = -1
|
||||
cmdJukebox = -1
|
||||
commands[cmdMap = commands.length] = ["map",_INTL("Map")]
|
||||
if $PokemonGlobal.phoneNumbers && $PokemonGlobal.phoneNumbers.length>0
|
||||
commands[cmdPhone = commands.length] = ["phone",_INTL("Phone")]
|
||||
end
|
||||
commands[cmdJukebox = commands.length] = ["jukebox",_INTL("Jukebox")]
|
||||
@scene.pbStartScene(commands)
|
||||
loop do
|
||||
cmd = @scene.pbScene
|
||||
if cmd<0
|
||||
break
|
||||
elsif cmdMap>=0 && cmd==cmdMap
|
||||
pbShowMap(-1,false)
|
||||
elsif cmdPhone>=0 && cmd==cmdPhone
|
||||
pbFadeOutIn {
|
||||
PokemonPhoneScene.new.start
|
||||
}
|
||||
elsif cmdJukebox>=0 && cmd==cmdJukebox
|
||||
pbFadeOutIn {
|
||||
scene = PokemonJukebox_Scene.new
|
||||
screen = PokemonJukeboxScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
}
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
@@ -1,376 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class MapBottomSprite < SpriteWrapper
|
||||
attr_reader :mapname
|
||||
attr_reader :maplocation
|
||||
|
||||
def initialize(viewport=nil)
|
||||
super(viewport)
|
||||
@mapname = ""
|
||||
@maplocation = ""
|
||||
@mapdetails = ""
|
||||
@thisbitmap = BitmapWrapper.new(Graphics.width,Graphics.height)
|
||||
pbSetSystemFont(@thisbitmap)
|
||||
self.x = 0
|
||||
self.y = 0
|
||||
self.bitmap = @thisbitmap
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@thisbitmap.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def mapname=(value)
|
||||
if @mapname!=value
|
||||
@mapname = value
|
||||
refresh
|
||||
end
|
||||
end
|
||||
|
||||
def maplocation=(value)
|
||||
if @maplocation!=value
|
||||
@maplocation = value
|
||||
refresh
|
||||
end
|
||||
end
|
||||
|
||||
def mapdetails=(value) # From Wichu
|
||||
if @mapdetails!=value
|
||||
@mapdetails = value
|
||||
refresh
|
||||
end
|
||||
end
|
||||
|
||||
def refresh
|
||||
self.bitmap.clear
|
||||
textpos = [
|
||||
[@mapname,18,-8,0,Color.new(248,248,248),Color.new(0,0,0)],
|
||||
[@maplocation,18,348,0,Color.new(248,248,248),Color.new(0,0,0)],
|
||||
[@mapdetails,Graphics.width-16,348,1,Color.new(248,248,248),Color.new(0,0,0)]
|
||||
]
|
||||
pbDrawTextPositions(self.bitmap,textpos)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonRegionMap_Scene
|
||||
LEFT = 0
|
||||
TOP = 0
|
||||
RIGHT = 29
|
||||
BOTTOM = 19
|
||||
SQUAREWIDTH = 16
|
||||
SQUAREHEIGHT = 16
|
||||
|
||||
def initialize(region=-1,wallmap=true)
|
||||
@region = region
|
||||
@wallmap = wallmap
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbStartScene(aseditor=false,mode=0)
|
||||
@editor = aseditor
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@mapdata = pbLoadTownMapData
|
||||
map_metadata = GameData::MapMetadata.try_get($game_map.map_id)
|
||||
playerpos = (map_metadata) ? map_metadata.town_map_position : nil
|
||||
if !playerpos
|
||||
mapindex = 0
|
||||
@map = @mapdata[0]
|
||||
@mapX = LEFT
|
||||
@mapY = TOP
|
||||
elsif @region>=0 && @region!=playerpos[0] && @mapdata[@region]
|
||||
mapindex = @region
|
||||
@map = @mapdata[@region]
|
||||
@mapX = LEFT
|
||||
@mapY = TOP
|
||||
else
|
||||
mapindex = playerpos[0]
|
||||
@map = @mapdata[playerpos[0]]
|
||||
@mapX = playerpos[1]
|
||||
@mapY = playerpos[2]
|
||||
mapsize = map_metadata.town_map_size
|
||||
if mapsize && mapsize[0] && mapsize[0]>0
|
||||
sqwidth = mapsize[0]
|
||||
sqheight = (mapsize[1].length*1.0/mapsize[0]).ceil
|
||||
if sqwidth>1
|
||||
@mapX += ($game_player.x*sqwidth/$game_map.width).floor
|
||||
end
|
||||
if sqheight>1
|
||||
@mapY += ($game_player.y*sqheight/$game_map.height).floor
|
||||
end
|
||||
end
|
||||
end
|
||||
if !@map
|
||||
pbMessage(_INTL("The map data cannot be found."))
|
||||
return false
|
||||
end
|
||||
addBackgroundOrColoredPlane(@sprites,"background","mapbg",Color.new(0,0,0),@viewport)
|
||||
@sprites["map"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["map"].setBitmap("Graphics/Pictures/#{@map[1]}")
|
||||
@sprites["map"].x += (Graphics.width-@sprites["map"].bitmap.width)/2
|
||||
@sprites["map"].y += (Graphics.height-@sprites["map"].bitmap.height)/2
|
||||
for hidden in Settings::REGION_MAP_EXTRAS
|
||||
if hidden[0]==mapindex && ((@wallmap && hidden[5]) ||
|
||||
(!@wallmap && hidden[1]>0 && $game_switches[hidden[1]]))
|
||||
if !@sprites["map2"]
|
||||
@sprites["map2"] = BitmapSprite.new(480,320,@viewport)
|
||||
@sprites["map2"].x = @sprites["map"].x
|
||||
@sprites["map2"].y = @sprites["map"].y
|
||||
end
|
||||
pbDrawImagePositions(@sprites["map2"].bitmap,[
|
||||
["Graphics/Pictures/#{hidden[4]}",hidden[2]*SQUAREWIDTH,hidden[3]*SQUAREHEIGHT]
|
||||
])
|
||||
end
|
||||
end
|
||||
@sprites["mapbottom"] = MapBottomSprite.new(@viewport)
|
||||
@sprites["mapbottom"].mapname = pbGetMessage(MessageTypes::RegionNames,mapindex)
|
||||
@sprites["mapbottom"].maplocation = pbGetMapLocation(@mapX,@mapY)
|
||||
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@mapX,@mapY)
|
||||
if playerpos && mapindex==playerpos[0]
|
||||
@sprites["player"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["player"].setBitmap(GameData::TrainerType.player_map_icon_filename($Trainer.trainer_type))
|
||||
@sprites["player"].x = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
|
||||
@sprites["player"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
|
||||
end
|
||||
if mode>0
|
||||
k = 0
|
||||
for i in LEFT..RIGHT
|
||||
for j in TOP..BOTTOM
|
||||
healspot = pbGetHealingSpot(i,j)
|
||||
if healspot && $PokemonGlobal.visitedMaps[healspot[0]]
|
||||
@sprites["point#{k}"] = AnimatedSprite.create("Graphics/Pictures/mapFly",2,16)
|
||||
@sprites["point#{k}"].viewport = @viewport
|
||||
@sprites["point#{k}"].x = -SQUAREWIDTH/2+(i*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
|
||||
@sprites["point#{k}"].y = -SQUAREHEIGHT/2+(j*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
|
||||
@sprites["point#{k}"].play
|
||||
k += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@sprites["cursor"] = AnimatedSprite.create("Graphics/Pictures/mapCursor",2,5)
|
||||
@sprites["cursor"].viewport = @viewport
|
||||
@sprites["cursor"].x = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
|
||||
@sprites["cursor"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
|
||||
@sprites["cursor"].play
|
||||
@changed = false
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
return true
|
||||
end
|
||||
|
||||
# TODO: Why is this PBS file writer here?
|
||||
def pbSaveMapData
|
||||
File.open("PBS/townmap.txt","wb") { |f|
|
||||
Compiler.add_PBS_header_to_file(f)
|
||||
for i in 0...@mapdata.length
|
||||
map = @mapdata[i]
|
||||
next if !map
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(sprintf("[%d]\r\n",i))
|
||||
f.write(sprintf("Name = %s\r\nFilename = %s\r\n",
|
||||
Compiler.csvQuote(map[0]), Compiler.csvQuote(map[1])))
|
||||
for loc in map[2]
|
||||
f.write("Point = ")
|
||||
Compiler.pbWriteCsvRecord(loc,f,[nil,"uussUUUU"])
|
||||
f.write("\r\n")
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbGetMapLocation(x,y)
|
||||
return "" if !@map[2]
|
||||
for loc in @map[2]
|
||||
if loc[0]==x && loc[1]==y
|
||||
if !loc[7] || (!@wallmap && $game_switches[loc[7]])
|
||||
maploc = pbGetMessageFromHash(MessageTypes::PlaceNames,loc[2])
|
||||
return @editor ? loc[2] : maploc
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
def pbChangeMapLocation(x,y)
|
||||
return if !@editor
|
||||
return "" if !@map[2]
|
||||
currentname = ""
|
||||
currentobj = nil
|
||||
for loc in @map[2]
|
||||
if loc[0]==x && loc[1]==y
|
||||
currentobj = loc
|
||||
currentname = loc[2]
|
||||
break
|
||||
end
|
||||
end
|
||||
currentname = pbMessageFreeText(_INTL("Set the name for this point."),currentname,false,250) { pbUpdate }
|
||||
if currentname
|
||||
if currentobj
|
||||
currentobj[2] = currentname
|
||||
else
|
||||
newobj = [x,y,currentname,""]
|
||||
@map[2].push(newobj)
|
||||
end
|
||||
@changed = true
|
||||
end
|
||||
end
|
||||
|
||||
def pbGetMapDetails(x,y) # From Wichu, with my help
|
||||
return "" if !@map[2]
|
||||
for loc in @map[2]
|
||||
if loc[0]==x && loc[1]==y
|
||||
if !loc[7] || (!@wallmap && $game_switches[loc[7]])
|
||||
mapdesc = pbGetMessageFromHash(MessageTypes::PlaceDescriptions,loc[3])
|
||||
return (@editor) ? loc[3] : mapdesc
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
end
|
||||
return ""
|
||||
end
|
||||
|
||||
def pbGetHealingSpot(x,y)
|
||||
return nil if !@map[2]
|
||||
for loc in @map[2]
|
||||
if loc[0]==x && loc[1]==y
|
||||
if !loc[4] || !loc[5] || !loc[6]
|
||||
return nil
|
||||
else
|
||||
return [loc[4],loc[5],loc[6]]
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def pbMapScene(mode=0)
|
||||
xOffset = 0
|
||||
yOffset = 0
|
||||
newX = 0
|
||||
newY = 0
|
||||
@sprites["cursor"].x = -SQUAREWIDTH/2+(@mapX*SQUAREWIDTH)+(Graphics.width-@sprites["map"].bitmap.width)/2
|
||||
@sprites["cursor"].y = -SQUAREHEIGHT/2+(@mapY*SQUAREHEIGHT)+(Graphics.height-@sprites["map"].bitmap.height)/2
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if xOffset!=0 || yOffset!=0
|
||||
distancePerFrame = 8*20/Graphics.frame_rate
|
||||
xOffset += (xOffset>0) ? -distancePerFrame : (xOffset<0) ? distancePerFrame : 0
|
||||
yOffset += (yOffset>0) ? -distancePerFrame : (yOffset<0) ? distancePerFrame : 0
|
||||
@sprites["cursor"].x = newX-xOffset
|
||||
@sprites["cursor"].y = newY-yOffset
|
||||
next
|
||||
end
|
||||
@sprites["mapbottom"].maplocation = pbGetMapLocation(@mapX,@mapY)
|
||||
@sprites["mapbottom"].mapdetails = pbGetMapDetails(@mapX,@mapY)
|
||||
ox = 0
|
||||
oy = 0
|
||||
case Input.dir8
|
||||
when 1 # lower left
|
||||
oy = 1 if @mapY<BOTTOM
|
||||
ox = -1 if @mapX>LEFT
|
||||
when 2 # down
|
||||
oy = 1 if @mapY<BOTTOM
|
||||
when 3 # lower right
|
||||
oy = 1 if @mapY<BOTTOM
|
||||
ox = 1 if @mapX<RIGHT
|
||||
when 4 # left
|
||||
ox = -1 if @mapX>LEFT
|
||||
when 6 # right
|
||||
ox = 1 if @mapX<RIGHT
|
||||
when 7 # upper left
|
||||
oy = -1 if @mapY>TOP
|
||||
ox = -1 if @mapX>LEFT
|
||||
when 8 # up
|
||||
oy = -1 if @mapY>TOP
|
||||
when 9 # upper right
|
||||
oy = -1 if @mapY>TOP
|
||||
ox = 1 if @mapX<RIGHT
|
||||
end
|
||||
if ox!=0 || oy!=0
|
||||
@mapX += ox
|
||||
@mapY += oy
|
||||
xOffset = ox*SQUAREWIDTH
|
||||
yOffset = oy*SQUAREHEIGHT
|
||||
newX = @sprites["cursor"].x+xOffset
|
||||
newY = @sprites["cursor"].y+yOffset
|
||||
end
|
||||
if Input.trigger?(Input::BACK)
|
||||
if @editor && @changed
|
||||
if pbConfirmMessage(_INTL("Save changes?")) { pbUpdate }
|
||||
pbSaveMapData
|
||||
end
|
||||
if pbConfirmMessage(_INTL("Exit from the map?")) { pbUpdate }
|
||||
break
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
elsif Input.trigger?(Input::USE) && mode==1 # Choosing an area to fly to
|
||||
healspot = pbGetHealingSpot(@mapX,@mapY)
|
||||
if healspot
|
||||
if $PokemonGlobal.visitedMaps[healspot[0]] || ($DEBUG && Input.press?(Input::CTRL))
|
||||
return healspot
|
||||
end
|
||||
end
|
||||
elsif Input.trigger?(Input::USE) && @editor # Intentionally after other USE input check
|
||||
pbChangeMapLocation(@mapX,@mapY)
|
||||
end
|
||||
end
|
||||
pbPlayCloseMenuSE
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonRegionMapScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartFlyScreen
|
||||
@scene.pbStartScene(false,1)
|
||||
ret = @scene.pbMapScene(1)
|
||||
@scene.pbEndScene
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
@scene.pbStartScene($DEBUG)
|
||||
@scene.pbMapScene
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbShowMap(region=-1,wallmap=true)
|
||||
pbFadeOutIn {
|
||||
scene = PokemonRegionMap_Scene.new(region,wallmap)
|
||||
screen = PokemonRegionMapScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
}
|
||||
end
|
||||
@@ -1,149 +0,0 @@
|
||||
#===============================================================================
|
||||
# Phone screen
|
||||
#===============================================================================
|
||||
class Window_PhoneList < Window_CommandPokemon
|
||||
def drawCursor(index,rect)
|
||||
selarrow = AnimatedBitmap.new("Graphics/Pictures/phoneSel")
|
||||
if self.index==index
|
||||
pbCopyBitmap(self.contents,selarrow.bitmap,rect.x,rect.y)
|
||||
end
|
||||
return Rect.new(rect.x+28,rect.y+8,rect.width-16,rect.height)
|
||||
end
|
||||
|
||||
def drawItem(index,count,rect)
|
||||
return if index>=self.top_row+self.page_item_max
|
||||
super
|
||||
drawCursor(index-1,itemRect(index-1))
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonPhoneScene
|
||||
def start
|
||||
commands = []
|
||||
@trainers = []
|
||||
if $PokemonGlobal.phoneNumbers
|
||||
for num in $PokemonGlobal.phoneNumbers
|
||||
if num[0] # if visible
|
||||
if num.length==8 # if trainer
|
||||
@trainers.push([num[1],num[2],num[6],(num[4]>=2)])
|
||||
else # if NPC
|
||||
@trainers.push([num[1],num[2],num[3]])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if @trainers.length==0
|
||||
pbMessage(_INTL("There are no phone numbers stored."))
|
||||
return
|
||||
end
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites["list"] = Window_PhoneList.newEmpty(152,32,Graphics.width-142,Graphics.height-80,@viewport)
|
||||
@sprites["header"] = Window_UnformattedTextPokemon.newWithSize(_INTL("Phone"),
|
||||
2,-18,128,64,@viewport)
|
||||
@sprites["header"].baseColor = Color.new(248,248,248)
|
||||
@sprites["header"].shadowColor = Color.new(0,0,0)
|
||||
mapname = (@trainers[0][2]) ? pbGetMessage(MessageTypes::MapNames,@trainers[0][2]) : ""
|
||||
@sprites["bottom"] = Window_AdvancedTextPokemon.newWithSize("",
|
||||
162,Graphics.height-64,Graphics.width-158,64,@viewport)
|
||||
@sprites["bottom"].text = "<ac>"+mapname
|
||||
@sprites["info"] = Window_AdvancedTextPokemon.newWithSize("",-8,224,180,160,@viewport)
|
||||
addBackgroundPlane(@sprites,"bg","phonebg",@viewport)
|
||||
@sprites["icon"] = IconSprite.new(70,102,@viewport)
|
||||
if @trainers[0].length==4
|
||||
filename = GameData::TrainerType.charset_filename(@trainers[0][0])
|
||||
else
|
||||
filename = sprintf("Graphics/Characters/phone%03d",@trainers[0][0])
|
||||
end
|
||||
@sprites["icon"].setBitmap(filename)
|
||||
charwidth = @sprites["icon"].bitmap.width
|
||||
charheight = @sprites["icon"].bitmap.height
|
||||
@sprites["icon"].x = 86-charwidth/8
|
||||
@sprites["icon"].y = 134-charheight/8
|
||||
@sprites["icon"].src_rect = Rect.new(0,0,charwidth/4,charheight/4)
|
||||
for trainer in @trainers
|
||||
if trainer.length==4
|
||||
displayname = _INTL("{1} {2}", GameData::TrainerType.get(trainer[0]).name,
|
||||
pbGetMessageFromHash(MessageTypes::TrainerNames,trainer[1])
|
||||
)
|
||||
commands.push(displayname) # trainer's display name
|
||||
else
|
||||
commands.push(trainer[1]) # NPC's display name
|
||||
end
|
||||
end
|
||||
@sprites["list"].commands = commands
|
||||
for i in 0...@sprites["list"].page_item_max
|
||||
@sprites["rematch[#{i}]"] = IconSprite.new(468,62+i*32,@viewport)
|
||||
j = i+@sprites["list"].top_item
|
||||
next if j>=commands.length
|
||||
trainer = @trainers[j]
|
||||
if trainer.length==4
|
||||
if trainer[3]
|
||||
@sprites["rematch[#{i}]"].setBitmap("Graphics/Pictures/phoneRematch")
|
||||
end
|
||||
end
|
||||
end
|
||||
rematchcount = 0
|
||||
for trainer in @trainers
|
||||
if trainer.length==4
|
||||
rematchcount += 1 if trainer[3]
|
||||
end
|
||||
end
|
||||
infotext = _INTL("Registered<br>")
|
||||
infotext += _INTL(" <r>{1}<br>",@sprites["list"].commands.length)
|
||||
infotext += _INTL("Waiting for a rematch<r>{1}",rematchcount)
|
||||
@sprites["info"].text = infotext
|
||||
pbFadeInAndShow(@sprites)
|
||||
pbActivateWindow(@sprites,"list") {
|
||||
oldindex = -1
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
if @sprites["list"].index!=oldindex
|
||||
trainer = @trainers[@sprites["list"].index]
|
||||
if trainer.length==4
|
||||
filename = GameData::TrainerType.charset_filename(trainer[0])
|
||||
else
|
||||
filename = sprintf("Graphics/Characters/phone%03d",trainer[0])
|
||||
end
|
||||
@sprites["icon"].setBitmap(filename)
|
||||
charwidth = @sprites["icon"].bitmap.width
|
||||
charheight = @sprites["icon"].bitmap.height
|
||||
@sprites["icon"].x = 86-charwidth/8
|
||||
@sprites["icon"].y = 134-charheight/8
|
||||
@sprites["icon"].src_rect = Rect.new(0,0,charwidth/4,charheight/4)
|
||||
mapname=(trainer[2]) ? pbGetMessage(MessageTypes::MapNames,trainer[2]) : ""
|
||||
@sprites["bottom"].text = "<ac>"+mapname
|
||||
for i in 0...@sprites["list"].page_item_max
|
||||
@sprites["rematch[#{i}]"].clearBitmaps
|
||||
j = i+@sprites["list"].top_item
|
||||
next if j>=commands.length
|
||||
trainer = @trainers[j]
|
||||
if trainer.length==4
|
||||
if trainer[3]
|
||||
@sprites["rematch[#{i}]"].setBitmap("Graphics/Pictures/phoneRematch")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
index = @sprites["list"].index
|
||||
if index>=0
|
||||
pbCallTrainer(@trainers[index][0],@trainers[index][1])
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
@@ -1,136 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonJukebox_Scene
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbStartScene(commands)
|
||||
@commands = commands
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/jukeboxbg")
|
||||
@sprites["header"] = Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Jukebox"),2,-18,128,64,@viewport)
|
||||
@sprites["header"].baseColor = Color.new(248,248,248)
|
||||
@sprites["header"].shadowColor = Color.new(0,0,0)
|
||||
@sprites["header"].windowskin = nil
|
||||
@sprites["commands"] = Window_CommandPokemon.newWithSize(@commands,
|
||||
94,92,324,224,@viewport)
|
||||
@sprites["commands"].windowskin = nil
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbScene
|
||||
ret = -1
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::BACK)
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
ret = @sprites["commands"].index
|
||||
break
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbSetCommands(newcommands,newindex)
|
||||
@sprites["commands"].commands = (!newcommands) ? @commands : newcommands
|
||||
@sprites["commands"].index = newindex
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonJukeboxScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
commands = []
|
||||
cmdMarch = -1
|
||||
cmdLullaby = -1
|
||||
cmdOak = -1
|
||||
cmdCustom = -1
|
||||
commands[cmdMarch = commands.length] = _INTL("March")
|
||||
commands[cmdLullaby = commands.length] = _INTL("Lullaby")
|
||||
commands[cmdOak = commands.length] = _INTL("Oak")
|
||||
commands[cmdCustom = commands.length] = _INTL("Custom")
|
||||
commands[commands.length] = _INTL("Exit")
|
||||
@scene.pbStartScene(commands)
|
||||
loop do
|
||||
cmd = @scene.pbScene
|
||||
if cmd<0
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
elsif cmdMarch>=0 && cmd==cmdMarch
|
||||
pbPlayDecisionSE
|
||||
pbBGMPlay("Radio - March", 100, 100)
|
||||
$PokemonMap.whiteFluteUsed = true if $PokemonMap
|
||||
$PokemonMap.blackFluteUsed = false if $PokemonMap
|
||||
elsif cmdLullaby>=0 && cmd==cmdLullaby
|
||||
pbPlayDecisionSE
|
||||
pbBGMPlay("Radio - Lullaby", 100, 100)
|
||||
$PokemonMap.blackFluteUsed = true if $PokemonMap
|
||||
$PokemonMap.whiteFluteUsed = false if $PokemonMap
|
||||
elsif cmdOak>=0 && cmd==cmdOak
|
||||
pbPlayDecisionSE
|
||||
pbBGMPlay("Radio - Oak", 100, 100)
|
||||
$PokemonMap.whiteFluteUsed = false if $PokemonMap
|
||||
$PokemonMap.blackFluteUsed = false if $PokemonMap
|
||||
elsif cmdCustom>=0 && cmd==cmdCustom
|
||||
pbPlayDecisionSE
|
||||
files = [_INTL("(Default)")]
|
||||
Dir.chdir("Audio/BGM/") {
|
||||
Dir.glob("*.mp3") { |f| files.push(f) }
|
||||
Dir.glob("*.MP3") { |f| files.push(f) }
|
||||
Dir.glob("*.ogg") { |f| files.push(f) }
|
||||
Dir.glob("*.OGG") { |f| files.push(f) }
|
||||
Dir.glob("*.wav") { |f| files.push(f) }
|
||||
Dir.glob("*.WAV") { |f| files.push(f) }
|
||||
Dir.glob("*.mid") { |f| files.push(f) }
|
||||
Dir.glob("*.MID") { |f| files.push(f) }
|
||||
Dir.glob("*.midi") { |f| files.push(f) }
|
||||
Dir.glob("*.MIDI") { |f| files.push(f) }
|
||||
}
|
||||
@scene.pbSetCommands(files,0)
|
||||
loop do
|
||||
cmd2 = @scene.pbScene
|
||||
if cmd2<0
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif cmd2==0
|
||||
pbPlayDecisionSE
|
||||
$game_system.setDefaultBGM(nil)
|
||||
$PokemonMap.whiteFluteUsed = false if $PokemonMap
|
||||
$PokemonMap.blackFluteUsed = false if $PokemonMap
|
||||
else
|
||||
pbPlayDecisionSE
|
||||
$game_system.setDefaultBGM(files[cmd2])
|
||||
$PokemonMap.whiteFluteUsed = false if $PokemonMap
|
||||
$PokemonMap.blackFluteUsed = false if $PokemonMap
|
||||
end
|
||||
end
|
||||
@scene.pbSetCommands(nil,cmdCustom)
|
||||
else # Exit
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
end
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
@@ -1,161 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonTrainerCard_Scene
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbStartScene
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
|
||||
setCardBackground()
|
||||
|
||||
is_postgame = $game_switches[SWITCH_BEAT_THE_LEAGUE]
|
||||
overlay_version = is_postgame ? "overlay_postgame" : "overlay"
|
||||
|
||||
addBackgroundPlane(@sprites, "highlights", "Trainer Card/#{overlay_version}", @viewport)
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@sprites["trainer"] = IconSprite.new(336, 112, @viewport)
|
||||
@sprites["trainer"].setBitmapDirectly(generate_front_trainer_sprite_bitmap())
|
||||
|
||||
@sprites["trainer"].x -= (@sprites["trainer"].bitmap.width - 128) / 2
|
||||
@sprites["trainer"].y -= (@sprites["trainer"].bitmap.height - 128)
|
||||
@sprites["trainer"].z = 2
|
||||
pbDrawTrainerCardFront
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def setCardBackground()
|
||||
background_img = $Trainer.card_background ? $Trainer.card_background : "BLUE"
|
||||
background_img_path = "Graphics/Pictures/Trainer Card/backgrounds/#{background_img}"
|
||||
cardexists = pbResolveBitmap(sprintf(background_img_path))
|
||||
@sprites["card"] = IconSprite.new(0, 0, @viewport)
|
||||
|
||||
if cardexists
|
||||
@sprites["card"].setBitmap(background_img_path) if cardexists
|
||||
else
|
||||
@sprites["card"].setBitmap("Graphics/Pictures/Trainer Card/card")
|
||||
end
|
||||
@sprites["card"].z=-100
|
||||
end
|
||||
|
||||
def promptSwapBackground()
|
||||
$Trainer.unlocked_card_backgrounds = [] if !$Trainer.unlocked_card_backgrounds
|
||||
if $Trainer.unlocked_card_backgrounds.length >= 1
|
||||
if pbConfirmMessage("Swap your current Trainer Card background")
|
||||
chosen = pbListScreen("Trainer card", TrainerCardBackgroundLister.new($Trainer.unlocked_card_backgrounds))
|
||||
echoln chosen
|
||||
if chosen
|
||||
$Trainer.card_background = chosen
|
||||
pbSEPlay("GUI trainer card open")
|
||||
setCardBackground()
|
||||
end
|
||||
end
|
||||
else
|
||||
pbMessage("You can purchase new Trainer Card backgrounds at PokéMarts!")
|
||||
end
|
||||
end
|
||||
|
||||
def pbDrawTrainerCardFront
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
baseColor = Color.new(72, 72, 72)
|
||||
shadowColor = Color.new(160, 160, 160)
|
||||
totalsec = Graphics.frame_count / Graphics.frame_rate
|
||||
hour = totalsec / 60 / 60
|
||||
min = totalsec / 60 % 60
|
||||
time = (hour > 0) ? _INTL("{1}h {2}m", hour, min) : _INTL("{1}m", min)
|
||||
$PokemonGlobal.startTime = pbGetTimeNow if !$PokemonGlobal.startTime
|
||||
starttime = _INTL("{1} {2}, {3}",
|
||||
pbGetAbbrevMonthName($PokemonGlobal.startTime.mon),
|
||||
$PokemonGlobal.startTime.day,
|
||||
$PokemonGlobal.startTime.year)
|
||||
textPositions = [
|
||||
[_INTL("Name"), 34, 58, 0, baseColor, shadowColor],
|
||||
[$Trainer.name, 302, 58, 1, baseColor, shadowColor],
|
||||
[_INTL("ID No."), 332, 58, 0, baseColor, shadowColor],
|
||||
[sprintf("%05d", $Trainer.public_ID), 468, 58, 1, baseColor, shadowColor],
|
||||
[_INTL("Money"), 34, 106, 0, baseColor, shadowColor],
|
||||
[_INTL("${1}", $Trainer.money.to_s_formatted), 302, 106, 1, baseColor, shadowColor],
|
||||
[_INTL("Pokédex"), 34, 154, 0, baseColor, shadowColor],
|
||||
[sprintf("%d/%d", $Trainer.pokedex.owned_count, $Trainer.pokedex.seen_count), 302, 154, 1, baseColor, shadowColor],
|
||||
[_INTL("Time"), 34, 202, 0, baseColor, shadowColor],
|
||||
[time, 302, 202, 1, baseColor, shadowColor],
|
||||
[_INTL("Started"), 34, 250, 0, baseColor, shadowColor],
|
||||
[starttime, 302, 250, 1, baseColor, shadowColor]
|
||||
]
|
||||
pbDrawTextPositions(overlay, textPositions)
|
||||
x = 72
|
||||
imagePositions = []
|
||||
postgame = $game_switches[SWITCH_BEAT_THE_LEAGUE]
|
||||
numberOfBadgesDisplayed = postgame ? 16 : 8
|
||||
for i in 0...numberOfBadgesDisplayed
|
||||
badgeRow = i < 8 ? 0 : 1
|
||||
if $Trainer.badges[i]
|
||||
if i == 8
|
||||
x = 72
|
||||
end
|
||||
badge_graphic_x = badgeRow == 0 ? i * 32 : (i - 8) * 32
|
||||
badge_graphic_y = badgeRow * 32
|
||||
y = getBadgeDisplayHeight(postgame, i)
|
||||
imagePositions.push(["Graphics/Pictures/Trainer Card/icon_badges", x, y, badge_graphic_x, badge_graphic_y, 32, 32])
|
||||
end
|
||||
x += 48
|
||||
end
|
||||
pbDrawImagePositions(overlay, imagePositions)
|
||||
end
|
||||
|
||||
def getBadgeDisplayHeight(postgame, i)
|
||||
if postgame
|
||||
if i < 8
|
||||
y = 310
|
||||
else
|
||||
y = 344
|
||||
end
|
||||
else
|
||||
y = 312
|
||||
end
|
||||
return y
|
||||
end
|
||||
|
||||
def pbTrainerCard
|
||||
pbSEPlay("GUI trainer card open")
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::USE)
|
||||
promptSwapBackground()
|
||||
end
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonTrainerCardScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
@scene.pbStartScene
|
||||
@scene.pbTrainerCard
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
@@ -1,374 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonLoadPanel < SpriteWrapper
|
||||
attr_reader :selected
|
||||
|
||||
TEXTCOLOR = Color.new(232,232,232)
|
||||
TEXTSHADOWCOLOR = Color.new(136,136,136)
|
||||
MALETEXTCOLOR = Color.new(56,160,248)
|
||||
MALETEXTSHADOWCOLOR = Color.new(56,104,168)
|
||||
FEMALETEXTCOLOR = Color.new(240,72,88)
|
||||
FEMALETEXTSHADOWCOLOR = Color.new(160,64,64)
|
||||
|
||||
def initialize(index,title,isContinue,trainer,framecount,mapid,viewport=nil)
|
||||
super(viewport)
|
||||
@index = index
|
||||
@title = title
|
||||
@isContinue = isContinue
|
||||
@trainer = trainer
|
||||
@totalsec = (framecount || 0) / Graphics.frame_rate
|
||||
@mapid = mapid
|
||||
@selected = (index==0)
|
||||
@bgbitmap = AnimatedBitmap.new("Graphics/Pictures/loadPanels")
|
||||
@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 = BitmapWrapper.new(@bgbitmap.width,111*2)
|
||||
pbSetSystemFont(self.bitmap)
|
||||
end
|
||||
if @refreshBitmap
|
||||
@refreshBitmap = false
|
||||
self.bitmap.clear if self.bitmap
|
||||
if @isContinue
|
||||
self.bitmap.blt(0,0,@bgbitmap.bitmap,Rect.new(0,(@selected) ? 111*2 : 0,@bgbitmap.width,111*2))
|
||||
else
|
||||
self.bitmap.blt(0,0,@bgbitmap.bitmap,Rect.new(0,111*2*2+((@selected) ? 23*2 : 0),@bgbitmap.width,23*2))
|
||||
end
|
||||
textpos = []
|
||||
if @isContinue
|
||||
textpos.push([@title,16*2,2*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
textpos.push([_INTL("Badges:"),16*2,53*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
textpos.push([@trainer.badge_count.to_s,103*2,53*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
# textpos.push([_INTL("Pokédex:"),16*2,69*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
# textpos.push([@trainer.pokedex.seen_count.to_s,103*2,69*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
|
||||
textpos.push([_INTL(getDisplayDifficultyFromIndex(@trainer.lowest_difficulty)),16*2,69*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
textpos.push([getGameModeFromIndex(@trainer.game_mode),103*2,69*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
|
||||
textpos.push([_INTL("Time:"),16*2,85*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
hour = @totalsec / 60 / 60
|
||||
min = @totalsec / 60 % 60
|
||||
if hour>0
|
||||
textpos.push([_INTL("{1}h {2}m",hour,min),103*2,85*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
else
|
||||
textpos.push([_INTL("{1}m",min),103*2,85*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
end
|
||||
if @trainer.male?
|
||||
textpos.push([@trainer.name,56*2,29*2,0,MALETEXTCOLOR,MALETEXTSHADOWCOLOR])
|
||||
elsif @trainer.female?
|
||||
textpos.push([@trainer.name,56*2,29*2,0,FEMALETEXTCOLOR,FEMALETEXTSHADOWCOLOR])
|
||||
else
|
||||
textpos.push([@trainer.name,56*2,29*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
end
|
||||
mapname = pbGetMapNameFromId(@mapid)
|
||||
mapname.gsub!(/\\PN/,@trainer.name)
|
||||
textpos.push([mapname,193*2,2*2,1,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
else
|
||||
textpos.push([@title,16*2,1*2,0,TEXTCOLOR,TEXTSHADOWCOLOR])
|
||||
end
|
||||
pbDrawTextPositions(self.bitmap,textpos)
|
||||
end
|
||||
@refreshing = false
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonLoad_Scene
|
||||
def pbStartScene(commands, show_continue, trainer, frame_count, map_id)
|
||||
@commands = commands
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99998
|
||||
addBackgroundOrColoredPlane(@sprites,"background","loadbg",Color.new(248,248,248),@viewport)
|
||||
y = 16*2
|
||||
for i in 0...commands.length
|
||||
@sprites["panel#{i}"] = PokemonLoadPanel.new(i,commands[i],
|
||||
(show_continue) ? (i==0) : false,trainer,frame_count,map_id,@viewport)
|
||||
@sprites["panel#{i}"].x = 24*2
|
||||
@sprites["panel#{i}"].y = y
|
||||
@sprites["panel#{i}"].pbRefresh
|
||||
y += (show_continue && i==0) ? 112*2 : 24*2
|
||||
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","loadbg",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-40*2
|
||||
for i in 0...@commands.length
|
||||
@sprites["panel#{i}"].y -= 24*2
|
||||
end
|
||||
for i in 0...6
|
||||
break if !@sprites["party#{i}"]
|
||||
@sprites["party#{i}"].y -= 24*2
|
||||
end
|
||||
@sprites["player"].y -= 24*2 if @sprites["player"]
|
||||
end
|
||||
while @sprites["panel#{newi}"].y<16*2
|
||||
for i in 0...@commands.length
|
||||
@sprites["panel#{i}"].y += 24*2
|
||||
end
|
||||
for i in 0...6
|
||||
break if !@sprites["party#{i}"]
|
||||
@sprites["party#{i}"].y += 24*2
|
||||
end
|
||||
@sprites["player"].y += 24*2 if @sprites["player"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbSetParty(trainer)
|
||||
return if !trainer || !trainer.party
|
||||
meta = GameData::Metadata.get_player(trainer.character_ID)
|
||||
if meta
|
||||
filename = pbGetPlayerCharset(meta,1,trainer,true)
|
||||
@sprites["player"] = TrainerWalkingCharSprite.new(filename,@viewport,trainer)
|
||||
charwidth = @sprites["player"].bitmap.width
|
||||
charheight = @sprites["player"].bitmap.height
|
||||
@sprites["player"].x = 56*2-charwidth/8
|
||||
@sprites["player"].y = 56*2-charheight/8
|
||||
@sprites["player"].src_rect = Rect.new(0,0,charwidth/4,charheight/4)
|
||||
end
|
||||
for i in 0...trainer.party.length
|
||||
@sprites["party#{i}"] = PokemonIconSprite.new(trainer.party[i],@viewport)
|
||||
@sprites["party#{i}"].setOffset(PictureOrigin::Center)
|
||||
@sprites["party#{i}"].x = (167+33*(i%2))*2
|
||||
@sprites["party#{i}"].y = (56+25*(i/2))*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.'))
|
||||
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
|
||||
|
||||
|
||||
#todo
|
||||
def copyKeybindings
|
||||
#return
|
||||
keybinding_path = "Data/"
|
||||
keybinding_fileName="keybindings.mkxp1"
|
||||
|
||||
srcPath = keybinding_path+keybinding_fileName
|
||||
destPath = System.data_directory + keybinding_fileName
|
||||
if !File.file?(destPath)
|
||||
File.copy(srcPath,destPath)
|
||||
print("New default controls for controllers were copied. Please re-launch the game to enable them.")
|
||||
end
|
||||
end
|
||||
|
||||
def pbStartLoadScreen
|
||||
copyKeybindings()
|
||||
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?
|
||||
new_game_plus = show_continue && (@save_data[:player].new_game_plus_unlocked || $DEBUG)
|
||||
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')
|
||||
if new_game_plus
|
||||
commands[cmd_new_game_plus = commands.length] = _INTL('New Game +')
|
||||
end
|
||||
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[:frame_count] || 0, 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_new_game_plus
|
||||
@scene.pbEndScene
|
||||
Game.start_new(@save_data[:bag],@save_data[:storage_system],@save_data[:player])
|
||||
@save_data[:player].new_game_plus_unlocked=true
|
||||
return
|
||||
when cmd_mystery_gift
|
||||
pbFadeOutIn { pbDownloadMysteryGift(@save_data[:player]) }
|
||||
when cmd_options
|
||||
pbFadeOutIn do
|
||||
scene = PokemonGameOption_Scene.new
|
||||
screen = PokemonOptionScreen.new(scene)
|
||||
screen.pbStartScreen(true)
|
||||
end
|
||||
when cmd_language
|
||||
@scene.pbEndScene
|
||||
$PokemonSystem.language = pbChooseLanguage
|
||||
pbLoadMessages('Data/' + 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
|
||||
@@ -1,129 +0,0 @@
|
||||
# @deprecated Use {Game.save} instead. pbSave is slated to be removed in v20.
|
||||
def pbSave(safesave = false)
|
||||
Deprecation.warn_method('pbSave', 'v20', 'Game.save')
|
||||
Game.save(safe: safesave)
|
||||
end
|
||||
|
||||
def pbEmergencySave
|
||||
oldscene = $scene
|
||||
$scene = nil
|
||||
pbMessage(_INTL("The script is taking too long. The game will restart."))
|
||||
return if !$Trainer
|
||||
if SaveData.exists?
|
||||
File.open(SaveData::FILE_PATH, 'rb') do |r|
|
||||
File.open(SaveData::FILE_PATH + '.bak', 'wb') do |w|
|
||||
while s = r.read(4096)
|
||||
w.write s
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
if Game.save
|
||||
pbMessage(_INTL("\\se[]The game was saved.\\me[GUI save game] The previous save file has been backed up.\\wtnp[30]"))
|
||||
else
|
||||
pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
|
||||
end
|
||||
$scene = oldscene
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonSave_Scene
|
||||
def pbStartScreen
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
@sprites={}
|
||||
totalsec = Graphics.frame_count / Graphics.frame_rate
|
||||
hour = totalsec / 60 / 60
|
||||
min = totalsec / 60 % 60
|
||||
mapname=$game_map.name
|
||||
textColor = ["0070F8,78B8E8","E82010,F8A8B8","0070F8,78B8E8"][$Trainer.gender]
|
||||
locationColor = "209808,90F090" # green
|
||||
loctext=_INTL("<ac><c3={1}>{2}</c3></ac>",locationColor,mapname)
|
||||
loctext+=_INTL("Player<r><c3={1}>{2}</c3><br>",textColor,$Trainer.name)
|
||||
if hour>0
|
||||
loctext+=_INTL("Time<r><c3={1}>{2}h {3}m</c3><br>",textColor,hour,min)
|
||||
else
|
||||
loctext+=_INTL("Time<r><c3={1}>{2}m</c3><br>",textColor,min)
|
||||
end
|
||||
loctext+=_INTL("Badges<r><c3={1}>{2}</c3><br>",textColor,$Trainer.badge_count)
|
||||
if $Trainer.has_pokedex
|
||||
loctext+=_INTL("Pokédex<r><c3={1}>{2}/{3}</c3>",textColor,$Trainer.pokedex.owned_count,$Trainer.pokedex.seen_count)
|
||||
end
|
||||
|
||||
@sprites["locwindow"]=Window_AdvancedTextPokemon.new(loctext)
|
||||
@sprites["locwindow"].viewport=@viewport
|
||||
@sprites["locwindow"].x=0
|
||||
@sprites["locwindow"].y=0
|
||||
@sprites["locwindow"].width=228 if @sprites["locwindow"].width<228
|
||||
@sprites["locwindow"].visible=true
|
||||
end
|
||||
|
||||
def pbEndScreen
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonSaveScreen
|
||||
def initialize(scene)
|
||||
@scene=scene
|
||||
end
|
||||
|
||||
def pbDisplay(text,brief=false)
|
||||
@scene.pbDisplay(text,brief)
|
||||
end
|
||||
|
||||
def pbDisplayPaused(text)
|
||||
@scene.pbDisplayPaused(text)
|
||||
end
|
||||
|
||||
def pbConfirm(text)
|
||||
return @scene.pbConfirm(text)
|
||||
end
|
||||
|
||||
def pbSaveScreen
|
||||
ret = false
|
||||
@scene.pbStartScreen
|
||||
if pbConfirmMessage(_INTL('Would you like to save the game?'))
|
||||
if SaveData.exists? && $PokemonTemp.begunNewGame
|
||||
pbMessage(_INTL('WARNING!'))
|
||||
pbMessage(_INTL('There is a different game file that is already saved.'))
|
||||
pbMessage(_INTL("If you save now, the other file's adventure, including items and Pokémon, will be entirely lost."))
|
||||
if !pbConfirmMessageSerious(
|
||||
_INTL('Are you sure you want to save now and overwrite the other save file?'))
|
||||
pbSEPlay('GUI save choice')
|
||||
@scene.pbEndScreen
|
||||
return false
|
||||
end
|
||||
end
|
||||
$PokemonTemp.begunNewGame = false
|
||||
pbSEPlay('GUI save choice')
|
||||
if Game.save
|
||||
pbMessage(_INTL("\\se[]{1} saved the game.\\me[GUI save game]\\wtnp[30]", $Trainer.name))
|
||||
ret = true
|
||||
else
|
||||
pbMessage(_INTL("\\se[]Save failed.\\wtnp[30]"))
|
||||
ret = false
|
||||
end
|
||||
else
|
||||
pbSEPlay('GUI save choice')
|
||||
end
|
||||
@scene.pbEndScreen
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbSaveScreen
|
||||
scene = PokemonSave_Scene.new
|
||||
screen = PokemonSaveScreen.new(scene)
|
||||
ret = screen.pbSaveScreen
|
||||
return ret
|
||||
end
|
||||
@@ -1,531 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonSystem
|
||||
attr_accessor :textspeed
|
||||
attr_accessor :battlescene
|
||||
attr_accessor :battlestyle
|
||||
attr_accessor :frame
|
||||
attr_accessor :textskin
|
||||
attr_accessor :screensize
|
||||
attr_accessor :language
|
||||
attr_accessor :runstyle
|
||||
attr_accessor :bgmvolume
|
||||
attr_accessor :sevolume
|
||||
attr_accessor :textinput
|
||||
attr_accessor :quicksurf
|
||||
attr_accessor :level_caps
|
||||
attr_accessor :battle_type
|
||||
attr_accessor :download_sprites
|
||||
attr_accessor :speedup
|
||||
attr_accessor :speedup_speed
|
||||
attr_accessor :max_nb_sprites_download
|
||||
attr_accessor :on_mobile
|
||||
attr_accessor :type_icons
|
||||
attr_accessor :use_generated_dex_entries
|
||||
attr_accessor :use_custom_eggs
|
||||
|
||||
def initialize
|
||||
@textspeed = 1 # Text speed (0=slow, 1=normal, 2=fast)
|
||||
@battlescene = 0 # Battle effects (animations) (0=on, 1=off)
|
||||
@battlestyle = 0 # Battle style (0=switch, 1=set)
|
||||
@frame = 0 # Default window frame (see also Settings::MENU_WINDOWSKINS)
|
||||
@textskin = 0 # Speech frame
|
||||
@screensize = (Settings::SCREEN_SCALE * 2).floor - 1 # 0=half size, 1=full size, 2=full-and-a-half size, 3=double size
|
||||
@language = 0 # Language (see also Settings::LANGUAGES in script PokemonSystem)
|
||||
@runstyle = 0 # Default movement speed (0=walk, 1=run)
|
||||
@bgmvolume = 40 # Volume of background music and ME
|
||||
@sevolume = 40 # Volume of sound effects
|
||||
@textinput = 1 # Text input mode (0=cursor, 1=keyboard)
|
||||
@quicksurf = 0
|
||||
@battle_type = 0
|
||||
@speedup = 0 #0= hold, 1=toggle
|
||||
@speedup_speed = 3 #for hold only
|
||||
@download_sprites = 0
|
||||
@max_nb_sprites_download = 5
|
||||
@on_mobile = false
|
||||
@type_icons = true
|
||||
@use_generated_dex_entries = true
|
||||
@use_custom_eggs = true
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
module PropertyMixin
|
||||
def get
|
||||
(@getProc) ? @getProc.call : nil
|
||||
end
|
||||
|
||||
def set(value)
|
||||
@setProc.call(value) if @setProc
|
||||
end
|
||||
end
|
||||
|
||||
class Option
|
||||
attr_reader :description
|
||||
|
||||
def initialize(description)
|
||||
@description = description
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class EnumOption < Option
|
||||
include PropertyMixin
|
||||
attr_reader :values
|
||||
attr_reader :name
|
||||
|
||||
def initialize(name, options, getProc, setProc, description = "")
|
||||
super(description)
|
||||
@name = name
|
||||
@values = options
|
||||
@getProc = getProc
|
||||
@setProc = setProc
|
||||
end
|
||||
|
||||
def next(current)
|
||||
index = current + 1
|
||||
index = @values.length - 1 if index > @values.length - 1
|
||||
return index
|
||||
end
|
||||
|
||||
def prev(current)
|
||||
index = current - 1
|
||||
index = 0 if index < 0
|
||||
return index
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class EnumOption2
|
||||
include PropertyMixin
|
||||
attr_reader :values
|
||||
attr_reader :name
|
||||
|
||||
def initialize(name, options, getProc, setProc)
|
||||
@name = name
|
||||
@values = options
|
||||
@getProc = getProc
|
||||
@setProc = setProc
|
||||
end
|
||||
|
||||
def next(current)
|
||||
index = current + 1
|
||||
index = @values.length - 1 if index > @values.length - 1
|
||||
return index
|
||||
end
|
||||
|
||||
def prev(current)
|
||||
index = current - 1
|
||||
index = 0 if index < 0
|
||||
return index
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class NumberOption < Option
|
||||
include PropertyMixin
|
||||
attr_reader :name
|
||||
attr_reader :optstart
|
||||
attr_reader :optend
|
||||
|
||||
def initialize(name, optstart, optend, getProc, setProc, description="")
|
||||
super(description)
|
||||
@name = name
|
||||
@optstart = optstart
|
||||
@optend = optend
|
||||
@getProc = getProc
|
||||
@setProc = setProc
|
||||
end
|
||||
|
||||
def next(current)
|
||||
index = current + @optstart
|
||||
index += 1
|
||||
index = @optstart if index > @optend
|
||||
return index - @optstart
|
||||
end
|
||||
|
||||
def prev(current)
|
||||
index = current + @optstart
|
||||
index -= 1
|
||||
index = @optend if index < @optstart
|
||||
return index - @optstart
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SliderOption < Option
|
||||
include PropertyMixin
|
||||
attr_reader :name
|
||||
attr_reader :optstart
|
||||
attr_reader :optend
|
||||
|
||||
def initialize(name, optstart, optend, optinterval, getProc, setProc, description = "")
|
||||
super(description)
|
||||
@name = name
|
||||
@optstart = optstart
|
||||
@optend = optend
|
||||
@optinterval = optinterval
|
||||
@getProc = getProc
|
||||
@setProc = setProc
|
||||
end
|
||||
|
||||
def next(current)
|
||||
index = current + @optstart
|
||||
index += @optinterval
|
||||
index = @optend if index > @optend
|
||||
return index - @optstart
|
||||
end
|
||||
|
||||
def prev(current)
|
||||
index = current + @optstart
|
||||
index -= @optinterval
|
||||
index = @optstart if index < @optstart
|
||||
return index - @optstart
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Main options list
|
||||
#===============================================================================
|
||||
class Window_PokemonOption < Window_DrawableCommand
|
||||
attr_reader :mustUpdateOptions
|
||||
attr_reader :mustUpdateDescription
|
||||
attr_reader :selected_position
|
||||
|
||||
def initialize(options, x, y, width, height)
|
||||
@previous_Index = 0
|
||||
@options = options
|
||||
@nameBaseColor = Color.new(24 * 8, 15 * 8, 0)
|
||||
@nameShadowColor = Color.new(31 * 8, 22 * 8, 10 * 8)
|
||||
@selBaseColor = Color.new(31 * 8, 6 * 8, 3 * 8)
|
||||
@selShadowColor = Color.new(31 * 8, 17 * 8, 16 * 8)
|
||||
@optvalues = []
|
||||
@mustUpdateOptions = false
|
||||
@mustUpdateDescription = false
|
||||
@selected_position = 0
|
||||
@allow_arrows_jump = false
|
||||
@is_first_update = true
|
||||
for i in 0...@options.length
|
||||
@optvalues[i] = 0
|
||||
end
|
||||
super(x, y, width, height)
|
||||
end
|
||||
|
||||
def changedPosition
|
||||
@mustUpdateDescription = true
|
||||
super
|
||||
end
|
||||
|
||||
def descriptionUpdated
|
||||
@mustUpdateDescription = false
|
||||
end
|
||||
|
||||
def nameBaseColor=(value)
|
||||
@nameBaseColor = value
|
||||
end
|
||||
|
||||
def nameShadowColor=(value)
|
||||
@nameShadowColor = value
|
||||
end
|
||||
|
||||
def [](i)
|
||||
return @optvalues[i]
|
||||
end
|
||||
|
||||
def []=(i, value)
|
||||
@optvalues[i] = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def setValueNoRefresh(i, value)
|
||||
@optvalues[i] = value
|
||||
end
|
||||
|
||||
def itemCount
|
||||
return @options.length + 1
|
||||
end
|
||||
|
||||
def dont_draw_item(index)
|
||||
return false
|
||||
end
|
||||
|
||||
def drawItem(index, _count, rect)
|
||||
return if dont_draw_item(index)
|
||||
rect = drawCursor(index, rect)
|
||||
optionname = (index == @options.length) ? _INTL("Confirm") : @options[index].name
|
||||
optionwidth = rect.width * 9 / 20
|
||||
pbDrawShadowText(self.contents, rect.x, rect.y, optionwidth, rect.height, optionname,
|
||||
@nameBaseColor, @nameShadowColor)
|
||||
return if index == @options.length
|
||||
if @options[index].is_a?(EnumOption)
|
||||
if @options[index].values.length > 1
|
||||
totalwidth = 0
|
||||
for value in @options[index].values
|
||||
totalwidth += self.contents.text_size(value).width
|
||||
end
|
||||
spacing = (optionwidth - totalwidth) / (@options[index].values.length - 1)
|
||||
spacing = 0 if spacing < 0
|
||||
xpos = optionwidth + rect.x
|
||||
ivalue = 0
|
||||
for value in @options[index].values
|
||||
pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value,
|
||||
(ivalue == self[index]) ? @selBaseColor : self.baseColor,
|
||||
(ivalue == self[index]) ? @selShadowColor : self.shadowColor
|
||||
)
|
||||
xpos += self.contents.text_size(value).width
|
||||
xpos += spacing
|
||||
ivalue += 1
|
||||
end
|
||||
else
|
||||
pbDrawShadowText(self.contents, rect.x + optionwidth, rect.y, optionwidth, rect.height,
|
||||
optionname, self.baseColor, self.shadowColor)
|
||||
end
|
||||
elsif @options[index].is_a?(NumberOption)
|
||||
value = _INTL("Type {1}/{2}", @options[index].optstart + self[index],
|
||||
@options[index].optend - @options[index].optstart + 1)
|
||||
xpos = optionwidth + rect.x
|
||||
pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value,
|
||||
@selBaseColor, @selShadowColor)
|
||||
elsif @options[index].is_a?(SliderOption)
|
||||
value = sprintf(" %d", @options[index].optend)
|
||||
sliderlength = optionwidth - self.contents.text_size(value).width
|
||||
xpos = optionwidth + rect.x
|
||||
self.contents.fill_rect(xpos, rect.y - 2 + rect.height / 2,
|
||||
optionwidth - self.contents.text_size(value).width, 4, self.baseColor)
|
||||
self.contents.fill_rect(
|
||||
xpos + (sliderlength - 8) * (@options[index].optstart + self[index]) / @options[index].optend,
|
||||
rect.y - 8 + rect.height / 2,
|
||||
8, 16, @selBaseColor)
|
||||
value = sprintf("%d", @options[index].optstart + self[index])
|
||||
xpos += optionwidth - self.contents.text_size(value).width
|
||||
pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value,
|
||||
@selBaseColor, @selShadowColor)
|
||||
else
|
||||
value = @options[index].values[self[index]]
|
||||
xpos = optionwidth + rect.x
|
||||
pbDrawShadowText(self.contents, xpos, rect.y, optionwidth, rect.height, value,
|
||||
@selBaseColor, @selShadowColor)
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
oldindex = self.index
|
||||
@mustUpdateOptions = false
|
||||
super
|
||||
|
||||
if @is_first_update
|
||||
# Needed for displaying the description of the initially selected option correctly
|
||||
@selected_position = self[self.index]
|
||||
@mustUpdateOptions = true
|
||||
@mustUpdateDescription = true
|
||||
@is_first_update = false
|
||||
refresh
|
||||
return
|
||||
end
|
||||
|
||||
if self.active && self.index < @options.length
|
||||
if Input.repeat?(Input::LEFT)
|
||||
self[self.index] = @options[self.index].prev(self[self.index])
|
||||
@selected_position = self[self.index]
|
||||
@mustUpdateOptions = true
|
||||
@mustUpdateDescription = true
|
||||
refresh if self[self.index]
|
||||
return
|
||||
end
|
||||
if Input.repeat?(Input::RIGHT)
|
||||
self[self.index] = @options[self.index].next(self[self.index])
|
||||
@selected_position = self[self.index]
|
||||
@mustUpdateOptions = true
|
||||
@mustUpdateDescription = true
|
||||
refresh
|
||||
return
|
||||
end
|
||||
if Input.repeat?(Input::UP) || Input.repeat?(Input::DOWN)
|
||||
@selected_position = self[self.index]
|
||||
@mustUpdateOptions = true
|
||||
@mustUpdateDescription = true
|
||||
refresh
|
||||
return
|
||||
end
|
||||
end
|
||||
refresh if (self.index != oldindex)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Options main screen
|
||||
#===============================================================================
|
||||
class PokemonOption_Scene
|
||||
def getDefaultDescription
|
||||
return _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin)
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
if @sprites["option"].mustUpdateDescription
|
||||
updateDescription(@sprites["option"].index)
|
||||
@sprites["option"].descriptionUpdated
|
||||
end
|
||||
end
|
||||
|
||||
def initialize
|
||||
@autosave_menu = false
|
||||
@manually_changed_difficulty=false
|
||||
end
|
||||
|
||||
def initUIElements
|
||||
@sprites["title"] = Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Options"), 0, 0, Graphics.width, 64, @viewport)
|
||||
@sprites["textbox"] = pbCreateMessageWindow
|
||||
@sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin)
|
||||
@sprites["textbox"].letterbyletter = false
|
||||
pbSetSystemFont(@sprites["textbox"].contents)
|
||||
end
|
||||
|
||||
def pbStartScene(inloadscreen = false)
|
||||
@sprites = {}
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
initUIElements
|
||||
# These are the different options in the game. To add an option, define a
|
||||
# setter and a getter for that option. To delete an option, comment it out
|
||||
# or delete it. The game's options may be placed in any order.
|
||||
@PokemonOptions = pbGetOptions(inloadscreen)
|
||||
@PokemonOptions = pbAddOnOptions(@PokemonOptions)
|
||||
@sprites["option"] = initOptionsWindow
|
||||
# Get the values of each option
|
||||
for i in 0...@PokemonOptions.length
|
||||
@sprites["option"].setValueNoRefresh(i, (@PokemonOptions[i].get || 0))
|
||||
end
|
||||
@sprites["option"].refresh
|
||||
pbDeactivateWindows(@sprites)
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def initOptionsWindow
|
||||
optionsWindow = Window_PokemonOption.new(@PokemonOptions, 0,
|
||||
@sprites["title"].height, Graphics.width,
|
||||
Graphics.height - @sprites["title"].height - @sprites["textbox"].height)
|
||||
optionsWindow.viewport = @viewport
|
||||
optionsWindow.visible = true
|
||||
return optionsWindow
|
||||
end
|
||||
|
||||
def updateDescription(index)
|
||||
index = 0 if !index
|
||||
begin
|
||||
horizontal_position = @sprites["option"].selected_position
|
||||
optionDescription = @PokemonOptions[index].description
|
||||
if optionDescription.is_a?(Array)
|
||||
if horizontal_position < optionDescription.size
|
||||
new_description = optionDescription[horizontal_position]
|
||||
else
|
||||
new_description = getDefaultDescription
|
||||
end
|
||||
else
|
||||
new_description = optionDescription
|
||||
end
|
||||
|
||||
new_description = getDefaultDescription if new_description == ""
|
||||
@sprites["textbox"].text = _INTL(new_description)
|
||||
rescue
|
||||
@sprites["textbox"].text = getDefaultDescription
|
||||
end
|
||||
end
|
||||
|
||||
#IMPLEMENT IN INHERITED CLASSES
|
||||
def pbGetOptions(inloadscreen = false)
|
||||
options = []
|
||||
return options
|
||||
end
|
||||
|
||||
def pbAddOnOptions(options)
|
||||
return options
|
||||
end
|
||||
|
||||
def openAutosaveMenu()
|
||||
return if !@autosave_menu
|
||||
pbFadeOutIn {
|
||||
scene = AutosaveOptionsScene.new
|
||||
screen = PokemonOptionScreen.new(scene)
|
||||
screen.pbStartScreen
|
||||
}
|
||||
@autosave_menu = false
|
||||
end
|
||||
|
||||
def pbOptions
|
||||
oldSystemSkin = $PokemonSystem.frame # Menu
|
||||
oldTextSkin = $PokemonSystem.textskin # Speech
|
||||
pbActivateWindow(@sprites, "option") {
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if @sprites["option"].mustUpdateOptions
|
||||
# Set the values of each option
|
||||
for i in 0...@PokemonOptions.length
|
||||
@PokemonOptions[i].set(@sprites["option"][i])
|
||||
end
|
||||
if $PokemonSystem.textskin != oldTextSkin
|
||||
@sprites["textbox"].setSkin(MessageConfig.pbGetSpeechFrame())
|
||||
@sprites["textbox"].text = _INTL("Speech frame {1}.", 1 + $PokemonSystem.textskin)
|
||||
oldTextSkin = $PokemonSystem.textskin
|
||||
end
|
||||
if $PokemonSystem.frame != oldSystemSkin
|
||||
@sprites["title"].setSkin(MessageConfig.pbGetSystemFrame())
|
||||
@sprites["option"].setSkin(MessageConfig.pbGetSystemFrame())
|
||||
oldSystemSkin = $PokemonSystem.frame
|
||||
end
|
||||
end
|
||||
if Input.trigger?(Input::BACK)
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
break if isConfirmedOnKeyPress
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def isConfirmedOnKeyPress
|
||||
return @sprites["option"].index == @PokemonOptions.length
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbPlayCloseMenuSE
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
# Set the values of each option
|
||||
for i in 0...@PokemonOptions.length
|
||||
@PokemonOptions[i].set(@sprites["option"][i])
|
||||
end
|
||||
pbDisposeMessageWindow(@sprites["textbox"])
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
pbRefreshSceneMap
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonOptionScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbStartScreen(inloadscreen = false)
|
||||
@scene.pbStartScene(inloadscreen)
|
||||
@scene.pbOptions
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
@@ -1,327 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class ReadyMenuButton < SpriteWrapper
|
||||
attr_reader :index # ID of button
|
||||
attr_reader :selected
|
||||
attr_reader :side
|
||||
|
||||
def initialize(index,command,selected,side,viewport=nil)
|
||||
super(viewport)
|
||||
@index = index
|
||||
@command = command # Item/move ID, name, mode (T move/F item), pkmnIndex
|
||||
@selected = selected
|
||||
@side = side
|
||||
if @command[2]
|
||||
@button = AnimatedBitmap.new("Graphics/Pictures/Ready Menu/icon_movebutton")
|
||||
else
|
||||
@button = AnimatedBitmap.new("Graphics/Pictures/Ready Menu/icon_itembutton")
|
||||
end
|
||||
@contents = BitmapWrapper.new(@button.width,@button.height/2)
|
||||
self.bitmap = @contents
|
||||
pbSetSystemFont(self.bitmap)
|
||||
if @command[2]
|
||||
@icon = PokemonIconSprite.new($Trainer.party[@command[3]],viewport)
|
||||
@icon.setOffset(PictureOrigin::Center)
|
||||
else
|
||||
@icon = ItemIconSprite.new(0,0,@command[0],viewport)
|
||||
end
|
||||
@icon.z = self.z+1
|
||||
refresh
|
||||
end
|
||||
|
||||
def dispose
|
||||
@button.dispose
|
||||
@contents.dispose
|
||||
@icon.dispose
|
||||
super
|
||||
end
|
||||
|
||||
def visible=(val)
|
||||
@icon.visible = val
|
||||
super(val)
|
||||
end
|
||||
|
||||
def selected=(val)
|
||||
oldsel = @selected
|
||||
@selected = val
|
||||
refresh if oldsel!=val
|
||||
end
|
||||
|
||||
def side=(val)
|
||||
oldsel = @side
|
||||
@side = val
|
||||
refresh if oldsel!=val
|
||||
end
|
||||
|
||||
def refresh
|
||||
sel = (@selected==@index && (@side==0)==@command[2])
|
||||
self.y = (Graphics.height-@button.height/2)/2 - (@selected-@index)*(@button.height/2+4)
|
||||
if @command[2] # Pokémon
|
||||
self.x = (sel) ? 0 : -16
|
||||
@icon.x = self.x+52
|
||||
@icon.y = self.y+32
|
||||
else # Item
|
||||
self.x = (sel) ? Graphics.width-@button.width : Graphics.width+16-@button.width
|
||||
@icon.x = self.x+32
|
||||
@icon.y = self.y+@button.height/4
|
||||
end
|
||||
self.bitmap.clear
|
||||
rect = Rect.new(0,(sel) ? @button.height/2 : 0,@button.width,@button.height/2)
|
||||
self.bitmap.blt(0,0,@button.bitmap,rect)
|
||||
textx = (@command[2]) ? 164 : (GameData::Item.get(@command[0]).is_important?) ? 146 : 124
|
||||
textpos = [
|
||||
[@command[1],textx,16,2,Color.new(248,248,248),Color.new(40,40,40),1],
|
||||
]
|
||||
if !@command[2]
|
||||
if !GameData::Item.get(@command[0]).is_important?
|
||||
qty = $PokemonBag.pbQuantity(@command[0])
|
||||
if qty>99
|
||||
textpos.push([_INTL(">99"),230,16,1,
|
||||
Color.new(248,248,248),Color.new(40,40,40),1])
|
||||
else
|
||||
textpos.push([_INTL("x{1}",qty),230,16,1,
|
||||
Color.new(248,248,248),Color.new(40,40,40),1])
|
||||
end
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(self.bitmap,textpos)
|
||||
end
|
||||
|
||||
def update
|
||||
@icon.update if @icon
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonReadyMenu_Scene
|
||||
attr_reader :sprites
|
||||
|
||||
def pbStartScene(commands)
|
||||
@commands = commands
|
||||
@movecommands = []
|
||||
@itemcommands = []
|
||||
for i in 0...@commands[0].length
|
||||
@movecommands.push(@commands[0][i][1])
|
||||
end
|
||||
for i in 0...@commands[1].length
|
||||
@itemcommands.push(@commands[1][i][1])
|
||||
end
|
||||
@index = $PokemonBag.registeredIndex
|
||||
if @index[0]>=@movecommands.length && @movecommands.length>0
|
||||
@index[0] = @movecommands.length-1
|
||||
end
|
||||
if @index[1]>=@itemcommands.length && @itemcommands.length>0
|
||||
@index[1] = @itemcommands.length-1
|
||||
end
|
||||
if @index[2]==0 && @movecommands.length==0; @index[2] = 1
|
||||
elsif @index[2]==1 && @itemcommands.length==0; @index[2] = 0
|
||||
end
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["cmdwindow"] = Window_CommandPokemon.new((@index[2]==0) ? @movecommands : @itemcommands)
|
||||
@sprites["cmdwindow"].height = 6*32
|
||||
@sprites["cmdwindow"].visible = false
|
||||
@sprites["cmdwindow"].viewport = @viewport
|
||||
for i in 0...@commands[0].length
|
||||
@sprites["movebutton#{i}"] = ReadyMenuButton.new(i,@commands[0][i],@index[0],@index[2],@viewport)
|
||||
end
|
||||
for i in 0...@commands[1].length
|
||||
@sprites["itembutton#{i}"] = ReadyMenuButton.new(i,@commands[1][i],@index[1],@index[2],@viewport)
|
||||
end
|
||||
pbSEPlay("GUI menu open")
|
||||
end
|
||||
|
||||
def pbShowMenu
|
||||
@sprites["cmdwindow"].visible = false
|
||||
for i in 0...@commands[0].length
|
||||
@sprites["movebutton#{i}"].visible = true
|
||||
end
|
||||
for i in 0...@commands[1].length
|
||||
@sprites["itembutton#{i}"].visible = true
|
||||
end
|
||||
end
|
||||
|
||||
def pbHideMenu
|
||||
@sprites["cmdwindow"].visible = false
|
||||
for i in 0...@commands[0].length
|
||||
@sprites["movebutton#{i}"].visible = false
|
||||
end
|
||||
for i in 0...@commands[1].length
|
||||
@sprites["itembutton#{i}"].visible = false
|
||||
end
|
||||
end
|
||||
|
||||
def pbShowCommands
|
||||
ret = -1
|
||||
cmdwindow = @sprites["cmdwindow"]
|
||||
cmdwindow.commands = (@index[2]==0) ? @movecommands : @itemcommands
|
||||
cmdwindow.index = @index[@index[2]]
|
||||
cmdwindow.visible = false
|
||||
loop do
|
||||
pbUpdate
|
||||
if Input.trigger?(Input::LEFT) && @index[2]==1 && @movecommands.length>0
|
||||
@index[2] = 0
|
||||
pbChangeSide
|
||||
elsif Input.trigger?(Input::RIGHT) && @index[2]==0 && @itemcommands.length>0
|
||||
@index[2] = 1
|
||||
pbChangeSide
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
ret = -1
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
ret = [@index[2],cmdwindow.index]
|
||||
break
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbChangeSide
|
||||
for i in 0...@commands[0].length
|
||||
@sprites["movebutton#{i}"].side = @index[2]
|
||||
end
|
||||
for i in 0...@commands[1].length
|
||||
@sprites["itembutton#{i}"].side = @index[2]
|
||||
end
|
||||
@sprites["cmdwindow"].commands = (@index[2]==0) ? @movecommands : @itemcommands
|
||||
@sprites["cmdwindow"].index = @index[@index[2]]
|
||||
end
|
||||
|
||||
def pbRefresh; end
|
||||
|
||||
def pbUpdate
|
||||
oldindex = @index[@index[2]]
|
||||
@index[@index[2]] = @sprites["cmdwindow"].index
|
||||
if @index[@index[2]]!=oldindex
|
||||
if @index[2]==0
|
||||
for i in 0...@commands[0].length
|
||||
@sprites["movebutton#{i}"].selected = @index[@index[2]]
|
||||
end
|
||||
elsif @index[2]==1
|
||||
for i in 0...@commands[1].length
|
||||
@sprites["itembutton#{i}"].selected = @index[@index[2]]
|
||||
end
|
||||
end
|
||||
end
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonReadyMenu
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbHideMenu
|
||||
@scene.pbHideMenu
|
||||
end
|
||||
|
||||
def pbShowMenu
|
||||
@scene.pbRefresh
|
||||
@scene.pbShowMenu
|
||||
end
|
||||
|
||||
def pbStartReadyMenu(moves,items)
|
||||
commands = [[],[]] # Moves, items
|
||||
for i in moves
|
||||
commands[0].push([i[0], GameData::Move.get(i[0]).name, true, i[1]])
|
||||
end
|
||||
commands[0].sort! { |a,b| a[1]<=>b[1] }
|
||||
for i in items
|
||||
commands[1].push([i, GameData::Item.get(i).name, false])
|
||||
end
|
||||
commands[1].sort! { |a,b| a[1]<=>b[1] }
|
||||
@scene.pbStartScene(commands)
|
||||
loop do
|
||||
command = @scene.pbShowCommands
|
||||
break if command==-1
|
||||
if command[0]==0 # Use a move
|
||||
move = commands[0][command[1]][0]
|
||||
user = $Trainer.party[commands[0][command[1]][3]]
|
||||
if move == :FLY
|
||||
ret = nil
|
||||
pbFadeOutInWithUpdate(99999,@scene.sprites) {
|
||||
pbHideMenu
|
||||
scene = PokemonRegionMap_Scene.new(-1,false)
|
||||
screen = PokemonRegionMapScreen.new(scene)
|
||||
ret = screen.pbStartFlyScreen
|
||||
pbShowMenu if !ret
|
||||
}
|
||||
if ret
|
||||
$PokemonTemp.flydata = ret
|
||||
$game_temp.in_menu = false
|
||||
pbUseHiddenMove(user,move)
|
||||
break
|
||||
end
|
||||
else
|
||||
pbHideMenu
|
||||
if pbConfirmUseHiddenMove(user,move)
|
||||
$game_temp.in_menu = false
|
||||
pbUseHiddenMove(user,move)
|
||||
break
|
||||
else
|
||||
pbShowMenu
|
||||
end
|
||||
end
|
||||
else # Use an item
|
||||
item = commands[1][command[1]][0]
|
||||
pbHideMenu
|
||||
if ItemHandlers.triggerConfirmUseInField(item)
|
||||
$game_temp.in_menu = false
|
||||
break if pbUseKeyItemInField(item)
|
||||
$game_temp.in_menu = true
|
||||
end
|
||||
end
|
||||
pbShowMenu
|
||||
end
|
||||
@scene.pbEndScene
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Using a registered item
|
||||
#===============================================================================
|
||||
def pbUseKeyItem
|
||||
moves = [:CUT, :DEFOG, :DIG, :DIVE, :FLASH, :FLY, :HEADBUTT, :ROCKCLIMB,
|
||||
:ROCKSMASH, :SECRETPOWER, :STRENGTH, :SURF, :SWEETSCENT, :TELEPORT,
|
||||
:WATERFALL, :WHIRLPOOL, :BOUNCE]
|
||||
real_moves = []
|
||||
moves.each do |move|
|
||||
$Trainer.pokemon_party.each_with_index do |pkmn, i|
|
||||
next if !pkmn.hasMove?(move)
|
||||
real_moves.push([move, i]) if pbCanUseHiddenMove?(pkmn, move, false)
|
||||
end
|
||||
end
|
||||
real_items = []
|
||||
for i in $PokemonBag.registeredItems
|
||||
itm = GameData::Item.get(i).id
|
||||
real_items.push(itm) if $PokemonBag.pbHasItem?(itm)
|
||||
end
|
||||
if real_items.length == 0 && real_moves.length == 0
|
||||
pbMessage(_INTL("An item in the Bag can be registered to this key for instant use."))
|
||||
else
|
||||
$game_temp.in_menu = true
|
||||
$game_map.update
|
||||
sscene = PokemonReadyMenu_Scene.new
|
||||
sscreen = PokemonReadyMenu.new(sscene)
|
||||
sscreen.pbStartReadyMenu(real_moves, real_items)
|
||||
$game_temp.in_menu = false
|
||||
end
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,368 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class Window_PokemonItemStorage < Window_DrawableCommand
|
||||
attr_reader :bag
|
||||
attr_reader :pocket
|
||||
attr_reader :sortIndex
|
||||
|
||||
def sortIndex=(value)
|
||||
@sortIndex = value
|
||||
refresh
|
||||
end
|
||||
|
||||
def initialize(bag,x,y,width,height)
|
||||
@bag = bag
|
||||
@sortIndex = -1
|
||||
@adapter = PokemonMartAdapter.new
|
||||
super(x,y,width,height)
|
||||
self.windowskin = nil
|
||||
end
|
||||
|
||||
def item
|
||||
item = @bag[self.index]
|
||||
return item ? item[0] : nil
|
||||
end
|
||||
|
||||
def itemCount
|
||||
return @bag.length+1
|
||||
end
|
||||
|
||||
def drawItem(index,_count,rect)
|
||||
rect = drawCursor(index,rect)
|
||||
textpos = []
|
||||
if index==@bag.length
|
||||
textpos.push([_INTL("CANCEL"),rect.x,rect.y-6,false,self.baseColor,self.shadowColor])
|
||||
else
|
||||
item = @bag[index][0]
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
baseColor = (index==@sortIndex) ? Color.new(248,24,24) : self.baseColor
|
||||
textpos.push([itemname,rect.x,rect.y-6,false,self.baseColor,self.shadowColor])
|
||||
if !GameData::Item.get(item).is_important? # Not a Key item/HM/TM
|
||||
qty = _ISPRINTF("x{1: 2d}",@bag[index][1])
|
||||
sizeQty = self.contents.text_size(qty).width
|
||||
xQty = rect.x+rect.width-sizeQty-2
|
||||
textpos.push([qty,xQty,rect.y-6,false,baseColor,self.shadowColor])
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(self.contents,textpos)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class ItemStorage_Scene
|
||||
ITEMLISTBASECOLOR = Color.new(88,88,80)
|
||||
ITEMLISTSHADOWCOLOR = Color.new(168,184,184)
|
||||
ITEMTEXTBASECOLOR = Color.new(248,248,248)
|
||||
ITEMTEXTSHADOWCOLOR = Color.new(0,0,0)
|
||||
TITLEBASECOLOR = Color.new(248,248,248)
|
||||
TITLESHADOWCOLOR = Color.new(0,0,0)
|
||||
ITEMSVISIBLE = 7
|
||||
|
||||
def initialize(title)
|
||||
@title = title
|
||||
end
|
||||
|
||||
def update
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbStartScene(bag)
|
||||
@viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@bag = bag
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0,0,@viewport)
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/pcItembg")
|
||||
@sprites["icon"] = ItemIconSprite.new(50,334,nil,@viewport)
|
||||
# Item list
|
||||
@sprites["itemwindow"] = Window_PokemonItemStorage.new(@bag,98,14,334,32+ITEMSVISIBLE*32)
|
||||
@sprites["itemwindow"].viewport = @viewport
|
||||
@sprites["itemwindow"].index = 0
|
||||
@sprites["itemwindow"].baseColor = ITEMLISTBASECOLOR
|
||||
@sprites["itemwindow"].shadowColor = ITEMLISTSHADOWCOLOR
|
||||
@sprites["itemwindow"].refresh
|
||||
# Title
|
||||
@sprites["pocketwindow"] = BitmapSprite.new(88,64,@viewport)
|
||||
@sprites["pocketwindow"].x = 14
|
||||
@sprites["pocketwindow"].y = 16
|
||||
pbSetNarrowFont(@sprites["pocketwindow"].bitmap)
|
||||
# Item description
|
||||
@sprites["itemtextwindow"] = Window_UnformattedTextPokemon.newWithSize("",84,270,Graphics.width-84,128,@viewport)
|
||||
@sprites["itemtextwindow"].baseColor = ITEMTEXTBASECOLOR
|
||||
@sprites["itemtextwindow"].shadowColor = ITEMTEXTSHADOWCOLOR
|
||||
@sprites["itemtextwindow"].windowskin = nil
|
||||
@sprites["helpwindow"] = Window_UnformattedTextPokemon.new("")
|
||||
@sprites["helpwindow"].visible = false
|
||||
@sprites["helpwindow"].viewport = @viewport
|
||||
# Letter-by-letter message window
|
||||
@sprites["msgwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
@sprites["msgwindow"].visible = false
|
||||
@sprites["msgwindow"].viewport = @viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"],1)
|
||||
pbDeactivateWindows(@sprites)
|
||||
pbRefresh
|
||||
pbFadeInAndShow(@sprites)
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
|
||||
def pbChooseNumber(helptext,maximum)
|
||||
return UIHelper.pbChooseNumber(@sprites["helpwindow"],helptext,maximum) { update }
|
||||
end
|
||||
|
||||
def pbDisplay(msg,brief=false)
|
||||
UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { update }
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
UIHelper.pbConfirm(@sprites["msgwindow"],msg) { update }
|
||||
end
|
||||
|
||||
def pbShowCommands(helptext,commands)
|
||||
return UIHelper.pbShowCommands(@sprites["helpwindow"],helptext,commands) { update }
|
||||
end
|
||||
|
||||
def pbRefresh
|
||||
bm = @sprites["pocketwindow"].bitmap
|
||||
# Draw title at upper left corner ("Toss Item/Withdraw Item")
|
||||
drawTextEx(bm,0,4,bm.width,2,@title,TITLEBASECOLOR,TITLESHADOWCOLOR)
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
# Draw item icon
|
||||
@sprites["icon"].item = itemwindow.item
|
||||
# Get item description
|
||||
if itemwindow.item
|
||||
@sprites["itemtextwindow"].text = GameData::Item.get(itemwindow.item).description
|
||||
else
|
||||
@sprites["itemtextwindow"].text = _INTL("Close storage.")
|
||||
end
|
||||
itemwindow.refresh
|
||||
end
|
||||
|
||||
def pbChooseItem
|
||||
pbRefresh
|
||||
@sprites["helpwindow"].visible = false
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
itemwindow.refresh
|
||||
pbActivateWindow(@sprites,"itemwindow") {
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
olditem = itemwindow.item
|
||||
self.update
|
||||
pbRefresh if itemwindow.item!=olditem
|
||||
if Input.trigger?(Input::BACK)
|
||||
return nil
|
||||
elsif Input.trigger?(Input::USE)
|
||||
if itemwindow.index<@bag.length
|
||||
pbRefresh
|
||||
return @bag[itemwindow.index][0]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class WithdrawItemScene < ItemStorage_Scene
|
||||
def initialize
|
||||
super(_INTL("Withdraw\nItem"))
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class TossItemScene < ItemStorage_Scene
|
||||
def initialize
|
||||
super(_INTL("Toss\nItem"))
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Common UI functions used in both the Bag and item storage screens.
|
||||
# Displays messages and allows the user to choose a number/command.
|
||||
# The window _helpwindow_ will display the _helptext_.
|
||||
#===============================================================================
|
||||
module UIHelper
|
||||
# Letter by letter display of the message _msg_ by the window _helpwindow_.
|
||||
def self.pbDisplay(helpwindow,msg,brief)
|
||||
cw = helpwindow
|
||||
oldvisible = cw.visible
|
||||
cw.letterbyletter = true
|
||||
cw.text = msg+"\1"
|
||||
cw.visible = true
|
||||
pbBottomLeftLines(cw,2)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
(block_given?) ? yield : cw.update
|
||||
if !cw.busy?
|
||||
if brief || (Input.trigger?(Input::USE) && cw.resume)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
cw.visible = oldvisible
|
||||
end
|
||||
|
||||
def self.pbDisplayStatic(msgwindow,message)
|
||||
oldvisible = msgwindow.visible
|
||||
msgwindow.visible = true
|
||||
msgwindow.letterbyletter = false
|
||||
msgwindow.width = Graphics.width
|
||||
msgwindow.resizeHeightToFit(message,Graphics.width)
|
||||
msgwindow.text = message
|
||||
pbBottomRight(msgwindow)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
(block_given?) ? yield : msgwindow.update
|
||||
if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
|
||||
break
|
||||
end
|
||||
end
|
||||
msgwindow.visible = oldvisible
|
||||
Input.update
|
||||
end
|
||||
|
||||
# Letter by letter display of the message _msg_ by the window _helpwindow_,
|
||||
# used to ask questions. Returns true if the user chose yes, false if no.
|
||||
def self.pbConfirm(helpwindow,msg)
|
||||
dw = helpwindow
|
||||
oldvisible = dw.visible
|
||||
dw.letterbyletter = true
|
||||
dw.text = msg
|
||||
dw.visible = true
|
||||
pbBottomLeftLines(dw,2)
|
||||
commands = [_INTL("Yes"),_INTL("No")]
|
||||
cw = Window_CommandPokemon.new(commands)
|
||||
cw.index = 0
|
||||
cw.viewport = helpwindow.viewport
|
||||
pbBottomRight(cw)
|
||||
cw.y -= dw.height
|
||||
ret = false
|
||||
loop do
|
||||
cw.visible = (!dw.busy?)
|
||||
Graphics.update
|
||||
Input.update
|
||||
cw.update
|
||||
(block_given?) ? yield : dw.update
|
||||
if !dw.busy? && dw.resume
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
pbPlayDecisionSE
|
||||
ret = (cw.index==0)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
cw.dispose
|
||||
dw.visible = oldvisible
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.pbChooseNumber(helpwindow,helptext,maximum,initnum=1)
|
||||
oldvisible = helpwindow.visible
|
||||
helpwindow.visible = true
|
||||
helpwindow.text = helptext
|
||||
helpwindow.letterbyletter = false
|
||||
curnumber = initnum
|
||||
ret = 0
|
||||
numwindow = Window_UnformattedTextPokemon.new("x000")
|
||||
numwindow.viewport = helpwindow.viewport
|
||||
numwindow.letterbyletter = false
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
numwindow.resizeToFit(numwindow.text,Graphics.width)
|
||||
pbBottomRight(numwindow)
|
||||
helpwindow.resizeHeightToFit(helpwindow.text,Graphics.width-numwindow.width)
|
||||
pbBottomLeft(helpwindow)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
numwindow.update
|
||||
helpwindow.update
|
||||
if Input.trigger?(Input::BACK)
|
||||
ret = 0
|
||||
pbPlayCancelSE
|
||||
break
|
||||
elsif Input.trigger?(Input::USE)
|
||||
ret = curnumber
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
elsif Input.repeat?(Input::UP)
|
||||
curnumber += 1
|
||||
curnumber = 1 if curnumber>maximum
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
curnumber -= 1
|
||||
curnumber = maximum if curnumber<1
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE
|
||||
elsif Input.repeat?(Input::LEFT)
|
||||
curnumber -= 10
|
||||
curnumber = 1 if curnumber<1
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE
|
||||
elsif Input.repeat?(Input::RIGHT)
|
||||
curnumber += 10
|
||||
curnumber = maximum if curnumber>maximum
|
||||
numwindow.text = _ISPRINTF("x{1:03d}",curnumber)
|
||||
pbPlayCursorSE
|
||||
end
|
||||
end
|
||||
numwindow.dispose
|
||||
helpwindow.visible = oldvisible
|
||||
return ret
|
||||
end
|
||||
|
||||
def self.pbShowCommands(helpwindow,helptext,commands,initcmd=0)
|
||||
ret = -1
|
||||
oldvisible = helpwindow.visible
|
||||
helpwindow.visible = helptext ? true : false
|
||||
helpwindow.letterbyletter = false
|
||||
helpwindow.text = helptext ? helptext : ""
|
||||
cmdwindow = Window_CommandPokemon.new(commands)
|
||||
cmdwindow.index = initcmd
|
||||
begin
|
||||
cmdwindow.viewport = helpwindow.viewport
|
||||
pbBottomRight(cmdwindow)
|
||||
helpwindow.resizeHeightToFit(helpwindow.text,Graphics.width-cmdwindow.width)
|
||||
pbBottomLeft(helpwindow)
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
yield
|
||||
cmdwindow.update
|
||||
if Input.trigger?(Input::BACK)
|
||||
ret = -1
|
||||
pbPlayCancelSE
|
||||
break
|
||||
end
|
||||
if Input.trigger?(Input::USE)
|
||||
ret = cmdwindow.index
|
||||
pbPlayDecisionSE
|
||||
break
|
||||
end
|
||||
end
|
||||
ensure
|
||||
cmdwindow.dispose if cmdwindow
|
||||
end
|
||||
helpwindow.visible = oldvisible
|
||||
return ret
|
||||
end
|
||||
end
|
||||
@@ -1,275 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class TrainerPC
|
||||
def shouldShow?
|
||||
return true
|
||||
end
|
||||
|
||||
def name
|
||||
return _INTL("{1}'s PC",$Trainer.name)
|
||||
end
|
||||
|
||||
def access
|
||||
pbMessage(_INTL("\\se[PC access]Accessed {1}'s PC.",$Trainer.name))
|
||||
pbTrainerPCMenu
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class StorageSystemPC
|
||||
def shouldShow?
|
||||
return true
|
||||
end
|
||||
|
||||
def name
|
||||
return "Pokemon Storage"
|
||||
#if $Trainer.seen_storage_creator
|
||||
# return _INTL("{1}'s PC",pbGetStorageCreator)
|
||||
#else
|
||||
# return _INTL("Someone's PC")
|
||||
#end
|
||||
end
|
||||
|
||||
def access
|
||||
pbMessage(_INTL("\\se[PC access]The Pokémon Storage System was opened."))
|
||||
command = 0
|
||||
loop do
|
||||
command = pbShowCommandsWithHelp(nil,
|
||||
[_INTL("Organize / Fuse"),
|
||||
_INTL("Withdraw Pokémon"),
|
||||
_INTL("Deposit Pokémon"),
|
||||
_INTL("See ya!")],
|
||||
[_INTL("Organize the Pokémon in Boxes and in your party."),
|
||||
_INTL("Move Pokémon stored in Boxes to your party."),
|
||||
_INTL("Store Pokémon in your party in Boxes."),
|
||||
_INTL("Return to the previous menu.")],-1,command
|
||||
)
|
||||
if command>=0 && command<3
|
||||
if command==1 # Withdraw
|
||||
if $PokemonStorage.party_full?
|
||||
pbMessage(_INTL("Your party is full!"))
|
||||
next
|
||||
end
|
||||
elsif command==2 # Deposit
|
||||
count=0
|
||||
for p in $PokemonStorage.party
|
||||
count += 1 if p && !p.egg? && p.hp>0
|
||||
end
|
||||
if count<=1
|
||||
pbMessage(_INTL("Can't deposit the last Pokémon!"))
|
||||
next
|
||||
end
|
||||
end
|
||||
pbFadeOutIn {
|
||||
scene = PokemonStorageScene.new
|
||||
screen = PokemonStorageScreen.new(scene,$PokemonStorage)
|
||||
screen.pbStartScreen(command)
|
||||
}
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
module PokemonPCList
|
||||
@@pclist = []
|
||||
|
||||
def self.registerPC(pc)
|
||||
@@pclist.push(pc)
|
||||
end
|
||||
|
||||
def self.getCommandList
|
||||
commands = []
|
||||
for pc in @@pclist
|
||||
commands.push(pc.name) if pc.shouldShow?
|
||||
end
|
||||
commands.push(_INTL("Log Off"))
|
||||
return commands
|
||||
end
|
||||
|
||||
def self.callCommand(cmd)
|
||||
return false if cmd<0 || cmd>=@@pclist.length
|
||||
i = 0
|
||||
for pc in @@pclist
|
||||
next if !pc.shouldShow?
|
||||
if i==cmd
|
||||
pc.access
|
||||
return true
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# PC menus
|
||||
#===============================================================================
|
||||
def pbPCItemStorage
|
||||
command = 0
|
||||
loop do
|
||||
command = pbShowCommandsWithHelp(nil,
|
||||
[_INTL("Withdraw Item"),
|
||||
_INTL("Deposit Item"),
|
||||
_INTL("Toss Item"),
|
||||
_INTL("Exit")],
|
||||
[_INTL("Take out items from the PC."),
|
||||
_INTL("Store items in the PC."),
|
||||
_INTL("Throw away items stored in the PC."),
|
||||
_INTL("Go back to the previous menu.")],-1,command
|
||||
)
|
||||
case command
|
||||
when 0 # Withdraw Item
|
||||
if !$PokemonGlobal.pcItemStorage
|
||||
$PokemonGlobal.pcItemStorage = PCItemStorage.new
|
||||
end
|
||||
if $PokemonGlobal.pcItemStorage.empty?
|
||||
pbMessage(_INTL("There are no items."))
|
||||
else
|
||||
pbFadeOutIn {
|
||||
scene = WithdrawItemScene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
screen.pbWithdrawItemScreen
|
||||
}
|
||||
end
|
||||
when 1 # Deposit Item
|
||||
pbFadeOutIn {
|
||||
scene = PokemonBag_Scene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
screen.pbDepositItemScreen
|
||||
}
|
||||
when 2 # Toss Item
|
||||
if !$PokemonGlobal.pcItemStorage
|
||||
$PokemonGlobal.pcItemStorage = PCItemStorage.new
|
||||
end
|
||||
if $PokemonGlobal.pcItemStorage.empty?
|
||||
pbMessage(_INTL("There are no items."))
|
||||
else
|
||||
pbFadeOutIn {
|
||||
scene = TossItemScene.new
|
||||
screen = PokemonBagScreen.new(scene,$PokemonBag)
|
||||
screen.pbTossItemScreen
|
||||
}
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbPCMailbox
|
||||
if !$PokemonGlobal.mailbox || $PokemonGlobal.mailbox.length==0
|
||||
pbMessage(_INTL("There's no Mail here."))
|
||||
else
|
||||
loop do
|
||||
command = 0
|
||||
commands=[]
|
||||
for mail in $PokemonGlobal.mailbox
|
||||
commands.push(mail.sender)
|
||||
end
|
||||
commands.push(_INTL("Cancel"))
|
||||
command = pbShowCommands(nil,commands,-1,command)
|
||||
if command>=0 && command<$PokemonGlobal.mailbox.length
|
||||
mailIndex = command
|
||||
commandMail = pbMessage(_INTL("What do you want to do with {1}'s Mail?",
|
||||
$PokemonGlobal.mailbox[mailIndex].sender),[
|
||||
_INTL("Read"),
|
||||
_INTL("Move to Bag"),
|
||||
_INTL("Give"),
|
||||
_INTL("Cancel")
|
||||
],-1)
|
||||
case commandMail
|
||||
when 0 # Read
|
||||
pbFadeOutIn {
|
||||
pbDisplayMail($PokemonGlobal.mailbox[mailIndex])
|
||||
}
|
||||
when 1 # Move to Bag
|
||||
if pbConfirmMessage(_INTL("The message will be lost. Is that OK?"))
|
||||
if $PokemonBag.pbStoreItem($PokemonGlobal.mailbox[mailIndex].item)
|
||||
pbMessage(_INTL("The Mail was returned to the Bag with its message erased."))
|
||||
$PokemonGlobal.mailbox.delete_at(mailIndex)
|
||||
else
|
||||
pbMessage(_INTL("The Bag is full."))
|
||||
end
|
||||
end
|
||||
when 2 # Give
|
||||
pbFadeOutIn {
|
||||
sscene = PokemonParty_Scene.new
|
||||
sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)
|
||||
sscreen.pbPokemonGiveMailScreen(mailIndex)
|
||||
}
|
||||
end
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbTrainerPCMenu
|
||||
command = 0
|
||||
loop do
|
||||
command = pbMessage(_INTL("What do you want to do?"),[
|
||||
_INTL("Item Storage"),
|
||||
_INTL("Mailbox"),
|
||||
_INTL("Turn Off")
|
||||
],-1,nil,command)
|
||||
case command
|
||||
when 0 then pbPCItemStorage
|
||||
when 1 then pbPCMailbox
|
||||
else break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbTrainerPC
|
||||
pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
|
||||
pbTrainerPCMenu
|
||||
pbSEPlay("PC close")
|
||||
end
|
||||
|
||||
def checkPorygonEncounter
|
||||
porygon_chance = 200
|
||||
if $PokemonGlobal.stepcount % porygon_chance == 0
|
||||
pbSEPlay("Paralyze3")
|
||||
pbWait(12)
|
||||
pbMessage(_INTL("Huh? The PC glitched for a second while it booted."))
|
||||
pbMessage(_INTL("Did something make its way into the PC?"))
|
||||
pbWait(8)
|
||||
pbAddPokemonSilent(:PORYGON,1)
|
||||
$PokemonGlobal.stepcount += 1
|
||||
end
|
||||
# code here
|
||||
end
|
||||
|
||||
def pbPokeCenterPC
|
||||
pbMessage(_INTL("\\se[PC open]{1} booted up the PC.",$Trainer.name))
|
||||
checkPorygonEncounter()
|
||||
command = 0
|
||||
loop do
|
||||
commands = PokemonPCList.getCommandList
|
||||
command = pbMessage(_INTL("Which PC should be accessed?"),commands,
|
||||
commands.length,nil,command)
|
||||
break if !PokemonPCList.callCommand(command)
|
||||
end
|
||||
pbSEPlay("PC close")
|
||||
end
|
||||
|
||||
def pbGetStorageCreator
|
||||
creator = Settings.storage_creator_name
|
||||
creator = _INTL("Bill") if nil_or_empty?(creator)
|
||||
return creator
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
PokemonPCList.registerPC(StorageSystemPC.new)
|
||||
PokemonPCList.registerPC(TrainerPC.new)
|
||||
@@ -1,794 +0,0 @@
|
||||
#===============================================================================
|
||||
# Abstraction layer for Pokemon Essentials
|
||||
#===============================================================================
|
||||
class PokemonMartAdapter
|
||||
def getMoney
|
||||
return $Trainer.money
|
||||
end
|
||||
|
||||
def getMoneyString
|
||||
return pbGetGoldString
|
||||
end
|
||||
|
||||
def setMoney(value)
|
||||
$Trainer.money = value
|
||||
end
|
||||
|
||||
def getInventory
|
||||
return $PokemonBag
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
return GameData::Item.get(item).name
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
item_name = getName(item)
|
||||
if GameData::Item.get(item).is_machine?
|
||||
machine = GameData::Item.get(item).move
|
||||
item_name = _INTL("{1} {2}", item_name, GameData::Move.get(machine).name)
|
||||
end
|
||||
return item_name
|
||||
end
|
||||
|
||||
def getDescription(item)
|
||||
return GameData::Item.get(item).description
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return (item) ? GameData::Item.icon_filename(item) : nil
|
||||
end
|
||||
|
||||
# Unused
|
||||
def getItemIconRect(_item)
|
||||
return Rect.new(0, 0, 48, 48)
|
||||
end
|
||||
|
||||
def getQuantity(item)
|
||||
return $PokemonBag.pbQuantity(item)
|
||||
end
|
||||
|
||||
def showQuantity?(item)
|
||||
return !GameData::Item.get(item).is_important?
|
||||
end
|
||||
|
||||
def getPrice(item, selling = false)
|
||||
if $game_temp.mart_prices && $game_temp.mart_prices[item]
|
||||
if selling
|
||||
return $game_temp.mart_prices[item][1] if $game_temp.mart_prices[item][1] >= 0
|
||||
else
|
||||
return $game_temp.mart_prices[item][0] if $game_temp.mart_prices[item][0] > 0
|
||||
end
|
||||
end
|
||||
return GameData::Item.get(item).price
|
||||
end
|
||||
|
||||
def getDisplayPrice(item, selling = false)
|
||||
price = getPrice(item, selling).to_s_formatted
|
||||
return _INTL("$ {1}", price)
|
||||
end
|
||||
|
||||
def canSell?(item)
|
||||
return getPrice(item, true) > 0 && !GameData::Item.get(item).is_important?
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
return $PokemonBag.pbStoreItem(item)
|
||||
end
|
||||
|
||||
def removeItem(item)
|
||||
return $PokemonBag.pbDeleteItem(item)
|
||||
end
|
||||
|
||||
def getBaseColorOverride(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getShadowColorOverride(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
#specialType is a symbol
|
||||
def getSpecialItemCaption(specialType)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemDescription(specialType)
|
||||
return nil
|
||||
end
|
||||
|
||||
def doSpecialItemAction(specialType,itemId=nil)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemBaseColor(specialType)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemShadowColor(specialType)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Buy and Sell adapters
|
||||
#===============================================================================
|
||||
class BuyAdapter
|
||||
def initialize(adapter)
|
||||
@adapter = adapter
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
@adapter.getDisplayName(item)
|
||||
end
|
||||
|
||||
def getDisplayPrice(item)
|
||||
@adapter.getDisplayPrice(item, false)
|
||||
end
|
||||
|
||||
def getBaseColorOverride(item)
|
||||
return @adapter.getBaseColorOverride(item)
|
||||
end
|
||||
|
||||
def getShadowColorOverride(item)
|
||||
return @adapter.getShadowColorOverride(item)
|
||||
end
|
||||
|
||||
def isSelling?
|
||||
return false
|
||||
end
|
||||
|
||||
def getSpecialItemCaption(specialType)
|
||||
return @adapter.getSpecialItemCaption(specialType)
|
||||
end
|
||||
|
||||
def getSpecialItemBaseColor(specialType)
|
||||
return @adapter.getSpecialItemBaseColor(specialType)
|
||||
end
|
||||
|
||||
def getSpecialItemShadowColor(specialType)
|
||||
return @adapter.getSpecialItemShadowColor(specialType)
|
||||
end
|
||||
|
||||
def getAdapter()
|
||||
return @adapter
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class SellAdapter
|
||||
def initialize(adapter)
|
||||
@adapter = adapter
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
@adapter.getDisplayName(item)
|
||||
end
|
||||
|
||||
def getDisplayPrice(item)
|
||||
if @adapter.showQuantity?(item)
|
||||
return sprintf("x%d", @adapter.getQuantity(item))
|
||||
else
|
||||
return ""
|
||||
end
|
||||
end
|
||||
|
||||
def isSelling?
|
||||
return true
|
||||
end
|
||||
|
||||
def getBaseColorOverride(item)
|
||||
return @adapter.getBaseColorOverride(item)
|
||||
end
|
||||
|
||||
def getShadowColorOverride(item)
|
||||
return @adapter.getShadowColorOverride(item)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Pokémon Mart
|
||||
#===============================================================================
|
||||
class Window_PokemonMart < Window_DrawableCommand
|
||||
def initialize(stock, adapter, x, y, width, height, viewport = nil)
|
||||
@stock = stock
|
||||
@adapter = adapter
|
||||
super(x, y, width, height, viewport)
|
||||
@selarrow = AnimatedBitmap.new("Graphics/Pictures/martSel")
|
||||
@baseColor = Color.new(88, 88, 80)
|
||||
@shadowColor = Color.new(168, 184, 184)
|
||||
self.windowskin = nil
|
||||
end
|
||||
|
||||
def itemCount
|
||||
return @stock.length + 1
|
||||
end
|
||||
|
||||
def item
|
||||
return (self.index >= @stock.length) ? nil : @stock[self.index]
|
||||
end
|
||||
|
||||
def drawItem(index, count, rect)
|
||||
textpos = []
|
||||
rect = drawCursor(index, rect)
|
||||
ypos = rect.y
|
||||
if index == count - 1
|
||||
textpos.push([_INTL("CANCEL"), rect.x, ypos - 4, false, self.baseColor, self.shadowColor])
|
||||
else
|
||||
item = @stock[index]
|
||||
if item.is_a?(Symbol) && @adapter.getAdapter().is_a?(OutfitsMartAdapter)
|
||||
itemname = @adapter.getSpecialItemCaption(item)
|
||||
baseColor = @adapter.getSpecialItemBaseColor(item) ? @adapter.getSpecialItemBaseColor(item) : baseColor
|
||||
shadowColor = @adapter.getSpecialItemShadowColor(item) ? @adapter.getSpecialItemShadowColor(item) : shadowColor
|
||||
textpos.push([itemname, rect.x, ypos - 4, false, baseColor, shadowColor])
|
||||
else
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
baseColorOverride = @adapter.getBaseColorOverride(item)
|
||||
shadowColorOverride = @adapter.getShadowColorOverride(item)
|
||||
|
||||
baseColor = baseColorOverride ? baseColorOverride : self.baseColor
|
||||
shadowColor = shadowColorOverride ? shadowColorOverride : self.shadowColor
|
||||
|
||||
qty = @adapter.getDisplayPrice(item)
|
||||
sizeQty = self.contents.text_size(qty).width
|
||||
xQty = rect.x + rect.width - sizeQty - 2 - 16
|
||||
textpos.push([itemname, rect.x, ypos - 4, false, baseColor, shadowColor])
|
||||
textpos.push([qty, xQty, ypos - 4, false, baseColor, shadowColor])
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(self.contents, textpos)
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonMart_Scene
|
||||
def initialize(currency_name = "Money")
|
||||
@currency_name = currency_name
|
||||
end
|
||||
|
||||
def update
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
@subscene.pbUpdate if @subscene
|
||||
end
|
||||
|
||||
def pbRefresh
|
||||
if @subscene
|
||||
@subscene.pbRefresh
|
||||
else
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
@sprites["icon"].item = itemwindow.item
|
||||
@sprites["itemtextwindow"].text =
|
||||
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
|
||||
itemwindow.refresh
|
||||
end
|
||||
@sprites["moneywindow"].text = _INTL("{2}:\r\n<r>{1}", @adapter.getMoneyString, @currency_name)
|
||||
end
|
||||
|
||||
def scroll_map()
|
||||
pbScrollMap(6, 5, 5)
|
||||
end
|
||||
|
||||
def scroll_back_map()
|
||||
pbScrollMap(4, 5, 5)
|
||||
end
|
||||
|
||||
def pbStartBuyOrSellScene(buying, stock, adapter)
|
||||
# Scroll right before showing screen
|
||||
scroll_map()
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@stock = stock
|
||||
@adapter = adapter
|
||||
@sprites = {}
|
||||
@sprites["background"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/martScreen")
|
||||
@sprites["icon"] = ItemIconSprite.new(36, Graphics.height - 50, nil, @viewport)
|
||||
winAdapter = buying ? BuyAdapter.new(adapter) : SellAdapter.new(adapter)
|
||||
@sprites["itemwindow"] = Window_PokemonMart.new(stock, winAdapter,
|
||||
Graphics.width - 316 - 16, 12, 330 + 16, Graphics.height - 126)
|
||||
@sprites["itemwindow"].viewport = @viewport
|
||||
@sprites["itemwindow"].index = 0
|
||||
@sprites["itemwindow"].refresh
|
||||
@sprites["itemtextwindow"] = Window_UnformattedTextPokemon.newWithSize("",
|
||||
64, Graphics.height - 96 - 16, Graphics.width - 64, 128, @viewport)
|
||||
pbPrepareWindow(@sprites["itemtextwindow"])
|
||||
@sprites["itemtextwindow"].baseColor = Color.new(248, 248, 248)
|
||||
@sprites["itemtextwindow"].shadowColor = Color.new(0, 0, 0)
|
||||
@sprites["itemtextwindow"].windowskin = nil
|
||||
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["helpwindow"])
|
||||
@sprites["helpwindow"].visible = false
|
||||
@sprites["helpwindow"].viewport = @viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"], 1)
|
||||
@sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["moneywindow"])
|
||||
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
|
||||
@sprites["moneywindow"].visible = true
|
||||
@sprites["moneywindow"].viewport = @viewport
|
||||
@sprites["moneywindow"].x = 0
|
||||
@sprites["moneywindow"].y = 0
|
||||
@sprites["moneywindow"].width = 190
|
||||
@sprites["moneywindow"].height = 96
|
||||
@sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
|
||||
@sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
|
||||
pbDeactivateWindows(@sprites)
|
||||
@buying = buying
|
||||
pbRefresh
|
||||
Graphics.frame_reset
|
||||
end
|
||||
|
||||
def pbStartBuyScene(stock, adapter)
|
||||
pbStartBuyOrSellScene(true, stock, adapter)
|
||||
end
|
||||
|
||||
def pbStartSellScene(bag, adapter)
|
||||
if $PokemonBag
|
||||
pbStartSellScene2(bag, adapter)
|
||||
else
|
||||
pbStartBuyOrSellScene(false, bag, adapter)
|
||||
end
|
||||
end
|
||||
|
||||
def pbStartSellScene2(bag, adapter)
|
||||
@subscene = PokemonBag_Scene.new
|
||||
@adapter = adapter
|
||||
@viewport2 = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport2.z = 99999
|
||||
numFrames = Graphics.frame_rate * 4 / 10
|
||||
alphaDiff = (255.0 / numFrames).ceil
|
||||
for j in 0..numFrames
|
||||
col = Color.new(0, 0, 0, j * alphaDiff)
|
||||
@viewport2.color = col
|
||||
Graphics.update
|
||||
Input.update
|
||||
end
|
||||
@subscene.pbStartScene(bag)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@sprites = {}
|
||||
@sprites["helpwindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["helpwindow"])
|
||||
@sprites["helpwindow"].visible = false
|
||||
@sprites["helpwindow"].viewport = @viewport
|
||||
pbBottomLeftLines(@sprites["helpwindow"], 1)
|
||||
@sprites["moneywindow"] = Window_AdvancedTextPokemon.new("")
|
||||
pbPrepareWindow(@sprites["moneywindow"])
|
||||
@sprites["moneywindow"].setSkin("Graphics/Windowskins/goldskin")
|
||||
@sprites["moneywindow"].visible = false
|
||||
@sprites["moneywindow"].viewport = @viewport
|
||||
@sprites["moneywindow"].x = 0
|
||||
@sprites["moneywindow"].y = 0
|
||||
@sprites["moneywindow"].width = 186
|
||||
@sprites["moneywindow"].height = 96
|
||||
@sprites["moneywindow"].baseColor = Color.new(88, 88, 80)
|
||||
@sprites["moneywindow"].shadowColor = Color.new(168, 184, 184)
|
||||
pbDeactivateWindows(@sprites)
|
||||
@buying = false
|
||||
pbRefresh
|
||||
end
|
||||
|
||||
def pbEndBuyScene
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
Kernel.pbClearText()
|
||||
@viewport.dispose
|
||||
# Scroll left after showing screen
|
||||
scroll_back_map()
|
||||
end
|
||||
|
||||
def pbEndSellScene
|
||||
@subscene.pbEndScene if @subscene
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
if @viewport2
|
||||
numFrames = Graphics.frame_rate * 4 / 10
|
||||
alphaDiff = (255.0 / numFrames).ceil
|
||||
for j in 0..numFrames
|
||||
col = Color.new(0, 0, 0, (numFrames - j) * alphaDiff)
|
||||
@viewport2.color = col
|
||||
Graphics.update
|
||||
Input.update
|
||||
end
|
||||
@viewport2.dispose
|
||||
end
|
||||
@viewport.dispose
|
||||
pbScrollMap(4, 5, 5) if !@subscene
|
||||
end
|
||||
|
||||
def pbPrepareWindow(window)
|
||||
window.visible = true
|
||||
window.letterbyletter = false
|
||||
end
|
||||
|
||||
def pbShowMoney
|
||||
pbRefresh
|
||||
@sprites["moneywindow"].visible = true
|
||||
end
|
||||
|
||||
def pbHideMoney
|
||||
pbRefresh
|
||||
@sprites["moneywindow"].visible = false
|
||||
end
|
||||
|
||||
def pbDisplay(msg, brief = false)
|
||||
cw = @sprites["helpwindow"]
|
||||
cw.letterbyletter = true
|
||||
cw.text = msg
|
||||
pbBottomLeftLines(cw, 2)
|
||||
cw.visible = true
|
||||
i = 0
|
||||
pbPlayDecisionSE
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
self.update
|
||||
if !cw.busy?
|
||||
return if brief
|
||||
pbRefresh if i == 0
|
||||
end
|
||||
if Input.trigger?(Input::USE) && cw.busy?
|
||||
cw.resume
|
||||
end
|
||||
return if i >= Graphics.frame_rate * 3 / 2
|
||||
i += 1 if !cw.busy?
|
||||
end
|
||||
end
|
||||
|
||||
def pbDisplayPaused(msg)
|
||||
cw = @sprites["helpwindow"]
|
||||
cw.letterbyletter = true
|
||||
cw.text = msg
|
||||
pbBottomLeftLines(cw, 2)
|
||||
cw.visible = true
|
||||
yielded = false
|
||||
pbPlayDecisionSE
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
wasbusy = cw.busy?
|
||||
self.update
|
||||
if !cw.busy? && !yielded
|
||||
yield if block_given? # For playing SE as soon as the message is all shown
|
||||
yielded = true
|
||||
end
|
||||
pbRefresh if !cw.busy? && wasbusy
|
||||
if Input.trigger?(Input::USE) && cw.resume && !cw.busy?
|
||||
@sprites["helpwindow"].visible = false
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
dw = @sprites["helpwindow"]
|
||||
dw.letterbyletter = true
|
||||
dw.text = msg
|
||||
dw.visible = true
|
||||
pbBottomLeftLines(dw, 2)
|
||||
commands = [_INTL("Yes"), _INTL("No")]
|
||||
cw = Window_CommandPokemon.new(commands)
|
||||
cw.viewport = @viewport
|
||||
pbBottomRight(cw)
|
||||
cw.y -= dw.height
|
||||
cw.index = 0
|
||||
pbPlayDecisionSE
|
||||
loop do
|
||||
cw.visible = !dw.busy?
|
||||
Graphics.update
|
||||
Input.update
|
||||
cw.update
|
||||
self.update
|
||||
if Input.trigger?(Input::BACK) && dw.resume && !dw.busy?
|
||||
cw.dispose
|
||||
@sprites["helpwindow"].visible = false
|
||||
return false
|
||||
end
|
||||
if Input.trigger?(Input::USE) && dw.resume && !dw.busy?
|
||||
cw.dispose
|
||||
@sprites["helpwindow"].visible = false
|
||||
return (cw.index == 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbChooseNumber(helptext, item, maximum)
|
||||
curnumber = 1
|
||||
ret = 0
|
||||
helpwindow = @sprites["helpwindow"]
|
||||
itemprice = @adapter.getPrice(item, !@buying)
|
||||
itemprice /= 2 if !@buying
|
||||
pbDisplay(helptext, true)
|
||||
using(numwindow = Window_AdvancedTextPokemon.new("")) { # Showing number of items
|
||||
qty = @adapter.getQuantity(item)
|
||||
using(inbagwindow = Window_AdvancedTextPokemon.new("")) { # Showing quantity in bag
|
||||
pbPrepareWindow(numwindow)
|
||||
pbPrepareWindow(inbagwindow)
|
||||
numwindow.viewport = @viewport
|
||||
numwindow.width = 224
|
||||
numwindow.height = 64
|
||||
numwindow.baseColor = Color.new(88, 88, 80)
|
||||
numwindow.shadowColor = Color.new(168, 184, 184)
|
||||
inbagwindow.visible = @buying
|
||||
inbagwindow.viewport = @viewport
|
||||
inbagwindow.width = 190
|
||||
inbagwindow.height = 64
|
||||
inbagwindow.baseColor = Color.new(88, 88, 80)
|
||||
inbagwindow.shadowColor = Color.new(168, 184, 184)
|
||||
inbagwindow.text = _INTL("In Bag:<r>{1} ", qty)
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
pbBottomRight(numwindow)
|
||||
numwindow.y -= helpwindow.height
|
||||
pbBottomLeft(inbagwindow)
|
||||
inbagwindow.y -= helpwindow.height
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
numwindow.update
|
||||
inbagwindow.update
|
||||
self.update
|
||||
if Input.repeat?(Input::LEFT)
|
||||
pbPlayCursorSE
|
||||
curnumber -= 10
|
||||
curnumber = 1 if curnumber < 1
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.repeat?(Input::RIGHT)
|
||||
pbPlayCursorSE
|
||||
curnumber += 10
|
||||
curnumber = maximum if curnumber > maximum
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.repeat?(Input::UP)
|
||||
pbPlayCursorSE
|
||||
curnumber += 1
|
||||
curnumber = 1 if curnumber > maximum
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
pbPlayCursorSE
|
||||
curnumber -= 1
|
||||
curnumber = maximum if curnumber < 1
|
||||
numwindow.text = _INTL("x{1}<r>$ {2}", curnumber, (curnumber * itemprice).to_s_formatted)
|
||||
elsif Input.trigger?(Input::USE)
|
||||
pbPlayDecisionSE
|
||||
ret = curnumber
|
||||
break
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
pbPlayCancelSE
|
||||
ret = 0
|
||||
break
|
||||
end
|
||||
end
|
||||
}
|
||||
}
|
||||
helpwindow.visible = false
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbChooseBuyItem
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
@sprites["helpwindow"].visible = false
|
||||
pbActivateWindow(@sprites, "itemwindow") {
|
||||
pbRefresh
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
olditem = itemwindow.item
|
||||
self.update
|
||||
if itemwindow.item != olditem
|
||||
@sprites["icon"].item = itemwindow.item
|
||||
@sprites["itemtextwindow"].text =
|
||||
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit shopping.")
|
||||
end
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
return nil
|
||||
elsif Input.trigger?(Input::USE)
|
||||
if itemwindow.index < @stock.length
|
||||
pbRefresh
|
||||
return @stock[itemwindow.index]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def pbChooseSellItem
|
||||
if @subscene
|
||||
return @subscene.pbChooseItem
|
||||
else
|
||||
return pbChooseBuyItem
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonMartScreen
|
||||
def initialize(scene, stock, adapter = PokemonMartAdapter.new)
|
||||
@scene = scene
|
||||
@stock = stock
|
||||
@adapter = adapter
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
return @scene.pbConfirm(msg)
|
||||
end
|
||||
|
||||
def pbDisplay(msg)
|
||||
return @scene.pbDisplay(msg)
|
||||
end
|
||||
|
||||
def pbDisplayPaused(msg, &block)
|
||||
return @scene.pbDisplayPaused(msg, &block)
|
||||
end
|
||||
|
||||
def pbBuyScreen
|
||||
@scene.pbStartBuyScene(@stock, @adapter)
|
||||
item = nil
|
||||
loop do
|
||||
pbWait(4)
|
||||
item = @scene.pbChooseBuyItem
|
||||
break if !item
|
||||
quantity = 0
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
price = @adapter.getPrice(item)
|
||||
if @adapter.getMoney < price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
if GameData::Item.get(item).is_important?
|
||||
if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
|
||||
itemname, price.to_s_formatted))
|
||||
next
|
||||
end
|
||||
quantity = 1
|
||||
else
|
||||
maxafford = (price <= 0) ? Settings::BAG_MAX_PER_SLOT : @adapter.getMoney / price
|
||||
maxafford = Settings::BAG_MAX_PER_SLOT if maxafford > Settings::BAG_MAX_PER_SLOT
|
||||
quantity = @scene.pbChooseNumber(
|
||||
_INTL("{1}? Certainly. How many would you like?", itemname), item, maxafford)
|
||||
next if quantity == 0
|
||||
price *= quantity
|
||||
if !pbConfirm(_INTL("{1}, and you want {2}. That will be ${3}. OK?",
|
||||
itemname, quantity, price.to_s_formatted))
|
||||
next
|
||||
end
|
||||
end
|
||||
if @adapter.getMoney < price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
added = 0
|
||||
quantity.times do
|
||||
break if !@adapter.addItem(item)
|
||||
added += 1
|
||||
end
|
||||
if added != quantity
|
||||
added.times do
|
||||
if !@adapter.removeItem(item)
|
||||
raise _INTL("Failed to delete stored items")
|
||||
end
|
||||
end
|
||||
pbDisplayPaused(_INTL("You have no more room in the Bag."))
|
||||
else
|
||||
@adapter.setMoney(@adapter.getMoney - price)
|
||||
for i in 0...@stock.length
|
||||
if GameData::Item.get(@stock[i]).is_important? && $PokemonBag.pbHasItem?(@stock[i])
|
||||
@stock[i] = nil
|
||||
end
|
||||
end
|
||||
@stock.compact!
|
||||
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
|
||||
if $PokemonBag
|
||||
if quantity >= 10 && GameData::Item.get(item).is_poke_ball? && GameData::Item.exists?(:PREMIERBALL)
|
||||
if @adapter.addItem(GameData::Item.get(:PREMIERBALL))
|
||||
pbDisplayPaused(_INTL("I'll throw in a Premier Ball, too."))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@scene.pbEndBuyScene
|
||||
end
|
||||
|
||||
def pbSellScreen
|
||||
item = @scene.pbStartSellScene(@adapter.getInventory, @adapter)
|
||||
loop do
|
||||
item = @scene.pbChooseSellItem
|
||||
break if !item
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
price = @adapter.getPrice(item, true)
|
||||
if !@adapter.canSell?(item)
|
||||
pbDisplayPaused(_INTL("{1}? Oh, no. I can't buy that.", itemname))
|
||||
next
|
||||
end
|
||||
qty = @adapter.getQuantity(item)
|
||||
next if qty == 0
|
||||
@scene.pbShowMoney
|
||||
if qty > 1
|
||||
qty = @scene.pbChooseNumber(
|
||||
_INTL("{1}? How many would you like to sell?", itemname), item, qty)
|
||||
end
|
||||
if qty == 0
|
||||
@scene.pbHideMoney
|
||||
next
|
||||
end
|
||||
price /= 2
|
||||
price *= qty
|
||||
if pbConfirm(_INTL("I can pay ${1}. Would that be OK?", price.to_s_formatted))
|
||||
@adapter.setMoney(@adapter.getMoney + price)
|
||||
qty.times do
|
||||
@adapter.removeItem(item)
|
||||
end
|
||||
pbDisplayPaused(_INTL("Turned over the {1} and received ${2}.", itemname, price.to_s_formatted)) { pbSEPlay("Mart buy item") }
|
||||
@scene.pbRefresh
|
||||
end
|
||||
@scene.pbHideMoney
|
||||
end
|
||||
@scene.pbEndSellScene
|
||||
end
|
||||
end
|
||||
|
||||
def replaceShopStockWithRandomized(stock)
|
||||
if $PokemonGlobal.randomItemsHash != nil
|
||||
newStock = []
|
||||
for item in stock
|
||||
newItem = $PokemonGlobal.randomItemsHash[item]
|
||||
if newItem != nil && GameData::Item.get(newItem).price > 0 && !Settings::EXCLUDE_FROM_RANDOM_SHOPS.include?(newItem)
|
||||
newStock << newItem
|
||||
else
|
||||
newStock << item
|
||||
end
|
||||
end
|
||||
return newStock
|
||||
end
|
||||
return stock
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbPokemonMart(stock, speech = nil, cantsell = false)
|
||||
if $game_switches[SWITCH_RANDOM_ITEMS_GENERAL] && $game_switches[SWITCH_RANDOM_SHOP_ITEMS]
|
||||
stock = replaceShopStockWithRandomized(stock)
|
||||
end
|
||||
|
||||
for i in 0...stock.length
|
||||
stock[i] = GameData::Item.get(stock[i]).id
|
||||
stock[i] = nil if GameData::Item.get(stock[i]).is_important? && $PokemonBag.pbHasItem?(stock[i])
|
||||
end
|
||||
stock.compact!
|
||||
commands = []
|
||||
cmdBuy = -1
|
||||
cmdSell = -1
|
||||
cmdQuit = -1
|
||||
commands[cmdBuy = commands.length] = _INTL("Buy")
|
||||
commands[cmdSell = commands.length] = _INTL("Sell") if !cantsell
|
||||
commands[cmdQuit = commands.length] = _INTL("Quit")
|
||||
cmd = pbMessage(
|
||||
speech ? speech : _INTL("Welcome! How may I serve you?"),
|
||||
commands, cmdQuit + 1)
|
||||
loop do
|
||||
if cmdBuy >= 0 && cmd == cmdBuy
|
||||
scene = PokemonMart_Scene.new
|
||||
screen = PokemonMartScreen.new(scene, stock)
|
||||
screen.pbBuyScreen
|
||||
elsif cmdSell >= 0 && cmd == cmdSell
|
||||
scene = PokemonMart_Scene.new
|
||||
screen = PokemonMartScreen.new(scene, stock)
|
||||
screen.pbSellScreen
|
||||
else
|
||||
pbMessage(_INTL("Please come again!"))
|
||||
break
|
||||
end
|
||||
cmd = pbMessage(_INTL("Is there anything else I can help you with?"),
|
||||
commands, cmdQuit + 1)
|
||||
end
|
||||
$game_temp.clear_mart_prices
|
||||
end
|
||||
@@ -1,217 +0,0 @@
|
||||
#===============================================================================
|
||||
# Scene class for handling appearance of the screen
|
||||
#===============================================================================
|
||||
class MoveRelearner_Scene
|
||||
VISIBLEMOVES = 4
|
||||
|
||||
def pbDisplay(msg,brief=false)
|
||||
UIHelper.pbDisplay(@sprites["msgwindow"],msg,brief) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbConfirm(msg)
|
||||
UIHelper.pbConfirm(@sprites["msgwindow"],msg) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def set_moves(moves_list)
|
||||
@moves = moves_list
|
||||
end
|
||||
|
||||
def pbStartScene(pokemon,moves)
|
||||
@pokemon=pokemon
|
||||
@moves=moves
|
||||
moveCommands=[]
|
||||
moves.each { |m| moveCommands.push(GameData::Move.get(m).name) }
|
||||
# Create sprite hash
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
@sprites={}
|
||||
addBackgroundPlane(@sprites,"bg","reminderbg",@viewport)
|
||||
@sprites["pokeicon"]=PokemonIconSprite.new(@pokemon,@viewport)
|
||||
@sprites["pokeicon"].setOffset(PictureOrigin::Center)
|
||||
@sprites["pokeicon"].x=320
|
||||
@sprites["pokeicon"].y=84
|
||||
@sprites["background"]=IconSprite.new(0,0,@viewport)
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/reminderSel")
|
||||
@sprites["background"].y=78
|
||||
@sprites["background"].src_rect=Rect.new(0,72,258,72)
|
||||
@sprites["overlay"]=BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
pbSetSystemFont(@sprites["overlay"].bitmap)
|
||||
@sprites["commands"]=Window_CommandPokemon.new(moveCommands,32)
|
||||
@sprites["commands"].height=32*(VISIBLEMOVES+1)
|
||||
@sprites["commands"].visible=false
|
||||
@sprites["msgwindow"]=Window_AdvancedTextPokemon.new("")
|
||||
@sprites["msgwindow"].visible=false
|
||||
@sprites["msgwindow"].viewport=@viewport
|
||||
@typebitmap=AnimatedBitmap.new(_INTL("Graphics/Pictures/types"))
|
||||
pbDrawMoveList
|
||||
pbDeactivateWindows(@sprites)
|
||||
# Fade in all sprites
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbDrawMoveList
|
||||
overlay=@sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
if @pokemon
|
||||
type1_number = GameData::Type.get(@pokemon.type1).id_number
|
||||
type2_number = GameData::Type.get(@pokemon.type2).id_number
|
||||
type1rect=Rect.new(0, type1_number * 28, 64, 28)
|
||||
type2rect=Rect.new(0, type2_number * 28, 64, 28)
|
||||
if @pokemon.type1==@pokemon.type2
|
||||
overlay.blt(400,70,@typebitmap.bitmap,type1rect)
|
||||
else
|
||||
overlay.blt(366,70,@typebitmap.bitmap,type1rect)
|
||||
overlay.blt(436,70,@typebitmap.bitmap,type2rect)
|
||||
end
|
||||
end
|
||||
|
||||
text = @pokemon ? "Teach which move?" : "Moves list"
|
||||
textpos=[
|
||||
[_INTL(text),16,2,0,Color.new(88,88,80),Color.new(168,184,184)]
|
||||
]
|
||||
imagepos=[]
|
||||
yPos=76
|
||||
for i in 0...VISIBLEMOVES
|
||||
moveobject=@moves[@sprites["commands"].top_item+i]
|
||||
if moveobject
|
||||
moveData=GameData::Move.get(moveobject)
|
||||
type_number = GameData::Type.get(moveData.type).id_number
|
||||
imagepos.push(["Graphics/Pictures/types", 12, yPos + 8, 0, type_number * 28, 64, 28])
|
||||
textpos.push([moveData.name,80,yPos,0,Color.new(248,248,248),Color.new(0,0,0)])
|
||||
if moveData.total_pp>0
|
||||
textpos.push([_INTL("PP"),112,yPos+32,0,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
textpos.push([_INTL("{1}/{1}",moveData.total_pp),230,yPos+32,1,
|
||||
Color.new(64,64,64),Color.new(176,176,176)])
|
||||
else
|
||||
textpos.push(["-",80,yPos,0,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
textpos.push(["--",228,yPos+32,1,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
end
|
||||
end
|
||||
yPos+=64
|
||||
end
|
||||
imagepos.push(["Graphics/Pictures/reminderSel",
|
||||
0,78+(@sprites["commands"].index-@sprites["commands"].top_item)*64,
|
||||
0,0,258,72])
|
||||
selMoveData=GameData::Move.get(@moves[@sprites["commands"].index])
|
||||
basedamage=selMoveData.base_damage
|
||||
category=selMoveData.category
|
||||
accuracy=selMoveData.accuracy
|
||||
textpos.push([_INTL("CATEGORY"),272,108,0,Color.new(248,248,248),Color.new(0,0,0)])
|
||||
textpos.push([_INTL("POWER"),272,140,0,Color.new(248,248,248),Color.new(0,0,0)])
|
||||
textpos.push([basedamage<=1 ? basedamage==1 ? "???" : "---" : sprintf("%d",basedamage),
|
||||
468,140,2,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
textpos.push([_INTL("ACCURACY"),272,172,0,Color.new(248,248,248),Color.new(0,0,0)])
|
||||
textpos.push([accuracy==0 ? "---" : "#{accuracy}%",
|
||||
468,172,2,Color.new(64,64,64),Color.new(176,176,176)])
|
||||
pbDrawTextPositions(overlay,textpos)
|
||||
imagepos.push(["Graphics/Pictures/category",436,116,0,category*28,64,28])
|
||||
if @sprites["commands"].index<@moves.length-1
|
||||
imagepos.push(["Graphics/Pictures/reminderButtons",48,350,0,0,76,32])
|
||||
end
|
||||
if @sprites["commands"].index>0
|
||||
imagepos.push(["Graphics/Pictures/reminderButtons",134,350,76,0,76,32])
|
||||
end
|
||||
pbDrawImagePositions(overlay,imagepos)
|
||||
drawTextEx(overlay,272,214,230,5,selMoveData.description,
|
||||
Color.new(64,64,64),Color.new(176,176,176))
|
||||
end
|
||||
|
||||
# Processes the scene
|
||||
def pbChooseMove
|
||||
oldcmd=-1
|
||||
pbActivateWindow(@sprites,"commands") {
|
||||
loop do
|
||||
oldcmd=@sprites["commands"].index
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
if @sprites["commands"].index!=oldcmd
|
||||
@sprites["background"].x=0
|
||||
@sprites["background"].y=78+(@sprites["commands"].index-@sprites["commands"].top_item)*64
|
||||
pbDrawMoveList
|
||||
end
|
||||
if Input.trigger?(Input::BACK)
|
||||
return nil
|
||||
elsif Input.trigger?(Input::USE) && @pokemon
|
||||
return @moves[@sprites["commands"].index]
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# End the scene here
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@typebitmap.dispose
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Screen class for handling game logic
|
||||
#===============================================================================
|
||||
class MoveRelearnerScreen
|
||||
def initialize(scene)
|
||||
@scene = scene
|
||||
end
|
||||
|
||||
def pbGetRelearnableMoves(pkmn)
|
||||
return [] if !pkmn || pkmn.egg? || pkmn.shadowPokemon?
|
||||
moves = []
|
||||
pkmn.getMoveList.each do |m|
|
||||
next if m[0] > pkmn.level || pkmn.hasMove?(m[1])
|
||||
moves.push(m[1]) if !moves.include?(m[1])
|
||||
end
|
||||
tmoves = []
|
||||
if pkmn.first_moves
|
||||
for i in pkmn.first_moves
|
||||
tmoves.push(i) if !pkmn.hasMove?(i) && !moves.include?(i)
|
||||
end
|
||||
end
|
||||
moves = tmoves + moves
|
||||
return moves | [] # remove duplicates
|
||||
end
|
||||
|
||||
def pbStartScreen(pkmn,moves=nil)
|
||||
if moves == nil
|
||||
moves = pbGetRelearnableMoves(pkmn)
|
||||
end
|
||||
@scene.pbStartScene(pkmn, moves)
|
||||
loop do
|
||||
move = @scene.pbChooseMove
|
||||
if !pkmn
|
||||
@scene.pbEndScene
|
||||
return false
|
||||
end
|
||||
if move
|
||||
if @scene.pbConfirm(_INTL("Teach {1}?", GameData::Move.get(move).name))
|
||||
if pbLearnMove(pkmn, move, false, true)
|
||||
@scene.pbEndScene
|
||||
return true
|
||||
end
|
||||
end
|
||||
elsif @scene.pbConfirm(_INTL("Give up trying to teach a new move to {1}?", pkmn.name))
|
||||
@scene.pbEndScene
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbRelearnMoveScreen(pkmn)
|
||||
retval = true
|
||||
pbFadeOutIn {
|
||||
scene = MoveRelearner_Scene.new
|
||||
screen = MoveRelearnerScreen.new(scene)
|
||||
retval = screen.pbStartScreen(pkmn)
|
||||
}
|
||||
return retval
|
||||
end
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,421 +0,0 @@
|
||||
#===============================================================================
|
||||
# Mystery Gift system
|
||||
# By Maruno
|
||||
#===============================================================================
|
||||
# This url is the location of an example Mystery Gift file.
|
||||
# You should change it to your file's url once you upload it.
|
||||
#===============================================================================
|
||||
module MysteryGift
|
||||
URL = "https://pastebin.com/raw/w6BqqUsm"
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Creating a new Mystery Gift for the Master file, and editing an existing one.
|
||||
#===============================================================================
|
||||
# type: 0=Pokémon; 1 or higher=item (is the item's quantity).
|
||||
# item: The thing being turned into a Mystery Gift (Pokémon object or item ID).
|
||||
def pbEditMysteryGift(type,item,id=0,giftname="")
|
||||
begin
|
||||
if type==0 # Pokémon
|
||||
commands=[_INTL("Mystery Gift"),
|
||||
_INTL("Faraway place")]
|
||||
commands.push(item.obtain_text) if item.obtain_text && !item.obtain_text.empty?
|
||||
commands.push(_INTL("[Custom]"))
|
||||
loop do
|
||||
command=pbMessage(
|
||||
_INTL("Choose a phrase to be where the gift Pokémon was obtained from."),commands,-1)
|
||||
if command<0
|
||||
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
|
||||
elsif command<commands.length-1
|
||||
item.obtain_text = commands[command]
|
||||
break
|
||||
elsif command==commands.length-1
|
||||
obtainname=pbMessageFreeText(_INTL("Enter a phrase."),"",false,30)
|
||||
if obtainname!=""
|
||||
item.obtain_text = obtainname
|
||||
break
|
||||
end
|
||||
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
|
||||
end
|
||||
end
|
||||
elsif type>0 # Item
|
||||
params=ChooseNumberParams.new
|
||||
params.setRange(1,99999)
|
||||
params.setDefaultValue(type)
|
||||
params.setCancelValue(0)
|
||||
loop do
|
||||
newtype=pbMessageChooseNumber(_INTL("Choose a quantity of {1}.",
|
||||
GameData::Item.get(item).name),params)
|
||||
if newtype==0
|
||||
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
|
||||
else
|
||||
type=newtype
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if id==0
|
||||
master=[]
|
||||
idlist=[]
|
||||
if safeExists?("MysteryGiftMaster.txt")
|
||||
master=IO.read("MysteryGiftMaster.txt")
|
||||
master=pbMysteryGiftDecrypt(master)
|
||||
end
|
||||
for i in master; idlist.push(i[0]); end
|
||||
params=ChooseNumberParams.new
|
||||
params.setRange(0,99999)
|
||||
params.setDefaultValue(id)
|
||||
params.setCancelValue(0)
|
||||
loop do
|
||||
newid=pbMessageChooseNumber(_INTL("Choose a unique ID for this gift."),params)
|
||||
if newid==0
|
||||
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
|
||||
else
|
||||
if idlist.include?(newid)
|
||||
pbMessage(_INTL("That ID is already used by a Mystery Gift."))
|
||||
else
|
||||
id=newid
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
loop do
|
||||
newgiftname=pbMessageFreeText(_INTL("Enter a name for the gift."),giftname,false,250)
|
||||
if newgiftname!=""
|
||||
giftname=newgiftname
|
||||
break
|
||||
end
|
||||
return nil if pbConfirmMessage(_INTL("Stop editing this gift?"))
|
||||
end
|
||||
return [id,type,item,giftname]
|
||||
rescue
|
||||
pbMessage(_INTL("Couldn't edit the gift."))
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def pbCreateMysteryGift(type,item)
|
||||
gift=pbEditMysteryGift(type,item)
|
||||
if !gift
|
||||
pbMessage(_INTL("Didn't create a gift."))
|
||||
else
|
||||
begin
|
||||
if safeExists?("MysteryGiftMaster.txt")
|
||||
master=IO.read("MysteryGiftMaster.txt")
|
||||
master=pbMysteryGiftDecrypt(master)
|
||||
master.push(gift)
|
||||
else
|
||||
master=[gift]
|
||||
end
|
||||
string=pbMysteryGiftEncrypt(master)
|
||||
File.open("MysteryGiftMaster.txt","wb") { |f| f.write(string) }
|
||||
pbMessage(_INTL("The gift was saved to MysteryGiftMaster.txt."))
|
||||
rescue
|
||||
pbMessage(_INTL("Couldn't save the gift to MysteryGiftMaster.txt."))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Debug option for managing gifts in the Master file and exporting them to a
|
||||
# file to be uploaded.
|
||||
#===============================================================================
|
||||
def pbManageMysteryGifts
|
||||
if !safeExists?("MysteryGiftMaster.txt")
|
||||
pbMessage(_INTL("There are no Mystery Gifts defined."))
|
||||
return
|
||||
end
|
||||
# Load all gifts from the Master file.
|
||||
master=IO.read("MysteryGiftMaster.txt")
|
||||
master=pbMysteryGiftDecrypt(master)
|
||||
if !master || !master.is_a?(Array) || master.length==0
|
||||
pbMessage(_INTL("There are no Mystery Gifts defined."))
|
||||
return
|
||||
end
|
||||
# Download all gifts from online
|
||||
msgwindow=pbCreateMessageWindow
|
||||
pbMessageDisplay(msgwindow,_INTL("Searching for online gifts...\\wtnp[0]"))
|
||||
online = pbDownloadToString(MysteryGift::URL)
|
||||
pbDisposeMessageWindow(msgwindow)
|
||||
if nil_or_empty?(online)
|
||||
pbMessage(_INTL("No online Mystery Gifts found.\\wtnp[20]"))
|
||||
online=[]
|
||||
else
|
||||
pbMessage(_INTL("Online Mystery Gifts found.\\wtnp[20]"))
|
||||
online=pbMysteryGiftDecrypt(online)
|
||||
t=[]
|
||||
online.each { |gift| t.push(gift[0]) }
|
||||
online=t
|
||||
end
|
||||
# Show list of all gifts.
|
||||
command=0
|
||||
loop do
|
||||
commands=pbRefreshMGCommands(master,online)
|
||||
command=pbMessage(_INTL("\\ts[]Manage Mystery Gifts (X=online)."),commands,-1,nil,command)
|
||||
# Gift chosen
|
||||
if command==-1 || command==commands.length-1 # Cancel
|
||||
break
|
||||
elsif command==commands.length-2 # Export selected to file
|
||||
begin
|
||||
newfile=[]
|
||||
for gift in master
|
||||
newfile.push(gift) if online.include?(gift[0])
|
||||
end
|
||||
string=pbMysteryGiftEncrypt(newfile)
|
||||
File.open("MysteryGift.txt","wb") { |f| f.write(string) }
|
||||
pbMessage(_INTL("The gifts were saved to MysteryGift.txt."))
|
||||
pbMessage(_INTL("Upload MysteryGift.txt to the Internet."))
|
||||
rescue
|
||||
pbMessage(_INTL("Couldn't save the gifts to MysteryGift.txt."))
|
||||
end
|
||||
elsif command>=0 && command<commands.length-2 # A gift
|
||||
cmd=0
|
||||
loop do
|
||||
commands=pbRefreshMGCommands(master,online)
|
||||
gift=master[command]
|
||||
cmds=[_INTL("Toggle on/offline"),
|
||||
_INTL("Edit"),
|
||||
_INTL("Receive"),
|
||||
_INTL("Delete"),
|
||||
_INTL("Cancel")]
|
||||
cmd=pbMessage("\\ts[]"+commands[command],cmds,-1,nil,cmd)
|
||||
if cmd==-1 || cmd==cmds.length-1
|
||||
break
|
||||
elsif cmd==0 # Toggle on/offline
|
||||
if online.include?(gift[0])
|
||||
for i in 0...online.length
|
||||
online[i]=nil if online[i]==gift[0]
|
||||
end
|
||||
online.compact!
|
||||
else
|
||||
online.push(gift[0])
|
||||
end
|
||||
elsif cmd==1 # Edit
|
||||
newgift=pbEditMysteryGift(gift[1],gift[2],gift[0],gift[3])
|
||||
master[command]=newgift if newgift
|
||||
elsif cmd==2 # Receive
|
||||
if !$Trainer
|
||||
pbMessage(_INTL("There is no save file loaded. Cannot receive any gifts."))
|
||||
next
|
||||
end
|
||||
replaced=false
|
||||
for i in 0...$Trainer.mystery_gifts.length
|
||||
if $Trainer.mystery_gifts[i][0]==gift[0]
|
||||
$Trainer.mystery_gifts[i]=gift; replaced=true
|
||||
end
|
||||
end
|
||||
$Trainer.mystery_gifts.push(gift) if !replaced
|
||||
pbReceiveMysteryGift(gift[0])
|
||||
elsif cmd==3 # Delete
|
||||
if pbConfirmMessage(_INTL("Are you sure you want to delete this gift?"))
|
||||
master[command]=nil
|
||||
master.compact!
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def pbRefreshMGCommands(master, online)
|
||||
commands = []
|
||||
for gift in master
|
||||
itemname = "BLANK"
|
||||
if gift[1] == 0
|
||||
itemname = gift[2].speciesName
|
||||
elsif gift[1] > 0
|
||||
itemname = GameData::Item.get(gift[2]).name + sprintf(" x%d", gift[1])
|
||||
end
|
||||
ontext = ["[ ]", "[X]"][(online.include?(gift[0])) ? 1 : 0]
|
||||
commands.push(_INTL("{1} {2}: {3} ({4})", ontext, gift[0], gift[3], itemname))
|
||||
end
|
||||
commands.push(_INTL("Export selected to file"))
|
||||
commands.push(_INTL("Cancel"))
|
||||
return commands
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Downloads all available Mystery Gifts that haven't been downloaded yet.
|
||||
#===============================================================================
|
||||
# Called from the Continue/New Game screen.
|
||||
def pbDownloadMysteryGift(trainer)
|
||||
sprites={}
|
||||
viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
viewport.z=99999
|
||||
addBackgroundPlane(sprites,"background","mysteryGiftbg",viewport)
|
||||
pbFadeInAndShow(sprites)
|
||||
sprites["msgwindow"]=pbCreateMessageWindow
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("Searching for a gift.\nPlease wait...\\wtnp[0]"))
|
||||
string = pbDownloadToString(MysteryGift::URL)
|
||||
if nil_or_empty?(string)
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available."))
|
||||
else
|
||||
online=pbMysteryGiftDecrypt(string)
|
||||
pending=[]
|
||||
for gift in online
|
||||
notgot=true
|
||||
for j in trainer.mystery_gifts
|
||||
notgot=false if j[0]==gift[0]
|
||||
end
|
||||
pending.push(gift) if notgot
|
||||
end
|
||||
if pending.length==0
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available."))
|
||||
else
|
||||
loop do
|
||||
commands=[]
|
||||
for gift in pending; commands.push(gift[3]); end
|
||||
commands.push(_INTL("Cancel"))
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("Choose the gift you want to receive.\\wtnp[0]"))
|
||||
command=pbShowCommands(sprites["msgwindow"],commands,-1)
|
||||
if command==-1 || command==commands.length-1
|
||||
break
|
||||
else
|
||||
gift=pending[command]
|
||||
sprites["msgwindow"].visible=false
|
||||
if gift[1]==0
|
||||
sprite=PokemonSprite.new(viewport)
|
||||
sprite.setOffset(PictureOrigin::Center)
|
||||
sprite.setPokemonBitmap(gift[2])
|
||||
sprite.x=Graphics.width/2
|
||||
sprite.y=-sprite.bitmap.height/2
|
||||
else
|
||||
sprite=ItemIconSprite.new(0,0,gift[2],viewport)
|
||||
sprite.x=Graphics.width/2
|
||||
sprite.y=-sprite.height/2
|
||||
end
|
||||
distanceDiff = 8*20/Graphics.frame_rate
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
sprite.update
|
||||
sprite.y+=distanceDiff
|
||||
break if sprite.y>=Graphics.height/2
|
||||
end
|
||||
pbMEPlay("Battle capture success")
|
||||
(Graphics.frame_rate*3).times do
|
||||
Graphics.update
|
||||
Input.update
|
||||
sprite.update
|
||||
pbUpdateSceneMap
|
||||
end
|
||||
sprites["msgwindow"].visible=true
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("The gift has been received!")) { sprite.update }
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("Please pick up your gift from the deliveryman in any Poké Mart.")) { sprite.update }
|
||||
trainer.mystery_gifts.push(gift)
|
||||
pending[command]=nil; pending.compact!
|
||||
opacityDiff = 16*20/Graphics.frame_rate
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
sprite.update
|
||||
sprite.opacity-=opacityDiff
|
||||
break if sprite.opacity<=0
|
||||
end
|
||||
sprite.dispose
|
||||
end
|
||||
if pending.length==0
|
||||
pbMessageDisplay(sprites["msgwindow"],_INTL("No new gifts are available."))
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
pbFadeOutAndHide(sprites)
|
||||
pbDisposeMessageWindow(sprites["msgwindow"])
|
||||
pbDisposeSpriteHash(sprites)
|
||||
viewport.dispose
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Converts an array of gifts into a string and back.
|
||||
#===============================================================================
|
||||
def pbMysteryGiftEncrypt(gift)
|
||||
ret=[Zlib::Deflate.deflate(Marshal.dump(gift))].pack("m")
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbMysteryGiftDecrypt(gift)
|
||||
return [] if nil_or_empty?(gift)
|
||||
ret = Marshal.restore(Zlib::Inflate.inflate(gift.unpack("m")[0]))
|
||||
if ret
|
||||
ret.each do |gift|
|
||||
if gift[1] == 0 # Pokémon
|
||||
gift[2] = PokeBattle_Pokemon.convert(gift[2])
|
||||
else # Item
|
||||
gift[2] = GameData::Item.get(gift[2]).id
|
||||
end
|
||||
end
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
#===============================================================================
|
||||
# Collecting a Mystery Gift from the deliveryman.
|
||||
#===============================================================================
|
||||
def pbNextMysteryGiftID
|
||||
for i in $Trainer.mystery_gifts
|
||||
return i[0] if i.length>1
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def pbReceiveMysteryGift(id)
|
||||
index=-1
|
||||
for i in 0...$Trainer.mystery_gifts.length
|
||||
if $Trainer.mystery_gifts[i][0]==id && $Trainer.mystery_gifts[i].length>1
|
||||
index=i
|
||||
break
|
||||
end
|
||||
end
|
||||
if index==-1
|
||||
pbMessage(_INTL("Couldn't find an unclaimed Mystery Gift with ID {1}.",id))
|
||||
return false
|
||||
end
|
||||
gift=$Trainer.mystery_gifts[index]
|
||||
if gift[1]==0 # Pokémon
|
||||
gift[2].personalID = rand(2**16) | rand(2**16) << 16
|
||||
gift[2].calc_stats
|
||||
time=pbGetTimeNow
|
||||
gift[2].timeReceived=time.getgm.to_i
|
||||
gift[2].obtain_method = 4 # Fateful encounter
|
||||
gift[2].record_first_moves
|
||||
if $game_map
|
||||
gift[2].obtain_map=$game_map.map_id
|
||||
gift[2].obtain_level=gift[2].level
|
||||
else
|
||||
gift[2].obtain_map=0
|
||||
gift[2].obtain_level=gift[2].level
|
||||
end
|
||||
if pbAddPokemonSilent(gift[2])
|
||||
pbMessage(_INTL("\\me[Pkmn get]{1} received {2}!",$Trainer.name,gift[2].name))
|
||||
$Trainer.mystery_gifts[index]=[id]
|
||||
return true
|
||||
end
|
||||
elsif gift[1]>0 # Item
|
||||
item=gift[2]
|
||||
qty=gift[1]
|
||||
if $PokemonBag.pbCanStore?(item,qty)
|
||||
$PokemonBag.pbStoreItem(item,qty)
|
||||
itm = GameData::Item.get(item)
|
||||
itemname=(qty>1) ? itm.name_plural : itm.name
|
||||
if item == :LEFTOVERS
|
||||
pbMessage(_INTL("\\me[Item get]You obtained some \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
|
||||
elsif itm.is_machine? # TM or HM
|
||||
pbMessage(_INTL("\\me[Item get]You obtained \\c[1]{1} {2}\\c[0]!\\wtnp[30]",itemname,
|
||||
GameData::Move.get(itm.move).name))
|
||||
elsif qty>1
|
||||
pbMessage(_INTL("\\me[Item get]You obtained {1} \\c[1]{2}\\c[0]!\\wtnp[30]",qty,itemname))
|
||||
elsif itemname.starts_with_vowel?
|
||||
pbMessage(_INTL("\\me[Item get]You obtained an \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
|
||||
else
|
||||
pbMessage(_INTL("\\me[Item get]You obtained a \\c[1]{1}\\c[0]!\\wtnp[30]",itemname))
|
||||
end
|
||||
$Trainer.mystery_gifts[index]=[id]
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
@@ -1,804 +0,0 @@
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class Window_CharacterEntry < Window_DrawableCommand
|
||||
XSIZE=13
|
||||
YSIZE=4
|
||||
|
||||
def initialize(charset,viewport=nil)
|
||||
@viewport=viewport
|
||||
@charset=charset
|
||||
@othercharset=""
|
||||
super(0,96,480,192)
|
||||
colors=getDefaultTextColors(self.windowskin)
|
||||
self.baseColor=colors[0]
|
||||
self.shadowColor=colors[1]
|
||||
self.columns=XSIZE
|
||||
refresh
|
||||
end
|
||||
|
||||
def setOtherCharset(value)
|
||||
@othercharset=value.clone
|
||||
refresh
|
||||
end
|
||||
|
||||
def setCharset(value)
|
||||
@charset=value.clone
|
||||
refresh
|
||||
end
|
||||
|
||||
def character
|
||||
if self.index<0 || self.index>=@charset.length
|
||||
return ""
|
||||
else
|
||||
return @charset[self.index]
|
||||
end
|
||||
end
|
||||
|
||||
def command
|
||||
return -1 if self.index==@charset.length
|
||||
return -2 if self.index==@charset.length+1
|
||||
return -3 if self.index==@charset.length+2
|
||||
return self.index
|
||||
end
|
||||
|
||||
def itemCount
|
||||
return @charset.length+3
|
||||
end
|
||||
|
||||
def drawItem(index,_count,rect)
|
||||
rect=drawCursor(index,rect)
|
||||
if index==@charset.length # -1
|
||||
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,"[ ]",
|
||||
self.baseColor,self.shadowColor)
|
||||
elsif index==@charset.length+1 # -2
|
||||
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,@othercharset,
|
||||
self.baseColor,self.shadowColor)
|
||||
elsif index==@charset.length+2 # -3
|
||||
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,_INTL("OK"),
|
||||
self.baseColor,self.shadowColor)
|
||||
else
|
||||
pbDrawShadowText(self.contents,rect.x,rect.y,rect.width,rect.height,@charset[index],
|
||||
self.baseColor,self.shadowColor)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Text entry screen - free typing.
|
||||
#===============================================================================
|
||||
class PokemonEntryScene
|
||||
@@Characters=[
|
||||
[("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz").scan(/./),"[*]"],
|
||||
[("0123456789 !@\#$%^&*() ~`-_+={}[] :;'\"<>,.?/ ").scan(/./),"[A]"],
|
||||
]
|
||||
USEKEYBOARD=true
|
||||
|
||||
def pbStartScene(helptext,minlength,maxlength,initialText,subject=0,pokemon=nil)
|
||||
@sprites={}
|
||||
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||
@viewport.z=99999
|
||||
if USEKEYBOARD
|
||||
@sprites["entry"]=Window_TextEntry_Keyboard.new(initialText,
|
||||
0,0,400-112,96,helptext,true)
|
||||
Input.text_input = true
|
||||
else
|
||||
@sprites["entry"]=Window_TextEntry.new(initialText,0,0,400,96,helptext,true)
|
||||
end
|
||||
@sprites["entry"].x=(Graphics.width/2)-(@sprites["entry"].width/2)+32
|
||||
@sprites["entry"].viewport=@viewport
|
||||
@sprites["entry"].visible=true
|
||||
@minlength=minlength
|
||||
@maxlength=maxlength
|
||||
@symtype=0
|
||||
@sprites["entry"].maxlength=maxlength
|
||||
if !USEKEYBOARD
|
||||
@sprites["entry2"]=Window_CharacterEntry.new(@@Characters[@symtype][0])
|
||||
@sprites["entry2"].setOtherCharset(@@Characters[@symtype][1])
|
||||
@sprites["entry2"].viewport=@viewport
|
||||
@sprites["entry2"].visible=true
|
||||
@sprites["entry2"].x=(Graphics.width/2)-(@sprites["entry2"].width/2)
|
||||
end
|
||||
if minlength==0
|
||||
@sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Enter text using the keyboard. Press\nEnter to confirm, or Esc to cancel."),
|
||||
32,Graphics.height-96,Graphics.width-64,96,@viewport
|
||||
)
|
||||
else
|
||||
@sprites["helpwindow"]=Window_UnformattedTextPokemon.newWithSize(
|
||||
_INTL("Enter text using the keyboard.\nPress Enter to confirm."),
|
||||
32,Graphics.height-96,Graphics.width-64,96,@viewport
|
||||
)
|
||||
end
|
||||
@sprites["helpwindow"].letterbyletter=false
|
||||
@sprites["helpwindow"].viewport=@viewport
|
||||
@sprites["helpwindow"].visible=USEKEYBOARD
|
||||
@sprites["helpwindow"].baseColor=Color.new(16,24,32)
|
||||
@sprites["helpwindow"].shadowColor=Color.new(168,184,184)
|
||||
addBackgroundPlane(@sprites,"background","Naming/bg_2",@viewport)
|
||||
case subject
|
||||
when 1 # Player
|
||||
meta=GameData::Metadata.get_player($Trainer.character_ID)
|
||||
if meta
|
||||
@sprites["shadow"]=IconSprite.new(0,0,@viewport)
|
||||
@sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow")
|
||||
@sprites["shadow"].x=33*2
|
||||
@sprites["shadow"].y=32*2
|
||||
filename=pbGetPlayerCharset(meta,1,nil,true)
|
||||
@sprites["subject"]=TrainerWalkingCharSprite.new(filename,@viewport)
|
||||
charwidth=@sprites["subject"].bitmap.width
|
||||
charheight=@sprites["subject"].bitmap.height
|
||||
@sprites["subject"].x = 44*2 - charwidth/8
|
||||
@sprites["subject"].y = 38*2 - charheight/4
|
||||
end
|
||||
when 2 # Pokémon
|
||||
if pokemon
|
||||
@sprites["shadow"]=IconSprite.new(0,0,@viewport)
|
||||
@sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow")
|
||||
@sprites["shadow"].x=33*2
|
||||
@sprites["shadow"].y=32*2
|
||||
@sprites["subject"]=PokemonIconSprite.new(pokemon,@viewport)
|
||||
@sprites["subject"].setOffset(PictureOrigin::Center)
|
||||
@sprites["subject"].x=88
|
||||
@sprites["subject"].y=54
|
||||
@sprites["gender"]=BitmapSprite.new(32,32,@viewport)
|
||||
@sprites["gender"].x=430
|
||||
@sprites["gender"].y=54
|
||||
@sprites["gender"].bitmap.clear
|
||||
pbSetSystemFont(@sprites["gender"].bitmap)
|
||||
textpos=[]
|
||||
if pokemon.male?
|
||||
textpos.push([_INTL("♂"),0,-6,false,Color.new(0,128,248),Color.new(168,184,184)])
|
||||
elsif pokemon.female?
|
||||
textpos.push([_INTL("♀"),0,-6,false,Color.new(248,24,24),Color.new(168,184,184)])
|
||||
end
|
||||
pbDrawTextPositions(@sprites["gender"].bitmap,textpos)
|
||||
end
|
||||
when 3 # NPC
|
||||
@sprites["shadow"]=IconSprite.new(0,0,@viewport)
|
||||
@sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow")
|
||||
@sprites["shadow"].x=33*2
|
||||
@sprites["shadow"].y=32*2
|
||||
@sprites["subject"]=TrainerWalkingCharSprite.new(pokemon.to_s,@viewport)
|
||||
charwidth=@sprites["subject"].bitmap.width
|
||||
charheight=@sprites["subject"].bitmap.height
|
||||
@sprites["subject"].x = 44*2 - charwidth/8
|
||||
@sprites["subject"].y = 38*2 - charheight/4
|
||||
when 4 # Storage box
|
||||
@sprites["subject"]=TrainerWalkingCharSprite.new(nil,@viewport)
|
||||
@sprites["subject"].altcharset="Graphics/Pictures/Naming/icon_storage"
|
||||
@sprites["subject"].animspeed=4
|
||||
charwidth=@sprites["subject"].bitmap.width
|
||||
charheight=@sprites["subject"].bitmap.height
|
||||
@sprites["subject"].x = 44*2 - charwidth/8
|
||||
@sprites["subject"].y = 26*2 - charheight/2
|
||||
end
|
||||
pbFadeInAndShow(@sprites)
|
||||
end
|
||||
|
||||
def pbEntry1
|
||||
ret=""
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
if Input.triggerex?(:ESCAPE) && @minlength==0
|
||||
ret=""
|
||||
break
|
||||
elsif Input.triggerex?(:RETURN) && @sprites["entry"].text.length>=@minlength
|
||||
ret=@sprites["entry"].text
|
||||
break
|
||||
end
|
||||
@sprites["helpwindow"].update
|
||||
@sprites["entry"].update
|
||||
@sprites["subject"].update if @sprites["subject"]
|
||||
end
|
||||
Input.update
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEntry2
|
||||
ret=""
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@sprites["helpwindow"].update
|
||||
@sprites["entry"].update
|
||||
@sprites["entry2"].update
|
||||
@sprites["subject"].update if @sprites["subject"]
|
||||
if Input.trigger?(Input::USE)
|
||||
index=@sprites["entry2"].command
|
||||
if index==-3 # Confirm text
|
||||
ret=@sprites["entry"].text
|
||||
if ret.length<@minlength || ret.length>@maxlength
|
||||
pbPlayBuzzerSE()
|
||||
else
|
||||
pbPlayDecisionSE()
|
||||
break
|
||||
end
|
||||
elsif index==-1 # Insert a space
|
||||
if @sprites["entry"].insert(" ")
|
||||
pbPlayDecisionSE()
|
||||
else
|
||||
pbPlayBuzzerSE()
|
||||
end
|
||||
elsif index==-2 # Change character set
|
||||
pbPlayDecisionSE()
|
||||
@symtype+=1
|
||||
@symtype=0 if @symtype>=@@Characters.length
|
||||
@sprites["entry2"].setCharset(@@Characters[@symtype][0])
|
||||
@sprites["entry2"].setOtherCharset(@@Characters[@symtype][1])
|
||||
else # Insert given character
|
||||
if @sprites["entry"].insert(@sprites["entry2"].character)
|
||||
pbPlayDecisionSE()
|
||||
else
|
||||
pbPlayBuzzerSE()
|
||||
end
|
||||
end
|
||||
next
|
||||
end
|
||||
end
|
||||
Input.update
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEntry
|
||||
return USEKEYBOARD ? pbEntry1 : pbEntry2
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites)
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
Input.text_input = false if USEKEYBOARD
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Text entry screen - arrows to select letter.
|
||||
#===============================================================================
|
||||
class PokemonEntryScene2
|
||||
@@Characters = [
|
||||
[("ABCDEFGHIJ ,." + "KLMNOPQRST '-" + "UVWXYZ ♂♀" + " " + "0123456789 ").scan(/./), _INTL("UPPER")],
|
||||
[("abcdefghij ,." + "klmnopqrst '-" + "uvwxyz ♂♀" + " " + "0123456789 ").scan(/./), _INTL("lower")],
|
||||
[("ÀÁÂÄÃàáâäã Ææ" + "ÈÉÊË èéêë Çç" + "ÌÍÎÏ ìíîï Ññ" + "ÒÓÔÖÕòóôöõ Ýý" + "ÙÚÛÜ ùúûü ").scan(/./), _INTL("accents")],
|
||||
[(",.'\":;!?¡¿ ♂♀" + "~@#*&$µ¶§ " + "()[]{}<>«» " + "+-×÷=±%¹²³¼½¾" + "^_/\\| ").scan(/./), _INTL("other")]
|
||||
]
|
||||
ROWS = 13
|
||||
COLUMNS = 5
|
||||
MODE1 = -6
|
||||
MODE2 = -5
|
||||
MODE3 = -4
|
||||
MODE4 = -3
|
||||
BACK = -2
|
||||
OK = -1
|
||||
|
||||
class NameEntryCursor
|
||||
def initialize(viewport)
|
||||
@sprite = SpriteWrapper.new(viewport)
|
||||
@cursortype = 0
|
||||
@cursor1 = AnimatedBitmap.new("Graphics/Pictures/Naming/cursor_1")
|
||||
@cursor2 = AnimatedBitmap.new("Graphics/Pictures/Naming/cursor_2")
|
||||
@cursor3 = AnimatedBitmap.new("Graphics/Pictures/Naming/cursor_3")
|
||||
@cursorPos = 0
|
||||
updateInternal
|
||||
end
|
||||
|
||||
def setCursorPos(value)
|
||||
@cursorPos = value
|
||||
end
|
||||
|
||||
def updateCursorPos
|
||||
value = @cursorPos
|
||||
case value
|
||||
when PokemonEntryScene2::MODE1 # Upper case
|
||||
@sprite.x = 44
|
||||
@sprite.y = 120
|
||||
@cursortype = 1
|
||||
when PokemonEntryScene2::MODE2 # Lower case
|
||||
@sprite.x = 106
|
||||
@sprite.y = 120
|
||||
@cursortype = 1
|
||||
when PokemonEntryScene2::MODE3 # Accents
|
||||
@sprite.x = 168
|
||||
@sprite.y = 120
|
||||
@cursortype = 1
|
||||
when PokemonEntryScene2::MODE4 # Other symbols
|
||||
@sprite.x = 230
|
||||
@sprite.y = 120
|
||||
@cursortype = 1
|
||||
when PokemonEntryScene2::BACK # Back
|
||||
@sprite.x = 314
|
||||
@sprite.y = 120
|
||||
@cursortype = 2
|
||||
when PokemonEntryScene2::OK # OK
|
||||
@sprite.x = 394
|
||||
@sprite.y = 120
|
||||
@cursortype = 2
|
||||
else
|
||||
if value >= 0
|
||||
@sprite.x = 52 + 32 * (value % PokemonEntryScene2::ROWS)
|
||||
@sprite.y = 180 + 38 * (value / PokemonEntryScene2::ROWS)
|
||||
@cursortype = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def visible=(value)
|
||||
@sprite.visible = value
|
||||
end
|
||||
|
||||
def visible
|
||||
@sprite.visible
|
||||
end
|
||||
|
||||
def color=(value)
|
||||
@sprite.color = value
|
||||
end
|
||||
|
||||
def color
|
||||
@sprite.color
|
||||
end
|
||||
|
||||
def disposed?
|
||||
@sprite.disposed?
|
||||
end
|
||||
|
||||
def updateInternal
|
||||
@cursor1.update
|
||||
@cursor2.update
|
||||
@cursor3.update
|
||||
updateCursorPos
|
||||
case @cursortype
|
||||
when 0 then @sprite.bitmap = @cursor1.bitmap
|
||||
when 1 then @sprite.bitmap = @cursor2.bitmap
|
||||
when 2 then @sprite.bitmap = @cursor3.bitmap
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
updateInternal
|
||||
end
|
||||
|
||||
def dispose
|
||||
@cursor1.dispose
|
||||
@cursor2.dispose
|
||||
@cursor3.dispose
|
||||
@sprite.dispose
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbStartScene(helptext,minlength,maxlength,initialText,subject=0,pokemon=nil)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@viewport.z = 99999
|
||||
@helptext = helptext
|
||||
@helper = CharacterEntryHelper.new(initialText)
|
||||
# Create bitmaps
|
||||
@bitmaps = []
|
||||
for i in 0...@@Characters.length
|
||||
@bitmaps[i] = AnimatedBitmap.new(sprintf("Graphics/Pictures/Naming/overlay_tab_#{i + 1}"))
|
||||
b = @bitmaps[i].bitmap.clone
|
||||
pbSetSystemFont(b)
|
||||
textPos = []
|
||||
for y in 0...COLUMNS
|
||||
for x in 0...ROWS
|
||||
pos = y * ROWS + x
|
||||
textPos.push([@@Characters[i][0][pos], 44 + x * 32, 12 + y * 38, 2,
|
||||
Color.new(16, 24, 32), Color.new(160, 160, 160)])
|
||||
end
|
||||
end
|
||||
pbDrawTextPositions(b, textPos)
|
||||
@bitmaps[@@Characters.length + i] = b
|
||||
end
|
||||
underline_bitmap = BitmapWrapper.new(24, 6)
|
||||
underline_bitmap.fill_rect(2, 2, 22, 4, Color.new(168, 184, 184))
|
||||
underline_bitmap.fill_rect(0, 0, 22, 4, Color.new(16, 24, 32))
|
||||
@bitmaps.push(underline_bitmap)
|
||||
# Create sprites
|
||||
@sprites = {}
|
||||
@sprites["bg"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["bg"].setBitmap("Graphics/Pictures/Naming/bg")
|
||||
case subject
|
||||
when 1 # Player
|
||||
meta = GameData::Metadata.get_player($Trainer.character_ID)
|
||||
if meta
|
||||
@sprites["shadow"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow")
|
||||
@sprites["shadow"].x = 66
|
||||
@sprites["shadow"].y = 64
|
||||
filename = pbGetPlayerCharset(meta, 1, nil, true)
|
||||
@sprites["subject"] = TrainerWalkingCharSprite.new(filename, @viewport)
|
||||
charwidth = @sprites["subject"].bitmap.width
|
||||
charheight = @sprites["subject"].bitmap.height
|
||||
@sprites["subject"].x = 88 - charwidth / 8
|
||||
@sprites["subject"].y = 76 - charheight / 4
|
||||
end
|
||||
when 2 # Pokémon
|
||||
if pokemon
|
||||
@sprites["shadow"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow")
|
||||
@sprites["shadow"].x = 66
|
||||
@sprites["shadow"].y = 64
|
||||
@sprites["subject"] = PokemonIconSprite.new(pokemon, @viewport)
|
||||
@sprites["subject"].setOffset(PictureOrigin::Center)
|
||||
@sprites["subject"].x = 88
|
||||
@sprites["subject"].y = 54
|
||||
@sprites["gender"] = BitmapSprite.new(32, 32, @viewport)
|
||||
@sprites["gender"].x = 430
|
||||
@sprites["gender"].y = 54
|
||||
@sprites["gender"].bitmap.clear
|
||||
pbSetSystemFont(@sprites["gender"].bitmap)
|
||||
textpos = []
|
||||
if pokemon.male?
|
||||
textpos.push([_INTL("♂"), 0, -6, false, Color.new(0, 128, 248), Color.new(168, 184, 184)])
|
||||
elsif pokemon.female?
|
||||
textpos.push([_INTL("♀"), 0, -6, false, Color.new(248, 24, 24), Color.new(168, 184, 184)])
|
||||
end
|
||||
pbDrawTextPositions(@sprites["gender"].bitmap, textpos)
|
||||
end
|
||||
when 3 # NPC
|
||||
@sprites["shadow"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["shadow"].setBitmap("Graphics/Pictures/Naming/icon_shadow")
|
||||
@sprites["shadow"].x = 66
|
||||
@sprites["shadow"].y = 64
|
||||
@sprites["subject"] = TrainerWalkingCharSprite.new(pokemon.to_s, @viewport)
|
||||
charwidth = @sprites["subject"].bitmap.width
|
||||
charheight = @sprites["subject"].bitmap.height
|
||||
@sprites["subject"].x = 88 - charwidth / 8
|
||||
@sprites["subject"].y = 76 - charheight / 4
|
||||
when 4 # Storage box
|
||||
@sprites["subject"] = TrainerWalkingCharSprite.new(nil, @viewport)
|
||||
@sprites["subject"].altcharset = "Graphics/Pictures/Naming/icon_storage"
|
||||
@sprites["subject"].animspeed = 4
|
||||
charwidth = @sprites["subject"].bitmap.width
|
||||
charheight = @sprites["subject"].bitmap.height
|
||||
@sprites["subject"].x = 88 - charwidth / 8
|
||||
@sprites["subject"].y = 52 - charheight / 2
|
||||
end
|
||||
@sprites["bgoverlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
pbDoUpdateOverlay
|
||||
@blanks = []
|
||||
@mode = 0
|
||||
@minlength = minlength
|
||||
@maxlength = maxlength
|
||||
@maxlength.times { |i|
|
||||
@sprites["blank#{i}"] = SpriteWrapper.new(@viewport)
|
||||
@sprites["blank#{i}"].x = 160 + 24 * i
|
||||
@sprites["blank#{i}"].bitmap = @bitmaps[@bitmaps.length - 1]
|
||||
@blanks[i] = 0
|
||||
}
|
||||
@sprites["bottomtab"] = SpriteWrapper.new(@viewport) # Current tab
|
||||
@sprites["bottomtab"].x = 22
|
||||
@sprites["bottomtab"].y = 162
|
||||
@sprites["bottomtab"].bitmap = @bitmaps[@@Characters.length]
|
||||
@sprites["toptab"]=SpriteWrapper.new(@viewport) # Next tab
|
||||
@sprites["toptab"].x = 22 - 504
|
||||
@sprites["toptab"].y = 162
|
||||
@sprites["toptab"].bitmap = @bitmaps[@@Characters.length + 1]
|
||||
@sprites["controls"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["controls"].x = 16
|
||||
@sprites["controls"].y = 96
|
||||
@sprites["controls"].setBitmap(_INTL("Graphics/Pictures/Naming/overlay_controls"))
|
||||
@init = true
|
||||
@sprites["overlay"] = BitmapSprite.new(Graphics.width, Graphics.height, @viewport)
|
||||
pbDoUpdateOverlay2
|
||||
@sprites["cursor"] = NameEntryCursor.new(@viewport)
|
||||
@cursorpos = 0
|
||||
@refreshOverlay = true
|
||||
@sprites["cursor"].setCursorPos(@cursorpos)
|
||||
pbFadeInAndShow(@sprites) { pbUpdate }
|
||||
end
|
||||
|
||||
def pbUpdateOverlay
|
||||
@refreshOverlay = true
|
||||
end
|
||||
|
||||
def pbDoUpdateOverlay2
|
||||
overlay = @sprites["overlay"].bitmap
|
||||
overlay.clear
|
||||
modeIcon = [[_INTL("Graphics/Pictures/Naming/icon_mode"), 44 + @mode * 62, 120, @mode * 60, 0, 60, 44]]
|
||||
pbDrawImagePositions(overlay, modeIcon)
|
||||
end
|
||||
|
||||
def pbDoUpdateOverlay
|
||||
return if !@refreshOverlay
|
||||
@refreshOverlay = false
|
||||
bgoverlay = @sprites["bgoverlay"].bitmap
|
||||
bgoverlay.clear
|
||||
pbSetSystemFont(bgoverlay)
|
||||
textPositions = [
|
||||
[@helptext, 160, 6, false, Color.new(16, 24, 32), Color.new(168, 184, 184)]
|
||||
]
|
||||
chars = @helper.textChars
|
||||
x = 166
|
||||
for ch in chars
|
||||
textPositions.push([ch, x, 42, false, Color.new(16, 24, 32), Color.new(168, 184, 184)])
|
||||
x += 24
|
||||
end
|
||||
pbDrawTextPositions(bgoverlay, textPositions)
|
||||
end
|
||||
|
||||
def pbChangeTab(newtab = @mode + 1)
|
||||
pbSEPlay("GUI naming tab swap start")
|
||||
@sprites["cursor"].visible = false
|
||||
@sprites["toptab"].bitmap = @bitmaps[(newtab % @@Characters.length) + @@Characters.length]
|
||||
# Move bottom (old) tab down off the screen, and move top (new) tab right
|
||||
# onto the screen
|
||||
deltaX = 48 * 20 / Graphics.frame_rate
|
||||
deltaY = 24 * 20 / Graphics.frame_rate
|
||||
loop do
|
||||
if @sprites["bottomtab"].y < 414
|
||||
@sprites["bottomtab"].y += deltaY
|
||||
@sprites["bottomtab"].y = 414 if @sprites["bottomtab"].y > 414
|
||||
end
|
||||
if @sprites["toptab"].x < 22
|
||||
@sprites["toptab"].x += deltaX
|
||||
@sprites["toptab"].x = 22 if @sprites["toptab"].x > 22
|
||||
end
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
break if @sprites["toptab"].x >= 22 && @sprites["bottomtab"].y >= 414
|
||||
end
|
||||
# Swap top and bottom tab around
|
||||
@sprites["toptab"].x, @sprites["bottomtab"].x = @sprites["bottomtab"].x, @sprites["toptab"].x
|
||||
@sprites["toptab"].y, @sprites["bottomtab"].y = @sprites["bottomtab"].y, @sprites["toptab"].y
|
||||
@sprites["toptab"].bitmap, @sprites["bottomtab"].bitmap = @sprites["bottomtab"].bitmap, @sprites["toptab"].bitmap
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
# Set the current mode
|
||||
@mode = newtab % @@Characters.length
|
||||
# Set the top tab up to be the next tab
|
||||
newtab = @bitmaps[((@mode + 1) % @@Characters.length) + @@Characters.length]
|
||||
@sprites["cursor"].visible = true
|
||||
@sprites["toptab"].bitmap = newtab
|
||||
@sprites["toptab"].x = 22 - 504
|
||||
@sprites["toptab"].y = 162
|
||||
pbSEPlay("GUI naming tab swap end")
|
||||
pbDoUpdateOverlay2
|
||||
end
|
||||
|
||||
def pbUpdate
|
||||
for i in 0...@@Characters.length
|
||||
@bitmaps[i].update
|
||||
end
|
||||
if @init || Graphics.frame_count % 5 == 0
|
||||
@init = false
|
||||
cursorpos = @helper.cursor
|
||||
cursorpos = @maxlength - 1 if cursorpos >= @maxlength
|
||||
cursorpos = 0 if cursorpos < 0
|
||||
@maxlength.times { |i|
|
||||
@blanks[i] = (i == cursorpos) ? 1 : 0
|
||||
@sprites["blank#{i}"].y = [78, 82][@blanks[i]]
|
||||
}
|
||||
end
|
||||
pbDoUpdateOverlay
|
||||
pbUpdateSpriteHash(@sprites)
|
||||
end
|
||||
|
||||
def pbColumnEmpty?(m)
|
||||
return false if m >= ROWS - 1
|
||||
chset = @@Characters[@mode][0]
|
||||
COLUMNS.times do |i|
|
||||
return false if chset[i * ROWS + m] != " "
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def wrapmod(x, y)
|
||||
result = x % y
|
||||
result += y if result < 0
|
||||
return result
|
||||
end
|
||||
|
||||
def pbMoveCursor
|
||||
oldcursor = @cursorpos
|
||||
cursordiv = @cursorpos / ROWS # The row the cursor is in
|
||||
cursormod = @cursorpos % ROWS # The column the cursor is in
|
||||
cursororigin = @cursorpos - cursormod
|
||||
if Input.repeat?(Input::LEFT)
|
||||
if @cursorpos < 0 # Controls
|
||||
@cursorpos -= 1
|
||||
@cursorpos = OK if @cursorpos < MODE1
|
||||
else
|
||||
begin
|
||||
cursormod = wrapmod(cursormod - 1, ROWS)
|
||||
@cursorpos = cursororigin + cursormod
|
||||
end while pbColumnEmpty?(cursormod)
|
||||
end
|
||||
elsif Input.repeat?(Input::RIGHT)
|
||||
if @cursorpos < 0 # Controls
|
||||
@cursorpos += 1
|
||||
@cursorpos = MODE1 if @cursorpos > OK
|
||||
else
|
||||
begin
|
||||
cursormod = wrapmod(cursormod + 1, ROWS)
|
||||
@cursorpos = cursororigin + cursormod
|
||||
end while pbColumnEmpty?(cursormod)
|
||||
end
|
||||
elsif Input.repeat?(Input::UP)
|
||||
if @cursorpos < 0 # Controls
|
||||
case @cursorpos
|
||||
when MODE1 then @cursorpos = ROWS * (COLUMNS - 1)
|
||||
when MODE2 then @cursorpos = ROWS * (COLUMNS - 1) + 2
|
||||
when MODE3 then @cursorpos = ROWS * (COLUMNS - 1) + 4
|
||||
when MODE4 then @cursorpos = ROWS * (COLUMNS - 1) + 6
|
||||
when BACK then @cursorpos = ROWS * (COLUMNS - 1) + 9
|
||||
when OK then @cursorpos = ROWS * (COLUMNS - 1) + 11
|
||||
end
|
||||
elsif @cursorpos < ROWS # Top row of letters
|
||||
case @cursorpos
|
||||
when 0, 1 then @cursorpos = MODE1
|
||||
when 2, 3 then @cursorpos = MODE2
|
||||
when 4, 5 then @cursorpos = MODE3
|
||||
when 6, 7 then @cursorpos = MODE4
|
||||
when 8, 9, 10 then @cursorpos = BACK
|
||||
when 11, 12 then @cursorpos = OK
|
||||
end
|
||||
else
|
||||
cursordiv = wrapmod(cursordiv - 1, COLUMNS)
|
||||
@cursorpos = cursordiv * ROWS + cursormod
|
||||
end
|
||||
elsif Input.repeat?(Input::DOWN)
|
||||
if @cursorpos < 0 # Controls
|
||||
case @cursorpos
|
||||
when MODE1 then @cursorpos = 0
|
||||
when MODE2 then @cursorpos = 2
|
||||
when MODE3 then @cursorpos = 4
|
||||
when MODE4 then @cursorpos = 6
|
||||
when BACK then @cursorpos = 9
|
||||
when OK then @cursorpos = 11
|
||||
end
|
||||
elsif @cursorpos >= ROWS * (COLUMNS - 1) # Bottom row of letters
|
||||
case cursormod
|
||||
when 0, 1 then @cursorpos = MODE1
|
||||
when 2, 3 then @cursorpos = MODE2
|
||||
when 4, 5 then @cursorpos = MODE3
|
||||
when 6, 7 then @cursorpos = MODE4
|
||||
when 8, 9, 10 then @cursorpos = BACK
|
||||
else @cursorpos = OK
|
||||
end
|
||||
else
|
||||
cursordiv = wrapmod(cursordiv + 1, COLUMNS)
|
||||
@cursorpos = cursordiv * ROWS + cursormod
|
||||
end
|
||||
end
|
||||
if @cursorpos != oldcursor # Cursor position changed
|
||||
@sprites["cursor"].setCursorPos(@cursorpos)
|
||||
pbPlayCursorSE
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def pbEntry
|
||||
ret = ""
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
pbUpdate
|
||||
next if pbMoveCursor
|
||||
if Input.trigger?(Input::SPECIAL)
|
||||
pbChangeTab
|
||||
elsif Input.trigger?(Input::ACTION)
|
||||
@cursorpos = OK
|
||||
@sprites["cursor"].setCursorPos(@cursorpos)
|
||||
elsif Input.trigger?(Input::BACK)
|
||||
@helper.delete
|
||||
pbPlayCancelSE
|
||||
pbUpdateOverlay
|
||||
elsif Input.trigger?(Input::USE)
|
||||
case @cursorpos
|
||||
when BACK # Backspace
|
||||
@helper.delete
|
||||
pbPlayCancelSE
|
||||
pbUpdateOverlay
|
||||
when OK # Done
|
||||
pbSEPlay("GUI naming confirm")
|
||||
if @helper.length >= @minlength
|
||||
ret = @helper.text
|
||||
break
|
||||
end
|
||||
when MODE1
|
||||
pbChangeTab(0) if @mode != 0
|
||||
when MODE2
|
||||
pbChangeTab(1) if @mode != 1
|
||||
when MODE3
|
||||
pbChangeTab(2) if @mode != 2
|
||||
when MODE4
|
||||
pbChangeTab(3) if @mode != 3
|
||||
else
|
||||
cursormod = @cursorpos % ROWS
|
||||
cursordiv = @cursorpos / ROWS
|
||||
charpos = cursordiv * ROWS + cursormod
|
||||
chset = @@Characters[@mode][0]
|
||||
if @helper.length >= @maxlength
|
||||
@helper.delete
|
||||
end
|
||||
@helper.insert(chset[charpos])
|
||||
pbPlayCursorSE
|
||||
if @helper.length >= @maxlength
|
||||
@cursorpos = OK
|
||||
@sprites["cursor"].setCursorPos(@cursorpos)
|
||||
end
|
||||
pbUpdateOverlay
|
||||
end
|
||||
end
|
||||
end
|
||||
Input.update
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEndScene
|
||||
pbFadeOutAndHide(@sprites) { pbUpdate }
|
||||
for bitmap in @bitmaps
|
||||
bitmap.dispose if bitmap
|
||||
end
|
||||
@bitmaps.clear
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
class PokemonEntry
|
||||
def initialize(scene)
|
||||
@scene=scene
|
||||
end
|
||||
|
||||
def pbStartScreen(helptext,minlength,maxlength,initialText,mode=-1,pokemon=nil)
|
||||
@scene.pbStartScene(helptext,minlength,maxlength,initialText,mode,pokemon)
|
||||
ret=@scene.pbEntry
|
||||
@scene.pbEndScene
|
||||
return ret
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
#
|
||||
#===============================================================================
|
||||
def pbEnterText(helptext,minlength,maxlength,initialText="",mode=0,pokemon=nil,nofadeout=false)
|
||||
ret=""
|
||||
if ($PokemonSystem.textinput==1 rescue false) # Keyboard
|
||||
pbFadeOutIn(99999,nofadeout) {
|
||||
sscene=PokemonEntryScene.new
|
||||
sscreen=PokemonEntry.new(sscene)
|
||||
ret=sscreen.pbStartScreen(helptext,minlength,maxlength,initialText,mode,pokemon)
|
||||
}
|
||||
else # Cursor
|
||||
pbFadeOutIn(99999,nofadeout) {
|
||||
sscene=PokemonEntryScene2.new
|
||||
sscreen=PokemonEntry.new(sscene)
|
||||
ret=sscreen.pbStartScreen(helptext,minlength,maxlength,initialText,mode,pokemon)
|
||||
}
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def pbEnterPlayerName(helptext,minlength,maxlength,initialText="",nofadeout=false)
|
||||
return pbEnterText(helptext,minlength,maxlength,initialText,1,nil,nofadeout)
|
||||
end
|
||||
|
||||
def pbEnterPokemonName(helptext,minlength,maxlength,initialText="",pokemon=nil,nofadeout=false)
|
||||
return pbEnterText(helptext,minlength,maxlength,initialText,2,pokemon,nofadeout)
|
||||
end
|
||||
|
||||
def pbEnterNPCName(helptext,minlength,maxlength,initialText="",id=0,nofadeout=false)
|
||||
return pbEnterText(helptext,minlength,maxlength,initialText,3,id,nofadeout)
|
||||
end
|
||||
|
||||
def pbEnterBoxName(helptext,minlength,maxlength,initialText="",nofadeout=false)
|
||||
return pbEnterText(helptext,minlength,maxlength,initialText,4,nil,nofadeout)
|
||||
end
|
||||
Reference in New Issue
Block a user