double hats UI wip

This commit is contained in:
chardub
2025-03-08 12:52:55 -05:00
parent 20a5811ab8
commit 60de077d01
23 changed files with 870 additions and 144 deletions

View File

@@ -1,6 +1,7 @@
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
@@ -13,6 +14,17 @@ class OutfitsMartAdapter < PokemonMartAdapter
@version = nil
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 toggleText()
return ""
end

View File

@@ -1,4 +1,5 @@
class ClothesMartAdapter < OutfitsMartAdapter
DEFAULT_NAME = "[unknown]"
DEFAULT_DESCRIPTION = "A piece of clothing that trainers can wear."
def toggleEvent(item)
@@ -14,13 +15,8 @@ class ClothesMartAdapter < OutfitsMartAdapter
end
def getName(item)
return item.id
end
def getDisplayName(item)
return getName(item) if !item.name
name = item.name
name = "* #{name}" if item.id == $Trainer.favorite_clothes
name= item.id
name = "* #{name}" if is_wearing_clothes(item.id)
return name
end

View File

@@ -18,6 +18,8 @@ def genericOutfitsShopMenu(stock = [], itemType = nil, versions = false, isShop=
end
end
def getPresenter(itemType, view, stock, adapter, versions)
case itemType
when :HAIR
@@ -110,11 +112,20 @@ 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 = ClothesShopView.new()
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|
@@ -134,32 +145,52 @@ def changeHatMenu(is_secondary_hat = false)
openSelectOutfitMenu(stock, :HAT, is_secondary_hat)
end
def changeOutfit()
hat1_name = get_hat_by_id($Trainer.hat) ? get_hat_by_id($Trainer.hat).name : "(Empty)"
hat2_name = get_hat_by_id($Trainer.hat2) ? get_hat_by_id($Trainer.hat2).name : "(Empty)"
# def changeOutfit()
# hat1_name = get_hat_by_id($Trainer.hat) ? get_hat_by_id($Trainer.hat).name : "(Empty)"
# hat2_name = get_hat_by_id($Trainer.hat2) ? get_hat_by_id($Trainer.hat2).name : "(Empty)"
#
# commands = []
# commands[cmdClothes = commands.length] = _INTL("Change clothes")
# commands[cmdHat = commands.length] = _INTL("Change hat 1 (#{hat1_name})")
# commands[cmdHat2 = commands.length] = _INTL("Change hat 2 (#{hat2_name})")
# commands[switchHats = commands.length] = _INTL("Switch hat positions")
# commands[cmdQuit = commands.length] = _INTL("Quit")
#
# #TODO change this into a graphical menu with icons
# loop do
# cmd = pbMessage(_INTL("What would you like to do?"), commands, cmdQuit + 1)
# if cmd == cmdClothes
# changeClothesMenu()
# break
# elsif cmd == cmdHat
# changeHatMenu()
# break
# elsif cmd == cmdHat2
# changeHatMenu(true)
# break
# elsif cmd == switchHats
# switchHatsPosition()
# break
# else
# break
# end
# end
# end
def changeOutfit()
commands = []
commands[cmdHat = commands.length] = _INTL("Change hat")
commands[cmdClothes = commands.length] = _INTL("Change clothes")
commands[cmdHat = commands.length] = _INTL("Change hat 1 (#{hat1_name})")
commands[cmdHat2 = commands.length] = _INTL("Change hat 2 (#{hat2_name})")
commands[switchHats = commands.length] = _INTL("Switch hat positions")
commands[cmdQuit = commands.length] = _INTL("Quit")
#TODO change this into a graphical menu with icons
cmd = pbMessage(_INTL("What would you like to do?"), commands, cmdQuit + 1)
loop do
cmd = pbMessage(_INTL("What would you like to do?"), commands, cmdQuit + 1)
if cmd == cmdClothes
changeClothesMenu()
break
elsif cmd == cmdHat
changeHatMenu()
break
elsif cmd == cmdHat2
changeHatMenu(true)
break
elsif cmd == switchHats
switchHatsPosition()
break
else
break
end

View File

@@ -13,57 +13,10 @@ class ClothesShopPresenter < PokemonMartScreen
@scene.pbEndBuyScene
end
def playerHatActionsMenu(item, is_secondary=false)
is_player_hat = item.id == @adapter.worn_clothes
options = []
if is_player_hat
options << "Take off"
else
options << "Wear"
end
remove_dye_option_available = $Trainer.hat_color(@adapter.is_secondary_hat) != 0
options << "Remove dye" if remove_dye_option_available
options << "Mark as favorite" if $Trainer.favorite_hat(@adapter.is_secondary_hat) != item.id
options << "Unmark as favorite" if $Trainer.favorite_hat(@adapter.is_secondary_hat) == item.id
options << "Cancel"
# if $Trainer.hat_color != 0
choice = pbMessage("What would you like to do?", options, -1)
if choice == 0
if is_player_hat # remove
@adapter.doSpecialItemAction(:REMOVE)
@scene.pbEndBuyScene
return false
else
# wear
putOnClothes(item)
$Trainer.set_hat_color(@adapter.get_dye_color(item),@adapter.is_secondary_hat)
return false
end
elsif choice == 1 && remove_dye_option_available
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
return true
elsif options[choice] == "Mark as favorite"
slot = @adapter.is_secondary_hat ? "slot 1" : "slot 2"
$Trainer.set_favorite_hat(item.id,@adapter.is_secondary_hat)
pbSEPlay("GUI storage show party panel")
pbMessage("The #{item.name} is now your favorite (#{slot})!")
echoln "marked #{item.id} as favorite hat"
elsif options[choice] == "Unmark as favorite"
$Trainer.set_favorite_hat(nil,@adapter.is_secondary_hat)
pbSEPlay("GUI storage show party panel")
pbMessage("The #{item.name} is no longer marked as your favorite!")
end
echoln "cancelled"
return true
end
# returns if should stay in the menu
def playerClothesActionsMenu(item)
is_worn = item.id == @adapter.worn_clothes
options = []
options << "Wear"
options << "Remove dye" if $Trainer.clothes_color != 0
@@ -106,7 +59,6 @@ class ClothesShopPresenter < PokemonMartScreen
return
elsif @adapter.is_a?(HatsMartAdapter)
stay_in_menu = playerHatActionsMenu(item)
echoln stay_in_menu
next if stay_in_menu
return
else

View File

@@ -0,0 +1,114 @@
class ClothesShopPresenter < PokemonMartScreen
def removeHat(item)
if item.id == @adapter.worn_clothes
$Trainer.set_hat(nil,false)
@adapter.worn_clothes = nil
elsif item.id == @adapter.worn_clothes2
$Trainer.set_hat(nil,true)
@adapter.worn_clothes2 = nil
end
end
def wearAsHat1(item)
@adapter.set_secondary_hat(false)
putOnClothes(item)
$Trainer.set_hat_color(@adapter.get_dye_color(item),false)
end
def wearAsHat2(item)
@adapter.set_secondary_hat(true)
putOnClothes(item)
$Trainer.set_hat_color(@adapter.get_dye_color(item),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()
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.hat2_color = hat2_color
pbSEPlay("GUI naming tab swap start")
new_selected_hat = @adapter.is_secondary_hat ? $Trainer.hat2 : $Trainer.hat
@scene.select_specific_item(new_selected_hat)
end
def build_options_menu(cmd_confirm,cmd_remove,cmd_remove_dye,cmd_swap,cmd_cancel)
options = []
options << cmd_confirm
options << cmd_remove
options << cmd_swap
remove_dye_option_available = $Trainer.hat_color(@adapter.is_secondary_hat) != 0
options << cmd_remove_dye if remove_dye_option_available
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()
putOnHat($Trainer.hat,true,false)
putOnHat($Trainer.hat2,true,true)
@worn_clothes = $Trainer.hat
@worn_clothes2 = $Trainer.hat2
playOutfitChangeAnimation()
pbMessage(_INTL("You put on the hat(s)!\\wtnp[30]"))
@scene.pbEndBuyScene
end
def playerHatActionsMenu(item)
cmd_confirm = "Confirm"
cmd_remove = "Remove hat"
cmd_cancel = "Cancel"
cmd_remove_dye = "Remove dye"
cmd_swap = "Swap hats positions"
options = build_options_menu(cmd_confirm,cmd_remove,cmd_remove_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
putOnHats()
$Trainer.hat_color = @adapter.get_dye_color($Trainer.hat)
$Trainer.hat2_color = @adapter.get_dye_color($Trainer.hat2)
return false
elsif options[choice] == cmd_remove_dye
removeDye(item)
return true
elsif options[choice] == cmd_swap
swapHats()
return true
end
end
end

View File

@@ -8,9 +8,9 @@ class ClothesShopView < PokemonMart_Scene
super(buying, stock, adapter)
@sprites["icon"].visible = false
if @adapter.isShop?
@sprites["background"].setBitmap("Graphics/Pictures/martScreenOutfit")
@sprites["background"].setBitmap("Graphics/Pictures/Outfits/martScreenOutfit")
else
@sprites["background"].setBitmap("Graphics/Pictures/changeOutfitScreen")
@sprites["background"].setBitmap("Graphics/Pictures/Outfits/changeOutfitScreen")
end
preview_y = @adapter.isShop? ? 80 : 0
@@ -23,6 +23,19 @@ class ClothesShopView < PokemonMart_Scene
end
def select_specific_item(scroll_to_item_id)
itemwindow = @sprites["itemwindow"]
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)
@@ -43,7 +56,7 @@ class ClothesShopView < PokemonMart_Scene
def refreshStock(adapter)
@adapter = adapter
@sprites["itemwindow"].dispose
@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
@@ -110,9 +123,9 @@ class ClothesShopView < PokemonMart_Scene
#@adapter.switchVersion(itemwindow.item, -1)
#updateTrainerPreview()
end
if Input.trigger?(Input::AUX2) #R button
@adapter.switchVersion(itemwindow.item, 1)
updateTrainerPreview()
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)
@@ -137,6 +150,11 @@ class ClothesShopView < PokemonMart_Scene
}
end
def switchItemVersion(itemwindow)
@adapter.switchVersion(itemwindow.item, 1)
updateTrainerPreview()
end
def update
if Input.trigger?(Input::LEFT)
pbSEPlay("GUI party switch", 80, 100)

