=begin メッセージ抽出スクリプト For VX イベント中で表示するメッセージをテキスト出力します。 あとスキルメッセージとか =end module TKCG;module DebugOutput;module Setting;end;end end module TKCG::DebugOutput::Setting # ------------------------------------------ # 設定 # ------------------------------------------ CommonEventMsg_FILENAME = '00CommonEventMsg.txt' # コモンイベントメッセージ出力ファイル名 MapEventMsg_FILENAME = '00MapEventMsg.txt' # マップイベントメッセージ出力ファイル名 BattleEventMsg_FILENAME = '00BattleEventMsg.txt' # バトルイベントメッセージ出力ファイル名 BaseItemMsg_FILENAME = '00EtcMsg.txt' # その他メッセージ出力ファイル名 IS_PRINT_MASSAGE_BORDER = false IS_OUTPUT_NOTE = true # ------------------------------------------ # 設定ここまで # ------------------------------------------ end module TKCG::DebugOutput module Message module DisplayInfo def create_info(color=Color.new(200,200,50)) @info_bitmap = Bitmap.new(200,40) @info_bitmap.fill_rect(@info_bitmap.rect, color) @info_sprite = Sprite.new @info_sprite.bitmap = @info_bitmap end def update_info(text) @info_bitmap.draw_text(@info_bitmap.rect, text) Graphics.update end def dispose_info @info_sprite.dispose @info_bitmap.dispose @info_sprite = nil @info_bitmap = nil end end module Event module Mode SEARCH = 0 MESSAGE = 101 SCROLL_MESSAGE = 105 end module Code MESSAGE = 101 CONTINUE_MESSAGE = 401 SCROLL_MESSAGE = 105 CONTINUE_SCROLL_MESSAGE = 405 CHOICE = 102 end class ListMsgData def initialize(mode, msg) @mode = mode @msg = msg end def to_s text = @msg if TKCG::DebugOutput::Setting::IS_PRINT_MASSAGE_BORDER case(@mode) when Mode::MESSAGE text = "> メッセージ---------------------------------\n" + text when Mode::SCROLL_MESSAGE text = "> スクロールメッセージ---------------------------------\n" + text end text += "> ---------------------------------------------\n" end return text end end class EventPageData attr_reader :page_no attr_reader :datas def initialize(page_no, datas) @page_no = page_no @datas = datas end def to_s(indent=0, spacer=" ") space = "" + spacer * indent text = space + sprintf("Page%d:\n\n", @page_no) @datas.each do |list_data| text += list_data.to_s end text += "\n" return text end end def analize_list(list) datas = [] index = 0 mode = Mode::SEARCH msg = "" list.each do |command| next unless command.is_a?(RPG::EventCommand) case command.code when Code::MESSAGE if mode != Mode::SEARCH && mode != Mode::MESSAGE datas += ListMsgData.new(mode, msg) unless msg.empty? msg = "" end mode = Mode::MESSAGE when Code::MESSAGE if mode != Mode::SEARCH && mode != Mode::MESSAGE datas.push( ListMsgData.new(mode, msg) ) unless msg.empty? msg = "" end mode = Mode::MESSAGE when Code::SCROLL_MESSAGE if mode != Mode::SEARCH && mode != Mode::SCROLL_MESSAGE datas.push( ListMsgData.new(mode, msg) ) unless msg.empty? msg = "" end mode = Mode::SCROLL_MESSAGE when Code::CONTINUE_MESSAGE,Code::CONTINUE_SCROLL_MESSAGE msg += "#{command.parameters[0]}\n" when Code::CHOICE command.parameters[0].each do |choice| next if choice.empty? msg += "選択肢:#{choice}\n" end else datas.push( ListMsgData.new(mode, msg) ) if (mode != Mode::SEARCH && !msg.empty?) mode = Mode::SEARCH msg = "" end end datas.push( ListMsgData.new(mode, msg) ) if mode != Mode::SEARCH && !msg.empty? return datas end end class CommonEvent include Event include DisplayInfo class CommonEventData def initialize(ce_id, name, list_datas) @ce_id = ce_id @name = name @list_datas = list_datas end def to_s(indent=0, spacer="=") prefix = "" + spacer * indent text = prefix + sprintf("%03d: %s\n\n",@ce_id, @name) @list_datas.each do |list_data| text += list_data.to_s end text += "\n" return text end end def initialize @data_common_events = load_data("Data/CommonEvents.rvdata") @analized_data = nil end def analize create_info(Color.new(50,200,50)) update_info('コモンイベント解析中') @analized_data = [] @data_common_events.each do |ce| next unless ce.is_a?(RPG::CommonEvent) ret = analize_list(ce.list) unless ret.empty? @analized_data.push( CommonEventData.new(ce.id, ce.name, ret) ) end end dispose_info end def output(fo) analize if @analized_data.nil? fo.print("■ コモンイベント\n") @analized_data.each do |ced| fo.print(ced.to_s(1)) end end end class MapEvent include Event include DisplayInfo class MapData def initialize(map_id, name, event_datas) @map_id = map_id @name = name @event_datas = event_datas end def to_s(indent=0, spacer=" ") prefix = "" + spacer * indent text = prefix + sprintf("Map%03d: %s\n", @map_id.to_i, @name) @event_datas.each do |event_data| text += event_data.to_s end return text end end class MapEventData def initialize(event_id, name, page_datas, x, y) @event_id = event_id @name = name @page_datas = page_datas @x = x @y = y end def to_s(indent=0) space = "" + " " * indent text = space + sprintf("[%d,%d]Event%03d: %s\n", @x,@y,@event_id, @name) @page_datas.each do |page_data| text += page_data.to_s(indent+1) end return text end end def initialize @data_mapinfos = load_data("Data/MapInfos.rvdata") @analized_data = nil end def analize_event(event) pages_data = [] event.pages.each_with_index do |page, pindex| ret = analize_list(page.list) next if ret.empty? pages_data.push( EventPageData.new(pindex+1, ret) ) end return nil if pages_data.empty? return MapEventData.new(event.id, event.name, pages_data, event.x, event.y) end def analize create_info(Color.new(200,50,50)) update_info('マップ解析中') @analized_data = [] @data_mapinfos.each do |map_id,mapinfo| map = load_data(sprintf("Data/Map%03d.rvdata", map_id)) data = [] map.events.each do |event_id, event| event_data = analize_event(event) data.push( event_data ) if event_data end next if data.empty? @analized_data.push( MapData.new(map_id, mapinfo.name, data) ) end dispose_info() end def output(fo) analize if @analized_data.nil? fo.print("■ マップイベント\n") @analized_data.each do |map_data| fo.print(map_data.to_s) end end end class BattleEvent include Event include DisplayInfo class TroopData def initialize(troop_id, name, pages_data) @troop_id = troop_id @name = name @pages_data = pages_data end def to_s(indent=0, spacer=" ") prefix = "" + spacer * indent text = prefix + sprintf("troop%03d: %s\n", @troop_id.to_i, @name) @pages_data.each do |page_data| text += page_data.to_s end return text end end def initialize @data_troops = load_data("Data/Troops.rvdata") @analized_data = nil end def analize create_info(Color.new(200,200,50)) update_info('バトルイベント解析中') @analized_data = [] @data_troops.each do |troop| next unless troop.is_a?(RPG::Troop) pages_data = [] troop.pages.each_with_index do |page, pindex| ret = analize_list(page.list) next if ret.empty? pages_data.push( EventPageData.new(pindex+1, ret) ) end next if pages_data.empty? @analized_data.push( TroopData.new(troop.id, troop.name, pages_data) ) end dispose_info() end def output(fo) analize if @analized_data.nil? fo.print("■ バトルイベント\n") @analized_data.each do |troop_data| fo.print(troop_data.to_s) end end end class BaseItem include DisplayInfo def analize(fo,filename,title) update_info("#{title}解析中") @data_items = load_data("Data/#{filename}.rvdata") fo.print("■ #{title}\n") @data_items.each do |item| next if item.nil? fo.print(sprintf("%03d: %s\n", item.id, item.name)) if Setting::IS_OUTPUT_NOTE && (item.is_a?(RPG::State) || item.is_a?(RPG::Enemy)) fo.print("メモ:\n#{item.note}\n") unless item.note.empty? end next unless item.is_a?(RPG::BaseItem) fo.print("#{item.description}\n") if !item.description.empty? if item.is_a?(RPG::Skill) fo.print("ラルフ#{item.message1}\n") unless item.message1.empty? fo.print("#{item.message2}\n") unless item.message2.empty? end if item.is_a?(RPG::State) fo.print("ラルフ#{item.message1}\n") unless item.message1.empty? fo.print("ラルフ#{item.message2}\n") unless item.message2.empty? fo.print("ラルフ#{item.message3}\n") unless item.message3.empty? fo.print("ラルフ#{item.message4}\n") unless item.message4.empty? end if Setting::IS_OUTPUT_NOTE fo.print("メモ:\n#{item.note}\n") unless item.note.empty? end end @data_items = nil end def output(fo) create_info(Color.new(200,200,50)) analize(fo,'Skills','スキル') analize(fo,'Weapons','武器') analize(fo,'Armors','防具') analize(fo,'Items','アイテム') analize(fo,'States','ステート') analize(fo,'Classes','職業') analize(fo,'Actors','アクター') analize(fo,'Enemies','エネミー') dispose_info() end end module_function def output() File.open(Setting::CommonEventMsg_FILENAME, "wb") do |fo| CommonEvent.new.output(fo) end File.open(Setting::MapEventMsg_FILENAME, "wb") do |fo| MapEvent.new.output(fo) end File.open(Setting::BattleEventMsg_FILENAME, "wb") do |fo| BattleEvent.new.output(fo) end File.open(Setting::BaseItemMsg_FILENAME, "wb") do |fo| BaseItem.new.output(fo) end end end module_function def output Message::output() end end TKCG::DebugOutput::output