¡Bienvenid@ a Mundo Maker!

¿Quieres aprender todo sobre el RPG Maker?



Regístrate y forma parte de Mundo Maker.
Conectarse

Recuperar mi contraseña

Temas importantes
----------------------------------------
Páginas con recursos RPG Maker
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
----------------------------------------
Últimos temas
» Tutorial Interactivo [Uso de interruptores]
por Ledai Hoy a las 16:58

» Necesito Script
por Elian84 Hoy a las 04:44

» Holaaa a tod@s!!!
por chronoMxx Hoy a las 03:41

» [AYUDA]Hootshot de moghunter
por Rudy_kinneas Hoy a las 01:06

» El poder oculto (Segunda entrega)
por alex1633 Ayer a las 23:18

» Hola mucho gusto
por Hk Diamond Ayer a las 13:49

» SoraDeathss se presenta!
por chronoMxx Ayer a las 07:50

» {AYUDA}Blizz-ABS Script
por chronoMxx Ayer a las 06:45

» las cosas como son...
por Bleuw Ayer a las 04:18

» Busco artistas graficos para proyecto serio
por Rudy_kinneas 2016-12-02, 20:52

Afiliados
Estadísticas
Tenemos 3381 miembros registrados.
El último usuario registrado es Hk Diamond.

Nuestros miembros han publicado un total de 79767 mensajes en 11247 argumentos.
Navega con Google Chrome
[DESCARGA]

[XP][WecTools] Load Tile Support

 :: RPG Maker :: Scripts

Ver el tema anterior Ver el tema siguiente Ir abajo

RPG Maker XP [XP][WecTools] Load Tile Support

Mensaje por Wecoc el 2016-05-07, 19:24

Hicimos éste script entre Eron y yo a partir de una idea interesante que tuvo.

- Éste script debe implentarse en la base de scripts WecTools
- Éste script ya viene implementado por defecto en la última versión del proyecto WecTools

No es un 'tool' del sistema sinó un script con una funcionalidad añadida, pero igualmente va encima de main. Lo que hace es añadir una nueva opción de cargado; si pulsas SHIFT y clicas en la imagen que quieres cargar se abre una ventana para seleccionar los tiles que te interesen.

Autores: Eron & Wecoc
Versión: 1.0 (ESP)

Imagen:

Spoiler:

Script:

Código:
#==============================================================================
# ** [WecTools] Load Tile Support
#==============================================================================
# * Éste script requiere la base de scripts WecTools versión 0.7 o superior.
#------------------------------------------------------------------------------
# Autores: Eron & Wecoc
#==============================================================================

module WecTools
 
  LOAD_TILE_SUPPORT = true # NO CAMBIAR ÉSTO
 
  FILE_GRID_COLOR = Color.new(128, 128, 128, 128)
  FILE_SEL_COLOR  = Color.new(0, 255, 0, 128)
 
  GRID_MIN = 16
  GRID_MAX = 256
 
end

#==============================================================================
# ** Window_File
#==============================================================================

