赞 | 342 |
VIP | 10 |
好人卡 | 8 |
积分 | 262 |
经验 | 235776 |
最后登录 | 2024-9-23 |
在线时间 | 2387 小时 |
Lv5.捕梦者 (版主) 遠航の猫咪
- 梦石
- 3
- 星屑
- 23191
- 在线时间
- 2387 小时
- 注册时间
- 2005-10-15
- 帖子
- 1166
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 fux2 于 2014-2-28 12:51 编辑
原版RMXP系统中的姓名输入功能是日文的,很不方便,这里改成软键盘的形式
配合鼠标脚本操作会比较舒服
使用方法:复制以下脚本插入到Main之前,然后用事件的输入名称处理即可看到效果。
(先@Index 以避免脚本出错 by fux2
#============================================================================== # ■ Window_NameInput #------------------------------------------------------------------------------ # 输入名称的画面、文字选择窗口。 #============================================================================== class Window_NameInput < Window_Base CHARACTER_TABLE_NORMAL = [ "Esc","1","2","3","4","5","6","7","8","9","0","-","=","<-Bksp", "`","q","w","e","r","t","y","u","i","o","p","[","]","\\", "CAPS","a","s","d","f","g","h","j","k","l",";","'","Enter", "Shift","z","x","c","v","b","n","m",",",".","/","Shift", " " ] CHARACTER_TABLE_CAPS = [ "Esc","1","2","3","4","5","6","7","8","9","0","-","=","<-Bksp", "`","Q","W","E","R","T","Y","U","I","O","P","[","]","\\", "caps","A","S","D","F","G","H","J","K","L",";","'","Enter", "Shift","Z","X","C","V","B","N","M",",",".","/","Shift", " " ] CHARACTER_TABLE_SHIFT = [ "Esc","!","@","#","$","%","^","&","*","(",")","_","+","<-Bksp", "~","Q","W","E","R","T","Y","U","I","O","P","{","}","|", "CAPS","A","S","D","F","G","H","J","K","L",":","\"","Enter", "[Shift]","Z","X","C","V","B","N","M","<",">","?","[Shift]", " " ] CHARACTER_TABLE_CAPS_SHIFT = [ "Esc","~","!","@","#","$","%","^","&","*","(",")","_","+","<-Bksp", "~","q","w","e","r","t","y","u","i","o","p","{","}","|", "caps","a","s","d","f","g","h","j","k","l",":","\"","Enter", "[Shift]","z","x","c","v","b","n","m","<",">","?","[Shift]", " " ] attr_accessor :caps # 是否大写锁定 attr_accessor :shift # 是否上档 #-------------------------------------------------------------------------- # ● 初始化对像 #-------------------------------------------------------------------------- def initialize super(0, 128, 640, 352) self.contents = Bitmap.new(width - 32, height - 32) @index = 0 @caps = false @shift = false @last_index = 0 refresh update_cursor_rect end #-------------------------------------------------------------------------- # ● 获取文字 #-------------------------------------------------------------------------- def character(id = -1) id = @index if id == -1 if @caps return @shift ? CHARACTER_TABLE_CAPS_SHIFT[id] : CHARACTER_TABLE_CAPS[id] else return @shift ? CHARACTER_TABLE_SHIFT[id] : CHARACTER_TABLE_NORMAL[id] end end #-------------------------------------------------------------------------- # ● 获取按钮位置 #-------------------------------------------------------------------------- def key_pos(id) x = y = w = 0 case id when 0..12 # Esc 1 ... = x = 4 + id * 40 y = 32 w = 40 when 13 # 退格 x = 524 y = 32 w = 80 when 14..27 # ` Q W ... \ x = 24 + (id - 14) * 40 y = 82 w = 40 when 28 # 大写 x = 4 y = 132 w = 80 when 29..39 # A S ... ' x = 84 + (id - 29) * 40 y = 132 w = 40 when 40 # 回车 x = 524 y = 132 w = 80 when 41 # LShift x = 4 y = 182 w = 100 when 42..51 # Z X ... / x = 104 + (id - 42) * 40 y = 182 w = 40 when 52 # RShift x = 504 y = 182 w = 100 when 53 # 空格 x = 184 y = 232 w = 280 end return [x, y, w] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0..53 pos = key_pos(i) self.contents.draw_text(pos[0], pos[1], pos[2], 40, character(i), 1) end end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect pos = key_pos(@index) self.cursor_rect.set(pos[0], pos[1], pos[2], 40) end #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update super # 光标下 if Input.repeat?(Input::DOWN) case @index when 0..27 @index += 14 @index = [@index, 40].min when 28..40 @index += 13 @index = [@index, 52].min when 41..52 @last_index = @index @index = 53 when 53 $game_system.se_play($data_system.buzzer_se) end $game_system.se_play($data_system.cursor_se) unless @index == 53 end # 光标上 if Input.repeat?(Input::UP) case @index when 0..13 $game_system.se_play($data_system.buzzer_se) when 14..40 @index -= 14 when 41..52 @index -= 13 when 53 @index = @last_index end $game_system.se_play($data_system.cursor_se) unless @index < 14 end # 光标左 if Input.repeat?(Input::LEFT) case @index when 0, 14, 28, 41, 53 $game_system.se_play($data_system.buzzer_se) else $game_system.se_play($data_system.cursor_se) @index -= 1 end end # 光标右 if Input.repeat?(Input::RIGHT) case @index when 13, 27, 40, 52, 53 $game_system.se_play($data_system.buzzer_se) else $game_system.se_play($data_system.cursor_se) @index += 1 end end update_cursor_rect end end #============================================================================== # ■ Scene_Name #------------------------------------------------------------------------------ # 处理名称输入画面的类。 #============================================================================== class Scene_Name #-------------------------------------------------------------------------- # ● 刷新画面 #-------------------------------------------------------------------------- def update # 刷新窗口 @edit_window.update @input_window.update # 按下 B 键的情况下 if Input.repeat?(Input::B) # 光标位置为 0 的情况下 if @edit_window.index == 0 return end # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 删除文字 @edit_window.back return end # 按下 C 键的情况下 if Input.trigger?(Input::C) # 取得光标位置 case @input_window.character # 光标位置为 [取消] 的情况下 when "Esc" # 还原为默认名称 @edit_window.restore_default return # 光标位置为 [回车] 的情况下 when "Enter" # 名称为空的情况下 if @edit_window.name == "" # 还原为默认名称 @edit_window.restore_default # 名称为空的情况下 if @edit_window.name == "" # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) return end # 更改角色名称 @actor.name = @edit_window.name # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 切换到地图画面 $scene = Scene_Map.new return # 光标位置为 [退格] 的情况下 when "<-Bksp" # 光标位置为 0 的情况下 if @edit_window.index == 0 return end # 演奏取消 SE $game_system.se_play($data_system.cancel_se) # 删除文字 @edit_window.back return # 光标位置为 [大写] 的情况下 when "CAPS", "caps" # 演奏光标 SE $game_system.se_play($data_system.cursor_se) @input_window.caps = !@input_window.caps @input_window.refresh return # 光标位置为 [上档] 的情况下 when "Shift", "[Shift]" # 演奏光标 SE $game_system.se_play($data_system.cursor_se) @input_window.shift = !@input_window.shift @input_window.refresh return # 其他情况下 else # 光标位置为最大的情况下 if @edit_window.index == $game_temp.name_max_char # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 文字为空的情况下 if @input_window.character == "" # 演奏冻结 SE $game_system.se_play($data_system.buzzer_se) return end # 演奏确定 SE $game_system.se_play($data_system.decision_se) # 添加文字 @edit_window.add(@input_window.character) # 取消上档 if @input_window.shift @input_window.shift = false @input_window.refresh end return end end end end
#==============================================================================
# ■ Window_NameInput
#------------------------------------------------------------------------------
# 输入名称的画面、文字选择窗口。
#==============================================================================
class Window_NameInput < Window_Base
CHARACTER_TABLE_NORMAL =
[
"Esc","1","2","3","4","5","6","7","8","9","0","-","=","<-Bksp",
"`","q","w","e","r","t","y","u","i","o","p","[","]","\\",
"CAPS","a","s","d","f","g","h","j","k","l",";","'","Enter",
"Shift","z","x","c","v","b","n","m",",",".","/","Shift",
" "
]
CHARACTER_TABLE_CAPS =
[
"Esc","1","2","3","4","5","6","7","8","9","0","-","=","<-Bksp",
"`","Q","W","E","R","T","Y","U","I","O","P","[","]","\\",
"caps","A","S","D","F","G","H","J","K","L",";","'","Enter",
"Shift","Z","X","C","V","B","N","M",",",".","/","Shift",
" "
]
CHARACTER_TABLE_SHIFT =
[
"Esc","!","@","#","$","%","^","&","*","(",")","_","+","<-Bksp",
"~","Q","W","E","R","T","Y","U","I","O","P","{","}","|",
"CAPS","A","S","D","F","G","H","J","K","L",":","\"","Enter",
"[Shift]","Z","X","C","V","B","N","M","<",">","?","[Shift]",
" "
]
CHARACTER_TABLE_CAPS_SHIFT =
[
"Esc","~","!","@","#","$","%","^","&","*","(",")","_","+","<-Bksp",
"~","q","w","e","r","t","y","u","i","o","p","{","}","|",
"caps","a","s","d","f","g","h","j","k","l",":","\"","Enter",
"[Shift]","z","x","c","v","b","n","m","<",">","?","[Shift]",
" "
]
attr_accessor :caps # 是否大写锁定
attr_accessor :shift # 是否上档
#--------------------------------------------------------------------------
# ● 初始化对像
#--------------------------------------------------------------------------
def initialize
super(0, 128, 640, 352)
self.contents = Bitmap.new(width - 32, height - 32)
@index = 0
@caps = false
@shift = false
@last_index = 0
refresh
update_cursor_rect
end
#--------------------------------------------------------------------------
# ● 获取文字
#--------------------------------------------------------------------------
def character(id = -1)
id = @index if id == -1
if @caps
return @shift ? CHARACTER_TABLE_CAPS_SHIFT[id] : CHARACTER_TABLE_CAPS[id]
else
return @shift ? CHARACTER_TABLE_SHIFT[id] : CHARACTER_TABLE_NORMAL[id]
end
end
#--------------------------------------------------------------------------
# ● 获取按钮位置
#--------------------------------------------------------------------------
def key_pos(id)
x = y = w = 0
case id
when 0..12 # Esc 1 ... =
x = 4 + id * 40
y = 32
w = 40
when 13 # 退格
x = 524
y = 32
w = 80
when 14..27 # ` Q W ... \
x = 24 + (id - 14) * 40
y = 82
w = 40
when 28 # 大写
x = 4
y = 132
w = 80
when 29..39 # A S ... '
x = 84 + (id - 29) * 40
y = 132
w = 40
when 40 # 回车
x = 524
y = 132
w = 80
when 41 # LShift
x = 4
y = 182
w = 100
when 42..51 # Z X ... /
x = 104 + (id - 42) * 40
y = 182
w = 40
when 52 # RShift
x = 504
y = 182
w = 100
when 53 # 空格
x = 184
y = 232
w = 280
end
return [x, y, w]
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0..53
pos = key_pos(i)
self.contents.draw_text(pos[0], pos[1], pos[2], 40, character(i), 1)
end
end
#--------------------------------------------------------------------------
# ● 刷新光标矩形
#--------------------------------------------------------------------------
def update_cursor_rect
pos = key_pos(@index)
self.cursor_rect.set(pos[0], pos[1], pos[2], 40)
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
super
# 光标下
if Input.repeat?(Input::DOWN)
case @index
when 0..27
@index += 14
@index = [@index, 40].min
when 28..40
@index += 13
@index = [@index, 52].min
when 41..52
@last_index = @index
@index = 53
when 53
$game_system.se_play($data_system.buzzer_se)
end
$game_system.se_play($data_system.cursor_se) unless @index == 53
end
# 光标上
if Input.repeat?(Input::UP)
case @index
when 0..13
$game_system.se_play($data_system.buzzer_se)
when 14..40
@index -= 14
when 41..52
@index -= 13
when 53
@index = @last_index
end
$game_system.se_play($data_system.cursor_se) unless @index < 14
end
# 光标左
if Input.repeat?(Input::LEFT)
case @index
when 0, 14, 28, 41, 53
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@index -= 1
end
end
# 光标右
if Input.repeat?(Input::RIGHT)
case @index
when 13, 27, 40, 52, 53
$game_system.se_play($data_system.buzzer_se)
else
$game_system.se_play($data_system.cursor_se)
@index += 1
end
end
update_cursor_rect
end
end
#==============================================================================
# ■ Scene_Name
#------------------------------------------------------------------------------
# 处理名称输入画面的类。
#==============================================================================
class Scene_Name
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
# 刷新窗口
@edit_window.update
@input_window.update
# 按下 B 键的情况下
if Input.repeat?(Input::B)
# 光标位置为 0 的情况下
if @edit_window.index == 0
return
end
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 删除文字
@edit_window.back
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 取得光标位置
case @input_window.character
# 光标位置为 [取消] 的情况下
when "Esc"
# 还原为默认名称
@edit_window.restore_default
return
# 光标位置为 [回车] 的情况下
when "Enter"
# 名称为空的情况下
if @edit_window.name == ""
# 还原为默认名称
@edit_window.restore_default
# 名称为空的情况下
if @edit_window.name == ""
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
return
end
# 更改角色名称
@actor.name = @edit_window.name
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 切换到地图画面
$scene = Scene_Map.new
return
# 光标位置为 [退格] 的情况下
when "<-Bksp"
# 光标位置为 0 的情况下
if @edit_window.index == 0
return
end
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 删除文字
@edit_window.back
return
# 光标位置为 [大写] 的情况下
when "CAPS", "caps"
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
@input_window.caps = !@input_window.caps
@input_window.refresh
return
# 光标位置为 [上档] 的情况下
when "Shift", "[Shift]"
# 演奏光标 SE
$game_system.se_play($data_system.cursor_se)
@input_window.shift = !@input_window.shift
@input_window.refresh
return
# 其他情况下
else
# 光标位置为最大的情况下
if @edit_window.index == $game_temp.name_max_char
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 文字为空的情况下
if @input_window.character == ""
# 演奏冻结 SE
$game_system.se_play($data_system.buzzer_se)
return
end
# 演奏确定 SE
$game_system.se_play($data_system.decision_se)
# 添加文字
@edit_window.add(@input_window.character)
# 取消上档
if @input_window.shift
@input_window.shift = false
@input_window.refresh
end
return
end
end
end
end
|
评分
-
查看全部评分
|