RPGVX Ace 스크립트
2016.01.10 09:03

Custom Icon Sheets (커스텀 아이콘 적용 스크립트)

조회 수 470 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
원문출처 :
http://himeworks.com/2013/03/custom-icon-sheets/

직접 만든 아이콘을 사용할 수 있게 해주는 스크립트 입니다.
아래 파란색 처리된 부분에서 사용할 아이템을 지정합니다.
그리고 주석에 를 쓰면 사용가능하죠.



#===============================================================================
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



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],
"Weapons_1" => [24, 24],
#"CustomIcons" => [24, 24],
#"LargeIcons" => [65, 65]
}


# The default sheet to use if none is specified
Default_Sheet = "Iconset"

# Note-tag format.
Regex = //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"]

?

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수 추천 수
288 유니티 스크립트 구간 루프 음악 스크립트 맛난호빵 2015.08.24 232 0
287 유니티 스크립트 [C#] 보안 64비트 정수 맛난호빵 2016.01.04 382 0
» RPGVX Ace 스크립트 Custom Icon Sheets (커스텀 아이콘 적용 스크립트) plam 2016.01.10 470 0
285 RPGMV 플러그인 [JS] 세이브 갯수를 20개에서 변경하기. 천무 2015.10.26 508 0
284 RPGVX Ace 스크립트 Ace로 만든 습작 랜덤 위치로 지형변환. JunkMan 2014.10.04 512 0
283 RPGMV 플러그인 배틀미스트(전투중포그효과) 플러그인 file 파란별빛 2015.10.26 545 0
282 RPGMV 플러그인 RPG MV 와 AJAX를 이용한 웹 통신 플러그인 파란별빛 2015.10.26 545 0
281 RPGXP 스크립트 Universal Message System 1.8.0 by ccoa 2013.10.01 581 0
280 RPGXP 스크립트 Switchless Common Events 2013.10.01 588 0
279 RPGMV 플러그인 현실 시간 변수 대입 플러그인 2 file 최빛빛 2015.10.26 601 1
278 RPGXP 스크립트 Initial Switches and Variables 2013.10.01 602 0
277 RPGXP 스크립트 메뉴에서 실제시간 보는 스크립트 4 청담 2013.09.24 607 0
276 RPGVX Ace 스크립트 Random Dungeon Generator - Random Cave JunkMan 2014.10.08 607 0
275 RPGVX Ace 스크립트 Damage Popup by Dargor (데미지 수치 팝업하는 스크립트) plam 2016.01.10 612 0
274 RPGXP 스크립트 한글조합입력기(영어가능) file 조규진1 2019.11.10 620 0
273 RPGVX Ace 스크립트 파일 존재의 유무 체크 4 휴리드 2013.09.30 639 0
272 RPGVX Ace 스크립트 텍스트 파일생성 1 휴리드 2013.09.30 654 0
271 RPGXP 스크립트 셀프 스위치 조작 4 청담 2013.09.29 656 0
270 RPGXP 스크립트 레벨업시 전회복 스크립트 2 청담 2013.09.24 685 0
269 RPGVX Ace 스크립트 VXA에서 XBOX360 컨트롤러 사용 여부 체크 file 러닝은빛 2018.07.15 691 0
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 15 Next
/ 15






[개인정보취급방침] | [이용약관] | [제휴문의] | [후원창구] | [인디사이드연혁]

Copyright © 1999 - 2016 INdiSide.com/(주)씨엘쓰리디 All Rights Reserved.
인디사이드 운영자 : 천무(이지선) | kernys(김원배) | 사신지(김병국)