mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
remove sys related adapter (#8523)
* remove sys adapter in runtime * remove web-adapter README.md * remove sys adapter on minigame
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
require('./sys');
|
||||
require('./Label');
|
||||
require('./Console');
|
||||
require('./AudioPlayer');
|
||||
@@ -1,11 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;
|
||||
const adapter = window.__globalAdapter;
|
||||
const env = adapter.getSystemInfoSync();
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.ALIPAY_MINI_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,2 +1 @@
|
||||
require('./sys');
|
||||
require('./sprite-frame');
|
||||
@@ -1,11 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;
|
||||
const adapter = window.__globalAdapter;
|
||||
const env = adapter.getSystemInfoSync();
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.BAIDU_MINI_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,2 @@
|
||||
require('./sys');
|
||||
require('./Label');
|
||||
require('./ImageAsset');
|
||||
@@ -1,40 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;
|
||||
const adapter = window.__globalAdapter;
|
||||
const env = adapter.getSystemInfoSync();
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
if (env.platform === 'devtools') {
|
||||
let system = env.system.toLowerCase();
|
||||
if (system.indexOf('android') > -1) {
|
||||
this.os = this.OS_ANDROID;
|
||||
}
|
||||
else if (system.indexOf('ios') > -1) {
|
||||
this.os = this.OS_IOS;
|
||||
}
|
||||
}
|
||||
this.platform = this.BYTEDANCE_MINI_GAME;
|
||||
|
||||
// move to common if other platforms support
|
||||
this.getSafeAreaRect = function () {
|
||||
let view = cc.view;
|
||||
let safeArea = adapter.getSafeArea();
|
||||
let screenSize = view.getFrameSize(); // Get leftBottom and rightTop point in UI coordinates
|
||||
let leftBottom = new cc.Vec2(safeArea.left, safeArea.bottom);
|
||||
let rightTop = new cc.Vec2(safeArea.right, safeArea.top); // Returns the real location in view.
|
||||
let relatedPos = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: screenSize.width,
|
||||
height: screenSize.height
|
||||
};
|
||||
view.convertToLocationInView(leftBottom.x, leftBottom.y, relatedPos, leftBottom);
|
||||
view.convertToLocationInView(rightTop.x, rightTop.y, relatedPos, rightTop); // convert view point to design resolution size
|
||||
view._convertPointWithScale(leftBottom);
|
||||
view._convertPointWithScale(rightTop);
|
||||
return cc.rect(leftBottom.x, leftBottom.y, rightTop.x - leftBottom.x, rightTop.y - leftBottom.y);
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
require('./sys');
|
||||
require('./VideoPlayer');
|
||||
require('./pc-adapter');
|
||||
require('./sprite-frame');
|
||||
@@ -1,46 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;
|
||||
const adapter = window.__globalAdapter;
|
||||
const env = adapter.getSystemInfoSync();
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
// TODO: add mac platform
|
||||
if (env.platform === 'windows') {
|
||||
this.isMobile = false;
|
||||
this.os = this.OS_WINDOWS;
|
||||
}
|
||||
else if (env.platform === 'devtools') {
|
||||
let system = env.system.toLowerCase();
|
||||
if (system.indexOf('android') > -1) {
|
||||
this.os = this.OS_ANDROID;
|
||||
}
|
||||
else if (system.indexOf('ios') > -1) {
|
||||
this.os = this.OS_IOS;
|
||||
}
|
||||
}
|
||||
this.platform = this.WECHAT_GAME;
|
||||
|
||||
// move to common if other platforms support
|
||||
this.getSafeAreaRect = function () {
|
||||
let view = cc.view;
|
||||
let safeArea = adapter.getSafeArea();
|
||||
let screenSize = view.getFrameSize(); // Get leftBottom and rightTop point in UI coordinates
|
||||
let leftBottom = new cc.Vec2(safeArea.left, safeArea.bottom);
|
||||
let rightTop = new cc.Vec2(safeArea.right, safeArea.top); // Returns the real location in view.
|
||||
let relatedPos = {
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: screenSize.width,
|
||||
height: screenSize.height,
|
||||
};
|
||||
view.convertToLocationInView(leftBottom.x, leftBottom.y, relatedPos, leftBottom);
|
||||
view.convertToLocationInView(rightTop.x, rightTop.y, relatedPos, rightTop); // convert view point to design resolution size
|
||||
view._convertPointWithScale(leftBottom);
|
||||
view._convertPointWithScale(rightTop);
|
||||
|
||||
return cc.rect(leftBottom.x, leftBottom.y, rightTop.x - leftBottom.x, rightTop.y - leftBottom.y);
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -1,2 +0,0 @@
|
||||
require('./sys');
|
||||
require('./download-ttf');
|
||||
@@ -1,11 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;
|
||||
const adapter = window.__globalAdapter;
|
||||
const env = adapter.getSystemInfoSync();
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.XIAOMI_QUICK_GAME;
|
||||
},
|
||||
});
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
require('./fs-utils');
|
||||
require('./canvas');
|
||||
require('./sys.js');
|
||||
require('./asset-manager.js');
|
||||
require('./EditBox.js');
|
||||
require('./game.js');
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
Object.assign(cc.sys, {
|
||||
__init() {
|
||||
this.isNative = false;
|
||||
this.isBrowser = false;
|
||||
this.isMobile = true;
|
||||
|
||||
let sysInfo = ral.getSystemInfoSync();
|
||||
// TODO: remove __getCurrentLanguage call
|
||||
let language = sysInfo.language || (__getCurrentLanguage && __getCurrentLanguage());
|
||||
this.language = language.substr(0, 2);
|
||||
this.languageCode = language.toLowerCase();
|
||||
var system = sysInfo.system.toLowerCase();
|
||||
var platform = sysInfo.platform.toLowerCase();
|
||||
|
||||
if (platform === "android") {
|
||||
this.os = this.OS_ANDROID;
|
||||
}
|
||||
else if (platform === "ios") {
|
||||
this.os = this.OS_IOS;
|
||||
}
|
||||
|
||||
// Adaptation to Android P
|
||||
if (system === 'android p') {
|
||||
system = 'android p 9.0';
|
||||
}
|
||||
|
||||
var version = /[\d\.]+/.exec(system);
|
||||
this.osVersion = version ? version[0] : system;
|
||||
this.osMainVersion = parseInt(this.osVersion);
|
||||
|
||||
this.browserType = null;
|
||||
this.browserVersion = null;
|
||||
|
||||
var w = sysInfo.screenWidth;
|
||||
var h = sysInfo.screenHeight;
|
||||
var ratio = sysInfo.pixelRatio || 1;
|
||||
this.windowPixelResolution = {
|
||||
width: ratio * w,
|
||||
height: ratio * h
|
||||
};
|
||||
|
||||
this.localStorage = window.localStorage;
|
||||
|
||||
var _supportWebp = false;
|
||||
try {
|
||||
var _canvas = document.createElement("canvas");
|
||||
_supportWebp = _canvas.toDataURL('image/webp').startsWith('data:image/webp');
|
||||
}
|
||||
catch (err) { }
|
||||
|
||||
this.capabilities = {
|
||||
canvas: true,
|
||||
opengl: true,
|
||||
webp: _supportWebp,
|
||||
imageBitmap: false,
|
||||
touches: true,
|
||||
mouse: false,
|
||||
keyboard: false,
|
||||
accelerometer: true,
|
||||
};
|
||||
this.__audioSupport = {
|
||||
ONLY_ONE: false,
|
||||
WEB_AUDIO: false,
|
||||
DELAY_CREATE_CTX: false,
|
||||
format: ['.mp3']
|
||||
};
|
||||
},
|
||||
|
||||
openURL(url) {
|
||||
console.warn("unspport openURL");
|
||||
},
|
||||
|
||||
getBatteryLevel() {
|
||||
const batteryInfo = ral.getBatteryInfoSync();
|
||||
return batteryInfo && batteryInfo.level;
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,4 @@
|
||||
// engine common adapter
|
||||
require('../../../common/engine/index');
|
||||
// engine platform adapter overwirte
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./orientation');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.COCOSPLAY;
|
||||
},
|
||||
});
|
||||
@@ -1,5 +1,4 @@
|
||||
// engine common adapter
|
||||
require('../../../common/engine/index');
|
||||
// engine platform adapter overwirte
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./orientation');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.COCOSPLAY;
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,2 @@
|
||||
require('../../../common/engine/index');
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./orientation');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.HUAWEI_QUICK_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
require('../../../common/engine/index');
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./resize');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.LINKSURE_MINI_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,3 @@
|
||||
require('../../../common/engine/index');
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./VideoPlayer');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.OPPO_MINI_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,2 @@
|
||||
require('../../../common/engine/index');
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./orientation');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.QTT_MINI_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,3 +1,2 @@
|
||||
require('../../../common/engine/index');
|
||||
require('./orientation');
|
||||
require('./sys');
|
||||
require('./orientation');
|
||||
@@ -1,9 +0,0 @@
|
||||
const sys = cc.sys;
|
||||
const originInit = sys.__init;;
|
||||
|
||||
Object.assign(sys, {
|
||||
__init () {
|
||||
originInit.call(this);
|
||||
this.platform = this.VIVO_MINI_GAME;
|
||||
},
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
# Adapter for Web platform
|
||||
included platforms:
|
||||
- web-mobile
|
||||
- web-desktop
|
||||
Reference in New Issue
Block a user