赞 | 2 |
VIP | 143 |
好人卡 | 1 |
积分 | 1 |
经验 | 216792 |
最后登录 | 2019-10-10 |
在线时间 | 24 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 61
- 在线时间
- 24 小时
- 注册时间
- 2008-8-5
- 帖子
- 1924
|
rm_mouse_wheel.rar
(21.14 KB, 下载次数: 162)
附件里是预编译的 DLL,目标环境是 x86
将 DLL 放在游戏根目录,然后在 RM 里加入如下脚本:- class Class
- def ===(aClass)
- return self == aClass
- end
- end
- module Mouse
- def self.on_wheel(delta, keys, x, y)
- case $scene.class
- when Scene_Title, Scene_End
- command_window = $scene.instance_eval { @command_window }
- item_max = command_window.instance_eval { @item_max }
- command_window and
- command_window.index =
- [0, [item_max - 1, command_window.index - delta / 120].min].max
- when Scene_Item
- # ...
- end
- end
- if !defined? Wheel
- Wheel = Win32API.new('rm_mouse_wheel', 'intercept', 'v', 'v')
- Wheel.call
- end
- end
复制代码 其中 on_wheel 就是处理滚轮的回调函数,可以在里面扩充不同场景的处理,这里实现了在标题和结束场景时滚轮移动窗口光标的功能
参数列表中,delta 是滚动的范围;keys 是滚动同时还有什么虚拟键按下;x 是滚动时的屏幕鼠标 x 坐标;x 是滚动时的屏幕鼠标 y 坐标
具体用法可以参考:
http://msdn.microsoft.com/en-us/library/ms645617(VS.85).aspx
DLL 源代码:
- #include <windows.h>
- #include <stdio.h>
- typedef DWORD (*EVALFUNC)(LPCSTR);
- LONG oldWndProc;
- EVALFUNC eval;
- LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- switch(uMsg) {
- case WM_MOUSEWHEEL:
- char buf[128];
- sprintf(buf, "Mouse.respond_to? :on_wheel and Mouse.on_wheel(%hd,%hd,%hd,%hd)",
- wParam >> 16 & 0xffff, wParam & 0xffff, lParam & 0xffff, lParam >> 16 & 0xffff);
- eval(buf);
- return TRUE;
- default:
- return CallWindowProc((WNDPROC)oldWndProc, hWnd, uMsg, wParam, lParam);
- }
- }
- void intercept() {
- HMODULE hRGSS;
- DWORD threadId = GetCurrentThreadId();
- HWND hWnd = GetWindow(GetForegroundWindow(), GW_HWNDFIRST);
- do {
- if(threadId == GetWindowThreadProcessId(hWnd, NULL)) {
- char className[12];
- GetClassName(hWnd, className, 12);
- if(!strcmp(className, "RGSS Player")) break;
- }
- hWnd = GetWindow(hWnd, GW_HWNDNEXT);
- } while(hWnd);
- oldWndProc = SetWindowLong(hWnd, GWL_WNDPROC, (LONG)WindowProc);
- if(!(hRGSS = LoadLibrary("rgss102j.dll")))
- hRGSS = LoadLibrary("rgss103j.dll");
- eval = (EVALFUNC)GetProcAddress(hRGSS, "RGSSEval");
- }
复制代码 |
|