release 6.2

This commit is contained in:
infinitefusion
2024-06-28 12:01:39 -04:00
parent 0b9e83f554
commit 3a488c9ba6
7249 changed files with 713866 additions and 136365 deletions

View File

@@ -0,0 +1,242 @@
def find_last_outfit(outfit_type_path, firstOutfit)
for i in firstOutfit..Settings::MAX_NB_OUTFITS
outfit_path = outfit_type_path + "/" + i.to_s #Settings::PLAYER_GRAPHICS_FOLDER + outfit_type_path + "/" + outfit_type_path + "_" + player_sprite + "_" + i.to_s
return i - 1 if !Dir.exist?(outfit_path)
end
return firstOutfit
end
def list_all_numeric_folders(directory_path)
entries = Dir.entries(directory_path)
# Filter out only the directories whose names are numeric (excluding "." and "..")
numeric_folders = entries.select do |entry|
full_path = File.join(directory_path, entry)
File.directory?(full_path) && entry != '.' && entry != '..' && entry.match?(/^\d+$/)
end
# Convert the folder names to integers and store in an array
folder_integers = numeric_folders.map(&:to_i)
folder_integers.sort!
return folder_integers
end
def list_all_numeric_files_with_filter(directory_path, prefix)
entries = Dir.entries(directory_path)
prefixless = []
for file in entries
next if file == "." || file == ".."
prefixless << file.gsub((prefix + "_"), "")
end
folder_integers = prefixless.map(&:to_i)
folder_integers.sort!
return folder_integers
end
#unlocked:
# -1 for all outfits unlocked
# Otherwise, an array of the ids of unlocked outfits
def list_available_outfits(directory, versions = [], unlocked = [], prefix_filter = nil)
if prefix_filter
outfits = list_all_numeric_files_with_filter(directory, prefix_filter)
else
outfits = list_all_numeric_folders(directory)
end
# #echoln outfits
# return outfits #todo: remove this return for unlockable outfits
available_outfits = []
for outfit in outfits
if !unlocked || unlocked.include?(outfit)
for version in versions
available_outfits << outfit.to_s + version
end
available_outfits << outfit.to_s if versions.empty?
end
end
return available_outfits
end
def get_current_outfit_position(currentOutfit_id, available_outfits)
current_index = available_outfits.index(currentOutfit_id)
return current_index.nil? ? 0 : current_index
end
def setHairColor(hue_shift)
$Trainer.hair_color = hue_shift
end
def shiftHatColor(incr)
$Trainer.hat_color = 0 if !$Trainer.hat_color
$Trainer.hat_color += incr
end
def shiftClothesColor(incr)
$Trainer.clothes_color = 0 if !$Trainer.clothes_color
$Trainer.clothes_color += incr
end
def shiftHairColor(incr)
$Trainer.hair_color = 0 if !$Trainer.hair_color
$Trainer.hair_color += incr
end
def pbLoadOutfitBitmap(outfitFileName)
begin
outfitBitmap = RPG::Cache.load_bitmap("", outfitFileName)
return outfitBitmap
rescue
return nil
end
end
def setOutfit(outfit_id)
$Trainer.clothes = outfit_id
end
def setHat(hat_id)
$Trainer.hat = hat_id
end
def getEasterEggHeldItem()
map = $game_map.map_id
return "HOTDOG" if [141, 194].include?(map) #restaurant
return "SNOWBALL" if [670, 693, 698, 694].include?(map)
return "WALLET" if [432, 433, 434, 435, 436, 292].include?(map) #dept. store
return "ALARMCLOCK" if [43, 48, 67, 68, 69, 70, 71, 73].include?(map) #Player room
return "SAFARIBALL" if [445, 484, 485, 486, 107, 487, 488, 717, 82, 75, 74].include?(map) #Safari Zone
return nil
end
def getCurrentPokeball()
otherItem = getEasterEggHeldItem()
return otherItem if otherItem
firstPokemon = $Trainer.party[0]
return firstPokemon.poke_ball if firstPokemon
return nil
end
def generate_front_trainer_sprite_bitmap(pokeball = nil, clothes_id = nil, hat_id = nil, hair_id = nil,
skin_tone_id = nil, hair_color = nil, hat_color = nil, clothes_color = nil)
clothes_id = $Trainer.clothes if !clothes_id
hat_id = $Trainer.hat if !hat_id
hair_id = $Trainer.hair if !hair_id
skin_tone_id = $Trainer.skin_tone if !skin_tone_id
hair_color = $Trainer.hair_color if !hair_color
hat_color = $Trainer.hat_color if !hat_color
clothes_color = $Trainer.clothes_color if !clothes_color
hairFilename = getTrainerSpriteHairFilename(hair_id) #_INTL(Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER + "/hair_trainer_{1}", $Trainer.hair)
outfitFilename = getTrainerSpriteOutfitFilename(clothes_id) #_INTL(Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_CLOTHES_FOLDER + "/clothes_trainer_{1}", $Trainer.clothes)
hatFilename = getTrainerSpriteHatFilename(hat_id) # _INTL(Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER + "/hat_trainer_{1}", $Trainer.hat)
pokeball = getCurrentPokeball if !pokeball
ballFilename = getTrainerSpriteBallFilename(pokeball) if pokeball
baseFilePath = getBaseTrainerSpriteFilename(skin_tone_id)
hair_color_shift = hair_color
hat_color_shift = hat_color
clothes_color_shift = clothes_color
hair_color_shift = 0 if !hair_color_shift
hat_color_shift = 0 if !hat_color_shift
clothes_color_shift = 0 if !clothes_color_shift
baseBitmap = AnimatedBitmap.new(baseFilePath) if pbResolveBitmap(baseFilePath)
ballBitmap = pbLoadOutfitBitmap(ballFilename) if pbResolveBitmap(ballFilename)
if !pbResolveBitmap(outfitFilename)
outfitFilename = getTrainerSpriteOutfitFilename(Settings::PLAYER_TEMP_OUTFIT_FALLBACK)
end
if !pbResolveBitmap(outfitFilename)
raise "No temp clothes graphics available"
end
outfitBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift) # if pbResolveBitmap(outfitFilename) #pb
hairBitmapWrapper = AnimatedBitmap.new(hairFilename, hair_color_shift) if pbResolveBitmap(hairFilename)
hatBitmap = AnimatedBitmap.new(hatFilename, hat_color_shift) if pbResolveBitmap(hatFilename) #pbLoadOutfitBitmap(hatFilename) if pbResolveBitmap(hatFilename)
baseBitmap.bitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect) if outfitBitmap
baseBitmap.bitmap.blt(0, 0, hairBitmapWrapper.bitmap, hairBitmapWrapper.bitmap.rect) if hairBitmapWrapper
baseBitmap.bitmap.blt(0, 0, hatBitmap.bitmap, hatBitmap.bitmap.rect) if hatBitmap
baseBitmap.bitmap.blt(44, 42, ballBitmap, ballBitmap.rect) if ballBitmap
return baseBitmap
end
def generateClothedBitmapStatic(trainer, action = "walk")
baseBitmapFilename = getBaseOverworldSpriteFilename(action, trainer.skin_tone)
if !pbResolveBitmap(baseBitmapFilename)
baseBitmapFilename = Settings::PLAYER_GRAPHICS_FOLDER + action
end
baseSprite = AnimatedBitmap.new(baseBitmapFilename)
baseBitmap = baseSprite.bitmap.clone #nekkid sprite
outfitFilename = getOverworldOutfitFilename(trainer.clothes, action) #
outfitFilename = getOverworldOutfitFilename(Settings::PLAYER_TEMP_OUTFIT_FALLBACK) if !pbResolveBitmap(outfitFilename)
hairFilename = getOverworldHairFilename(trainer.hair)
hatFilename = getOverworldHatFilename(trainer.hat)
hair_color_shift = trainer.hair_color
hat_color_shift = trainer.hat_color
clothes_color_shift = trainer.clothes_color
hair_color_shift = 0 if !hair_color_shift
hat_color_shift = 0 if !hat_color_shift
clothes_color_shift = 0 if !clothes_color_shift
#@hat.update(@character_name, hatFilename,hat_color_shift) if @hat
if !pbResolveBitmap(outfitFilename)
outfitFilename = Settings::PLAYER_TEMP_OUTFIT_FALLBACK
end
outfitBitmap = AnimatedBitmap.new(outfitFilename, clothes_color_shift) # if pbResolveBitmap(outfitFilename) #pbLoadOutfitBitmap(outfitFilename) if pbResolveBitmap(outfitFilename)
hairBitmapWrapper = AnimatedBitmap.new(hairFilename, hair_color_shift) if pbResolveBitmap(hairFilename)
baseBitmap.blt(0, 0, outfitBitmap.bitmap, outfitBitmap.bitmap.rect) if outfitBitmap
#baseBitmap.blt(0, 0, hairBitmapWrapper.bitmap, hairBitmapWrapper.bitmap.rect)
current_offset = 0 #getCurrentSpriteOffset()
positionHair(baseBitmap, hairBitmapWrapper.bitmap, current_offset) if hairBitmapWrapper
#baseBitmap.blt(0, 0, hatBitmap, hatBitmap.rect) if hatBitmap
return baseBitmap
end
def positionHair(baseBitmap, hairBirmap, offset)
baseBitmap.blt(offset[0], offset[1], hairBirmap, hairBirmap.rect)
end
def add_hat_to_bitmap(bitmap, hat_id, x_pos, y_pos, scale = 1, mirrored = false)
base_scale = 1.5 #coz hat & poke sprites aren't the same size
adjusted_scale = base_scale * scale
hat_filename = getTrainerSpriteHatFilename(hat_id)
hatBitmapWrapper = AnimatedBitmap.new(hat_filename, 0) if pbResolveBitmap(hat_filename)
hatBitmapWrapper.scale_bitmap(adjusted_scale) if hatBitmapWrapper
hatBitmapWrapper.mirror if mirrored
bitmap.blt(x_pos * adjusted_scale, y_pos * adjusted_scale, hatBitmapWrapper.bitmap, hatBitmapWrapper.bitmap.rect) if hatBitmapWrapper
end
class PokemonTemp
attr_accessor :trainer_preview
end
def display_outfit_preview(x = 320, y = 0, withBorder = true)
hide_outfit_preview() if $PokemonTemp.trainer_preview
$PokemonTemp.trainer_preview = TrainerClothesPreview.new(x, y, withBorder)
$PokemonTemp.trainer_preview.show()
end
def hide_outfit_preview()
$game_screen.pictures[20].erase
$PokemonTemp.trainer_preview.erase() if $PokemonTemp.trainer_preview
$PokemonTemp.trainer_preview = nil
end

