简便设定全画面
rpgmakervxace吧
全部回复
仅看楼主
level 13
tseyik 楼主
按F5改変视窗大小
#******************************************************************************
#
# * 简便设定全画面
#
# --------------------------------------------------------------------------
# バージョン : 1.0.1
# 対 応 : RPGツクールVX : RGSS2
# 制 作 者 : CACAO
# 配 布 元 : http://cacaosoft.web.fc2.com/# --------------------------------------------------------------------------
# == 摘 要 ==
#
# : 添加改变视窗大小功能。
#
# --------------------------------------------------------------------------
# == 使用方法 ==
#
# ★ WLIB::SetGameWindowSize(width, height)
# 视窗移动到中心、然后更改指定的尺寸。
# 参数为负数、或大放桌面会改成全画面。
# 处理失败时会返回 false 。
#
#
#******************************************************************************
#==============================================================================
# ◆ 使用者设定
#==============================================================================
module WND_SIZE
#--------------------------------------------------------------------------
# ◇ 変更键
#--------------------------------------------------------------------------
# nil .. 不调整大小
#--------------------------------------------------------------------------
INPUT_KEY = :F5
#--------------------------------------------------------------------------
# ◇ 大小列表
#--------------------------------------------------------------------------
# [ [横幅, 縦幅], ... ] 以二个数据为一组设置。
# 设为 0 则为全画面。
#--------------------------------------------------------------------------
SIZE_LIST = [ [544,416], [640,480], [800,600], [1088,832], [0,0] ]
#--------------------------------------------------------------------------
# ◇ 储存
#--------------------------------------------------------------------------
# 设定视窗大小状况储存的文件名。
# 如果为零,则它不保存大小。
#--------------------------------------------------------------------------
FILE_SAVE = "System/test"
end
#/////////////////////////////////////////////////////////////////////////////#
# #

#        下面的脚本不需要改变。       #