class Window_File < Window_Base
  unless $@
    alias load_tile_dis dispose
    alias load_tile_x x=
    alias load_tile_y y=
    alias load_tile_z z=         
    alias load_tile_upd update
    alias load_tile_ref refresh
  end
 
  def refresh
    load_tile_ref
    if @type == "load"
      self.contents.font.size = 10
      self.contents.font.color = disabled_color
      self.contents.draw_text(336, 192, 64, 16, "SHIFT")
      self.contents.font.size = default_font.size
      self.contents.font.color = normal_color
    end
  end
 
  def refresh_bar
    @bar_sprite.bitmap = Bitmap.new(self.width, 16)
    dest_rect = Rect.new(1, 1, self.width - 2, 16)
    rect = Rect.new(0, 0, 1, 16)
    if self.enabled == true and self.active == true or !@tilemap_window.nil?
      bitmap = RPG::Cache.windowskin(@template + "/Window_Enabled")
    else
      bitmap = RPG::Cache.windowskin(@template + "/Window_Disabled")
    end
    @bar_sprite.bitmap.stretch_blt(dest_rect, bitmap, rect)
    if self.close_option == true
      rect = Rect.new(48, 0, 16, 16)
      bitmap = RPG::Cache.windowskin(@template + "/Window_Buttons")
      @bar_sprite.bitmap.blt(self.width - 16 - 2, 2, bitmap, rect)
    end
    if @title != ""
      @bar_sprite.bitmap.font.name = default_font.name
      @bar_sprite.bitmap.font.size = default_font.size
      @bar_sprite.bitmap.font.color = normal_color
      @bar_sprite.bitmap.font.bold = true
      @bar_sprite.bitmap.draw_text(8, 0, self.width, 16, @title)
    end
  end
 
  def dispose
    load_tile_dis
    @tilemap_window.dispose rescue nil
  end
 
  def x=(x)
    dx = x - @x
    load_tile_x(x)
    unless @tilemap_window.nil?
      @tilemap_window.x += dx
    end
  end
 
  def y=(y)
    dy = y - @y
    load_tile_y(y)
    unless @tilemap_window.nil?
      @tilemap_window.y += dy
    end
  end
 
  def z=(z)
    dz = z - @z
    load_tile_z(z)
    unless @tilemap_window.nil?
      @tilemap_window.z += dz
    end
  end
 
  def update
    if self.active && @tilemap_window.nil?
      if @type == "load"
        if Input.press?(Input::SHIFT)
          if !@image.bitmap.nil?
            update_shift_mode
          end
        end
      end
    end
    load_tile_upd
    if !@tilemap_window.nil? and @tilemap_window.visible == true
      update_tilemap
    end
  end
 
  def update_shift_mode
    dx = @image.x
    dy = @image.y
    if Mouse.in_area?(dx, dy, 160, 160)
      if Mouse.trigger?(Mouse::LBUTTON)
        if @list_window.index >= 0
          item = @list_window.commands[@list_window.index]
          if item[0] == 1
            bitmap = RPG::Cache.load_bitmap(self.folder + "/", item[1])
            select_tiles(bitmap)
            return
          end
        end
      end
    end
  end
 
  def select_tiles(bitmap)
    screen_rect = Rect.new(@screen_x, @screen_y, @screen_width, @screen_height)
    dx = self.x + self.width
    if (dx + 256 + 32) > (@screen_x + @screen_width)
      dx = self.x - (256 + 32)
    end
    @tilemap_window = Window_FileTilemap.new(dx, self.y, 256 + 32, 256 + 112,
    bitmap, screen_rect)
    @tilemap_window.z = self.z
    @tilemap_window.bar = true
    @tilemap_window.title = Vocab::SELECT_TILES_W
    @tilemap_window.create_button(@tilemap_window.width - 72 - 16,
    @tilemap_window.height - 24 * 2 - 16, 72, 24, Vocab::APPLY)
    @tilemap_window.create_button(@tilemap_window.width - 72 - 16,
    @tilemap_window.height - 24 * 1 - 16, 72, 24, Vocab::CANCEL)
  end
 
  def update_tilemap
    self.active = false
    @tilemap_window.update
    if @tilemap_window.active == true
      if @tilemap_window.close_button? or
        @tilemap_window.press_button?(Vocab::CANCEL)
        @tilemap_window.dispose
        @tilemap_window = nil
        self.active = true
        return
      end
      if @tilemap_window.press_button?(Vocab::APPLY)
        $game_system.file_grid_x = @tilemap_window.grid_x
        $game_system.file_grid_y = @tilemap_window.grid_y
        start_coords = @tilemap_window.select_start_coords
        end_coords = @tilemap_window.select_end_coords
        if !start_coords.nil? and !end_coords.nil?
          bitmap = @tilemap_window.tilemap.clone
          msx = [start_coords[0], end_coords[0]].min
          msy = [start_coords[1], end_coords[1]].min
          mex = [start_coords[0], end_coords[0]].max
          mey = [start_coords[1], end_coords[1]].max
          sx = msx * @tilemap_window.grid_x
          sy = msy * @tilemap_window.grid_y
          ex = (mex - msx + 1) * @tilemap_window.grid_x
          ey = (mey - msy + 1) * @tilemap_window.grid_y
          if sx < bitmap.width and sy < bitmap.height
            ex = [ex, bitmap.width - sx].min
            ey = [ey, bitmap.height - sy].min
            self.image = bitmap.cut(sx, sy, ex, ey)
          end
        end
        @tilemap_window.dispose
        @tilemap_window = nil
        self.active = true
        return
      end
    end
  end
end

#==============================================================================
# ** Window_FileTilemap
#==============================================================================