View File

@@ -0,0 +1,114 @@
class OutfitSelector
attr_reader :clothes_list
attr_reader :hats_list
attr_reader :hairstyles_list
def initialize()
@clothes_list = parse_clothes_folder()
@hats_list = parse_hats_folder()
@hairstyles_list =parse_hairstyles_folder()
end
def parse_clothes_folder
return list_folders(get_clothes_sets_list_path())
end
def parse_hats_folder
return list_folders(get_hats_sets_list_path())
end
def parse_hairstyle_types_folder
return list_folders(get_hair_sets_list_path())
end
def parse_hairstyles_folder
hairstyle_types= list_folders(get_hair_sets_list_path())
max_versions_number = 10
list= []
for hairstyle in hairstyle_types
for i in 1..max_versions_number
type = i.to_s + "_" + hairstyle
filePath = getOverworldHairFilename(type)
if pbResolveBitmap(filePath)
list << type
end
end
end
return list
end
def list_folders(path)
entries= Dir.entries(path)
return entries.select { |entry| File.directory?(File.join(path, entry)) && entry != '.' && entry != '..' }
end
def filter_unlocked_outfits(outfits_list,unlocked_outfits)
available_outfits = []
outfits_list.each do |outfit|
available_outfits << outfit if unlocked_outfits.include?(outfit)
end
return available_outfits
end
def selectNextOutfit(currentOutfit, incr, outfits_list, versions = [], allowNone = true, prefix_filter = nil,unlockedOutfits=[],everythingUnlocked=false)
available_outfits = []
available_outfits = outfits_list if everythingUnlocked
available_outfits << "" if allowNone
available_outfits += filter_unlocked_outfits(outfits_list,unlockedOutfits) if !everythingUnlocked
#available_outfits += list_available_outfits(directory, versions, unlockedOutfits, prefix_filter) #unlockedOutfits = nil for all outfits unlocked
last_outfit = available_outfits[-1]
current_outfit_index = get_current_outfit_position(currentOutfit, available_outfits)
next_outfit_index = current_outfit_index +incr
nextOutfit = available_outfits[next_outfit_index]
nextOutfit = last_outfit if next_outfit_index < 0
nextOutfit = available_outfits[0] if next_outfit_index >= available_outfits.length()
return nextOutfit if available_outfits.include?(nextOutfit)
return currentOutfit
end
def changeToNextClothes(incr,all_unlocked=false)
$Trainer.unlocked_clothes = [] if !$Trainer.unlocked_clothes
currentOutfit = $Trainer.clothes
currentOutfit = 0 if !currentOutfit
nextOutfit = selectNextOutfit(currentOutfit, incr, @clothes_list, [], false,nil,$Trainer.unlocked_clothes,all_unlocked)
$Trainer.clothes = nextOutfit
$Trainer.clothes_color = 0
echoln $Trainer.clothes
end
def changeToNextHat(incr,all_unlocked=false)
$Trainer.unlocked_hats = [] if !$Trainer.unlocked_hats
currentHat = $Trainer.hat
currentHat = 0 if !currentHat
nextOutfit = selectNextOutfit(currentHat, incr, @hats_list, [], true, "hat",$Trainer.unlocked_hats,all_unlocked)
$Trainer.hat = nextOutfit
$Trainer.hat_color = 0
echoln $Trainer.hat
end
def changeToNextHairstyle(incr,all_unlocked=false)
$Trainer.unlocked_hairstyles = [] if !$Trainer.unlocked_hairstyles
currentHair = $Trainer.hair
currentHair = 0 if !currentHair
nextOutfit = selectNextOutfit(currentHair, incr, @hairstyles_list, ["a", "b", "c", "d"], true,nil,$Trainer.unlocked_hairstyles,all_unlocked)
$Trainer.hair_color = 0
$Trainer.hair = nextOutfit
echoln $Trainer.hair
end
end

