Project1
标题:
关于数值输入的问题
[打印本页]
作者:
banbianzhang
时间:
2013-10-1 08:55
标题:
关于数值输入的问题
本帖最后由 myownroc 于 2013-10-1 08:59 编辑
有没有单独的数值输入脚本可以改成键盘输入?夏娜的太难用了。
或者教教我怎么用夏娜的脚本吧……多谢大侠
以下是夏娜的脚本
@Person
=begin
脚本:【完美输入法修正】
功能:输入法。
说明: 直接用Type_Field创建输入域即可进行输入,在此可根据Type_Field域对象
的活动标记active来自定义刷新等,在Type_Field中需要自己处理特殊按键
的处理方法。具体不明白之处请参考范例工程。
作者:灼眼的夏娜
补充: 至于以前那个版本也许很多人都注意到那个烦人的问题了吧,按Enter和Tab那
些会出现不爽的声音,这个版本解决了那个问题,并简化添加了Type_Field类
来方便创建输入域。
=end
#==============================================================================
# ■ RInput
#------------------------------------------------------------------------------
# 全键盘处理的模块。
#==============================================================================
module RInput
#--------------------------------------------------------------------------
# ● 常量定义
#--------------------------------------------------------------------------
ENTER = 0x0D
SPACE = 0x20
UP = 0x26
DOWN = 0x28
LEFT = 0x25
RIGHT = 0x27
LCTRL = 0xA2
LALT = 0xA4
#--------------------------------------------------------------------------
# ● 临时Hash
#--------------------------------------------------------------------------
@R_Key_Hash = {}
@R_Key_Repeat = {}
#--------------------------------------------------------------------------
# ● 唯一API
#--------------------------------------------------------------------------
GetKeyState = Win32API.new("user32","GetAsyncKeyState",['I'],'I')
#--------------------------------------------------------------------------
# ● 单键处理
#--------------------------------------------------------------------------
def self.trigger?(rkey)
result = GetKeyState.call(rkey)
if @R_Key_Hash[rkey] == 1 and result != 0
return false
end
if result != 0
@R_Key_Hash[rkey] = 1
return true
else
@R_Key_Hash[rkey] = 0
return false
end
end
end
#==============================================================================
# ■ EasyConv
#------------------------------------------------------------------------------
# 转码模块。
#==============================================================================
module EasyConv
#--------------------------------------------------------------------------
# ● 常量定义
#--------------------------------------------------------------------------
CP_ACP = 0
CP_UTF8 = 65001
#--------------------------------------------------------------------------
# ● 模块函数
#--------------------------------------------------------------------------
module_function
#--------------------------------------------------------------------------
# ● 转码
#--------------------------------------------------------------------------
def s2u(text)
m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
len = m2w.call(CP_ACP, 0, text, -1, nil, 0)
buf = "\0" * (len*2)
m2w.call(CP_ACP, 0, text, -1, buf, buf.size/2)
len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil)
ret = "\0" * len
w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil)
ret[-1] = ""
return ret
end
#--------------------------------------------------------------------------
# ● 转码
#--------------------------------------------------------------------------
def u2s(text)
m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
len = m2w.call(CP_UTF8, 0, text, -1, nil, 0)
buf = "\0" * (len*2)
m2w.call(CP_UTF8, 0, text, -1, buf, buf.size/2)
len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
ret = "\0" * len
w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
return ret
end
end
#==============================================================================
# ■ TypeAPI
#------------------------------------------------------------------------------
# 输入法相关API模块。
#==============================================================================
module TypeAPI
#--------------------------------------------------------------------------
# ● API定义
#--------------------------------------------------------------------------
GPPS = Win32API.new("kernel32","GetPrivateProfileString",'pppplp','l')
FindWindow = Win32API.new("user32", "FindWindow", 'pp', 'i')
CreateWindow = Win32API.new("NetGame","CreatWnd",'l','l')
SetHK = Win32API.new("NetGame","SetHK",'v','v')
GetText = Win32API.new("NetGame","GetWndText",'l','p')
SetFocus = Win32API.new("user32","SetFocus",'l','l')
IfBack = Win32API.new("NetGame","If_Back",'v','i')
StartType = Win32API.new("NetGame","StartType",'v','v')
EndType = Win32API.new("NetGame","EndType",'v','v')
GetKeyInfos = Win32API.new("NetGame","GetKeyInfo",'v','i')
#--------------------------------------------------------------------------
# ● 模块函数
#--------------------------------------------------------------------------
module_function
#--------------------------------------------------------------------------
# ● 获取参数
#--------------------------------------------------------------------------
def getParam
val = "\0" * 256
GPPS.call("Game","Title","",val,256,"./Game.ini")
val.delete!("\0")
return val
end
#--------------------------------------------------------------------------
# ● 获取窗口
#--------------------------------------------------------------------------
def findWindow
return FindWindow.call("RGSS Player",self.getParam)
end
#--------------------------------------------------------------------------
# ● 创建窗口
#--------------------------------------------------------------------------
def createWindow(hwnd)
return CreateWindow.call(hwnd)
end
#--------------------------------------------------------------------------
# ● 设置HK
#--------------------------------------------------------------------------
def setHK
SetHK.call
end
#--------------------------------------------------------------------------
# ● 获取文字
#--------------------------------------------------------------------------
def getText
return EasyConv.s2u(GetText.call(@subhwnd))
end
#--------------------------------------------------------------------------
# ● 设置焦点
#--------------------------------------------------------------------------
def setFocus
SetFocus.call(@subhwnd)
end
#--------------------------------------------------------------------------
# ● 转换焦点
#--------------------------------------------------------------------------
def lostFocus
SetFocus.call(@hwnd)
end
#--------------------------------------------------------------------------
# ● 退格判定
#--------------------------------------------------------------------------
def ifBack
return IfBack.call
end
#--------------------------------------------------------------------------
# ● 开始输入
#--------------------------------------------------------------------------
def startType
StartType.call
end
#--------------------------------------------------------------------------
# ● 结束输入
#--------------------------------------------------------------------------
def endType
EndType.call
end
#--------------------------------------------------------------------------
# ● 输入中特殊按键处理
#--------------------------------------------------------------------------
def getKeyInfos
return GetKeyInfos.call
end
#--------------------------------------------------------------------------
# ● 获取句柄
#--------------------------------------------------------------------------
@hwnd = self.findWindow
@subhwnd = self.createWindow(@hwnd)
#--------------------------------------------------------------------------
# ● 设置HK应用
#--------------------------------------------------------------------------
self.setHK
end
#==============================================================================
# ■ Type_Field
#------------------------------------------------------------------------------
# 处理输入域的类。
#==============================================================================
class Type_Field
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr(:active)
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(v,default_text = "",default_careth = nil,default_fonts = 16,\
default_fontc = Color.new(0,0,0))
# active
@active = true
# 视口
rect = v.rect
@v = Viewport.new(rect.x,rect.y,rect.width,rect.height)
[url=home.php?mod=space&uid=133944]@w[/url] = rect.width
@h = rect.height
# 属性
@caret_h = default_careth.nil? ? @h : [@h,default_careth].min
@caret_y = rect.y + (@h - @caret_h) / 2
@font_size = [default_fonts,@h].min
# 描绘contents
@cts = Sprite.new(@v)
@cts.bitmap = Bitmap.new([url=home.php?mod=space&uid=133944]@w[/url] - 3,@h)
@cts.bitmap.font.size = @font_size
@cts.bitmap.font.color = default_fontc
# 辅助属性
@bk_count = 0
@text = default_text.scan(/./)
@max_width = @w - 3
@caret_pos = @text.size
@save_pos = @caret_pos
# 光标Caret
@v1 = Viewport.new(rect.x,@caret_y,@w + 3,@caret_h)
@caret_sp = Sprite.new(@v1)
@caret_bitmap = Bitmap.new(3,@caret_h)
@caret_bitmap.fill_rect(0,0,1,@caret_h,Color.new(0,0,0,180))
@caret_bitmap.fill_rect(1,0,1,@caret_h,Color.new(0,0,0))
@caret_bitmap.fill_rect(2,0,1,@caret_h,Color.new(120,120,120))
@caret_sp.bitmap = @caret_bitmap
@caret_sp.x = self.get_width(@text[0,@caret_pos].to_s)
@caret_sp.y = 0
@caret_sp.visible = false
@caret_flash_count = 0
# 刷新
refresh
# 设置焦点
TypeAPI.setFocus
# 开始输入
TypeAPI.startType
end
#--------------------------------------------------------------------------
# ● 设置活动标记
#--------------------------------------------------------------------------
def active=(value)
if value != true and value != false
return
end
@active = value
@caret_sp.visible = @active
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
@caret_bitmap.dispose
@caret_sp.bitmap.dispose
@caret_sp.dispose
@cts.bitmap.dispose
@cts.dispose
@v.dispose
@v1.dispose
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
@cts.bitmap.clear
@cts.bitmap.draw_text(0,0,@w,@h,@text.to_s)
end
#--------------------------------------------------------------------------
# ● 获取文字
#--------------------------------------------------------------------------
def get_text
return @text.to_s
end
#--------------------------------------------------------------------------
# ● 取得字符宽度
#--------------------------------------------------------------------------
def get_width(str)
return @cts.bitmap.text_size(str).width
end
#--------------------------------------------------------------------------
# ● 更新
#--------------------------------------------------------------------------
def update
# 非激活状态则返回
unless @active
return
end
# 获取按键信息
key_info = TypeAPI.getKeyInfos
case key_info
when 0x09 # Tab
# 按下 Tab 键的情况自己定义怎么处理
return
when 0x0d # Enter
# 按下 Enter 键的情况自己定义怎么处理
return
when 0x1B # Esc
# 按下 Esc 键的情况自己定义怎么处理
return
end
self.update_text
self.update_lrb
self.update_back
self.update_caret
end
#--------------------------------------------------------------------------
# ● 更新文字
#--------------------------------------------------------------------------
def update_text
# 文字刷新
TypeAPI.setFocus
text = TypeAPI.getText
if text != ""
for char in text.scan(/./)
if self.get_width(@text.to_s + char) <= @max_width
@text[@caret_pos,0] = char
@caret_pos += 1
else
break
end
end
refresh
end
end
#--------------------------------------------------------------------------
# ● 更新左右按键
#--------------------------------------------------------------------------
def update_lrb
if RInput.trigger?(RInput::LEFT) and @caret_pos > 0
@caret_pos -= 1
return
end
if RInput.trigger?(RInput::RIGHT) and @caret_pos < @text.size
@caret_pos += 1
return
end
end
#--------------------------------------------------------------------------
# ● 更新退格
#--------------------------------------------------------------------------
def update_back
# 前退格处理
@bk_count += TypeAPI.ifBack
if @bk_count > 0
@bk_count -= 1
if @caret_pos > 0
@text.delete_at(@caret_pos - 1);@caret_pos -= 1;refresh
end
end
end
#--------------------------------------------------------------------------
# ● 更新光标闪烁
#--------------------------------------------------------------------------
def update_caret
# 闪烁计时
@caret_flash_count += 1
if @caret_flash_count == 20
@caret_sp.visible = !@caret_sp.visible
@caret_flash_count = 0
end
# Caret位置刷新
if @save_pos != @caret_pos
@save_pos = @caret_pos
@caret_sp.x = self.get_width(@text[0,@save_pos].to_s)
end
end
end
复制代码
作者:
紫英晓狼1130
时间:
2013-10-1 11:01
这里有一个输入法脚本
http://rpg.blue/forum.php?mod=viewthread&tid=243422
作者:
张咚咚
时间:
2013-10-1 11:44
仿网游 输入法.rar
(243.12 KB, 下载次数: 33)
2013-10-1 11:44 上传
点击文件名下载附件
作者:
张咚咚
时间:
2013-10-1 11:45
仿网游 输入法.rar
(243.12 KB, 下载次数: 22)
2013-10-1 11:45 上传
点击文件名下载附件
作者:
chd114
时间:
2013-10-1 11:49
#==============================================================================
# ■ Kernel
#------------------------------------------------------------------------------
# 该模块中定义了可供所有类使用的方法。Object 类中包含了该模块。
#==============================================================================
module Kernel
#--------------------------------------------------------------------------
# ● 需要的 Windows API 函数
#--------------------------------------------------------------------------
GetWindowThreadProcessId = Win32API.new("user32", "GetWindowThreadProcessId", "LP", "L")
GetWindow = Win32API.new("user32", "GetWindow", "LL", "L")
GetClassName = Win32API.new("user32", "GetClassName", "LPL", "L")
GetCurrentThreadId = Win32API.new("kernel32", "GetCurrentThreadId", "V", "L")
GetForegroundWindow = Win32API.new("user32", "GetForegroundWindow", "V", "L")
#--------------------------------------------------------------------------
# ● 获取窗口句柄
#--------------------------------------------------------------------------
def get_hWnd
# 获取调用线程(RM 的主线程)的进程标识
threadID = GetCurrentThreadId.call
# 获取 Z 次序中最靠前的窗口
hWnd = GetWindow.call(GetForegroundWindow.call, 0)
# 枚举所有窗口
while hWnd != 0
# 如果创建该窗口的线程标识匹配本线程标识
if threadID == GetWindowThreadProcessId.call(hWnd, 0)
# 分配一个 11 个字节的缓冲区
className = " " * 11
# 获取该窗口的类名
GetClassName.call(hWnd, className, 12)
# 如果匹配 RGSS Player 则跳出循环
break if className == "RGSS Player"
end
# 获取下一个窗口
hWnd = GetWindow.call(hWnd, 2)
end
return hWnd
end
end
复制代码
#==============================================================================
# ■ TextBox by EngShun
#------------------------------------------------------------------------------
# 输入框的类。
#==============================================================================
class TextBox
#--------------------------------------------------------------------------
# ● 设置API
#--------------------------------------------------------------------------
CreateWindow = Win32API.new('user32','CreateWindowEx','lpplllllllll','l')
ShowWindow = Win32API.new('user32','ShowWindow','ll','l')
DestroyWindow = Win32API.new('user32','DestroyWindow','l','l')
GetWindowText = Win32API.new('user32','GetWindowText','lpl','l')
SetWindowText = Win32API.new("user32", "SetWindowText", "lp", "l")
GetWindowTextLength = Win32API.new('user32','GetWindowTextLength','l','l')
UpdateWindow = Win32API.new('user32','UpdateWindow','l','i')
SetFocus = Win32API.new('user32','SetFocus','l','l')
SendMessage = Win32API.new('user32','SendMessage','llll','l')
MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
GetKeyState = Win32API.new("user32","GetAsyncKeyState",'I','I')
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :focus
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(text = "",limit = 8,number=false)
c = 0x40011000
c = (c|0x00001000) if number
[url=home.php?mod=space&uid=37298]@Window[/url] = CreateWindow.call(0, 'EDIT', u2s(text), c, 0, 480-22, 640, 22, get_hWnd, 0, 0, 0)
SendMessage.call(@window,0xC5,limit,0)
@focus = true
@disposed = false
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
@disposed = true
DestroyWindow.call(@window)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def update
return if !@focus or @disposed
UpdateWindow.call(@window)
SetFocus.call(@window)
end
#--------------------------------------------------------------------------
# ● 获取内容
#--------------------------------------------------------------------------
def text
return if @disposed
l = GetWindowTextLength.call(@window)
str = "\0" * (l + 1)
GetWindowText.call(@window, str, l+1)
return s2u(str.delete("\0"))
end
#--------------------------------------------------------------------------
# ● 更改内容
#--------------------------------------------------------------------------
def text=(str)
SetWindowText.call(@window, u2s(str))
return if @disposed
end
#--------------------------------------------------------------------------
# ● 获取光标位置
#--------------------------------------------------------------------------
def sel_pos
return if @disposed
return (SendMessage.call(@window,0xB0,0,0) % 65535) / 2
end
#--------------------------------------------------------------------------
# ● 设置光标位置
#--------------------------------------------------------------------------
def sel_pos=(i)
return if @disposed
SendMessage.call(@window,0xB1,i,i)
end
#--------------------------------------------------------------------------
# ● 获取光标位置
#--------------------------------------------------------------------------
def limit
return if @disposed
return SendMessage.call(@window,0xD5,0,0)
end
#--------------------------------------------------------------------------
# ● 设置光标位置
#--------------------------------------------------------------------------
def limit=(i)
return if @disposed
SendMessage.call(@window,0xC5,i,0)
end
#--------------------------------------------------------------------------
# ● 是否按下回车键
#--------------------------------------------------------------------------
def press_enter?
return if @disposed
return (@focus and (GetKeyState.call(13) != 0))
end
#--------------------------------------------------------------------------
# ● 转码:系统转UTF-8
#--------------------------------------------------------------------------
def s2u(text)
len = MultiByteToWideChar.call(0, 0, text, -1, nil, 0);
buf = "\0" * (len*2)
MultiByteToWideChar.call(0, 0, text, -1, buf, buf.size/2);
len = WideCharToMultiByte.call(65001, 0, buf, -1, nil, 0, nil, nil);
ret = "\0" * len
WideCharToMultiByte.call(65001, 0, buf, -1, ret, ret.size, nil, nil);
return ret.delete("\000")
end
#--------------------------------------------------------------------------
# ● 转码:UTF-8转系统
#--------------------------------------------------------------------------
def u2s(text)
len = MultiByteToWideChar.call(65001, 0, text, -1, nil, 0);
buf = "\0" * (len*2)
MultiByteToWideChar.call(65001, 0, text, -1, buf, buf.size/2);
len = WideCharToMultiByte.call(0, 0, buf, -1, nil, 0, nil, nil);
ret = "\0" * len
WideCharToMultiByte.call(0, 0, buf, -1, ret, ret.size, nil, nil);
return ret.delete("\000")
end
private :u2s ,:s2u # 定义私有功能
end
复制代码
#==============================================================================
# ■ Sprite_TextBox by EngShun
#------------------------------------------------------------------------------
# 显示输入框用的活动块。
#==============================================================================
class Sprite_TextBox < Sprite
#--------------------------------------------------------------------------
# ● 设置缓存的类
#--------------------------------------------------------------------------
Cache = Struct.new(:bc ,:fc ,:fs ,:text ,:sel_pos)
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_accessor :textbox
attr_accessor :back_color
#--------------------------------------------------------------------------
# ● 初始化
#--------------------------------------------------------------------------
def initialize(x = 0,y = 0,w = 128,h = 32,bc = Color.new(255,255,255),fc = Color.new(0,0,0),tb = TextBox.new)
super(nil)
self.x = x
self.y = y
self.bitmap = Bitmap.new(w,h)
self.bitmap.font.color = fc
@back_color = bc
@textbox = tb
[url=home.php?mod=space&uid=341345]@Cache[/url] = Cache.new
refresh
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def update
super
return unless @textbox.focus
@textbox.update
if (self.bitmap.font.color != @cache.fc) or
(self.bitmap.font.size != @cache.fs) or
(@textbox.sel_pos != @cache.sel_pos) or
(@textbox.text != @cache.text) or
(@back_color != @cache.bc)
refresh
end
end
#--------------------------------------------------------------------------
# ● 释放
#--------------------------------------------------------------------------
def dispose
self.bitmap.dispose
@textbox.dispose
super
end
#--------------------------------------------------------------------------
# ● 内容刷新
#--------------------------------------------------------------------------
def refresh
@cache.fc = self.bitmap.font.color
@cache.fs = self.bitmap.font.size
@cache.sel_pos = @textbox.sel_pos
@cache.text = @textbox.text
@cache.bc = @back_color
w = self.bitmap.width
h = self.bitmap.height
self.bitmap.fill_rect(0,0,w,h,@back_color)
self.bitmap.draw_text(4,0,w-4,h,@textbox.text)
t = @textbox.text.scan(/./)[0,@textbox.sel_pos].join("")
s = self.bitmap.text_size(t).width
self.bitmap.draw_text((4 + s)-16,0,32,h,"|",1)
end
private :refresh # 设置私有功能
end
复制代码
#==============================================================================
# ■ Scene_Name
#------------------------------------------------------------------------------
# 处理名称输入画面的类。
#==============================================================================
class Scene_Name
#--------------------------------------------------------------------------
# ● 主处理
#--------------------------------------------------------------------------
def main
[url=home.php?mod=space&uid=95897]@actor[/url] = $game_actors[$game_temp.name_actor_id]
@window = Window_Base.new(0,176,640,128)
@window.contents = Bitmap.new(576,96)
@window.draw_actor_graphic(@actor, 64, 80)
@window.contents.draw_text(128,0,480,32,"请输入名称:")
@sprite_tb = Sprite_TextBox.new(144,240,464)
@sprite_tb.z = 500
@sprite_tb.textbox.limit = $game_temp.name_max_char
@sprite_tb.textbox.text = @actor.name
@sprite_tb.textbox.sel_pos = @actor.name.length
Graphics.transition
loop do
Graphics.update
Input.update
update
break if $scene != self
end
Graphics.freeze
@sprite_tb.dispose
@window.dispose
end
#--------------------------------------------------------------------------
# ● 刷新画面
#--------------------------------------------------------------------------
def update
@sprite_tb.update
if @sprite_tb.textbox.press_enter?
if @sprite_tb.textbox.text == ""
$game_system.se_play($data_system.buzzer_se)
return
end
@actor.name = @sprite_tb.textbox.text
$scene = Scene_Map.new
end
end
end
复制代码
用这个的话你可以做文字+数字符号混合输入密码···按顺序把脚本放入脚本编辑器Main上方就可以了,即插即用
作者:
banbianzhang
时间:
2013-10-2 14:33
你们上面的脚本我都看过了,但是你们貌似没搞懂我的意思…………
我想把事件中的“数值输入的处理”改成键盘输入,你们给的脚本不对
我自己搜了一个数值输入的脚本,可以用数字键和方向键输入数字,可不可以把方向键输入给去掉?
#==============================================================================
# ■ 全键盘输入数值 1.1
#
http://orzFly.com/RM/FullKeyboardInputNumber
#------------------------------------------------------------------------------
# 为『输入数值的处理』增加全键盘的支持。
#------------------------------------------------------------------------------
# - 1.1 by orzFly [
[email protected]
]
# * 修正 bug:屏蔽小键盘光标移动功能。
#
# - 1.0 by orzFly [
[email protected]
]
# * 首个版本
#==============================================================================
module OrzFly
RM = Game_Temp.method_defined?(:background_bitmap) unless const_defined?(:RM)
module FullKeyInputNumber
Keys = {
# 主键盘区数字 0~9
0x30 => 0, 0x31 => 1, 0x32 => 2, 0x33 => 3, 0x34 => 4,
0x35 => 5, 0x36 => 6, 0x37 => 7, 0x38 => 8, 0x39 => 9,
# 小键盘区数字 Numpad 0, 1, 3, 5, 7, 9
0x60 => 0, 0x61 => 1, 0x63 => 3, 0x65 => 5, 0x67 => 7, 0x69 => 9,
# Numpad 2, 4, 6, 8 较特殊,单独处理
# 退格 Backspace
0x08 => -1,
# 删除 Delete
0x2E => -2
}
GetKeyState = Win32API.new(
"user32", "GetAsyncKeyState", ['I'], 'I'
)
end
end
#==============================================================================
# ■ Window_InputNumber (XP) / Window_InputNumber (VX) 追加定义
#------------------------------------------------------------------------------
# 信息窗口内部使用、输入数值的窗口。
#==============================================================================
(OrzFly::RM ? Window_NumberInput : Window_InputNumber).class_eval {
def update
super
if active
catch(:loop) {
OrzFly::FullKeyInputNumber::Keys.keys.each { |key|
if OrzFly::FullKeyInputNumber::GetKeyState.call(key) & 1 != 0
OrzFly::RM ? Sound.play_cursor \
: $game_system.se_play($data_system.cursor_se)
process_key(OrzFly::FullKeyInputNumber::Keys[key])
throw(:loop)
end
}
}
if Input.repeat?(Input::UP)or Input.repeat?(Input::DOWN)
if OrzFly::FullKeyInputNumber::GetKeyState.call(0x68) != 0
process_key(8)
elsif OrzFly::FullKeyInputNumber::GetKeyState.call(0x62) != 0
process_key(2)
else
OrzFly::RM ? Sound.play_cursor \
: $game_system.se_play($data_system.cursor_se)
place = 10 ** (@digits_max - 1 - @index)
n =
@Number
/ place % 10
@number -= n * place
n = (n + 1) % 10 if Input.repeat?(Input::UP)
n = (n + 9) % 10 if Input.repeat?(Input::DOWN)
@number += n * place
refresh
end
end
if Input.repeat?(Input::RIGHT)
if OrzFly::FullKeyInputNumber::GetKeyState.call(0x66) != 0
process_key(6)
else
OrzFly::RM ? Sound.play_cursor \
: $game_system.se_play($data_system.cursor_se)
if
@Index
< @digits_max - 1 or Input.trigger?(Input::RIGHT)
@index = (@index + 1) % @digits_max
end
end
end
if Input.repeat?(Input::LEFT)
if OrzFly::FullKeyInputNumber::GetKeyState.call(0x64) != 0
process_key(4)
else
OrzFly::RM ? Sound.play_cursor \
: $game_system.se_play($data_system.cursor_se)
if @index > 0 or Input.trigger?(Input::LEFT)
@index = (@index + @digits_max - 1) % @digits_max
end
end
end
OrzFly::RM ? update_cursor \
: update_cursor_rect
end
end
def process_key(result)
if result >= 0 and result <= 9
place = 10 ** (@digits_max - 1 - @index)
@number = @number - (@number / place % 10) * place \
+ result * place
refresh
if @digits_max >= 2
@index = (@index + 1) % @digits_max
end
elsif result == -1
if @digits_max >= 2 and @index >= 1
@index = (@index + @digits_max - 1) % @digits_max
end
place = 10 ** (@digits_max - 1 - @index)
@number = @number - (@number / place % 10) * place
refresh
elsif result == -2
place = 10 ** (@digits_max - 1 - @index)
@number = @number - (@number / place % 10) * place
refresh
end
end
}
作者:
chd114
时间:
2013-10-19 14:30
banbianzhang 发表于 2013-10-2 14:33
你们上面的脚本我都看过了,但是你们貌似没搞懂我的意思…………
我想把事件中的“数值输入的处理”改成键 ...
你确定是这个脚本吗···最后那个大括号哪里来的?
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1