SHARE
TWEET

Localization Tool

Holy87 May 28th, 2015 (edited) 320 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. =begin
  2.  ==============================================================================
  3.   ■ Strumento per la localizzazione di Holy87
  4.       versione 1.0.1
  5.       Difficoltà utente: ★
  6.       Licenza: CC. Chiunque può scaricare, modificare, distribuire e utilizzare
  7.       lo script nei propri progetti, sia amatoriali che commerciali. Vietata
  8.       l'attribuzione impropria.
  9.  ==============================================================================
  10.     Questo script localizza automaticamente un gioco già completo, creando un
  11.     file della lingua specifico.
  12.  ==============================================================================
  13.   ■ Compatibilità
  14.     Necessita dello script di localizzazione.
  15.  ==============================================================================
  16.   ■ Changelog
  17.     07/06/2015 -> v1.0.1
  18.     ● Fix di un errore di conversione
  19.     ● Fix per un problema che cancellava i nomi delle mappe
  20.  ==============================================================================
  21.   ■ Installazione e istruzioni
  22.     ● Installare questo script sotto Materials e prima del Main.
  23.     ● Necessita dello script di localizzazione.
  24.     ● Assicurarsi di aver creato la cartella Localization nel gioco.
  25.     ● FARE UNA COPIA DI BACKUP. Il tool modifica irrimediabilmente TUTTI i
  26.       dialoghi, quindi assicurati di fare una copia del gioco nel caso vada
  27.       storto qualcosa.
  28.     ● Avviare il gioco in modalità TEST, quindi alla schermata del titolo
  29.       tieni premuto la freccia sinistra e premi ESC. Seleziona la lingua in cui
  30.       verrà creato il file di localizzazione (se non c'è metti altro, poi potrai
  31.       configurare l'header manualmente)
  32.     ● Al termine dell'operazione, il file della lingua sarà creato.
  33.     ● IMPORTANTE: Appena finita la conversione, chiuderere RPG Maker SENZA
  34.       salvare (o le modifiche verranno sovrascritte) quindi riaprire RPG Maker.
  35.    
  36.    
  37.   ■ Cosa fa lo strumento
  38.      
  39.     ● Crea un file della lingua nella cartella Localization, con header e
  40.       rispettive informazioni
  41.     ● Scandaglia tutto il database e scrive nel file le informazioni di tutti
  42.       gli eroi, classi, skill, oggetti, armi, armature, nemici e stati
  43.     ● Cerca in tutte le mappe, in tutte le battaglie e in tutti gli eventi comuni
  44.       i messaggi di dialoghi e, quando li trova, crea la stringa con la chiave
  45.       all'interno del file e MODIFICA il dialogo con la chiave della stringa
  46.       creata
  47.     ● Scrive anche i nomi delle mappe
  48.    
  49.   ■ Cosa NON fa lo strumento
  50.  
  51.     ● Traduzione. Non fa alcuna traduzione, una volta creata la localizzazione
  52.       dovrai tradurre stringa per stringa il file (o farlo fare ad altri) nelle
  53.       altre lingue.
  54.     ● Creare una localizzazione per le stringhe negli script. Mi spiace, ma
  55.       questa è una cosa che si deve fare manualmente.
  56.      
  57.  ==============================================================================
  58. =end
  59. module LocalizationOptions
  60.   #--------------------------------------------------------------------------
  61.   # * Lingue del menu. È semplicemente una comodità per creare lingue già
  62.   #   configurare. Altro crea il file della lingua, ma bisogna modificare
  63.   #   l'header manualmente.
  64.   #--------------------------------------------------------------------------
  65.   LANGUAGES = {
  66.   #ID      #sigla     #nome completo
  67.   1033  => ["en",     "English"],             #inglese-stati uniti
  68.   1040  => ["it",     "Italiano"],            #italiano tradizionale
  69.   1036  => ["fr",     "Français"],            #francese
  70.   1031  => ["de",     "Deutsch"],             #tedesco
  71.   1034  => ["es",     "Español"],             #spagnolo
  72.   1030  => ["da",     "Danske"],              #danese
  73.   1026  => ["bg-BG"   "Belgian"],             #belga
  74.   1027  => ["ca-ES"   "Català"],              #catalano
  75.   1041  => ["jp",     "日本 - 日本語"],        #giapponese
  76.   1042  => ["ko",     "한국의"],               #coreano
  77.   1049  => ["ru",     "Pусский"],             #russo
  78.   2055  => ["de-BG",  "Deutsch - Schweizer"], #tedesco-svizzero
  79.   4103  => ["de-LU",  "Deutsch - Luxemburg"], #tedesco-lussemburgo
  80.   2057  => ["en-UL",  "English - UK"],        #inglese-regno unito
  81.   3081  => ["en-AU",  "English - Australia"], #inglese australiano
  82.   4105  => ["en-CA",  "English - Canada"],    #inglese canadese
  83.   5129  => ["en-NZ",  "English - New Zeland"],#inglese nuova zelanda
  84.   2058  => ["es-MX",  "Español - México"],    #spagnolo messicano
  85.   11274 => ["es-AR",  "Español - Cile"],      #spagnolo-cile
  86.   2060  => ["fr-BE",  "Français - Belgique"], #francese belgio
  87.   4108  => ["fr-CH",  "Français - Suisse"],   #francese svizzero
  88.   2064  => ["it-CH",  "Italiano - Svizzera"], #italiano svizzero
  89.   0     => ["na",     "Altro"],  #altra lingua da configurare successivamente
  90.   }
  91.   #--------------------------------------------------------------------------
  92.   # * Vocaboli della schermata
  93.   #--------------------------------------------------------------------------
  94.   VOCABS = {
  95.   :start => "Inizia conversione",
  96.   :select=> "Seleziona lingua",
  97.   :exit  => "Esci",
  98.   :wait  => "Creazione del file %s in corso...",
  99.   :done  => "Creazione della lingua completata.",
  100.   }
  101.   #--------------------------------------------------------------------------
  102.   # * Le chiavi delle stringhe che verranno create.
  103.   #--------------------------------------------------------------------------
  104.   STRING = "Map[%03d] Ev[%03d] Page %02d Line %d"
  105.   CHOICE = "Map[%03d] Ev[%03d] Page %02d Line %d - %d"
  106.   BATTLE = "Troop[%03d] Page %02d Line %d"
  107.   BATTLC = "Troop[%03d] Page %02d Line %d - %d"
  108.   COMMON = "C. Ev[%03d] Line %d"
  109.   COMMOC = "C. Ev[%03d] Line %d - %d"
  110.   MAPNAM = "Map[%03d] Name"
  111.  
  112. #--------------------------- FINE DELLO SCRIPT ------------------------------
  113.  
  114.  
  115.  
  116.  
  117.  
  118.   #--------------------------------------------------------------------------
  119.   # * Returns the proper vocab
  120.   #--------------------------------------------------------------------------
  121.   def vocab(vocab_id)
  122.     return VOCABS[vocab_id]
  123.   end
  124. end
  125.  
  126. #==============================================================================
  127. # ** Scene_Localization
  128. #------------------------------------------------------------------------------
  129. #  Scene for localization tool
  130. #==============================================================================
  131. class Scene_Localization < Scene_MenuBase
  132.   include LocalizationOptions
  133.   #--------------------------------------------------------------------------
  134.   # * start
  135.   #--------------------------------------------------------------------------
  136.   def start
  137.     super
  138.     create_localization_window
  139.     create_language_window
  140.     create_popup_window
  141.   end
  142.   #--------------------------------------------------------------------------
  143.   # * localization window creation
  144.   #--------------------------------------------------------------------------
  145.   def create_localization_window
  146.     @localization_window = Window_LocalizationInfo.new
  147.     @localization_window.set_handler(:start, method(:open_language))
  148.     @localization_window.set_handler(:cancel, method(:return_scene))
  149.     @localization_window.activate
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # * language list windows creation
  153.   #--------------------------------------------------------------------------
  154.   def create_language_window
  155.     x = @localization_window.x
  156.     @language_window = Window_LanguageList.new(x, 0, 250, Graphics.height)
  157.     @language_window.set_handler(:ok, method(:start_creation))
  158.     @language_window.set_handler(:cancel, method(:open_localization))
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # * popup window creation
  162.   #--------------------------------------------------------------------------
  163.   def create_popup_window
  164.     @popup_window = Window_ToolPpup.new
  165.     @popup_window.set_pressure_method(method(:process_done))
  166.   end
  167.   #--------------------------------------------------------------------------
  168.   # * start creation
  169.   #--------------------------------------------------------------------------
  170.   def start_creation
  171.     @language_window.openness = 0
  172.     @popup_window.visible = true
  173.     @popup_window.set_text(vocab(:wait))
  174.     Graphics.update
  175.     localization_tool = Loc_Tool.new(@language_window.item)
  176.     localization_tool.start_creating
  177.     @popup_window.activate
  178.     @popup_window.set_text(sprintf(vocab(:done), localization_tool.file_name))
  179.   end
  180.   #--------------------------------------------------------------------------
  181.   # * language selection process
  182.   #--------------------------------------------------------------------------
  183.   def open_language
  184.     @localization_window.close
  185.     @language_window.open
  186.     @language_window.activate
  187.   end
  188.   #--------------------------------------------------------------------------
  189.   # * localization process (back)
  190.   #--------------------------------------------------------------------------
  191.   def open_localization
  192.     @language_window.close
  193.     @localization_window.open
  194.     @localization_window.activate
  195.   end
  196.   #--------------------------------------------------------------------------
  197.   # * localization done
  198.   #--------------------------------------------------------------------------
  199.   def process_done
  200.     @popup_window.visible = false
  201.     @popup_window.deactivate
  202.     @localization_window.open
  203.     @localization_window.activate
  204.   end
  205. end
  206.  
  207. #==============================================================================
  208. # ** Window_LocalizationInfo
  209. #------------------------------------------------------------------------------
  210. #  window for localization commands
  211. #==============================================================================
  212. class Window_LocalizationInfo < Window_Command
  213.   include LocalizationOptions
  214.   #--------------------------------------------------------------------------
  215.   # * initialize
  216.   #--------------------------------------------------------------------------
  217.   def initialize
  218.     super(0, 0)
  219.     update_placement
  220.     self.openness = 0
  221.     open
  222.   end
  223.   #--------------------------------------------------------------------------
  224.   # * Get Window Width
  225.   #--------------------------------------------------------------------------
  226.   def window_width
  227.     return 250
  228.   end
  229.   #--------------------------------------------------------------------------
  230.   # * Update Window Position
  231.   #--------------------------------------------------------------------------
  232.   def update_placement
  233.     self.x = (Graphics.width - width) / 2
  234.     self.y = (Graphics.height * 1.6 - height) / 2
  235.   end
  236.   #--------------------------------------------------------------------------
  237.   # * Create Command List
  238.   #--------------------------------------------------------------------------
  239.   def make_command_list
  240.     add_command(vocab(:start), :start)
  241.     add_command(vocab(:exit), :cancel)
  242.   end
  243. end
  244.  
  245. #==============================================================================
  246. # ** Window_LanguageList
  247. #------------------------------------------------------------------------------
  248. #  Shows the list of avaiable language for this tool
  249. #==============================================================================
  250. class Window_LanguageList < Window_Selectable
  251.   include LocalizationOptions
  252.   #--------------------------------------------------------------------------
  253.   # * Object initialization
  254.   #--------------------------------------------------------------------------
  255.   def initialize(x, y, width, height)
  256.     super
  257.     make_language_list
  258.     create_contents
  259.     refresh
  260.     self.index = 0
  261.     self.openness = 0
  262.   end
  263.   #--------------------------------------------------------------------------
  264.   # * Make language list
  265.   #--------------------------------------------------------------------------
  266.   def make_language_list
  267.     @data = get_languages(LANGUAGES)
  268.   end
  269.   #--------------------------------------------------------------------------
  270.   # * Get Number of Items
  271.   #--------------------------------------------------------------------------
  272.   def item_max
  273.     @data ? @data.size : 0
  274.   end
  275.   #--------------------------------------------------------------------------
  276.   # * draw_item
  277.   #   index: indice dell
  278.   #--------------------------------------------------------------------------
  279.   def draw_item(index)
  280.     item = @data[index]
  281.     if item
  282.       rect = item_rect(index)
  283.       rect.width -= 4
  284.       draw_text(rect, item.name)
  285.     end
  286.   end
  287.   #--------------------------------------------------------------------------
  288.   # * Selected item
  289.   #--------------------------------------------------------------------------
  290.   def item
  291.     return @data[@index]
  292.   end
  293.   #--------------------------------------------------------------------------
  294.   # * Get all languages
  295.   #--------------------------------------------------------------------------
  296.   def get_languages(hash)
  297.     ary = []
  298.     hash.each_pair do |a, b|
  299.       ary.push(Language.new(a, b[0], b[1]))
  300.     end
  301.     return ary
  302.   end
  303. end    
  304.  
  305. #==============================================================================
  306. # ** Window_ToolPpup
  307. #------------------------------------------------------------------------------
  308. #  Window that appears when the localization is finished
  309. #==============================================================================
  310. class Window_ToolPpup < Window_Base
  311.   #--------------------------------------------------------------------------
  312.   # * Object initialization
  313.   #--------------------------------------------------------------------------
  314.   def initialize
  315.     super(0,0,0,line_height + standard_padding*2)
  316.     deactivate
  317.     self.visible = false
  318.   end
  319.   #--------------------------------------------------------------------------
  320.   # * Set new text
  321.   #   text = new text
  322.   #--------------------------------------------------------------------------
  323.   def set_text(text)
  324.     width = text_size(text).width + self.padding*2
  325.     self.width = width
  326.     x = (Graphics.width - width)/2
  327.     y = (Graphics.height - height)/2
  328.     @text = text
  329.     refresh
  330.   end
  331.   #--------------------------------------------------------------------------
  332.   # * set the method launched when pressing :C
  333.   #--------------------------------------------------------------------------
  334.   def set_pressure_method(mth)
  335.     @method = mth
  336.   end
  337.   #--------------------------------------------------------------------------
  338.   # * Refresh
  339.   #--------------------------------------------------------------------------
  340.   def refresh
  341.     create_contents
  342.     return if @text.nil?
  343.     draw_text(0,0,contents_width, line_height, @text)
  344.   end
  345.   #--------------------------------------------------------------------------
  346.   # * Update
  347.   #--------------------------------------------------------------------------
  348.   def update
  349.     super
  350.     check_pressure if self.active == true
  351.   end
  352.   #--------------------------------------------------------------------------
  353.   # * Pressure check
  354.   #--------------------------------------------------------------------------
  355.   def check_pressure
  356.     return unless @method
  357.     @method.call if Input.trigger?(:C) or Input.trigger?(:B)
  358.   end
  359. end
  360.  
  361. #==============================================================================
  362. # ** Loc_Tool
  363. #------------------------------------------------------------------------------
  364. #  Localization class that parses all the game and creates the file.
  365. #==============================================================================
  366. class Loc_Tool
  367.   include LocalizationOptions
  368.   #--------------------------------------------------------------------------
  369.   # * Object initialization
  370.   #   language: language object
  371.   #--------------------------------------------------------------------------
  372.   def initialize(language)
  373.     @id = language.id
  374.     @short = language.short
  375.     @name = language.name
  376.   end
  377.   #--------------------------------------------------------------------------
  378.   # * Returns the language file name
  379.   #--------------------------------------------------------------------------
  380.   def file_name
  381.     H87Localization.language_folder+"/#{@short}.ini"
  382.   end
  383.   #--------------------------------------------------------------------------
  384.   # * Creation process
  385.   #--------------------------------------------------------------------------
  386.   def start_creating
  387.     File.open(file_name,"w") do |file|
  388.       file.write(header)
  389.       file.write(actors)
  390.       file.write(classes)
  391.       file.write(skills)
  392.       file.write(items)
  393.       file.write(weapons)
  394.       file.write(armors)
  395.       file.write(enemies)
  396.       file.write(states)
  397.       file.write(terms)
  398.       file.write(dialogs)
  399.     end
  400.   end
  401.   #--------------------------------------------------------------------------
  402.   # * Header creation
  403.   #--------------------------------------------------------------------------
  404.   def header
  405.     mp = Mark_Parser.new("header")
  406.     mp.add_item("Language",@name)
  407.     mp.add_item("ID",@id)
  408.     return mp.to_s
  409.   end
  410.   #--------------------------------------------------------------------------
  411.   # * Actors list creation
  412.   #--------------------------------------------------------------------------
  413.   def actors
  414.     attributes = [:id, :name, :nickname, :description]
  415.     return attr_process("actors",$data_actors,attributes)
  416.   end
  417.   #--------------------------------------------------------------------------
  418.   # * Classes list creation
  419.   #--------------------------------------------------------------------------
  420.   def classes
  421.     attributes = [:id, :name]
  422.     return attr_process("classes",$data_classes,attributes)
  423.   end
  424.   #--------------------------------------------------------------------------
  425.   # * Skills list creation
  426.   #--------------------------------------------------------------------------
  427.   def skills
  428.     attributes = [:id, :name, :description, :message1, :message2]
  429.     return attr_process("skills",$data_skills,attributes)
  430.   end
  431.   #--------------------------------------------------------------------------
  432.   # * Items list creation
  433.   #--------------------------------------------------------------------------
  434.   def items
  435.     attributes = [:id, :name, :description]
  436.     return attr_process("items",$data_items,attributes)
  437.   end
  438.   #--------------------------------------------------------------------------
  439.   # * Weapons list creation
  440.   #--------------------------------------------------------------------------
  441.   def weapons
  442.     attributes = [:id, :name, :description]
  443.     return attr_process("weapons",$data_weapons,attributes)
  444.   end
  445.   #--------------------------------------------------------------------------
  446.   # * Armors list creation
  447.   #--------------------------------------------------------------------------
  448.   def armors
  449.     attributes = [:id, :name, :description]
  450.     return attr_process("armors",$data_armors,attributes)
  451.   end
  452.   #--------------------------------------------------------------------------
  453.   # * Enemies list creation
  454.   #--------------------------------------------------------------------------
  455.   def enemies
  456.     attributes = [:id, :name]
  457.     return attr_process("enemies",$data_enemies,attributes)
  458.   end
  459.   #--------------------------------------------------------------------------
  460.   # * States list creation
  461.   #--------------------------------------------------------------------------
  462.   def states
  463.     attributes = [:id, :name, :message1, :message2, :message3, :message4]
  464.     return attr_process("states",$data_states,attributes)
  465.   end
  466.   #--------------------------------------------------------------------------
  467.   # * Terms list creation
  468.   #--------------------------------------------------------------------------
  469.   def terms
  470.     terms = $data_system.terms
  471.     mp = Mark_Parser.new("params")
  472.     for i in 0..terms.basic.size-1
  473.       mp.add_item(i, terms.params[i])
  474.     end
  475.     mp2 = Mark_Parser.new("basic")
  476.     for i in 0..terms.basic.size-1
  477.       mp2.add_item(i, terms.basic[i])
  478.     end
  479.     mp3 = Mark_Parser.new("etypes")
  480.     for i in 0..terms.etypes.size-1
  481.       mp3.add_item(i, terms.etypes[i])
  482.     end
  483.     mp4 = Mark_Parser.new("commands")
  484.     for i in 0..terms.commands.size-1
  485.       mp4.add_item(i, terms.commands[i])
  486.     end
  487.     return mp.to_s + mp2.to_s + mp3.to_s + mp4.to_s
  488.   end
  489.   #--------------------------------------------------------------------------
  490.   # * Dialog list creation
  491.   #--------------------------------------------------------------------------
  492.   def dialogs
  493.     mp = Mark_Parser.new("strings")
  494.     records = 0
  495.     records += get_from_map(mp)
  496.     records += get_from_troops(mp)
  497.     records += get_from_common_events(mp)
  498.     println "#{records} strings created from Message Dialogs."
  499.     return mp.to_s
  500.   end
  501.   #--------------------------------------------------------------------------
  502.   # * Get all message box on all over the maps
  503.   #--------------------------------------------------------------------------
  504.   def get_from_map(mp)
  505.     records = 0
  506.     for i in 1..999
  507.       map_file = sprintf("Data/Map%03d.rvdata2", i)
  508.       next unless File.exist?(map_file)
  509.       map = load_data(map_file)
  510.       if !map.display_name.empty?
  511.         name = sprintf(MAPNAM,i)
  512.         mp.add_item(name, map.display_name)
  513.         map.display_name = "{S: #{name}}"
  514.       end
  515.       map.events.each_pair do |event_id, event|
  516.         event.pages.each_with_index do |page, page_i|
  517.           page.list.each_with_index do |command, command_i|
  518.             case command.code
  519.             when 401
  520.               next if command.parameters[0] =~ H87Localization::REG_EXCAPE
  521.               name = sprintf(STRING,i,event_id,page_i,command_i)
  522.               mp.add_item(name, command.parameters[0])
  523.               command.parameters[0] = "{S: #{name}}"
  524.               records += 1
  525.             when 102
  526.               command.parameters[0].each_with_index do |param, param_i|
  527.                 next if param =~ H87Localization::REG_EXCAPE
  528.                 name = sprintf(CHOICE,i,event_id,page_i,command_i,param_i)
  529.                 mp.add_item(name, param)
  530.                 command.parameters[0][param_i] = "{S: #{name}}"
  531.                 records += 1
  532.               end
  533.             end
  534.           end
  535.         end
  536.       end
  537.       save_data(map, map_file)
  538.     end
  539.     return records
  540.   end
  541.   #--------------------------------------------------------------------------
  542.   # * Get all message box in all troops
  543.   #--------------------------------------------------------------------------
  544.   def get_from_troops(mp)
  545.     records = 0
  546.     for troop in $data_troops
  547.       next if troop.nil?
  548.       troop.pages.each_with_index do |page, page_i|
  549.         page.list.each_with_index do |command, command_i|
  550.           case command.code
  551.           when 401
  552.             next if command.parameters[0] =~ H87Localization::REG_EXCAPE
  553.             name = sprintf(BATTLE,troop.id,page_i,command_i)
  554.             mp.add_item(name, command.parameters[0])
  555.             command.parameters[0] = "{S: #{name}}"
  556.             records += 1
  557.           when 102
  558.             command.parameters[0].each_with_index do |param, param_i|
  559.               next if param =~ H87Localization::REG_EXCAPE
  560.               name = sprintf(BATTLC,troop.id,page_i,command_i,param_i)
  561.               mp.add_item(name, param)
  562.               command.parameters[0][param_i] = "{S: #{name}}"
  563.               records += 1
  564.             end
  565.           end
  566.         end
  567.       end
  568.     end
  569.     save_data($data_troops,"Data/Troops.rvdata2")
  570.     return records
  571.   end
  572.   #--------------------------------------------------------------------------
  573.   # * Gets all message box in all common events
  574.   #--------------------------------------------------------------------------
  575.   def get_from_common_events(mp)
  576.     records = 0
  577.     for event in $data_common_events
  578.       next if event.nil?
  579.       event.list.each_with_index do |command, command_i|
  580.         case command.code
  581.         when 401
  582.           next if command.parameters[0] =~ H87Localization::REG_EXCAPE
  583.           name = sprintf(COMMON,event.id,command_i)
  584.           mp.add_item(name, command.parameters[0])
  585.           command.parameters[0] = "{S: #{name}}"
  586.           records += 1
  587.         when 102
  588.           command.parameters[0].each_with_index do |param, param_i|
  589.             next if param =~ H87Localization::REG_EXCAPE
  590.             name = sprintf(COMMOC,event.id,command_i,param_i)
  591.             mp.add_item(name, param)
  592.             command.parameters[0][param_i] = "{S: #{name}}"
  593.             records += 1
  594.           end
  595.         end
  596.       end
  597.     end
  598.     save_data($data_common_events, "Data/CommonEvents.rvdata2")
  599.     return records
  600.   end
  601.   #--------------------------------------------------------------------------
  602.   # * Process that creates tag with attributes
  603.   #   name: tag name
  604.   #   array: database array
  605.   #   attributes: attributes to copy
  606.   #--------------------------------------------------------------------------
  607.   def attr_process(name, array, attributes)
  608.     mp = Mark_Parser.new(name)
  609.     for item in array
  610.       next if item.nil?
  611.       next if item.name.empty?
  612.       next if item.name == " "
  613.       mp.add_item
  614.       for attr in attributes
  615.         attr_value = eval("item.#{attr}")
  616.         next if attr_value == ""
  617.         mp.push_attr(attr.to_s, attr_value)
  618.       end
  619.     end
  620.     println "#{name} saved. #{array.size} lines created."
  621.     return mp.to_s
  622.   end
  623. end
  624.  
  625. #==============================================================================
  626. # ** Mark Parser
  627. #------------------------------------------------------------------------------
  628. #  This class is used within Localization_Tool and creates the string that
  629. #  will be written into the file.
  630. #==============================================================================
  631. class Mark_Parser
  632.   attr_accessor :tag
  633.   #--------------------------------------------------------------------------
  634.   # * Object initialization
  635.   #--------------------------------------------------------------------------
  636.   def initialize(tag)
  637.     @tag = tag
  638.     @items = []
  639.   end
  640.   #--------------------------------------------------------------------------
  641.   # * Add attribute to item
  642.   #   attr_name: name of attribute
  643.   #   value: value of attribute
  644.   #--------------------------------------------------------------------------
  645.   def push_attr(attr_name, value)
  646.     return if value =~ H87Localization::REG_EXCAPE
  647.     val = value.to_s.gsub(/[\r\n]+/,"\\n").gsub(";","\\;")
  648.     @items.last.push("#{attr_name}:#{val}")
  649.   end
  650.   #--------------------------------------------------------------------------
  651.   # * Add new item
  652.   #--------------------------------------------------------------------------
  653.   def add_item(attr_name = nil, value = nil)
  654.     @items.push([])
  655.     push_attr(attr_name, value) if attr_name != nil
  656.   end
  657.   #--------------------------------------------------------------------------
  658.   # * String converter
  659.   #--------------------------------------------------------------------------
  660.   def to_s
  661.     string = ""
  662.     string << "<#{@tag}>\n"
  663.     @items.each do |item|
  664.       string << item * "; "
  665.       string << "\n"
  666.     end
  667.     string << "</#{@tag}>\n\n"
  668.     return string
  669.   end
  670. end
  671.  
  672. #==============================================================================
  673. # ** Scene_Title
  674. #------------------------------------------------------------------------------
  675. #  Access for tool's scene
  676. #==============================================================================
  677. class Scene_Title < Scene_Base
  678.   alias h87loctool_update update unless $@
  679.   #--------------------------------------------------------------------------
  680.   # * update
  681.   #--------------------------------------------------------------------------
  682.   def update
  683.     h87loctool_update
  684.     go_loc_tool if Input.trigger?(:B) && Input.press?(:LEFT) && $TEST
  685.   end
  686.   #--------------------------------------------------------------------------
  687.   # * go to localizer tool scene
  688.   #--------------------------------------------------------------------------
  689.   def go_loc_tool
  690.     SceneManager.call(Scene_Localization)
  691.   end
  692. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top