mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 21:24:59 +00:00
Secondary Hat (WIP)
This commit is contained in:
@@ -133,28 +133,34 @@ def getCurrentPokeball(allowEasterEgg=true)
|
||||
end
|
||||
|
||||
def generate_front_trainer_sprite_bitmap_from_appearance(trainerAppearance)
|
||||
echoln caller
|
||||
echoln trainerAppearance.hat
|
||||
return generate_front_trainer_sprite_bitmap(false,nil,trainerAppearance.clothes,trainerAppearance.hat,
|
||||
return generate_front_trainer_sprite_bitmap(false,nil,trainerAppearance.clothes,trainerAppearance.hat,nil,
|
||||
trainerAppearance.hair,trainerAppearance.skin_color,
|
||||
trainerAppearance.hair_color,trainerAppearance.hat_color,trainerAppearance.clothes_color)
|
||||
end
|
||||
|
||||
def generate_front_trainer_sprite_bitmap(allowEasterEgg=true, pokeball = nil, clothes_id = nil, hat_id = nil, hair_id = nil,
|
||||
skin_tone_id = nil, hair_color = nil, hat_color = nil, clothes_color = nil)
|
||||
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)
|
||||
echoln hat_id
|
||||
clothes_id = $Trainer.clothes if !clothes_id
|
||||
hat_id = $Trainer.hat if !hat_id
|
||||
hat2_id = $Trainer.hat 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) # _INTL(Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER + "/hat_trainer_{1}", $Trainer.hat)
|
||||
hatFilename = getTrainerSpriteHatFilename(hat_id)
|
||||
hat2Filename = getTrainerSpriteHatFilename(hat2_id)
|
||||
|
||||
pokeball = getCurrentPokeball(allowEasterEgg) if !pokeball
|
||||
ballFilename = getTrainerSpriteBallFilename(pokeball) if pokeball
|
||||
|
||||
@@ -162,10 +168,13 @@ def generate_front_trainer_sprite_bitmap(allowEasterEgg=true, pokeball = nil, cl
|
||||
|
||||
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)
|
||||
@@ -181,7 +190,8 @@ def generate_front_trainer_sprite_bitmap(allowEasterEgg=true, pokeball = nil, cl
|
||||
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) #pbLoadOutfitBitmap(hatFilename) if pbResolveBitmap(hatFilename)
|
||||
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
|
||||
@@ -193,6 +203,7 @@ def generate_front_trainer_sprite_bitmap(allowEasterEgg=true, pokeball = nil, cl
|
||||
end
|
||||
baseBitmap.bitmap.blt(0, 0, hairBitmapWrapper.bitmap, hairBitmapWrapper.bitmap.rect) if hairBitmapWrapper
|
||||
baseBitmap.bitmap.blt(0, 0, hatBitmap.bitmap, hatBitmap.bitmap.rect) if hatBitmap
|
||||
baseBitmap.bitmap.blt(0, 0, hat2Bitmap.bitmap, hat2Bitmap.bitmap.rect) if hat2Bitmap
|
||||
baseBitmap.bitmap.blt(44, 42, ballBitmap, ballBitmap.rect) if ballBitmap
|
||||
|
||||
return baseBitmap
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class TrainerClothesPreview
|
||||
attr_writer :pokeball, :clothes, :hat, :hair, :skin_tone, :hair_color, :hat_color, :clothes_color
|
||||
attr_writer :pokeball, :clothes, :hat, :hat2, :hair, :skin_tone, :hair_color, :hat_color, :clothes_color
|
||||
|
||||
def initialize(x = 0, y = 0, windowed = true, pokeball = nil)
|
||||
@playerBitmap = nil
|
||||
@@ -15,19 +15,22 @@ class TrainerClothesPreview
|
||||
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, @hair,
|
||||
@clothes,
|
||||
@hat,@hat2, @hair,
|
||||
@skin_tone,
|
||||
@hair_color, @hat_color, @clothes_color)
|
||||
@hair_color, @hat_color, @clothes_color, @hat2_color)
|
||||
initialize_preview()
|
||||
end
|
||||
|
||||
|
||||
@@ -71,8 +71,38 @@ def hairShop(outfits_list = [],free=false, customMessage=nil)
|
||||
genericOutfitsShopMenu(stock, :HAIR, true,!free,customMessage)
|
||||
end
|
||||
|
||||
|
||||
|
||||
SWAP_HAT_POSITIONS_CAPTION = "Switch hats position"
|
||||
def set_hat_adapter_options(adapter)
|
||||
slot1_hat = $Trainer.hat ? "Swap #{get_hat_by_id($Trainer.hat).name}" : "(Empty slot)"
|
||||
slot2_hat = $Trainer.hat2 ? "Swap #{get_hat_by_id($Trainer.hat2).name}" : "(Empty slot)"
|
||||
options = [slot1_hat,slot2_hat]
|
||||
options << SWAP_HAT_POSITIONS_CAPTION if $Trainer.hat && $Trainer.hat2
|
||||
options << "Cancel"
|
||||
hat_options_choice = optionsMenu(options)
|
||||
if options[hat_options_choice] == SWAP_HAT_POSITIONS_CAPTION
|
||||
hat1 = $Trainer.hat
|
||||
hat2 = $Trainer.hat2
|
||||
$Trainer.hat = hat2
|
||||
$Trainer.hat2 = hat1
|
||||
pbSEPlay("GUI naming tab swap start")
|
||||
return set_hat_adapter_options(adapter)
|
||||
end
|
||||
if hat_options_choice == options.length #cancel
|
||||
return nil
|
||||
end
|
||||
is_secondary = hat_options_choice ==1
|
||||
adapter.set_secondary_hat(is_secondary)
|
||||
return adapter
|
||||
end
|
||||
|
||||
def openSelectOutfitMenu(stock = [], itemType)
|
||||
adapter = getAdapter(itemType, stock, false)
|
||||
if adapter.is_a?(HatsMartAdapter)
|
||||
adapter = set_hat_adapter_options(adapter)
|
||||
return if !adapter
|
||||
end
|
||||
view = ClothesShopView.new()
|
||||
presenter = ClothesShopPresenter.new(view, stock, adapter)
|
||||
presenter.pbBuyScreen
|
||||
|
||||
@@ -2,23 +2,38 @@ class HatsMartAdapter < OutfitsMartAdapter
|
||||
DEFAULT_NAME = "[unknown]"
|
||||
DEFAULT_DESCRIPTION = "A headgear that trainers can wear."
|
||||
|
||||
def initialize(stock = nil, isShop = nil)
|
||||
super
|
||||
def initialize(stock = nil, isShop = nil, isSecondaryHat = false)
|
||||
super(stock,isShop)
|
||||
@is_secondary_hat = isSecondaryHat
|
||||
end
|
||||
|
||||
def toggleEvent(item)
|
||||
if !@isShop
|
||||
$Trainer.hat = nil
|
||||
@worn_clothes = nil
|
||||
if @is_secondary_hat
|
||||
$Trainer.hat2 = nil
|
||||
@worn_clothes = nil
|
||||
|
||||
if pbConfirmMessage(_INTL("Do you want to take off your hat?"))
|
||||
if pbConfirmMessage(_INTL("Do you want to take off your hat?"))
|
||||
$Trainer.hat2 = nil
|
||||
@worn_clothes = nil
|
||||
end
|
||||
else
|
||||
$Trainer.hat = nil
|
||||
@worn_clothes = nil
|
||||
|
||||
if pbConfirmMessage(_INTL("Do you want to take off your hat?"))
|
||||
$Trainer.hat = nil
|
||||
@worn_clothes = nil
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def set_secondary_hat(value)
|
||||
@is_secondary_hat = value
|
||||
end
|
||||
|
||||
def toggleText()
|
||||
return
|
||||
# return if @isShop
|
||||
@@ -48,14 +63,27 @@ class HatsMartAdapter < OutfitsMartAdapter
|
||||
end
|
||||
|
||||
def updateTrainerPreview(item, previewWindow)
|
||||
if item.is_a?(Outfit)
|
||||
previewWindow.hat = item.id
|
||||
$Trainer.hat = item.id# unless $Trainer.hat==nil
|
||||
set_dye_color(item,previewWindow)
|
||||
if @is_secondary_hat
|
||||
if item.is_a?(Outfit)
|
||||
previewWindow.hat2 = item.id
|
||||
$Trainer.hat2 = item.id# unless $Trainer.hat==nil
|
||||
set_dye_color(item,previewWindow)
|
||||
else
|
||||
$Trainer.hat2=nil
|
||||
previewWindow.hat2= nil
|
||||
end
|
||||
else
|
||||
$Trainer.hat=nil
|
||||
previewWindow.hat= nil
|
||||
if item.is_a?(Outfit)
|
||||
previewWindow.hat = item.id
|
||||
$Trainer.hat = item.id# unless $Trainer.hat==nil
|
||||
set_dye_color(item,previewWindow)
|
||||
else
|
||||
$Trainer.hat=nil
|
||||
previewWindow.hat= nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
@@ -91,7 +119,7 @@ class HatsMartAdapter < OutfitsMartAdapter
|
||||
|
||||
def addItem(item)
|
||||
return unless item.is_a?(Outfit)
|
||||
changed_clothes = obtainHat(item.id)
|
||||
changed_clothes = obtainHat(item.id,@is_secondary_hat)
|
||||
if changed_clothes
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
@@ -103,13 +131,23 @@ class HatsMartAdapter < OutfitsMartAdapter
|
||||
|
||||
def putOnOutfit(item)
|
||||
return unless item.is_a?(Outfit)
|
||||
putOnHat(item.id)
|
||||
if @is_secondary_hat
|
||||
echoln "broder"
|
||||
putOnSecondaryHat(item.id)
|
||||
else
|
||||
putOnHat(item.id)
|
||||
end
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
$Trainer.hat = @worn_clothes
|
||||
$Trainer.hat_color = $Trainer.dyed_hats[@worn_clothes] if $Trainer.dyed_hats && $Trainer.dyed_hats[@worn_clothes]
|
||||
if @is_secondary_hat
|
||||
$Trainer.hat2 = @worn_clothes
|
||||
$Trainer.hat2_color = $Trainer.dyed_hats[@worn_clothes] if $Trainer.dyed_hats && $Trainer.dyed_hats[@worn_clothes]
|
||||
else
|
||||
$Trainer.hat = @worn_clothes
|
||||
$Trainer.hat_color = $Trainer.dyed_hats[@worn_clothes] if $Trainer.dyed_hats && $Trainer.dyed_hats[@worn_clothes]
|
||||
end
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
|
||||
@@ -6,7 +6,7 @@ def obtainNewClothes(outfit_id)
|
||||
return obtainClothes(outfit_id)
|
||||
end
|
||||
|
||||
def obtainHat(outfit_id)
|
||||
def obtainHat(outfit_id,secondary=false)
|
||||
echoln "obtained new hat: " + outfit_id
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
if !outfit
|
||||
@@ -16,7 +16,8 @@ def obtainHat(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, false)
|
||||
putOnHat(outfit_id, false, ) if !secondary
|
||||
putOnSecondaryHat(outfit_id, false, ) if secondary
|
||||
return true
|
||||
end
|
||||
return false
|
||||
@@ -70,6 +71,7 @@ def putOnHat(outfit_id, silent = false)
|
||||
$Trainer.dyed_hats= {} if ! $Trainer.dyed_hats
|
||||
$Trainer.last_worn_hat = $Trainer.hat
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
|
||||
$Trainer.hat = outfit_id
|
||||
|
||||
dye_color = $Trainer.dyed_hats[outfit_id]
|
||||
@@ -83,6 +85,25 @@ def putOnHat(outfit_id, silent = false)
|
||||
putOnOutfitMessage(outfit) if !silent
|
||||
end
|
||||
|
||||
def putOnSecondaryHat(outfit_id, silent = false)
|
||||
$Trainer.dyed_hats= {} if ! $Trainer.dyed_hats
|
||||
$Trainer.last_worn_hat = $Trainer.hat2
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
|
||||
$Trainer.hat2 = outfit_id
|
||||
|
||||
dye_color = $Trainer.dyed_hats[outfit_id]
|
||||
if dye_color
|
||||
$Trainer.hat2_color = dye_color
|
||||
else
|
||||
$Trainer.hat2_color = nil
|
||||
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)
|
||||
@@ -306,6 +327,7 @@ end
|
||||
|
||||
def randomizePlayerOutfit()
|
||||
$Trainer.hat = $PokemonGlobal.hats_data.keys.sample
|
||||
$Trainer.hat2 = $PokemonGlobal.hats_data.keys.sample
|
||||
$Trainer.clothes = $PokemonGlobal.clothes_data.keys.sample
|
||||
$Trainer.hat_color = rand(2)==0 ? rand(255) : 0
|
||||
$Trainer.clothes_color = rand(2)==0 ? rand(255) : 0
|
||||
|
||||
Reference in New Issue
Block a user