Skip to content

Commit 6adda0f

Browse files
author
liply
committed
add window size parameter
1 parent 8404080 commit 6adda0f

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

plugins/Community_Basic.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* @desc The resolution of screen height
1515
* @default 624
1616
*
17+
* @param changeWindowWidthTo
18+
* @desc If set, change window width to this value
19+
*
20+
* @param changeWindowHeightTo
21+
* @desc If set, change window height to this value
22+
*
1723
* @param renderingMode
1824
* @desc The rendering mode (canvas/webgl/auto)
1925
* @default auto
@@ -39,6 +45,12 @@
3945
* @desc 画面サイズの高さ
4046
* @default 624
4147
*
48+
* @param changeWindowWidthTo
49+
* @desc 値が設定された場合、ウインドウの幅を指定した値に変更
50+
*
51+
* @param changeWindowHeightTo
52+
* @desc 値が設定された場合、ウインドウの高さを指定した値に変更
53+
*
4254
* @param renderingMode
4355
* @desc レンダリングモード (canvas/webgl/auto)
4456
* @default auto
@@ -59,6 +71,16 @@
5971
var screenHeight = toNumber(parameters['screenHeight'], 624);
6072
var renderingMode = parameters['renderingMode'].toLowerCase();
6173
var alwaysDash = parameters['alwaysDash'].toLowerCase() === 'on';
74+
var windowWidth = toNumber(parameters['changeWindowWidthTo'], 0);
75+
var windowHeight = toNumber(parameters['changeWindowHeightTo'], 0);
76+
77+
if(screenWidth !== SceneManager._screenWidth && !windowWidth) {
78+
windowWidth = screenWidth;
79+
}
80+
81+
if(screenHeight !== SceneManager._screenHeight && !windowHeight) {
82+
windowHeight = screenHeight;
83+
}
6284

6385
ImageCache.limit = cacheLimit * 1000 * 1000;
6486
SceneManager._screenWidth = screenWidth;
@@ -87,4 +109,17 @@
87109
this.alwaysDash = alwaysDash;
88110
}
89111
};
112+
113+
114+
var _SceneManager_initNwjs = SceneManager.initNwjs;
115+
SceneManager.initNwjs = function() {
116+
_SceneManager_initNwjs.apply(this, arguments);
117+
118+
if (Utils.isNwjs() && windowWidth && windowHeight) {
119+
var dw = windowWidth - window.innerWidth;
120+
var dh = windowHeight - window.innerHeight;
121+
window.moveBy(-dw / 2, -dh / 2);
122+
window.resizeBy(dw, dh);
123+
}
124+
};
90125
})();

0 commit comments

Comments
 (0)