赞 | 0 |
VIP | 133 |
好人卡 | 5 |
积分 | 1 |
经验 | 15036 |
最后登录 | 2017-9-12 |
在线时间 | 190 小时 |
Lv1.梦旅人 彩色的银子
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 190 小时
- 注册时间
- 2006-6-13
- 帖子
- 1361
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
大概就酱紫...
圆一下以前的想法..哈....
参考于.
http://rpg.blue/viewthread.php?t ... D7%2D9+19%3A46%3A04
- #------------------------------------------------------------------------------
- # Moonlight INN
- # [url]http://cgi.members.interq.or.jp/aquarius/rasetsu/[/url]
- # RaTTiE
- # [email][email protected][/email]
- #------------------------------------------------------------
- # EasyConv::s2u(text) : S-JIS -> UTF-8
- # EasyConv::u2s(text) : UTF-8 -> S-JIS
- #==============================================
- module EasyConv
- # API梡掕悢掕媊
- CP_ACP = 0
- CP_UTF8 = 65001
- #--------------------------------------------------------------------------
- # 仠 S-JIS -> UTF-8
- #--------------------------------------------------------------------------
- def s2u(text)
- # API掕媊
- m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
- w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
- # S-JIS -> Unicode
- 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);
- # Unicode -> UTF-8
- 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);
-
- return ret
- end
- # module_function偲偟偰岞奐
- module_function :s2u
- #--------------------------------------------------------------------------
- # 仠 UTF-8 -> S-JIS
- #--------------------------------------------------------------------------
- def u2s(text)
- # API掕媊
- m2w = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
- w2m = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
- # UTF-8 -> Unicode
- 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);
- # Unicode -> S-JIS
- 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
- # module_function偲偟偰岞奐
- module_function :u2s
- end
- #========================================
- # 本脚本来自[url]www.66rpg.com[/url]
- #========================================
- #==============================================================================
- # ■ TextBox
- #------------------------------------------------------------------------------
- # 设置输入窗口
- #==============================================================================
- class TextBox
- # 获取程序模块
- GetModuleHandle = Win32API.new("kernel32", "GetModuleHandle", "p", "l")
- # 创建窗口
- CreateWindowEx = Win32API.new("user32", "CreateWindowExA", "lppllllllllp", "l")
- # 销毁窗口
- DestroyWindow = Win32API.new("user32", "DestroyWindow", "l", "l")
- # 控制窗口显示
- ShowWindow = Win32API.new("user32", "ShowWindow", "ll", "l")
- # 设置输入焦点
- SetFocus = Win32API.new("user32", "SetFocus", "l", "l")
- # 获取活动的窗口
- GetActiveWindow = Win32API.new("user32", "GetActiveWindow", nil, "l")
- # 获取控件文字
- GetWindowText = Win32API.new("user32", "GetWindowTextA", "lpl", "l")
- # 获取控件文字长度
- GetWindowTextLength = Win32API.new("user32", "GetWindowTextLength", "l", "l")
- # 设置控件文字
- SetWindowTextA = Win32API.new("user32", "SetWindowTextA", "lp", "l")
- # 刷新窗口
- UpdateWindow = Win32API.new("user32", "UpdateWindow", "l", "l")
- # 常数
- WS_CHILD = 0x40000000
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(w, h)
- @wnd = CreateWindowEx.call(1, "Edit", "", WS_CHILD, 0,0,w,h,GetActiveWindow.call,1,GetModuleHandle.call(nil),1)
- SetFocus.call(@wnd)
- ShowWindow.call(@wnd,0)
- end
- #--------------------------------------------------------------------------
- # ● 释放窗口
- #--------------------------------------------------------------------------
- def dispose
- DestroyWindow.call(@wnd)
- end
- #--------------------------------------------------------------------------
- # ● 获取txt
- #--------------------------------------------------------------------------
- def txt
- length = GetWindowTextLength.call(@wnd)
- lpstring = Array.new(length+1).pack("C*")
- GetWindowText.call(@wnd, lpstring, length)
- lpstring.delete!("\0")
- t = EasyConv::s2u(lpstring)
- return t
- end
- #--------------------------------------------------------------------------
- # ● 设置txt
- #--------------------------------------------------------------------------
- def set_txt(txt)
- str = EasyConv::u2s(txt)
- SetWindowTextA.call(@wnd, str)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- UpdateWindow.call(@wnd)
- SetFocus.call(@wnd)
- end
- end
- t = TextBox.new(320, 24)
- v = Viewport.new(160, 228, 320 , 24)
- sprite = Sprite.new(v)
- sprite.bitmap = Bitmap.new(320,24)
- sprite.bitmap.fill_rect(0,0,320,24,Color.new(0,0,0))
- sprite.bitmap.fill_rect(1,1,318,22,Color.new(255,255,255))
- cou = Sprite.new(v)
- cou.bitmap = Bitmap.new(1, 22)
- cou.bitmap.fill_rect(0, 0, 1, 22, Color.new(0,255,255))
- cou.y = 1
- s = t.txt
- loop {
- Graphics.update
- Input.update
- t.update
- cou.visible = Time.now.sec % 2 == 0
- if s != t.txt
- cou.visible = true
- s = t.txt
- sprite.bitmap.clear
- sprite.bitmap.font.size = 18
- sprite.bitmap.font.color.set(0,0,0)
- sprite.bitmap.fill_rect(0,0,320,24,Color.new(0,0,0))
- sprite.bitmap.fill_rect(1,1,318,22,Color.new(255,255,255))
- sprite.bitmap.draw_text(0,0,320,24,s)
- cou.x = 1 + sprite.bitmap.text_size(s).width
- end
- }
复制代码 |
|