mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 08:02:39 +08:00
Vendored
+6
-1
@@ -16,7 +16,12 @@ declare module 'pal/screen-adapter' {
|
||||
* Determine whether the game frame exact fits the screen.
|
||||
* Now it only works on Web platform.
|
||||
*/
|
||||
exactFitScreen: boolean,
|
||||
exactFitScreen: boolean;
|
||||
|
||||
/**
|
||||
* Determine whether use headless renderer, which means do not support some screen operations.
|
||||
*/
|
||||
isHeadlessMode: boolean;
|
||||
}
|
||||
|
||||
class ScreenAdapter {
|
||||
|
||||
@@ -42,7 +42,8 @@ class Screen {
|
||||
public init () {
|
||||
const exactFitScreen = settings.querySettings(Settings.Category.SCREEN, 'exactFitScreen') ?? true;
|
||||
const orientation = settings.querySettings(Settings.Category.SCREEN, 'orientation') ?? 'auto';
|
||||
screenAdapter.init({ exactFitScreen, configOrientation: orientation }, () => {
|
||||
const isHeadlessMode = settings.querySettings(Settings.Category.RENDERING, 'renderMode') === 3;
|
||||
screenAdapter.init({ exactFitScreen, configOrientation: orientation, isHeadlessMode }, () => {
|
||||
const director = legacyCC.director;
|
||||
if (!director.root?.pipeline) {
|
||||
warnID(1220);
|
||||
|
||||
@@ -157,6 +157,7 @@ class ScreenAdapter extends EventTarget {
|
||||
private _orientationChangeTimeoutId = -1;
|
||||
private _cachedFrameSize = new Size(0, 0); // cache before enter fullscreen.
|
||||
private _exactFitScreen = false;
|
||||
private _isHeadlessMode = false;
|
||||
private _fn = {} as IScreenFunctionName;
|
||||
// Function mapping for cross browser support
|
||||
private _fnGroup = [
|
||||
@@ -237,6 +238,9 @@ class ScreenAdapter extends EventTarget {
|
||||
}
|
||||
}
|
||||
private get _windowType (): WindowType {
|
||||
if (this._isHeadlessMode) {
|
||||
return WindowType.Unknown;
|
||||
}
|
||||
if (this.isFullScreen) {
|
||||
return WindowType.Fullscreen;
|
||||
}
|
||||
@@ -298,6 +302,7 @@ class ScreenAdapter extends EventTarget {
|
||||
this._cbToUpdateFrameBuffer = cbToRebuildFrameBuffer;
|
||||
this.orientation = orientationMap[options.configOrientation];
|
||||
this._exactFitScreen = options.exactFitScreen;
|
||||
this._isHeadlessMode = options.isHeadlessMode;
|
||||
this._resizeFrame();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user