class Window_FileTilemap < Window_Base
 
  attr_reader :tilemap
  attr_reader :select_start_coords
  attr_reader :select_end_coords
  attr_reader :grid_x
  attr_reader :grid_y
 
  def initialize(x, y, width, height, tilemap,
    screen_rect=Rect.new(0, 0, Graphics.width, Graphics.height))
    super(x, y, width, height, screen_rect)
    @tilemap = tilemap.clone
   
    @tilemap_viewport = Viewport.new(self.x + 16, self.y + 32, 256, 256)
    @tilemap_viewport.z = self.z + 100
    @tilemap_sprite = Sprite.new(@tilemap_viewport)
    @tilemap_sprite.bitmap = tilemap
    @sel_sprite = Sprite.new(@tilemap_viewport)
    @sel_sprite.bitmap = Bitmap.new(tilemap.width, tilemap.height)
    @grid_sprite = Sprite.new(@tilemap_viewport)
    @grid_sprite.bitmap = Bitmap.new(tilemap.width, tilemap.height)

    grid_min = WecTools::GRID_MIN
    grid_max = WecTools::GRID_MAX
   
    create_numeric_box(32, 256 + 80, 64, 20, 32, grid_min, grid_max)
    create_numeric_box(108, 256 + 80, 64, 20, 32, grid_min, grid_max)
   
    if $game_system.file_grid_x == nil
      $game_system.file_grid_x = 32
      $game_system.file_grid_y = 32
    end
    @numeric_boxes[0].text = $game_system.file_grid_x
    @numeric_boxes[1].text = $game_system.file_grid_y
   
    @grid_x = @numeric_boxes[0].text.to_i
    @grid_y = @numeric_boxes[1].text.to_i
   
    @select_mode = false
    @select_start_coords = nil
    @select_end_coords = nil
   
    refresh
    refresh_grid
  end
 
  def dispose
    super
    @tilemap_sprite.dispose
    @grid_sprite.dispose
    @sel_sprite.dispose
  end
 
  def refresh
    super
    self.contents.fill_rect(16, 32, 256, 256, back_color)
   
    self.contents.draw_text(32, 256 + 60, 64, 20, Vocab::WIDTH, 1)
    self.contents.draw_text(108, 256 + 60, 64, 20, Vocab::HEIGHT, 1)
   
    draw_arrow_up(136, 24)
    draw_arrow_right(272, 152)
    draw_arrow_left(8, 152)
    draw_arrow_down(136, 288)
  end
 
  def refresh_grid
    @grid_sprite.bitmap.clear
    tw = @tilemap_sprite.bitmap.width
    th = @tilemap_sprite.bitmap.height
    gw = (tw.to_f / @grid_x).floor
    gh = (th.to_f / @grid_y).floor
    color = WecTools::FILE_GRID_COLOR
    for ix in 1..gw
      next if ix * @grid_x == tw
      @grid_sprite.bitmap.fill_rect(ix * @grid_x, 0, 1, th, color)
    end
    for iy in 1..gh
      next if iy * @grid_y == th
      @grid_sprite.bitmap.fill_rect(0, iy * @grid_y, tw, 1, color)
    end
    if WecTools::SMOOTH_SCROLL == false
      tox = ((@tilemap_sprite.ox.to_f) / @grid_x).floor
      toy = ((@tilemap_sprite.oy.to_f) / @grid_y).floor
      @tilemap_sprite.ox = tox * @grid_x
      @tilemap_sprite.oy = toy * @grid_y
      @grid_sprite.ox = tox * @grid_x
      @grid_sprite.oy = toy * @grid_y
      @sel_sprite.ox = tox * @grid_x
      @sel_sprite.oy = toy * @grid_y
    end
  end
 
  def refresh_select
    @sel_sprite.bitmap.clear
    if @select_start_coords.nil? or @select_end_coords.nil?
      return
    end
    msx = [@select_start_coords[0], @select_end_coords[0]].min
    msy = [@select_start_coords[1], @select_end_coords[1]].min
    mex = [@select_start_coords[0], @select_end_coords[0]].max
    mey = [@select_start_coords[1], @select_end_coords[1]].max
    sx = msx * @grid_x
    sy = msy * @grid_y
    ex = (mex - msx + 1) * @grid_x
    ey = (mey - msy + 1) * @grid_y
    @sel_sprite.bitmap.fill_rect(sx, sy, ex, ey, WecTools::FILE_SEL_COLOR)
  end
 
  def arrow_color
    if (normal_color.red + normal_color.green + normal_color.blue) / 3 < 64
      return Color.new(255, 140, 20)
    else
      return Color.new(255, 235, 125)
    end
  end
 
  def draw_arrow_up(x, y)
    arrow_a = Bitmap.new(8, 8)
    arrow_b = Bitmap.new(8, 8)
    if @tilemap_sprite.oy > 0
      color = arrow_color
    else
      color = disabled_color
    end
    for iy in 0...8
      for ix in 0...8
        if ix <= iy
          arrow_a.set_pixel(8 - ix, iy, color)
          arrow_b.set_pixel(ix, iy, color)
        end
      end
    end
    self.contents.draw_bitmap(x, y - 1, arrow_a)
    self.contents.draw_bitmap(x + 8, y - 1, arrow_b)
  end
 
  def draw_arrow_down(x, y)
    arrow_a = Bitmap.new(8, 8)
    arrow_b = Bitmap.new(8, 8)
    if @tilemap_sprite.oy < (@tilemap_sprite.bitmap.height - 256)
      color = arrow_color
    else
      color = disabled_color
    end
    for iy in 0...8
      for ix in 0...8
        if ix <= iy
          arrow_a.set_pixel(8 - ix, 7 - iy, color)
          arrow_b.set_pixel(ix, 7 - iy, color)
        end
      end
    end
    self.contents.draw_bitmap(x, y + 1, arrow_a)
    self.contents.draw_bitmap(x + 8, y + 1, arrow_b)
  end
 
  def draw_arrow_right(x, y)
    arrow_a = Bitmap.new(8, 8)
    arrow_b = Bitmap.new(8, 8)
    if @tilemap_sprite.ox < (@tilemap_sprite.bitmap.width - 256)
      color = arrow_color
    else
      color = disabled_color
    end
    for iy in 0...8
      for ix in 0...8
        if ix <= iy
          arrow_a.set_pixel(ix, 7 - iy, color)
          arrow_b.set_pixel(ix, iy, color)
        end
      end
    end
    self.contents.draw_bitmap(x + 1, y + 8, arrow_a)
    self.contents.draw_bitmap(x + 1, y, arrow_b)
  end
 
  def draw_arrow_left(x, y)
    arrow_a = Bitmap.new(8, 8)
    arrow_b = Bitmap.new(8, 8)
    if @tilemap_sprite.ox > 0
      color = arrow_color
    else
      color = disabled_color
    end
    for iy in 0...8
      for ix in 0...8
        if ix <= iy
          arrow_a.set_pixel(7 - ix, 7 - iy, color)
          arrow_b.set_pixel(7 - ix, iy, color)
        end
      end
    end
    self.contents.draw_bitmap(x - 1, y + 8, arrow_a)
    self.contents.draw_bitmap(x - 1, y, arrow_b)
  end
   
  def x=(x)
    unless @tilemap_viewport.nil?
      dx = x - self.x
      @tilemap_viewport.rect.x += dx
    end
    super(x)
  end
 
  def y=(y)
    unless @tilemap_viewport.nil?
      dy = y - self.y
      @tilemap_viewport.rect.y += dy
    end
    super(y)
  end
 
  def z=(z)
    unless @tilemap_viewport.nil?
      dz = z - self.z
      @tilemap_viewport.z += dz
    end
    super(z)
  end
 
  def update
    super
    @tilemap_sprite.update
    update_keyboard
    update_grid_size
    update_selection
  end
 
  def update_grid_size
    grid_x = [WecTools::GRID_MIN, @numeric_boxes[0].text.to_i].max
    grid_x = [WecTools::GRID_MAX, grid_x].min
    grid_y = [WecTools::GRID_MIN, @numeric_boxes[1].text.to_i].max
    grid_y = [WecTools::GRID_MAX, grid_y].min
    grid_x = grid_x.to_i
    grid_y = grid_y.to_i
    if @grid_x != grid_x or @grid_y != grid_y
      @grid_x = grid_x
      @grid_y = grid_y
      @select_start_coords = nil
      @select_end_coords = nil
      refresh_grid
      refresh_select
      return
    end
  end
 
  def update_selection
    if Mouse.trigger?(Mouse::RBUTTON)
      @select_mode = false
      @select_start_coords = nil
      @select_end_coords = nil
      refresh_select
      return
    end
    if Mouse.trigger?(Mouse::LBUTTON)
      if Mouse.in_area?(*@tilemap_viewport.rect)
        @select_mode = true
        mx = Mouse.x - @tilemap_viewport.rect.x.to_f
        my = Mouse.y - @tilemap_viewport.rect.y.to_f
        mx = ((mx + @tilemap_sprite.ox) / @grid_x).floor
        my = ((my + @tilemap_sprite.oy) / @grid_y).floor
        @select_start_coords = [mx, my]
        @select_end_coords = [mx, my]
      end
    end
    if @select_mode == true
      if !Mouse.in_area?(*@tilemap_viewport.rect)
        @select_mode = false
        @select_start_coords = nil
        @select_end_coords = nil
        refresh_select
        return
      end
      if Mouse.release?(Mouse::LBUTTON)
        @select_mode = false
        refresh_select
        return
      end
      mx = Mouse.x - @tilemap_viewport.rect.x.to_f
      my = Mouse.y - @tilemap_viewport.rect.y.to_f
      mx = ((mx + @tilemap_sprite.ox) / @grid_x).floor
      my = ((my + @tilemap_sprite.oy) / @grid_y).floor
      end_coords = [mx, my]
      if @select_end_coords != end_coords
        @select_end_coords = end_coords
        refresh_select
        return
      end
    end
  end
 
  def update_drag
  end
 
  def update_enabled
    self.enabled = true
  end
 
  def update_keyboard
    if WecTools::SMOOTH_SCROLL == true
      if Input.press?(Input::DOWN)
        n = (@tilemap_sprite.bitmap.height - 256) - @tilemap_sprite.oy
        @tilemap_sprite.oy += [[8, n].min, 0].max
        @grid_sprite.oy    += [[8, n].min, 0].max
        @sel_sprite.oy    += [[8, n].min, 0].max
        refresh
        return
      end
      if Input.press?(Input::UP)
        n = @tilemap_sprite.oy
        @tilemap_sprite.oy -= [[8, n].min, 0].max
        @grid_sprite.oy    -= [[8, n].min, 0].max
        @sel_sprite.oy    -= [[8, n].min, 0].max
        refresh
        return
      end
      if Input.press?(Input::RIGHT)
        n = (@tilemap_sprite.bitmap.width - 256) - @tilemap_sprite.ox
        @tilemap_sprite.ox += [[8, n].min, 0].max
        @grid_sprite.ox    += [[8, n].min, 0].max
        @sel_sprite.ox    += [[8, n].min, 0].max
        refresh
        return
      end
      if Input.press?(Input::LEFT)
        n = @tilemap_sprite.ox
        @tilemap_sprite.ox -= [[8, n].min, 0].max
        @grid_sprite.ox    -= [[8, n].min, 0].max
        @sel_sprite.ox    -= [[8, n].min, 0].max
        refresh
        return
      end
    else
      if Input.trigger?(Input::DOWN)
        n = (@tilemap_sprite.bitmap.height - 256) - @tilemap_sprite.oy
        @tilemap_sprite.oy += [[@grid_y, n].min, 0].max
        @grid_sprite.oy    += [[@grid_y, n].min, 0].max
        @sel_sprite.oy    += [[@grid_y, n].min, 0].max
        refresh
        return
      end
      if Input.trigger?(Input::UP)
        n = @tilemap_sprite.oy
        @tilemap_sprite.oy -= [[@grid_y, n].min, 0].max
        @grid_sprite.oy    -= [[@grid_y, n].min, 0].max
        @sel_sprite.oy    -= [[@grid_y, n].min, 0].max
        refresh
        return
      end
      if Input.trigger?(Input::RIGHT)
        n = (@tilemap_sprite.bitmap.width - 256) - @tilemap_sprite.ox
        @tilemap_sprite.ox += [[@grid_x, n].min, 0].max
        @grid_sprite.ox    += [[@grid_x, n].min, 0].max
        @sel_sprite.ox    += [[@grid_x, n].min, 0].max
        refresh
        return
      end
      if Input.trigger?(Input::LEFT)
        n = @tilemap_sprite.ox
        @tilemap_sprite.ox -= [[@grid_x, n].min, 0].max
        @grid_sprite.ox    -= [[@grid_x, n].min, 0].max
        @sel_sprite.ox    -= [[@grid_x, n].min, 0].max
        refresh
        return
      end
    end
  end
end

Instalación:

Descarga el proyecto WecTools.
Ábrelo con el Editor de RPG maker y ve a Scripts.
Copia el script encima de main, en el apartado Features.

Para saber que realmente funciona, al cargar, debajo del cuadro de imagen debe poner en letras pequeñas "SHIFT" (mira la imagen de arriba).

Configuración:

En el module WecTools, al principio del script, se puede cambiar el color de la rejilla, el color de selección, el tamaño mínimo de la rejilla (por defecto 16) y el tamaño máximo (por defecto 256)

Wecoc
Administrador
Administrador



Créditos 8263

Gracias : 372

Volver arriba Ir abajo

Ver el tema anterior Ver el tema siguiente Volver arriba


 :: RPG Maker :: Scripts

Permisos de este foro:
No puedes responder a temas en este foro.