简介
本工具为 RMXP 数据库增加了与 VX 及 VX Ace 相同的“备注”功能。
灵感来源于http://rm.66rpg.com/forum.php?mod=viewthread&tid=241539
本工具为 RMXP 数据库增加了与 VX 及 VX Ace 相同的“备注”功能。
灵感来源于http://rm.66rpg.com/forum.php?mod=viewthread&tid=241539
在RGSS中使用Win32API时,如果涉及中文及其他特殊字符,就必须在系统代码页及UTF-8间进行必要的转换,否则就会出现乱码。在许许多多的脚本中都可以见到类似的转码脚本,其中大多数年代久远,作者已不可考。我的这个版本只是选取一个常见的版本,简单地进行了些许优化。
#==============================================================================
# ■ EasyConv
#------------------------------------------------------------------------------
# 转码模块。原作者不明,由失落的乐章优化。
#==============================================================================
module EasyConv
#--------------------------------------------------------------------------
# ● 常量定义
#--------------------------------------------------------------------------
CP_ACP = 0
CP_UTF8 = 65001
M2W = Win32API.new('kernel32', 'MultiByteToWideChar', 'ilpipi', 'i')
W2M = Win32API.new('kernel32', 'WideCharToMultiByte', 'ilpipipp', 'i')
#--------------------------------------------------------------------------
# ● 转码
#--------------------------------------------------------------------------
def s2u
len = M2W.call(CP_ACP, 0, self, -1, nil, 0)
buf = "\0" * (len*2)
M2W.call(CP_ACP, 0, self, -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
len = M2W.call(CP_UTF8, 0, self, -1, nil, 0)
buf = "\0" * (len*2)
M2W.call(CP_UTF8, 0, self, -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
class String
include EasyConv
end
module Graphics
#取得窗口句柄
HWND = Win32API.new('user32','GetActiveWindow',nil,'l').call
def self.fullscreen?
#取得窗口范围矩形
window_rect = "\0" * 16
Win32API.new('user32','GetWindowRect',['l','p'],'i').call(HWND,window_rect)
wl,wt,wr,wb = window_rect.unpack('llll')
#取得客户区矩形
client_rect = "\0" * 16
Win32API.new('user32','GetClientRect',['l','p'],'i').call(HWND,client_rect)
cl,ct,cr,cb = client_rect.unpack('llll')
wr - wl == cr
end
end
使用时:
Graphics.fullscreen? #当游戏处于全屏状态时返回true, 否则返回false
原理:使用GetWindowRect 和GetClientRect 分别取得游戏窗口的整个范围矩形和客户区矩形。游戏全屏后,由于不再存在边框,这两个矩形就是相等的。而在窗口模式下,客户区矩形会小一些。