mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-22 06:06:01 +00:00
Created and implemented GameData::TrainerType, fixed free text entry text mispositioning
This commit is contained in:
@@ -218,135 +218,134 @@ end
|
||||
#===============================================================================
|
||||
# Trainer type editor
|
||||
#===============================================================================
|
||||
def pbTrainerTypeEditorNew(trconst)
|
||||
data = pbLoadTrainerTypesData
|
||||
# Get the first unused ID after all existing t-types for the new t-type to use.
|
||||
maxid = -1
|
||||
for rec in data
|
||||
next if !rec
|
||||
maxid = rec[0] if rec[0]>maxid
|
||||
end
|
||||
trainertype = maxid+1
|
||||
trname = pbMessageFreeText(_INTL("Please enter the trainer type's name."),
|
||||
(trconst) ? trconst.gsub(/_+/," ") : "",false,30)
|
||||
return -1 if trname=="" && !trconst
|
||||
# Create an internal name based on the trainer type's name if there is none.
|
||||
trconst = trname if !trconst
|
||||
trconst = trconst.gsub(/é/,"e")
|
||||
trconst = trconst.gsub(/[^A-Za-z0-9_]/,"")
|
||||
trconst = trconst.upcase
|
||||
if trconst.length==0
|
||||
trconst = sprintf("T_%03d",trainertype)
|
||||
elsif !trconst[0,1][/[A-Z]/]
|
||||
trconst = "T_"+trconst
|
||||
end
|
||||
# Create a default name if there is none.
|
||||
trname = trconst if trname==""
|
||||
cname = trconst
|
||||
if hasConst?(PBTrainers,cname)
|
||||
suffix = 1
|
||||
100.times do
|
||||
tname = sprintf("%s_%d",cname,suffix)
|
||||
if !hasConst?(PBTrainers,tname)
|
||||
cname = tname
|
||||
break
|
||||
end
|
||||
suffix += 1
|
||||
end
|
||||
end
|
||||
if hasConst?(PBTrainers,cname)
|
||||
pbMessage(_INTL("Failed to create the trainer type. Choose a different name."))
|
||||
return -1
|
||||
end
|
||||
record = []
|
||||
record[0] = trainertype
|
||||
record[1] = cname
|
||||
record[2] = trname
|
||||
record[7] = pbMessage(_INTL("Is the Trainer male, female, or mixed gender?"),[
|
||||
_INTL("Male"),_INTL("Female"),_INTL("Mixed")],0)
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0,255)
|
||||
params.setDefaultValue(30)
|
||||
record[3] = pbMessageChooseNumber(_INTL("Set the money per level won for defeating the Trainer."),params)
|
||||
record[8] = record[3]
|
||||
record[9] = ""
|
||||
PBTrainers.const_set(cname,record[0])
|
||||
data[record[0]] = record
|
||||
save_data(data,"Data/trainer_types.dat")
|
||||
$PokemonTemp.trainerTypesData = nil
|
||||
pbConvertTrainerData
|
||||
pbMessage(_INTL("The Trainer type was created (ID: {1}).",record[0]))
|
||||
pbMessage(_ISPRINTF("Put the Trainer's graphic (trainer{1:03d}.png or trainer{2:s}.png) in Graphics/Characters, or it will be blank.",
|
||||
record[0],getConstantName(PBTrainers,record[0])))
|
||||
return record[0]
|
||||
end
|
||||
|
||||
def pbTrainerTypeEditorSave(trainertype,ttdata)
|
||||
record = []
|
||||
record[0] = trainertype
|
||||
for i in 0..ttdata.length
|
||||
record.push(ttdata[i])
|
||||
end
|
||||
setConstantName(PBTrainers,trainertype,ttdata[0])
|
||||
data = pbLoadTrainerTypesData
|
||||
data[record[0]] = record
|
||||
save_data(data,"Data/trainer_types.dat")
|
||||
$PokemonTemp.trainerTypesData = nil
|
||||
pbConvertTrainerData
|
||||
end
|
||||
|
||||
def pbTrainerTypeEditor
|
||||
selection = 0
|
||||
trainerTypes = [
|
||||
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that appears in constructs like PBTrainers::XXX.")],
|
||||
trainer_types = [
|
||||
[_INTL("Internal Name"), ReadOnlyProperty, _INTL("Internal name that is used as a symbol like :XXX.")],
|
||||
[_INTL("Trainer Name"), StringProperty, _INTL("Name of the trainer type as displayed by the game.")],
|
||||
[_INTL("Money Per Level"), LimitProperty.new(9999), _INTL("Player earns this amount times the highest level among the trainer's Pokémon.")],
|
||||
[_INTL("Base Money"), LimitProperty.new(9999), _INTL("Player earns this much money times the highest level among the trainer's Pokémon.")],
|
||||
[_INTL("Battle BGM"), BGMProperty, _INTL("BGM played in battles against trainers of this type.")],
|
||||
[_INTL("Battle End ME"), MEProperty, _INTL("ME played when player wins battles against trainers of this type.")],
|
||||
[_INTL("Battle Intro ME"), MEProperty, _INTL("ME played before battles against trainers of this type.")],
|
||||
[_INTL("Gender"), EnumProperty.new([
|
||||
_INTL("Male"),_INTL("Female"),_INTL("Mixed gender")]),
|
||||
_INTL("Male"), _INTL("Female"), _INTL("Undefined")]),
|
||||
_INTL("Gender of this Trainer type.")],
|
||||
[_INTL("Skill"), LimitProperty.new(9999), _INTL("Skill level of this Trainer type.")],
|
||||
[_INTL("Skill Codes"), StringProperty, _INTL("Letters/phrases representing AI modifications of trainers of this type.")],
|
||||
[_INTL("Skill Level"), LimitProperty.new(9999), _INTL("Skill level of this Trainer type.")],
|
||||
[_INTL("Skill Code"), StringProperty, _INTL("Letters/phrases representing AI modifications of trainers of this type.")],
|
||||
]
|
||||
pbListScreenBlock(_INTL("Trainer Types"),TrainerTypeLister.new(selection,true)) { |button,trtype|
|
||||
if trtype
|
||||
pbListScreenBlock(_INTL("Trainer Types"), TrainerTypeLister.new(selection, true)) { |button, tr_type|
|
||||
if tr_type
|
||||
if button==Input::A
|
||||
if trtype[0]>=0
|
||||
if tr_type.is_a?(Symbol)
|
||||
if pbConfirmMessageSerious("Delete this trainer type?")
|
||||
data = pbLoadTrainerTypesData
|
||||
removeConstantValue(PBTrainers,trtype[0])
|
||||
data[trtype[0]] = nil
|
||||
save_data(data,"Data/trainer_types.dat")
|
||||
$PokemonTemp.trainerTypesData = nil
|
||||
id_number = GameData::TrainerType.get(tr_type).id_number
|
||||
GameData::TrainerType::DATA.delete(tr_type)
|
||||
GameData::TrainerType::DATA.delete(id_number)
|
||||
GameData::TrainerType.save
|
||||
pbConvertTrainerData
|
||||
pbMessage(_INTL("The Trainer type was deleted."))
|
||||
end
|
||||
end
|
||||
elsif button==Input::C
|
||||
selection = trtype[0]
|
||||
if selection<0
|
||||
newid = pbTrainerTypeEditorNew(nil)
|
||||
if newid>=0
|
||||
selection = newid
|
||||
end
|
||||
else
|
||||
data = []
|
||||
for i in 1..trtype.length
|
||||
data.push(trtype[i])
|
||||
end
|
||||
# trtype[2] contains trainer's name to display as title
|
||||
save = pbPropertyList(trtype[2],data,trainerTypes,true)
|
||||
if save
|
||||
pbTrainerTypeEditorSave(selection,data)
|
||||
elsif button == Input::C
|
||||
if tr_type.is_a?(Symbol)
|
||||
t_data = GameData::TrainerType.get(tr_type)
|
||||
data = [
|
||||
t_data.id.to_s,
|
||||
t_data.real_name,
|
||||
t_data.base_money,
|
||||
t_data.battle_BGM,
|
||||
t_data.victory_ME,
|
||||
t_data.intro_ME,
|
||||
t_data.gender,
|
||||
t_data.skill_level,
|
||||
t_data.skill_code
|
||||
]
|
||||
if pbPropertyList(t_data.id.to_s, data, trainer_types, true)
|
||||
# Construct trainer type hash
|
||||
type_hash = {
|
||||
:id_number => t_data.id_number,
|
||||
:id => t_data.id,
|
||||
:name => line[1],
|
||||
:base_money => line[2],
|
||||
:battle_BGM => line[3],
|
||||
:victory_ME => line[4],
|
||||
:intro_ME => line[5],
|
||||
:gender => line[6],
|
||||
:skill_level => line[7],
|
||||
:skill_code => line[8]
|
||||
}
|
||||
# Add trainer type's data to records
|
||||
GameData::TrainerType::DATA[t_data.id_number] = GameData::TrainerType::DATA[t_data.id] = GameData::TrainerType.new(type_hash)
|
||||
GameData::TrainerType.save
|
||||
pbConvertTrainerData
|
||||
end
|
||||
else # Add a new trainer type
|
||||
pbTrainerTypeEditorNew(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def pbTrainerTypeEditorNew(default_name)
|
||||
# Get an unused ID number for the new item
|
||||
max_id = 0
|
||||
GameData::TrainerType.each { |t| max_id = t.id_number if max_id < t.id_number }
|
||||
id_number = max_id + 1
|
||||
# Choose a name
|
||||
name = pbMessageFreeText(_INTL("Please enter the trainer type's name."),
|
||||
(default_name) ? default_name.gsub(/_+/, " ") : "", false, 30)
|
||||
if name == ""
|
||||
return nil if !default_name
|
||||
name = default_name
|
||||
end
|
||||
# Generate an ID based on the item name
|
||||
id = name.gsub(/é/, "e")
|
||||
id = id.gsub(/[^A-Za-z0-9_]/, "")
|
||||
id = id.upcase
|
||||
if id.length == 0
|
||||
id = sprintf("T_%03d", id_number)
|
||||
elsif !id[0, 1][/[A-Z]/]
|
||||
id = "T_" + id
|
||||
end
|
||||
if GameData::TrainerType.exists?(id)
|
||||
for i in 1..100
|
||||
trial_id = sprintf("%s_%d", id, i)
|
||||
next if GameData::TrainerType.exists?(trial_id)
|
||||
id = trial_id
|
||||
break
|
||||
end
|
||||
end
|
||||
if GameData::TrainerType.exists?(id)
|
||||
pbMessage(_INTL("Failed to create the trainer type. Choose a different name."))
|
||||
return nil
|
||||
end
|
||||
# Choose a gender
|
||||
gender = pbMessage(_INTL("Is the Trainer male, female or undefined?"), [
|
||||
_INTL("Male"), _INTL("Female"), _INTL("Undefined")], 0)
|
||||
# Choose a base money value
|
||||
params = ChooseNumberParams.new
|
||||
params.setRange(0, 255)
|
||||
params.setDefaultValue(30)
|
||||
base_money = pbMessageChooseNumber(_INTL("Set the money per level won for defeating the Trainer."), params)
|
||||
# Construct trainer type hash
|
||||
tr_type_hash = {
|
||||
:id_number => id_number,
|
||||
:id => id.to_sym,
|
||||
:name => name,
|
||||
:base_money => base_money,
|
||||
:gender => gender
|
||||
}
|
||||
# Add trainer type's data to records
|
||||
GameData::TrainerType::DATA[id_number] = GameData::TrainerType::DATA[id.to_sym] = GameData::TrainerType.new(tr_type_hash)
|
||||
GameData::TrainerType.save
|
||||
pbConvertTrainerData
|
||||
pbMessage(_INTL("The trainer type {1} was created (ID: {2}).", name, id.to_s))
|
||||
pbMessage(_ISPRINTF("Put the Trainer's graphic (trainer{1:s}.png or trainer{2:03d}.png) in Graphics/Trainers, or it will be blank.",
|
||||
id, id_number))
|
||||
return id.to_sym
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
@@ -391,13 +390,11 @@ end
|
||||
|
||||
def pbTrainerBattleEditor
|
||||
selection = 0
|
||||
trainertypes = pbLoadTrainerTypesData
|
||||
trainers = pbLoadTrainersData
|
||||
trainers = pbLoadTrainersData
|
||||
modified = false
|
||||
for trainer in trainers
|
||||
trtype = trainer[0]
|
||||
next if trainertypes && trainertypes[trtype]
|
||||
trainer[0] = 0
|
||||
next if GameData::TrainerType.exists?(trainer[0])
|
||||
trainer[0] = nil
|
||||
modified = true
|
||||
end
|
||||
pbListScreenBlock(_INTL("Trainer Battles"),TrainerBattleLister.new(selection,true)) { |button,trtype|
|
||||
@@ -418,22 +415,19 @@ def pbTrainerBattleEditor
|
||||
selection = index
|
||||
if selection<0
|
||||
# New trainer
|
||||
trainertype = -1
|
||||
ret = pbMessage(_INTL("First, define the type of trainer."),[
|
||||
trainertype = nil
|
||||
ret = pbMessage(_INTL("First, define the new trainer's type."),[
|
||||
_INTL("Use existing type"),
|
||||
_INTL("Use new type"),
|
||||
_INTL("Cancel")],3)
|
||||
_INTL("Create new type"),
|
||||
_INTL("Cancel")], 3)
|
||||
if ret==0
|
||||
trainertype = pbListScreen(_INTL("TRAINER TYPE"),TrainerTypeLister.new(0,false))
|
||||
next if !trainertype
|
||||
trainertype = trainertype[0]
|
||||
next if trainertype<0
|
||||
elsif ret==1
|
||||
trainertype = pbTrainerTypeEditorNew(nil)
|
||||
next if trainertype<0
|
||||
else
|
||||
next
|
||||
end
|
||||
next if !trainertype
|
||||
trainername = pbMessageFreeText(_INTL("Now enter the trainer's name."),"",false,30)
|
||||
next if trainername==""
|
||||
trainerparty = pbGetFreeTrainerParty(trainertype,trainername)
|
||||
@@ -670,7 +664,7 @@ def pbItemEditor
|
||||
]
|
||||
pbListScreenBlock(_INTL("Items"), ItemLister.new(selection, true)) { |button, item|
|
||||
if item
|
||||
if button==Input::A
|
||||
if button == Input::A
|
||||
if item.is_a?(Symbol)
|
||||
if pbConfirmMessageSerious("Delete this item?")
|
||||
id_number = GameData::Item.get(item).id_number
|
||||
@@ -681,7 +675,7 @@ def pbItemEditor
|
||||
pbMessage(_INTL("The item was deleted."))
|
||||
end
|
||||
end
|
||||
elsif button==Input::C
|
||||
elsif button == Input::C
|
||||
if item.is_a?(Symbol)
|
||||
itm = GameData::Item.get(item)
|
||||
data = [
|
||||
@@ -740,6 +734,11 @@ def pbItemEditorNew(default_name)
|
||||
id = name.gsub(/é/, "e")
|
||||
id = id.gsub(/[^A-Za-z0-9_]/, "")
|
||||
id = id.upcase
|
||||
if id.length == 0
|
||||
id = sprintf("ITEM_%03d", id_number)
|
||||
elsif !id[0, 1][/[A-Z]/]
|
||||
id = "ITEM_" + id
|
||||
end
|
||||
if GameData::Item.exists?(id)
|
||||
for i in 1..100
|
||||
trial_id = sprintf("%s_%d", id, i)
|
||||
@@ -776,7 +775,7 @@ def pbItemEditorNew(default_name)
|
||||
pbSaveItems
|
||||
pbMessage(_INTL("The item {1} was created (ID: {2}).", name, id.to_s))
|
||||
pbMessage(_ISPRINTF("Put the item's graphic (item{1:s}.png or item{2:03d}.png) in Graphics/Icons, or it will be blank.",
|
||||
id.to_s, id_number))
|
||||
id, id_number))
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@ def pbSaveTypes
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
for i in 0..(PBTypes.maxValue rescue 25)
|
||||
name = PBTypes.getName(i) rescue nil
|
||||
next if !name || name==""
|
||||
@@ -52,8 +51,7 @@ def pbSaveAbilities
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
GameData::Ability.each do |a|
|
||||
f.write(sprintf("%d,%s,%s,%s\r\n",
|
||||
@@ -76,8 +74,7 @@ def pbSaveMoveData
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
current_type = -1
|
||||
GameData::Move.each do |m|
|
||||
if current_type != m.type
|
||||
@@ -144,8 +141,7 @@ def pbSerializeConnectionData(conndata,mapinfos)
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for conn in conndata
|
||||
if mapinfos
|
||||
@@ -184,8 +180,7 @@ def pbSaveMetadata
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
# Write global metadata
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[000]\r\n")
|
||||
@@ -230,8 +225,7 @@ def pbSaveItems
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
current_pocket = 0
|
||||
GameData::Item.each do |i|
|
||||
if current_pocket != i.pocket
|
||||
@@ -268,8 +262,7 @@ def pbSaveBerryPlants
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
GameData::BerryPlant.each do |bp|
|
||||
f.write(sprintf("%s = %d,%d,%d,%d\r\n",
|
||||
@@ -295,8 +288,7 @@ def pbSaveTrainerLists
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
for tr in trainerlists
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write(((tr[5]) ? "[DefaultTrainerList]" : "[TrainerList]")+"\r\n")
|
||||
@@ -321,8 +313,7 @@ def pbSaveMachines
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
keys = machines.keys.sort { |a, b| GameData::Move.get(a).id_number <=> GameData::Move.get(b).id_number }
|
||||
for i in 0...keys.length
|
||||
Graphics.update if i%50==0
|
||||
@@ -356,8 +347,7 @@ def pbSaveEncounterData
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
sortedkeys = encdata.keys.sort
|
||||
for i in sortedkeys
|
||||
next if !encdata[i]
|
||||
@@ -395,29 +385,25 @@ end
|
||||
# Save trainer type data to PBS file
|
||||
#===============================================================================
|
||||
def pbSaveTrainerTypes
|
||||
data = pbLoadTrainerTypesData
|
||||
return if !data
|
||||
File.open("PBS/trainertypes.txt","wb") { |f|
|
||||
File.open("PBS/trainertypes.txt", "wb") { |f|
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for i in 0...data.length
|
||||
record = data[i]
|
||||
next if !record
|
||||
dataline = sprintf("%d,%s,%s,%d,%s,%s,%s,%s,%s,%s",
|
||||
i,record[1],record[2],
|
||||
record[3],
|
||||
record[4] ? record[4] : "",
|
||||
record[5] ? record[5] : "",
|
||||
record[6] ? record[6] : "",
|
||||
record[7] ? ["Male","Female","Mixed"][record[7]] : "Mixed",
|
||||
(record[8]!=record[3]) ? record[8] : "",
|
||||
record[9] ? record[9] : "")
|
||||
f.write(dataline)
|
||||
f.write("\r\n")
|
||||
GameData::TrainerType.each do |t|
|
||||
f.write(sprintf("%d,%s,%s,%d,%s,%s,%s,%s,%s,%s\r\n",
|
||||
t.id_number,
|
||||
csvQuote(t.id.to_s),
|
||||
csvQuote(t.real_name),
|
||||
t.base_money,
|
||||
csvQuote(t.battle_BGM),
|
||||
csvQuote(t.victory_ME),
|
||||
csvQuote(t.intro_ME),
|
||||
["Male", "Female", "Mixed"][t.gender],
|
||||
(t.skill_level == t.base_money) ? "" : t.skill_level.to_s,
|
||||
csvQuote(t.skill_code)
|
||||
))
|
||||
end
|
||||
}
|
||||
end
|
||||
@@ -434,10 +420,9 @@ def pbSaveTrainerBattles
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
for trainer in data
|
||||
trtypename = getConstantName(PBTrainers,trainer[0]) rescue pbGetTrainerConst(trainer[0]) rescue nil
|
||||
trtypename = trainer[0].to_s
|
||||
next if !trtypename
|
||||
f.write("\#-------------------------------\r\n")
|
||||
# Section
|
||||
@@ -540,8 +525,7 @@ def pbSaveTownMap
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
for i in 0...mapdata.length
|
||||
map = mapdata[i]
|
||||
next if !map
|
||||
@@ -572,8 +556,7 @@ def pbSavePhoneData
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
f.write("[<Generics>]\r\n")
|
||||
f.write(data.generics.join("\r\n")+"\r\n")
|
||||
@@ -616,8 +599,7 @@ def pbSavePokemonData
|
||||
pokedata.write(0xEF.chr)
|
||||
pokedata.write(0xBB.chr)
|
||||
pokedata.write(0xBF.chr)
|
||||
pokedata.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
pokedata.write("\r\n")
|
||||
pokedata.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
for i in 1..(PBSpecies.maxValue rescue PBSpecies.getCount-1 rescue messages.getCount(MessageTypes::Species)-1)
|
||||
cname = getConstantName(PBSpecies,i) rescue next
|
||||
speciesname = messages.get(MessageTypes::Species,i)
|
||||
@@ -878,8 +860,7 @@ def pbSavePokemonFormsData
|
||||
pokedata.write(0xEF.chr)
|
||||
pokedata.write(0xBB.chr)
|
||||
pokedata.write(0xBF.chr)
|
||||
pokedata.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
pokedata.write("\r\n")
|
||||
pokedata.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
m1 = (PBSpecies.maxValue+1 rescue PBSpecies.getCount rescue messages.getCount(MessageTypes::Species))
|
||||
m2 = (PBSpecies.maxValueF rescue m1)
|
||||
for i in m1..m2
|
||||
@@ -1335,8 +1316,7 @@ def pbSaveShadowMoves
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for i in 0...shadow_movesets.length
|
||||
moveset = shadow_movesets[i]
|
||||
@@ -1372,8 +1352,7 @@ def pbSaveBTTrainers(bttrainers,filename)
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
for i in 0...bttrainers.length
|
||||
next if !bttrainers[i]
|
||||
f.write("\#-------------------------------\r\n")
|
||||
@@ -1384,7 +1363,7 @@ def pbSaveBTTrainers(bttrainers,filename)
|
||||
next if record==nil
|
||||
f.write(sprintf("%s = ",key))
|
||||
if key=="Type"
|
||||
f.write((getConstantName(PBTrainers,record) rescue pbGetTrainerConst(record)))
|
||||
f.write(record.to_s)
|
||||
elsif key=="PokemonNos"
|
||||
f.write(record.join(",")) # pbWriteCsvRecord somehow won't work here
|
||||
else
|
||||
@@ -1411,8 +1390,7 @@ def pbSaveBattlePokemon(btpokemon,filename)
|
||||
f.write(0xEF.chr)
|
||||
f.write(0xBB.chr)
|
||||
f.write(0xBF.chr)
|
||||
f.write("\# "+_INTL("See the documentation on the wiki to learn how to edit this file."))
|
||||
f.write("\r\n")
|
||||
f.write("\# " + _INTL("See the documentation on the wiki to learn how to edit this file.") + "\r\n")
|
||||
f.write("\#-------------------------------\r\n")
|
||||
for i in 0...btpokemon.length
|
||||
Graphics.update if i%500==0
|
||||
|
||||
@@ -23,6 +23,8 @@ def pbWriteCsvRecord(record,file,schema)
|
||||
# do nothing
|
||||
elsif rec[i].is_a?(String)
|
||||
file.write(csvQuote(rec[i]))
|
||||
elsif rec[i].is_a?(Symbol)
|
||||
file.write(csvQuote(rec[i].to_s))
|
||||
elsif rec[i]==true
|
||||
file.write("true")
|
||||
elsif rec[i]==false
|
||||
@@ -35,11 +37,7 @@ def pbWriteCsvRecord(record,file,schema)
|
||||
file.write(enumer[rec[i]])
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
mod = Object.const_get(enumer.to_sym)
|
||||
if enumer.to_s=="PBTrainers" && !mod.respond_to?("getCount")
|
||||
file.write((getConstantName(mod,rec[i]) rescue pbGetTrainerConst(rec[i])))
|
||||
else
|
||||
file.write(getConstantName(mod,rec[i]))
|
||||
end
|
||||
file.write(getConstantName(mod,rec[i]))
|
||||
elsif enumer.is_a?(Module)
|
||||
file.write(getConstantName(enumer,rec[i]))
|
||||
elsif enumer.is_a?(Hash)
|
||||
@@ -60,11 +58,7 @@ def pbWriteCsvRecord(record,file,schema)
|
||||
end
|
||||
elsif enumer.is_a?(Symbol) || enumer.is_a?(String)
|
||||
mod = Object.const_get(enumer.to_sym)
|
||||
if enumer.to_s=="PBTrainers" && !mod.respond_to?("getCount")
|
||||
file.write((getConstantNameOrValue(mod,rec[i]) rescue pbGetTrainerConst(rec[i])))
|
||||
else
|
||||
file.write(getConstantNameOrValue(mod,rec[i]))
|
||||
end
|
||||
file.write(getConstantNameOrValue(mod,rec[i]))
|
||||
elsif enumer.is_a?(Module)
|
||||
file.write(getConstantNameOrValue(enumer,rec[i]))
|
||||
elsif enumer.is_a?(Hash)
|
||||
|
||||
@@ -249,13 +249,13 @@ end
|
||||
|
||||
|
||||
module TrainerTypeProperty
|
||||
def self.set(settingname,oldsetting)
|
||||
chosenmap = pbListScreen(settingname,TrainerTypeLister.new(oldsetting,false))
|
||||
return (chosenmap) ? chosenmap[0] : oldsetting
|
||||
def self.set(settingname, oldsetting)
|
||||
chosenmap = pbListScreen(settingname, TrainerTypeLister.new(0, false))
|
||||
return chosenmap || oldsetting
|
||||
end
|
||||
|
||||
def self.format(value)
|
||||
return (!value) ? value.inspect : PBTrainers.getName(value)
|
||||
return (value && GameData::TrainerType.exists?(value)) ? GameData::TrainerType.get(value).real_name : "-"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -376,9 +376,8 @@ end
|
||||
|
||||
|
||||
class ItemLister
|
||||
def initialize(selection=0,includeNew=false)
|
||||
@sprite = IconSprite.new(0,0)
|
||||
@sprite = ItemIconSprite.new(Graphics.width*3/4,Graphics.height/2,nil)
|
||||
def initialize(selection = 0, includeNew = false)
|
||||
@sprite = ItemIconSprite.new(Graphics.width * 3 / 4, Graphics.height / 2, nil)
|
||||
@sprite.z = 2
|
||||
@selection = selection
|
||||
@commands = []
|
||||
@@ -418,13 +417,13 @@ class ItemLister
|
||||
@ids.push(i[1])
|
||||
end
|
||||
@index = @selection
|
||||
@index = @commands.length-1 if @index>=@commands.length
|
||||
@index = 0 if @index<0
|
||||
@index = @commands.length - 1 if @index >= @commands.length
|
||||
@index = 0 if @index < 0
|
||||
return @commands
|
||||
end
|
||||
|
||||
def value(index)
|
||||
return nil if index<0
|
||||
return nil if index < 0
|
||||
return @ids[index]
|
||||
end
|
||||
|
||||
@@ -436,12 +435,9 @@ end
|
||||
|
||||
|
||||
class TrainerTypeLister
|
||||
def initialize(selection,includeNew)
|
||||
@sprite = IconSprite.new(0,0)
|
||||
@sprite.bitmap = nil
|
||||
@sprite.x = Graphics.width * 3 / 4
|
||||
@sprite.y = (Graphics.height - 64) / 2 + 64
|
||||
@sprite.z = 2
|
||||
def initialize(selection = 0, includeNew = false)
|
||||
@sprite = IconSprite.new(Graphics.width * 3 / 4, (Graphics.height - 64) / 2 + 64)
|
||||
@sprite.z = 2
|
||||
@selection = selection
|
||||
@commands = []
|
||||
@ids = []
|
||||
@@ -466,47 +462,41 @@ class TrainerTypeLister
|
||||
def commands
|
||||
@commands.clear
|
||||
@ids.clear
|
||||
@trainers = pbLoadTrainerTypesData
|
||||
cmds = []
|
||||
GameData::TrainerType.each do |tr_type|
|
||||
cmds.push([tr_type.id_number, tr_type.id, tr_type.real_name])
|
||||
end
|
||||
cmds.sort! { |a, b| a[2].downcase <=> b[2].downcase }
|
||||
if @includeNew
|
||||
@commands.push(_INTL("[NEW TRAINER TYPE]"))
|
||||
@ids.push(-1)
|
||||
@ids.push(true)
|
||||
end
|
||||
@trainers.length.times do |i|
|
||||
next if !@trainers[i]
|
||||
@commands.push(sprintf("%3d: %s",i,@trainers[i][2]))
|
||||
@ids.push(@trainers[i][0])
|
||||
end
|
||||
@commands.length.times do |i|
|
||||
@index = i if @ids[i]==@selection
|
||||
for t in cmds
|
||||
@commands.push(sprintf("%03d: %s", t[0], t[2]))
|
||||
@ids.push(t[1])
|
||||
end
|
||||
@index = @selection
|
||||
@index = @commands.length - 1 if @index >= @commands.length
|
||||
@index = 0 if @index < 0
|
||||
return @commands
|
||||
end
|
||||
|
||||
def value(index)
|
||||
return nil if index<0
|
||||
return [-1] if @ids[index]==-1
|
||||
return @trainers[@ids[index]]
|
||||
return nil if index < 0
|
||||
return @ids[index]
|
||||
end
|
||||
|
||||
def refresh(index)
|
||||
@sprite.bitmap.dispose if @sprite.bitmap
|
||||
return if index<0
|
||||
return if index < 0
|
||||
begin
|
||||
@sprite.setBitmap(pbTrainerSpriteFile(@ids[index]),0)
|
||||
@sprite.setBitmap(pbTrainerSpriteFile(@ids[index]), 0)
|
||||
rescue
|
||||
@sprite.setBitmap(nil)
|
||||
end
|
||||
sprite_width = @sprite.bitmap.width
|
||||
sprite_height = @sprite.bitmap.height
|
||||
@sprite.ox = sprite_width/2
|
||||
@sprite.oy = sprite_height/2
|
||||
scale_x = (Graphics.width/2).to_f/sprite_width
|
||||
scale_y = (Graphics.height-64).to_f/sprite_height
|
||||
if scale_x<1.0 || scale_y<1.0
|
||||
min_scale = [scale_x, scale_y].min
|
||||
@sprite.zoom_x = @sprite.zoom_y = min_scale
|
||||
else
|
||||
@sprite.zoom_x = @sprite.zoom_y = 1.0
|
||||
if @sprite.bitmap
|
||||
@sprite.ox = @sprite.bitmap.width / 2
|
||||
@sprite.oy = @sprite.bitmap.height / 2
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -515,11 +505,8 @@ end
|
||||
|
||||
class TrainerBattleLister
|
||||
def initialize(selection,includeNew)
|
||||
@sprite = IconSprite.new
|
||||
@sprite.bitmap = nil
|
||||
@sprite.x = Graphics.width*3/4
|
||||
@sprite.y = (Graphics.height/2)+32
|
||||
@sprite.z = 2
|
||||
@sprite = IconSprite.new(Graphics.width * 3 / 4, (Graphics.height / 2) + 32)
|
||||
@sprite.z = 2
|
||||
@pkmnList = Window_UnformattedTextPokemon.new()
|
||||
@pkmnList.x = Graphics.width/2
|
||||
@pkmnList.y = Graphics.height-64
|
||||
@@ -562,12 +549,12 @@ class TrainerBattleLister
|
||||
if @trainers[i][4]>0
|
||||
# TrainerType TrainerName (version) xPartySize
|
||||
@commands.push(_ISPRINTF("{1:s} {2:s} ({3:d}) x{4:d}",
|
||||
PBTrainers.getName(@trainers[i][0]),@trainers[i][1],@trainers[i][4],
|
||||
@trainers[i][3].length))
|
||||
GameData::TrainerType.get(@trainers[i][0]).name, @trainers[i][1],
|
||||
@trainers[i][4], @trainers[i][3].length))
|
||||
else
|
||||
# TrainerType TrainerName xPartySize
|
||||
@commands.push(_ISPRINTF("{1:s} {2:s} x{3:d}",
|
||||
PBTrainers.getName(@trainers[i][0]),@trainers[i][1],
|
||||
GameData::TrainerType.get(@trainers[i][0]).name, @trainers[i][1],
|
||||
@trainers[i][3].length))
|
||||
end
|
||||
# Trainer type ID
|
||||
@@ -594,8 +581,10 @@ class TrainerBattleLister
|
||||
rescue
|
||||
@sprite.setBitmap(nil)
|
||||
end
|
||||
@sprite.ox = @sprite.bitmap.width/2
|
||||
@sprite.oy = @sprite.bitmap.height
|
||||
if @sprite.bitmap
|
||||
@sprite.ox = @sprite.bitmap.width/2
|
||||
@sprite.oy = @sprite.bitmap.height
|
||||
end
|
||||
text = ""
|
||||
if !@includeNew || index>0
|
||||
@trainers[(@includeNew) ? index-1 : index][3].each_with_index do |p,i|
|
||||
|
||||
@@ -237,29 +237,10 @@ def pbGetHabitatConst(i)
|
||||
return ret
|
||||
end
|
||||
|
||||
# Unused
|
||||
#def pbGetAbilityConst(i)
|
||||
# return MakeshiftConsts.get(MessageTypes::Abilities,i,PBAbilities)
|
||||
#end
|
||||
|
||||
# Unused
|
||||
#def pbGetMoveConst(i)
|
||||
# return MakeshiftConsts.get(MessageTypes::Moves,i,PBMoves)
|
||||
#end
|
||||
|
||||
# Unused
|
||||
#def pbGetItemConst(i)
|
||||
# return MakeshiftConsts.get(MessageTypes::Items,i,PBItems)
|
||||
#end
|
||||
|
||||
def pbGetSpeciesConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::Species,i,PBSpecies)
|
||||
end
|
||||
|
||||
def pbGetTrainerConst(i)
|
||||
return MakeshiftConsts.get(MessageTypes::TrainerTypes,i,PBTrainers)
|
||||
end
|
||||
|
||||
|
||||
|
||||
#===============================================================================
|
||||
|
||||
Reference in New Issue
Block a user