XP 스크립트

http://www.rmxp.org/forums/showthread.php?t=5226
(내용을 보려면 로그인 필요)

커맨드 윈도우의 형태를 약간(?)의 작업만으로 세로 또는 가로로 만들 수 있고, 아이콘을 넣는다든가 선택된 항목의 글자 색깔을 바꾸는 기능이 있습니다.


#==============================================================================
# ** Window_Command
#------------------------------------------------------------------------------
# This window deals with general command choices.
#==============================================================================
class Window_Command < Window_Selectable
attr_accessor :disabled
#--------------------------------------------------------------------------
# * Object Initialization
# width : window width
# commands : command text string array
#--------------------------------------------------------------------------
def initialize(width,a,type=nil,align = nil,b = nil,color = nil,icons = nil)
if type.nil?
@type = 0
elsif !type.nil?
@type = type
end
# Compute window height from command quantity
case @type
when 0
super(0, 0, width, a.size * 32 + 32)
@item_max = a.size
self.contents = Bitmap.new(width - 32, @item_max * 32)
when 1
super(0, 0,width,80)
@item_max = a.size
@column_max = a.size
self.contents = Bitmap.new(width - 32,height - 32)
end
@commands_a = a
@disabled = []
@cursor_status = true
for i in 0..@item_max
@disabled[i] = false
end
if align.nil?
@alignment = 0
elsif !align.nil?
@alignment = align
end
if b.nil?
@commands_b = []
for i in 0..@commands_a.size
@commands_b[i] = @commands_a[i]
end
else !b.nil?
@commands_b = b
end
if color.nil?
@selected_color = normal_color
elsif !color.nil?
@selected_color = color
end
if icons.nil?
@icon_status = false
elsif !icons.nil?
@icons = icons
@icon_status = true
end
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if @icon_status == true
case @type
when 0
for i in 0..(@icons.size - 1)
y = ((i * 32) + ((i + 1) * 4))
draw_icon(@icons[i],4,y)
end
when 1
command_width = (self.contents.width / @item_max)
for i in 0..(@icons.size - 1)
x = ((i * command_width) + ((i + 1) * 4))
y = ((self.contents.height - 24) / 2)
draw_icon(@icons[i],x,y)
end
end
end
for i in 0...@item_max
if self.index == i
draw_item(i, @selected_color,1,@alignment)
elsif @disabled[i] == true
draw_item(i, disabled_color,0,@alignment)
elsif @index != i
draw_item(i, normal_color,0,@alignment)
end
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
# color : text color
#--------------------------------------------------------------------------
def draw_item(index, color,type,alignment)
case @type
when 0
if @icon_status == true
x = 8 + 24
elsif @icon_status == false
x = 4
end
rect = Rect.new(x, 32 * index, self.contents.width - 36, 32)
self.contents.font.color = color
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
case type
when 0
self.contents.draw_text(rect, @commands_a[index],alignment)
when 1
self.contents.draw_text(rect, @commands_b[index],alignment)
end
when 1
y = ((self.contents.height - 32) / 2)
if @icon_status == true
command_width = ((self.contents.width / @column_max) - 24 - 8)
x = ((index * command_width) + ((index + 1) * (24 + 8)))
rect = Rect.new(x,y,command_width - 24 - 8,32)
elsif @icon_status == false
command_width = ((self.contents.width / @column_max) - 4)
x = ((index * command_width) + (index * 4))
rect = Rect.new(x,y,command_width - 4,32)
end
self.contents.font.color = color
self.contents.fill_rect(rect,Color.new(0,0,0,0))
case type
when 0
self.contents.draw_text(rect,@commands_a[index],alignment)
when 1
self.contents.draw_text(rect,@commands_b[index],alignment)
end
end
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
@disabled[index] = true
end
#--------------------------------------------------------------------------
# * Update
#--------------------------------------------------------------------------
def update
refresh
super
end
#--------------------------------------------------------------------------
# * Disable Cursor
#--------------------------------------------------------------------------
def disable_cursor
@cursor_status = false
end
#--------------------------------------------------------------------------
# * Update Cursor
#--------------------------------------------------------------------------
def update_cursor_rect
if @cursor_status == false
self.cursor_rect.empty
return
end
if @type == 0
super
else
command_width = (self.contents.width / @item_max)
x = @index * command_width
y = ((self.contents.height - 32) / 2)
self.cursor_rect.set(x, y, command_width, 32)
end
end
#--------------------------------------------------------------------------
# * Draw Icon
#--------------------------------------------------------------------------
def draw_icon(name,x,y)
if name == ''
return
else
bitmap = RPG::Cache.icon(name)
w = 24
h = 24
src_rect = Rect.new(0, 0, w, h)
self.contents.blt(x, y , bitmap, src_rect)
end
end
end


