mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Migrate a reorganizes bunch of files from PIF
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user