View File

@@ -0,0 +1,75 @@
class PokemonGlobalMetadata
attr_accessor :hats_data
attr_accessor :hairstyles_data
attr_accessor :clothes_data
end
def update_global_hats_list()
file_path = Settings::HATS_DATA_PATH
json_data = File.read(file_path)
hat_data = HTTPLite::JSON.parse(json_data)
$PokemonGlobal.hats_data = {}
# Iterate through the JSON data and create Hat objects
hat_data.each do |data|
tags = data['tags'] ? data['tags'].split(',') : []
hat = Hat.new(
data['id'],
data['name'],
data['description'],
data['price'],
tags
)
$PokemonGlobal.hats_data[hat.id] = hat
end
end
def update_global_hairstyles_list()
file_path = Settings::HAIRSTYLE_DATA_PATH
json_data = File.read(file_path)
hair_data = HTTPLite::JSON.parse(json_data)
$PokemonGlobal.hairstyles_data = {}
# Iterate through the JSON data and create Hat objects
hair_data.each do |data|
tags = data['tags'] ? data['tags'].split(',') : []
hair = Hairstyle.new(
data['id'],
data['name'],
data['description'],
data['price'],
tags
)
$PokemonGlobal.hairstyles_data[hair.id] = hair
end
end
def update_global_clothes_list()
file_path = Settings::CLOTHES_DATA_PATH
json_data = File.read(file_path)
outfits_data = HTTPLite::JSON.parse(json_data)
$PokemonGlobal.clothes_data = {}
# Iterate through the JSON data and create Hat objects
outfits_data.each do |data|
tags = data['tags'] ? data['tags'].split(',') : []
outfit = Clothes.new(
data['id'],
data['name'],
data['description'],
data['price'],
tags
)
$PokemonGlobal.clothes_data[outfit.id] = outfit
end
end
def update_global_outfit_lists()
update_global_hats_list
update_global_hairstyles_list
update_global_clothes_list
end

