Ace 스크립트

기존 아이콘 셋을 유지하면서 사용자 아이콘셋을 추가로 사용하는 스크립트 입니다.


스크립트 ↓


=begin
#===============================================================================
 Title: Custom Icon Sheets
 Author: Hime
 Date: Jun 1, 2016
--------------------------------------------------------------------------------
 ** Change log
 Jun 1, 2015
   - added patch for yanfly's ace item menu
 May 27, 2015
   - fixed bug with yanfly's shop options
 Jun 13, 2013
   - icon width and height is now specified for each sheet individually
 Mar 31, 2013
   - now correctly draws icons of non-default sizes
 Mar 25, 2013
   - Initial release
--------------------------------------------------------------------------------  
 ** Terms of Use
 * Free to use in non-commercial projects
 * Contact me for commercial use
 * No real support. The script is provided as-is
 * Will do bug fixes, but no compatibility patches
 * Features may be requested but no guarantees, especially if it is non-trivial
 * Credits to Hime Works in your project
 * Preserve this header
--------------------------------------------------------------------------------
 ** Description
 
 This script allows you to designate which icon sheet you want to draw your
 icon from. This allows you to organize your icons so that you don't need
 to load one large iconset just to draw one icon.
--------------------------------------------------------------------------------
 ** Installation
 
 Place this script below Materials and above Main
 
--------------------------------------------------------------------------------
 ** Usage
 
 -- Installation --
 
 Place this script below Materials and above Main.
 
 -- Setting up custom icon sheets --
 
 Place any custom icon sheets in your Graphics/System folder.
 In the configuration below, add the filenames (without extensions) to the
 `Icon_Sheets` array. You must also include the default icon sheet to use,
 which is "Iconset"
 
 -- Using custom icon indices --
 
 Now that you have set up your icon sheets, you can begin using them.
 In your database, note-tag objects with
 
   <icon: name index>
  
 Where
   `name` is the exact filename of the icon index, without extensions
   `index` is the index of the icon in the specified file.

--------------------------------------------------------------------------------
 ** Compatibility
 
 This script overwrites the following methods:
 
   Window_Base
     draw_icon
 
#===============================================================================
=end
$imported = {} if $imported.nil?
$imported["TH_CustomIconSheets"] = true
#===============================================================================
# ** Configuration
#===============================================================================
module TH
  module Custom_Icon_Sheets
   
    # List of icon sheets to load. Case-insensitive.
    # All icon sheets must be placed in the System folder
    # You must provide the dimensions of the icons as well
    Icon_Sheets = {
      "Iconset"     => [24, 24],
      "Iconset2"     => [24, 24],
      #"CustomIcons" => [24, 24],
      #"LargeIcons"  => [65, 65]
    }
   
    # The default sheet to use if none is specified
    Default_Sheet = "Iconset"
   
    # Note-tag format.
    Regex = /<icon:\s*(\w+)\s*(\d+)>/i

#===============================================================================
# ** Rest of script
#===============================================================================

    #---------------------------------------------------------------------------
    # Each sheet starts at a specific icon index.
    #---------------------------------------------------------------------------
    def self.icon_offsets
      @icon_offsets
    end
    #---------------------------------------------------------------------------
    # Load all icon sheets. This script uses a look-up table to map icon
    # indices to specific icon sheets.
    #---------------------------------------------------------------------------
    def self.load_sheets
      @icon_offsets = {}
      @icon_table = []
      icon_count = 0
      Icon_Sheets.each {|sheet, (width, height)|
        sheet = sheet.downcase
        bmp = Cache.system(sheet)
     
        # update the "icon index offset" for the current icon sheet.
        # This is used by the look-up table to determine how the icon index
        # is offset
        @icon_offsets[sheet] = icon_count
        @icon_table.push([sheet, icon_count, width, height])
       
        # number of icons per sheet is given by the number of icons per row
        # times the number of icons per height, including empty spaces.
        icon_count += (bmp.width / width) * (bmp.height / height)
      }
     
      # store the icon table in reverse order
      @icon_table.reverse!
    end
   
    def self.load_icon_sheet(index)
      @icon_table.each {|sheet, offset, width, height|
        if index >= offset
          index -= offset
          return Cache.system(sheet), index, width, height
        end
      }
    end
  end