View File

@@ -85,11 +85,6 @@ class HairMartAdapter < OutfitsMartAdapter
return item.id
end
def getDisplayName(item)
return getName(item) if !item.name
return item.name
end
def getDescription(item)
return DEFAULT_DESCRIPTION if !item.description
return item.description

View File

@@ -0,0 +1,95 @@
# 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
echoln "scroll to #{new_selected_hat} (#{@adapter.is_secondary_hat}"
select_specific_item(new_selected_hat)
updateTrainerPreview()
end
def displayLayerIcons(selected_item=nil)
if !selected_item.is_a?(Hat)
if @adapter.is_secondary_hat
@sprites["wornHat_layer2"].bitmap=nil
else
@sprites["wornHat_layer1"].bitmap=nil
end
return
end
hat1Filename = getOverworldHatFilename($Trainer.hat)
hat2Filename = getOverworldHatFilename($Trainer.hat2)
hat_color_shift = $Trainer.dyed_hats[@adapter.worn_clothes]
hat2_color_shift = $Trainer.dyed_hats[@adapter.worn_clothes2]
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=40
@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

View File

@@ -1,9 +1,14 @@
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(false)
@worn_clothes2 = $Trainer.hat(true)
end
def toggleEvent(item)
@@ -11,8 +16,18 @@ class HatsMartAdapter < OutfitsMartAdapter
$Trainer.set_hat(nil,@is_secondary_hat)
@worn_clothes = nil
if pbConfirmMessage(_INTL("Do you want to take off your hat?"))
$Trainer.set_hat(nil,@is_secondary_hat)
hat1_name = get_hat_by_id($Trainer.hat) ? get_hat_by_id($Trainer.hat).name : "(Empty)"
hat2_name = get_hat_by_id($Trainer.hat2) ? get_hat_by_id($Trainer.hat2).name : "(Empty)"
cmd_remove_hat1 = "Remove #{hat1_name}"
cmd_remove_hat2 = "Remove #{hat2_name}"
options = [cmd_remove_hat1,cmd_remove_hat2, "Cancel"]
choice = optionsMenu(options)
if options[choice] == cmd_remove_hat1
$Trainer.set_hat(nil,false)
@worn_clothes = nil
elsif options[choice] == cmd_remove_hat2
$Trainer.set_hat(nil,true)
@worn_clothes = nil
end
end
@@ -22,6 +37,10 @@ class HatsMartAdapter < OutfitsMartAdapter
@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
@@ -29,15 +48,12 @@ class HatsMartAdapter < OutfitsMartAdapter
# return "Remove hat: #{toggleKey}"
end
def getName(item)
return item.id
def switchVersion(item,delta=1)
@is_secondary_hat = !@is_secondary_hat
end
def getDisplayName(item)
return getName(item) if !item.name
name = item.name
name = "* #{name}" if item.id == $Trainer.favorite_hat(@is_secondary_hat)
return name
def getName(item)
return item.id
end
def getDescription(item)
@@ -151,7 +167,7 @@ class HatsMartAdapter < OutfitsMartAdapter
return "Go without a hat and show off your #{hair_situation}!"
end
def doSpecialItemAction(specialType)
toggleEvent(nil)
def doSpecialItemAction(specialType,item=nil)
toggleEvent(item)
end
end