Skip to content

Commit

Permalink
Adjust some files (cocos#12910)
Browse files Browse the repository at this point in the history
`cocos/core` should not depend other modules, so move some files out of `cocos/core`:
- move some files from `cocos/core` to `cocos/game`
  - director.ts
  - splash-screen.ts
  - game.ts
 - move `cocos/core/root.ts` to `cocos/root.ts` as there is not better module to contain `root.ts`.
 - move `cocos/core/platform/view.ts` to `cocos/ui/view.ts` as screen related logic is moved to `cocos/core/platform/screen.ts`
  • Loading branch information
minggo authored Sep 28, 2022
1 parent cf874e6 commit 95a7623
Show file tree
Hide file tree
Showing 104 changed files with 419 additions and 317 deletions.
2 changes: 1 addition & 1 deletion cc.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@
"cocos/scene-graph/scene.ts": "cocos/scene-graph/scene.jsb.ts",
"cocos/scene-graph/scene-globals.ts": "cocos/scene-graph/scene-globals.jsb.ts",
"cocos/scene-graph/index.ts": "cocos/scene-graph/index.jsb.ts",
"cocos/core/root.ts": "cocos/core/root.jsb.ts",
"cocos/root.ts": "cocos/root.jsb.ts",
"cocos/asset/asset-manager/builtin-res-mgr.ts": "cocos/asset/asset-manager/builtin-res-mgr.jsb.ts",
"cocos/asset/assets/index.ts": "cocos/asset/assets/index.jsb.ts",
"cocos/asset/assets/asset.ts": "cocos/asset/assets/asset.jsb.ts",
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/assembler/label/font-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ImageAsset, Texture2D } from '../../../asset/assets';
import { PixelFormat } from '../../../asset/assets/asset-enum';
import { BufferTextureCopy } from '../../../gfx';
import { safeMeasureText, BASELINE_RATIO, MIDDLE_RATIO, getBaselineOffset } from '../../utils/text-utils';
import { director, Director } from '../../../core/director';
import { director, Director } from '../../../game/director';
import { macro, warnID } from '../../../core';