end

module RPG
  class BaseItem
    def icon_sheet
      return @icon_sheet unless @icon_sheet.nil?
      load_notetag_custom_icon_sheet
      return @icon_sheet
    end
   
    def load_notetag_custom_icon_sheet
      res = self.note.match(TH::Custom_Icon_Sheets::Regex)
      if res
        @icon_sheet = res[1].downcase
        @custom_icon_index = res[2].to_i
      else
        @icon_sheet = TH::Custom_Icon_Sheets::Default_Sheet.downcase
        @custom_icon_index = @icon_index
      end
    end
   
    alias :th_custom_icon_sheets_icon_index :icon_index
    def icon_index
      parse_custom_icon_index unless @custom_icon_index_checked
      th_custom_icon_sheets_icon_index
    end
   
    #---------------------------------------------------------------------------
    # Automatically updates the icon index based on the appropriate icon sheet
    # to use.
    #---------------------------------------------------------------------------
    def parse_custom_icon_index
      # offset the index as necessary, using the icon sheet to look up the offset
      self.icon_index = TH::Custom_Icon_Sheets.icon_offsets[self.icon_sheet] + @custom_icon_index
      @custom_icon_index_checked = true
    end
  end
end

module DataManager
   
  class << self
    alias :th_custom_icon_sheets_load_database :load_database
  end
 
  #-----------------------------------------------------------------------------
  # Prepare the custom icon database
  #-----------------------------------------------------------------------------
  def self.load_database
    th_custom_icon_sheets_load_database
    TH::Custom_Icon_Sheets.load_sheets
  end
end

class Window_Base < Window
 
  #-----------------------------------------------------------------------------
  # Overwrite. Get the appropriate bitmap to draw from.
  #-----------------------------------------------------------------------------
  def draw_icon(icon_index, x, y, enabled = true)
    bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(icon_index)
    rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
    contents.blt(x, y, bitmap, rect, enabled ? 255 : translucent_alpha)
  end
end

#===============================================================================
# Compatibility patches. This script must be placed under the other scripts
#===============================================================================
class CSCA_Window_EncyclopediaInfo < Window_Base
  def csca_draw_icon(item)
    if item.csca_custom_picture == ""
      bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(icon_index)
      rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
      target = Rect.new(0,0,72,72)
      contents.stretch_blt(target, bitmap, rect)
    else
      bitmap = Bitmap.new("Graphics/Pictures/"+item.csca_custom_picture+".png")
      target = Rect.new(0,0,72,72)
      contents.stretch_blt(target, bitmap, bitmap.rect, 255)
    end
  end
end if $imported["CSCA-Encyclopedia"]

#===============================================================================
# Compatibility with Yanfly Ace Shop Options: drawing custom icon in shop
#===============================================================================
class Window_ShopData < Window_Base
  def draw_item_image
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(1, 1, 94, 94)
    contents.fill_rect(rect, colour)
    if @item.image.nil?
     
      bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(@item.icon_index)
      rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
      target = Rect.new(0, 0, 96, 96)
      contents.stretch_blt(target, bitmap, rect)
    else
      bitmap = Cache.picture(@item.image)
      contents.blt(0, 0, bitmap, bitmap.rect, 255)
    end
  end
end if $imported["YEA-ShopOptions"]

