O TEMA DO FÓRUM ESTÁ EM MANUTENÇÃO. FEEDBACKS AQUI: ACESSAR

Conversor de Autotile VX para XP

Iniciado por RD12, 08/02/2016 às 12:44

Conversor Autotile VX > XP

Compatível com: RMXP

[box class=titlebg]
Descrição
[/box]
Fiz esse script ao notar a necessidade de algumas pessoas em fazer esta conversão. E por não encontrarem um utilitário próprio. O script é um algorítimo que poupa todo o trabalho manual de recorte, colagem e salvar o arquivo. Ele aceita qualquer conjunto de autotiles do RMVX, 3x3, 4x5, por exemplo, desde que os tiles estejam alinhados adequadamente.

[box class=titlebg]
Imagens
[/box]
Tile do VX a ser convertido

Tiles compatíveis com o XP após a conversão


[box class=titlebg]
Script
[/box]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#| RD12 |              Conversor de Autotile
#                          VX para XP
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#**Coloque o autotile a ser convertido na pasta do projeto, com o 
#nome configurável abaixo (Converter.png)
#** Após a conversão verifique na pasta Tiles Convertidos.
#** Troque o diretório da pasta se for converter outro autotile
#para evitar que substituem os já convertidos.
#=begin

module TileConvert
 DIR = "Tiles Convertidos/" #Diretório que salvará os tiles convertidos
 ConvertTile = "Converter" #Arquivo a ser convertido
end

class Scene_Title

  def main
    $game_system = Game_System.new
    $data_system  = load_data("Data/System.rxdata")
    @bitmap = Bitmap.new(TileConvert::ConvertTile)
    @tiles_x = @bitmap.width/64
    @tiles_y = @bitmap.height/96
    @status = IconSplit_Status.new
    @total = (@tiles_x*@tiles_y)
    @status.value = "Convertendo #{@total} tiles... Aguarde"
    @status.refresh
    @count = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
  end
  
  def update
    return if @ended
    
   for tx in 0..@tiles_x
     for ty in 0..@tiles_y
      spacex = tx*64
      spacey = ty*96
      newtile = Bitmap.new(96,128)
      #Primeira e terceira fileiras
      for i in 0..1
        newtile.blt(i*64, 0, @bitmap, Rect.new(i*32+spacex, 0+(spacey), 32, 64))
        newtile.blt(i*64, 64, @bitmap, Rect.new(i*32+spacex, 32+16+(spacey), 32, 32))
        newtile.blt(i*64, 96, @bitmap, Rect.new(i*32+spacex, 64+(spacey), 32, 32))
      end
      #Segunda Fileira
      newtile.blt(32, 32, @bitmap, Rect.new(16+spacex, 32+(spacey), 32, 32))
      newtile.blt(32, 64, @bitmap, Rect.new(16+spacex, 32+16+(spacey), 32, 32))
      newtile.blt(32, 96, @bitmap, Rect.new(16+spacex, 64+(spacey), 16, 32))
      newtile.blt(32+16, 96, @bitmap, Rect.new(32-16+(spacex), 64+(spacey), 16, 32))
      newtile.make_png("Newtile #{tx}-#{ty}", TileConvert::DIR)
      @status.refresh
    end
  end
  @ended = true
  @status.value = (@total).to_s + " Tiles convertidos!"
  @status.ended
  end
end
#WINDOW
class IconSplit_Status < Window_Base
   attr_accessor :value
  def initialize
    super(410/2, 250/2, 300, 200)
    self.windowskin = RPG::Cache.windowskin("001-Blue01") 
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Segoe UI"
    self.contents.font.size = 20
    @value = ""
  end
    
  def refresh
    self.contents.clear
     self.contents.draw_text(0, 0, 300-64, 32, "Conversor de Autotiles Vx > XP",1)
     self.contents.draw_text(0, 20, 300-64, 32, "Por: RD12",1)
     self.contents.draw_text(0, 52, 200, 32, @value)   
    if @ended
     self.contents.draw_text(0, 82, 300-64, 32, "Pronto! Verifique na pasta NewTiles.")   
     self.contents.draw_text(0, 132, 300-64, 32, "Desative o script.")   
    end
  end
  
  def ended
    @ended = true
    refresh
  end
end
#=end

#==============================================================================
#               本脚本出自www.66rpg.com,转载请注明。
#==============================================================================
=begin
==============================================================================
                        Bitmap to PNG By 轮回者
==============================================================================

 对Bitmap对象直接使用
 
 bitmap_obj.make_png(name[, path])
 
 name:保存文件名
 path:保存路径

 感谢66、夏娜、金圭子的提醒和帮助!
   
==============================================================================
=end

