mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
data protection (#4650)
This commit is contained in:
@@ -34,7 +34,7 @@ import { ISharedLabelData } from './font-utils';
|
||||
|
||||
// const OUTLINE_SUPPORTED = cc.js.isChildClassOf(LabelOutlineComponent, UIComponent);
|
||||
const Overflow = LabelComponent.Overflow;
|
||||
const WHITE = cc.Color.WHITE;
|
||||
const WHITE = Color.WHITE;
|
||||
const space = 2;
|
||||
const TextAlignment = LabelComponent.HorizontalAlign;
|
||||
const VerticalTextAlignment = LabelComponent.VerticalAlign;
|
||||
|
||||
@@ -195,12 +195,12 @@ export class ButtonComponent extends Component {
|
||||
return this._normalColor;
|
||||
}
|
||||
|
||||
set normalColor (value: Color) {
|
||||
set normalColor (value) {
|
||||
if (this._normalColor === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._normalColor = value;
|
||||
this._normalColor.set(value);
|
||||
this._updateState();
|
||||
}
|
||||
|
||||
@@ -213,12 +213,12 @@ export class ButtonComponent extends Component {
|
||||
return this._pressColor;
|
||||
}
|
||||
|
||||
set pressedColor (value: Color) {
|
||||
set pressedColor (value) {
|
||||
if (this._pressColor === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._pressColor = value;
|
||||
this._pressColor.set(value);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,12 +230,12 @@ export class ButtonComponent extends Component {
|
||||
return this._hoverColor;
|
||||
}
|
||||
|
||||
set hoverColor (value: Color) {
|
||||
set hoverColor (value) {
|
||||
if (this._hoverColor === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._hoverColor = value;
|
||||
this._hoverColor.set(value);
|
||||
}
|
||||
/**
|
||||
* @zh
|
||||
@@ -246,12 +246,12 @@ export class ButtonComponent extends Component {
|
||||
return this._disabledColor;
|
||||
}
|
||||
|
||||
set disabledColor (value: Color) {
|
||||
set disabledColor (value) {
|
||||
if (this._disabledColor === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._disabledColor = value;
|
||||
this._disabledColor.set(value);
|
||||
this._updateState();
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ export class ButtonComponent extends Component {
|
||||
|
||||
this._normalSprite = value;
|
||||
const sprite = this.node.getComponent(SpriteComponent);
|
||||
if (sprite){
|
||||
if (sprite) {
|
||||
sprite.spriteFrame = value;
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ export class ButtonComponent extends Component {
|
||||
}
|
||||
|
||||
const renderComp = target.getComponent(UIRenderComponent);
|
||||
if (!renderComp){
|
||||
if (!renderComp) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -542,11 +542,11 @@ export class ButtonComponent extends Component {
|
||||
this._hovered = false;
|
||||
// Restore button status
|
||||
const target = this._target;
|
||||
if (!target){
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
const renderComp = target.getComponent(UIRenderComponent);
|
||||
if (!renderComp){
|
||||
if (!renderComp) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ export class ButtonComponent extends Component {
|
||||
|
||||
this._pressed = true;
|
||||
this._updateState();
|
||||
if (event){
|
||||
if (event) {
|
||||
event.propagationStopped = true;
|
||||
}
|
||||
}
|
||||
@@ -618,7 +618,7 @@ export class ButtonComponent extends Component {
|
||||
} else {
|
||||
this._time = 0;
|
||||
this._transitionFinished = true;
|
||||
if (this._target){
|
||||
if (this._target) {
|
||||
this._target!.setScale(this._originalScale);
|
||||
}
|
||||
}
|
||||
@@ -700,7 +700,7 @@ export class ButtonComponent extends Component {
|
||||
private _updateColorTransition (state: string) {
|
||||
const color = this[state + 'Color'];
|
||||
const target = this._target;
|
||||
if (!target){
|
||||
if (!target) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -727,7 +727,7 @@ export class ButtonComponent extends Component {
|
||||
}
|
||||
|
||||
private _updateScaleTransition (state: string) {
|
||||
if (!this._interactable){
|
||||
if (!this._interactable) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -746,7 +746,7 @@ export class ButtonComponent extends Component {
|
||||
}
|
||||
|
||||
private _zoomBack () {
|
||||
if (!this._target){
|
||||
if (!this._target) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,15 +200,17 @@ export class CanvasComponent extends Component {
|
||||
|
||||
// this.applySettings();
|
||||
this.alignWithScreen();
|
||||
}
|
||||
|
||||
public onEnable (){
|
||||
cc.director.root.ui.addScreen(this);
|
||||
}
|
||||
|
||||
public onDisable () {
|
||||
cc.director.root.ui.removeScreen(this);
|
||||
}
|
||||
// public onEnable (){
|
||||
|
||||
// }
|
||||
|
||||
// public onDisable () {
|
||||
|
||||
// }
|
||||
|
||||
public onDestroy () {
|
||||
if (this._camera) {
|
||||
@@ -220,7 +222,7 @@ export class CanvasComponent extends Component {
|
||||
}
|
||||
|
||||
cc.view.off('design-resolution-changed', this._thisOnResized);
|
||||
|
||||
cc.director.root.ui.removeScreen(this);
|
||||
// if (CanvasComponent.instance === this) {
|
||||
// CanvasComponent.instance = null;
|
||||
// }
|
||||
|
||||
@@ -244,7 +244,7 @@ export class EditBoxComponent extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
this._fontColor = value;
|
||||
this._fontColor.set(value);
|
||||
if (this._textLabel) {
|
||||
// this._textLabel.node.opacity = this._fontColor.a;
|
||||
const renderComp = this._textLabel.node.getComponent(UIRenderComponent);
|
||||
|
||||
@@ -114,7 +114,8 @@ export class GraphicsComponent extends UIRenderComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.impl.strokeColor = this._strokeColor = new Color(value);
|
||||
this._strokeColor.set(value);
|
||||
this.impl.strokeColor = this._strokeColor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,7 +132,8 @@ export class GraphicsComponent extends UIRenderComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this.impl.fillColor = this._fillColor = new Color(value);
|
||||
this._fillColor.set(value);
|
||||
this.impl.fillColor = this._fillColor;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,8 +154,8 @@ export class GraphicsComponent extends UIRenderComponent {
|
||||
override: true,
|
||||
visible: false,
|
||||
})
|
||||
get color (){
|
||||
return super.color;
|
||||
get color () {
|
||||
return this._color;
|
||||
}
|
||||
|
||||
public static LineJoin = LineJoin;
|
||||
|
||||
@@ -71,7 +71,7 @@ export class LabelOutlineComponent extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
this._color = value;
|
||||
this._color.set(value);
|
||||
this._updateRenderData();
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,12 @@ export class MaskComponent extends UIRenderComponent {
|
||||
}
|
||||
|
||||
set dstBlendFactor (value) {
|
||||
super.dstBlendFactor = value;
|
||||
if (this._dstBlendFactor === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._dstBlendFactor = value;
|
||||
this._updateBlendFunc();
|
||||
}
|
||||
|
||||
@property({
|
||||
@@ -214,7 +219,12 @@ export class MaskComponent extends UIRenderComponent {
|
||||
}
|
||||
|
||||
set srcBlendFactor (value) {
|
||||
super.srcBlendFactor = value;
|
||||
if (this._srcBlendFactor === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._srcBlendFactor = value;
|
||||
this._updateBlendFunc();
|
||||
}
|
||||
|
||||
@property({
|
||||
@@ -222,11 +232,16 @@ export class MaskComponent extends UIRenderComponent {
|
||||
override: true,
|
||||
})
|
||||
get color () {
|
||||
return super.color;
|
||||
return this._color;
|
||||
}
|
||||
|
||||
set color (value){
|
||||
super.color = value;
|
||||
if (this._color === value) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._color.set(value);
|
||||
this.markForUpdateRenderData();
|
||||
}
|
||||
|
||||
public static Type = MaskType;
|
||||
|
||||
@@ -52,16 +52,16 @@ const RichTextChildImageName = 'RICHTEXT_Image_CHILD';
|
||||
*/
|
||||
function debounce (func: Function, wait: number, immediate?: boolean) {
|
||||
let timeout;
|
||||
return function (this: any) {
|
||||
return function (this: any, ...args: any[]) {
|
||||
const context = this;
|
||||
const later = () => {
|
||||
timeout = null;
|
||||
if (!immediate) { func.apply(context, arguments); }
|
||||
if (!immediate) { func.apply(context, args); }
|
||||
};
|
||||
const callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) { func.apply(context, arguments); }
|
||||
if (callNow) { func.apply(context, args); }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
import { Component } from '../../../components';
|
||||
import { ccclass, executionOrder, menu, property } from '../../../core/data/class-decorator';
|
||||
import { clamp01 } from '../../../core/utils';
|
||||
import { Size, Vec2, Vec3 } from '../../../core/value-types';
|
||||
import { Color, Size, Vec2, Vec3 } from '../../../core/value-types';
|
||||
import { ccenum } from '../../../core/value-types/enum';
|
||||
import { vec3 } from '../../../core/vmath';
|
||||
import { Node } from '../../../scene-graph/node';
|
||||
@@ -39,6 +39,7 @@ const ZERO = new Vec3();
|
||||
const _tempPos_1 = new Vec3();
|
||||
const _tempPos_2 = new Vec3();
|
||||
const defaultAnchor = new Vec2();
|
||||
const _tempColor = new Color();
|
||||
|
||||
/**
|
||||
* @zh
|
||||
@@ -320,12 +321,16 @@ export class ScrollBarComponent extends Component {
|
||||
if (this._handle) {
|
||||
let renderComp = this.node.getComponent(SpriteComponent);
|
||||
if (renderComp) {
|
||||
renderComp.color.a = opacity;
|
||||
_tempColor.set(renderComp.color);
|
||||
_tempColor.a = opacity;
|
||||
renderComp.color = _tempColor;
|
||||
}
|
||||
|
||||
renderComp = this._handle.getComponent(SpriteComponent);
|
||||
if (renderComp) {
|
||||
renderComp.color.a = opacity;
|
||||
_tempColor.set(renderComp.color);
|
||||
_tempColor.a = opacity;
|
||||
renderComp.color = _tempColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ export class UIRenderComponent extends UIComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
this._color = value;
|
||||
this._color.set(value);
|
||||
this.markForUpdateRenderData();
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ export class UITransformComponent extends Component {
|
||||
* @zh
|
||||
* 设置节点原始大小,不受该节点是否被缩放或者旋转的影响。
|
||||
*
|
||||
* @typeparam size - 节点内容变换的尺寸或者宽度。
|
||||
* @param size - 节点内容变换的尺寸或者宽度。
|
||||
* @param height - 节点内容未变换的高度。
|
||||
* @example
|
||||
* ```ts
|
||||
@@ -214,7 +214,7 @@ export class UITransformComponent extends Component {
|
||||
* 默认的锚点是(0.5,0.5),因此它开始于节点的中心位置。<br>
|
||||
* 注意:Creator 中的锚点仅用于定位所在的节点,子节点的定位不受影响。
|
||||
*
|
||||
* @typeparam point - 节点锚点或节点 x 轴锚。
|
||||
* @param point - 节点锚点或节点 x 轴锚。
|
||||
* @param y - 节点 y 轴锚。
|
||||
* @example
|
||||
* ```ts
|
||||
@@ -250,8 +250,8 @@ export class UITransformComponent extends Component {
|
||||
* @zh
|
||||
* 当前节点的点击计算。
|
||||
*
|
||||
* @typeparam point - 屏幕点。
|
||||
* @typeparam listener - 事件监听器。
|
||||
* @param point - 屏幕点。
|
||||
* @param listener - 事件监听器。
|
||||
*/
|
||||
public isHit (point: Vec2, listener?: EventListener) {
|
||||
// console.log('click point ' + point.toString());
|
||||
@@ -317,12 +317,12 @@ export class UITransformComponent extends Component {
|
||||
* 将一个 UI 节点世界坐标系下点转换到另一个 UI 节点 (局部) 空间坐标系,这个坐标系以锚点为原点。
|
||||
* 非 UI 节点转换到 UI 节点(局部) 空间坐标系,请走 `cc.pipelineUtils.ConvertWorldToUISpaceAR`。
|
||||
*
|
||||
* @typeparam worldPoint - 世界坐标点。
|
||||
* @typeparam out - 转换后坐标。
|
||||
* @param worldPoint - 世界坐标点。
|
||||
* @param out - 转换后坐标。
|
||||
* @returns - 返回与目标节点的相对位置。
|
||||
* @example
|
||||
* ```ts
|
||||
* var newVec2 = uiTransform.convertToNodeSpaceAR(cc.v2(100, 100));
|
||||
* var newVec2 = uiTransform.convertToNodeSpaceAR(cc.v3(100, 100, 0));
|
||||
* ```
|
||||
*/
|
||||
public convertToNodeSpaceAR (worldPoint: Vec3, out?: Vec3) {
|
||||
@@ -344,7 +344,7 @@ export class UITransformComponent extends Component {
|
||||
* @returns - 返回 UI 世界坐标系。
|
||||
* @example
|
||||
* ```ts
|
||||
* var newVec2 = uiTransform.convertToWorldSpaceAR(cc.v2(100, 100));
|
||||
* var newVec2 = uiTransform.convertToWorldSpaceAR(3(100, 100, 0));
|
||||
* ```
|
||||
*/
|
||||
public convertToWorldSpaceAR (nodePoint: Vec3, out?: Vec3) {
|
||||
|
||||
Reference in New Issue
Block a user