# #
#/////////////////////////////////////////////////////////////////////////////#
module WLIB
#--------------------------------------------------------------------------
# ● 定数
#--------------------------------------------------------------------------
# SystemMetrics
SM_CYCAPTION = 0x04
SM_CXDLGFRAME = 0x07
SM_CYDLGFRAME = 0x08
# SetWindowPos
SWP_NOSIZE = 0x01
SWP_NOMOVE = 0x02
SWP_NOZORDER = 0x04
#--------------------------------------------------------------------------
# ● Win32API
#--------------------------------------------------------------------------
@@FindWindow =
Win32API.new('user32', 'FindWindow', 'pp', 'l')
@@GetDesktopWindow =
Win32API.new('user32', 'GetDesktopWindow', 'v', 'l')
@@SetWindowPos =
Win32API.new('user32', 'SetWindowPos', 'lliiiii', 'i')
@@GetClientRect =
Win32API.new('user32', 'GetClientRect', 'lp', 'i')
@@GetWindowRect =
Win32API.new('user32', 'GetWindowRect', 'lp', 'i')
@@GetWindowLong =
Win32API.new('user32', 'GetWindowLong', 'li', 'l')
@@GetSystemMetrics =
Win32API.new('user32', 'GetSystemMetrics', 'i', 'i')
@@SystemParametersInfo =
Win32API.new('user32', 'SystemParametersInfo', 'iipi', 'i')
#--------------------------------------------------------------------------
# ● 视窗情报
#--------------------------------------------------------------------------
GAME_TITLE = load_data("Data/System.rvdata2").game_title.encode('SHIFT_JIS')
GAME_HANDLE = @@FindWindow.call("RGSS Player", GAME_TITLE)
# GAME_HANDLE = Win32API.new('user32', 'GetForegroundWindow', 'v', 'l').call
GAME_STYLE = @@GetWindowLong.call(GAME_HANDLE, -16)
GAME_EXSTYLE = @@GetWindowLong.call(GAME_HANDLE, -20)
HDSK = @@GetDesktopWindow.call
module_function
#--------------------------------------------------------------------------
# ● GetWindowRect
#--------------------------------------------------------------------------
def GetWindowRect(hwnd)
r = [0,0,0,0].pack('l4')
if @@GetWindowRect.call(hwnd, r) != 0
result = Rect.new(*r.unpack('l4'))
result.width -= result.x
result.height -= result.y
else
result = nil
end
return result
end
#--------------------------------------------------------------------------
# ● GetClientRect
#--------------------------------------------------------------------------
def GetClientRect(hwnd)
r = [0,0,0,0].pack('l4')
if @@GetClientRect.call(hwnd, r) != 0
result = Rect.new(*r.unpack('l4'))
else
result = nil
end
return result
end
#--------------------------------------------------------------------------
# ● GetSystemMetrics
#--------------------------------------------------------------------------
def GetSystemMetrics(index)
@@GetSystemMetrics.call(index)
end
#--------------------------------------------------------------------------
# ● SetWindowPos
#--------------------------------------------------------------------------
def SetWindowPos(hwnd, x, y, width, height, z, flag)
@@SetWindowPos.call(hwnd, z, x, y, width, height, flag) != 0
end
#--------------------------------------------------------------------------
# ● ウィンドウのサイズを取得
#--------------------------------------------------------------------------
def GetGameWindowRect
GetWindowRect(GAME_HANDLE)
end
#--------------------------------------------------------------------------
# ● ウィンドウのクライアントサイズを取得
#--------------------------------------------------------------------------
def GetGameClientRect
GetClientRect(GAME_HANDLE)
end
#--------------------------------------------------------------------------
# ● デスクトップのサイズを取得
#--------------------------------------------------------------------------
def GetDesktopRect
r = [0,0,0,0].pack('l4')
if @@SystemParametersInfo.call(0x30, 0, r, 0) != 0
result = Rect.new(*r.unpack('l4'))
result.width -= result.x
result.height -= result.y
else
result = nil
end
return result
end
#--------------------------------------------------------------------------
# ● 取得视窗大小
#--------------------------------------------------------------------------
def GetFrameSize
return [
GetSystemMetrics(SM_CYCAPTION), # タイトルバー
GetSystemMetrics(SM_CXDLGFRAME), # 左右フレーム
GetSystemMetrics(SM_CYDLGFRAME) # 上下フレーム
]
end
#--------------------------------------------------------------------------
# ● 変更视窗位置
#--------------------------------------------------------------------------
def MoveGameWindow(x, y)
SetWindowPos(GAME_HANDLE, x, y, 0, 0, 0, SWP_NOSIZE|SWP_NOZORDER)
end
#--------------------------------------------------------------------------
# ● 视窗位置到中央
#--------------------------------------------------------------------------
def MoveGameWindowCenter
dr = GetDesktopRect()
wr = GetGameWindowRect()
x = (dr.width - wr.width) / 2
y = (dr.height - wr.height) / 2
SetWindowPos(GAME_HANDLE, x, y, 0, 0, 0, SWP_NOSIZE|SWP_NOZORDER)
end
#--------------------------------------------------------------------------
# ● 変更视窗大小
#--------------------------------------------------------------------------
def SetGameWindowSize(width, height)
# 各领域取得
dr = GetDesktopRect()
wr = GetGameWindowRect()
cr = GetGameClientRect()
return false unless dr && wr && cr
# 取得帧大小
frame = GetFrameSize()
ft = frame[0] + frame[2]
fl = frame[1]
fs = frame[1] * 2
fb = frame[2]
if width <= 0 || height <= 0 || width >= dr.width || height >= dr.height
w = dr.width + fs
h = dr.height + ft + fb
SetWindowPos(GAME_HANDLE, -fl, -ft, w, h, 0, SWP_NOZORDER)
else
w = width + fs
h = height + ft + fb
SetWindowPos(GAME_HANDLE, 0, 0, w, h, 0, SWP_NOMOVE|SWP_NOZORDER)
MoveGameWindowCenter()
end
end
end
class Scene_Base
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
@@screen_mode = 0
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def self.screen_mode=(index)
@@screen_mode = index % WND_SIZE::SIZE_LIST.size
end
#--------------------------------------------------------------------------
# ●
#--------------------------------------------------------------------------
def self.screen_mode
@@screen_mode
end
#--------------------------------------------------------------------------
# ○ 帧更新
#--------------------------------------------------------------------------
alias _cao_update_wndsize update
def update
_cao_update_wndsize
if Input.trigger?(WND_SIZE::INPUT_KEY) && WLIB::GAME_HANDLE != 0
Scene_Base.screen_mode += 1
if WLIB::SetGameWindowSize(*WND_SIZE::SIZE_LIST[@@screen_mode])
if WND_SIZE::FILE_SAVE
save_data(Scene_Base.screen_mode, WND_SIZE::FILE_SAVE)
end
else
Sound.play_buzzer
end
end
end
end
module WND_SIZE
#--------------------------------------------------------------------------
# ● 除去太大的设定
#--------------------------------------------------------------------------
def self.remove_large_window
dr = WLIB::GetDesktopRect()
WND_SIZE::SIZE_LIST.reject! do |wsz|
wsz.size != 2 || dr.width < wsz[0] || dr.height < wsz[1]
end
if WND_SIZE::SIZE_LIST.empty?
WND_SIZE::SIZE_LIST << [Graphics.width, Graphics.height]
end
end
#--------------------------------------------------------------------------
# ● 初期大小设定
#--------------------------------------------------------------------------
def self.init_window_size
if WND_SIZE::FILE_SAVE && File.file?(WND_SIZE::FILE_SAVE)
Scene_Base.screen_mode = load_data(WND_SIZE::FILE_SAVE)
WLIB::SetGameWindowSize(*WND_SIZE::SIZE_LIST[Scene_Base.screen_mode])
end
end
end
WND_SIZE.remove_large_window
WND_SIZE.init_window_size
2014年02月28日 09点02分 1
level 13
tseyik 楼主
VXAce
按F5改変视窗大小,予设四段阶544,414>640,480>800,600>1088,832>全画面
2014年02月28日 14点02分 3
level 12
神马?
2014年03月02日 13点03分 6
level 10
[真棒]不错
2014年03月03日 03点03分 7
level 13
tseyik 楼主