module Zlib
  class Png_File < GzipWriter
    #--------------------------------------------------------------------------
    # ● 主处理
    #-------------------------------------------------------------------------- 
    def make_png(bitmap_Fx,mode)
      @mode = mode
      @bitmap_Fx = bitmap_Fx
      self.write(make_header)
      self.write(make_ihdr)
      self.write(make_idat)
      self.write(make_iend)
    end
    #--------------------------------------------------------------------------
    # ● PNG文件头数据块
    #--------------------------------------------------------------------------
    def make_header
      return [0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a].pack("C*")
    end
    #--------------------------------------------------------------------------
    # ● PNG文件情报头数据块(IHDR)
    #-------------------------------------------------------------------------- 
    def make_ihdr
      ih_size = [13].pack("N")
      ih_sign = "IHDR"
      ih_width = [@bitmap_Fx.width].pack("N")
      ih_height = [@bitmap_Fx.height].pack("N")
      ih_bit_depth = [8].pack("C")
      ih_color_type = [6].pack("C")
      ih_compression_method = [0].pack("C")
      ih_filter_method = [0].pack("C")
      ih_interlace_method = [0].pack("C")
      string = ih_sign + ih_width + ih_height + ih_bit_depth + ih_color_type +
               ih_compression_method + ih_filter_method + ih_interlace_method
      ih_crc = [Zlib.crc32(string)].pack("N")
      return ih_size + string + ih_crc
    end
    #--------------------------------------------------------------------------
    # ● 生成图像数据(IDAT)
    #-------------------------------------------------------------------------- 
    def make_idat
      header = "\x49\x44\x41\x54"
      case @mode # 请54~
      when 1
        data = make_bitmap_data#1
      else
        data = make_bitmap_data
      end
      data = Zlib::Deflate.deflate(data, 8)
      crc = [Zlib.crc32(header + data)].pack("N")
      size = [data.length].pack("N")
      return size + header + data + crc
    end
    #--------------------------------------------------------------------------
    # ● 从Bitmap对象中生成图像数据 mode 1(请54~)
    #-------------------------------------------------------------------------- 
    def make_bitmap_data1
      w = @bitmap_Fx.width
      h = @bitmap_Fx.height
      data = []
      for y in 0...h
        data.push(0)
        for x in 0...w
          color = @bitmap_Fx.get_pixel(x, y)
          red = color.red
          green = color.green
          blue = color.blue
          alpha = color.alpha
          data.push(red)
          data.push(green)
          data.push(blue)
          data.push(alpha)
        end
      end
      return data.pack("C*")
    end
    #--------------------------------------------------------------------------
    # ● 从Bitmap对象中生成图像数据 mode 0
    #-------------------------------------------------------------------------- 
    def make_bitmap_data
      gz = Zlib::GzipWriter.open('hoge.gz')
      t_Fx = 0
      w = @bitmap_Fx.width
      h = @bitmap_Fx.height
      data = []
      for y in 0...h
        data.push(0)
        for x in 0...w
          t_Fx += 1
          if t_Fx % 10000 == 0
            Graphics.update
          end
          if t_Fx % 100000 == 0
            s = data.pack("C*")
            gz.write(s)
            data.clear
            #GC.start
          end
          color = @bitmap_Fx.get_pixel(x, y)
          red = color.red
          green = color.green
          blue = color.blue
          alpha = color.alpha
          data.push(red)
          data.push(green)
          data.push(blue)
          data.push(alpha)
        end
      end
      s = data.pack("C*")
      gz.write(s)
      gz.close    
      data.clear
      gz = Zlib::GzipReader.open('hoge.gz')
      data = gz.read
      gz.close
      File.delete('hoge.gz') 
      return data
    end
    #--------------------------------------------------------------------------
    # ● PNG文件尾数据块(IEND)
    #-------------------------------------------------------------------------- 
    def make_iend
      ie_size = [0].pack("N")
      ie_sign = "IEND"
      ie_crc = [Zlib.crc32(ie_sign)].pack("N")
      return ie_size + ie_sign + ie_crc
    end
  end
end
#==============================================================================
# ■ Bitmap
#------------------------------------------------------------------------------
#  关联到Bitmap。
#==============================================================================
class Bitmap
  #--------------------------------------------------------------------------
  # ● 关联
  #-------------------------------------------------------------------------- 
  def make_png(name="like", path="",mode=0)
    make_dir(path) if path != ""
    Zlib::Png_File.open("temp.gz") {|gz|
      gz.make_png(self,mode)
    }
    Zlib::GzipReader.open("temp.gz") {|gz|
      $read = gz.read
    }
    f = File.open(path + name + ".png","wb")
    f.write($read)
    f.close
    File.delete('temp.gz') 
  end
  #--------------------------------------------------------------------------
  # ● 生成保存路径
  #-------------------------------------------------------------------------- 
  def make_dir(path)
    dir = path.split("/")
    for i in 0...dir.size
      unless dir == "."
        add_dir = dir[0..i].join("/")
        begin
          Dir.mkdir(add_dir)
        rescue
        end
      end
    end
  end
end
#==============================================================================
#               本脚本出自www.66rpg.com,转载请注明。
#==============================================================================


[box class=titlebg]
Créditos e Avisos
[/box]
Criador: (Lucas) RD12
Foi usado um script que salva bitmaps, criador por 轮回者

 Muito bom RD12, eu não utilizo o XP mas para quem utiliza com certeza será uma mão na roda.  :ok:

 Muito bom mesmo, conheço uma pessoa que tem que converter a mão pro VX pro XP, é útil mesmo.

2010 ~ 2016 / 2024