module VIPArcher GetWindowThreadProcessId = Win32API.new('user32', 'GetWindowThreadProcessId', 'lp', 'l') GetWindow = Win32API.new('user32', 'GetWindow', 'll', 'l') GetClassName = Win32API.new('user32', 'GetClassName', 'lpl', 'l') GetWindowText = Win32API.new('user32', 'GetWindowText', 'lpl', 'l') GetCurrentThreadId = Win32API.new('kernel32', 'GetCurrentThreadId', 'V', 'l') GetForegroundWindow = Win32API.new('user32', 'GetForegroundWindow', 'V', 'l') ShellExecuteA = Win32API.new('shell32', 'ShellExecuteA', 'pppppi', 'i') def self.get_window_handle threadID = GetCurrentThreadId.call hWnd = GetWindow.call(GetForegroundWindow.call, 0) while hWnd != 0 if threadID == GetWindowThreadProcessId.call(hWnd, 0) className = " " * 11 GetClassName.call(hWnd, className, 12) break if className == "RGSS Player" end hWnd = GetWindow.call(hWnd, 2) end return hWnd end def self.open_url(addr) ShellExecuteA.call(0,'open',addr,0, 0, 1) end end class Game_Interpreter def get_bitmap(id = 0) spriteset = SceneManager.scene.instance_variable_get(:@spriteset) sprite = spriteset.instance_variable_get(:@picture_sprites)[id] sprite ? sprite.bitmap : nil end end class IniFile attr_reader :filename GetPrivateProfileString = Win32API.new('kernel32','GetPrivateProfileString' , 'ppppip', 'i') WritePrivateProfileString = Win32API.new('kernel32','WritePrivateProfileString', 'pppp' , 'i') def initialize(filename = './Game.ini') @filename = filename end def [](section, key, default_value = '') l = GetPrivateProfileString.call(section, key, default_value, buffer = [].pack('x256'), buffer.size, @filename); buffer[0, l] end def []=(section, key, value) WritePrivateProfileString.call(section, key, value.to_s, @filename) end end class String MultiByteToWideChar = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i') WideCharToMultiByte = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i') Codepages = { :System => 0, :UTF7 => 65000, :UTF8 => 65001, :S_JIS => 932, :GB2312 => 936, :BIG5 => 950, } def iconv s, d src = s.is_a?(Symbol)? Codepages[s] : s dest = d.is_a?(Symbol)? Codepages[d] : d len = MultiByteToWideChar.call src, 0, self, -1, nil, 0 buf = "\0" * (len * 2) MultiByteToWideChar.call src, 0, self, -1, buf, buf.size / 2 len = WideCharToMultiByte.call dest, 0, buf, -1, nil, 0, nil, nil ret = "\0" * len WideCharToMultiByte.call dest, 0, buf, -1, ret, ret.size, nil, nil self.respond_to?(:force_encoding) ? ret.force_encoding("ASCII-8BIT").delete("\000") : ret.delete("\000") end def s2u self.respond_to?(:force_encoding) ? iconv(:System, :UTF8).force_encoding("utf-8") : iconv(:System, :UTF8) end def u2s iconv(:UTF8, :System) end end class RPG::BaseItem def renote(note,default = nil) result = /<#{note}\s+(\S+)\s*>/ =~ @note ? $1 : default result end end class Bitmap def draw_gradient_text(x, y, w, h, str, align = 0, level = 1) if font.color == Color.new(255, 255, 255) draw_text(x, y, w, h, str, align); return self end; buffer, buffer.font = Bitmap.new(w, h), font.dup delta = (alpha = font.color.alpha) / h * level buffer.font.out_color, buffer.font.shadow = Color.new, false rect, buffer.font.color = Rect.new(0, 0, w, level), Color.new(255, 255, 255) draw_text(x, y, w, h, str, align); buffer.draw_text(0, 0, w, h, str, align) y.upto(y + h) { |n| next unless n % level == 0 blt(x, n, buffer, rect, alpha -= delta); rect.y += level }; buffer.dispose; self end end
|