GAME_TITLE = load_data("Data/System.rvdata2").game_title.encode('SHIFT_JIS')
GAME_HANDLE = @@FindWindow.call("RGSS Player", GAME_TITLE)
# GAME_HANDLE = Win32API.new('user32', 'GetForegroundWindow', 'v', 'l').call
改成
GAME_TITLE = load_data("Data/System.rvdata2").game_title.encode('SHIFT_UTH-8')
GAME_HANDLE = @@FindWindow.call("RGSS Player", GAME_TITLE)
GAME_HANDLE = Win32API.new('user32', 'GetForegroundWindow', 'v', 'l').call
2014年07月07日 13点07分 9
(*SHIFT_UTH-8*)応为(*UTF-8*)
2014年10月25日 08点10分
level 2
能显示帧率?
哪能否在屏幕左上角显示年月号,或版本号?
2014年08月01日 08点08分 10
level 13

2014年08月13日 04点08分 11
level 1
你这个东西,在保存退出后再打开就会失效啊
2014年12月17日 14点12分 12
一般不会失效,但有一些例外,这时可在main脚本加入指定大小如WLIB::SetGameWindowSize(1088,832);注:加在SceneManager.run之前一行
2015年04月20日 09点04分
level 8
不行啊,第一个就会显示INPUT_KEY = :F5出错
2015年02月26日 13点02分 13
level 1
你好,这个是直接放进脚本编辑器里么?新建一个脚本,插入到哪都行?
2015年11月10日 04点11分 14
level 11
顶,谢谢楼主
2015年12月27日 14点12分 15
@短却持久 你谁啊你,我看比懂我也可以用,你是不是有毛病
2016年02月11日 10点02分
level 1
得到不少帮助,谢谢楼主
2017年01月20日 09点01分 16
level 11
有没有窗口变大,但是人不要跟着变大的啊[啊]
2017年06月11日 04点06分 17
level 1
按了F5没有反应, 是不是要设置什么? 我就是复制到新脚本,什么都没动
2018年01月29日 12点01分 18
level 1
试着做了一下弹出这个不知道什么问题?
2018年03月05日 17点03分 19
level 1
这个要怎么用啊[咦]
2018年03月14日 09点03分 20
level 1
如果已经封包了的rpg游戏,没有project文件,要如何才能添加脚本呢
2024年02月24日 04点02分 21
同问
2025年06月10日 12点06分
1