Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #=============================================================================
- # Gab RTP Export
- #---------------------------------------------------------------------------
- # @author : Gab!
- # @date : 2014/06/04
- # @version : 1.1
- #---------------------------------------------------------------------------
- # Exporta os arquivos do RTP que estão sendo utilizados pelo jogo para que
- # não haja necessidade de exportar todo o RTP ao distribuir o jogo.
- #
- # ATENÇÃO: Este script não identifica automaticamente recursos utilizados por
- # outros scripts. O alvo é o banco de dados, mapas e eventos.
- #---------------------------------------------------------------------------
- # Basta colocar o script acima do Main para ativá-lo.
- #=============================================================================
- if $TEST
- # Método necessário
- class << File
- def copy(from, to, buffer=0)
- File.open(from, 'rb'){|f|
- File.open(to, 'wb'){|t|
- if (buffer > 0) and block_given?
- until f.eof
- t << f.read(buffer)
- yield
- end
- else
- t << f.read
- end
- }
- }
- end
- end
- # Arquivos Gráficos
- @Graphics = {
- Animations: [],
- BattleBacks1: [],
- BattleBacks2: [],
- Battlers: [],
- Characters: [],
- Faces: [],
- Parallaxes: [],
- System: [],
- Tilesets: [],
- Titles1: [],
- Titles2: [],
- }
- # Arquivos Sonoros
- @Audio = {
- BGM: [],
- BGS: [],
- SE: [],
- ME: [],
- }
- # Actors
- load_data('Data/Actors.rvdata2').each{|actor|
- next unless actor
- @Graphics[:Characters] << actor.character_name
- @Graphics[:Faces] << actor.face_name
- }
- # Enemies
- load_data('Data/Enemies.rvdata2').each{|enemy|
- next unless enemy
- @Graphics[:Battlers] << enemy.battler_name
- }
- # Animations
- load_data('Data/Animations.rvdata2').each{|animation|
- next unless animation
- @Graphics[:Animations] << animation.animation1_name
- @Graphics[:Animations] << animation.animation2_name
- animation.timings.each{|timing|
- @Audio[:SE] << timing.se.name
- }
- }
- # Tilesets
- load_data('Data/Tilesets.rvdata2').each{|tileset|
- next unless tileset
- tileset.tileset_names.each{|tileset_name|
- next if tileset_name.empty?
- @Graphics[:Tilesets] << tileset_name
- }
- }
- # Parallaxes
- Dir['Data/Map???.rvdata2'].each{|mapfile|
- map = load_data(mapfile)
- @Graphics[:Parallaxes ] << map.parallax_name
- @Graphics[:BattleBacks1] << map.battleback1_name
- @Graphics[:BattleBacks1] << map.battleback2_name
- @Audio[:BGM] << map.bgm.name
- @Audio[:BGS] << map.bgs.name
- map.events.each_value{|event|
- event.pages.each{|page|
- page.list.each{|command|
- index = [241, 245, 249, 250].index(command.code)
- next unless index
- key = [:BGM, :BGS, :ME, :SE][index]
- @Audio[key] << command.parameters.first.name
- }
- }
- }
- }
- # System
- system = load_data('Data/System.rvdata2')
- @Graphics[:Characters] << system.airship.character_name
- @Graphics[:Characters] << system.ship.character_name
- @Graphics[:Characters] << system.boat.character_name
- @Graphics[:Titles1] << system.title1_name
- @Graphics[:Titles2] << system.title2_name
- @Graphics[:System] << "IconSet"
- @Graphics[:System] << "Window"
- @Graphics[:System] << "GameOver"
- @Graphics[:System] << "Balloon"
- @Graphics[:System] << "Shadow"
- @Graphics[:System] << "BattleStart"
- @Audio[:BGM] << system.airship.bgm.name
- @Audio[:BGM] << system.ship.bgm.name
- @Audio[:BGM] << system.boat.bgm.name
- @Audio[:BGM] << system.title_bgm.name
- @Audio[:BGM] << system.battle_bgm.name
- @Audio[:ME] << system.gameover_me.name
- @Audio[:ME] << system.battle_end_me.name
- @Audio[:SE] += system.sounds.map(&:name)
- # Identifica diretório do RTP
- library = 0.chr * 256
- Win32API.new('kernel32', 'GetPrivateProfileStringA', 'PPPPLP', 'L').call(
- 'Game', 'Library', '', library, library.size, './Game.ini'
- )
- GameDLL = library.delete!("\0")
- RGSSGetRTPPath = Win32API.new(GameDLL, 'RGSSGetRTPPath', 'L', 'L')
- RGSSGetPathWithRTP = Win32API.new(GameDLL, 'RGSSGetPathWithRTP', 'L', 'L')
- @RTP = DL::CPtr.new(RGSSGetPathWithRTP.call(RGSSGetRTPPath.call(1))).
- to_s(480).
- delete(0.chr).
- gsub('\\', '/')
- if @RTP.empty?
- msgbox("Gab RTP Export: Caminho para o RTP não encontrado!")
- else
- # Verificação dos arquivos
- @Graphics.each_pair{|folder, files|
- files.uniq.each{|file|
- next if file.empty?
- next unless Dir["Graphics/#{folder}/#{file}.*"].empty?
- fromFile = Dir["#{@RTP}/Graphics/#{folder}/#{file}.*"].select{|f|
- File.extname(f) != '.txt'
- }.first
- toFile = "Graphics/#{folder}/#{file}#{File.extname(fromFile)}"
- File.copy(fromFile, toFile)
- }
- }
- @Audio.each_pair{|folder, files|
- files.uniq.each{|file|
- next if file.empty?
- next unless Dir["Audio/#{folder}/#{file}.*"].empty?
- fromFile = Dir["#{@RTP}/Audio/#{folder}/#{file}.*"].first
- toFile = "Audio/#{folder}/#{file}#{File.extname(fromFile)}"
- File.copy(fromFile, toFile)
- }
- }
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment