mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-23 06:46:00 +00:00
release 6.2
This commit is contained in:
181
Data/Scripts/050_Outfits/UI/CharacterSelectMenu.rb
Normal file
181
Data/Scripts/050_Outfits/UI/CharacterSelectMenu.rb
Normal file
@@ -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
|
||||
265
Data/Scripts/050_Outfits/UI/CharacterSelectMenuPresenter.rb
Normal file
265
Data/Scripts/050_Outfits/UI/CharacterSelectMenuPresenter.rb
Normal file
@@ -0,0 +1,265 @@
|
||||
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)
|
||||
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 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)
|
||||
pbSet(VAR_TRAINER_AGE, @gender)
|
||||
$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()
|
||||
hairColorId = HAIR_COLOR_IDS[@hairColor]
|
||||
hairId = hairColorId.to_s + "_" + @hairstyle.to_s
|
||||
$Trainer.hair = hairId
|
||||
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
|
||||
209
Data/Scripts/050_Outfits/UI/LayeredClothes_Menus.rb
Normal file
209
Data/Scripts/050_Outfits/UI/LayeredClothes_Menus.rb
Normal file
@@ -0,0 +1,209 @@
|
||||
|
||||
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 selectHairColor
|
||||
display_outfit_preview()
|
||||
hat = $Trainer.hat
|
||||
commands = ["Shift up", "Shift down", "Toggle hat", "Reset", "Back"]
|
||||
previous_input = 0
|
||||
while (true)
|
||||
choice = pbShowCommands(nil, commands, commands.length, previous_input)
|
||||
previous_input = choice
|
||||
case choice
|
||||
when 0 #NEXT
|
||||
#playOutfitChangeAnimation()
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHairColor(10)
|
||||
display_outfit_preview()
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHairColor(-10)
|
||||
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()
|
||||
when 3 #Reset
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
$Trainer.hair_color = 0
|
||||
display_outfit_preview()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
$Trainer.hat = hat
|
||||
end
|
||||
|
||||
def selectHatColor
|
||||
display_outfit_preview()
|
||||
commands = ["Shift up", "Shift down", "Reset", "Back"]
|
||||
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)
|
||||
display_outfit_preview()
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftHatColor(-10)
|
||||
display_outfit_preview()
|
||||
when 2 #Reset
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
$Trainer.hat_color = 0
|
||||
display_outfit_preview()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
end
|
||||
|
||||
def selectClothesColor
|
||||
display_outfit_preview()
|
||||
commands = ["Shift up", "Shift down", "Reset", "Back"]
|
||||
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)
|
||||
shiftClothesColor(10)
|
||||
display_outfit_preview()
|
||||
when 1 #PREVIOUS
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
shiftClothesColor(-10)
|
||||
display_outfit_preview()
|
||||
when 2 #Reset
|
||||
pbSEPlay("GUI storage pick up", 80, 100)
|
||||
$Trainer.clothes_color = 0
|
||||
display_outfit_preview()
|
||||
else
|
||||
break
|
||||
end
|
||||
end
|
||||
hide_outfit_preview()
|
||||
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
|
||||
103
Data/Scripts/050_Outfits/UI/PokemonHatScreenPresenter.rb
Normal file
103
Data/Scripts/050_Outfits/UI/PokemonHatScreenPresenter.rb
Normal file
@@ -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 getPicturePath()
|
||||
if @pokemon.isTripleFusion?
|
||||
picturePath = GameData::Species::getSpecialSpriteName(@pokemon.species_data.id_number)
|
||||
elsif @pokemon.isFusion?
|
||||
picturePath = get_fusion_sprite_path(@pokemon.species_data.head_pokemon.id_number, @pokemon.species_data.body_pokemon.id_number)
|
||||
else
|
||||
picturePath = get_unfused_sprite_path(@pokemon.species_data.id_number, @pokemon.spriteform_body)
|
||||
end
|
||||
return picturePath
|
||||
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") if Input.trigger?(Input::RIGHT)
|
||||
@hat_id = selector.selectNextOutfit(@hat_id, -1, selector.hats_list, [], false, "hat_trainer") 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
|
||||
loop do
|
||||
Graphics.update
|
||||
Input.update
|
||||
@x_pos += PIXELS_PER_MOVEMENT if Input.repeat?(Input::RIGHT)
|
||||
@x_pos -= PIXELS_PER_MOVEMENT if Input.repeat?(Input::LEFT)
|
||||
@y_pos += PIXELS_PER_MOVEMENT if Input.repeat?(Input::DOWN)
|
||||
@y_pos -= PIXELS_PER_MOVEMENT if Input.repeat?(Input::UP)
|
||||
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()
|
||||
picturePath = getPicturePath()
|
||||
@original_pokemon_bitmap = AnimatedBitmap.new(picturePath)
|
||||
@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
|
||||
136
Data/Scripts/050_Outfits/UI/PokemonHatScreenView.rb
Normal file
136
Data/Scripts/050_Outfits/UI/PokemonHatScreenView.rb
Normal file
@@ -0,0 +1,136 @@
|
||||
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 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
|
||||
echoln @sprites["rightarrow"].frame
|
||||
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
|
||||
52
Data/Scripts/050_Outfits/UI/TrainerClothesPreview.rb
Normal file
52
Data/Scripts/050_Outfits/UI/TrainerClothesPreview.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
class TrainerClothesPreview
|
||||
attr_writer :pokeball, :clothes, :hat, :hair, :skin_tone, :hair_color, :hat_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 resetOutfits()
|
||||
@clothes = $Trainer.clothes
|
||||
@hat = $Trainer.hat
|
||||
@hair = $Trainer.hair
|
||||
@skin_tone = $Trainer.skin_tone
|
||||
@hair_color = $Trainer.hair_color
|
||||
@hat_color = $Trainer.hat_color
|
||||
@clothes_color = $Trainer.clothes_color
|
||||
end
|
||||
|
||||
def show()
|
||||
@playerBitmap = generate_front_trainer_sprite_bitmap(@pokeball,
|
||||
@clothes, @hat, @hair,
|
||||
@skin_tone,
|
||||
@hair_color, @hat_color, @clothes_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,98 @@
|
||||
class OutfitsMartAdapter < PokemonMartAdapter
|
||||
WORN_ITEM_BASE_COLOR = MessageConfig::BLUE_TEXT_MAIN_COLOR
|
||||
WORN_ITEM_SHADOW_COLOR = MessageConfig::BLUE_TEXT_SHADOW_COLOR
|
||||
|
||||
def initialize(stock = [], isShop = true)
|
||||
@items = stock
|
||||
@worn_clothes = get_current_clothes()
|
||||
@isShop = isShop
|
||||
@version = nil
|
||||
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 getBaseColorOverride(item)
|
||||
return WORN_ITEM_BASE_COLOR if isWornItem?(item)
|
||||
return nil
|
||||
end
|
||||
|
||||
def getShadowColorOverride(item)
|
||||
return WORN_ITEM_SHADOW_COLOR if isWornItem?(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
|
||||
end
|
||||
@@ -0,0 +1,64 @@
|
||||
class ClothesMartAdapter < OutfitsMartAdapter
|
||||
DEFAULT_NAME = "[unknown]"
|
||||
DEFAULT_DESCRIPTION = "A piece of clothing that trainers can wear."
|
||||
|
||||
def initialize(stock = nil, isShop = nil)
|
||||
super
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
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
|
||||
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
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
|
||||
|
||||
def addItem(item)
|
||||
changed_clothes = obtainNewClothes(item.id)
|
||||
if changed_clothes
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_clothes()
|
||||
return $Trainer.clothes
|
||||
end
|
||||
|
||||
def putOnOutfit(item)
|
||||
putOnClothes(item.id)
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
$Trainer.clothes = @worn_clothes
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
return $Trainer.unlocked_clothes
|
||||
end
|
||||
|
||||
def isWornItem?(item)
|
||||
super
|
||||
end
|
||||
end
|
||||
115
Data/Scripts/050_Outfits/UI/clothesShop/ClothesShop.rb
Normal file
115
Data/Scripts/050_Outfits/UI/clothesShop/ClothesShop.rb
Normal file
@@ -0,0 +1,115 @@
|
||||
def genericOutfitsShopMenu(stock = [], itemType = nil, versions = false)
|
||||
commands = []
|
||||
commands[cmdBuy = commands.length] = _INTL("Buy")
|
||||
commands[cmdQuit = commands.length] = _INTL("Quit")
|
||||
cmd = pbMessage(_INTL("Welcome! How may I serve you?"), commands, cmdQuit + 1)
|
||||
loop do
|
||||
if cmdBuy >= 0 && cmd == cmdBuy
|
||||
adapter = getAdapter(itemType, stock, true)
|
||||
view = ClothesShopView.new()
|
||||
presenter = getPresenter(itemType, view, stock, adapter, versions)
|
||||
presenter.pbBuyScreen
|
||||
break
|
||||
else
|
||||
pbMessage(_INTL("Please come again!"))
|
||||
break
|
||||
end
|
||||
cmd = pbMessage(_INTL("Is there anything else I can help you with?"),
|
||||
commands, cmdQuit + 1)
|
||||
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)
|
||||
case itemType
|
||||
when :CLOTHES
|
||||
return ClothesMartAdapter.new(stock, isShop)
|
||||
when :HAT
|
||||
return HatsMartAdapter.new(stock, isShop)
|
||||
when :HAIR
|
||||
return HairMartAdapter.new(stock, isShop)
|
||||
end
|
||||
end
|
||||
|
||||
def list_all_possible_outfits() end
|
||||
|
||||
def clothesShop(outfits_list = [])
|
||||
stock = []
|
||||
outfits_list.each { |outfit_id|
|
||||
outfit = get_clothes_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
genericOutfitsShopMenu(stock, :CLOTHES)
|
||||
end
|
||||
|
||||
def hatShop(outfits_list = [])
|
||||
stock = []
|
||||
outfits_list.each { |outfit_id|
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
genericOutfitsShopMenu(stock, :HAT)
|
||||
end
|
||||
|
||||
def hairShop(outfits_list = [])
|
||||
stock = []
|
||||
outfits_list.each { |outfit_id|
|
||||
echoln outfit_id
|
||||
outfit = get_hair_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
genericOutfitsShopMenu(stock, :HAIR, true)
|
||||
end
|
||||
|
||||
def openSelectOutfitMenu(stock = [], itemType)
|
||||
adapter = getAdapter(itemType, stock, false)
|
||||
view = ClothesShopView.new()
|
||||
presenter = ClothesShopPresenter.new(view, stock, adapter)
|
||||
presenter.pbBuyScreen
|
||||
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()
|
||||
stock = []
|
||||
$Trainer.unlocked_hats.each { |outfit_id|
|
||||
outfit = get_hat_by_id(outfit_id)
|
||||
stock << outfit if outfit
|
||||
}
|
||||
openSelectOutfitMenu(stock, :HAT)
|
||||
end
|
||||
|
||||
def changeOutfit()
|
||||
commands = []
|
||||
commands[cmdClothes = commands.length] = _INTL("Change clothes")
|
||||
commands[cmdHat = commands.length] = _INTL("Change hat")
|
||||
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,64 @@
|
||||
class ClothesShopPresenter < 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 put on the {1}?", item.name))
|
||||
@adapter.putOnOutfit(item)
|
||||
@scene.pbEndBuyScene
|
||||
return
|
||||
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
|
||||
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
|
||||
|
||||
end
|
||||
144
Data/Scripts/050_Outfits/UI/clothesShop/ClothesShopView.rb
Normal file
144
Data/Scripts/050_Outfits/UI/clothesShop/ClothesShopView.rb
Normal file
@@ -0,0 +1,144 @@
|
||||
class ClothesShopView < PokemonMart_Scene
|
||||
|
||||
|
||||
def initialize(currency_name="Money")
|
||||
@currency_name = currency_name
|
||||
end
|
||||
|
||||
def pbStartBuyOrSellScene(buying, stock, adapter)
|
||||
super(buying, stock, adapter)
|
||||
@initial_direction = $game_player.direction
|
||||
@sprites["icon"].visible=false
|
||||
if @adapter.isShop?
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/martScreenOutfit")
|
||||
else
|
||||
@sprites["background"].setBitmap("Graphics/Pictures/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 scroll_map
|
||||
pbScrollMap(DIRECTION_UP, 5, 5)
|
||||
pbScrollMap(DIRECTION_RIGHT, 7, 5)
|
||||
$game_player.turn_down
|
||||
pbRefreshSceneMap
|
||||
end
|
||||
|
||||
def scroll_back_map
|
||||
@adapter.reset_player_clothes()
|
||||
pbScrollMap(DIRECTION_LEFT, 7, 5)
|
||||
pbScrollMap(DIRECTION_DOWN, 5, 5)
|
||||
$game_player.turn_generic(@initial_direction)
|
||||
pbRefreshSceneMap
|
||||
end
|
||||
|
||||
def refreshStock(adapter)
|
||||
@adapter = adapter
|
||||
@sprites["itemwindow"].dispose
|
||||
@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"]
|
||||
#@sprites["icon"].item = itemwindow.item
|
||||
#@sprites["icon"].item = itemwindow.item
|
||||
@sprites["itemtextwindow"].text =
|
||||
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit.")
|
||||
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)
|
||||
@adapter.updateTrainerPreview(itemwindow.item,@sprites["trainerPreview"])
|
||||
@sprites["itemtextwindow"].text =
|
||||
(itemwindow.item) ? @adapter.getDescription(itemwindow.item) : _INTL("Quit.")
|
||||
end
|
||||
|
||||
|
||||
|
||||
def pbChooseBuyItem
|
||||
itemwindow = @sprites["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
|
||||
@adapter.switchVersion(itemwindow.item,-1)
|
||||
updateTrainerPreview()
|
||||
end
|
||||
if Input.trigger?(Input::AUX2)#R button
|
||||
@adapter.switchVersion(itemwindow.item,1)
|
||||
updateTrainerPreview()
|
||||
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.index < @stock.length
|
||||
pbRefresh
|
||||
return @stock[itemwindow.index]
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
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
|
||||
@sprites["trainerPreview"].erase()
|
||||
@sprites["trainerPreview"]=nil
|
||||
pbDisposeSpriteHash(@sprites)
|
||||
@viewport.dispose
|
||||
Kernel.pbClearText()
|
||||
# Scroll left after showing screen
|
||||
scroll_back_map()
|
||||
end
|
||||
|
||||
end
|
||||
126
Data/Scripts/050_Outfits/UI/clothesShop/HairMartAdapter.rb
Normal file
126
Data/Scripts/050_Outfits/UI/clothesShop/HairMartAdapter.rb
Normal file
@@ -0,0 +1,126 @@
|
||||
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_hat = $Trainer.hat
|
||||
@hat_visible=false
|
||||
@removable = true
|
||||
end
|
||||
|
||||
def switchVersion(item, delta=1)
|
||||
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 toggleEvent(item)
|
||||
pbSEPlay("GUI storage put down", 80, 100)
|
||||
toggleHatVisibility()
|
||||
end
|
||||
|
||||
def toggleText()
|
||||
text = ""
|
||||
text << "Color: L / R\n"
|
||||
text << "Hat: D\n"
|
||||
|
||||
end
|
||||
|
||||
def toggleHatVisibility()
|
||||
@hat_visible = !@hat_visible
|
||||
end
|
||||
|
||||
def getPrice(item, selling = nil)
|
||||
return 0 if !@isShop
|
||||
trainerStyleID = getSplitHairFilenameAndVersionFromID($Trainer.hair)[0]
|
||||
return 0 if item == trainerStyleID
|
||||
return nil if itemOwned(item)
|
||||
return item.price.to_i
|
||||
end
|
||||
|
||||
def getDisplayPrice(item, selling = nil)
|
||||
trainerStyleID = getSplitHairFilenameAndVersionFromID($Trainer.hair)[0]
|
||||
return "-" if item == 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)
|
||||
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
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return Settings::BACK_ITEM_ICON_PATH if !item
|
||||
itemId = getCurrentHairId(item.id)
|
||||
return getOverworldHatFilename(item.id)
|
||||
end
|
||||
|
||||
def updateTrainerPreview(item, previewWindow)
|
||||
return if !item
|
||||
displayed_hat = @hat_visible ? @worn_hat : nil
|
||||
previewWindow.hat=displayed_hat
|
||||
$Trainer.hat = displayed_hat
|
||||
itemId = getCurrentHairId(item.id)
|
||||
echoln itemId
|
||||
previewWindow.hair = itemId
|
||||
$Trainer.hair = itemId
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
itemId = getCurrentHairId(item.id)
|
||||
|
||||
changed_clothes = obtainNewHairstyle(itemId)
|
||||
if changed_clothes
|
||||
@worn_clothes = itemId
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_clothes()
|
||||
return $Trainer.hair
|
||||
end
|
||||
|
||||
def putOnOutfit(item)
|
||||
itemFullId = getCurrentHairId(item.id)
|
||||
putOnHair(item.id, @version)
|
||||
@worn_clothes = itemFullId
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
$Trainer.hair = @worn_clothes
|
||||
$Trainer.hat = @worn_hat
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
return $Trainer.unlocked_hairstyles
|
||||
end
|
||||
end
|
||||
66
Data/Scripts/050_Outfits/UI/clothesShop/HairShopPresenter.rb
Normal file
66
Data/Scripts/050_Outfits/UI/clothesShop/HairShopPresenter.rb
Normal file
@@ -0,0 +1,66 @@
|
||||
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)
|
||||
if !price.is_a?(Integer)
|
||||
pbDisplayPaused(_INTL("This is your current hairstyle!"))
|
||||
@adapter.putOnOutfit(item)
|
||||
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
|
||||
75
Data/Scripts/050_Outfits/UI/clothesShop/HatsMartAdapter.rb
Normal file
75
Data/Scripts/050_Outfits/UI/clothesShop/HatsMartAdapter.rb
Normal file
@@ -0,0 +1,75 @@
|
||||
class HatsMartAdapter < OutfitsMartAdapter
|
||||
DEFAULT_NAME = "[unknown]"
|
||||
DEFAULT_DESCRIPTION = "A headgear that trainers can wear."
|
||||
|
||||
def initialize(stock = nil, isShop = nil)
|
||||
super
|
||||
end
|
||||
|
||||
def toggleEvent(item)
|
||||
if !@isShop
|
||||
if pbConfirmMessage(_INTL("Do you want to take off your hat?"))
|
||||
$Trainer.hat = nil
|
||||
@worn_clothes = nil
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def toggleText()
|
||||
return if @isShop
|
||||
toggleKey = "D"#getMappedKeyFor(Input::SPECIAL)
|
||||
return "Remove hat: #{toggleKey}"
|
||||
end
|
||||
|
||||
def getName(item)
|
||||
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
|
||||
end
|
||||
|
||||
def getItemIcon(item)
|
||||
return Settings::BACK_ITEM_ICON_PATH if !item
|
||||
return getOverworldHatFilename(item.id)
|
||||
end
|
||||
|
||||
def updateTrainerPreview(item, previewWindow)
|
||||
return if !item
|
||||
previewWindow.hat = item.id
|
||||
$Trainer.hat = item.id unless $Trainer.hat==nil
|
||||
pbRefreshSceneMap
|
||||
previewWindow.updatePreview()
|
||||
end
|
||||
|
||||
def addItem(item)
|
||||
changed_clothes = obtainNewHat(item.id)
|
||||
if changed_clothes
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
end
|
||||
|
||||
def get_current_clothes()
|
||||
return $Trainer.hat
|
||||
end
|
||||
|
||||
def putOnOutfit(item)
|
||||
putOnHat(item.id)
|
||||
@worn_clothes = item.id
|
||||
end
|
||||
|
||||
def reset_player_clothes()
|
||||
$Trainer.hat = @worn_clothes
|
||||
end
|
||||
|
||||
def get_unlocked_items_list()
|
||||
return $Trainer.unlocked_hats
|
||||
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