View File

@@ -0,0 +1,99 @@
#CLOTHES
def search_clothes(matching_tags = [], only_unlocked = false)
update_global_outfit_lists()
selector = OutfitSelector.new
full_data_list = $PokemonGlobal.clothes_data
existing_files_list = selector.parse_clothes_folder()
unlocked_list = $Trainer.unlocked_clothes
return search_outfits_by_tag(full_data_list, matching_tags, existing_files_list, unlocked_list, only_unlocked)
end
def filter_clothes(filter_tags = [], only_unlocked = false)
update_global_outfit_lists()
selector = OutfitSelector.new
full_data_list = $PokemonGlobal.hats_data
existing_files_list = selector.parse_hats_folder()
unlocked_list = $Trainer.unlocked_hats
return filter_outfits_by_tag(full_data_list, filter_tags, existing_files_list, unlocked_list, only_unlocked)
end
#HATS
def search_hats(matching_tags = [], only_unlocked = false)
update_global_outfit_lists()
selector = OutfitSelector.new
full_data_list = $PokemonGlobal.hats_data
existing_files_list = selector.parse_hats_folder()
unlocked_list = $Trainer.unlocked_hats
return search_outfits_by_tag(full_data_list, matching_tags, existing_files_list, unlocked_list, only_unlocked)
end
def filter_hats(filter_tags = [], only_unlocked = false)
update_global_outfit_lists()
selector = OutfitSelector.new
full_data_list = $PokemonGlobal.hats_data
existing_files_list = selector.parse_hats_folder()
echoln existing_files_list
unlocked_list = $Trainer.unlocked_hats
return filter_outfits_by_tag(full_data_list, filter_tags, existing_files_list, unlocked_list, only_unlocked)
end
# Generic searching methods
#Get outfits that have ANY of the tags
def search_outfits_by_tag(outfits_map, matching_tags = [], physical_files_list = [], unlocked_list = [], require_unlocked = false)
filtered_list = []
outfits_map.each do |outfit_id, outfit|
if outfit.tags.any? { |tag| matching_tags.include?(tag) }
filtered_list << outfit_id if outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
end
end
return filtered_list
end
#Get outfits that have ALL of the tags
def filter_outfits_by_tag(outfits_map, filter_tags = [], physical_files_list = [], unlocked_list = [], require_unlocked = false)
update_global_outfit_lists()
filtered_list = []
outfits_map.each do |outfit_id, outfit|
if filter_tags.all? { |tag| outfit.tags.include?(tag) }
filtered_list << outfit_id if outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
end
end
return filtered_list
end
def outfit_is_valid?(outfit_id, physical_files_list, unlocked_list, require_unlocked)
return false if require_unlocked && !unlocked_list.include?(outfit_id)
return physical_files_list.include?(outfit_id)
end
def add_tags(tags_list=[])
newTag=pbEnterText("add tag",0,10)
return tags_list if newTag.length == 0
tags_list << newTag
return tags_list
end
def get_clothes_by_id(id)
update_global_outfit_lists()
return $PokemonGlobal.clothes_data.has_key?(id) ? $PokemonGlobal.clothes_data[id] : nil
end
def get_hat_by_id(id)
update_global_outfit_lists()
return $PokemonGlobal.hats_data.has_key?(id) ? $PokemonGlobal.hats_data[id] : nil
end
def get_hair_by_id(id)
update_global_outfit_lists()
return $PokemonGlobal.hairstyles_data.has_key?(id) ? $PokemonGlobal.hairstyles_data[id] : nil
end