export interface ISharedLabelData {
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/components/graphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { ccclass, help, executionOrder, menu, tooltip, type, visible, override,
import { JSB } from 'internal:constants';
import { builtinResMgr } from '../../asset/asset-manager';
import { InstanceMaterialType, UIRenderer } from '../framework/ui-renderer';
import { director } from '../../core/director';
import { director } from '../../game/director';
import { Color } from '../../core/math';
import { scene } from '../../render-scene';
import { IAssembler } from '../renderer/base';
Expand Down
3 changes: 2 additions & 1 deletion cocos/2d/components/ui-static-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ import { ccclass, help, menu, executionOrder, visible, override } from 'cc.decor
import { UIRenderer } from '../framework/ui-renderer';
import { IBatcher } from '../renderer/i-batcher';
import { DrawBatch2D } from '../renderer/draw-batch';
import { director, Color, warnID } from '../../core';
import { Color, warnID } from '../../core';
import { StaticVBAccessor } from '../renderer/static-vb-accessor';
import { director } from '../../game';

/**
* @en
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/framework/canvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { EDITOR } from 'internal:constants';
import { Camera } from '../../misc/camera-component';
import { Widget } from '../../ui/widget';
import { Vec3 } from '../../core/math';
import { view } from '../../core/platform/view';
import { view } from '../../ui/view';
import { legacyCC } from '../../core/global-exports';
import { Enum } from '../../core/value-types/enum';
import visibleRect from '../../core/platform/visible-rect';
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/framework/sprite-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Color, Vec2 } from '../../core';
import { legacyCC } from '../../core/global-exports';
import { ModelLocalBindings } from '../../rendering/define';
import { Model } from '../../render-scene/scene';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { TransformBit } from '../../scene-graph/node-enum';
import { SpriteFrame } from '../assets/sprite-frame';
import { ModelRenderer } from '../../misc';
Expand Down
3 changes: 2 additions & 1 deletion cocos/2d/framework/ui-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ import { NodeEventType } from '../../scene-graph/node-event';
import { Renderer } from '../../misc/renderer';
import { RenderEntity, RenderEntityType } from '../renderer/render-entity';
import { uiRendererManager } from './ui-renderer-manager';
import { assert, director } from '../../core';
import { assert } from '../../core';
import { RenderDrawInfoType } from '../renderer/render-draw-info';
import { director } from '../../game';

// hack
ccenum(BlendFactor);
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/framework/ui-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EDITOR } from 'internal:constants';
import { Component, Node } from '../../scene-graph';
import { Mat4, Rect, Size, Vec2, Vec3 } from '../../core/math';
import { AABB } from '../../core/geometry';
import { Director, director } from '../../core/director';
import { Director, director } from '../../game/director';
import { warnID } from '../../core/platform/debug';
import { NodeEventType } from '../../scene-graph/node-event';
import visibleRect from '../../core/platform/visible-rect';
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/renderer/batcher-2d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { Texture, Device, Attribute, Sampler, DescriptorSetInfo, Buffer,
BufferInfo, BufferUsageBit, MemoryUsageBit, DescriptorSet, InputAssembler, deviceManager, PrimitiveMode } from '../../gfx';
import { Pool } from '../../core/memop';
import { CachedArray } from '../../core/memop/cached-array';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { Node } from '../../scene-graph';
import { Stage, StencilManager } from './stencil-manager';
import { DrawBatch2D } from './draw-batch';
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/renderer/render-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

import { DEBUG, JSB } from 'internal:constants';
import { director } from '../../core/director';
import { director } from '../../game/director';
import { Material } from '../../asset/assets/material';
import { TextureBase } from '../../asset/assets/texture-base';
import { Color } from '../../core/math';
Expand Down
2 changes: 1 addition & 1 deletion cocos/2d/renderer/static-vb-accessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { assertID, errorID } from '../../core/platform/debug';
import { assertIsTrue } from '../../core/data/utils/asserts';
import { Pool } from '../../core/memop/pool';
import { macro } from '../../core/platform/macro';
import { director } from '../../core';
import { director } from '../../game';

interface IFreeEntry {
offset: number;
Expand Down
3 changes: 2 additions & 1 deletion cocos/2d/utils/dynamic-atlas/atlas-manager.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { EDITOR } from 'internal:constants';
import { director, System } from '../../../core';
import { System } from '../../../core';
import { Filter } from '../../../asset/assets/asset-enum';
import { legacyCC } from '../../../core/global-exports';
import { macro } from '../../../core/platform';
import { js } from '../../../core/utils/js';
import { Atlas } from './atlas';
import { director } from '../../../game';

export class DynamicAtlasManager extends System {
public static instance: DynamicAtlasManager;
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { Mesh } from '../assets/mesh';
import { Vec4 } from '../../core/math';
import { scene } from '../../render-scene';
import { MorphModel } from '../models/morph-model';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { TransformBit } from '../../scene-graph/node-enum';
import { Enum } from '../../core/value-types';
import { builtinResMgr } from '../../asset/asset-manager';
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/lights/directional-light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { Light } from './light-component';
import { scene } from '../../render-scene';
import { legacyCC } from '../../core/global-exports';
import { Camera, PCFType, Shadows, ShadowType, CSMOptimizationMode, CSMLevel } from '../../render-scene/scene';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { property } from '../../core/data/class-decorator';
import { CCBoolean, CCFloat } from '../../core/data/utils/attribute';
import { clamp, warnID } from '../../core';
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/lights/light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { Component } from '../../scene-graph/component';
import { Color, Vec3 } from '../../core/math';
import { Enum } from '../../core/value-types';
import { scene } from '../../render-scene';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { legacyCC } from '../../core/global-exports';

const _color_tmp = new Vec3();
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/lights/sphere-light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { scene } from '../../render-scene';
import { Light, PhotometricTerm } from './light-component';
import { legacyCC } from '../../core/global-exports';
import { Camera } from '../../render-scene/scene';
import { Root } from '../../core/root';
import { Root } from '../../root';

/**
* @en The sphere light component, multiple sphere lights can be added to one scene.
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/lights/spot-light-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { toRadian } from '../../core/math';
import { scene } from '../../render-scene';
import { Light, PhotometricTerm } from './light-component';
import { legacyCC } from '../../core/global-exports';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { Camera, PCFType, ShadowType } from '../../render-scene/scene';
import { property } from '../../core/data/class-decorator';
import { CCBoolean, CCFloat } from '../../core/data/utils/attribute';
Expand Down
2 changes: 1 addition & 1 deletion cocos/3d/models/skinning-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { MorphModel } from './morph-model';
import { deleteTransform, getTransform, getWorldMatrix, IJointTransform } from '../../animation/skeletal-animation-utils';
import { IMacroPatch, BatchingSchemes, Pass } from '../../render-scene';
import { warnID } from '../../core/platform/debug';
import { director } from '../../core';
import { director } from '../../game';
import { PixelFormat } from '../../asset/assets/asset-enum';
import { Texture2D, ImageAsset } from '../../asset/assets';

Expand Down
2 changes: 1 addition & 1 deletion cocos/animation/animation-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { ccclass } from 'cc.decorator';
import System from '../core/system';
import { director, Director } from '../core/director';
import { director, Director } from '../game/director';
import { errorID } from '../core/platform/debug';
import { Node } from '../scene-graph';
import { MutableForwardIterator } from '../core/utils/array';
Expand Down
4 changes: 2 additions & 2 deletions cocos/asset/asset-manager/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

import { BUILD } from 'internal:constants';
import { Asset } from '../assets/asset';
import { director } from '../../core/director';
import { game } from '../../core/game';
import { director } from '../../game/director';
import { game } from '../../game';
import { legacyCC } from '../../core/global-exports';
import { getError } from '../../core/platform/debug';
import { macro } from '../../core/platform/macro';
Expand Down
2 changes: 1 addition & 1 deletion cocos/asset/assets/effect-asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import { ccclass, serializable, editable, editorOnly } from 'cc.decorator';
import { EDITOR } from 'internal:constants';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { BlendState, DepthStencilState, RasterizerState,
DynamicStateFlags, PrimitiveMode, ShaderStageFlags, Type, Uniform, MemoryAccess, Format, deviceManager } from '../../gfx';
import { RenderPassStage } from '../../rendering/define';
Expand Down
2 changes: 1 addition & 1 deletion cocos/asset/assets/render-texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { clamp } from '../../core/math/utils';
import { Texture, ColorAttachment, DepthStencilAttachment, GeneralBarrierInfo, AccessFlagBit, RenderPassInfo, Format, deviceManager } from '../../gfx';
import { legacyCC } from '../../core/global-exports';
import { RenderWindow, IRenderWindowInfo } from '../../render-scene/core/render-window';
import { Root } from '../../core/root';
import { Root } from '../../root';
import { TextureBase } from './texture-base';
import { BufferTextureCopy } from '../../gfx/base/define';
import { errorID } from '../../core/platform/debug';
Expand Down
86 changes: 2 additions & 84 deletions cocos/core/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@
THE SOFTWARE.
*/

import { replaceProperty, removeProperty, markAsWarning } from './utils/x-deprecated';
import { replaceProperty, removeProperty } from './utils/x-deprecated';
import * as math from './math';
import { Scheduler } from './scheduler';
import { legacyCC } from './global-exports';
import { SubModel } from '../render-scene/scene/submodel';
import { Root } from './root';
import { game } from './game';

import System from './system';
import { Director } from './director';

// VMATH

Expand Down Expand Up @@ -241,83 +239,3 @@ removeProperty(SubModel.prototype, 'SubModel.prototype', [
suggest: 'Use `subModels.length` instead',
},
]);

// Root

replaceProperty(Root.prototype, 'Root.prototype', [
{
name: 'ui',
newName: 'batcher2D',
},
]);

// game

markAsWarning(game, 'game', [
{
name: 'collisionMatrix',
},
{
name: 'groupList',
},
]);

// Director

markAsWarning(Director.prototype, 'director', [
{
name: 'calculateDeltaTime',
},
{
name: 'getDeltaTime',
suggest: 'Use game.deltaTime instead',
},
{
name: 'getTotalTime',
suggest: 'Use game.totalTime instead',
},
{
name: 'getCurrentTime',
suggest: 'Use game.frameStartTime instead',
},
]);

removeProperty(Director.prototype, 'director', [
{
name: 'setAnimationInterval',
suggest: 'please use game.frameRate instead',
},
{
name: 'getAnimationInterval',
suggest: 'please use game.frameRate instead',
},
{
name: 'getRunningScene',
suggest: 'please use getScene instead',
},
{
name: 'setDepthTest',
suggest: 'please use camera API instead',
},
{
name: 'setClearColor',
suggest: 'please use camera API instead',
},
{
name: 'getWinSize',
suggest: 'please use view.getVisibleSize instead',
},
{
name: 'getWinSizeInPixels',
},
{
name: 'purgeCachedData',
suggest: 'please use assetManager.releaseAll instead',
},
{
name: 'convertToGL',
},
{
name: 'convertToUI',
},
]);
4 changes: 0 additions & 4 deletions cocos/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import * as easing from './algorithm/easing';
import * as geometry from './geometry';
import * as math from './math';
import * as memop from './memop';
import './splash-screen';
import './deprecated';

legacyCC.math = math;
Expand All @@ -45,10 +44,7 @@ export * from './utils';
export * from './data';
export * from './event';
export * from './platform';
export * from './game';
export { Root } from './root';
export * from './scheduler';
export * from './director';
export * from './algorithm/murmurhash2_gc';
export * from './curves';
export * from './settings';
Expand Down
56 changes: 0 additions & 56 deletions cocos/core/platform/deprecated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,65 +25,9 @@

import { markAsWarning, removeProperty, replaceProperty } from '../utils';
import { sys } from './sys';
import { View } from './view';
import { legacyCC } from '../global-exports';
import { screen } from './screen';

// #region deprecation on view
removeProperty(View.prototype, 'View.prototype', [
{
name: 'isAntiAliasEnabled',
suggest: 'The API of Texture2d have been largely modified, no alternative',
},
{
name: 'enableAntiAlias',
suggest: 'The API of Texture2d have been largely modified, no alternative',
},
]);
markAsWarning(View.prototype, 'View.prototype', [
{
name: 'adjustViewportMeta',
},
{
name: 'enableAutoFullScreen',
suggest: 'use screen.requestFullScreen() instead.',
},
{
name: 'isAutoFullScreenEnabled',
},
{
name: 'setCanvasSize',
suggest: 'setting size in CSS pixels is not recommended, please use screen.windowSize instead.',
},
{
name: 'getCanvasSize',
suggest: 'please use screen.windowSize instead.',
},
{
name: 'getFrameSize',
suggest: 'getting size in CSS pixels is not recommended, please use screen.windowSize instead.',
},
{
name: 'setFrameSize',
suggest: 'setting size in CSS pixels is not recommended, please use screen.windowSize instead.',
},
{
name: 'getDevicePixelRatio',
suggest: 'use screen.devicePixelRatio instead.',
},
{
name: 'convertToLocationInView',
},
{
name: 'enableRetina',
},
{
name: 'isRetinaEnabled',
},
{
name: 'setRealPixelResolution',
},
]);
markAsWarning(legacyCC, 'cc', [
{
name: 'winSize',
Expand Down
Loading

0 comments on commit 95a7623

Please sign in to comment.