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
761 기타 카운트 3초 1 file 백호 2009.02.22 1295
760 변수/스위치 Initial Switches and Variables by PK8 (XP/VX/VXA) Alkaid 2012.09.14 1296
759 파티 Party Switching Screen by exseiken file 백호 2009.02.22 1299
758 기타 KGC - 입수 경험치&금 증가 스크립트 백호 2009.02.22 1299
757 넷플2.0(펌) 3번째 4 오동훈 2008.02.25 1303
» 메뉴 Advanced Command Windows by Tsunokiette file 백호 2009.02.22 1307
755 기타 Complete Climate and Time System 1.2 by ForeverZer0 1 Alkaid 2010.09.17 1310
754 전투 Real Time Active Battle(RTAB) 1.14 from 歯車の城 3 file 백호 2009.02.22 1315
753 기타 Text to RGSS by DerVVulfman Alkaid 2011.04.18 1319
752 전투 적의 여러차례 행동 스크립트 1 백호 2009.02.22 1320
751 메뉴 플레이 시간 윈도우 개조 file 백호 2009.02.21 1328
750 메뉴 스테이터스 일람 스크립트 file 백호 2009.02.21 1328
749 Seph's Test Bed 0.4 (SDK2 호환, Method & Class Library 2 WMN 2008.04.06 1330
748 기타 엔딩에 스탭롤을 도입하는 스크립트 1 file 백호 2009.02.21 1335
747 이름입력 영어 이름 입력기 2 백호 2009.02.22 1335
746 기타 랜덤 지하 감옥 작성 스크립트 1 file 백호 2009.02.21 1338
745 메시지 Animated Window Skin by Tana 1 백호 2009.02.22 1338
744 스킬 스킬도감 오류 수정본 2 file 백호 2009.02.22 1340
743 HUD Advanced HUD Script 3 file 백호 2009.02.22 1341
742 비공정 스크립트의 탑승속도 변경하기. 3 아방스 2008.01.14 1346
Board Pagination Prev 1 ... 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 ... 52 Next
/ 52