-
Notifications
You must be signed in to change notification settings - Fork 0
/
windowtools.js
66 lines (55 loc) · 1.92 KB
/
windowtools.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* GDevelop JS Platform
* Copyright 2013-2015 Florian Rival (Florian.Rival@gmail.com). All rights reserved.
* This project is released under the MIT License.
*/
/**
* Tools related to window, for events generated code.
* @namespace gdjs.evtTools
* @class window
* @static
* @private
*/
gdjs.evtTools.window = gdjs.evtTools.window || {};
gdjs.evtTools.window.setMargins = function(runtimeScene, top, right, bottom, left) {
runtimeScene.getGame().setMargins(top, right, bottom, left);
};
gdjs.evtTools.window.setFullScreen = function(runtimeScene, enable, keepAspectRatio) {
runtimeScene.getGame().keepAspectRatio(keepAspectRatio);
runtimeScene.getGame().setFullScreen(enable);
};
gdjs.evtTools.window.setCanvasSize = function(runtimeScene, width, height, changeDefaultSize) {
runtimeScene.getGame().setCanvasSize(width, height);
if ( changeDefaultSize ) {
runtimeScene.getGame().setDefaultWidth(width);
runtimeScene.getGame().setDefaultHeight(height);
}
};
gdjs.evtTools.window.setWindowTitle = function(runtimeScene, title) {
document.title = title;
};
gdjs.evtTools.window.getWindowTitle = function() {
return document.title;
};
gdjs.evtTools.window.getWindowWidth = function() {
return window.innerWidth;
};
gdjs.evtTools.window.getWindowHeight = function() {
return window.innerHeight;
};
gdjs.evtTools.window.getCanvasWidth = function(runtimeScene) {
return runtimeScene.getGame().getCurrentWidth();
};
gdjs.evtTools.window.getCanvasHeight = function(runtimeScene) {
return runtimeScene.getGame().getCurrentHeight();
};
gdjs.evtTools.window.openURL = function(url) {
//Try to detect the environment to use the most adapted
//way of opening an URL.
if (typeof Cocoon !== "undefined" && Cocoon.App && Cocoon.App.openURL ) {
Cocoon.App.openURL(url);
} else {
var target = window.cordova ? "_system" : "_blank";
window.open(url, target);
}
};