-
caveman
-
-
Вне сайта
-
Архитектор Миров
-
- Сообщений: 1274
- Спасибо получено: 1307
-
-
|
Всем бобра!
Наконец то дотянулись руки выпросить у DeadElf79 его наработки по экспорту/импорту для VX ACE и дописать импорт.
Он аж о трех файлах скриптов, которые можно положить в Materials.
- Dials содержит настройки экспорта / импорта (с описанием работы) и расширенное титульное меню игры, в котором появился пункт "Настройки", откуда и можно произвести экспорт и импорт данных игры.
- Dial_Import отвечает за импорт
- Dial_Export отвечает за экспорт
Правила таковы:
- Выбираете удобные настройки экспорта (можно все в 1 файл либо разделить БД, общие события и карты, или даже разбить карты на кучу файлов покартово)
- Экспортируете
- Правите текстовые файлы
- Импортируете при тех же настройках и не меняя ничего в игре между экспортом и импортом
Скриншот титульного меню:
Код
Установка - вначале Dials Export, потом Import, а Dials module - под ними.
Dials #===============================================================================
=begin
DIALS module
Экстрактор диалогов, часть третья
Этот скрипт необходим для настройки работы экспорта и импорта.
Автор: DeadElf79
Версия: 1.01 Добавлены настройки для импорта (caveman)
=end
#===============================================================================
class Dials
def initialize
#==========МЕНЯЕМ ТОЛЬКО ЗДЕСЬ==========
#возможность экспорта (true-вкл, false-выкл)
@do_export=true
#возможность импорта
@do_import=true
#включить экспорт базы данных
@do_save_db=true
#включить импорт базы данных
@do_load_db=true
#экспорт карт в отдельные файлы (сколько карт, столько и файлов)
#а также импорт из них
@do_map_is_file=false
#экспорт базы данных в отдельный файл(если do_save_db=true)
#а также импорт из него (если do_load_db=true)
@do_db_is_file=true
#экспорт данных из Общих событий
@do_save_common=true
#импорт данных из Общих событий
@do_load_common=true
#экспорт общих событий в отдельные файлы
#а также импорт из них
@do_common_is_file=false
#комментарии в файлах
@do_comments=true
#язык комментариев в файлах (true-русский, false-английский)
#только если do_comments=true
@do_comments_lang=true
#язык, на котором написаны данные в экспортируемом
#файле. необходимо для запуска в игре одного из нескольких
#по выбору.
#может быть одним из вариантов:
#rus eng deu fre jap
@do_language="rus"
#возможность экспорта/импорта прямо из титульного экрана
#если проект был запущен из редактора (то есть $DEBUG=true)
@do_title_debug=true
#==========ДАЛЬШЕ НЕ ТРОГАЕМ============
@options_button_name="Настройки"
@options_extractor_name="Экспортировать"
@options_import_name="Импортировать"
@options_cancel_name="Отмена"
end
attr_accessor :do_title_debug
attr_accessor :do_export
attr_accessor :do_import
attr_accessor :do_save_db
attr_accessor :do_load_db
attr_accessor :do_map_is_file
attr_accessor :do_db_is_file
attr_accessor :do_save_common
attr_accessor :do_load_common
attr_accessor :do_common_is_file
attr_accessor :do_comments_lang
attr_accessor :do_comments
attr_accessor :do_language
attr_reader :options_button_name
attr_reader :options_extractor_name
attr_reader :options_import_name
attr_reader :options_cancel_name
attr_reader :do_dir
end
$max_maps=999
$counter=0
class Game_Event
attr_accessor :erased
def g_event
return @event
end
end
class Game_Map
def g_map
return @map
end
end
class Window_TitleCommand
def make_command_list
add_command(Vocab::new_game, :new_game)
add_command(Vocab::continue, :continue, continue_enabled)
if $dials.do_title_debug
add_command($dials.options_button_name, :extractor)
end
add_command(Vocab::shutdown, :shutdown)
end
end
class Window_DialsCommand<Window_TitleCommand
def make_command_list
add_command($dials.options_extractor_name,:extract,$dials.do_export)
add_command($dials.options_import_name,:import,$dials.do_import)
add_command($dials.options_cancel_name,:cancel)
end
end
class Scene_Title
def start
super
SceneManager.clear
Graphics.freeze
create_background
create_foreground
$dials=Dials.new
create_command_window
create_extra_window
play_title_music
end
def create_command_window
@command_window = Window_TitleCommand.new
@command_window.set_handler(:new_game, method(:command_new_game))
@command_window.set_handler(:continue, method(:command_continue))
if $dials.do_title_debug
@command_window.set_handler(:extractor, method(:command_extractor))
end
@command_window.set_handler(:shutdown, method(:command_shutdown))
end
def create_extra_window
@extra=Window_DialsCommand.new
@extra.visible=false
@extra.x = (Graphics.width - @command_window.width) / 2+@extra.width
@extra.y = (Graphics.height * 1.6 - @command_window.height) / 2
@extra.set_handler(:extract, method(:command_extract))
@extra.set_handler(:import, method(:command_import))
@extra.set_handler(:cancel, method(:command_cancel))
end
def command_extractor
@extra.visible=true
@extra.openness=0
@extra.open
@command_window.active=false
@extra.active=true
end
def command_extract
extract=Dial_Extract.new
if extract.done then
@extra.close
msgbox "Операция успешно завершена!"
update until @extra.close?
@command_window.active=true
@extra.active=false
end
end
def command_import
extract=Dial_Import.new
if extract.done then
@extra.close
msgbox "Операция успешно завершена!"
update until @extra.close?
@command_window.active=true
@extra.active=false
end
end
def command_cancel
@extra.close
update until @extra.close?
@command_window.active=true
@extra.active=false
end
end
Dial_Export #===============================================================================
=begin
DIAL_EXPORT
Экспортер
Этот скрипт извлекает все сообщения и слова БД из проекта и записывает
в файл dials_<язык>.txt или же в несколько файлов
Авторы: DeadElf79, caveman
Версия: 1.07
История версий:
1.08 - добавлен экспорт закладки Terms
1.07 - изменен формат экспорта;
- добавлен экспорт для Общих событий (Common Events);
- добавлен экспорт базы данных;
- опционально: экспорт каждой карты в отдельный файл;
- опционально: экспорт базы данных в отдельный файл;
- опционально: экспорт общих событий в отдельный файл;
- добавлен модуль настроек Dials.
1.06 - оригинальный скрипт, вывод имени карты и сообщений построчно.
Ограничения:
- На одном из проектов не нашлось записи Vocab::surprise, что привело к
падению, решил добавлением в Vocab этой строки
=end
#===============================================================================
class Dial_Extract
attr_accessor :done
attr_accessor :error
def initialize
DataManager.init
$dials=Dials.new if $dials==nil
@file=File.open("dials_#{$dials.do_language}.txt","w")
if $dials.do_save_db
if $dials.do_db_is_file==false
export_database
else
@file.close
@file=File.open("dials_#{$dials.do_language}_DATABASE.txt","w")
export_database
@file.close
@file=File.open("dials_#{$dials.do_language}.txt","w")
end
end
if $dials.do_save_common
if $dials.do_common_is_file==false
export_common_events
else
@file.close
@file=File.open("dials_#{$dials.do_language}_COMMONEVENTS.txt","w")
export_common_events
@file.close
@file=File.open("dials_#{$dials.do_language}.txt","w")
end
end
if $dials.do_map_is_file!=false
@file.close
File.delete("dials_#{$dials.do_language}.txt")
end
for map in 1..$max_maps
if FileTest.exist?(sprintf("Data/Map%03d.rvdata2",map))
if $dials.do_map_is_file==false
export_map(map)
else
@file.close if @file.closed?!=true
$counter=0
@file=File.open(sprintf("dials_#{$dials.do_language}_Map%03d_"+
"#{$data_mapinfos[map].name}.txt",map),"w")
export_map(map)
@file.close
end
else
next
end
end
@file.close if @file.closed?!=true
@done=true
end
def export_database
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("||||||||||||||DATABASE||||||||||||||" + "\n")
else
@file.write("||||||||||||||База данных||||||||||||||" + "\n")
end
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== ACTORS ===================" + "\n")
else
@file.write("=================== ГЕРОИ ===================" + "\n")
end
end
if $data_actors.size>2
for i in 1...$data_actors.size
text = i.to_s + ":" + $data_actors[i].name
@file.write(text + "\n")
end
else
if $data_actors[1].name.size>1
text = 1.to_s + ":" + $data_actors[1].name
@file.write(text + "\n")
else
@file.write("Ни одного героя не было создано" + "\n")
end
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== CLASSES ===================" + "\n")
else
@file.write("=================== КЛАССЫ ===================" + "\n")
end
end
if $data_classes.size>2
for i in 1...$data_classes.size
text = i.to_s + ":" + $data_classes[i].name
@file.write(text + "\n")
end
else
if $data_classes[1].name.size>1
text = 1.to_s + ":" + $data_classes[1].name
@file.write(text + "\n")
else
@file.write("Ни одного класса не было создано" + "\n")
end
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== SKILLS ===================" + "\n")
else
@file.write("=================== НАВЫКИ ===================" + "\n")
end
end
for i in 1...$data_skills.size
text = i.to_s + ":" + $data_skills[i].name
@file.write(text + "\n")
@file.write($data_skills[i].description + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== ITEMS ===================" + "\n")
else
@file.write("=================== ПРЕДМЕТЫ ===================" + "\n")
end
end
for i in 1...$data_items.size
text = i.to_s + ":" + $data_items[i].name
@file.write(text + "\n")
@file.write($data_items[i].description + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
file.write("=================== WEAPONS ===================" + "\n")
else
@file.write("=================== ОРУЖИЕ ===================" + "\n")
end
end
for i in 1...$data_weapons.size
text = i.to_s + ":" + $data_weapons[i].name
@file.write(text + "\n")
@file.write($data_weapons[i].description + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== ARMORS ===================" + "\n")
else
@file.write("=================== БРОНЯ ===================" + "\n")
end
end
for i in 1...$data_armors.size
text = i.to_s + ":" + $data_armors[i].name
@file.write(text + "\n")
@file.write($data_armors[i].description + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== ENEMIES ===================" + "\n")
else
@file.write("=================== ПРОТИВНИКИ ===================" + "\n")
end
end
for i in 1...$data_enemies.size
text = i.to_s + ":" + $data_enemies[i].name
@file.write(text + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== TROOPS ===================" + "\n")
else
@file.write("=================== ГРУППЫ ВРАГОВ ===================" + "\n")
end
end
for i in 1...$data_troops.size
text = i.to_s + ":" + $data_troops[i].name
@file.write(text + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== STATES ===================" + "\n")
else
@file.write("=================== СТАТУСЫ ===================" + "\n")
end
end
for i in 1...$data_states.size
text = i.to_s + ":" + $data_states[i].name
@file.write(text + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== ANIMATIONS ===================" + "\n")
else
@file.write("=================== ИМЕНА АНИМАЦИЙ ===================" + "\n")
end
end
for i in 1...$data_animations.size
text = i.to_s + ":" + $data_animations[i].name
@file.write(text + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== TILESETS ===================" + "\n")
else
@file.write("=================== ТАЙЛСЕТЫ ===================" + "\n")
end
end
for i in 1...$data_tilesets.size
text = i.to_s + ":" + $data_tilesets[i].name
@file.write(text + "\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== SYSTEM ===================" + "\n")
else
@file.write("=================== СИСТЕМНЫЕ СТРОКИ ===================\n")
end
end
@file.write("ShopBuy:#{Vocab::ShopBuy}\n")
@file.write("ShopSell:#{Vocab::ShopSell}\n")
@file.write("ShopCancel:#{Vocab::ShopCancel}\n")
@file.write("Possession:#{Vocab::Possession}\n")
@file.write("ExpTotal:#{Vocab::ExpTotal}\n")
@file.write("ExpNext:#{Vocab::ExpNext}\n")
@file.write("SaveMessage:#{Vocab::SaveMessage}\n")
@file.write("LoadMessage:#{Vocab::LoadMessage}\n")
@file.write("File:#{Vocab::File}\n")
@file.write("PartyName:#{Vocab::PartyName}\n")
@file.write("Emerge:#{Vocab::Emerge}\n")
@file.write("Preemptive:#{Vocab::Preemptive}\n")
@file.write("Surprise:#{Vocab::Surprise}\n")
@file.write("EscapeStart:#{Vocab::EscapeStart}\n")
@file.write("EscapeFailure:#{Vocab::EscapeFailure}\n")
@file.write("Victory:#{Vocab::Victory}\n")
@file.write("Defeat:#{Vocab::Defeat}\n")
@file.write("ObtainExp:#{Vocab::ObtainExp}\n")
@file.write("ObtainGold:#{Vocab::ObtainGold}\n")
@file.write("ObtainItem:#{Vocab::ObtainItem}\n")
@file.write("LevelUp:#{Vocab::LevelUp}\n")
@file.write("ObtainSkill:#{Vocab::ObtainSkill}\n")
@file.write("UseItem:#{Vocab::UseItem}\n")
@file.write("CrticalToEnemy:#{Vocab::CriticalToEnemy}\n")
@file.write("CriticalToActor:#{Vocab::CriticalToActor}\n")
@file.write("ActorDamage:#{Vocab::ActorDamage}\n")
@file.write("ActorRecovery:#{Vocab::ActorRecovery}\n")
@file.write("ActorGain:#{Vocab::ActorGain}\n")
@file.write("ActorLoss:#{Vocab::ActorLoss}\n")
@file.write("ActorDrain:#{Vocab::ActorDrain}\n")
@file.write("ActorNoDamage:#{Vocab::ActorNoDamage}\n")
@file.write("ActorNoHit:#{Vocab::ActorNoHit}\n")
@file.write("EnemyDamage:#{Vocab::EnemyDamage}\n")
@file.write("EnemyRecovery:#{Vocab::EnemyRecovery}\n")
@file.write("EnemyGain:#{Vocab::EnemyGain}\n")
@file.write("EnemyLoss:#{Vocab::EnemyLoss}\n")
@file.write("EnemyDrain:#{Vocab::EnemyDrain}\n")
@file.write("EnemyNoDamage:#{Vocab::EnemyNoDamage}\n")
@file.write("EnomyNoHit:#{Vocab::EnemyNoHit}\n")
@file.write("Evasion:#{Vocab::Evasion}\n")
@file.write("MagicEvasion:#{Vocab::MagicEvasion}\n")
@file.write("MagicReflection:#{Vocab::MagicReflection}\n")
@file.write("CounterAttack:#{Vocab::CounterAttack}\n")
@file.write("Substitute:#{Vocab::Substitute}\n")
@file.write("BuffAdd:#{Vocab::BuffAdd}\n")
@file.write("DebuffAdd:#{Vocab::DebuffAdd}\n")
@file.write("BuffRemove:#{Vocab::BuffRemove}\n")
@file.write("ActionFailure:#{Vocab::ActionFailure}\n")
@file.write("PlayerPosError:#{Vocab::PlayerPosError}\n")
@file.write("EventOverflow:#{Vocab::EventOverflow}\n")
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("=================== TERMINS ===================" + "\n")
else
@file.write("=================== ТЕРМИНЫ ===================" + "\n")
end
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("ELEMENTS:" + "\n")
else
@file.write("ЭЛЕМЕНТЫ:" + "\n")
end
end
for i in 1...$data_system.elements.size
@file.write("#{i.to_s}:#{$data_system.elements[i]}\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("SKILL TYPES:" + "\n")
else
@file.write("ТИПЫ СКИЛЛОВ:" + "\n")
end
end
for i in 1...$data_system.skill_types.size
@file.write("#{i.to_s}:#{$data_system.skill_types[i]}\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("WEAPON TYPES:" + "\n")
else
@file.write("ТИПЫ ОРУЖИЯ:" + "\n")
end
end
for i in 1...$data_system.weapon_types.size
@file.write("#{i.to_s}:#{$data_system.weapon_types[i]}\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("ARMOR TYPES:" + "\n")
else
@file.write("ТИПЫ БРОНИ:" + "\n")
end
end
for i in 1...$data_system.armor_types.size
@file.write("#{i.to_s}:#{$data_system.armor_types[i]}\n")
end
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("TERMS:" + "\n")
else
@file.write("ТЕРМИНЫ:" + "\n")
end
end
# basic
@file.write("Level:#{$data_system.terms.basic[0]}\n")
@file.write("Level (short):#{$data_system.terms.basic[1]}\n")
@file.write("HP:#{$data_system.terms.basic[2]}\n")
@file.write("HP (short):#{$data_system.terms.basic[3]}\n")
@file.write("MP:#{$data_system.terms.basic[4]}\n")
@file.write("MP (short):#{$data_system.terms.basic[5]}\n")
@file.write("TP:#{$data_system.terms.basic[6]}\n")
@file.write("TP (short):#{$data_system.terms.basic[7]}\n")
# params
@file.write("MHP:#{$data_system.terms.params[0]}\n")
@file.write("MMP:#{$data_system.terms.params[1]}\n")
@file.write("ATK:#{$data_system.terms.params[2]}\n")
@file.write("DEF:#{$data_system.terms.params[3]}\n")
@file.write("MAT:#{$data_system.terms.params[4]}\n")
@file.write("MDF:#{$data_system.terms.params[5]}\n")
@file.write("AGI:#{$data_system.terms.params[6]}\n")
@file.write("LUK:#{$data_system.terms.params[7]}\n")
# etypes
@file.write("Weapon:#{$data_system.terms.etypes[0]}\n")
@file.write("Shield:#{$data_system.terms.etypes[1]}\n")
@file.write("Head:#{$data_system.terms.etypes[2]}\n")
@file.write("Body:#{$data_system.terms.etypes[3]}\n")
@file.write("Accessory:#{$data_system.terms.etypes[4]}\n")
# commands
@file.write("Fight:#{$data_system.terms.commands[0]}\n")
@file.write("Escape:#{$data_system.terms.commands[1]}\n")
@file.write("Attack:#{$data_system.terms.commands[2]}\n")
@file.write("Defend:#{$data_system.terms.commands[3]}\n")
@file.write("Item:#{$data_system.terms.commands[4]}\n")
@file.write("Skill:#{$data_system.terms.commands[5]}\n")
@file.write("Equip:#{$data_system.terms.commands[6]}\n")
@file.write("Status:#{$data_system.terms.commands[7]}\n")
@file.write("Sort:#{$data_system.terms.commands[8]}\n")
@file.write("Save:#{$data_system.terms.commands[9]}\n")
@file.write("Exit Game:#{$data_system.terms.commands[10]}\n")
@file.write("(not used):#{$data_system.terms.commands[11]}\n")
@file.write("Weapon:#{$data_system.terms.commands[12]}\n")
@file.write("Armor:#{$data_system.terms.commands[13]}\n")
@file.write("Key Item:#{$data_system.terms.commands[14]}\n")
@file.write("Change Equipment:#{$data_system.terms.commands[15]}\n")
@file.write("Ultimate Equipment:#{$data_system.terms.commands[16]}\n")
@file.write("Remove All:#{$data_system.terms.commands[17]}\n")
@file.write("New Game:#{$data_system.terms.commands[18]}\n")
@file.write("Continue:#{$data_system.terms.commands[19]}\n")
@file.write("Shut Down:#{$data_system.terms.commands[20]}\n")
@file.write("Go to Title:#{$data_system.terms.commands[21]}\n")
@file.write("Cancel:#{$data_system.terms.commands[22]}\n")
@file.write("\n\n")
end
def export_common_events
if $dials.do_comments
if $dials.do_comments_lang==false
@file.write("||||||||||||||COMMON EVENTS||||||||||||||" + "\n")
else
@file.write("||||||||||||||ОБЩИЕ СОБЫТИЯ||||||||||||||" + "\n")
end
end
for i in 1...$data_common_events.size
if $dials.do_comments_lang==false
ev_text = "common_event_id:" + i.to_s
else
ev_text = "Номер:" + i.to_s
end
@file.write(ev_text + "\n")
if $dials.do_comments_lang==false
ev_text = "common_event_name:" + $data_common_events[i].name
else
ev_text = "Название:" + $data_common_events[i].name
end
@file.write(ev_text + "\n")
list = $data_common_events[i].list
if list != nil
for command in list
str4=""
case command.code
when 101
wait_flag = true
$counter+=1
@file.write((sprintf("%07d",$counter))+":")
@file.write("#{command.parameters[0]}"+"\n")
when 401 #message
if wait_flag
@file.write("#{command.parameters[0]}"+"\n")
end
when 102 #choices
wait_flag = false
$counter+=1
@file.write((sprintf("%07d",$counter))+":")
if $dials.do_comments_lang==false
@file.write("CHOICE:"+"\n")
else
@file.write("Варианты выбора:\n")
end
for j in 0...command.parameters[0].size
@file.write("#{command.parameters[0][j]}"+"\n")
end
else
wait_flag = false
end
end
end
end
@file.write("\n\n")
end
#=============================================================================
#=============================================================================
#========================САМОЕ ГЛАВНОЕ В ЭТОМ СКРИПТЕ!========================
#=============================================================================
#=============================================================================
def export_map(map_id)
if $dials.do_comments_lang==false
@file.write(sprintf("||||||||||||||MAP %03d||||||||||||||",map_id) + "\n")
else
@file.write(sprintf("||||||||||||||КАРТА %03d||||||||||||||",map_id) + "\n")
end
if $dials.do_comments_lang==false
str4="[map name in editor=\"#{$data_mapinfos[map_id].name}\"]"
#str4="[map name in game=\"#{$data_maps[map_id].name}\"]"
else
str4="[имя карты в редакторе=\"#{$data_mapinfos[map_id].name}\"]"
#str4="[имя карты в игре=\"#{$data_mapinfos[map_id].display_name}\"]"
end
@file.write((sprintf("%07d",$counter))+":#{str4}\n")
$game_map = Game_Map.new
$game_map.setup(map_id)
events=$game_map.events
wait_flag = true
for i in 1..9999
if events[i]!=nil
if $dials.do_comments_lang==false
ev_text = "event_id:" + i.to_s
else
#name="smthng"
ev_text = "Событие №:" + i.to_s# + ":"+name#events[i].name
end
@file.write(ev_text + "\n")
for page in events[i].g_event.pages
unless page.list.nil?
for command in page.list
str4=""
case command.code
when 101
wait_flag = true
$counter+=1
@file.write((sprintf("%07d",$counter))+":")
@file.write("#{command.parameters[0]}"+"\n")
when 401 #message
if wait_flag
@file.write("#{command.parameters[0]}"+"\n")
end
when 102 #choices
wait_flag = false
$counter+=1
@file.write((sprintf("%07d",$counter))+":")
if $dials.do_comments_lang==false
@file.write("CHOICE:"+"\n")
else
@file.write("Варианты выбора:\n")
end
for j in 0...command.parameters[0].size
@file.write("#{command.parameters[0][j]}"+"\n")
end
else
wait_flag = false
end
end
end
end
end
end
@file.write("\n\n")
end
end
Dial_Import #===============================================================================
=begin
DIAL_IMPORT
Импортер
Этот скрипт анализирует файлы экспорта и ипмортирует их,
заменяя текст сообщений и БД проекта на содержимое файлов.
Автор: DeadElf79, caveman
Версия: 1.02 Импорт БД, общих событий и карт
Ограничения:
- Импорт многострочных описаний в БД пока без переноса
- Нет импорта названий тайлсетов (да и не стоит)
- Нет импорта Vocab
=end
#===============================================================================
class Dial_Import
attr_accessor :done
attr_accessor :error
def initialize
DataManager.init
$dials=Dials.new if $dials==nil
@lines = []
@lines_db = []
@lines_common = []
@lines_map = []
@line_all = 0
if !FileTest.exist?("dials_#{$dials.do_language}.txt")
p "Файл с общими данными не найден"
@error = true
return
end
@file=File.open("dials_#{$dials.do_language}.txt","r")
@lines = @file.readlines
@file.close
if $dials.do_load_db
if !$dials.do_db_is_file
import_database
else
if !FileTest.exist?("dials_#{$dials.do_language}_DATABASE.txt")
p "Файл _DATABASE не найден"
@error = true
return
end
@file=File.open("dials_#{$dials.do_language}_DATABASE.txt","r")
@lines_db = @file.readlines
@file.close
import_database
end
end
if $dials.do_load_common
if !$dials.do_common_is_file
import_common_events
else
@file.close if @file.closed?!=true
if !FileTest.exist?("dials_#{$dials.do_language}_COMMONEVENTS.txt")
p "Файл _COMMONEVENTS не найден"
@error = true
return
end
@file=File.open("dials_#{$dials.do_language}_COMMONEVENTS.txt","r")
@lines_common = @file.readlines
@file.close
import_common_events
end
save_data($data_common_events, "Data/CommonEvents.rvdata2")
end
for map in 1..$max_maps
if FileTest.exist?(sprintf("Data/Map%03d.rvdata2",map))
if !$dials.do_map_is_file
import_map(map)
else
@file.close if @file.closed?!=true
if !FileTest.exist?(sprintf("dials_#{$dials.do_language}_Map%03d_"+
"#{$data_mapinfos[map].name}.txt",map))
p = "Файл карты" + map + ' не найден'
@error = true
return
end
@file=File.open(sprintf("dials_#{$dials.do_language}_Map%03d_"+
"#{$data_mapinfos[map].name}.txt",map),"r")
@lines_map = @file.readlines
@file.close
import_map(map)
end
save_data($game_map.g_map, sprintf("Data/Map%03d.rvdata2", map))
else
next
end
end
save_data($data_mapinfos, "Data/MapInfos.rvdata2")
@file.close if @file.closed?!=true
@done=true
end
def import_database
l = $dials.do_db_is_file ? 0 : @line_all
data = $dials.do_db_is_file ? @lines_db : @lines
l += 1 if $dials.do_comments #DATABASE
l += 1 if $dials.do_comments #ACTORS
for i in 1...$data_actors.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_actors[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #CLASSES
for i in 1...$data_classes.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_classes[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #SKILLS
for i in 1...$data_skills.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_skills[i].name = $2.to_s
end
l += 1
text = ""
while !data[l].include?(":") and !data[l].include?("==")
text += data[l] + " \n"
l += 1
end
$data_skills[i].description = text
end
l += 1 if $dials.do_comments #ITEMS
for i in 1...$data_items.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_items[i].name = $2.to_s
end
l += 1
text = ""
while !data[l].include?(":") and !data[l].include?("==")
text += data[l] + " \n"
l += 1
end
$data_items[i].description = text
end
l += 1 if $dials.do_comments #WEAPONS
for i in 1...$data_weapons.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_weapons[i].name = $2.to_s
end
l += 1
text = ""
while !data[l].include?(":") and !data[l].include?("==")
text += data[l] + " \n"
l += 1
end
$data_weapons[i].description = text
end
l += 1 if $dials.do_comments #ARMORS
for i in 1...$data_armors.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_armors[i].name = $2.to_s
end
l += 1
text = ""
while !data[l].include?(":") and !data[l].include?("==")
text += data[l] + " \n"
l += 1
end
$data_armors[i].description = text
end
l += 1 if $dials.do_comments #ENEMIES
for i in 1...$data_enemies.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_enemies[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #TROOPS
for i in 1...$data_troops.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_troops[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #STATES
for i in 1...$data_states.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_states[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #ANIMATIONS
for i in 1...$data_animations.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_animations[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #TILESETS
for i in 1...$data_tilesets.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_tilesets[i].name = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #SYSTEM
l += 50 # словарь не импортим
l += 1 if $dials.do_comments #TERMS
l += 1 if $dials.do_comments #ELEMENTS
for i in 1...$data_system.elements.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.elements[i] = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #SKILL TYPES
for i in 1...$data_system.skill_types.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.skill_types[i] = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #WEAPON TYPES
for i in 1...$data_system.weapon_types.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.weapon_types[i] = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #ARMOR TYPES
for i in 1...$data_system.armor_types.size
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.armor_types[i] = $2.to_s
end
l += 1
end
l += 1 if $dials.do_comments #TERMS
# basic
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[0] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[1] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[2] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[3] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[4] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[5] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[6] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.basic[7] = $2.to_s
end
l += 1
# params
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[0] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[1] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[2] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[3] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[4] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[5] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[6] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.params[7] = $2.to_s
end
l += 1
# etypes
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.etypes[0] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.etypes[1] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.etypes[2] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.etypes[3] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.etypes[4] = $2.to_s
end
l += 1
# commands
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[0] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[1] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[2] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[3] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[4] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[5] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[6] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[7] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[8] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[9] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[10] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[11] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[12] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[13] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[14] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[15] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[16] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[17] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[18] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[19] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[20] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[21] = $2.to_s
end
l += 1
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_system.terms.commands[22] = $2.to_s
end
l += 3 # \n\n
save_data($data_actors, "Data/Actors.rvdata2")
save_data($data_classes, "Data/Classes.rvdata2")
save_data($data_skills, "Data/Skills.rvdata2")
save_data($data_items, "Data/Items.rvdata2")
save_data($data_weapons, "Data/Weapons.rvdata2")
save_data($data_armors, "Data/Armors.rvdata2")
save_data($data_enemies, "Data/Enemies.rvdata2")
save_data($data_troops, "Data/Troops.rvdata2")
save_data($data_states, "Data/States.rvdata2")
save_data($data_animations, "Data/Animations.rvdata2")
save_data($data_system, "Data/System.rvdata2")
@line_all = l if !$dials.do_db_is_file
end
def import_common_events
l = $dials.do_common_is_file ? 0 : @line_all
data = $dials.do_common_is_file ? @lines_common : @lines
l += 1 if $dials.do_comments #COMMON EVENTS
has_dials = false
choices = []
for i in 1...$data_common_events.size
l += 1 # common_event_id
# common_event_name
data[l].gsub(/\A(.+?)\:(.+?)\Z/) do
$data_common_events[i].name = $2.to_s
end
l += 1
list = $data_common_events[i].list
if list != nil
for command in list
case command.code
when 101 #message start
wait_flag = true
l += 1 # counter id
when 401 #message continue
if wait_flag
data[l].gsub(/\A(.+?)\n\Z/) do
command.parameters[0] = data[l] = $1.to_s
end
l += 1
has_dials = true
end
when 102 #choices list
wait_flag = false
p data[l]
l += 1 # counter id
for j in 0...command.parameters[0].size
data[l].gsub(/\A(.+?)\Z/) do
command.parameters[0][j] = $1.to_s
choices.push($1.to_s)
end
l += 1
end
choices.reverse! # нам нужен не стек, а очередь!
when 402 #choice
wait_flag = false
command.parameters[1] = choices.pop
else
wait_flag = false
end
end
end
end
l += 2 #\n\n
@line_all = l if !$dials.do_common_is_file
p @line_all
end
def import_map(map)
l = $dials.do_map_is_file ? 0 : @line_all
data = $dials.do_map_is_file ? @lines_map : @lines
l += 1 # == MAP map_id ==
$game_map = Game_Map.new
$game_map.setup(map)
events=$game_map.events
choices = []
p 'map: ' + data[l]
data[l].gsub(/\A(.+?)\:\[(.+?)\=\"(.+?)\"]\Z/) do
$data_mapinfos[map].name = $3.to_s
end
l += 1
wait_flag = false
for i in 1..9999
if events[i]!=nil
l += 1 # event_id
for page in events[i].g_event.pages
unless page.list.nil?
for command in page.list
case command.code
when 101 #message start
wait_flag = true
l += 1 # counter id
when 401 #message continue
if wait_flag
data[l].gsub(/\A(.+?)\n\Z/) do
command.parameters[0] = data[l] = $1.to_s
end
l += 1
end
when 102 #choices list
wait_flag = false
p data[l]
l += 1 # counter id
for j in 0...command.parameters[0].size
data[l].gsub(/\A(.+?)\Z/) do
command.parameters[0][j] = $1.to_s
choices.push($1.to_s)
end
l += 1
end
choices.reverse! # нам нужен не стек, а очередь!
when 402 #choice
wait_flag = false
command.parameters[1] = choices.pop
else
wait_flag = false
end
end
end
end
end
end
l += 2 #\n\n
@line_all = l if !$dials.do_map_is_file
end
end
Тестовая демо прилагается yadi.sk/d/AG1rXG9ud2QWe
Также тестировал экспорт / импорт в полевых условиях на игре "Долгая дорога домой", работает.
Некоторые несущественные ограничения описал в скриптах; позже, либо я, либо Эльф придумаем как поправить.
|