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 상점 Mog- 상점업그레이드 ps인간 2009.01.23 2682
760 스킬 스킬 포인트를 올리자! 3 what더붥 2012.01.26 2680
759 이동 및 탈것 백호님이올린 발소리 스크립트를 소리만 바꾸어 밨음 4 lhh9606 2009.05.19 2676
758 미니맵 미니맵 스크랩트 + 예재 15 file WMN 2008.03.17 2674
757 기타 몬스터 도감 18 file 백호 2009.02.22 2667
756 기타 4방향 마우스 스크립트 12 file 아방스 2009.02.28 2662
755 저장 세이브파일 망가뜨리기 by RPG Advocate 3 백호 2009.02.22 2657
754 변수/스위치 셀프 스위치 조작 10 file 허걱 2009.01.30 2655
753 테두리 글자 & 그림자 글자 12 아방스 2008.09.19 2643
752 타이틀/게임오버 게..임..오버.. ps인간 2009.01.23 2636
751 전투 자동전투 from RPG 쯔꾸르 XP RGSS Wiki 1 file 백호 2009.02.22 2621
750 메뉴 각 메뉴를 호화롭게 하는 스크립트 3 file 백호 2009.02.21 2616
749 스킬 제한시간내 커맨드를 입력해야 스킬이 발동~ 3 file 백호 2009.02.22 2614
748 온라인 [멀티넷스크립 PvP 이벤트버전] / [넷플레이0.7.2]버전 3 file 백호 2009.02.22 2604
747 전투 데미지 폰트변경 7 카르닉스 2010.02.26 2600
746 메뉴 혹시있나해서-_-.. 대화창에 테두리치기 스크립트 7 백호 2009.02.22 2591
745 전투 Mr.Mo's ABS Ultimate 7.0 by DerVVulfman 4 Alkaid 2012.08.26 2587
744 액터 (killer님 요청)자동회복 스크립트 3 나뚜루 2009.02.22 2572
743 메시지 윈도우즈 확장 file 백호 2009.02.21 2564
742 기타 [RGSS XP] 게임 해상도 조절 스크립트 (*2) 11 file Cheapmunk 2014.10.03 2560
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