mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 22:24:58 +00:00
release 6.2
This commit is contained in:
131
Data/Scripts/050_Outfits/utils/OutfitFilenameUtils.rb
Normal file
131
Data/Scripts/050_Outfits/utils/OutfitFilenameUtils.rb
Normal file
@@ -0,0 +1,131 @@
|
||||
#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
|
||||
|
||||
|
||||
# Input: red_a
|
||||
# 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)
|
||||
# matches = hairstyle_id.to_s.match(/\A(\d+)([A-Za-z])?\z/)
|
||||
# return "" if !matches
|
||||
# hair_id = matches[1]
|
||||
# version = matches.length > 1 ? matches[2] : "a"
|
||||
hairstyle_split = getSplitHairFilenameAndVersionFromID(hairstyle_id)
|
||||
name= hairstyle_split[-1]
|
||||
version= hairstyle_split[-2]
|
||||
|
||||
# match_data = hairstyle_id.match(/(\d+)_/)
|
||||
# version = match_data[0].to_i if match_data
|
||||
|
||||
|
||||
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)
|
||||
#filename += version if version
|
||||
full_path = base_path + dynamic_path + filename
|
||||
return full_path
|
||||
end
|
||||
|
||||
def getTrainerSpriteHairFilename(hairstyle_id)
|
||||
# matches = hairstyle_id.to_s.match(/\A(\d+)([A-Za-z])?\z/)
|
||||
# return "" if !matches
|
||||
# hair_id = matches[1]
|
||||
# version = matches.length > 1 ? matches[2] : "a"
|
||||
return "" if !hairstyle_id
|
||||
hairstyle_id= hairstyle_id.to_s
|
||||
hairstyle_split= hairstyle_id.split("_")
|
||||
name= hairstyle_split[-1]
|
||||
version= hairstyle_split[-2]
|
||||
|
||||
# match_data = hairstyle_id.match(/(\d+)_/)
|
||||
# version = match_data[0].to_i if match_data
|
||||
|
||||
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)
|
||||
#filename += version if version
|
||||
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
|
||||
96
Data/Scripts/050_Outfits/utils/OutfitsGameplayUtils.rb
Normal file
96
Data/Scripts/050_Outfits/utils/OutfitsGameplayUtils.rb
Normal file
@@ -0,0 +1,96 @@
|
||||
def obtainNewHat(outfit_id)
|
||||
echoln "obtained new hat: " + outfit_id
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
$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)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
def obtainNewClothes(outfit_id)
|
||||
echoln "obtained new clothes: " + outfit_id
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
$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_version= split_outfit_id[0]
|
||||
outfit = get_hair_by_id(hairstyle_id)
|
||||
$Trainer.unlocked_clothes << hairstyle_id if !$Trainer.unlocked_hairstyles.include?(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, outfit.name))
|
||||
# pbMessage(_INTL("\\me[{1}]You obtained the \\c[1]{2}\\c[0] hairstyle!\\wtnp[30]", musical_effect, outfit.name))
|
||||
# if pbConfirmMessage("Would you like to use this hairstyle right now?")
|
||||
# putOnHair(hairstyle_id,hairstyle_version)
|
||||
# return true
|
||||
# end
|
||||
return false
|
||||
end
|
||||
|
||||
def putOnClothes(outfit_id)
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
$Trainer.clothes = outfit_id
|
||||
putOnOutfitMessage(outfit)
|
||||
end
|
||||
|
||||
def putOnHat(outfit_id)
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
$Trainer.hat = outfit_id
|
||||
putOnOutfitMessage(outfit)
|
||||
end
|
||||
|
||||
def putOnHairFullId(full_outfit_id)
|
||||
outfit_id = getSplitHairFilenameAndVersionFromID(full_outfit_id)[1]
|
||||
outfit = get_hair_by_id(outfit_id)
|
||||
$Trainer.hair = getFullHairId(full_outfit_id)
|
||||
putOnOutfitMessage(outfit)
|
||||
end
|
||||
|
||||
def putOnHair(outfit_id, version)
|
||||
#outfit = get_hair_by_id(outfit_id)
|
||||
$Trainer.hair = getFullHairId(outfit_id,version)
|
||||
#putOnOutfitMessage(outfit)
|
||||
end
|
||||
|
||||
|
||||
#todo: add a little preview window?
|
||||
def obtainOutfitMessage(outfit)
|
||||
musical_effect = "Key item get"
|
||||
pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]", musical_effect, outfit.name))
|
||||
end
|
||||
|
||||
def putOnOutfitMessage(outfit)
|
||||
playOutfitChangeAnimation()
|
||||
pbMessage(_INTL("You put on the \\c[1]{1}\\c[0]!\\wtnp[30]", outfit.name))
|
||||
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)
|
||||
if pbResolveBitmap(getOverworldHairFilename(hair_id))
|
||||
last_version = version
|
||||
else
|
||||
return last_version
|
||||
end
|
||||
}
|
||||
return last_version
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user