赞 | 3 |
VIP | 0 |
好人卡 | 39 |
积分 | 1 |
经验 | 101436 |
最后登录 | 2017-9-1 |
在线时间 | 2276 小时 |
Lv1.梦旅人 路人党员
- 梦石
- 0
- 星屑
- 52
- 在线时间
- 2276 小时
- 注册时间
- 2010-12-30
- 帖子
- 3225
|
5楼
楼主 |
发表于 2015-8-21 17:19:16
|
只看该作者
# coding: gbk require 'win32api' def err_msg(format, *args) Win32API.new('user32', 'MessageBox', 'lppl', 'i').call(@hWnd ? @hWnd : 0, format % args, @title, 16) stop end def stop Win32API.new('kernel32', 'FreeLibrary', 'l', 'i').call(@hRGSSCore) if @hRGSSCore and @hRGSSCore != 0 Win32API.new('user32', 'DestroyWindow', 'l', 'i').call(@hWnd) if @hWnd and @hWnd != 0 Win32API.new('user32', 'UnregisterClass', 'pl', 'i').call(WndClassName, @hInstance) exit end WndClassName = "RGSS Player" DefaultLibrary = "RGSS102J.dll" DefaultTitle = "Untitled" DefaultScripts = "Data\\Scripts.rxdata" @library = [0].pack('C') * 100 @title = [0].pack('C') * 100 @scripts = [0].pack('C') * 100 @hInstance = Win32API.new('kernel32', 'GetModuleHandle', 'l', 'l').call(0) Win32API.new('user32', 'ShowWindow', 'li', 'i').call(Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, 0) @inipath = File.basename(__FILE__).sub(/\.rb$/i, '.ini') @inipath = File.join(Dir.pwd, @inipath).gsub(/\//, "\\") if File.exist?(@inipath) gpps = Win32API.new('kernel32', 'GetPrivateProfileString', 'ppppip', 'i') gpps.call('Game', 'Library', DefaultLibrary, @library, 100, @inipath) gpps.call('Game', 'Title', DefaultTitle, @title, 100, @inipath) gpps.call('Game', 'Scripts', DefaultScripts, @scripts, 100, @inipath) @library.delete([0].pack('C')) @title.delete([0].pack('C')) @scripts.delete([0].pack('C')) else @library = DefaultLibrary @title = DefaultTitle @scripts = DefaultScripts end if File.exist?(File.basename(__FILE__).sub(/\.rb$/i, '.rgssad')) @rgssad = File.basename(__FILE__).sub(/\.rb$/i, '.rgssad') @rgssad = File.join(Dir.pwd, @rgssad).gsub(/\//, "\\") end @wndclass = [ 43, # style Win32API.new('kernel32', 'GetProcAddress', 'lp', 'l').call( Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call('User32.dll'), 'DefWindowProcW'), # wndproc 0, # class extra 0, # wnd extra @hInstance, Win32API.new('user32', 'LoadIcon', 'll', 'l').call(0, 32512), # icon Win32API.new('user32', 'LoadCursor', 'll', 'l').call(0, 32512), # cursor Win32API.new('gdi32', 'GetStockObject', 'i', 'l').call(4), # brush 0, # menu name WndClassName # class name ].pack('ILiiLLLLLp') temp = Win32API.new('user32', 'RegisterClass', 'p', 'l').call(@wndclass) err_msg("注册窗口类失败 %s。", WndClassName) if temp == 0 gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i') width = gsm.call(7) * 2 + 640 height = gsm.call(8) * 2 + gsm.call(4) + 480 x = (gsm.call(0) - width) / 2 y = (gsm.call(1) - height) / 2 @hWnd = Win32API.new('user32','CreateWindowExA','lpplllllllll','l').call( 0x100, WndClassName, @title, 0x90CA0000, x, y, width, height, 0, 0, @hInstance, 0) err_msg("创建窗口失败 %s。", @title) if @hWnd == 0 @hRGSSCore = Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call(@library) err_msg("加载RGSS核心库失败 %s。", @library) if @hRGSSCore == 0 def get_check(ary) begin Kernel.const_set(ary[0], Win32API.new(@library, *ary)) rescue Exception err_msg("获取RGSS核心库导出函数失败 %s。", ary[0]) end end get_check(%w{RGSSEval p i}) get_check(%w{RGSSInitialize l v}) get_check(%w{RGSSGameMain lpl v}) get_check(%w{RGSSSetupRTP ppi}) undef :get_check rtpname = [0].pack('C') * 1024 if (RGSSSetupRTP.call(@inipath, rtpname, 1024) == 0) err_msg("没有发现 RGSS-RTP %s。", rtpname.delete([0].pack('C'))) end RGSSInitialize.call(@hRGSSCore) if ARGV.include?("btest") RGSSEval.call("$DEBUG = true; $BTEST = true") @rgssad = nil elsif ARGV.include?('debug') RGSSEval.call("$DEBUG = true") end RGSSGameMain.call(@hWnd, @scripts, @rgssad ? rgssad.object_id * 2 + 16 : 0) stop
# coding: gbk
require 'win32api'
def err_msg(format, *args)
Win32API.new('user32', 'MessageBox', 'lppl', 'i').call(@hWnd ? @hWnd : 0, format % args, @title, 16)
stop
end
def stop
Win32API.new('kernel32', 'FreeLibrary', 'l', 'i').call(@hRGSSCore) if @hRGSSCore and @hRGSSCore != 0
Win32API.new('user32', 'DestroyWindow', 'l', 'i').call(@hWnd) if @hWnd and @hWnd != 0
Win32API.new('user32', 'UnregisterClass', 'pl', 'i').call(WndClassName, @hInstance)
exit
end
WndClassName = "RGSS Player"
DefaultLibrary = "RGSS102J.dll"
DefaultTitle = "Untitled"
DefaultScripts = "Data\\Scripts.rxdata"
@library = [0].pack('C') * 100
@title = [0].pack('C') * 100
@scripts = [0].pack('C') * 100
@hInstance = Win32API.new('kernel32', 'GetModuleHandle', 'l', 'l').call(0)
Win32API.new('user32', 'ShowWindow', 'li', 'i').call(Win32API.new('kernel32', 'GetConsoleWindow', 'v', 'l').call, 0)
@inipath = File.basename(__FILE__).sub(/\.rb$/i, '.ini')
@inipath = File.join(Dir.pwd, @inipath).gsub(/\//, "\\")
if File.exist?(@inipath)
gpps = Win32API.new('kernel32', 'GetPrivateProfileString', 'ppppip', 'i')
gpps.call('Game', 'Library', DefaultLibrary, @library, 100, @inipath)
gpps.call('Game', 'Title', DefaultTitle, @title, 100, @inipath)
gpps.call('Game', 'Scripts', DefaultScripts, @scripts, 100, @inipath)
@library.delete([0].pack('C'))
@title.delete([0].pack('C'))
@scripts.delete([0].pack('C'))
else
@library = DefaultLibrary
@title = DefaultTitle
@scripts = DefaultScripts
end
if File.exist?(File.basename(__FILE__).sub(/\.rb$/i, '.rgssad'))
@rgssad = File.basename(__FILE__).sub(/\.rb$/i, '.rgssad')
@rgssad = File.join(Dir.pwd, @rgssad).gsub(/\//, "\\")
end
@wndclass = [
43, # style
Win32API.new('kernel32', 'GetProcAddress', 'lp', 'l').call(
Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call('User32.dll'),
'DefWindowProcW'), # wndproc
0, # class extra
0, # wnd extra
@hInstance,
Win32API.new('user32', 'LoadIcon', 'll', 'l').call(0, 32512), # icon
Win32API.new('user32', 'LoadCursor', 'll', 'l').call(0, 32512), # cursor
Win32API.new('gdi32', 'GetStockObject', 'i', 'l').call(4), # brush
0, # menu name
WndClassName # class name
].pack('ILiiLLLLLp')
temp = Win32API.new('user32', 'RegisterClass', 'p', 'l').call(@wndclass)
err_msg("注册窗口类失败 %s。", WndClassName) if temp == 0
gsm = Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
width = gsm.call(7) * 2 + 640
height = gsm.call(8) * 2 + gsm.call(4) + 480
x = (gsm.call(0) - width) / 2
y = (gsm.call(1) - height) / 2
@hWnd = Win32API.new('user32','CreateWindowExA','lpplllllllll','l').call(
0x100, WndClassName, @title, 0x90CA0000, x, y, width, height, 0, 0, @hInstance, 0)
err_msg("创建窗口失败 %s。", @title) if @hWnd == 0
@hRGSSCore = Win32API.new('kernel32', 'LoadLibrary', 'p', 'l').call(@library)
err_msg("加载RGSS核心库失败 %s。", @library) if @hRGSSCore == 0
def get_check(ary)
begin
Kernel.const_set(ary[0], Win32API.new(@library, *ary))
rescue Exception
err_msg("获取RGSS核心库导出函数失败 %s。", ary[0])
end
end
get_check(%w{RGSSEval p i})
get_check(%w{RGSSInitialize l v})
get_check(%w{RGSSGameMain lpl v})
get_check(%w{RGSSSetupRTP ppi})
undef :get_check
rtpname = [0].pack('C') * 1024
if (RGSSSetupRTP.call(@inipath, rtpname, 1024) == 0)
err_msg("没有发现 RGSS-RTP %s。", rtpname.delete([0].pack('C')))
end
RGSSInitialize.call(@hRGSSCore)
if ARGV.include?("btest")
RGSSEval.call("$DEBUG = true; $BTEST = true")
@rgssad = nil
elsif ARGV.include?('debug')
RGSSEval.call("$DEBUG = true")
end
RGSSGameMain.call(@hWnd, @scripts, @rgssad ? rgssad.object_id * 2 + 16 : 0)
stop
|
|