커맨드 윈도우 작성법(물론 기존의 커맨드 윈도우도 동작합니다):
a = 200 #윈도우 가로길이 - REQUIRED
b = ['Command','Command','Command'] #명령 - REQUIRED
c = nil #윈도우 타입 (0 = Vertical, 1 = Horizontal) - OPTIONAL
d = nil #문자 정렬 (0 = Left, 1 = Center, 2 = Right) - OPTIONAL
e = nil #선택된 명령 (EX: N E W G A M E) - OPTIONAL
f = nil #명령이 선택되었을 때 색상 - OPTIONAL
g = nil #아이콘 (EX: ['Icon1','Icon2','Icon3'] - OPTIONAL
@command_window = Window_Command.new(a,b,c,d,e,f,g) 


 




 
 

Who's 백호

?

이상혁입니다.

http://elab.kr

Atachment
첨부 '3'

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 스크립트 자료 게시물 작성시 주의사항 습작 2012.12.24 6153
1001 ABM(액알)+Jindow(진도우) 3 WMN 2008.04.06 5115
1000 전투 ABP 액알 (Action Battle Player) 14 file 백호 2009.02.22 4556
999 스킬 ABP액알 v1.2 스킬추가, 버그수정판 36 file 백호 2009.02.22 6919
998 기타 ABS 몬스터 HP 게이지 바 11 백호 2009.02.22 2485
997 전투 ABS_v3액션 알피지 46 file 알피지GM 2010.03.07 5806
996 기타 Activation_system file 백호 2009.02.22 775
995 전투 Active Time Battle 2.57 by パラ犬 6 file 백호 2009.02.22 2371
994 전투 Active Time Battle 2.62 by パラ犬 file Alkaid 2010.09.06 1652
993 액터 Actor Customization 6.0.2 by Synthesize 4 file Alkaid 2010.09.17 1911
992 아이템 Additional Item Drop by SephirothSpawn (SDK호환) 1 백호 2009.02.22 891
» 메뉴 Advanced Command Windows by Tsunokiette file 백호 2009.02.22 1307
990 이름입력 Advanced Enter Hero Name Window by RPG Advocate 백호 2009.02.22 1168
989 장비 Advanced Equip Window 백호 2009.02.22 806
988 기타 Advanced Gold display by Dubealex 1 백호 2009.02.22 761
987 기타 Advanced Gold Display by Dubealex (돈 액수를 세자리씩 끊어 표기) 2 Alkaid 2010.11.18 1559
986 HUD Advanced HUD Script 3 file 백호 2009.02.22 1341
985 전투 Advanced Individual Battle Command v2.1 by Trickster@rmxp.org (SDK호환) 1 file 백호 2009.02.22 1189
984 전투 Advanced Limit Breaks (KGC스크립트를 SDK호환용으로 손질한 것) 백호 2009.02.22 1214
983 스킬 Advanced Mission Skills/Shop/Manager by trickster 3 file 백호 2009.02.22 1601
982 이동 및 탈것 Advanced Player Movement by SephirothSpawn (SDK호환) 1 file 백호 2009.02.22 801
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... 52 Next
/ 52