View 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

View 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

View 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

View 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

View 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

View 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

View File

@@ -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

View File

@@ -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

View 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

View File

@@ -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

View 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

View 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

View 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

View 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

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,131 @@
#Naked sprites
BASE_FOLDER = "base"
BASE_OVERWORLD_FOLDER = "overworld"
BASE_TRAINER_FOLDER = "trainer"
def getBaseOverworldSpriteFilename(action = "walk", skinTone = "default")
base_path = Settings::PLAYER_GRAPHICS_FOLDER + BASE_FOLDER + "/" + BASE_OVERWORLD_FOLDER
dynamic_path = _INTL("/{1}/{2}_{1}", skinTone, action)
full_path = base_path + dynamic_path
return full_path if pbResolveBitmap(full_path)
return getBaseOverworldSpriteFilename(action) if skinTone != "default" #try again with default skintone
return nil
end
def getBaseTrainerSpriteFilename(skinTone = "default")
base_path = Settings::PLAYER_GRAPHICS_FOLDER + BASE_FOLDER + "/" + BASE_TRAINER_FOLDER
dynamic_path = _INTL("/{1}_{2}", BASE_TRAINER_FOLDER, skinTone)
full_path = base_path + dynamic_path
return full_path if pbResolveBitmap(full_path)
return getBaseTrainerSpriteFilename() #default skintone
end
### OUTFIT #
def get_clothes_sets_list_path()
return Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_CLOTHES_FOLDER
end
def getOverworldOutfitFilename(outfit_id, action="walk")
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_CLOTHES_FOLDER
dynamic_path = _INTL("/{1}/", outfit_id)
filename = _INTL(Settings::PLAYER_CLOTHES_FOLDER + "_{1}_{2}", action, outfit_id)
full_path = base_path + dynamic_path + filename
#echoln full_path
return full_path
end
def getTrainerSpriteOutfitFilename(outfit_id)
return getOverworldOutfitFilename(outfit_id, BASE_TRAINER_FOLDER)
end
#### HAIR
def get_hair_sets_list_path()
return Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER
end
# Input: red_a
# Output: ["1","red"]
def getSplitHairFilenameAndVersionFromID(hairstyle_id)
return "" if !hairstyle_id
hairstyle_id= hairstyle_id.to_s
return hairstyle_id.split("_")
end
def getFullHairId(hairstyle,version)
return _INTL("{1}_{2}",version,hairstyle)
end
def getOverworldHairFilename(hairstyle_id)
# matches = hairstyle_id.to_s.match(/\A(\d+)([A-Za-z])?\z/)
# return "" if !matches
# hair_id = matches[1]
# version = matches.length > 1 ? matches[2] : "a"
hairstyle_split = getSplitHairFilenameAndVersionFromID(hairstyle_id)
name= hairstyle_split[-1]
version= hairstyle_split[-2]
# match_data = hairstyle_id.match(/(\d+)_/)
# version = match_data[0].to_i if match_data
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER
dynamic_path = _INTL("/{1}/", name)
filename = _INTL(Settings::PLAYER_HAIR_FOLDER + "_{1}_{2}",version, name)
#filename += version if version
full_path = base_path + dynamic_path + filename
return full_path
end
def getTrainerSpriteHairFilename(hairstyle_id)
# matches = hairstyle_id.to_s.match(/\A(\d+)([A-Za-z])?\z/)
# return "" if !matches
# hair_id = matches[1]
# version = matches.length > 1 ? matches[2] : "a"
return "" if !hairstyle_id
hairstyle_id= hairstyle_id.to_s
hairstyle_split= hairstyle_id.split("_")
name= hairstyle_split[-1]
version= hairstyle_split[-2]
# match_data = hairstyle_id.match(/(\d+)_/)
# version = match_data[0].to_i if match_data
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAIR_FOLDER
dynamic_path = _INTL("/{1}/", name)
filename = _INTL(Settings::PLAYER_HAIR_FOLDER + "_trainer_{1}_{2}",version, name)
#filename += version if version
full_path = base_path + dynamic_path + filename
return full_path
end
#### HATS
#
def get_hats_sets_list_path()
return Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER
end
def getOverworldHatFilename(hat_id)
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER
dynamic_path = _INTL("/{1}/", hat_id)
filename = _INTL(Settings::PLAYER_HAT_FOLDER + "_{1}", hat_id)
full_path = base_path + dynamic_path + filename
return full_path
end
def getTrainerSpriteHatFilename(hat_id)
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_HAT_FOLDER
dynamic_path = _INTL("/{1}/", hat_id)
filename = _INTL(Settings::PLAYER_HAT_FOLDER + "_trainer_{1}", hat_id)
full_path = base_path + dynamic_path + filename
return full_path
end
def getTrainerSpriteBallFilename(pokeball)
base_path = Settings::PLAYER_GRAPHICS_FOLDER + Settings::PLAYER_BALL_FOLDER
return base_path + "/" + pokeball.to_s
end

