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
88 메뉴 1-Scene CMS 1.03 by LegACy@rmxp.org (SDK호환) file 백호 2009.02.22 871
87 메뉴 Customizable Ring Menu by SephirothSpawn 백호 2009.02.22 884
86 메뉴 1-Scene CMS 1.1 by LegACy@rmxp.org (SDK호환) file 백호 2009.02.22 953
85 메뉴 Event Spawner 1 file 백호 2009.02.22 979
84 메뉴 SG_Artifact Colors by sandgolem (SDK 호환) 1 백호 2009.02.22 1003
83 메뉴 링메뉴+음악도입스크립트 백호 2009.02.21 1051
82 메뉴 SG_Hide zero SP cost by sandgolem (SDK호환) 백호 2009.02.22 1064
81 메뉴 FF7 Menu version 3 by AcedentProne (SDK 호환) file 백호 2009.02.22 1116
80 메뉴 메뉴에서 실제시간 보기 2 백호 2009.02.21 1124
79 메뉴 Materia System 2 file 백호 2009.02.22 1222
78 메뉴 CogWheel Plug'n'Play Menu Bar by DerVVulfman@rmxp.org 2 백호 2009.02.22 1222
77 메뉴 L's Simple Custom Menu #1 R2 (SDK 2.x 필요) Alkaid 2013.01.18 1227
» 메뉴 Advanced Command Windows by Tsunokiette file 백호 2009.02.22 1307
75 메뉴 플레이 시간 윈도우 개조 file 백호 2009.02.21 1328
74 메뉴 스테이터스 일람 스크립트 file 백호 2009.02.21 1328
73 메뉴 Ring menu edit for SDK2 (Original by Hypershadow180) file Alkaid 2010.09.08 1374
72 메뉴 링메뉴 스크립트 file 백호 2009.02.21 1391
71 메뉴 콤보 스크립트 백호 2009.02.22 1399
70 메뉴 링메뉴에 돈(G)표시하기 백호 2009.02.21 1413
69 메뉴 Leidy's Ring Command Window 1.2 by DerVVulfman Alkaid 2012.09.09 1430
Board Pagination Prev 1 2 3 4 5 Next
/ 5