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
28 메뉴 Ryex's Collapsing CMS 2.51 3 Alkaid 2010.09.05 1667
27 메뉴 스테이터스 화면 from Harts Horn 2 백호 2009.02.22 1571
26 메뉴 Star Ocean 3 형식으로 스테이터스 화면 변경 1 file 백호 2009.02.21 1570
25 메뉴 1-Scene CMS 1.16 by LegACy (SDK호환) 3 file 백호 2009.02.22 1564
24 메뉴 Ring menu edit (Non-SDK ver.) Alkaid 2010.09.08 1538
23 메뉴 MOG - Scroll Bar for XP file 습작 2014.07.06 1532
22 메뉴 AP 올리기 8 알피지GM 2010.02.15 1490
21 메뉴 FF7형식의 메뉴로 변경하는 스크립트 1 file 백호 2009.02.21 1462
20 메뉴 Leidy's Ring Command Window 1.2 by DerVVulfman Alkaid 2012.09.09 1430
19 메뉴 링메뉴에 돈(G)표시하기 백호 2009.02.21 1414
18 메뉴 콤보 스크립트 백호 2009.02.22 1399
17 메뉴 링메뉴 스크립트 file 백호 2009.02.21 1391
16 메뉴 Ring menu edit for SDK2 (Original by Hypershadow180) file Alkaid 2010.09.08 1374
15 메뉴 플레이 시간 윈도우 개조 file 백호 2009.02.21 1328
14 메뉴 스테이터스 일람 스크립트 file 백호 2009.02.21 1328
» 메뉴 Advanced Command Windows by Tsunokiette file 백호 2009.02.22 1307
12 메뉴 L's Simple Custom Menu #1 R2 (SDK 2.x 필요) Alkaid 2013.01.18 1227
11 메뉴 Materia System 2 file 백호 2009.02.22 1222
10 메뉴 CogWheel Plug'n'Play Menu Bar by DerVVulfman@rmxp.org 2 백호 2009.02.22 1222
9 메뉴 메뉴에서 실제시간 보기 2 백호 2009.02.21 1124
Board Pagination Prev 1 2 3 4 5 Next
/ 5