View File

@@ -0,0 +1,96 @@
def obtainNewHat(outfit_id)
echoln "obtained new hat: " + outfit_id
outfit = get_hat_by_id(outfit_id)
$Trainer.unlocked_hats << outfit_id if !$Trainer.unlocked_hats.include?(outfit_id)
obtainOutfitMessage(outfit)
if pbConfirmMessage("Would you like to put it on right now?")
putOnHat(outfit_id)
return true
end
return false
end
def obtainNewClothes(outfit_id)
echoln "obtained new clothes: " + outfit_id
outfit = get_clothes_by_id(outfit_id)
$Trainer.unlocked_clothes << outfit_id if !$Trainer.unlocked_clothes.include?(outfit_id)
obtainOutfitMessage(outfit)
if pbConfirmMessage("Would you like to put it on right now?")
putOnClothes(outfit_id)
return true
end
return false
end
def obtainNewHairstyle(full_outfit_id)
split_outfit_id =getSplitHairFilenameAndVersionFromID(full_outfit_id)
hairstyle_id =split_outfit_id[1]
hairstyle_version= split_outfit_id[0]
outfit = get_hair_by_id(hairstyle_id)
$Trainer.unlocked_clothes << hairstyle_id if !$Trainer.unlocked_hairstyles.include?(hairstyle_id)
musical_effect = "Key item get"
pbMessage(_INTL("\\me[{1}]Your hairstyle was changed to \\c[1]{2}\\c[0] hairstyle!\\wtnp[30]", musical_effect, outfit.name))
# pbMessage(_INTL("\\me[{1}]You obtained the \\c[1]{2}\\c[0] hairstyle!\\wtnp[30]", musical_effect, outfit.name))
# if pbConfirmMessage("Would you like to use this hairstyle right now?")
# putOnHair(hairstyle_id,hairstyle_version)
# return true
# end
return false
end
def putOnClothes(outfit_id)
outfit = get_clothes_by_id(outfit_id)
$Trainer.clothes = outfit_id
putOnOutfitMessage(outfit)
end
def putOnHat(outfit_id)
outfit = get_hat_by_id(outfit_id)
$Trainer.hat = outfit_id
putOnOutfitMessage(outfit)
end
def putOnHairFullId(full_outfit_id)
outfit_id = getSplitHairFilenameAndVersionFromID(full_outfit_id)[1]
outfit = get_hair_by_id(outfit_id)
$Trainer.hair = getFullHairId(full_outfit_id)
putOnOutfitMessage(outfit)
end
def putOnHair(outfit_id, version)
#outfit = get_hair_by_id(outfit_id)
$Trainer.hair = getFullHairId(outfit_id,version)
#putOnOutfitMessage(outfit)
end
#todo: add a little preview window?
def obtainOutfitMessage(outfit)
musical_effect = "Key item get"
pbMessage(_INTL("\\me[{1}]You obtained a \\c[1]{2}\\c[0]!\\wtnp[30]", musical_effect, outfit.name))
end
def putOnOutfitMessage(outfit)
playOutfitChangeAnimation()
pbMessage(_INTL("You put on the \\c[1]{1}\\c[0]!\\wtnp[30]", outfit.name))
end
def refreshPlayerOutfit()
return if !$scene.spritesetGlobal
$scene.spritesetGlobal.playersprite.refreshOutfit()
end
def findLastHairVersion(hairId)
possible_versions = (1..9).to_a
last_version = 0
possible_versions.each { |version|
hair_id = getFullHairId(hairId, version)
if pbResolveBitmap(getOverworldHairFilename(hair_id))
last_version = version
else
return last_version
end
}
return last_version
end

View File

@@ -0,0 +1,15 @@
class Outfit
attr_accessor :id
attr_accessor :name
attr_accessor :description
attr_accessor :tags
attr_accessor :price
def initialize(id, name, description = '',price=0, tags = [])
@id = id
@name = name
@description = description
@tags = tags
@price = price
end
end

View File

@@ -0,0 +1,5 @@
class Clothes < Outfit
def initialize(id, name, description = '',price=0, tags = [])
super
end
end

View File

@@ -0,0 +1,5 @@
class Hairstyle < Outfit
def initialize(id, name, description = '',price=0, tags = [])
super
end
end

View File

@@ -0,0 +1,5 @@
class Hat < Outfit
def initialize(id,name,description='',price=0,tags=[])
super
end
end