#===============================================================================
# Compatibility with Yanfly Ace Item Menu: drawing custom icon in item menu
#===============================================================================
class Window_ItemStatus < Window_Base
  def draw_item_image
    colour = Color.new(0, 0, 0, translucent_alpha/2)
    rect = Rect.new(1, 1, 94, 94)
    contents.fill_rect(rect, colour)
    if @item.image.nil?
     
      bitmap, icon_index, icon_width, icon_height = TH::Custom_Icon_Sheets.load_icon_sheet(@item.icon_index)
      rect = Rect.new(icon_index % 16 * icon_width, icon_index / 16 * icon_height, icon_width, icon_height)
      target = Rect.new(0, 0, 96, 96)
      contents.stretch_blt(target, bitmap, rect)
    else
      bitmap = Cache.picture(@item.image)
      contents.blt(0, 0, bitmap, bitmap.rect, 255)
    end
  end
end if $imported["YEA-ItemMenu"]




스크립트 적용후

3.png



1.png


스킬이나 아이템 무기 등등 필요한곳 주석에

<icon: 불러올파일명 번호> 써주시면 됩니다.


'불러올파일명'은 스크립트내에서 수정가능합니다.


2.png



출처: http://himeworks.com/2013/03/custom-icon-sheets/

  • profile
    시즈쿠 2015.09.29 20:29
    오오 이거 좋네요!
  • profile
    AANNSS 2016.01.24 19:06
    으음....분명히 간로님 말대로 한거같은데 Script '커스텀 아이콘' line 172: NoMethodError occurred. undefined method '+'for nil:NilClass라고 오류가 뜨네요... 왜 그러는지 알 수 있을까요?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 5593
공지 RPG VX ACE 유용한 링크 모음 16 아방스 2012.01.03 29399
137 전투 XAS VX ACE 데모 한글 번역 ( 스크립트 번역 모음 ) 1 미루 2013.01.10 4595
136 전투 XAS Hero Edition Ace Experimental 0.5 6 Alkaid 2012.01.15 6162
135 전투 WhiteFlute: 자동전투 스크립트 3 file Alkaid 2012.09.20 3794
134 맵/타일 WhiteFlute - XPMap-EX (VX Ace에서 XP의 맵 데이터를 읽을 수 있게 함) 3 Alkaid 2012.12.26 1525
133 스킬 VXACE 패시브 스킬 스크립트 Ver. 0.82 21 file 아이미르 2012.03.07 6696
132 장비 VXAce 장비장착 스킬발동 스크립트 2 아이미르 2012.09.02 2421
131 스킬 VXAce 아츠장착 스킬습득 스크립트 1 file 아이미르 2013.02.24 2792
130 아이템 VXAce 아이템 합성 스크립트 Ver 0.8 17 아이미르 2012.08.23 4022
129 아이템 VXAce 아이템 채집 스크립트 23 file 아이미르 2012.11.23 4069
128 아이템 VXAce 아이템 도감 스크립트 7 file 아이미르 2012.12.31 3830
127 스킬 VXAce 스킬포인트 스크립트 5 file 아이미르 2013.03.21 4179
126 스킬 VXAce 스킬레벨, 스킬장착 스크립트 11 file 아이미르 2012.11.01 3831
125 아이템 VXAce 셋트장비 스크립트 9 file 아이미르 2013.03.08 3646
124 상점 VXAce 상점 스크립트 V0.9 17 아이미르 2012.06.29 5398
123 전투 VXAce 사이드뷰 스크립트 (번역) 23 아이미르 2012.12.10 6379
122 스킬 VXAce 경험치 스킬습득 스크립트 3 file 아이미르 2012.10.27 2757
121 버그픽스 VXAce SP1 2 Alkaid 2013.02.15 2080
120 상점 VXAce SkillShop 스크립트 3 file 아이미르 2012.10.30 2906
119 아이템 VXAce No Recipe 아이템합성 스크립트(버그 수정) 11 file 아이미르 2013.01.07 3324
118 제작도구 VXAce HUD Designer by Cidiomar R. Dias Jr 1 file 습작 2013.01.19 6786
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11