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 5109
공지 RPG VX ACE 유용한 링크 모음 16 아방스 2012.01.03 28922
217 전투 스킬 캐스팅 시스템 3 스리아씨 2013.10.12 32157
216 전투 RPG VX Ace 전투 대사 한글화 37 재규어 2012.01.04 20290
215 전투 Yanfly 엔진 - 몬스터의 레벨 설정 6 file 스리아씨 2013.11.08 13003
214 이름입력 한글 이름입력창 23 file 에틴 2012.01.23 11679
213 기타 Dialog Extractor 1.04 (VXA/VX/XP) 6 AltusZeon 2014.01.16 11665
212 기타 원하는 글씨체로 변경하기 12 조말생 2012.04.20 8847
211 이름입력 전체키 + 조합한글 + 이름입력처리 변경 47 file 허걱 2012.07.04 8197
210 전투 vx ace 애니메이션 배틀 3 gor 2012.05.27 7663
209 전투 SRPG 컨버터 for Ace (SRPGコンバータ for Ace) by AD.Bank 27 file 습작 2012.04.17 7274
208 메시지 [스크립트] Ace Message System - by. Yanfly 17 file 허걱 2012.05.21 7252
207 그래픽 [ACE][BR] Awesome Light Effects 1.0(빛관련 스크립트) 37 file 꿈꾸는사람 2012.08.02 7013
206 메뉴 Etude87's Menu Editor 44 file 습작 2014.07.17 6992
205 전투 [스크립트] Sideview Battle System ver. 1.00 (일본어) 7 file 허걱 2012.05.20 6912
204 제작도구 VXAce HUD Designer by Cidiomar R. Dias Jr 1 file 습작 2013.01.19 6761
203 메뉴 [VX Ace] 다이얼 링 메뉴 스크립트 8 file RaonHank 2012.04.16 6670
202 스킬 VXACE 패시브 스킬 스크립트 Ver. 0.82 21 file 아이미르 2012.03.07 6669
201 장비 사용자 장비 슬롯 1.1 27 file 아방스 2012.01.31 6615
200 미니맵 미니맵 표시 스크립트 21 file 아방스 2012.01.16 6488
199 전투 VXAce 사이드뷰 스크립트 (번역) 23 아이미르 2012.12.10 6356
198 전투 XAS Hero Edition Ace Experimental 0.5 6 Alkaid 2012.01.15 6130
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 Next
/ 11