| 赞 | 15 |
| VIP | |
| 好人卡 | |
| 积分 | 3 |
| 经验 | |
| 最后登录 | 2022-8-25 |
| 在线时间 | 2355 小时 |
- 梦石
- 0
- 星屑
- 266
- 在线时间
- 2355 小时
- 注册时间
- 2009-3-13
- 回帖
- 2257

|
发表于 2014-8-30 15:54:08
|
显示全部楼层
替换脚本 ├Window_CDKeyInput ┤
点击展开/收起[pre lang="ruby" line="1"]#encoding:utf-8
#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
# 名字输入画面中,选择文字的窗口。
#==============================================================================
class Window_CDKeyInput < Window_Selectable
#--------------------------------------------------------------------------
# ● 文字表
#--------------------------------------------------------------------------
TABLE0 = [ '1','2','3','4','5','6','7','8','9','0',
'Q','W','E','R','T','Y','U','I','O','P',
'A','S','D','F','G','H','J','K','L','Enter',
'Z','X','C','V','B','N','M','-','','Shift']
TABLE1 = [ '1','2','3','4','5','6','7','8','9','0',
'q','w','e','r','t','y','u','i','o','p',
'a','s','d','f','g','h','j','k','l','Enter',
'z','x','c','v','b','n','m','-','','Shift']
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(edit_window)
super(edit_window.x, edit_window.y + edit_window.height + 8,
edit_window.width, fitting_height(4))
@edit_window = edit_window
@page = 0
@index = 0
refresh
update_cursor
activate
end
#--------------------------------------------------------------------------
# ● 获取字表
#--------------------------------------------------------------------------
def table
return [TABLE0,TABLE1]
end
#--------------------------------------------------------------------------
# ● 获取文字
#--------------------------------------------------------------------------
def character
((@index != 29)&&(@index != 39))? table[@page][@index] : ""
end
#--------------------------------------------------------------------------
# ● 判定光标位置是否在“切换”上(平假/片假)
#--------------------------------------------------------------------------
def is_page_change?
@index == 39
end
#--------------------------------------------------------------------------
# ● 判定光标位置是否在“确定”上
#--------------------------------------------------------------------------
def is_ok?
@index == 29
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
#~ def item_rect(index)
#~ rect = Rect.new
#~ rect.x = index % 10 * 40# + index % 10 / 5 * 16
#~ rect.y = index / 10 * line_height
#~ rect.width = 40
#~ rect.height = line_height
#~ rect
#~ end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
change_color(normal_color)
90.times {|i| draw_text(item_rect(i), table[@page], 1) }
end
#--------------------------------------------------------------------------
# ● 更新光标
#--------------------------------------------------------------------------
def update_cursor
cursor_rect.set(item_rect(@index))
end
#--------------------------------------------------------------------------
# ● 判定光标是否可以移动
#--------------------------------------------------------------------------
def cursor_movable?
active
end
#--------------------------------------------------------------------------
# ● 光标向下移动
# wrap : 允许循环
#--------------------------------------------------------------------------
def cursor_down(wrap)
if @index < 30 or wrap
@index = (index + 10) % 40
end
end
#--------------------------------------------------------------------------
# ● 光标向上移动
# wrap : 允许循环
#--------------------------------------------------------------------------
def cursor_up(wrap)
if @index >= 10 or wrap
@index = (index + 30) % 40
end
end
#--------------------------------------------------------------------------
# ● 光标向右移动
# wrap : 允许循环
#--------------------------------------------------------------------------
def cursor_right(wrap)
if @index % 10 < 9
@index += 1
elsif wrap
@index -= 9
end
end
#--------------------------------------------------------------------------
# ● 光标向左移动
# wrap : 允许循环
#--------------------------------------------------------------------------
def cursor_left(wrap)
if @index % 10 > 0
@index -= 1
elsif wrap
@index += 9
end
end
#--------------------------------------------------------------------------
# ● 向下一页移动
#--------------------------------------------------------------------------
def cursor_pagedown
@page = (@page + 1) % table.size
refresh
end
#--------------------------------------------------------------------------
# ● 向上一页移动
#--------------------------------------------------------------------------
def cursor_pageup
@page = (@page + table.size - 1) % table.size
refresh
end
#--------------------------------------------------------------------------
# ● 处理光标的移动
#--------------------------------------------------------------------------
def process_cursor_move
last_page = @page
super
update_cursor
Sound.play_cursor if @page != last_page
end
#--------------------------------------------------------------------------
# ● “确定”、“删除字符”和“取消输入”的处理
#--------------------------------------------------------------------------
def process_handling
return unless open? && active
process_jump if Input.trigger?(:A)
process_back if Input.repeat?(:B)
process_ok if Input.trigger?(:C)
end
#--------------------------------------------------------------------------
# ● 跳转“确定”
#--------------------------------------------------------------------------
def process_jump
if @index != 40
@index = 40
Sound.play_cursor
end
end
#--------------------------------------------------------------------------
# ● 后退一个字符
#--------------------------------------------------------------------------
def process_back
Sound.play_cancel if @edit_window.back
end
#--------------------------------------------------------------------------
# ● 按下确定键时的处理
#--------------------------------------------------------------------------
def process_ok
if !character.empty?
on_name_add
elsif is_page_change?
Sound.play_ok
cursor_pagedown
elsif is_ok?
on_name_ok
end
end
#--------------------------------------------------------------------------
# ● 添加名字字符
#--------------------------------------------------------------------------
def on_name_add
if @edit_window.add(character)
Sound.play_ok
else
Sound.play_buzzer
end
end
#--------------------------------------------------------------------------
# ● 确定名字
#--------------------------------------------------------------------------
def on_name_ok
call_ok_handler
end
def col_max
10
end
def row_max
4
end
def item_max
40
end
def spacing
3
end
end
[/pre] |
|