mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 21:54:58 +00:00
Migrate a reorganizes bunch of files from PIF
This commit is contained in:
@@ -0,0 +1,409 @@
|
||||
def find_last_outfit(outfit_type_path, firstOutfit)
|
||||
for i in firstOutfit..Settings::MAX_NB_OUTFITS
|
||||
outfit_path = outfit_type_path + "/" + i.to_s #Settings::PLAYER_GRAPHICS_FOLDER + outfit_type_path + "/" + outfit_type_path + "_" + player_sprite + "_" + i.to_s
|
||||
return i - 1 if !Dir.exist?(outfit_path)
|
||||
end
|
||||
return firstOutfit
|
||||
end
|
||||
|
||||
def list_all_numeric_folders(directory_path)
|
||||
entries = Dir.entries(directory_path)
|
||||
# Filter out only the directories whose names are numeric (excluding "." and "..")
|
||||
numeric_folders = entries.select do |entry|
|
||||
full_path = File.join(directory_path, entry)
|
||||
File.directory?(full_path) && entry != '.' && entry != '..' && entry.match?(/^\d+$/)
|
||||
end
|
||||
|
||||
# Convert the folder names to integers and store in an array
|
||||
folder_integers = numeric_folders.map(&:to_i)
|
||||
folder_integers.sort!
|
||||
return folder_integers
|
||||
end
|
||||
|
||||
def list_all_numeric_files_with_filter(directory_path, prefix)
|
||||
entries = Dir.entries(directory_path)
|
||||
prefixless = []
|
||||
for file in entries
|
||||
next if file == "." || file == ".."
|
||||
prefixless << file.gsub((prefix + "_"), "")
|
||||
end
|
||||
|
||||
folder_integers = prefixless.map(&:to_i)
|
||||
folder_integers.sort!
|
||||
return folder_integers
|
||||
end
|
||||
|
||||
#unlocked:
|
||||
# -1 for all outfits unlocked
|
||||
# Otherwise, an array of the ids of unlocked outfits
|
||||
def list_available_outfits(directory, versions = [], unlocked = [], prefix_filter = nil)
|
||||
if prefix_filter
|
||||
outfits = list_all_numeric_files_with_filter(directory, prefix_filter)
|
||||
else
|
||||
outfits = list_all_numeric_folders(directory)
|
||||
end
|
||||
# #echoln outfits
|
||||
# return outfits #todo: remove this return for unlockable outfits
|
||||
available_outfits = []
|
||||
for outfit in outfits
|
||||
if !unlocked || unlocked.include?(outfit)
|
||||
for version in versions
|
||||
available_outfits << outfit.to_s + version
|
||||
end
|
||||
available_outfits << outfit.to_s if versions.empty?
|
||||
end
|
||||
end
|
||||
return available_outfits
|
||||
end
|
||||
|
||||
def get_current_outfit_position(currentOutfit_id, available_outfits)
|
||||
current_index = available_outfits.index(currentOutfit_id)
|
||||
return current_index.nil? ? 0 : current_index
|
||||
end
|
||||
|
||||
def setHairColor(hue_shift)
|
||||
$Trainer.hair_color = hue_shift
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def shiftHatColor(incr,secondary_hat=false)
|
||||
if secondary_hat
|
||||
$Trainer.hat2_color = 0 if !$Trainer.hat2_color
|
||||
$Trainer.hat2_color += incr
|
||||
else
|
||||
$Trainer.hat_color = 0 if !$Trainer.hat_color
|
||||
$Trainer.hat_color += incr
|
||||
end
|
||||
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def shiftClothesColor(incr)
|
||||
$Trainer.clothes_color = 0 if !$Trainer.clothes_color
|
||||
$Trainer.clothes_color += incr
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def shiftHairColor(incr)
|
||||
$Trainer.hair_color = 0 if !$Trainer.hair_color
|
||||
$Trainer.hair_color += incr
|
||||
echoln "Hair color: #{$Trainer.hair_color}"
|
||||
refreshPlayerOutfit()
|
||||
end
|
||||
|
||||
def pbLoadOutfitBitmap(outfitFileName)
|
||||
begin
|
||||
outfitBitmap = RPG::Cache.load_bitmap("", outfitFileName)
|
||||
return outfitBitmap
|
||||
rescue
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def setOutfit(outfit_id)
|
||||
$Trainer.clothes = outfit_id
|
||||
end
|
||||
|
||||
def setHat(hat_id)
|
||||
$Trainer.hat = hat_id
|
||||
end
|
||||
|
||||
def getEasterEggHeldItem()
|
||||
map = $game_map.map_id
|
||||
return "secrets/HOTDOG" if [141, 194].include?(map) #restaurant
|
||||
return "secrets/SNOWBALL" if [670, 693, 698, 694].include?(map)
|
||||
return "secrets/WALLET" if [432, 433, 434, 435, 436, 292].include?(map) #dept. store
|
||||
return "secrets/ALARMCLOCK" if [43, 48, 67, 68, 69, 70, 71, 73].include?(map) #Player room
|
||||
return "SAFARIBALL" if [445, 484, 485, 486, 107, 487, 488, 717, 82, 75, 74].include?(map) #Safari Zone
|
||||
return "secrets/WISP" if [401,402,403,467,468,469].include?(map) #Pokemon Tower
|
||||
return "secrets/SKULL" if [400].include?(map) #Pokemon Tower ground floor
|
||||
return "secrets/ROCK" if [349,350,800,].include?(map) #Rock Tunnel
|
||||
return "secrets/MAGIKARP" if [394,471,189,].include?(map) #Fishing huts
|
||||
return "secrets/AZUREFLUTE" if [694,].include?(map) && $PokemonBag.pbQuantity(:AZUREFLUTE)>=1 #Ice Mountain peak
|
||||
return "secrets/BIGSODA" if [436,].include?(map) && $PokemonBag.pbQuantity(:SODAPOP)>=1 #Celadon dept. store top
|
||||
return "secrets/EGG" if [13,406,214,].include?(map) #Day care
|
||||
return "secrets/STICK" if [266,].include?(map) #Ilex forest
|
||||
return "secrets/BANANA" if [600,].include?(map) #Bond Bridge
|
||||
return "secrets/BERRY" if [619,620,].include?(map) #Berry forest
|
||||
return "secrets/COIN" if [357].include?(map) #Pokemart
|
||||
return "secrets/LATTE" if [406].include?(map) #Celadon Café
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
def getCurrentPokeball(allowEasterEgg=true)
|
||||
otherItem = getEasterEggHeldItem() if allowEasterEgg
|
||||
return otherItem if otherItem
|
||||
firstPokemon = $Trainer.party[0]
|
||||
return firstPokemon.poke_ball if firstPokemon
|
||||
return nil
|
||||
end
|
||||
|
||||
def generate_front_trainer_sprite_bitmap_from_appearance(trainerAppearance)
|
||||
echoln trainerAppearance.hat
|
||||
return generate_front_trainer_sprite_bitmap(false,nil,trainerAppearance.clothes,trainerAppearance.hat,trainerAppearance.hat2,
|
||||
trainerAppearance.hair,trainerAppearance.skin_color,
|
||||
trainerAppearance.hair_color,trainerAppearance.hat_color,trainerAppearance.clothes_color,
|
||||
trainerAppearance.hat2_color)
|
||||
end
|
||||
|
||||
def generate_front_trainer_sprite_bitmap(allowEasterEgg=true, pokeball = nil,
|
||||
clothes_id = nil, hat_id = nil, hat2_id=nil, hair_id = nil,
|
||||
skin_tone_id = nil, hair_color = nil, hat_color = nil, clothes_color = nil,
|
||||
hat2_color = nil)
|
||||
|
||||
clothes_id = $Trainer.clothes if !clothes_id
|
||||
hat_id = $Trainer.hat if !hat_id
|
||||
hat2_id = $Trainer.hat2 if !hat2_id
|
||||
|
||||
hair_id = $Trainer.hair if !hair_id
|
||||
skin_tone_id = $Trainer.skin_tone if !skin_tone_id
|
||||
hair_color = $Trainer.hair_color if !hair_color
|
||||
hat_color = $Trainer.hat_color if !hat_color
|
||||
hat2_color = $Trainer.hat2_color if !hat2_color
|
||||
clothes_color = $Trainer.clothes_color if !clothes_color
|
||||
|
||||
hairFilename = getTrainerSpriteHairFilename(hair_id) #_INTL(Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER + "/hair_trainer_{1}", $Trainer.hair)
|
||||
outfitFilename = getTrainerSpriteOutfitFilename(clothes_id) #_INTL(Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_CLOTHES_FOLDER + "/clothes_trainer_{1}", $Trainer.clothes)
|
||||
|
||||
hatFilename = getTrainerSpriteHatFilename(hat_id)
|
||||
hat2Filename = getTrainerSpriteHatFilename(hat2_id)
|
||||
|
||||
pokeball = getCurrentPokeball(allowEasterEgg) if !pokeball
|
||||
ballFilename = getTrainerSpriteBallFilename(pokeball) if pokeball
|
||||
|
||||
baseFilePath = getBaseTrainerSpriteFilename(skin_tone_id)
|
||||
|
||||
hair_color_shift = hair_color
|
||||
hat_color_shift = hat_color
|
||||
hat2_color_shift = hat2_color
|
||||
clothes_color_shift = clothes_color
|
||||
|
||||
hair_color_shift = 0 if !hair_color_shift
|
||||
hat_color_shift = 0 if !hat_color_shift
|
||||
hat2_color_shift = 0 if !hat2_color_shift
|
||||
|
||||
clothes_color_shift = 0 if !clothes_color_shift
|
||||
|
||||
baseBitmap = AnimatedBitmap.new(baseFilePath) if pbResolveBitmap(baseFilePath)
|
||||
ballBitmap = pbLoadOutfitBitmap(ballFilename) if pbResolveBitmap(ballFilename)
|
||||
|
||||
if !pbResolveBitmap(outfitFilename)
|
||||
outfitFilename = getTrainerSpriteOutfitFilename(Settings::PLAYER_TEMP_OUTFIT_FALLBACK)
|
||||
end
|
||||
if !pbResolveBitmap(outfitFilename)
|
||||
raise "No temp clothes graphics available"
|
||||
end
|
||||
|
||||
outfitBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift) if pbResolveBitmap(outfitFilename) #pb
|
||||
hairBitmapWrapper = AnimatedBitmap.new(hairFilename, hair_color_shift) if pbResolveBitmap(hairFilename)
|
||||
|
||||
hatBitmap = AnimatedBitmap.new(hatFilename, hat_color_shift) if pbResolveBitmap(hatFilename)
|
||||
hat2Bitmap = AnimatedBitmap.new(hat2Filename, hat2_color_shift) if pbResolveBitmap(hat2Filename)
|
||||
|
||||
baseBitmap.bitmap = baseBitmap.bitmap.clone
|
||||
if outfitBitmap
|
||||
baseBitmap.bitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect)
|
||||
else
|
||||
outfitFilename = getTrainerSpriteOutfitFilename("temp")
|
||||
outfitBitmap = AnimatedBitmap.new(outfitFilename, 0)
|
||||
baseBitmap.bitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect)
|
||||
end
|
||||
baseBitmap.bitmap.blt(0, 0, hairBitmapWrapper.bitmap, hairBitmapWrapper.bitmap.rect) if hairBitmapWrapper
|
||||
baseBitmap.bitmap.blt(0, 0, hat2Bitmap.bitmap, hat2Bitmap.bitmap.rect) if hat2Bitmap
|
||||
baseBitmap.bitmap.blt(0, 0, hatBitmap.bitmap, hatBitmap.bitmap.rect) if hatBitmap
|
||||
baseBitmap.bitmap.blt(44, 42, ballBitmap, ballBitmap.rect) if ballBitmap
|
||||
|
||||
return baseBitmap
|
||||
end
|
||||
|
||||
def generateNPCClothedBitmapStatic(trainerAppearance,action = "walk")
|
||||
baseBitmapFilename = getBaseOverworldSpriteFilename(action, trainerAppearance.skin_color)
|
||||
baseSprite = AnimatedBitmap.new(baseBitmapFilename)
|
||||
|
||||
baseBitmap = baseSprite.bitmap.clone # nekkid sprite
|
||||
outfitFilename = getOverworldOutfitFilename(trainerAppearance.clothes, action)
|
||||
|
||||
hairFilename = getOverworldHairFilename(trainerAppearance.hair)
|
||||
|
||||
|
||||
#Clothes
|
||||
clothes_color_shift = trainerAppearance.clothes_color || 0
|
||||
clothesBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift).bitmap if pbResolveBitmap(outfitFilename)
|
||||
baseBitmap.blt(0, 0, clothesBitmap, clothesBitmap.rect)
|
||||
#clothesBitmap.dispose
|
||||
|
||||
|
||||
#Hair
|
||||
hair_color_shift = trainerAppearance.hair_color || 0
|
||||
hairBitmap = AnimatedBitmap.new(hairFilename, hair_color_shift).bitmap if pbResolveBitmap(hairFilename)
|
||||
baseBitmap.blt(0, 0, hairBitmap, hairBitmap.rect)
|
||||
|
||||
#Hat
|
||||
hat_color_shift = trainerAppearance.hat_color || 0
|
||||
hat2_color_shift = trainerAppearance.hat2_color || 0
|
||||
|
||||
hatFilename = getOverworldHatFilename(trainerAppearance.hat)
|
||||
hat2Filename = getOverworldHatFilename(trainerAppearance.hat2)
|
||||
|
||||
hatBitmapWrapper = AnimatedBitmap.new(hatFilename, hat_color_shift) if pbResolveBitmap(hatFilename)
|
||||
hat2BitmapWrapper = AnimatedBitmap.new(hat2Filename, hat2_color_shift) if pbResolveBitmap(hat2Filename)
|
||||
|
||||
|
||||
if hat2BitmapWrapper
|
||||
frame_count = 4 # Assuming 4 frames for hair animation; adjust as needed
|
||||
hat2_frame_bitmap = duplicateHatForFrames(hat2BitmapWrapper.bitmap, frame_count)
|
||||
|
||||
frame_width = baseSprite.bitmap.width / frame_count # Calculate frame width
|
||||
|
||||
frame_count.times do |i|
|
||||
# Calculate offset for each frame
|
||||
frame_offset = [i * frame_width, 0]
|
||||
# Adjust Y offset if frame index is odd
|
||||
frame_offset[1] -= 2 if i.odd?
|
||||
positionHat(baseBitmap, hat2_frame_bitmap, frame_offset, i, frame_width)
|
||||
end
|
||||
end
|
||||
|
||||
if hatBitmapWrapper
|
||||
frame_count = 4 # Assuming 4 frames for hair animation; adjust as needed
|
||||
hat_frame_bitmap = duplicateHatForFrames(hatBitmapWrapper.bitmap, frame_count)
|
||||
|
||||
frame_width = baseSprite.bitmap.width / frame_count # Calculate frame width
|
||||
|
||||
frame_count.times do |i|
|
||||
# Calculate offset for each frame
|
||||
frame_offset = [i * frame_width, 0]
|
||||
# Adjust Y offset if frame index is odd
|
||||
frame_offset[1] -= 2 if i.odd?
|
||||
positionHat(baseBitmap, hat_frame_bitmap, frame_offset, i, frame_width)
|
||||
end
|
||||
end
|
||||
|
||||
return baseBitmap
|
||||
end
|
||||
|
||||
#for continue screen
|
||||
def generateClothedBitmapStatic(trainer, action = "walk")
|
||||
baseBitmapFilename = getBaseOverworldSpriteFilename(action, trainer.skin_tone)
|
||||
if !pbResolveBitmap(baseBitmapFilename)
|
||||
baseBitmapFilename = Settings::PLAYER_GRAPHICS_FOLDER + action
|
||||
end
|
||||
baseSprite = AnimatedBitmap.new(baseBitmapFilename)
|
||||
|
||||
# Clone the base sprite bitmap to create the base for the player's sprite
|
||||
baseBitmap = baseSprite.bitmap.clone # nekkid sprite
|
||||
outfitFilename = getOverworldOutfitFilename(trainer.clothes, action)
|
||||
outfitFilename = getOverworldOutfitFilename(Settings::PLAYER_TEMP_OUTFIT_FALLBACK) if !pbResolveBitmap(outfitFilename)
|
||||
hairFilename = getOverworldHairFilename(trainer.hair)
|
||||
hatFilename = getOverworldHatFilename(trainer.hat)
|
||||
hat2Filename = getOverworldHatFilename(trainer.hat2)
|
||||
|
||||
# Use default values if color shifts are not set
|
||||
hair_color_shift = trainer.hair_color || 0
|
||||
hat_color_shift = trainer.hat_color || 0
|
||||
hat2_color_shift = trainer.hat2_color || 0
|
||||
|
||||
clothes_color_shift = trainer.clothes_color || 0
|
||||
|
||||
# Use fallback outfit if the specified outfit cannot be resolved
|
||||
if !pbResolveBitmap(outfitFilename)
|
||||
outfitFilename = Settings::PLAYER_TEMP_OUTFIT_FALLBACK
|
||||
end
|
||||
|
||||
# Load the outfit and hair bitmaps
|
||||
outfitBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift)
|
||||
hairBitmapWrapper = AnimatedBitmap.new(hairFilename, hair_color_shift) if pbResolveBitmap(hairFilename)
|
||||
hatBitmapWrapper = AnimatedBitmap.new(hatFilename, hat_color_shift) if pbResolveBitmap(hatFilename)
|
||||
hat2BitmapWrapper = AnimatedBitmap.new(hat2Filename, hat2_color_shift) if pbResolveBitmap(hat2Filename)
|
||||
|
||||
# Blit the outfit onto the base sprite
|
||||
baseBitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect) if outfitBitmap
|
||||
|
||||
current_offset = [0, 0] # Replace this with getCurrentSpriteOffset() if needed
|
||||
positionHair(baseBitmap, hairBitmapWrapper.bitmap, current_offset) if hairBitmapWrapper
|
||||
|
||||
frame_count = 4
|
||||
frame_width = baseSprite.bitmap.width / frame_count # Calculate frame width
|
||||
if hat2BitmapWrapper
|
||||
hat2_frame_bitmap = duplicateHatForFrames(hat2BitmapWrapper.bitmap, frame_count)
|
||||
frame_count.times do |i|
|
||||
# Calculate offset for each frame
|
||||
frame_offset = [i * frame_width, 0]
|
||||
# Adjust Y offset if frame index is odd
|
||||
frame_offset[1] -= 2 if i.odd?
|
||||
positionHat(baseBitmap, hat2_frame_bitmap, frame_offset, i, frame_width)
|
||||
end
|
||||
end
|
||||
if hatBitmapWrapper
|
||||
hat_frame_bitmap = duplicateHatForFrames(hatBitmapWrapper.bitmap, frame_count)
|
||||
frame_count.times do |i|
|
||||
# Calculate offset for each frame
|
||||
frame_offset = [i * frame_width, 0]
|
||||
# Adjust Y offset if frame index is odd
|
||||
frame_offset[1] -= 2 if i.odd?
|
||||
positionHat(baseBitmap, hat_frame_bitmap, frame_offset, i, frame_width)
|
||||
end
|
||||
end
|
||||
|
||||
return baseBitmap
|
||||
end
|
||||
|
||||
def positionHair(baseBitmap, hairBitmap, offset)
|
||||
baseBitmap.blt(offset[0], offset[1], hairBitmap, hairBitmap.rect)
|
||||
end
|
||||
|
||||
def positionHat(baseBitmap, hatBitmap, offset, frame_index, frame_width)
|
||||
# Define a rect for each frame
|
||||
frame_rect = Rect.new(frame_index * frame_width, 0, frame_width, hatBitmap.height)
|
||||
|
||||
# Blit only the part of the hat corresponding to the current frame
|
||||
baseBitmap.blt(offset[0], offset[1], hatBitmap, frame_rect)
|
||||
end
|
||||
|
||||
def duplicateHatForFrames(hatBitmap, frame_count)
|
||||
# Create a new bitmap for the duplicated hat frames
|
||||
frame_width = hatBitmap.width
|
||||
total_width = frame_width * frame_count
|
||||
duplicatedBitmap = Bitmap.new(total_width, hatBitmap.height)
|
||||
|
||||
# Copy the single hat frame across each required frame
|
||||
frame_count.times do |i|
|
||||
duplicatedBitmap.blt(i * frame_width, 0, hatBitmap, hatBitmap.rect)
|
||||
end
|
||||
|
||||
return duplicatedBitmap
|
||||
end
|
||||
|
||||
def add_hat_to_bitmap(bitmap, hat_id, x_pos, y_pos, scale = 1, mirrored = false)
|
||||
base_scale = 1.5 #coz hat & poke sprites aren't the same size
|
||||
adjusted_scale = base_scale * scale
|
||||
hat_filename = getTrainerSpriteHatFilename(hat_id)
|
||||
hatBitmapWrapper = AnimatedBitmap.new(hat_filename, 0) if pbResolveBitmap(hat_filename)
|
||||
hatBitmapWrapper.scale_bitmap(adjusted_scale) if hatBitmapWrapper
|
||||
hatBitmapWrapper.mirror if hatBitmapWrapper && mirrored
|
||||
bitmap.blt(x_pos * adjusted_scale, y_pos * adjusted_scale, hatBitmapWrapper.bitmap, hatBitmapWrapper.bitmap.rect) if hatBitmapWrapper
|
||||
end
|
||||
|
||||
class PokemonTemp
|
||||
attr_accessor :trainer_preview
|
||||
end
|
||||
|
||||
def display_outfit_preview(x = 320, y = 0, withBorder = true)
|
||||
hide_outfit_preview() if $PokemonTemp.trainer_preview
|
||||
$PokemonTemp.trainer_preview = TrainerClothesPreview.new(x, y, withBorder)
|
||||
$PokemonTemp.trainer_preview.show()
|
||||
end
|
||||
|
||||
def hide_outfit_preview()
|
||||
$game_screen.pictures[20].erase
|
||||
$PokemonTemp.trainer_preview.erase() if $PokemonTemp.trainer_preview
|
||||
$PokemonTemp.trainer_preview = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
class OutfitSelector
|
||||
attr_reader :clothes_list
|
||||
attr_reader :hats_list
|
||||
attr_reader :hairstyles_list
|
||||
|
||||
def initialize()
|
||||
@clothes_list = parse_clothes_folder()
|
||||
@hats_list = parse_hats_folder()
|
||||
@hairstyles_list =parse_hairstyles_folder()
|
||||
end
|
||||
|
||||
|
||||
def parse_clothes_folder
|
||||
return list_folders(get_clothes_sets_list_path())
|
||||
end
|
||||
|
||||
def parse_hats_folder
|
||||
return list_folders(get_hats_sets_list_path())
|
||||
end
|
||||
|
||||
def parse_hairstyle_types_folder
|
||||
return list_folders(get_hair_sets_list_path())
|
||||
end
|
||||
|
||||
def generate_hats_choice(baseOptions=true,additionalIds=[],additionalTags=[],filterOutTags=[])
|
||||
list = []
|
||||
list += additionalIds
|
||||
list += search_hats(additionalTags)
|
||||
if baseOptions
|
||||
list += get_hats_base_options()
|
||||
list += search_hats(get_regional_sets_tags())
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
def generate_clothes_choice(baseOptions=true,additionalIds=[],additionalTags=[],filterOutTags=[])
|
||||
list = []
|
||||
list += additionalIds
|
||||
list += search_clothes(additionalTags)
|
||||
if baseOptions
|
||||
list += get_clothes_base_options()
|
||||
list += search_clothes(get_regional_sets_tags())
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
def generate_hairstyle_choice(baseOptions=true,additionalIds=[],additionalTags=[],filterOutTags=[])
|
||||
list = []
|
||||
list += additionalIds
|
||||
list += search_hairstyles(additionalTags)
|
||||
if baseOptions
|
||||
list += get_hairstyle_salon_base_options()
|
||||
list += search_hairstyles(get_regional_sets_tags())
|
||||
end
|
||||
list << HAIR_BALD
|
||||
return list
|
||||
end
|
||||
|
||||
def get_regional_sets_tags()
|
||||
regional_tags = []
|
||||
regional_tags << "kanto" if $game_switches[SWITCH_KANTO_HAIR_COLLECTION]
|
||||
regional_tags << "johto" if $game_switches[SWITCH_JOHTO_HAIR_COLLECTION]
|
||||
regional_tags << "hoenn" if $game_switches[SWITCH_HOENN_HAIR_COLLECTION]
|
||||
regional_tags << "sinnoh" if $game_switches[SWITCH_SINNOH_HAIR_COLLECTION]
|
||||
regional_tags << "unova" if $game_switches[SWITCH_UNOVA_HAIR_COLLECTION]
|
||||
regional_tags << "kalos" if $game_switches[SWITCH_KALOS_HAIR_COLLECTION]
|
||||
regional_tags << "alola" if $game_switches[SWITCH_ALOLA_HAIR_COLLECTION]
|
||||
regional_tags << "galar" if $game_switches[SWITCH_GALAR_HAIR_COLLECTION]
|
||||
regional_tags << "paldea" if $game_switches[SWITCH_PALDEA_HAIR_COLLECTION]
|
||||
return regional_tags
|
||||
end
|
||||
|
||||
def get_hairstyle_salon_base_options()
|
||||
return search_hairstyles(["default"])
|
||||
end
|
||||
|
||||
def get_clothes_base_options()
|
||||
return search_clothes(["default"])
|
||||
end
|
||||
|
||||
def get_hats_base_options()
|
||||
return search_hats(["default"])
|
||||
end
|
||||
|
||||
def parse_hairstyles_folder
|
||||
hairstyle_types= list_folders(get_hair_sets_list_path())
|
||||
max_versions_number = 10
|
||||
list= []
|
||||
for hairstyle in hairstyle_types
|
||||
for i in 1..max_versions_number
|
||||
type = i.to_s + "_" + hairstyle
|
||||
filePath = getOverworldHairFilename(type)
|
||||
if pbResolveBitmap(filePath)
|
||||
list << type
|
||||
end
|
||||
end
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
def list_folders(path)
|
||||
entries= Dir.entries(path)
|
||||
return entries.select { |entry| File.directory?(File.join(path, entry)) && entry != '.' && entry != '..' }
|
||||
end
|
||||
|
||||
|
||||
def filter_unlocked_outfits(outfits_list,unlocked_outfits)
|
||||
available_outfits = []
|
||||
outfits_list.each do |outfit|
|
||||
available_outfits << outfit if unlocked_outfits.include?(outfit)
|
||||
end
|
||||
return available_outfits
|
||||
end
|
||||
|
||||
|
||||
def selectNextOutfit(currentOutfit, incr, outfits_list, versions = [], allowNone = true, prefix_filter = nil,unlockedOutfits=[],everythingUnlocked=false)
|
||||
available_outfits = []
|
||||
available_outfits = outfits_list if everythingUnlocked
|
||||
available_outfits << "" if allowNone
|
||||
available_outfits += filter_unlocked_outfits(outfits_list,unlockedOutfits) if !everythingUnlocked
|
||||
#available_outfits += list_available_outfits(directory, versions, unlockedOutfits, prefix_filter) #unlockedOutfits = nil for all outfits unlocked
|
||||
last_outfit = available_outfits[-1]
|
||||
|
||||
current_outfit_index = get_current_outfit_position(currentOutfit, available_outfits)
|
||||
next_outfit_index = current_outfit_index +incr
|
||||
|
||||
nextOutfit = available_outfits[next_outfit_index]
|
||||
nextOutfit = last_outfit if next_outfit_index < 0
|
||||
|
||||
nextOutfit = available_outfits[0] if next_outfit_index >= available_outfits.length()
|
||||
|
||||
return nextOutfit if available_outfits.include?(nextOutfit)
|
||||
return currentOutfit
|
||||
end
|
||||
|
||||
def changeToNextClothes(incr,all_unlocked=false)
|
||||
$Trainer.unlocked_clothes = [] if !$Trainer.unlocked_clothes
|
||||
|
||||
|
||||
currentOutfit = $Trainer.clothes
|
||||
currentOutfit = 0 if !currentOutfit
|
||||
nextOutfit = selectNextOutfit(currentOutfit, incr, @clothes_list, [], false,nil,$Trainer.unlocked_clothes,all_unlocked)
|
||||
$Trainer.clothes = nextOutfit
|
||||
$Trainer.clothes_color = 0
|
||||
echoln $Trainer.clothes
|
||||
|
||||
end
|
||||
|
||||
def changeToNextHat(incr,all_unlocked=false)
|
||||
$Trainer.unlocked_hats = [] if !$Trainer.unlocked_hats
|
||||
|
||||
currentHat = $Trainer.hat
|
||||
currentHat = 0 if !currentHat
|
||||
nextOutfit = selectNextOutfit(currentHat, incr, @hats_list, [], true, "hat",$Trainer.unlocked_hats,all_unlocked)
|
||||
$Trainer.hat = nextOutfit
|
||||
$Trainer.hat_color = 0
|
||||
echoln $Trainer.hat
|
||||
|
||||
end
|
||||
|
||||
def changeToNextHairstyle(incr,all_unlocked=false)
|
||||
$Trainer.unlocked_hairstyles = [] if !$Trainer.unlocked_hairstyles
|
||||
|
||||
currentHair = $Trainer.hair
|
||||
currentHair = 0 if !currentHair
|
||||
nextOutfit = selectNextOutfit(currentHair, incr, @hairstyles_list, ["a", "b", "c", "d"], true,nil,$Trainer.unlocked_hairstyles,all_unlocked)
|
||||
$Trainer.hair_color = 0
|
||||
$Trainer.hair = nextOutfit
|
||||
echoln $Trainer.hair
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,75 @@
|
||||
class PokemonGlobalMetadata
|
||||
attr_accessor :hats_data
|
||||
attr_accessor :hairstyles_data
|
||||
attr_accessor :clothes_data
|
||||
end
|
||||
|
||||
def update_global_hats_list()
|
||||
file_path = Settings::HATS_DATA_PATH
|
||||
json_data = File.read(file_path)
|
||||
hat_data = HTTPLite::JSON.parse(json_data)
|
||||
|
||||
$PokemonGlobal.hats_data = {}
|
||||
|
||||
# Iterate through the JSON data and create Hat objects
|
||||
hat_data.each do |data|
|
||||
tags = data['tags'] ? data['tags'].split(',').map(&:strip) : []
|
||||
hat = Hat.new(
|
||||
data['id'],
|
||||
data['name'],
|
||||
data['description'],
|
||||
data['price'],
|
||||
tags
|
||||
)
|
||||
$PokemonGlobal.hats_data[hat.id] = hat
|
||||
end
|
||||
end
|
||||
|
||||
def update_global_hairstyles_list()
|
||||
file_path = Settings::HAIRSTYLE_DATA_PATH
|
||||
json_data = File.read(file_path)
|
||||
hair_data = HTTPLite::JSON.parse(json_data)
|
||||
|
||||
$PokemonGlobal.hairstyles_data = {}
|
||||
|
||||
# Iterate through the JSON data and create Hat objects
|
||||
hair_data.each do |data|
|
||||
tags = data['tags'] ? data['tags'].split(',').map(&:strip) : []
|
||||
hair = Hairstyle.new(
|
||||
data['id'],
|
||||
data['name'],
|
||||
data['description'],
|
||||
data['price'],
|
||||
tags
|
||||
)
|
||||
$PokemonGlobal.hairstyles_data[hair.id] = hair
|
||||
end
|
||||
end
|
||||
|
||||
def update_global_clothes_list()
|
||||
file_path = Settings::CLOTHES_DATA_PATH
|
||||
json_data = File.read(file_path)
|
||||
outfits_data = HTTPLite::JSON.parse(json_data)
|
||||
|
||||
$PokemonGlobal.clothes_data = {}
|
||||
|
||||
# Iterate through the JSON data and create Hat objects
|
||||
outfits_data.each do |data|
|
||||
tags = data['tags'] ? data['tags'].split(',').map(&:strip) : []
|
||||
outfit = Clothes.new(
|
||||
data['id'],
|
||||
data['name'],
|
||||
data['description'],
|
||||
data['price'],
|
||||
tags
|
||||
)
|
||||
$PokemonGlobal.clothes_data[outfit.id] = outfit
|
||||
end
|
||||
end
|
||||
|
||||
def update_global_outfit_lists()
|
||||
update_global_hats_list
|
||||
update_global_hairstyles_list
|
||||
update_global_clothes_list
|
||||
end
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
#CLOTHES
|
||||
|
||||
def search_clothes(matching_tags = [], only_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
selector = OutfitSelector.new
|
||||
|
||||
full_data_list = $PokemonGlobal.clothes_data
|
||||
existing_files_list = selector.parse_clothes_folder()
|
||||
unlocked_list = $Trainer.unlocked_clothes
|
||||
return search_outfits_by_tag(full_data_list, matching_tags, existing_files_list, unlocked_list, only_unlocked)
|
||||
end
|
||||
|
||||
def filter_clothes(filter_tags = [], only_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
selector = OutfitSelector.new
|
||||
|
||||
full_data_list = $PokemonGlobal.hats_data
|
||||
existing_files_list = selector.parse_hats_folder()
|
||||
unlocked_list = $Trainer.unlocked_hats
|
||||
return filter_outfits_by_tag(full_data_list, filter_tags, existing_files_list, unlocked_list, only_unlocked)
|
||||
end
|
||||
|
||||
def filter_clothes_only_not_owned(clothes_ids_list)
|
||||
filtered_list = []
|
||||
clothes_ids_list.each do|clothe_id|
|
||||
filtered_list << clothe_id if !$Trainer.unlocked_clothes.include?(clothe_id)
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
def filter_clothes_only_owned(clothes_ids_list)
|
||||
filtered_list = []
|
||||
clothes_ids_list.each do|clothe_id|
|
||||
filtered_list << clothe_id if $Trainer.unlocked_clothes.include?(clothe_id)
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
|
||||
#HATS
|
||||
|
||||
def search_hats(matching_tags = [],excluding_tags=[], only_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
selector = OutfitSelector.new
|
||||
|
||||
full_data_list = $PokemonGlobal.hats_data
|
||||
existing_files_list = selector.parse_hats_folder()
|
||||
unlocked_list = $Trainer.unlocked_hats
|
||||
return search_outfits_by_tag(full_data_list, matching_tags, existing_files_list, unlocked_list, only_unlocked,excluding_tags)
|
||||
end
|
||||
|
||||
def filter_hats(filter_tags = [], only_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
selector = OutfitSelector.new
|
||||
|
||||
full_data_list = $PokemonGlobal.hats_data
|
||||
existing_files_list = selector.parse_hats_folder()
|
||||
unlocked_list = $Trainer.unlocked_hats
|
||||
return filter_outfits_by_tag(full_data_list, filter_tags, existing_files_list, unlocked_list, only_unlocked)
|
||||
end
|
||||
|
||||
def filter_hats_only_not_owned(hats_ids_list)
|
||||
filtered_list = []
|
||||
hats_ids_list.each do|hat_id|
|
||||
filtered_list << hat_id if !$Trainer.unlocked_hats.include?(hat_id)
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
def filter_hats_only_owned(hats_ids_list)
|
||||
filtered_list = []
|
||||
hats_ids_list.each do|hat_id|
|
||||
filtered_list << hat_id if $Trainer.unlocked_hats.include?(hat_id)
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
|
||||
|
||||
#HAIRSTYLES
|
||||
|
||||
def search_hairstyles(matching_tags = [], only_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
selector = OutfitSelector.new
|
||||
|
||||
full_data_list = $PokemonGlobal.hairstyles_data
|
||||
existing_files_list = selector.parse_hairstyle_types_folder()
|
||||
return search_outfits_by_tag(full_data_list, matching_tags, existing_files_list, [], false)
|
||||
end
|
||||
|
||||
def filter_out_hairstyles(filter_tags = [],base_list = [],require_unlocked=false)
|
||||
update_global_outfit_lists()
|
||||
selector = OutfitSelector.new
|
||||
|
||||
data_list = $PokemonGlobal.hairstyles_data
|
||||
existing_files_list = selector.parse_hairstyle_types_folder()
|
||||
return exclude_outfits_by_tag(data_list, filter_tags, existing_files_list, base_list, false)
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
# Generic searching methods
|
||||
|
||||
#Get outfits that have ANY of the tags
|
||||
def search_outfits_by_tag(outfits_map, matching_tags = [], physical_files_list = [], unlocked_list = [], require_unlocked = false, excluding_tags=[])
|
||||
filtered_list = []
|
||||
outfits_map.each do |outfit_id, outfit|
|
||||
next if outfit.tags.any? { |tag| excluding_tags.include?(tag) }
|
||||
if outfit.tags.any? { |tag| matching_tags.include?(tag) }
|
||||
filtered_list << outfit_id if outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
|
||||
end
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
#Get outfits that have ALL of the tags
|
||||
def filter_outfits_by_tag(outfits_map, filter_tags = [], physical_files_list = [], unlocked_list = [], require_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
|
||||
filtered_list = []
|
||||
outfits_map.each do |outfit_id, outfit|
|
||||
if filter_tags.all? { |tag| outfit.tags.include?(tag) }
|
||||
filtered_list << outfit_id if outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
|
||||
end
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
#Get all outfits from list that DON'T have a tag
|
||||
def exclude_outfits_by_tag(outfits_map, filter_tags = [], physical_files_list = [], unlocked_list = [], require_unlocked = false)
|
||||
update_global_outfit_lists()
|
||||
|
||||
filtered_list = []
|
||||
outfits_map.each do |outfit_id, outfit|
|
||||
if filter_tags.any? { |tag| !outfit.tags.include?(tag) }
|
||||
filtered_list << outfit_id if outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
|
||||
end
|
||||
end
|
||||
return filtered_list
|
||||
end
|
||||
|
||||
|
||||
def outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
|
||||
return false if require_unlocked && !unlocked_list.include?(outfit_id)
|
||||
return physical_files_list.include?(outfit_id)
|
||||
end
|
||||
|
||||
def add_tags(tags_list=[])
|
||||
newTag=pbEnterText("add tag",0,10)
|
||||
return tags_list if newTag.length == 0
|
||||
tags_list << newTag
|
||||
return tags_list
|
||||
end
|
||||
|
||||
def get_clothes_by_id(id)
|
||||
update_global_outfit_lists()
|
||||
return $PokemonGlobal.clothes_data.has_key?(id) ? $PokemonGlobal.clothes_data[id] : nil
|
||||
end
|
||||
|
||||
def get_hat_by_id(id)
|
||||
update_global_outfit_lists()
|
||||
return $PokemonGlobal.hats_data.has_key?(id) ? $PokemonGlobal.hats_data[id] : nil
|
||||
end
|
||||
|
||||
def get_hair_by_id(id)
|
||||
update_global_outfit_lists()
|
||||
return $PokemonGlobal.hairstyles_data.has_key?(id) ? $PokemonGlobal.hairstyles_data[id] : nil
|
||||
end
|
||||
|
||||
|
||||
def generate_clothes_choice(baseOptions=true,additionalIds=[],additionalTags=[],filterOutTags=[])
|
||||
list = []
|
||||
list += additionalIds
|
||||
list += search_clothes(additionalTags)
|
||||
if baseOptions
|
||||
list += get_clothes_base_options()
|
||||
list += search_clothes(get_regional_sets_tags())
|
||||
end
|
||||
return list
|
||||
end
|
||||
|
||||
|
||||
CITY_OUTFIT_TAGS= [
|
||||
"pewter","cerulean","vermillion","lavender","celadon","fuchsia","cinnabar",
|
||||
"crimson","goldenrod","azalea", "violet", "blackthorn", "mahogany", "ecruteak",
|
||||
"olivine","cianwood", "kin"
|
||||
]
|
||||
def list_city_exclusive_clothes()
|
||||
tags_list = CITY_OUTFIT_TAGS
|
||||
echoln search_clothes(tags_list)
|
||||
return search_clothes(tags_list)
|
||||
end
|
||||
|
||||
def list_city_exclusive_hats()
|
||||
tags_list = CITY_OUTFIT_TAGS
|
||||
return search_hats(tags_list)
|
||||
end
|
||||
|
||||
def list_city_exclusive_hairstyles()
|
||||
tags_list = CITY_OUTFIT_TAGS
|
||||
return search_hairstyles(tags_list)
|
||||
end
|
||||
|
||||
def list_regional_clothes()
|
||||
selector = OutfitSelector.new
|
||||
tags_list = selector.get_regional_sets_tags()
|
||||
return search_clothes(tags_list)
|
||||
end
|
||||
|
||||
def list_regional_hats()
|
||||
selector = OutfitSelector.new
|
||||
tags_list = selector.get_regional_sets_tags()
|
||||
return search_hats(tags_list)
|
||||
end
|
||||
|
||||
def list_regional_hairstyles()
|
||||
selector = OutfitSelector.new
|
||||
tags_list = selector.get_regional_sets_tags()
|
||||
return search_hairstyles(tags_list)
|
||||
end
|
||||
185
Data/Scripts/998_InfiniteFusion/Outfits/ItemSets.rb
Normal file
185
Data/Scripts/998_InfiniteFusion/Outfits/ItemSets.rb
Normal file
@@ -0,0 +1,185 @@
|
||||
#set outfit ids,
|
||||
#
|
||||
|
||||
CLOTHES_NORMAL = "normal"
|
||||
|
||||
CLOTHES_FIGHTING = "fighting"
|
||||
|
||||
CLOTHES_FLYING = "temp"
|
||||
|
||||
CLOTHES_POISON = "deadlypoisondanger"
|
||||
|
||||
CLOTHES_GROUND = "groundcowboy"
|
||||
|
||||
CLOTHES_ROCK = "temp"
|
||||
|
||||
CLOTHES_BUG_1 = "bughakama"
|
||||
CLOTHES_BUG_2 = "bughakamapants"
|
||||
|
||||
CLOTHES_GHOST = "temp"
|
||||
|
||||
CLOTHES_STEEL_M = "steelworkerM"
|
||||
CLOTHES_STEEL_F = "steelworkerF"
|
||||
|
||||
CLOTHES_FIRE = "fire"
|
||||
|
||||
CLOTHES_WATER = "waterdress"
|
||||
|
||||
CLOTHES_GRASS = "temp"
|
||||
|
||||
CLOTHES_ELECTRIC = "urbanelectric"
|
||||
|
||||
CLOTHES_PSYCHIC = "temp"
|
||||
|
||||
CLOTHES_ICE = "iceoutfit"
|
||||
|
||||
CLOTHES_DRAGON = "dragonconqueror"
|
||||
|
||||
CLOTHES_DARK = "temp"
|
||||
|
||||
CLOTHES_FAIRY_M = "mikufairym"
|
||||
CLOTHES_FAIRY_F = "mikufairyf"
|
||||
|
||||
|
||||
NORMAL_ITEMS = [:NORMALGEM,:MOOMOOMILK,:POTION,:FULLHEAL,:CHILANBERRY,]
|
||||
FIGHTING_ITEMS = [:FIGHTINGGEM,:PROTEIN,:CHOPLEBERRY,]
|
||||
FLYING_ITEMS = [:FLYINGGEM,:HEALTHWING,:MUSCLEWING,:RESISTWING,:GENIUSWING,:CLEVERWING,:SWIFTWING,:AIRBALLOON,:PRETTYWING,:COBABERRY, ]
|
||||
POISON_ITEMS = [:POISONGEM,:ANTIDOTE, :KEBIABERRY, ]
|
||||
GROUND_ITEMS = [:GROUNDGEM,:SHUCABERRY, ]
|
||||
ROCK_ITEMS = [:ROCKGEM, :STARDUST,:CHARTIBERRY, ]
|
||||
BUG_ITEMS = [:BUGGEM,:HONEY,:TANGABERRY, ]
|
||||
GHOST_ITEMS = [:GHOSTGEM,:KASIBBERRY,]
|
||||
STEEL_ITEMS = [:STEELGEM,:BABIRIBERRY,:METALPOWDER,]
|
||||
FIRE_ITEMS = [:FIREGEM,:LAVACOOKIE,:BURNHEAL,:OCCABERRY, ]
|
||||
WATER_ITEMS = [:WATERGEM,:HEARTSCALE,:PEARL,:PASSHOBERRY ]
|
||||
GRASS_ITEMS = [:GRASSGEM,:LUMBERRY,:ORANBERRY,:SITRUSBERRY,:GRASSYSEED,:ABSORBBULB,:TINYMUSHROOM, :RINDOBERRY, ]
|
||||
ELECTRIC_ITEMS = [:ELECTRICGEM,:ELECTRICSEED,:PARLYZHEAL,:CELLBATTERY,:WACANBERRY, ]
|
||||
PSYCHIC_ITEMS = [:PSYCHICGEM,:PSYCHICSEED, :MENTALHERB, :PAYAPABERRY,]
|
||||
ICE_ITEMS = [:ICEGEM,:SNOWBALL,:ICEHEAL,:YACHEBERRY, ]
|
||||
DRAGON_ITEMS = [:DRAGONGEM,:HABANBERRY, ]
|
||||
DARK_ITEMS = [:DARKGEM,:COLBURBERRY, ]
|
||||
FAIRY_ITEMS = [:FAIRYGEM,:MISTYSEED, ]
|
||||
|
||||
|
||||
def isWearingElectricOutfit()
|
||||
return (isWearingClothes(CLOTHES_ELECTRIC))
|
||||
end
|
||||
|
||||
def isWearingNormalOutfit()
|
||||
return (isWearingClothes(CLOTHES_NORMAL))
|
||||
end
|
||||
|
||||
def isWearingFightingOutfit()
|
||||
return (isWearingClothes(CLOTHES_FIGHTING))
|
||||
end
|
||||
|
||||
def isWearingFlyingOutfit()
|
||||
return (isWearingClothes(CLOTHES_FLYING))
|
||||
end
|
||||
|
||||
def isWearingPoisonOutfit()
|
||||
return (isWearingClothes(CLOTHES_POISON))
|
||||
end
|
||||
|
||||
def isWearingGroundOutfit()
|
||||
return (isWearingClothes(CLOTHES_GROUND))
|
||||
end
|
||||
|
||||
def isWearingRockOutfit()
|
||||
return (isWearingClothes(CLOTHES_ROCK))
|
||||
end
|
||||
|
||||
def isWearingBugOutfit()
|
||||
return ((isWearingClothes(CLOTHES_BUG_1) || isWearingClothes(CLOTHES_BUG_2)))
|
||||
end
|
||||
|
||||
def isWearingGhostOutfit()
|
||||
return (isWearingClothes(CLOTHES_GHOST))
|
||||
end
|
||||
|
||||
def isWearingSteelOutfit()
|
||||
return ((isWearingClothes(CLOTHES_STEEL_M) || isWearingClothes(CLOTHES_STEEL_F)))
|
||||
end
|
||||
|
||||
def isWearingFireOutfit()
|
||||
return (isWearingClothes(CLOTHES_FIRE))
|
||||
end
|
||||
|
||||
def isWearingWaterOutfit()
|
||||
return (isWearingClothes(CLOTHES_WATER))
|
||||
end
|
||||
|
||||
def isWearingGrassOutfit()
|
||||
return (isWearingClothes(CLOTHES_GRASS))
|
||||
end
|
||||
|
||||
def isWearingPsychicOutfit()
|
||||
return (isWearingClothes(CLOTHES_PSYCHIC))
|
||||
end
|
||||
|
||||
def isWearingIceOutfit()
|
||||
return (isWearingClothes(CLOTHES_ICE))
|
||||
end
|
||||
|
||||
def isWearingDragonOutfit()
|
||||
return (isWearingClothes(CLOTHES_DRAGON))
|
||||
end
|
||||
|
||||
def isWearingDarkOutfit()
|
||||
return (isWearingClothes(CLOTHES_DARK))
|
||||
end
|
||||
|
||||
def isWearingFairyOutfit()
|
||||
return ((isWearingClothes(CLOTHES_FAIRY_M) || isWearingClothes(CLOTHES_FAIRY_F)))
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def pickUpTypeItemSetBonus()
|
||||
return if rand(10) != 0
|
||||
items_list = if isWearingElectricOutfit()
|
||||
ELECTRIC_ITEMS
|
||||
elsif isWearingNormalOutfit()
|
||||
NORMAL_ITEMS
|
||||
elsif isWearingFightingOutfit()
|
||||
FIGHTING_ITEMS
|
||||
elsif isWearingFlyingOutfit()
|
||||
FLYING_ITEMS
|
||||
elsif isWearingPoisonOutfit()
|
||||
POISON_ITEMS
|
||||
elsif isWearingGroundOutfit()
|
||||
GROUND_ITEMS
|
||||
elsif isWearingRockOutfit()
|
||||
ROCK_ITEMS
|
||||
elsif isWearingBugOutfit()
|
||||
BUG_ITEMS
|
||||
elsif isWearingGhostOutfit()
|
||||
GHOST_ITEMS
|
||||
elsif isWearingSteelOutfit()
|
||||
STEEL_ITEMS
|
||||
elsif isWearingFireOutfit()
|
||||
FIRE_ITEMS
|
||||
elsif isWearingWaterOutfit()
|
||||
WATER_ITEMS
|
||||
elsif isWearingGrassOutfit()
|
||||
GRASS_ITEMS
|
||||
elsif isWearingPsychicOutfit()
|
||||
PSYCHIC_ITEMS
|
||||
elsif isWearingIceOutfit()
|
||||
ICE_ITEMS
|
||||
elsif isWearingDragonOutfit()
|
||||
DRAGON_ITEMS
|
||||
elsif isWearingDarkOutfit()
|
||||
DARK_ITEMS
|
||||
elsif isWearingFairyOutfit()
|
||||
FAIRY_ITEMS
|
||||
else
|
||||
[]
|
||||
end
|
||||
if !items_list.empty?
|
||||
Kernel.pbItemBall(items_list.sample)
|
||||
end
|
||||
end
|
||||
|
||||
148
Data/Scripts/998_InfiniteFusion/Outfits/OutfitIds.rb
Normal file
148
Data/Scripts/998_InfiniteFusion/Outfits/OutfitIds.rb
Normal file
@@ -0,0 +1,148 @@
|
||||
#Clothes
|
||||
CLOTHES_TEAM_ROCKET_MALE = "rocketm"
|
||||
CLOTHES_TEAM_ROCKET_FEMALE = "rocketf"
|
||||
|
||||
CLOTHES_OFFICE_WORKER_F = "officeworkerf"
|
||||
CLOTHES_OFFICE_WORKER_M = "officeworkerm"
|
||||
CLOTHES_BUSINESS_SUIT = "BusinessSuit"
|
||||
|
||||
CLOTHES_ADVENTURER = "fantasyadventurersoutfit"
|
||||
CLOTHES_EMERALD = "emeraldSPE"
|
||||
CLOTHES_PIKACHU_ONESIE = "pikaonesie"
|
||||
|
||||
CLOTHES_GLITCH = "glitzerset"
|
||||
CLOTHES_BREEDER="PKMBreeder"
|
||||
|
||||
CLOTHES_FOSSIL_M ="sado"
|
||||
CLOTHES_FOSSIL_F ="sada"
|
||||
|
||||
CLOTHES_TREVENANT= "trevenantforestkingcloak"
|
||||
|
||||
CLOTHES_WAITRESS = "maid"
|
||||
CLOTHES_WAITER = "butler"
|
||||
|
||||
CLOTHES_LASS_YELLOW ="lass"
|
||||
CLOTHES_LASS_BLUE ="lass2"
|
||||
|
||||
DEFAULT_OUTFIT_MALE = "red"
|
||||
DEFAULT_OUTFIT_FEMALE = "leaf"
|
||||
STARTING_OUTFIT = "pikajamas"
|
||||
|
||||
|
||||
#Hats
|
||||
HAT_TEAM_ROCKET = "rocketcap"
|
||||
HAT_POSTMAN = "postman"
|
||||
HAT_PIDGEY_NEST = "pidgey"
|
||||
HAT_SWABLU_NEST = "swablu"
|
||||
HAT_PIKACHUM_NEST = "pikhatchum"
|
||||
HAT_PIKACHUF_NEST = "pikhatchuf"
|
||||
HAT_PARAS_NEST = "headparas"
|
||||
HAT_EEVEE_NEST = "eevee"
|
||||
|
||||
HAT_PARASHROOM = "parashroom"
|
||||
HAT_AERODACTYL = "aerodactylSkull"
|
||||
HAT_DUSKULL_MASK = "duskullmask"
|
||||
HAT_SLEEPMASK = "sleepmask"
|
||||
HAT_DITTO_MASK = "creepydittomask"
|
||||
HAT_EGG = "egg"
|
||||
HAT_DRIFLOON_CAP = "drifloon"
|
||||
HAT_EMERALD = "emeraldSPEgem"
|
||||
HAT_SQUIRTLE_SHADES = "squirtlesquadshades"
|
||||
HAT_WOOPER = "wooperclips"
|
||||
HAT_PIKACHU_HOOD = "pikaonesie"
|
||||
HAT_FEZ = "fez"
|
||||
HAT_HALO = "halo"
|
||||
HAT_MAGIKARP = "magicap"
|
||||
HAT_SLOWKING_SHELL = "slowking"
|
||||
HAT_ZOROARK = "banefulfoxmask"
|
||||
HAT_FROG = "froghat"
|
||||
HAT_SANTA = "santa"
|
||||
HAT_QMARKS = "glitzerset"
|
||||
HAT_SUDOWOODO = "sudowoodohorns"
|
||||
|
||||
HAT_TREVENANT="trevenantforestkingcrown"
|
||||
|
||||
HAT_CLOWN = "clownnose"
|
||||
|
||||
HAT_BREEDER_1="breedervisor"
|
||||
HAT_BREEDER_2="breederbandana"
|
||||
HAT_BREEDER_2_2="PKMBreeder"
|
||||
|
||||
HAT_BREEDER_3="egg"
|
||||
|
||||
HAT_BREEDEROUTFIT="PKMBreeder"
|
||||
|
||||
HAT_WAITRESS = "maid"
|
||||
|
||||
FUSION_HAT = "fusionnerd"
|
||||
FUSION_OUTFIT = "fusionnerd"
|
||||
|
||||
HAT_ASH = "ash"
|
||||
HAT_BIANCA = "bianca"
|
||||
HAT_CLEFAIRY = "clefairyearheadband"
|
||||
HAT_FLOWER = "mikufairy"
|
||||
|
||||
HAT_SKITTY_TV = "skittyTV"
|
||||
HAT_TVHEAD = "tvhead"
|
||||
|
||||
HAT_SCRIBBLES1 = "scribbles1"
|
||||
HAT_SCRIBBLES2 = "scribbles2"
|
||||
HAT_SCRIBBLES3 = "scribbles3"
|
||||
HAT_SCRIBBLES4 = "scribbles4"
|
||||
|
||||
HAT_CARDBOARD_BOX = "box"
|
||||
HAT_CAPTAIN = "seacaptain"
|
||||
HAT_GYM_REWARD_1 = "brockpan"
|
||||
HAT_GYM_REWARD_2 = "starmieclip"
|
||||
HAT_GYM_REWARD_3 = "surgeglasses"
|
||||
HAT_GYM_REWARD_4 = "erikaHeadband"
|
||||
HAT_GYM_REWARD_5 = "kogascarf"
|
||||
HAT_GYM_REWARD_6 = "sabrinasballs"
|
||||
HAT_GYM_REWARD_7 = "blaineGlasses"
|
||||
HAT_GYM_REWARD_8 = "giovannifedora"
|
||||
HAT_GYM_REWARD_9 = "luluribbon"
|
||||
HAT_GYM_REWARD_10 = "kurtsentaihelmet"
|
||||
HAT_GYM_REWARD_11 = "falknerscage"
|
||||
HAT_GYM_REWARD_12 = "clairbow"
|
||||
HAT_GYM_REWARD_13 = "chuckmoustache"
|
||||
HAT_GYM_REWARD_14 = "prycemask"
|
||||
HAT_GYM_REWARD_15 = "mortyHeadband"
|
||||
HAT_GYM_REWARD_16 = "magnemitepin"
|
||||
|
||||
|
||||
#Hairstyles
|
||||
HAIR_RED = "red"
|
||||
HAIR_LEAF = "leaf"
|
||||
|
||||
HAIR_HEXMANIAC = "HexManiac"
|
||||
HAIR_LASS = "lass"
|
||||
|
||||
HAIR_BALD = "bald"
|
||||
HAIR_RIVAL = "gary"
|
||||
HAIR_BROCK = "brock"
|
||||
HAIR_MISTY1 = "mistyRBY"
|
||||
HAIR_MISTY2 = "mistyGSC"
|
||||
|
||||
HAIR_SURGE = "surge" #does not exist yet
|
||||
HAIR_ERIKA = "erika"
|
||||
HAIR_KOGA = "koga" #does not exist yet
|
||||
HAIR_JANINE = "janine"
|
||||
HAIR_SABRINA = "sabrinaGSC"
|
||||
HAIR_BLAINE = "blaine" #does not exist yet
|
||||
HAIR_GIOVANNI = "giovanni" #does not exist yet
|
||||
HAIR_WHITNEY = "whitney"
|
||||
HAIR_KURT = "kurt"
|
||||
HAIR_FALKNER = "falkner"
|
||||
HAIR_CLAIR = "clair"
|
||||
HAIR_CHUCK = "chuck" #does not exist yet
|
||||
HAIR_PRYCE = "pryce" #does not exist yet
|
||||
HAIR_MORTY = "morty" #does not exist yet
|
||||
HAIR_JASMINE = "jasmine" #does not exist yet
|
||||
|
||||
HAIR_HOOH = "ho-oh"
|
||||
HAIR_CRESSELIA = "lunarbob"
|
||||
HAIR_LYCANROC="lycanrocshorthair"
|
||||
HAIR_HAPPINY="happinysuit"
|
||||
HAIR_LATIAS="SpecialLatias"
|
||||
HAIR_GARDEVOIR="gardevoir"
|
||||
HAIR_EEVEE="eeveetail"
|
||||
@@ -0,0 +1,181 @@
|
||||
class CharacterSelectionMenuView
|
||||
attr_accessor :name_sprite
|
||||
attr_accessor :viewport
|
||||
attr_accessor :sprites
|
||||
attr_accessor :textValues
|
||||
|
||||
|
||||
OPTIONS_START_Y = 66
|
||||
CURSOR_Y_MARGIN = 50
|
||||
CURSOR_X_MARGIN = 76
|
||||
|
||||
CHECKMARK_Y_MARGIN = 20
|
||||
CHECKMARK_WIDTH = 50
|
||||
|
||||
OPTIONS_LABEL_X = 50
|
||||
|
||||
|
||||
OPTIONS_LABEL_WIDTH = 100
|
||||
|
||||
OPTIONS_VALUE_X = 194
|
||||
SELECTOR_X = 120
|
||||
SELECTOR_STAGGER_OFFSET=26
|
||||
|
||||
|
||||
ARROW_LEFT_X_POSITION = 75
|
||||
ARROW_RIGHT_X_POSITION = 275
|
||||
ARROWS_Y_OFFSET = 10#20
|
||||
|
||||
CONFIRM_X = 296
|
||||
CONFIRM_Y= 322
|
||||
|
||||
STAGGER_OFFSET_1 = 26
|
||||
STAGGER_OFFSET_2 = 50
|
||||
|
||||
|
||||
|
||||
def initialize
|
||||
@presenter = CharacterSelectMenuPresenter.new(self)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@sprites = {}
|
||||
@textValues={}
|
||||
@max_index=5
|
||||
end
|
||||
|
||||
def init_graphics()
|
||||
@sprites["bg"] = IconSprite.new(@viewport)
|
||||
@sprites["bg"].setBitmap("Graphics/Pictures/trainer_application_form")
|
||||
|
||||
|
||||
@sprites["select"] = IconSprite.new(@viewport)
|
||||
@sprites["select"].setBitmap("Graphics/Pictures/cc_selection_box")
|
||||
@sprites["select"].x = get_cursor_x_position(0)#OPTIONS_LABEL_X + OPTIONS_LABEL_WIDTH + CURSOR_X_MARGIN
|
||||
@sprites["select"].y = OPTIONS_START_Y
|
||||
@sprites["select"].visible = true
|
||||
|
||||
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["leftarrow"].x = ARROW_LEFT_X_POSITION
|
||||
@sprites["leftarrow"].y = 0
|
||||
@sprites["leftarrow"].visible = false
|
||||
@sprites["leftarrow"].play
|
||||
|
||||
|
||||
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["rightarrow"].x = ARROW_RIGHT_X_POSITION
|
||||
@sprites["rightarrow"].y = 0
|
||||
@sprites["rightarrow"].visible = false
|
||||
@sprites["rightarrow"].play
|
||||
|
||||
@presenter.setInitialValues()
|
||||
end
|
||||
|
||||
def setMaxIndex(maxIndex)
|
||||
@max_index=maxIndex
|
||||
end
|
||||
|
||||
def init_labels()
|
||||
Kernel.pbDisplayText("Confirm", (CONFIRM_X+CURSOR_X_MARGIN), CONFIRM_Y)
|
||||
|
||||
#Labels are directly in the image
|
||||
|
||||
# current_Y = OPTIONS_START_Y
|
||||
# for option in @presenter.options
|
||||
# x_pos = option == "Confirm" ? OPTIONS_VALUE_X : OPTIONS_LABEL_X
|
||||
#
|
||||
# Kernel.pbDisplayText(option, x_pos, current_Y)
|
||||
# current_Y += CURSOR_Y_MARGIN
|
||||
# end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def start
|
||||
init_graphics()
|
||||
init_labels()
|
||||
@presenter.main()
|
||||
end
|
||||
|
||||
def get_cursor_y_position(index)
|
||||
return CONFIRM_Y if index == @max_index
|
||||
return index * CURSOR_Y_MARGIN + OPTIONS_START_Y
|
||||
end
|
||||
|
||||
def get_cursor_x_position(index)
|
||||
return CONFIRM_X if index == @max_index
|
||||
return SELECTOR_X + getTextBoxStaggerOffset(index)
|
||||
end
|
||||
|
||||
def get_value_x_position(index)
|
||||
return (OPTIONS_VALUE_X + getTextBoxStaggerOffset(index))
|
||||
end
|
||||
|
||||
def getTextBoxStaggerOffset(index)
|
||||
case index
|
||||
when 1
|
||||
return STAGGER_OFFSET_1
|
||||
when 2
|
||||
return STAGGER_OFFSET_2
|
||||
when 3
|
||||
return STAGGER_OFFSET_1
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
def showSideArrows(y_index)
|
||||
y_position = get_cursor_y_position(y_index)
|
||||
|
||||
@sprites["rightarrow"].y=y_position+ARROWS_Y_OFFSET
|
||||
@sprites["leftarrow"].y=y_position+ARROWS_Y_OFFSET
|
||||
|
||||
@sprites["leftarrow"].x=getTextBoxStaggerOffset(y_index)+ARROW_LEFT_X_POSITION
|
||||
@sprites["rightarrow"].x= getTextBoxStaggerOffset(y_index)+ARROW_RIGHT_X_POSITION
|
||||
|
||||
@sprites["rightarrow"].visible=true
|
||||
@sprites["leftarrow"].visible=true
|
||||
end
|
||||
|
||||
def hideSideArrows()
|
||||
@sprites["rightarrow"].visible=false
|
||||
@sprites["leftarrow"].visible=false
|
||||
end
|
||||
|
||||
def displayAge(age,y_index)
|
||||
y_position = get_cursor_y_position(y_index)
|
||||
x_position = get_value_x_position(y_index)
|
||||
Kernel.pbClearNumber()
|
||||
Kernel.pbDisplayNumber(age,x_position,y_position)
|
||||
end
|
||||
|
||||
def displayText(spriteId,text,y_index)
|
||||
@textValues[spriteId].dispose if @textValues[spriteId]
|
||||
yposition = get_cursor_y_position(y_index)
|
||||
xposition = get_value_x_position(y_index)
|
||||
|
||||
baseColor= baseColor ? baseColor : Color.new(72,72,72)
|
||||
shadowColor= shadowColor ? shadowColor : Color.new(160,160,160)
|
||||
@textValues[spriteId] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
text1=_INTL(text)
|
||||
textPosition=[
|
||||
[text1,xposition,yposition,2,baseColor,shadowColor],
|
||||
]
|
||||
pbSetSystemFont(@textValues[spriteId].bitmap)
|
||||
pbDrawTextPositions(@textValues[spriteId].bitmap,textPosition)
|
||||
|
||||
end
|
||||
|
||||
|
||||
def updateGraphics()
|
||||
Graphics.update
|
||||
Input.update
|
||||
if @sprites
|
||||
@sprites["rightarrow"].update
|
||||
@sprites["leftarrow"].update
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,275 @@
|
||||
class CharacterSelectMenuPresenter
|
||||
attr_accessor :options
|
||||
attr_reader :current_index
|
||||
|
||||
OPTION_NAME = 'Name'
|
||||
OPTION_AGE = "Age"
|
||||
OPTION_GENDER = "Gender"
|
||||
OPTION_HAIR = "Hair"
|
||||
OPTION_SKIN = "Skin"
|
||||
OPTION_CONFIRM = "Confirm"
|
||||
|
||||
MIN_AGE = 10
|
||||
MAX_AGE = 17
|
||||
DEFAULT_NAMES = ["Green", "Red"]
|
||||
|
||||
MIN_SKIN_COLOR = 1
|
||||
MAX_SKIN_COLOR = 6
|
||||
SKIN_COLOR_IDS = ["Type A", "Type B", "Type C", "Type D", "Type E", "Type F"]
|
||||
GENDERS_IDS = ["Female", "Male"]
|
||||
|
||||
HAIR_COLOR_IDS = [1, 2, 3, 4]
|
||||
HAIR_COLOR_NAMES = ["Blonde", "Light Brown", "Dark Brown", "Black"]
|
||||
|
||||
#ids for displayed text sprites
|
||||
NAME_TEXT_ID = "name"
|
||||
HAIR_TEXT_ID = "hair"
|
||||
SKIN_TEXT_ID = "skin"
|
||||
|
||||
def initialize(view)
|
||||
@view = view
|
||||
|
||||
@gender = 1
|
||||
@age = MIN_AGE
|
||||
@name = ""
|
||||
@skinTone = 5
|
||||
@hairstyle = "red"
|
||||
@hairColor = 2
|
||||
|
||||
@options = [OPTION_NAME, OPTION_GENDER, OPTION_AGE, OPTION_SKIN, OPTION_HAIR, OPTION_CONFIRM]
|
||||
|
||||
@trainerPreview = TrainerClothesPreview.new(300, 80, false, "POKEBALL")
|
||||
@trainerPreview.show()
|
||||
@closed = false
|
||||
@current_index = 0
|
||||
@view.setMaxIndex(@options.length - 1)
|
||||
end
|
||||
|
||||
def main()
|
||||
pbSEPlay("GUI naming tab swap start", 80, 100)
|
||||
@current_index = 0
|
||||
loop do
|
||||
@view.updateGraphics()
|
||||
if Input.trigger?(Input::DOWN)
|
||||
@current_index = move_menu_vertical(1)
|
||||
elsif Input.trigger?(Input::UP)
|
||||
@current_index = move_menu_vertical(-1)
|
||||
elsif Input.trigger?(Input::RIGHT)
|
||||
move_menu_horizontal(@current_index, 1)
|
||||
elsif Input.trigger?(Input::LEFT)
|
||||
move_menu_horizontal(@current_index, -1)
|
||||
elsif Input.trigger?(Input::ACTION) || Input.trigger?(Input::USE)
|
||||
action_button_pressed(@current_index)
|
||||
end
|
||||
break if @closed
|
||||
end
|
||||
end
|
||||
|
||||
def updateTrainerPreview
|
||||
@trainerPreview.resetOutfits
|
||||
@trainerPreview.updatePreview
|
||||
end
|
||||
|
||||
def action_button_pressed(current_index)
|
||||
selected_option = @options[current_index]
|
||||
case selected_option
|
||||
when OPTION_NAME
|
||||
pbSEPlay("GUI summary change page", 80, 100)
|
||||
@name = pbEnterPlayerName(_INTL("Enter your name"), 0, Settings::MAX_PLAYER_NAME_SIZE)
|
||||
@name = getDefaultName() if @name == ''
|
||||
pbSEPlay("GUI trainer card open", 80, 100)
|
||||
updateDisplayedName(current_index)
|
||||
applyHair() #for easter egg lol
|
||||
when OPTION_CONFIRM
|
||||
pbSEPlay("GUI save choice", 80, 100)
|
||||
@current_index = @options.length - 1
|
||||
update_cursor(@current_index)
|
||||
@name = getDefaultName if @name == ""
|
||||
updateDisplayedName(getOptionIndex(OPTION_NAME))
|
||||
cmd = pbMessage("Is this information correct?", [_INTL("Yes"), _INTL("No")])
|
||||
if cmd == 0
|
||||
pbSEPlay("GUI naming confirm", 80, 100)
|
||||
#pbMessage("You will be able to customize your appearance further while playing")
|
||||
applyAllSelectedValues()
|
||||
close_menu()
|
||||
end
|
||||
else
|
||||
pbSEPlay("GUI save choice", 80, 100)
|
||||
@current_index = @options.length - 1
|
||||
update_cursor(@current_index)
|
||||
@name = getDefaultName if @name == ""
|
||||
updateDisplayedName(getOptionIndex(OPTION_NAME))
|
||||
end
|
||||
end
|
||||
|
||||
def getDefaultName()
|
||||
return DEFAULT_NAMES[@gender]
|
||||
end
|
||||
|
||||
def updateDisplayedName(current_index)
|
||||
@view.displayText(NAME_TEXT_ID, @name, current_index)
|
||||
end
|
||||
|
||||
def applyAllSelectedValues
|
||||
applyGender(@gender)
|
||||
echoln @age
|
||||
pbSet(VAR_TRAINER_AGE, @age)
|
||||
$Trainer.skin_tone = @skinTone
|
||||
$Trainer.name = @name
|
||||
end
|
||||
|
||||
def getOptionIndex(option_name)
|
||||
i = 0
|
||||
for option in @options
|
||||
return i if option == option_name
|
||||
i += 1
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
#VERTICAL NAVIGATION
|
||||
|
||||
def move_menu_vertical(offset)
|
||||
pbSEPlay("GUI sel decision", 80, 100)
|
||||
@current_index += offset
|
||||
@current_index = 0 if @current_index > @options.length - 1
|
||||
@current_index = @options.length - 1 if @current_index <= -1
|
||||
|
||||
update_cursor(@current_index)
|
||||
return @current_index
|
||||
end
|
||||
|
||||
def update_cursor(index)
|
||||
@view.sprites["select"].y = @view.get_cursor_y_position(index)
|
||||
@view.sprites["select"].x = @view.get_cursor_x_position(index)
|
||||
|
||||
set_custom_cursor(index)
|
||||
end
|
||||
|
||||
def close_menu
|
||||
@trainerPreview.erase()
|
||||
Kernel.pbClearNumber()
|
||||
Kernel.pbClearText()
|
||||
pbDisposeSpriteHash(@view.sprites)
|
||||
pbDisposeSpriteHash(@view.textValues)
|
||||
@closed = true
|
||||
end
|
||||
|
||||
def set_custom_cursor(index)
|
||||
selected_option = @options[index]
|
||||
case selected_option
|
||||
when OPTION_GENDER
|
||||
@view.showSideArrows(index)
|
||||
when OPTION_AGE
|
||||
@view.showSideArrows(index)
|
||||
when OPTION_HAIR
|
||||
@view.showSideArrows(index)
|
||||
when OPTION_SKIN
|
||||
@view.showSideArrows(index)
|
||||
else
|
||||
@view.hideSideArrows
|
||||
end
|
||||
end
|
||||
|
||||
#HORIZONTAL NAVIGATION
|
||||
def move_menu_horizontal(current_index, incr)
|
||||
pbSEPlay("GUI sel cursor", 80, 100)
|
||||
selected_option = @options[current_index]
|
||||
case selected_option
|
||||
when OPTION_GENDER then
|
||||
setGender(current_index, incr)
|
||||
when OPTION_HAIR then
|
||||
setHairColor(current_index, incr)
|
||||
when OPTION_SKIN then
|
||||
setSkinColor(current_index, incr)
|
||||
when OPTION_AGE then
|
||||
setAge(current_index, incr)
|
||||
end
|
||||
updateTrainerPreview()
|
||||
end
|
||||
|
||||
def setGender(current_index, incr)
|
||||
@gender += incr
|
||||
@gender = 0 if @gender >= 2
|
||||
@gender = 1 if @gender <= -1
|
||||
applyGender(@gender)
|
||||
label = GENDERS_IDS[@gender]
|
||||
@view.displayText(GENDERS_IDS, label, current_index)
|
||||
end
|
||||
|
||||
def setSkinColor(current_index, incr)
|
||||
@skinTone += incr
|
||||
@skinTone = MIN_SKIN_COLOR if @skinTone > MAX_SKIN_COLOR
|
||||
@skinTone = MAX_SKIN_COLOR if @skinTone < MIN_SKIN_COLOR
|
||||
$Trainer.skin_tone = @skinTone
|
||||
label = SKIN_COLOR_IDS[@skinTone - 1]
|
||||
@view.displayText(SKIN_TEXT_ID, label, current_index)
|
||||
end
|
||||
|
||||
def setHairColor(current_index, incr)
|
||||
max_id = HAIR_COLOR_IDS.length - 1
|
||||
@hairColor += incr
|
||||
@hairColor = 0 if @hairColor > max_id
|
||||
@hairColor = max_id if @hairColor <= -1
|
||||
applyHair()
|
||||
@view.displayText(HAIR_TEXT_ID, HAIR_COLOR_NAMES[@hairColor], current_index)
|
||||
end
|
||||
|
||||
def applyHair()
|
||||
applyHairEasterEggs()
|
||||
hairColorId = HAIR_COLOR_IDS[@hairColor]
|
||||
hairId = hairColorId.to_s + "_" + @hairstyle.to_s
|
||||
$Trainer.hair = hairId
|
||||
end
|
||||
|
||||
def applyHairEasterEggs()
|
||||
@hairstyle = HAIR_RIVAL if @name == "Gary" && @gender == 1
|
||||
@hairstyle = HAIR_BROCK if @name == "Brock" && @gender == 1
|
||||
@hairstyle = HAIR_MISTY1 if @name == "Misty" && @gender == 0
|
||||
|
||||
end
|
||||
|
||||
def applyGender(gender_index)
|
||||
# outfitId = gender + 1
|
||||
pbSet(VAR_TRAINER_GENDER, gender_index)
|
||||
|
||||
outfitId = get_outfit_id_from_index(gender_index)
|
||||
@hairstyle = outfitId
|
||||
applyHair()
|
||||
#$Trainer.hair = outfitId
|
||||
$Trainer.clothes = outfitId
|
||||
$Trainer.hat = outfitId
|
||||
end
|
||||
|
||||
def get_outfit_id_from_index(gender_index)
|
||||
if gender_index == 1 #Male
|
||||
return "red"
|
||||
else
|
||||
#Female
|
||||
return "leaf"
|
||||
end
|
||||
end
|
||||
|
||||
#AGE
|
||||
def setAge(y_index, incr)
|
||||
@age += incr
|
||||
@age = MIN_AGE if @age > MAX_AGE
|
||||
@age = MAX_AGE if @age < MIN_AGE
|
||||
|
||||
@view.displayAge(@age, y_index)
|
||||
end
|
||||
|
||||
def setInitialValues()
|
||||
genderIndex = getOptionIndex(OPTION_GENDER)
|
||||
hairIndex = getOptionIndex(OPTION_HAIR)
|
||||
skinIndex = getOptionIndex(OPTION_SKIN)
|
||||
ageIndex = getOptionIndex(OPTION_AGE)
|
||||
|
||||
setGender(genderIndex, 0)
|
||||
setAge(ageIndex, 0)
|
||||
setHairColor(hairIndex, 0)
|
||||
setSkinColor(skinIndex, 0)
|
||||
updateTrainerPreview()
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,265 @@
|
||||
def playOutfitRemovedAnimation()
|
||||
pbSEPlay("shiny", 80, 60)
|
||||
$scene.spriteset.addUserAnimation(Settings::OW_SHINE_ANIMATION_ID, $game_player.x, $game_player.y, true)
|
||||
end
|
||||
|
||||
def playOutfitChangeAnimation()
|
||||
pbSEPlay("shiny", 80, 100)
|
||||
$scene.spriteset.addUserAnimation(Settings::OW_SHINE_ANIMATION_ID, $game_player.x, $game_player.y, true)
|
||||
end
|
||||
|
||||
def selectHairstyle(all_unlocked = false)
|
||||
selector = OutfitSelector.new
|
||||
display_outfit_preview()
|
||||
hat = $Trainer.hat
|
||||
commands = ["Next style", "Previous style", "Toggle hat", "Back"]
|
||||
previous_input = 0
|
||||
# To enable turning the common event that lets you turn around while in the dialog box
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
playOutfitChangeAnimation()
|
||||
selector.changeToNextHairstyle(1, all_unlocked)
|
||||
display_outfit_preview()
|
||||
when 1 #PREVIOUS
|
||||
playOutfitChangeAnimation()
|
||||
selector.changeToNextHairstyle(-1, all_unlocked)
|
||||
display_outfit_preview()
|
||||
when 2 #Toggle hat
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
if hat == $Trainer.hat
|
||||
$Trainer.hat = nil
|
||||
else
|
||||
$Trainer.hat = hat
|
||||
end
|
||||
display_outfit_preview()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
$Trainer.hat = hat
|
||||
end
|
||||
|
||||
def swapToNextHairVersion()
|
||||
split_hair = getSplitHairFilenameAndVersionFromID($Trainer.hair)
|
||||
hair_version = split_hair[0]
|
||||
hair_style = split_hair[1]
|
||||
current_version = hair_version
|
||||
pbSEPlay("GUI party switch", 80, 100)
|
||||
newVersion = current_version.to_i + 1
|
||||
lastVersion = findLastHairVersion(hair_style)
|
||||
newVersion = lastVersion if newVersion <= 0
|
||||
newVersion = 1 if newVersion > lastVersion
|
||||
$Trainer.hair = getFullHairId(hair_style,newVersion)
|
||||
end
|
||||
|
||||
def selectHairColor
|
||||
original_color = $Trainer.hair_color
|
||||
original_hair = $Trainer.hair
|
||||
$game_switches[SWITCH_SELECTING_CLOTHES]=true
|
||||
$game_map.update
|
||||
display_outfit_preview()
|
||||
hat = $Trainer.hat
|
||||
commands = ["Swap base color", "Shift up", "Shift down", "Toggle hat", "Remove dye", "Confirm", "Never Mind"]
|
||||
previous_input = 0
|
||||
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #change base
|
||||
swapToNextHairVersion()
|
||||
display_outfit_preview()
|
||||
ret = false
|
||||
when 1 #NEXT
|
||||
#playOutfitChangeAnimation()
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHairColor(10)
|
||||
display_outfit_preview()
|
||||
ret = true
|
||||
when 2 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHairColor(-10)
|
||||
display_outfit_preview()
|
||||
ret = true
|
||||
when 3 #Toggle hat
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
if hat == $Trainer.hat
|
||||
$Trainer.hat = nil
|
||||
else
|
||||
$Trainer.hat = hat
|
||||
end
|
||||
display_outfit_preview()
|
||||
when 4 #Reset
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
$Trainer.hair_color = 0
|
||||
display_outfit_preview()
|
||||
ret = false
|
||||
when 5 #Confirm
|
||||
break
|
||||
else
|
||||
$Trainer.hair_color = original_color
|
||||
$Trainer.hair = original_hair
|
||||
ret = false
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
$Trainer.hat = hat
|
||||
$game_switches[SWITCH_SELECTING_CLOTHES]=false
|
||||
$game_map.update
|
||||
return ret
|
||||
|
||||
end
|
||||
|
||||
def selectHatColor(secondary_hat=false)
|
||||
original_color = secondary_hat ? $Trainer.hat2_color : $Trainer.hat_color
|
||||
display_outfit_preview()
|
||||
commands = ["Shift up", "Shift down", "Reset", "Confirm", "Never Mind"]
|
||||
previous_input = 0
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHatColor(10,secondary_hat)
|
||||
display_outfit_preview
|
||||
ret = true
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHatColor(-10,secondary_hat)
|
||||
display_outfit_preview
|
||||
ret = true
|
||||
when 2 #Reset
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
$Trainer.hat_color = 0 if !secondary_hat
|
||||
$Trainer.hat2_color = 0 if secondary_hat
|
||||
display_outfit_preview
|
||||
refreshPlayerOutfit
|
||||
ret = false
|
||||
when 3 #Confirm
|
||||
break
|
||||
else
|
||||
$Trainer.hat_color = original_color if !secondary_hat
|
||||
$Trainer.hat2_color = original_color if secondary_hat
|
||||
ret = false
|
||||
break
|
||||
end
|
||||
end
|
||||
refreshPlayerOutfit()
|
||||
hide_outfit_preview()
|
||||
return ret
|
||||
end
|
||||
|
||||
def selectClothesColor
|
||||
original_color = $Trainer.clothes_color
|
||||
display_outfit_preview()
|
||||
commands = ["Shift up", "Shift down", "Reset", "Confirm", "Never Mind"]
|
||||
previous_input = 0
|
||||
ret = false
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftClothesColor(10)
|
||||
display_outfit_preview()
|
||||
ret = true
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftClothesColor(-10)
|
||||
display_outfit_preview()
|
||||
ret = true
|
||||
when 2 #Reset
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
$Trainer.clothes_color = 0
|
||||
display_outfit_preview()
|
||||
refreshPlayerOutfit()
|
||||
ret = false
|
||||
when 3 #Confirm
|
||||
break
|
||||
else
|
||||
$Trainer.clothes_color = original_color
|
||||
ret = false
|
||||
break
|
||||
end
|
||||
end
|
||||
refreshPlayerOutfit()
|
||||
hide_outfit_preview()
|
||||
return ret
|
||||
end
|
||||
|
||||
def selectHat(all_unlocked = false)
|
||||
selector = OutfitSelector.new
|
||||
display_outfit_preview()
|
||||
commands = ["Next hat", "Previous hat", "Remove hat", "Back"]
|
||||
previous_input = 0
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
playOutfitChangeAnimation()
|
||||
selector.changeToNextHat(1, all_unlocked)
|
||||
display_outfit_preview()
|
||||
when 1 #PREVIOUS
|
||||
playOutfitChangeAnimation()
|
||||
selector.changeToNextHat(-1, all_unlocked)
|
||||
display_outfit_preview()
|
||||
when 2 #REMOVE HAT
|
||||
playOutfitRemovedAnimation()
|
||||
$Trainer.hat = nil
|
||||
selector.display_outfit_preview()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
end
|
||||
|
||||
def spinCharacter
|
||||
pbSEPlay("GUI party switch", 80, 100)
|
||||
|
||||
end
|
||||
|
||||
def selectClothes(all_unlocked = false)
|
||||
selector = OutfitSelector.new
|
||||
display_outfit_preview()
|
||||
commands = ["Next", "Previous"]
|
||||
#commands << "Remove clothes (DEBUG)" if $DEBUG
|
||||
commands << "Remove" if $DEBUG
|
||||
commands << "Back"
|
||||
previous_input = 0
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
playOutfitChangeAnimation()
|
||||
selector.changeToNextClothes(1, all_unlocked)
|
||||
display_outfit_preview()
|
||||
when 1 #PREVIOUS
|
||||
playOutfitChangeAnimation()
|
||||
selector.changeToNextClothes(-1, all_unlocked)
|
||||
display_outfit_preview()
|
||||
when 2 #REMOVE CLOTHES
|
||||
break if !$DEBUG
|
||||
playOutfitRemovedAnimation()
|
||||
$Trainer.clothes = nil
|
||||
display_outfit_preview()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
end
|
||||
|
||||
def place_hat_on_pokemon(pokemon)
|
||||
hatscreen = PokemonHatPresenter.new(nil, pokemon)
|
||||
hatscreen.pbStartScreen()
|
||||
end
|
||||
@@ -0,0 +1,103 @@
|
||||
class PokemonHatPresenter
|
||||
PIXELS_PER_MOVEMENT = 4
|
||||
|
||||
def initialize(view, pokemon)
|
||||
@view = view
|
||||
@pokemon = pokemon
|
||||
@hatFilename = "Graphics/Characters/player/hat/trainer/hat_trainer_1"
|
||||
@sprites = {}
|
||||
|
||||
@x_pos = pokemon.hat_x ? pokemon.hat_x : 0
|
||||
@y_pos = pokemon.hat_y ? pokemon.hat_y : 0
|
||||
@hat_id = pokemon.hat ? pokemon.hat : 1
|
||||
@viewport = nil
|
||||
@previewwindow = nil
|
||||
|
||||
@original_pokemon_bitmap = nil
|
||||
end
|
||||
|
||||
def pbStartScreen
|
||||
@view.init_window(self)
|
||||
cancel if !select_hat()
|
||||
if position_hat()
|
||||
updatePokemonHatPosition()
|
||||
else
|
||||
cancel
|
||||
end
|
||||
@view.hide_move_arrows
|
||||
@view.hide_select_arrows
|
||||
@view.dispose_window()
|
||||
end
|
||||
|
||||
def updatePokemonHatPosition()
|
||||
@pokemon.hat = @hat_id
|
||||
@pokemon.hat_x = @x_pos
|
||||
@pokemon.hat_y = @y_pos
|
||||
end
|
||||
|
||||
def cancel
|
||||
@pokemon.hat = nil
|
||||
end
|
||||
|
||||
def select_hat
|
||||
selector = OutfitSelector.new
|
||||
@view.display_select_arrows
|
||||
outfit_type_path = get_hats_sets_list_path()
|
||||
@pokemon.hat = 0 if !@pokemon.hat
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@hat_id = selector.selectNextOutfit(@hat_id, 1, selector.hats_list, [], false, "hat",$Trainer.unlocked_hats,false) if Input.trigger?(Input::RIGHT)
|
||||
@hat_id = selector.selectNextOutfit(@hat_id, -1, selector.hats_list, [], false, "hat",$Trainer.unlocked_hats,false) if Input.trigger?(Input::LEFT)
|
||||
break if Input.trigger?(Input::USE)
|
||||
return false if Input.trigger?(Input::BACK)
|
||||
@view.update()
|
||||
end
|
||||
@pokemon.hat = @hat_id
|
||||
@view.hide_select_arrows
|
||||
|
||||
end
|
||||
|
||||
def position_hat
|
||||
@view.display_move_arrows
|
||||
min_x, max_x = -64, 88
|
||||
min_y, max_y = -20, 140
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@x_pos += PIXELS_PER_MOVEMENT if Input.repeat?(Input::RIGHT) && @x_pos < max_x
|
||||
@x_pos -= PIXELS_PER_MOVEMENT if Input.repeat?(Input::LEFT) && @x_pos > min_x
|
||||
@y_pos += PIXELS_PER_MOVEMENT if Input.repeat?(Input::DOWN) && @y_pos < max_y
|
||||
@y_pos -= PIXELS_PER_MOVEMENT if Input.repeat?(Input::UP) && @y_pos > min_y
|
||||
break if Input.trigger?(Input::USE)
|
||||
return false if Input.trigger?(Input::BACK)
|
||||
@view.update()
|
||||
end
|
||||
@view.hide_move_arrows
|
||||
return true
|
||||
end
|
||||
|
||||
def initialize_bitmap()
|
||||
spriteLoader = BattleSpriteLoader.new
|
||||
|
||||
if @pokemon.isTripleFusion?
|
||||
#todo
|
||||
elsif @pokemon.isFusion?
|
||||
@original_pokemon_bitmap = spriteLoader.load_fusion_sprite(@pokemon.head_id(),@pokemon.body_id())
|
||||
else
|
||||
echoln @pokemon
|
||||
echoln @pokemon.species_data
|
||||
@original_pokemon_bitmap = spriteLoader.load_base_sprite(@pokemon.id_number)
|
||||
end
|
||||
@original_pokemon_bitmap.scale_bitmap(Settings::FRONTSPRITE_SCALE)
|
||||
end
|
||||
|
||||
def getPokemonHatBitmap()
|
||||
@hatFilename = getTrainerSpriteHatFilename(@hat_id)
|
||||
hatBitmapWrapper = AnimatedBitmap.new(@hatFilename, 0) if pbResolveBitmap(@hatFilename)
|
||||
pokemon_bitmap = @original_pokemon_bitmap.bitmap.clone
|
||||
pokemon_bitmap.blt(@x_pos, @y_pos, hatBitmapWrapper.bitmap, hatBitmapWrapper.bitmap.rect) if hatBitmapWrapper
|
||||
return pokemon_bitmap
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,139 @@
|
||||
class PokemonHatView
|
||||
WINDOW_POS_X = Graphics.width / 4
|
||||
WINDOW_POS_Y = Graphics.height / 8
|
||||
|
||||
attr_accessor :x_pos
|
||||
attr_accessor :y_pos
|
||||
|
||||
def initialize(x_pos = nil, y_pos = nil, windowed = true)
|
||||
@x_pos = x_pos ? x_pos : WINDOW_POS_X
|
||||
@y_pos = y_pos ? y_pos : WINDOW_POS_Y
|
||||
@windowed = windowed
|
||||
|
||||
end
|
||||
|
||||
def init_window(presenter)
|
||||
@presenter = presenter
|
||||
|
||||
|
||||
presenter.initialize_bitmap()
|
||||
pokemon_bitmap = presenter.getPokemonHatBitmap()
|
||||
|
||||
@previewwindow = PictureWindow.new(pokemon_bitmap)
|
||||
@previewwindow.opacity = 0 if !@windowed
|
||||
update_window_position()
|
||||
@previewwindow.z = 9999999
|
||||
|
||||
@viewport = Viewport.new(@previewwindow.x, @previewwindow.y, @previewwindow.width, @previewwindow.height)
|
||||
@viewport.z = 9999999
|
||||
@sprites = {}
|
||||
|
||||
initialize_arrows()
|
||||
|
||||
end
|
||||
|
||||
def getWindowWidth()
|
||||
return @previewwindow.width/2
|
||||
end
|
||||
|
||||
def initialize_arrows()
|
||||
middle_horizontal = 100
|
||||
width_horizontal = 90
|
||||
|
||||
middle_vertical = 100
|
||||
width_vertical = 90
|
||||
|
||||
@sprites["uparrow"] = AnimatedSprite.new("Graphics/Pictures/uparrow", 8, 28, 40, 2, @viewport)
|
||||
@sprites["uparrow"].x = middle_horizontal
|
||||
@sprites["uparrow"].y = middle_vertical - width_vertical
|
||||
@sprites["uparrow"].z = 100
|
||||
@sprites["uparrow"].visible=true
|
||||
|
||||
|
||||
@sprites["downarrow"] = AnimatedSprite.new("Graphics/Pictures/downarrow", 8, 28, 40, 2, @viewport)
|
||||
@sprites["downarrow"].x = middle_horizontal
|
||||
@sprites["downarrow"].y = middle_vertical + width_vertical
|
||||
|
||||
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["leftarrow"].x = middle_horizontal - width_horizontal -10
|
||||
@sprites["leftarrow"].y = middle_vertical
|
||||
|
||||
|
||||
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["rightarrow"].x = middle_horizontal + width_horizontal
|
||||
@sprites["rightarrow"].y = middle_vertical
|
||||
|
||||
@sprites["uparrow"].visible=false
|
||||
@sprites["downarrow"].visible=false
|
||||
@sprites["leftarrow"].visible=false
|
||||
@sprites["rightarrow"].visible=false
|
||||
|
||||
end
|
||||
|
||||
def update_window_position()
|
||||
@previewwindow.x = @x_pos
|
||||
@previewwindow.y = @y_pos
|
||||
end
|
||||
|
||||
#TODO
|
||||
def display_select_arrows
|
||||
hide_move_arrows
|
||||
@sprites["rightarrow"].visible=true
|
||||
@sprites["leftarrow"].visible=true
|
||||
|
||||
@sprites["rightarrow"].play
|
||||
@sprites["leftarrow"].play
|
||||
end
|
||||
|
||||
def hide_select_arrows
|
||||
@sprites["rightarrow"].visible=false
|
||||
@sprites["leftarrow"].visible=false
|
||||
@sprites["rightarrow"].stop
|
||||
@sprites["leftarrow"].stop
|
||||
@sprites["rightarrow"].reset
|
||||
@sprites["leftarrow"].reset
|
||||
end
|
||||
|
||||
def display_move_arrows
|
||||
hide_move_arrows
|
||||
@sprites["rightarrow"].visible=true
|
||||
@sprites["leftarrow"].visible=true
|
||||
@sprites["uparrow"].visible=true
|
||||
@sprites["downarrow"].visible=true
|
||||
|
||||
@sprites["rightarrow"].play
|
||||
@sprites["leftarrow"].play
|
||||
@sprites["uparrow"].play
|
||||
@sprites["downarrow"].play
|
||||
end
|
||||
|
||||
def hide_move_arrows
|
||||
@sprites["rightarrow"].visible=false
|
||||
@sprites["leftarrow"].visible=false
|
||||
@sprites["uparrow"].visible=false
|
||||
@sprites["downarrow"].visible=false
|
||||
|
||||
@sprites["rightarrow"].stop
|
||||
@sprites["leftarrow"].stop
|
||||
@sprites["uparrow"].stop
|
||||
@sprites["downarrow"].stop
|
||||
end
|
||||
|
||||
def dispose_window
|
||||
@previewwindow.dispose
|
||||
@viewport.dispose
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@sprites = nil
|
||||
end
|
||||
|
||||
def update
|
||||
@sprites["rightarrow"].update
|
||||
@sprites["leftarrow"].update
|
||||
@sprites["uparrow"].update
|
||||
@sprites["downarrow"].update
|
||||
|
||||
@previewwindow.clearBitmaps
|
||||
@previewwindow.setBitmap(@presenter.getPokemonHatBitmap())
|
||||
@previewwindow.update
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,72 @@
|
||||
class TrainerClothesPreview
|
||||
attr_writer :pokeball, :clothes, :hat, :hat2, :hair, :skin_tone, :hair_color, :hat_color,:hat2_color, :clothes_color
|
||||
|
||||
def initialize(x = 0, y = 0, windowed = true, pokeball = nil)
|
||||
@playerBitmap = nil
|
||||
@playerSprite = nil
|
||||
@x_pos = x
|
||||
@y_pos = y
|
||||
@windowed = windowed
|
||||
|
||||
@pokeball = pokeball
|
||||
resetOutfits()
|
||||
end
|
||||
|
||||
def set_hat(value,is_secondaryHat=false)
|
||||
if is_secondaryHat
|
||||
@hat2 = value
|
||||
else
|
||||
@hat = value
|
||||
end
|
||||
end
|
||||
|
||||
def set_hat_color(value,is_secondaryHat=false)
|
||||
if is_secondaryHat
|
||||
@hat2_color = value
|
||||
else
|
||||
@hat_color = value
|
||||
end
|
||||
end
|
||||
|
||||
def resetOutfits()
|
||||
@clothes = $Trainer.clothes
|
||||
@hat = $Trainer.hat
|
||||
@hat2 = $Trainer.hat2
|
||||
@hair = $Trainer.hair
|
||||
@skin_tone = $Trainer.skin_tone
|
||||
@hair_color = $Trainer.hair_color
|
||||
@hat_color = $Trainer.hat_color
|
||||
@hat2_color = $Trainer.hat2_color
|
||||
@clothes_color = $Trainer.clothes_color
|
||||
end
|
||||
|
||||
def show()
|
||||
@playerBitmap = generate_front_trainer_sprite_bitmap(false,
|
||||
@pokeball,
|
||||
@clothes,
|
||||
@hat,@hat2, @hair,
|
||||
@skin_tone,
|
||||
@hair_color, @hat_color, @clothes_color, @hat2_color)
|
||||
initialize_preview()
|
||||
end
|
||||
|
||||
def updatePreview()
|
||||
erase()
|
||||
show()
|
||||
end
|
||||
|
||||
def initialize_preview()
|
||||
@playerSprite = PictureWindow.new(@playerBitmap)
|
||||
@playerSprite.opacity = 0 if !@windowed
|
||||
|
||||
@playerSprite.x = @x_pos
|
||||
@playerSprite.y = @y_pos
|
||||
@playerSprite.z = 9999
|
||||
@playerSprite.update
|
||||
end
|
||||
|
||||
def erase()
|
||||
@playerSprite.dispose if @playerSprite
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,159 @@
|
||||
class OutfitsMartAdapter < PokemonMartAdapter
|
||||
attr_accessor :worn_clothes
|
||||
attr_accessor :is_secondary_hat
|
||||
attr_accessor :items
|
||||
|
||||
WORN_ITEM_BASE_COLOR = MessageConfig::BLUE_TEXT_MAIN_COLOR
|
||||
WORN_ITEM_SHADOW_COLOR = MessageConfig::BLUE_TEXT_SHADOW_COLOR
|
||||
|
||||
|
||||
REGIONAL_SET_BASE_COLOR = Color.new(76,72,104)
|
||||
REGIONAL_SET_SHADOW_COLOR = Color.new(173,165,189)
|
||||
|
||||
CITY_EXCLUSIVE_BASE_COLOR = Color.new(61 , 125, 70) #Color.new(72 , 104, 83)
|
||||
CITY_EXCLUSIVE_SHADOW_COLOR = Color.new(165, 189, 178)
|
||||
|
||||
def initialize(stock = [], isShop = true, isSecondaryHat = false)
|
||||
@is_secondary_hat = isSecondaryHat
|
||||
@items = stock
|
||||
@worn_clothes = get_current_clothes()
|
||||
@isShop = isShop
|
||||
@version = nil
|
||||
$Trainer.dyed_hats = {} if !$Trainer.dyed_hats
|
||||
$Trainer.dyed_clothes = {} if !$Trainer.dyed_clothes
|
||||
|
||||
#todo: refactor to get the list from the first search when
|
||||
# setting the stock instead of searching twice
|
||||
@regional_set_items = @isShop ? list_regional_set_items : []
|
||||
@city_exclusive_items = @isShop ? list_city_exclusive_items : []
|
||||
end
|
||||
|
||||
def list_regional_set_items()
|
||||
return []
|
||||
end
|
||||
|
||||
def list_city_exclusive_items()
|
||||
return []
|
||||
end
|
||||
|
||||
def getDisplayName(item)
|
||||
return getName(item) if !item.name
|
||||
name = item.name
|
||||
name = "* #{name}" if is_wearing_clothes(item.id)
|
||||
return name
|
||||
end
|
||||
|
||||
def is_wearing_clothes(outfit_id)
|
||||
return outfit_id == @worn_clothes
|
||||
end
|
||||
|
||||
def player_changed_clothes?()
|
||||
return false
|
||||
#implement in inheriting classes
|
||||
end
|
||||
|
||||
def toggleText()
|
||||
return ""
|
||||
end
|
||||
|
||||
def switchVersion(item,delta=1)
|
||||
return
|
||||
end
|
||||
|
||||
def toggleEvent(item)
|
||||
return
|
||||
end
|
||||
|
||||
def isWornItem?(item)
|
||||
return false
|
||||
end
|
||||
|
||||
def isShop?()
|
||||
return @isShop
|
||||
end
|
||||
|
||||
def getPrice(item, selling = nil)
|
||||
return 0 if !@isShop
|
||||
return nil if itemOwned(item)
|
||||
return item.price.to_i
|
||||
end
|
||||
|
||||
def getDisplayPrice(item, selling = nil)
|
||||
return "" if !@isShop
|
||||
return "-" if itemOwned(item)
|
||||
super
|
||||
end
|
||||
|
||||
def updateStock()
|
||||
updated_items = []
|
||||
for item in @items
|
||||
updated_items << item if !get_unlocked_items_list().include?(item.id)
|
||||
end
|
||||
@items = updated_items
|
||||
end
|
||||
|
||||
def removeItem(item)
|
||||
super
|
||||
end
|
||||
|
||||
def itemOwned(item)
|
||||
owned_list = get_unlocked_items_list()
|
||||
return owned_list.include?(item.id)
|
||||
end
|
||||
|
||||
def canSell?(item)
|
||||
super
|
||||
end
|
||||
|
||||
def isItemInRegionalSet(item)
|
||||
return @regional_set_items.include?(item.id)
|
||||
end
|
||||
|
||||
def isItemCityExclusive(item)
|
||||
return @city_exclusive_items.include?(item.id)
|
||||
end
|
||||
|
||||
def getBaseColorOverride(item)
|
||||
return REGIONAL_SET_BASE_COLOR if isItemInRegionalSet(item)
|
||||
return CITY_EXCLUSIVE_BASE_COLOR if isItemCityExclusive(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getShadowColorOverride(item)
|
||||
return REGIONAL_SET_SHADOW_COLOR if isItemInRegionalSet(item)
|
||||
return CITY_EXCLUSIVE_SHADOW_COLOR if isItemCityExclusive(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getMoney
|
||||
super
|
||||
end
|
||||
|
||||
def getMoneyString
|
||||
super
|
||||
end
|
||||
|
||||
def setMoney(value)
|
||||
super
|
||||
end
|
||||
|
||||
def getItemIconRect(_item)
|
||||
super
|
||||
end
|
||||
|
||||
def getQuantity(item)
|
||||
super
|
||||
end
|
||||
|
||||
def showQuantity?(item)
|
||||
super
|
||||
end
|
||||
|
||||
def updateVersion(item)
|
||||
@version = 1 if !currentVersionExists?(item)
|
||||
end
|
||||
|
||||
def currentVersionExists?(item)
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,116 @@
|
||||
class ClothesMartAdapter < OutfitsMartAdapter
|
||||
|
||||
DEFAULT_NAME = "[unknown]"
|
||||
DEFAULT_DESCRIPTION = "A piece of clothing that trainers can wear."
|
||||
def toggleEvent(item)
|
||||
if !isShop? && $Trainer.clothes_color != 0
|
||||
if pbConfirmMessage(_INTL("Would you like to remove the dye?"))
|
||||
$Trainer.clothes_color = 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def list_regional_set_items()
|
||||
return list_regional_clothes
|
||||
end
|
||||
|
||||
def list_city_exclusive_items
|
||||
return list_city_exclusive_clothes
|
||||
end
|
||||
|
||||
def initialize(stock = nil, isShop = nil)
|
||||
super
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
name= item.id
|
||||
name = "* #{name}" if is_wearing_clothes(item.id)
|
||||
return name
|
||||
end
|
||||
|
||||
def getDescription(item)
|
||||
return DEFAULT_DESCRIPTION if !item.description
|
||||
return item.description
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return Settings::BACK_ITEM_ICON_PATH if !item
|
||||
return getOverworldOutfitFilename(item.id)
|
||||
end
|
||||
|
||||
def updateTrainerPreview(item, previewWindow)
|
||||
return if !item
|
||||
previewWindow.clothes = item.id
|
||||
$Trainer.clothes = item.id
|
||||
set_dye_color(item,previewWindow)
|
||||
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
|
||||
def get_dye_color(item_id)
|
||||
return 0 if isShop?
|
||||
$Trainer.dyed_clothes= {} if ! $Trainer.dyed_clothes
|
||||
if $Trainer.dyed_clothes.include?(item_id)
|
||||
return $Trainer.dyed_clothes[item_id]
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
def set_dye_color(item,previewWindow)
|
||||
if !isShop?
|
||||
$Trainer.dyed_clothes= {} if ! $Trainer.dyed_clothes
|
||||
if $Trainer.dyed_clothes.include?(item.id)
|
||||
dye_color = $Trainer.dyed_clothes[item.id]
|
||||
$Trainer.clothes_color = dye_color
|
||||
previewWindow.clothes_color = dye_color
|
||||
else
|
||||
$Trainer.clothes_color=0
|
||||
previewWindow.clothes_color=0
|
||||
end
|
||||
else
|
||||
$Trainer.clothes_color=0
|
||||
previewWindow.clothes_color=0
|
||||
end
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
changed_clothes = obtainClothes(item.id)
|
||||
if changed_clothes
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_clothes()
|
||||
return $Trainer.clothes
|
||||
end
|
||||
|
||||
def player_changed_clothes?()
|
||||
$Trainer.clothes != @worn_clothes
|
||||
end
|
||||
|
||||
def putOnSelectedOutfit()
|
||||
putOnClothes($Trainer.clothes)
|
||||
@worn_clothes = $Trainer.clothes
|
||||
end
|
||||
|
||||
def putOnOutfit(item)
|
||||
putOnClothes(item.id) if item
|
||||
@worn_clothes = item.id if item
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
$Trainer.clothes = @worn_clothes
|
||||
$Trainer.clothes_color = $Trainer.dyed_clothes[@worn_clothes] if $Trainer.dyed_clothes && $Trainer.dyed_clothes[@worn_clothes]
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
return $Trainer.unlocked_clothes
|
||||
end
|
||||
|
||||
def isWornItem?(item)
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -0,0 +1,146 @@
|
||||
def genericOutfitsShopMenu(stock = [], itemType = nil, versions = false, isShop=true, message=nil)
|
||||
commands = []
|
||||
commands[cmdBuy = commands.length] = _INTL("Buy")
|
||||
commands[cmdQuit = commands.length] = _INTL("Quit")
|
||||
message = _INTL("Welcome! How may I serve you?") if !message
|
||||
cmd = pbMessage(message, commands, cmdQuit + 1)
|
||||
loop do
|
||||
if cmdBuy >= 0 && cmd == cmdBuy
|
||||
adapter = getAdapter(itemType, stock, isShop)
|
||||
view = ClothesShopView.new()
|
||||
presenter = getPresenter(itemType, view, stock, adapter, versions)
|
||||
presenter.pbBuyScreen
|
||||
break
|
||||
else
|
||||
pbMessage(_INTL("Please come again!"))
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
def getPresenter(itemType, view, stock, adapter, versions)
|
||||
case itemType
|
||||
when :HAIR
|
||||
return HairShopPresenter.new(view, stock, adapter, versions)
|
||||
else
|
||||
return ClothesShopPresenter.new(view, stock, adapter, versions)
|
||||
end
|
||||
end
|
||||
|
||||
def getAdapter(itemType, stock, isShop, is_secondary=false)
|
||||
case itemType
|
||||
when :CLOTHES
|
||||
return ClothesMartAdapter.new(stock, isShop)
|
||||
when :HAT
|
||||
return HatsMartAdapter.new(stock, isShop,is_secondary)
|
||||
when :HAIR
|
||||
return HairMartAdapter.new(stock, isShop)
|
||||
end
|
||||
end
|
||||
|
||||
def list_all_possible_outfits() end
|
||||
|
||||
def clothesShop(outfits_list = [], free=false,customMessage=nil)
|
||||
stock = []
|
||||
outfits_list.each { |outfit_id|
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
genericOutfitsShopMenu(stock, :CLOTHES,false,!free,customMessage)
|
||||
end
|
||||
|
||||
def hatShop(outfits_list = [], free=false, customMessage=nil)
|
||||
stock = []
|
||||
outfits_list.each { |outfit_id|
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
genericOutfitsShopMenu(stock, :HAT,false,!free,customMessage)
|
||||
end
|
||||
|
||||
def hairShop(outfits_list = [],free=false, customMessage=nil)
|
||||
currentHair = getSimplifiedHairIdFromFullID($Trainer.hair)
|
||||
stock = [:SWAP_COLOR]
|
||||
#always add current hairstyle as first option (in case the player just wants to swap the color)
|
||||
stock << get_hair_by_id(currentHair) if $Trainer.hair
|
||||
outfits_list.each { |outfit_id|
|
||||
next if outfit_id == currentHair
|
||||
outfit = get_hair_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
genericOutfitsShopMenu(stock, :HAIR, true,!free,customMessage)
|
||||
end
|
||||
|
||||
def switchHatsPosition()
|
||||
hat1 = $Trainer.hat
|
||||
hat2 = $Trainer.hat2
|
||||
hat1_color = $Trainer.hat_color
|
||||
hat2_color = $Trainer.hat2_color
|
||||
|
||||
$Trainer.hat = hat2
|
||||
$Trainer.hat2 = hat1
|
||||
$Trainer.hat_color = hat1_color
|
||||
$Trainer.hat_color = hat2_color
|
||||
|
||||
pbSEPlay("GUI naming tab swap start")
|
||||
end
|
||||
|
||||
SWAP_HAT_POSITIONS_CAPTION = "Switch hats position"
|
||||
|
||||
#is_secondary only used for hats
|
||||
def openSelectOutfitMenu(stock = [], itemType =nil, is_secondary=false)
|
||||
adapter = getAdapter(itemType, stock, false, is_secondary)
|
||||
view = getView(itemType)
|
||||
presenter = ClothesShopPresenter.new(view, stock, adapter)
|
||||
presenter.pbBuyScreen
|
||||
end
|
||||
|
||||
def getView(itemType)
|
||||
case itemType
|
||||
when :HAT
|
||||
return HatShopView.new
|
||||
else
|
||||
return ClothesShopView.new
|
||||
end
|
||||
end
|
||||
|
||||
def changeClothesMenu()
|
||||
stock = []
|
||||
$Trainer.unlocked_clothes.each { |outfit_id|
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
openSelectOutfitMenu(stock, :CLOTHES)
|
||||
end
|
||||
|
||||
def changeHatMenu(is_secondary_hat = false)
|
||||
stock = []
|
||||
$Trainer.unlocked_hats.each { |outfit_id|
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
stock << :REMOVE_HAT
|
||||
openSelectOutfitMenu(stock, :HAT, is_secondary_hat)
|
||||
end
|
||||
|
||||
def changeOutfit()
|
||||
commands = []
|
||||
commands[cmdHat = commands.length] = _INTL("Change hat")
|
||||
commands[cmdClothes = commands.length] = _INTL("Change clothes")
|
||||
commands[cmdQuit = commands.length] = _INTL("Quit")
|
||||
|
||||
cmd = pbMessage(_INTL("What would you like to do?"), commands, cmdQuit + 1)
|
||||
loop do
|
||||
if cmd == cmdClothes
|
||||
changeClothesMenu()
|
||||
break
|
||||
elsif cmd == cmdHat
|
||||
changeHatMenu()
|
||||
break
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,163 @@
|
||||
class ClothesShopPresenter < PokemonMartScreen
|
||||
def pbChooseBuyItem
|
||||
|
||||
end
|
||||
|
||||
def initialize(scene, stock, adapter = nil, versions = false)
|
||||
super(scene, stock, adapter)
|
||||
@use_versions = versions
|
||||
end
|
||||
|
||||
def putOnClothes(item,end_scene=true)
|
||||
@adapter.putOnOutfit(item) if item
|
||||
@scene.pbEndBuyScene if end_scene
|
||||
end
|
||||
|
||||
|
||||
def dyeClothes()
|
||||
original_color = $Trainer.clothes_color
|
||||
options = ["Shift up", "Shift down", "Reset", "Confirm", "Never Mind"]
|
||||
previous_input = 0
|
||||
ret = false
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, options, options.length, previous_input,200)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftClothesColor(10)
|
||||
ret = true
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftClothesColor(-10)
|
||||
ret = true
|
||||
when 2 #Reset
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
$Trainer.clothes_color = 0
|
||||
ret = false
|
||||
when 3 #Confirm
|
||||
break
|
||||
else
|
||||
$Trainer.clothes_color = original_color
|
||||
ret = false
|
||||
break
|
||||
end
|
||||
@scene.updatePreviewWindow
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
# returns true if should stay in the menu
|
||||
def playerClothesActionsMenu(item)
|
||||
cmd_wear = "Wear"
|
||||
cmd_dye = "Dye Kit"
|
||||
options = []
|
||||
options << cmd_wear
|
||||
options << cmd_dye if $PokemonBag.pbHasItem?(:CLOTHESDYEKIT)
|
||||
options << "Cancel"
|
||||
choice = pbMessage("What would you like to do?", options, -1)
|
||||
|
||||
if options[choice] == cmd_wear
|
||||
putOnClothes(item,false)
|
||||
$Trainer.clothes_color = @adapter.get_dye_color(item.id)
|
||||
return true
|
||||
elsif options[choice] == cmd_dye
|
||||
dyeClothes()
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
def confirmPutClothes(item)
|
||||
putOnClothes(item)
|
||||
end
|
||||
|
||||
def quitMenuPrompt()
|
||||
return true if !(@adapter.is_a?(HatsMartAdapter) || @adapter.is_a?(ClothesMartAdapter))
|
||||
boolean_changes_detected = @adapter.player_changed_clothes?
|
||||
return true if !boolean_changes_detected
|
||||
pbPlayCancelSE
|
||||
cmd_confirm = "Set outfit"
|
||||
cmd_discard = "Discard changes"
|
||||
cmd_cancel = "Cancel"
|
||||
options = [cmd_discard,cmd_confirm,cmd_cancel]
|
||||
choice = pbMessage("You have unsaved changes!",options,3)
|
||||
case options[choice]
|
||||
when cmd_confirm
|
||||
@adapter.putOnSelectedOutfit
|
||||
pbPlayDecisionSE
|
||||
return true
|
||||
when cmd_discard
|
||||
pbPlayCloseMenuSE
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def pbBuyScreen
|
||||
@scene.pbStartBuyScene(@stock, @adapter)
|
||||
@scene.select_specific_item(@adapter.worn_clothes) if !@adapter.isShop?
|
||||
item = nil
|
||||
loop do
|
||||
item = @scene.pbChooseBuyItem
|
||||
if !item
|
||||
break if @adapter.isShop?
|
||||
#quit_menu_choice = quitMenuPrompt()
|
||||
#break if quit_menu_choice
|
||||
break
|
||||
next
|
||||
end
|
||||
|
||||
|
||||
if !@adapter.isShop?
|
||||
if @adapter.is_a?(ClothesMartAdapter)
|
||||
stay_in_menu = playerClothesActionsMenu(item)
|
||||
next if stay_in_menu
|
||||
return
|
||||
elsif @adapter.is_a?(HatsMartAdapter)
|
||||
echoln pbGet(1)
|
||||
stay_in_menu = playerHatActionsMenu(item)
|
||||
echoln pbGet(1)
|
||||
next if stay_in_menu
|
||||
return
|
||||
else
|
||||
if pbConfirm(_INTL("Would you like to put on the {1}?", item.name))
|
||||
confirmPutClothes(item)
|
||||
return
|
||||
end
|
||||
next
|
||||
end
|
||||
next
|
||||
end
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
price = @adapter.getPrice(item)
|
||||
if !price.is_a?(Integer)
|
||||
pbDisplayPaused(_INTL("You already own this item!"))
|
||||
if pbConfirm(_INTL("Would you like to put on the {1}?", item.name))
|
||||
@adapter.putOnOutfit(item)
|
||||
end
|
||||
next
|
||||
end
|
||||
if @adapter.getMoney < price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
|
||||
if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
|
||||
itemname, price.to_s_formatted))
|
||||
next
|
||||
end
|
||||
if @adapter.getMoney < price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
@adapter.setMoney(@adapter.getMoney - price)
|
||||
@stock.compact!
|
||||
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
|
||||
@adapter.addItem(item)
|
||||
end
|
||||
@scene.pbEndBuyScene
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,154 @@
|
||||
class ClothesShopPresenter < PokemonMartScreen
|
||||
|
||||
def removeHat(item)
|
||||
pbSEPlay("GUI storage put down")
|
||||
@adapter.toggleEvent(item)
|
||||
@scene.select_specific_item(nil,true)
|
||||
end
|
||||
|
||||
def wearAsHat1(item)
|
||||
@adapter.set_secondary_hat(false)
|
||||
putOnClothes(item)
|
||||
$Trainer.set_hat_color(@adapter.get_dye_color(item.id),false)
|
||||
end
|
||||
def wearAsHat2(item)
|
||||
@adapter.set_secondary_hat(true)
|
||||
putOnClothes(item)
|
||||
$Trainer.set_hat_color(@adapter.get_dye_color(item.id),true)
|
||||
end
|
||||
|
||||
def removeDye(item)
|
||||
if pbConfirm(_INTL("Are you sure you want to remove the dye from the {1}?", item.name))
|
||||
$Trainer.set_hat_color(0,@adapter.is_secondary_hat)
|
||||
end
|
||||
end
|
||||
|
||||
def swapHats()
|
||||
echoln "hat 1: #{$Trainer.hat}"
|
||||
echoln "hat 2: #{$Trainer.hat2}"
|
||||
|
||||
|
||||
$Trainer.hat, $Trainer.hat2 = $Trainer.hat2, $Trainer.hat
|
||||
|
||||
pbSEPlay("GUI naming tab swap start")
|
||||
new_selected_hat = @adapter.is_secondary_hat ? $Trainer.hat2 : $Trainer.hat
|
||||
echoln "hat 1: #{$Trainer.hat}"
|
||||
echoln "hat 2: #{$Trainer.hat2}"
|
||||
echoln "new selected hat: #{new_selected_hat}"
|
||||
|
||||
@scene.select_specific_item(new_selected_hat,true)
|
||||
@scene.updatePreviewWindow
|
||||
end
|
||||
|
||||
|
||||
def build_options_menu(item,cmd_confirm,cmd_remove,cmd_dye,cmd_swap,cmd_cancel)
|
||||
options = []
|
||||
options << cmd_confirm
|
||||
options << cmd_remove
|
||||
|
||||
options << cmd_swap
|
||||
options << cmd_dye if $PokemonBag.pbHasItem?(:HATSDYEKIT)
|
||||
options << cmd_cancel
|
||||
end
|
||||
|
||||
def build_wear_options(cmd_wear_hat1,cmd_wear_hat2,cmd_replace_hat1,cmd_replace_hat2)
|
||||
options = []
|
||||
primary_hat, secondary_hat = @adapter.worn_clothes, @adapter.worn_clothes2
|
||||
primary_cmds = primary_hat ? cmd_replace_hat1 : cmd_wear_hat1
|
||||
secondary_cmds = secondary_hat ? cmd_replace_hat2 : cmd_wear_hat2
|
||||
|
||||
if @adapter.is_secondary_hat
|
||||
options << secondary_cmds
|
||||
options << primary_cmds
|
||||
else
|
||||
options << primary_cmds
|
||||
options << secondary_cmds
|
||||
end
|
||||
return options
|
||||
end
|
||||
|
||||
|
||||
def putOnHats()
|
||||
@adapter.worn_clothes = $Trainer.hat
|
||||
@adapter.worn_clothes2 = $Trainer.hat2
|
||||
|
||||
putOnHat($Trainer.hat,true,false)
|
||||
putOnHat($Trainer.hat2,true,true)
|
||||
|
||||
playOutfitChangeAnimation()
|
||||
pbMessage(_INTL("You put on the hat(s)!\\wtnp[30]"))
|
||||
end
|
||||
|
||||
def dyeOptions(secondary_hat=false,item)
|
||||
original_color = secondary_hat ? $Trainer.hat2_color : $Trainer.hat_color
|
||||
options = ["Shift up", "Shift down", "Reset", "Confirm", "Never Mind"]
|
||||
previous_input = 0
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, options, options.length, previous_input,200)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHatColor(10,secondary_hat)
|
||||
ret = true
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHatColor(-10,secondary_hat)
|
||||
ret = true
|
||||
when 2 #Reset
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
$Trainer.hat_color = 0 if !secondary_hat
|
||||
$Trainer.hat2_color = 0 if secondary_hat
|
||||
ret = false
|
||||
when 3 #Confirm
|
||||
break
|
||||
else
|
||||
$Trainer.hat_color = original_color if !secondary_hat
|
||||
$Trainer.hat2_color = original_color if secondary_hat
|
||||
ret = false
|
||||
break
|
||||
end
|
||||
@scene.updatePreviewWindow
|
||||
@scene.displayLayerIcons(item)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
def confirmPutClothes(item)
|
||||
if @adapter.is_a?(HatsMartAdapter)
|
||||
putOnHats()
|
||||
$Trainer.hat_color = @adapter.get_dye_color($Trainer.hat)
|
||||
$Trainer.hat2_color = @adapter.get_dye_color($Trainer.hat2)
|
||||
else
|
||||
putOnClothes(item,false)
|
||||
end
|
||||
end
|
||||
|
||||
def playerHatActionsMenu(item)
|
||||
cmd_confirm = "Confirm"
|
||||
cmd_remove = "Remove hat"
|
||||
cmd_cancel = "Cancel"
|
||||
cmd_dye = "Dye Kit"
|
||||
cmd_swap = "Swap hat positions"
|
||||
|
||||
options = build_options_menu(item,cmd_confirm,cmd_remove,cmd_dye,cmd_swap,cmd_cancel)
|
||||
choice = pbMessage("What would you like to do?", options, -1,nil,0)
|
||||
if options[choice] == cmd_remove
|
||||
removeHat(item)
|
||||
return true
|
||||
elsif options[choice] == cmd_confirm
|
||||
confirmPutClothes(nil)
|
||||
return true
|
||||
elsif options[choice] == cmd_dye
|
||||
dyeOptions(@adapter.is_secondary_hat,item)
|
||||
return true
|
||||
elsif options[choice] == cmd_swap
|
||||
swapHats()
|
||||
return true
|
||||
elsif options[choice] == "dye"
|
||||
selectHatColor
|
||||
end
|
||||
@scene.updatePreviewWindow
|
||||
return true
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,205 @@
|
||||
class ClothesShopView < PokemonMart_Scene
|
||||
|
||||
def initialize(currency_name = "Money")
|
||||
@currency_name = currency_name
|
||||
end
|
||||
|
||||
def pbStartBuyOrSellScene(buying, stock, adapter)
|
||||
super(buying, stock, adapter)
|
||||
@sprites["icon"].visible = false
|
||||
if @adapter.isShop?
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/Outfits/martScreenOutfit")
|
||||
else
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/Outfits/changeOutfitScreen")
|
||||
end
|
||||
|
||||
preview_y = @adapter.isShop? ? 80 : 0
|
||||
@sprites["trainerPreview"] = TrainerClothesPreview.new(0, preview_y, true, "WALLET")
|
||||
|
||||
@sprites["trainerPreview"].show()
|
||||
@sprites["moneywindow"].visible = false if !@adapter.isShop?
|
||||
|
||||
Kernel.pbDisplayText(@adapter.toggleText, 80, 200, 99999) if @adapter.toggleText
|
||||
|
||||
end
|
||||
|
||||
def select_specific_item(scroll_to_item_id,go_to_end_of_list_if_nil=false)
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
if !scroll_to_item_id && go_to_end_of_list_if_nil
|
||||
itemwindow.index=@adapter.items.length-1
|
||||
itemwindow.refresh
|
||||
end
|
||||
i=0
|
||||
for item in @adapter.items
|
||||
next if !item.is_a?(Outfit)
|
||||
if item.id == scroll_to_item_id
|
||||
itemwindow.index=i
|
||||
itemwindow.refresh
|
||||
end
|
||||
i+=1
|
||||
end
|
||||
end
|
||||
|
||||
def scroll_map
|
||||
pbScrollMap(DIRECTION_UP, 5, 6)
|
||||
pbScrollMap(DIRECTION_RIGHT, 7, 6)
|
||||
@initial_direction = $game_player.direction
|
||||
$game_player.turn_down
|
||||
pbRefreshSceneMap
|
||||
end
|
||||
|
||||
def scroll_back_map
|
||||
@adapter.reset_player_clothes()
|
||||
pbScrollMap(DIRECTION_LEFT, 7, 6)
|
||||
pbScrollMap(DIRECTION_DOWN, 5, 6)
|
||||
$game_player.turn_generic(@initial_direction)
|
||||
end
|
||||
|
||||
def refreshStock(adapter)
|
||||
@adapter = adapter
|
||||
@sprites["itemwindow"].dispose if !@sprites
|
||||
@sprites["itemwindow"] = Window_PokemonMart.new(@stock, BuyAdapter.new(adapter),
|
||||
Graphics.width - 316 - 16, 12, 330 + 16, Graphics.height - 126)
|
||||
end
|
||||
|
||||
def pbRefresh
|
||||
if @subscene
|
||||
@subscene.pbRefresh
|
||||
else
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
item = itemwindow.item
|
||||
if itemwindow.item
|
||||
if itemwindow.item.is_a?(Symbol)
|
||||
text = @adapter.getSpecialItemCaption(item)
|
||||
else
|
||||
text = @adapter.getDescription(item)
|
||||
end
|
||||
else
|
||||
text = _INTL("Quit.")
|
||||
end
|
||||
@sprites["itemtextwindow"].text = text
|
||||
itemwindow.refresh
|
||||
end
|
||||
@sprites["moneywindow"].text = _INTL("{2}:\r\n<r>{1}", @adapter.getMoneyString, @currency_name)
|
||||
end
|
||||
|
||||
def updateTrainerPreview()
|
||||
displayNewItem(@sprites["itemwindow"])
|
||||
end
|
||||
|
||||
def displayNewItem(itemwindow)
|
||||
item = itemwindow.item
|
||||
if item
|
||||
if item.is_a?(Symbol)
|
||||
description = @adapter.getSpecialItemDescription(itemwindow.item)
|
||||
else
|
||||
description = @adapter.getDescription(itemwindow.item)
|
||||
@adapter.updateVersion(itemwindow.item)
|
||||
end
|
||||
@adapter.updateTrainerPreview(itemwindow.item, @sprites["trainerPreview"])
|
||||
else
|
||||
description = _INTL("Quit.")
|
||||
end
|
||||
@sprites["itemtextwindow"].text = description
|
||||
end
|
||||
|
||||
def updatePreviewWindow
|
||||
itemwindow= @sprites["itemwindow"]
|
||||
@adapter.updateTrainerPreview(itemwindow.item, @sprites["trainerPreview"])
|
||||
end
|
||||
|
||||
def pbChooseBuyItem
|
||||
itemwindow = @sprites["itemwindow"]
|
||||
refreshStock(@adapter) if !itemwindow
|
||||
displayNewItem(itemwindow)
|
||||
@sprites["helpwindow"].visible = false
|
||||
pbActivateWindow(@sprites, "itemwindow") {
|
||||
pbRefresh
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
olditem = itemwindow.item
|
||||
self.update
|
||||
if itemwindow.item != olditem
|
||||
displayNewItem(itemwindow)
|
||||
end
|
||||
if Input.trigger?(Input::AUX1) #L button - disabled because same key as speed up...
|
||||
#@adapter.switchVersion(itemwindow.item, -1)
|
||||
#updateTrainerPreview()
|
||||
end
|
||||
|
||||
if Input.trigger?(Input::AUX2) || Input.trigger?(Input::SHIFT) #R button
|
||||
switchItemVersion(itemwindow)
|
||||
end
|
||||
if Input.trigger?(Input::SPECIAL) #R button
|
||||
@adapter.toggleEvent(itemwindow.item)
|
||||
updateTrainerPreview()
|
||||
end
|
||||
|
||||
if Input.trigger?(Input::BACK)
|
||||
pbPlayCloseMenuSE
|
||||
return nil
|
||||
elsif Input.trigger?(Input::USE)
|
||||
if itemwindow.item.is_a?(Symbol)
|
||||
ret = onSpecialActionTrigger(itemwindow)
|
||||
return ret if ret
|
||||
elsif itemwindow.index < @stock.length
|
||||
pbRefresh
|
||||
return @stock[itemwindow.index]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def onSpecialActionTrigger(itemwindow)
|
||||
@adapter.doSpecialItemAction(itemwindow.item)
|
||||
updateTrainerPreview()
|
||||
return nil
|
||||
end
|
||||
def onItemClick(itemwindow)
|
||||
if itemwindow.item.is_a?(Symbol)
|
||||
@adapter.doSpecialItemAction(itemwindow.item)
|
||||
updateTrainerPreview()
|
||||
elsif itemwindow.index < @stock.length
|
||||
pbRefresh
|
||||
return @stock[itemwindow.index]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
def switchItemVersion(itemwindow)
|
||||
@adapter.switchVersion(itemwindow.item, 1)
|
||||
updateTrainerPreview()
|
||||
end
|
||||
|
||||
def update
|
||||
if Input.trigger?(Input::LEFT)
|
||||
pbSEPlay("GUI party switch", 80, 100)
|
||||
$game_player.turn_right_90
|
||||
pbRefreshSceneMap
|
||||
end
|
||||
if Input.trigger?(Input::RIGHT)
|
||||
pbSEPlay("GUI party switch", 80, 100)
|
||||
$game_player.turn_left_90
|
||||
pbRefreshSceneMap
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def pbEndBuyScene
|
||||
if !@sprites.empty?
|
||||
@sprites["trainerPreview"].erase()
|
||||
@sprites["trainerPreview"] = nil
|
||||
end
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
Kernel.pbClearText()
|
||||
# Scroll left after showing screen
|
||||
scroll_back_map()
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,209 @@
|
||||
class HairMartAdapter < OutfitsMartAdapter
|
||||
DEFAULT_NAME = "[unknown]"
|
||||
DEFAULT_DESCRIPTION = "A hairstyle for trainers."
|
||||
|
||||
POSSIBLE_VERSIONS = (1..9).to_a
|
||||
|
||||
def initialize(stock = nil, isShop = nil)
|
||||
super
|
||||
|
||||
@version = getCurrentHairVersion().to_i
|
||||
@worn_hair = $Trainer.hair
|
||||
@worn_hat = $Trainer.hat
|
||||
@worn_hat2 = $Trainer.hat2
|
||||
|
||||
@hat_visible = false
|
||||
@removable = true
|
||||
@previous_item= find_first_item()
|
||||
end
|
||||
|
||||
def find_first_item()
|
||||
return @items.find { |item| item.is_a?(Outfit) }
|
||||
end
|
||||
|
||||
def switchVersion(item, delta = 1)
|
||||
if !item.is_a?(Outfit)
|
||||
item = @previous_item
|
||||
end
|
||||
pbSEPlay("GUI party switch", 80, 100)
|
||||
newVersion = @version + delta
|
||||
lastVersion = findLastHairVersion(item.id)
|
||||
newVersion = lastVersion if newVersion <= 0
|
||||
newVersion = 1 if newVersion > lastVersion
|
||||
@version = newVersion
|
||||
end
|
||||
|
||||
def player_changed_clothes?()
|
||||
$Trainer.hairstyle != @worn_hair
|
||||
end
|
||||
|
||||
#player can't "own" hairstyles
|
||||
# if you want to go back one you had before, you have to pay again
|
||||
def itemOwned(item)
|
||||
return false
|
||||
end
|
||||
|
||||
def list_regional_set_items()
|
||||
return list_regional_hairstyles
|
||||
end
|
||||
|
||||
def list_city_exclusive_items
|
||||
return list_city_exclusive_hairstyles
|
||||
end
|
||||
|
||||
|
||||
def toggleEvent(item)
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
toggleHatVisibility()
|
||||
end
|
||||
|
||||
def toggleText()
|
||||
text = ""
|
||||
#text << "Color: R, \n"
|
||||
text << "Toggle Hat: D\n"
|
||||
|
||||
end
|
||||
|
||||
def toggleHatVisibility()
|
||||
@hat_visible = !@hat_visible
|
||||
end
|
||||
|
||||
def getPrice(item, selling = nil)
|
||||
return 0 if !@isShop
|
||||
trainer_hair_id = getSplitHairFilenameAndVersionFromID(@worn_hair)[1]
|
||||
|
||||
|
||||
return nil if item.id == trainer_hair_id
|
||||
return item.price.to_i
|
||||
end
|
||||
|
||||
def getDisplayPrice(item, selling = nil)
|
||||
trainerStyleID = getSplitHairFilenameAndVersionFromID(@worn_hair)[1]
|
||||
return "-" if item.id == trainerStyleID
|
||||
super
|
||||
end
|
||||
|
||||
def getCurrentHairVersion()
|
||||
begin
|
||||
return getSplitHairFilenameAndVersionFromID($Trainer.hair)[0]
|
||||
rescue
|
||||
return 1
|
||||
end
|
||||
end
|
||||
|
||||
def getCurrentHairId(itemId)
|
||||
return getFullHairId(itemId, @version)
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
echoln $Trainer.hair
|
||||
return item.id
|
||||
end
|
||||
|
||||
def getDescription(item)
|
||||
return DEFAULT_DESCRIPTION if !item.description
|
||||
return item.description
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return Settings::BACK_ITEM_ICON_PATH if !item
|
||||
return getOverworldHatFilename(item.id)
|
||||
end
|
||||
|
||||
def updateTrainerPreview(item, previewWindow)
|
||||
item = @previous_item if !item
|
||||
item = @previous_item if item.is_a?(Symbol)
|
||||
@previous_item = find_first_item() if !item.is_a?(Symbol)
|
||||
|
||||
displayed_hat = @hat_visible ? @worn_hat : nil
|
||||
displayed_hat2 = @hat_visible ? @worn_hat2 : nil
|
||||
|
||||
previewWindow.hat = displayed_hat
|
||||
previewWindow.hat2 = displayed_hat2
|
||||
|
||||
$Trainer.hat = displayed_hat
|
||||
$Trainer.hat2 = displayed_hat2
|
||||
|
||||
itemId = getCurrentHairId(item.id)
|
||||
previewWindow.hair = itemId
|
||||
$Trainer.hair = itemId
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
itemId = getCurrentHairId(item.id)
|
||||
|
||||
obtainNewHairstyle(itemId)
|
||||
@worn_hair = itemId
|
||||
end
|
||||
|
||||
def get_current_clothes()
|
||||
return $Trainer.hair
|
||||
end
|
||||
|
||||
def putOnOutfit(item)
|
||||
itemFullId = getCurrentHairId(item.id)
|
||||
putOnHair(item.id, @version)
|
||||
@worn_hair = itemFullId
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
# can change hair color for free if not changing the style
|
||||
if getVersionFromFullID(@worn_hair) != @version
|
||||
worn_id = getSimplifiedHairIdFromFullID(@worn_hair)
|
||||
if getSimplifiedHairIdFromFullID($Trainer.hair) == worn_id
|
||||
@worn_hair = getFullHairId(worn_id,@version)
|
||||
end
|
||||
end
|
||||
|
||||
$Trainer.hair = @worn_hair
|
||||
$Trainer.hat = @worn_hat
|
||||
$Trainer.hat2 = @worn_hat2
|
||||
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
return $Trainer.unlocked_hairstyles
|
||||
end
|
||||
|
||||
|
||||
def getSpecialItemCaption(specialType)
|
||||
case specialType
|
||||
when :SWAP_COLOR
|
||||
return "Swap Color"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemBaseColor(specialType)
|
||||
case specialType
|
||||
when :SWAP_COLOR
|
||||
return MessageConfig::BLUE_TEXT_MAIN_COLOR
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemShadowColor(specialType)
|
||||
case specialType
|
||||
when :SWAP_COLOR
|
||||
return MessageConfig::BLUE_TEXT_SHADOW_COLOR
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemDescription(specialType)
|
||||
return "Swap to the next base hair color."
|
||||
end
|
||||
|
||||
def doSpecialItemAction(specialType)
|
||||
switchVersion(nil,1)
|
||||
end
|
||||
|
||||
def currentVersionExists?(item)
|
||||
hairId = getCurrentHairId(item.id)
|
||||
filename = getOverworldHairFilename(hairId)
|
||||
return pbResolveBitmap(filename)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,68 @@
|
||||
class HairShopPresenter < PokemonMartScreen
|
||||
def pbChooseBuyItem
|
||||
|
||||
end
|
||||
|
||||
def initialize(scene, stock, adapter = nil, versions=false)
|
||||
super(scene,stock,adapter)
|
||||
@use_versions = versions
|
||||
end
|
||||
|
||||
|
||||
def pbBuyScreen
|
||||
@scene.pbStartBuyScene(@stock, @adapter)
|
||||
item = nil
|
||||
loop do
|
||||
item = @scene.pbChooseBuyItem
|
||||
break if !item
|
||||
|
||||
if !@adapter.isShop?
|
||||
if pbConfirm(_INTL("Would you like to purchase {1}?", item.name))
|
||||
@adapter.putOnOutfit(item)
|
||||
@scene.pbEndBuyScene
|
||||
return
|
||||
end
|
||||
next
|
||||
|
||||
end
|
||||
|
||||
itemname = @adapter.getDisplayName(item)
|
||||
price = @adapter.getPrice(item)
|
||||
|
||||
echoln price
|
||||
if !price.is_a?(Integer)
|
||||
#@adapter.switchVersion(item,1)
|
||||
pbDisplayPaused(_INTL("This is your current hairstyle!"))
|
||||
next
|
||||
end
|
||||
if @adapter.getMoney < price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
|
||||
if !pbConfirm(_INTL("Certainly. You want {1}. That will be ${2}. OK?",
|
||||
itemname, price.to_s_formatted))
|
||||
next
|
||||
end
|
||||
quantity = 1
|
||||
|
||||
if @adapter.getMoney < price
|
||||
pbDisplayPaused(_INTL("You don't have enough money."))
|
||||
next
|
||||
end
|
||||
added = 0
|
||||
|
||||
@adapter.setMoney(@adapter.getMoney - price)
|
||||
@stock.compact!
|
||||
pbDisplayPaused(_INTL("Here you are! Thank you!")) { pbSEPlay("Mart buy item") }
|
||||
@adapter.addItem(item)
|
||||
#break
|
||||
end
|
||||
@scene.pbEndBuyScene
|
||||
end
|
||||
|
||||
def isWornItem?(item)
|
||||
super
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,110 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class HatShopView < ClothesShopView
|
||||
|
||||
def initialize(currency_name = "Money")
|
||||
@currency_name = currency_name
|
||||
end
|
||||
|
||||
|
||||
def pbStartBuyOrSellScene(buying, stock, adapter)
|
||||
super(buying, stock, adapter)
|
||||
if !@adapter.isShop?
|
||||
@sprites["hatLayer_selected1"] = IconSprite.new(0, 0, @viewport)
|
||||
@sprites["hatLayer_selected2"] = IconSprite.new(0, 0, @viewport)
|
||||
|
||||
@sprites["hatLayer_selected1"].setBitmap("Graphics/Pictures/Outfits/hatLayer_selected1")
|
||||
@sprites["hatLayer_selected2"].setBitmap("Graphics/Pictures/Outfits/hatLayer_selected2")
|
||||
|
||||
updateSelectedLayerGraphicsVisibility
|
||||
|
||||
@sprites["wornHat_layer1"] = IconSprite.new(25, 200, @viewport)
|
||||
@sprites["wornHat_layer2"] = IconSprite.new(95, 200, @viewport)
|
||||
|
||||
displayLayerIcons
|
||||
end
|
||||
end
|
||||
|
||||
def switchItemVersion(itemwindow)
|
||||
@adapter.switchVersion(itemwindow.item, 1)
|
||||
new_selected_hat = @adapter.is_secondary_hat ? $Trainer.hat2 : $Trainer.hat
|
||||
select_specific_item(new_selected_hat,true)
|
||||
updateTrainerPreview()
|
||||
end
|
||||
|
||||
def onSpecialActionTrigger(itemwindow)
|
||||
#@adapter.doSpecialItemAction(itemwindow.item)
|
||||
#updateTrainerPreview()
|
||||
return @stock[itemwindow.index]
|
||||
end
|
||||
|
||||
def handleHatlessLayerIcons(selected_item)
|
||||
other_hat = @adapter.is_secondary_hat ? $Trainer.hat : $Trainer.hat2
|
||||
if !selected_item.is_a?(Hat)
|
||||
if @adapter.is_secondary_hat
|
||||
@sprites["wornHat_layer2"].bitmap=nil
|
||||
else
|
||||
@sprites["wornHat_layer1"].bitmap=nil
|
||||
end
|
||||
end
|
||||
if !other_hat.is_a?(Hat)
|
||||
if @adapter.is_secondary_hat
|
||||
@sprites["wornHat_layer1"].bitmap=nil
|
||||
else
|
||||
@sprites["wornHat_layer2"].bitmap=nil
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
def displayLayerIcons(selected_item=nil)
|
||||
handleHatlessLayerIcons(selected_item)
|
||||
|
||||
hat1Filename = getOverworldHatFilename($Trainer.hat)
|
||||
hat2Filename = getOverworldHatFilename($Trainer.hat2)
|
||||
|
||||
|
||||
hat_color_shift = $Trainer.dyed_hats[$Trainer.hat]
|
||||
hat2_color_shift = $Trainer.dyed_hats[$Trainer.hat2]
|
||||
|
||||
hatBitmapWrapper = AnimatedBitmap.new(hat1Filename, hat_color_shift) if pbResolveBitmap(hat1Filename)
|
||||
hat2BitmapWrapper = AnimatedBitmap.new(hat2Filename, hat2_color_shift) if pbResolveBitmap(hat2Filename)
|
||||
|
||||
@sprites["wornHat_layer1"].bitmap = hatBitmapWrapper.bitmap if hatBitmapWrapper
|
||||
@sprites["wornHat_layer2"].bitmap = hat2BitmapWrapper.bitmap if hat2BitmapWrapper
|
||||
|
||||
frame_width=80
|
||||
frame_height=80
|
||||
|
||||
@sprites["wornHat_layer1"].src_rect.set(0, 0, frame_width, frame_height) if hatBitmapWrapper
|
||||
@sprites["wornHat_layer2"].src_rect.set(0, 0, frame_width, frame_height) if hat2BitmapWrapper
|
||||
end
|
||||
|
||||
|
||||
def updateSelectedLayerGraphicsVisibility()
|
||||
@sprites["hatLayer_selected1"].visible = !@adapter.is_secondary_hat
|
||||
@sprites["hatLayer_selected2"].visible = @adapter.is_secondary_hat
|
||||
end
|
||||
|
||||
|
||||
def displayNewItem(itemwindow)
|
||||
item = itemwindow.item
|
||||
if item
|
||||
if item.is_a?(Symbol)
|
||||
description = @adapter.getSpecialItemDescription(itemwindow.item)
|
||||
else
|
||||
description = @adapter.getDescription(itemwindow.item)
|
||||
end
|
||||
@adapter.updateTrainerPreview(itemwindow.item, @sprites["trainerPreview"])
|
||||
displayLayerIcons(item)
|
||||
else
|
||||
description = _INTL("Quit.")
|
||||
end
|
||||
@sprites["itemtextwindow"].text = description
|
||||
end
|
||||
|
||||
def updateTrainerPreview()
|
||||
super
|
||||
updateSelectedLayerGraphicsVisibility
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,230 @@
|
||||
class HatsMartAdapter < OutfitsMartAdapter
|
||||
attr_accessor :worn_clothes
|
||||
attr_accessor :worn_clothes2
|
||||
|
||||
DEFAULT_NAME = "[unknown]"
|
||||
DEFAULT_DESCRIPTION = "A headgear that trainers can wear."
|
||||
|
||||
def initialize(stock = nil, isShop = nil, isSecondaryHat = false)
|
||||
super(stock,isShop,isSecondaryHat)
|
||||
@worn_clothes = $Trainer.hat
|
||||
@worn_clothes2 = $Trainer.hat2
|
||||
@second_hat_visible = true
|
||||
end
|
||||
|
||||
#Used in shops only
|
||||
def toggleSecondHat()
|
||||
@second_hat_visible = !@second_hat_visible
|
||||
$Trainer.hat2 = @second_hat_visible ? @worn_clothes2 : nil
|
||||
end
|
||||
|
||||
def toggleEvent(item)
|
||||
if isShop?
|
||||
toggleSecondHat
|
||||
else
|
||||
$Trainer.set_hat(nil,@is_secondary_hat)
|
||||
@worn_clothes = nil
|
||||
end
|
||||
end
|
||||
|
||||
def list_regional_set_items()
|
||||
return list_regional_hats
|
||||
end
|
||||
|
||||
def list_city_exclusive_items
|
||||
return list_city_exclusive_hats
|
||||
end
|
||||
|
||||
def set_secondary_hat(value)
|
||||
@is_secondary_hat = value
|
||||
end
|
||||
|
||||
def is_wearing_clothes(outfit_id)
|
||||
return outfit_id == @worn_clothes || outfit_id == @worn_clothes2
|
||||
end
|
||||
|
||||
def toggleText()
|
||||
return
|
||||
# return if @isShop
|
||||
# toggleKey = "D"#getMappedKeyFor(Input::SPECIAL)
|
||||
# return "Remove hat: #{toggleKey}"
|
||||
end
|
||||
|
||||
def switchVersion(item,delta=1)
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
return toggleSecondHat if isShop?
|
||||
@is_secondary_hat = !@is_secondary_hat
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
return item.id
|
||||
end
|
||||
|
||||
def getDescription(item)
|
||||
return DEFAULT_DESCRIPTION if !item.description
|
||||
return item.description
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return Settings::BACK_ITEM_ICON_PATH if !item
|
||||
return getOverworldHatFilename(item.id)
|
||||
end
|
||||
|
||||
def updateTrainerPreview(item, previewWindow)
|
||||
if item.is_a?(Outfit)
|
||||
hat1 = @is_secondary_hat ? get_hat_by_id($Trainer.hat) : item
|
||||
hat2 = @is_secondary_hat ? item : get_hat_by_id($Trainer.hat2)
|
||||
|
||||
previewWindow.set_hat(hat1.id,false) if hat1
|
||||
previewWindow.set_hat(hat2.id,true) if hat2
|
||||
previewWindow.set_hat(nil,true) if !@second_hat_visible #for toggling in shops
|
||||
|
||||
hat1_color=0
|
||||
hat2_color=0
|
||||
hat1_color = $Trainer.dyed_hats[hat1.id] if hat1 && $Trainer.dyed_hats.include?(hat1.id)
|
||||
hat2_color = $Trainer.dyed_hats[hat2.id] if hat2 && $Trainer.dyed_hats.include?(hat2.id)
|
||||
previewWindow.hat_color = hat1_color
|
||||
previewWindow.hat2_color = hat2_color
|
||||
|
||||
$Trainer.hat = hat1&.id
|
||||
$Trainer.hat2 = hat2&.id
|
||||
$Trainer.hat_color = hat1_color
|
||||
$Trainer.hat2_color = hat2_color
|
||||
|
||||
else
|
||||
$Trainer.set_hat(nil,@is_secondary_hat)
|
||||
previewWindow.set_hat(nil,@is_secondary_hat)
|
||||
end
|
||||
|
||||
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
|
||||
def get_dye_color(item_id)
|
||||
return if !item_id
|
||||
return 0 if isShop?
|
||||
$Trainer.dyed_hats= {} if ! $Trainer.dyed_hats
|
||||
if $Trainer.dyed_hats.include?(item_id)
|
||||
return $Trainer.dyed_hats[item_id]
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
def set_dye_color(item,previewWindow,is_secondary_hat=false)
|
||||
return if !item
|
||||
if !isShop?
|
||||
|
||||
else
|
||||
$Trainer.set_hat_color(0,is_secondary_hat)
|
||||
previewWindow.hat_color=0
|
||||
end
|
||||
end
|
||||
|
||||
# def set_dye_color(item,previewWindow,is_secondary_hat=false)
|
||||
# return if !item
|
||||
# if !isShop?
|
||||
# $Trainer.dyed_hats= {} if !$Trainer.dyed_hats
|
||||
#
|
||||
# echoln item.id
|
||||
# echoln $Trainer.dyed_hats.include?(item.id)
|
||||
# echoln $Trainer.dyed_hats[item.id]
|
||||
#
|
||||
# if $Trainer.dyed_hats.include?(item.id)
|
||||
# dye_color = $Trainer.dyed_hats[item.id]
|
||||
# $Trainer.set_hat_color(dye_color,is_secondary_hat)
|
||||
# previewWindow.hat_color = dye_color
|
||||
# else
|
||||
# $Trainer.set_hat_color(0,is_secondary_hat)
|
||||
# previewWindow.hat_color=0
|
||||
# end
|
||||
# #echoln $Trainer.dyed_hats
|
||||
# else
|
||||
# $Trainer.set_hat_color(0,is_secondary_hat)
|
||||
# previewWindow.hat_color=0
|
||||
# end
|
||||
# end
|
||||
|
||||
|
||||
def addItem(item)
|
||||
return unless item.is_a?(Outfit)
|
||||
changed_clothes = obtainHat(item.id,@is_secondary_hat)
|
||||
if changed_clothes
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_clothes()
|
||||
return $Trainer.hat(@is_secondary_hat)
|
||||
end
|
||||
|
||||
def player_changed_clothes?()
|
||||
echoln("Trainer hat: #{$Trainer.hat}, Worn hat: #{@worn_clothes}")
|
||||
echoln("Trainer hat2: #{$Trainer.hat2}, Worn hat2: #{@worn_clothes2}")
|
||||
$Trainer.hat != @worn_clothes || $Trainer.hat2 != @worn_clothes2
|
||||
end
|
||||
|
||||
def putOnSelectedOutfit()
|
||||
|
||||
putOnHat($Trainer.hat,true,false) if $Trainer.hat
|
||||
putOnHat($Trainer.hat2,true,true) if $Trainer.hat2
|
||||
|
||||
@worn_clothes = $Trainer.hat
|
||||
@worn_clothes2 = $Trainer.hat2
|
||||
|
||||
playOutfitChangeAnimation()
|
||||
pbMessage(_INTL("You put on the hat(s)!\\wtnp[30]"))
|
||||
end
|
||||
|
||||
def putOnOutfit(item)
|
||||
return unless item.is_a?(Outfit)
|
||||
putOnHat(item.id,false,@is_secondary_hat)
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
$Trainer.set_hat(@worn_clothes,false)
|
||||
$Trainer.set_hat(@worn_clothes2,true)
|
||||
|
||||
$Trainer.set_hat_color($Trainer.dyed_hats[@worn_clothes],false) if $Trainer.dyed_hats && $Trainer.dyed_hats[@worn_clothes]
|
||||
$Trainer.set_hat_color($Trainer.dyed_hats[@worn_clothes2],true) if $Trainer.dyed_hats && $Trainer.dyed_hats[@worn_clothes2]
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
return $Trainer.unlocked_hats
|
||||
end
|
||||
|
||||
def getSpecialItemCaption(specialType)
|
||||
case specialType
|
||||
when :REMOVE_HAT
|
||||
return "Remove hat"
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemBaseColor(specialType)
|
||||
case specialType
|
||||
when :REMOVE_HAT
|
||||
return MessageConfig::BLUE_TEXT_MAIN_COLOR
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemShadowColor(specialType)
|
||||
case specialType
|
||||
when :REMOVE_HAT
|
||||
return MessageConfig::BLUE_TEXT_SHADOW_COLOR
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
def getSpecialItemDescription(specialType)
|
||||
hair_situation = !$Trainer.hair || getSimplifiedHairIdFromFullID($Trainer.hair) == HAIR_BALD ? "bald head" : "fabulous hair"
|
||||
return "Go without a hat and show off your #{hair_situation}!"
|
||||
end
|
||||
|
||||
def doSpecialItemAction(specialType,item=nil)
|
||||
toggleEvent(item)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,160 @@
|
||||
class HairStyleSelectionMenuView
|
||||
attr_accessor :name_sprite
|
||||
attr_accessor :viewport
|
||||
attr_accessor :sprites
|
||||
attr_accessor :textValues
|
||||
|
||||
|
||||
OPTIONS_START_Y = 66
|
||||
CURSOR_Y_MARGIN = 50
|
||||
CURSOR_X_MARGIN = 76
|
||||
|
||||
CHECKMARK_Y_MARGIN = 20
|
||||
CHECKMARK_WIDTH = 50
|
||||
|
||||
OPTIONS_LABEL_X = 50
|
||||
|
||||
|
||||
OPTIONS_LABEL_WIDTH = 100
|
||||
|
||||
OPTIONS_VALUE_X = 194
|
||||
SELECTOR_X = 120
|
||||
SELECTOR_STAGGER_OFFSET=26
|
||||
|
||||
|
||||
ARROW_LEFT_X_POSITION = 75
|
||||
ARROW_RIGHT_X_POSITION = 275
|
||||
ARROWS_Y_OFFSET = 10#20
|
||||
|
||||
CONFIRM_X = 296
|
||||
CONFIRM_Y= 322
|
||||
|
||||
STAGGER_OFFSET_1 = 26
|
||||
STAGGER_OFFSET_2 = 50
|
||||
|
||||
|
||||
|
||||
def initialize
|
||||
@presenter = HairstyleSelectionMenuPresenter.new(self)
|
||||
@viewport = Viewport.new(0, 0, Graphics.width, Graphics.height)
|
||||
@sprites = {}
|
||||
@textValues={}
|
||||
@max_index=5
|
||||
end
|
||||
|
||||
def init_graphics()
|
||||
@sprites["bg"] = IconSprite.new(@viewport)
|
||||
#@sprites["bg"].setBitmap("Graphics/Pictures/trainer_application_form")
|
||||
@sprites["bg"].setBitmap("")
|
||||
|
||||
|
||||
@sprites["select"] = IconSprite.new(@viewport)
|
||||
@sprites["select"].setBitmap("Graphics/Pictures/cc_selection_box")
|
||||
@sprites["select"].x = get_cursor_x_position(0)#OPTIONS_LABEL_X + OPTIONS_LABEL_WIDTH + CURSOR_X_MARGIN
|
||||
@sprites["select"].y = OPTIONS_START_Y
|
||||
@sprites["select"].visible = true
|
||||
|
||||
@sprites["leftarrow"] = AnimatedSprite.new("Graphics/Pictures/leftarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["leftarrow"].x = ARROW_LEFT_X_POSITION
|
||||
@sprites["leftarrow"].y = 0
|
||||
@sprites["leftarrow"].visible = false
|
||||
@sprites["leftarrow"].play
|
||||
|
||||
|
||||
@sprites["rightarrow"] = AnimatedSprite.new("Graphics/Pictures/rightarrow", 8, 40, 28, 2, @viewport)
|
||||
@sprites["rightarrow"].x = ARROW_RIGHT_X_POSITION
|
||||
@sprites["rightarrow"].y = 0
|
||||
@sprites["rightarrow"].visible = false
|
||||
@sprites["rightarrow"].play
|
||||
end
|
||||
|
||||
def setMaxIndex(maxIndex)
|
||||
@max_index=maxIndex
|
||||
end
|
||||
|
||||
def init_labels()
|
||||
Kernel.pbDisplayText("Confirm", (CONFIRM_X+CURSOR_X_MARGIN), CONFIRM_Y)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def start
|
||||
init_graphics()
|
||||
init_labels()
|
||||
@presenter.main()
|
||||
end
|
||||
|
||||
def get_cursor_y_position(index)
|
||||
return CONFIRM_Y if index == @max_index
|
||||
return index * CURSOR_Y_MARGIN + OPTIONS_START_Y
|
||||
end
|
||||
|
||||
def get_cursor_x_position(index)
|
||||
return CONFIRM_X if index == @max_index
|
||||
return SELECTOR_X + getTextBoxStaggerOffset(index)
|
||||
end
|
||||
|
||||
def get_value_x_position(index)
|
||||
return (OPTIONS_VALUE_X + getTextBoxStaggerOffset(index))
|
||||
end
|
||||
|
||||
def getTextBoxStaggerOffset(index)
|
||||
case index
|
||||
when 1
|
||||
return STAGGER_OFFSET_1
|
||||
when 2
|
||||
return STAGGER_OFFSET_2
|
||||
when 3
|
||||
return STAGGER_OFFSET_1
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
def showSideArrows(y_index)
|
||||
y_position = get_cursor_y_position(y_index)
|
||||
|
||||
@sprites["rightarrow"].y=y_position+ARROWS_Y_OFFSET
|
||||
@sprites["leftarrow"].y=y_position+ARROWS_Y_OFFSET
|
||||
|
||||
@sprites["leftarrow"].x=getTextBoxStaggerOffset(y_index)+ARROW_LEFT_X_POSITION
|
||||
@sprites["rightarrow"].x= getTextBoxStaggerOffset(y_index)+ARROW_RIGHT_X_POSITION
|
||||
|
||||
@sprites["rightarrow"].visible=true
|
||||
@sprites["leftarrow"].visible=true
|
||||
end
|
||||
|
||||
def hideSideArrows()
|
||||
@sprites["rightarrow"].visible=false
|
||||
@sprites["leftarrow"].visible=false
|
||||
end
|
||||
|
||||
def displayText(spriteId,text,y_index)
|
||||
@textValues[spriteId].dispose if @textValues[spriteId]
|
||||
yposition = get_cursor_y_position(y_index)
|
||||
xposition = get_value_x_position(y_index)
|
||||
|
||||
baseColor= baseColor ? baseColor : Color.new(72,72,72)
|
||||
shadowColor= shadowColor ? shadowColor : Color.new(160,160,160)
|
||||
@textValues[spriteId] = BitmapSprite.new(Graphics.width,Graphics.height,@viewport)
|
||||
text1=_INTL(text)
|
||||
textPosition=[
|
||||
[text1,xposition,yposition,2,baseColor,shadowColor],
|
||||
]
|
||||
pbSetSystemFont(@textValues[spriteId].bitmap)
|
||||
pbDrawTextPositions(@textValues[spriteId].bitmap,textPosition)
|
||||
|
||||
end
|
||||
|
||||
|
||||
def updateGraphics()
|
||||
Graphics.update
|
||||
Input.update
|
||||
if @sprites
|
||||
@sprites["rightarrow"].update
|
||||
@sprites["leftarrow"].update
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,187 @@
|
||||
class HairstyleSelectionMenuPresenter
|
||||
attr_accessor :options
|
||||
attr_reader :current_index
|
||||
|
||||
OPTION_STYLE = 'Hairstyle'
|
||||
OPTION_BASE_COLOR = "Base color"
|
||||
OPTION_DYE = "Dye"
|
||||
|
||||
HAIR_COLOR_NAMES = ["Blonde", "Light Brown", "Dark Brown", "Black"]
|
||||
HAIR_COLOR_IDS = [1, 2, 3, 4]
|
||||
|
||||
#ids for displayed text sprites
|
||||
STYLE_TEXT_ID = "style"
|
||||
BASECOLOR_TEXT_ID = "baseCplor"
|
||||
DYE_TEXT_ID = "dye"
|
||||
|
||||
def initialize(view)
|
||||
@view = view
|
||||
@hairstyle_full_id = $Trainer.hair
|
||||
|
||||
hairstyle_split = getSplitHairFilenameAndVersionFromID(@hairstyle_full_id)
|
||||
@hairstyle = hairstyle_split[0] if hairstyle_split[0]
|
||||
@hair_version = hairstyle_split[1] if hairstyle_split[1]
|
||||
@hairColor = $Trainer.hair_color
|
||||
|
||||
@available_styles= $Trainer.unlocked_hairstyles
|
||||
@selected_hairstyle_index = 0
|
||||
|
||||
echoln @available_styles
|
||||
|
||||
@options = [OPTION_STYLE, OPTION_BASE_COLOR, OPTION_DYE]
|
||||
|
||||
@trainerPreview = TrainerClothesPreview.new(300, 80, false)
|
||||
@trainerPreview.show()
|
||||
@closed = false
|
||||
@current_index = 0
|
||||
@view.setMaxIndex(@options.length - 1)
|
||||
end
|
||||
|
||||
def main()
|
||||
pbSEPlay("GUI naming tab swap start", 80, 100)
|
||||
@current_index = 0
|
||||
loop do
|
||||
@view.updateGraphics()
|
||||
if Input.trigger?(Input::DOWN)
|
||||
@current_index = move_menu_vertical(1)
|
||||
elsif Input.trigger?(Input::UP)
|
||||
@current_index = move_menu_vertical(-1)
|
||||
elsif Input.trigger?(Input::RIGHT)
|
||||
move_menu_horizontal(@current_index, 1)
|
||||
elsif Input.trigger?(Input::LEFT)
|
||||
move_menu_horizontal(@current_index, -1)
|
||||
elsif Input.trigger?(Input::ACTION) || Input.trigger?(Input::USE)
|
||||
action_button_pressed(@current_index)
|
||||
end
|
||||
break if @closed
|
||||
end
|
||||
end
|
||||
|
||||
def updateTrainerPreview
|
||||
@trainerPreview.resetOutfits
|
||||
@trainerPreview.updatePreview
|
||||
end
|
||||
|
||||
def action_button_pressed(current_index)
|
||||
pbSEPlay("GUI save choice", 80, 100)
|
||||
@current_index = @options.length - 1
|
||||
update_cursor(@current_index)
|
||||
end
|
||||
|
||||
def getDefaultName()
|
||||
return DEFAULT_NAMES[@gender]
|
||||
end
|
||||
|
||||
|
||||
def applyAllSelectedValues
|
||||
$Trainer.hair = getFullHairId(@hairstyle,@hair_version)
|
||||
$Trainer.hair_color = @hairColor
|
||||
end
|
||||
|
||||
def getOptionIndex(option_name)
|
||||
i = 0
|
||||
for option in @options
|
||||
return i if option == option_name
|
||||
i += 1
|
||||
end
|
||||
return -1
|
||||
end
|
||||
|
||||
#VERTICAL NAVIGATION
|
||||
|
||||
def move_menu_vertical(offset)
|
||||
pbSEPlay("GUI sel decision", 80, 100)
|
||||
@current_index += offset
|
||||
@current_index = 0 if @current_index > @options.length - 1
|
||||
@current_index = @options.length - 1 if @current_index <= -1
|
||||
|
||||
update_cursor(@current_index)
|
||||
return @current_index
|
||||
end
|
||||
|
||||
def update_cursor(index)
|
||||
@view.sprites["select"].y = @view.get_cursor_y_position(index)
|
||||
@view.sprites["select"].x = @view.get_cursor_x_position(index)
|
||||
|
||||
set_custom_cursor(index)
|
||||
end
|
||||
|
||||
def close_menu
|
||||
@trainerPreview.erase()
|
||||
Kernel.pbClearNumber()
|
||||
Kernel.pbClearText()
|
||||
pbDisposeSpriteHash(@view.sprites)
|
||||
pbDisposeSpriteHash(@view.textValues)
|
||||
@closed = true
|
||||
end
|
||||
|
||||
def set_custom_cursor(index)
|
||||
# selected_option = @options[index]
|
||||
# case selected_option
|
||||
# when OPTION_GENDER
|
||||
# @view.showSideArrows(index)
|
||||
# when OPTION_AGE
|
||||
# @view.showSideArrows(index)
|
||||
# when OPTION_HAIR
|
||||
# @view.showSideArrows(index)
|
||||
# when OPTION_SKIN
|
||||
# @view.showSideArrows(index)
|
||||
# else
|
||||
# @view.hideSideArrows
|
||||
# end
|
||||
end
|
||||
|
||||
#HORIZONTAL NAVIGATION
|
||||
def move_menu_horizontal(current_index, incr)
|
||||
pbSEPlay("GUI sel cursor", 80, 100)
|
||||
selected_option = @options[current_index]
|
||||
case selected_option
|
||||
when OPTION_STYLE then
|
||||
setHairstyle(@selected_hairstyle_index,incr)
|
||||
end
|
||||
|
||||
# case selected_option
|
||||
# when OPTION_GENDER then
|
||||
# setGender(current_index, incr)
|
||||
# when OPTION_HAIR then
|
||||
# setHairColor(current_index, incr)
|
||||
# when OPTION_SKIN then
|
||||
# setSkinColor(current_index, incr)
|
||||
# when OPTION_AGE then
|
||||
# setAge(current_index, incr)
|
||||
# end
|
||||
updateTrainerPreview()
|
||||
end
|
||||
|
||||
|
||||
|
||||
def setHairstyle(current_index, incr)
|
||||
@selected_hairstyle_index += incr
|
||||
@selected_hairstyle_index = 0 if @selected_hairstyle_index > @available_styles.length
|
||||
@selected_hairstyle_index = @available_styles.length-1 if @selected_hairstyle_index < 0
|
||||
|
||||
@hairstyle = @available_styles[@selected_hairstyle_index]
|
||||
|
||||
applyHair()
|
||||
echoln @hairstyle
|
||||
echoln "hairstyle: #{@hairstyle}, full list: #{@available_styles}, index: #{current_index}"
|
||||
|
||||
@view.displayText(STYLE_TEXT_ID, @hairstyle, @selected_hairstyle_index)
|
||||
end
|
||||
|
||||
def setBaseColor(current_index, incr)
|
||||
max_id = HAIR_COLOR_IDS.length - 1
|
||||
@hairColor += incr
|
||||
@hairColor = 0 if @hairColor > max_id
|
||||
@hairColor = max_id if @hairColor <= -1
|
||||
applyHair()
|
||||
@view.displayText(BASECOLOR_TEXT_ID, HAIR_COLOR_NAMES[@hairColor], current_index)
|
||||
end
|
||||
|
||||
def applyHair()
|
||||
hairstyle = @hairstyle
|
||||
hair_version =@hair_version
|
||||
hairId = getFullHairId(hairstyle,hair_version)
|
||||
$Trainer.hair = hairId
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,126 @@
|
||||
#Naked sprites
|
||||
BASE_FOLDER = "base"
|
||||
BASE_OVERWORLD_FOLDER = "overworld"
|
||||
BASE_TRAINER_FOLDER = "trainer"
|
||||
|
||||
def getBaseOverworldSpriteFilename(action = "walk", skinTone = "default")
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + BASE_FOLDER + "/" + BASE_OVERWORLD_FOLDER
|
||||
dynamic_path = _INTL("/{1}/{2}_{1}", skinTone, action)
|
||||
full_path = base_path + dynamic_path
|
||||
return full_path if pbResolveBitmap(full_path)
|
||||
return getBaseOverworldSpriteFilename(action) if skinTone != "default" #try again with default skintone
|
||||
return nil
|
||||
end
|
||||
|
||||
def getBaseTrainerSpriteFilename(skinTone = "default")
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + BASE_FOLDER + "/" + BASE_TRAINER_FOLDER
|
||||
dynamic_path = _INTL("/{1}_{2}", BASE_TRAINER_FOLDER, skinTone)
|
||||
full_path = base_path + dynamic_path
|
||||
return full_path if pbResolveBitmap(full_path)
|
||||
return getBaseTrainerSpriteFilename() #default skintone
|
||||
end
|
||||
|
||||
### OUTFIT #
|
||||
|
||||
def get_clothes_sets_list_path()
|
||||
return Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_CLOTHES_FOLDER
|
||||
end
|
||||
|
||||
def getOverworldOutfitFilename(outfit_id, action="walk")
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_CLOTHES_FOLDER
|
||||
dynamic_path = _INTL("/{1}/", outfit_id)
|
||||
filename = _INTL(Settings::PLAYER_CLOTHES_FOLDER + "_{1}_{2}", action, outfit_id)
|
||||
full_path = base_path + dynamic_path + filename
|
||||
#echoln full_path
|
||||
return full_path
|
||||
end
|
||||
|
||||
def getTrainerSpriteOutfitFilename(outfit_id)
|
||||
return getOverworldOutfitFilename(outfit_id, BASE_TRAINER_FOLDER)
|
||||
end
|
||||
|
||||
#### HAIR
|
||||
|
||||
def get_hair_sets_list_path()
|
||||
return Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER
|
||||
end
|
||||
|
||||
|
||||
def getSimplifiedHairIdFromFullID(full_id)
|
||||
split_id = getSplitHairFilenameAndVersionFromID(full_id)
|
||||
return split_id[1] if split_id.length > 1
|
||||
return ""
|
||||
end
|
||||
|
||||
def getVersionFromFullID(full_id)
|
||||
split_id = getSplitHairFilenameAndVersionFromID(full_id)
|
||||
return split_id[0]
|
||||
end
|
||||
|
||||
# Input: 1_red
|
||||
# Output: ["1","red"]
|
||||
def getSplitHairFilenameAndVersionFromID(hairstyle_id)
|
||||
return "" if !hairstyle_id
|
||||
hairstyle_id= hairstyle_id.to_s
|
||||
return hairstyle_id.split("_")
|
||||
end
|
||||
|
||||
def getFullHairId(hairstyle,version)
|
||||
return _INTL("{1}_{2}",version,hairstyle)
|
||||
|
||||
end
|
||||
|
||||
def getOverworldHairFilename(hairstyle_id)
|
||||
hairstyle_split = getSplitHairFilenameAndVersionFromID(hairstyle_id)
|
||||
name= hairstyle_split[-1]
|
||||
version= hairstyle_split[-2]
|
||||
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER
|
||||
dynamic_path = _INTL("/{1}/", name)
|
||||
filename = _INTL(Settings::PLAYER_HAIR_FOLDER + "_{1}_{2}",version, name)
|
||||
full_path = base_path + dynamic_path + filename
|
||||
return full_path
|
||||
end
|
||||
|
||||
def getTrainerSpriteHairFilename(hairstyle_id)
|
||||
return "" if !hairstyle_id
|
||||
hairstyle_id= hairstyle_id.to_s
|
||||
hairstyle_split= hairstyle_id.split("_")
|
||||
name= hairstyle_split[-1]
|
||||
version= hairstyle_split[-2]
|
||||
|
||||
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER
|
||||
dynamic_path = _INTL("/{1}/", name)
|
||||
filename = _INTL(Settings::PLAYER_HAIR_FOLDER + "_trainer_{1}_{2}",version, name)
|
||||
full_path = base_path + dynamic_path + filename
|
||||
return full_path
|
||||
end
|
||||
|
||||
#### HATS
|
||||
#
|
||||
def get_hats_sets_list_path()
|
||||
return Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER
|
||||
end
|
||||
|
||||
def getOverworldHatFilename(hat_id)
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER
|
||||
dynamic_path = _INTL("/{1}/", hat_id)
|
||||
filename = _INTL(Settings::PLAYER_HAT_FOLDER + "_{1}", hat_id)
|
||||
full_path = base_path + dynamic_path + filename
|
||||
return full_path
|
||||
end
|
||||
|
||||
def getTrainerSpriteHatFilename(hat_id)
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER
|
||||
dynamic_path = _INTL("/{1}/", hat_id)
|
||||
filename = _INTL(Settings::PLAYER_HAT_FOLDER + "_trainer_{1}", hat_id)
|
||||
full_path = base_path + dynamic_path + filename
|
||||
return full_path
|
||||
end
|
||||
|
||||
def getTrainerSpriteBallFilename(pokeball)
|
||||
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_BALL_FOLDER
|
||||
|
||||
return base_path + "/" + pokeball.to_s
|
||||
end
|
||||
@@ -0,0 +1,412 @@
|
||||
def obtainNewHat(outfit_id)
|
||||
return obtainHat(outfit_id)
|
||||
end
|
||||
|
||||
def obtainNewClothes(outfit_id)
|
||||
return obtainClothes(outfit_id)
|
||||
end
|
||||
|
||||
def obtainHat(outfit_id,secondary=false)
|
||||
echoln "obtained new hat: " + outfit_id
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
if !outfit
|
||||
pbMessage(_INTL("The hat #{outfit_id} is invalid."))
|
||||
return
|
||||
end
|
||||
$Trainer.unlocked_hats << outfit_id if !$Trainer.unlocked_hats.include?(outfit_id)
|
||||
obtainOutfitMessage(outfit)
|
||||
if pbConfirmMessage("Would you like to put it on right now?")
|
||||
putOnHat(outfit_id, false, false) if !secondary
|
||||
putOnHat(outfit_id, false, true) if secondary
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def obtainClothes(outfit_id)
|
||||
echoln "obtained new clothes: " + outfit_id
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
if !outfit
|
||||
pbMessage(_INTL("The clothes #{outfit_id} are invalid."))
|
||||
return
|
||||
end
|
||||
return if !outfit
|
||||
$Trainer.unlocked_clothes << outfit_id if !$Trainer.unlocked_clothes.include?(outfit_id)
|
||||
obtainOutfitMessage(outfit)
|
||||
if pbConfirmMessage("Would you like to put it on right now?")
|
||||
putOnClothes(outfit_id)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def obtainNewHairstyle(full_outfit_id)
|
||||
split_outfit_id = getSplitHairFilenameAndVersionFromID(full_outfit_id)
|
||||
hairstyle_id = split_outfit_id[1]
|
||||
hairstyle = get_hair_by_id(hairstyle_id)
|
||||
musical_effect = "Key item get"
|
||||
pbMessage(_INTL("\\me[{1}]Your hairstyle was changed to \\c[1]{2}\\c[0] hairstyle!\\wtnp[30]", musical_effect, hairstyle.name))
|
||||
return true
|
||||
end
|
||||
|
||||
def putOnClothes(outfit_id, silent = false)
|
||||
$Trainer.dyed_clothes= {} if ! $Trainer.dyed_clothes
|
||||
$Trainer.last_worn_outfit = $Trainer.clothes
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
$Trainer.clothes = outfit_id
|
||||
|
||||
dye_color = $Trainer.dyed_clothes[outfit_id]
|
||||
if dye_color
|
||||
$Trainer.clothes_color = dye_color
|
||||
else
|
||||
$Trainer.clothes_color = nil
|
||||
end
|
||||
|
||||
$game_map.update
|
||||
refreshPlayerOutfit()
|
||||
putOnOutfitMessage(outfit) if !silent
|
||||
end
|
||||
|
||||
def putOnHat(outfit_id, silent = false, is_secondary=false)
|
||||
$Trainer.dyed_hats= {} if ! $Trainer.dyed_hats
|
||||
$Trainer.set_last_worn_hat($Trainer.hat,is_secondary)
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
|
||||
$Trainer.set_hat(outfit_id,is_secondary)
|
||||
|
||||
dye_color = $Trainer.dyed_hats[outfit_id]
|
||||
if dye_color
|
||||
$Trainer.hat_color = dye_color if !is_secondary
|
||||
$Trainer.hat2_color = dye_color if is_secondary
|
||||
else
|
||||
$Trainer.hat_color = nil if !is_secondary
|
||||
$Trainer.hat2_color = nil if is_secondary
|
||||
end
|
||||
|
||||
$game_map.refreshPlayerOutfit()
|
||||
putOnOutfitMessage(outfit) if !silent
|
||||
end
|
||||
|
||||
|
||||
def putOnHairFullId(full_outfit_id)
|
||||
outfit_id = getSplitHairFilenameAndVersionFromID(full_outfit_id)[1]
|
||||
outfit = get_hair_by_id(outfit_id)
|
||||
$Trainer.hair = full_outfit_id
|
||||
$game_map.update
|
||||
refreshPlayerOutfit()
|
||||
putOnOutfitMessage(outfit)
|
||||
end
|
||||
|
||||
def putOnHair(outfit_id, version)
|
||||
full_id = getFullHairId(outfit_id, version)
|
||||
putOnHairFullId(full_id)
|
||||
#outfit = get_hair_by_id(outfit_id)
|
||||
#$Trainer.hair =
|
||||
#putOnOutfitMessage(outfit)
|
||||
end
|
||||
|
||||
def showOutfitPicture(outfit)
|
||||
begin
|
||||
outfitPath = outfit.trainer_sprite_path()
|
||||
|
||||
viewport = Viewport.new(Graphics.width / 4, 0, Graphics.width / 2, Graphics.height)
|
||||
bg_sprite = Sprite.new(viewport)
|
||||
outfit_sprite = Sprite.new(viewport)
|
||||
outfit_bitmap = AnimatedBitmap.new(outfitPath) if pbResolveBitmap(outfitPath)
|
||||
bg_bitmap = AnimatedBitmap.new("Graphics/Pictures/Outfits/obtain_bg")
|
||||
|
||||
outfit_sprite.bitmap = outfit_bitmap.bitmap
|
||||
bg_sprite.bitmap = bg_bitmap.bitmap
|
||||
|
||||
# bitmap = AnimatedBitmap.new("Graphics/Pictures/Outfits/obtain_bg")
|
||||
outfit_sprite.x = -50
|
||||
outfit_sprite.y = 50
|
||||
outfit_sprite.y -= 120 if outfit.type == :CLOTHES
|
||||
|
||||
# outfit_sprite.y = Graphics.height/2
|
||||
outfit_sprite.zoom_x = 2
|
||||
outfit_sprite.zoom_y = 2
|
||||
|
||||
bg_sprite.x = 0
|
||||
|
||||
viewport.z = 99999
|
||||
# bg_sprite.y = Graphics.height/2
|
||||
|
||||
return viewport
|
||||
rescue
|
||||
#ignore
|
||||
end
|
||||
end
|
||||
|
||||
def obtainOutfitMessage(outfit)
|
||||
pictureViewport = showOutfitPicture(outfit)
|
||||
musical_effect = "Key item get"
|
||||
pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]", musical_effect, outfit.name))
|
||||
pictureViewport.dispose if pictureViewport
|
||||
end
|
||||
|
||||
def putOnOutfitMessage(outfit)
|
||||
playOutfitChangeAnimation()
|
||||
outfitName = outfit.name == "" ? outfit.id : outfit.name
|
||||
pbMessage(_INTL("You put on the \\c[1]{1}\\c[0]!\\wtnp[30]", outfitName))
|
||||
end
|
||||
|
||||
def refreshPlayerOutfit()
|
||||
return if !$scene.spritesetGlobal
|
||||
$scene.spritesetGlobal.playersprite.refreshOutfit()
|
||||
end
|
||||
|
||||
def findLastHairVersion(hairId)
|
||||
possible_versions = (1..9).to_a
|
||||
last_version = 0
|
||||
possible_versions.each { |version|
|
||||
hair_id = getFullHairId(hairId, version)
|
||||
echoln hair_id
|
||||
echoln pbResolveBitmap(getOverworldHairFilename(hair_id))
|
||||
if pbResolveBitmap(getOverworldHairFilename(hair_id))
|
||||
last_version = version
|
||||
else
|
||||
return last_version
|
||||
end
|
||||
}
|
||||
return last_version
|
||||
end
|
||||
|
||||
def isWearingClothes(outfitId)
|
||||
return $Trainer.clothes == outfitId
|
||||
end
|
||||
|
||||
def isWearingHat(outfitId)
|
||||
return $Trainer.hat == outfitId || $Trainer.hat2 == outfitId
|
||||
end
|
||||
|
||||
def isWearingHairstyle(outfitId, version = nil)
|
||||
current_hair_split_id = getSplitHairFilenameAndVersionFromID($Trainer.hair)
|
||||
current_id = current_hair_split_id.length >= 1 ? current_hair_split_id[1] : nil
|
||||
current_version = current_hair_split_id[0]
|
||||
if version
|
||||
return outfitId == current_id && version == current_version
|
||||
end
|
||||
return outfitId == current_id
|
||||
end
|
||||
|
||||
#Some game switches need to be on/off depending on the outfit that the player is wearing,
|
||||
# this is called every time you change outfit to make sure that they're always updated correctly
|
||||
def updateOutfitSwitches(refresh_map = true)
|
||||
$game_switches[WEARING_ROCKET_OUTFIT] = isWearingTeamRocketOutfit()
|
||||
#$game_map.update
|
||||
|
||||
#$scene.reset_map(true) if refresh_map
|
||||
#$scene.reset_map(false)
|
||||
end
|
||||
|
||||
def getDefaultClothes()
|
||||
gender = pbGet(VAR_TRAINER_GENDER)
|
||||
if gender == GENDER_MALE
|
||||
return DEFAULT_OUTFIT_MALE
|
||||
end
|
||||
return DEFAULT_OUTFIT_FEMALE
|
||||
end
|
||||
|
||||
def hasClothes?(outfit_id)
|
||||
return $Trainer.unlocked_clothes.include?(outfit_id)
|
||||
end
|
||||
|
||||
def hasHat?(outfit_id)
|
||||
return $Trainer.unlocked_hats.include?(outfit_id)
|
||||
end
|
||||
|
||||
def getOutfitForPokemon(pokemonSpecies)
|
||||
possible_clothes = []
|
||||
possible_hats = []
|
||||
|
||||
body_pokemon_id = get_body_species_from_symbol(pokemonSpecies).to_s.downcase
|
||||
head_pokemon_id = get_head_species_from_symbol(pokemonSpecies).to_s.downcase
|
||||
body_pokemon_tag = "pokemon-#{body_pokemon_id}"
|
||||
head_pokemon_tag = "pokemon-#{head_pokemon_id}"
|
||||
|
||||
possible_hats += search_hats([body_pokemon_tag])
|
||||
possible_hats += search_hats([head_pokemon_tag])
|
||||
possible_clothes += search_clothes([body_pokemon_tag])
|
||||
possible_clothes += search_clothes([head_pokemon_tag])
|
||||
|
||||
if isFusion(getDexNumberForSpecies(pokemonSpecies))
|
||||
possible_hats += search_hats(["pokemon-fused"], [], false)
|
||||
possible_clothes += search_clothes(["pokemon-fused"], false)
|
||||
end
|
||||
|
||||
possible_hats = filter_hats_only_not_owned(possible_hats)
|
||||
possible_clothes = filter_clothes_only_not_owned(possible_clothes)
|
||||
|
||||
if !possible_hats.empty?() && !possible_clothes.empty?() #both have values, pick one at random
|
||||
return [[possible_hats.sample, :HAT], [possible_clothes.sample, :CLOTHES]].sample
|
||||
elsif !possible_hats.empty?
|
||||
return [possible_hats.sample, :HAT]
|
||||
elsif !possible_clothes.empty?
|
||||
return [possible_clothes.sample, :CLOTHES]
|
||||
end
|
||||
return []
|
||||
end
|
||||
|
||||
def hatUnlocked?(hatId)
|
||||
return $Trainer.unlocked_hats.include?(hatId)
|
||||
end
|
||||
|
||||
def export_current_outfit()
|
||||
skinTone = $Trainer.skin_tone ? $Trainer.skin_tone : 0
|
||||
hat = $Trainer.hat ? $Trainer.hat : "nil"
|
||||
hair_color = $Trainer.hair_color || 0
|
||||
clothes_color = $Trainer.clothes_color || 0
|
||||
hat_color = $Trainer.hat_color || 0
|
||||
exportedString = "TrainerAppearance.new(#{skinTone},\"#{hat}\",\"#{$Trainer.clothes}\",\"#{$Trainer.hair}\",#{hair_color},#{clothes_color},#{hat_color})"
|
||||
Input.clipboard = exportedString
|
||||
end
|
||||
|
||||
def clearEventCustomAppearance(event_id)
|
||||
return if !$scene.is_a?(Scene_Map)
|
||||
event_sprite = $scene.spriteset.character_sprites[@event_id]
|
||||
for sprite in $scene.spriteset.character_sprites
|
||||
if sprite.character.id == event_id
|
||||
event_sprite = sprite
|
||||
end
|
||||
end
|
||||
return if !event_sprite
|
||||
event_sprite.clearBitmapOverride
|
||||
end
|
||||
|
||||
def setEventAppearance(event_id, trainerAppearance)
|
||||
return if !$scene.is_a?(Scene_Map)
|
||||
event_sprite = $scene.spriteset.character_sprites[@event_id]
|
||||
for sprite in $scene.spriteset.character_sprites
|
||||
if sprite.character.id == event_id
|
||||
event_sprite = sprite
|
||||
end
|
||||
end
|
||||
return if !event_sprite
|
||||
event_sprite.setSpriteToAppearance(trainerAppearance)
|
||||
end
|
||||
|
||||
def getPlayerAppearance()
|
||||
return TrainerAppearance.new($Trainer.skin_tone,$Trainer.hat,$Trainer.clothes, $Trainer.hair,
|
||||
$Trainer.hair_color, $Trainer.clothes_color, $Trainer.hat_color)
|
||||
end
|
||||
|
||||
def randomizePlayerOutfitUnlocked()
|
||||
$Trainer.hat = $Trainer.unlocked_hats.sample
|
||||
$Trainer.hat2 = $Trainer.unlocked_hats.sample
|
||||
$Trainer.clothes = $Trainer.unlocked_clothes.sample
|
||||
|
||||
dye_hat = rand(2)==0
|
||||
dye_hat2 = rand(2)==0
|
||||
dye_clothes = rand(2)==0
|
||||
dye_hair = rand(2)==0
|
||||
$Trainer.hat2 = nil if rand(3)==0
|
||||
|
||||
$Trainer.hat_color = dye_hat ? rand(255) : 0
|
||||
$Trainer.hat2_color = dye_hat2 ? rand(255) : 0
|
||||
|
||||
$Trainer.clothes_color = dye_clothes ? rand(255) : 0
|
||||
$Trainer.hair_color = dye_hair ? rand(255) : 0
|
||||
|
||||
hair_id = $PokemonGlobal.hairstyles_data.keys.sample
|
||||
hair_color = [1,2,3,4].sample
|
||||
$Trainer.hair = getFullHairId(hair_id,hair_color)
|
||||
|
||||
end
|
||||
|
||||
def convert_letter_to_number(letter, max_number = nil)
|
||||
return 0 unless letter
|
||||
base_value = (letter.ord * 31) & 0xFFFFFFFF # Use a prime multiplier to spread values
|
||||
return base_value unless max_number
|
||||
return base_value % max_number
|
||||
end
|
||||
|
||||
|
||||
def generate_appearance_from_name(name)
|
||||
name_seed_length = 13
|
||||
max_dye_color=360
|
||||
|
||||
seed = name[0, name_seed_length] # Truncate if longer than 8
|
||||
seed += seed[0, name_seed_length - seed.length] while seed.length < name_seed_length # Repeat first characters if shorter
|
||||
|
||||
echoln seed
|
||||
|
||||
hats_list = $PokemonGlobal.hats_data.keys
|
||||
clothes_list = $PokemonGlobal.clothes_data.keys
|
||||
hairstyles_list = $PokemonGlobal.hairstyles_data.keys
|
||||
|
||||
hat = hats_list[convert_letter_to_number(seed[0],hats_list.length)]
|
||||
hat_color = convert_letter_to_number(seed[1],max_dye_color)
|
||||
hat2_color = convert_letter_to_number(seed[2],max_dye_color)
|
||||
hat_color = 0 if convert_letter_to_number(seed[2]) % 2 == 0 #1/2 chance of no dyed hat
|
||||
|
||||
hat2 = hats_list[convert_letter_to_number(seed[10],hats_list.length)]
|
||||
hat2_color = 0 if convert_letter_to_number(seed[11]) % 2 == 0 #1/2 chance of no dyed ha
|
||||
hat2 = "" if convert_letter_to_number(seed[12]) % 2 == 0 #1/2 chance of no 2nd hat
|
||||
|
||||
clothes = clothes_list[convert_letter_to_number(seed[3],clothes_list.length)]
|
||||
clothes_color = convert_letter_to_number(seed[4],max_dye_color)
|
||||
clothes_color = 0 if convert_letter_to_number(seed[5]) % 2 == 0 #1/2 chance of no dyed clothes
|
||||
|
||||
hair_base = hairstyles_list[convert_letter_to_number(seed[6],hairstyles_list.length)]
|
||||
hair_number = [1,2,3,4][convert_letter_to_number(seed[7],3)]
|
||||
echoln "hair_number: #{hair_number}"
|
||||
|
||||
hair=getFullHairId(hair_base,hair_number)
|
||||
hair_color = convert_letter_to_number(seed[8],max_dye_color)
|
||||
hair_color = 0 if convert_letter_to_number(seed[9]) % 2 == 0 #1/2 chance of no dyed hair
|
||||
|
||||
echoln hair_color
|
||||
echoln clothes_color
|
||||
echoln hat_color
|
||||
|
||||
skin_tone = [1,2,3,4,5,6][convert_letter_to_number(seed[10],5)]
|
||||
return TrainerAppearance.new(skin_tone,hat,clothes, hair,
|
||||
hair_color, clothes_color, hat_color,
|
||||
hat2,hat2_color)
|
||||
|
||||
end
|
||||
|
||||
def get_random_appearance()
|
||||
hat = $PokemonGlobal.hats_data.keys.sample
|
||||
hat2 = $PokemonGlobal.hats_data.keys.sample
|
||||
hat2 = nil if(rand(3)==0)
|
||||
|
||||
clothes = $PokemonGlobal.clothes_data.keys.sample
|
||||
hat_color = rand(2)==0 ? rand(255) : 0
|
||||
hat2_color = rand(2)==0 ? rand(255) : 0
|
||||
|
||||
clothes_color = rand(2)==0 ? rand(255) : 0
|
||||
hair_color = rand(2)==0 ? rand(255) : 0
|
||||
|
||||
hair_id = $PokemonGlobal.hairstyles_data.keys.sample
|
||||
hair_color = [1,2,3,4].sample
|
||||
skin_tone = [1,2,3,4,5,6].sample
|
||||
hair = getFullHairId(hair_id,hair_color)
|
||||
|
||||
return TrainerAppearance.new(skin_tone,hat,clothes, hair,
|
||||
hair_color, clothes_color, hat_color,hat2)
|
||||
end
|
||||
|
||||
def randomizePlayerOutfit()
|
||||
$Trainer.hat = $PokemonGlobal.hats_data.keys.sample
|
||||
$Trainer.hat2 = $PokemonGlobal.hats_data.keys.sample
|
||||
$Trainer.hat2 = nil if(rand(3)==0)
|
||||
|
||||
$Trainer.clothes = $PokemonGlobal.clothes_data.keys.sample
|
||||
$Trainer.hat_color = rand(2)==0 ? rand(255) : 0
|
||||
$Trainer.hat2_color = rand(2)==0 ? rand(255) : 0
|
||||
|
||||
$Trainer.clothes_color = rand(2)==0 ? rand(255) : 0
|
||||
$Trainer.hair_color = rand(2)==0 ? rand(255) : 0
|
||||
|
||||
hair_id = $PokemonGlobal.hairstyles_data.keys.sample
|
||||
hair_color = [1,2,3,4].sample
|
||||
$Trainer.skin_tone = [1,2,3,4,5,6].sample
|
||||
$Trainer.hair = getFullHairId(hair_id,hair_color)
|
||||
|
||||
end
|
||||
|
||||
def canPutHatOnPokemon(pokemon)
|
||||
return !pokemon.egg? && !pokemon.isTripleFusion? && $game_switches[SWITCH_UNLOCKED_POKEMON_HATS]
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
class Outfit
|
||||
attr_accessor :id
|
||||
attr_accessor :name
|
||||
attr_accessor :description
|
||||
attr_accessor :tags
|
||||
attr_accessor :price
|
||||
|
||||
def initialize(id, name, description = '',price=0, tags = [])
|
||||
@id = id
|
||||
@name = name
|
||||
@description = description
|
||||
@tags = tags
|
||||
@price = price
|
||||
end
|
||||
|
||||
def trainer_sprite_path()
|
||||
return nil
|
||||
end
|
||||
end
|
||||
11
Data/Scripts/998_InfiniteFusion/Outfits/wrappers/Clothes.rb
Normal file
11
Data/Scripts/998_InfiniteFusion/Outfits/wrappers/Clothes.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Clothes < Outfit
|
||||
attr_accessor :type
|
||||
def initialize(id, name, description = '',price=0, tags = [])
|
||||
super
|
||||
@type = :CLOTHES
|
||||
end
|
||||
|
||||
def trainer_sprite_path()
|
||||
return getTrainerSpriteOutfitFilename(self.id)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,12 @@
|
||||
class Hairstyle < Outfit
|
||||
attr_accessor :type
|
||||
def initialize(id, name, description = '',price=0, tags = [])
|
||||
super
|
||||
@type = :HAIR
|
||||
end
|
||||
|
||||
def trainer_sprite_path()
|
||||
return getTrainerSpriteHairFilename(self.id)
|
||||
end
|
||||
|
||||
end
|
||||
11
Data/Scripts/998_InfiniteFusion/Outfits/wrappers/Hat.rb
Normal file
11
Data/Scripts/998_InfiniteFusion/Outfits/wrappers/Hat.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class Hat < Outfit
|
||||
attr_accessor :type
|
||||
def initialize(id,name,description='',price=0,tags=[])
|
||||
super
|
||||
@type = :HAT
|
||||
end
|
||||
|
||||
def trainer_sprite_path()
|
||||
return getTrainerSpriteHatFilename(self.id)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user