Skip to content

Commit

Permalink
修复非延迟加载失效问题
Browse files Browse the repository at this point in the history
  • Loading branch information
wingcd committed Nov 8, 2023
1 parent 3fed602 commit 1b7e0aa
Show file tree
Hide file tree
Showing 21 changed files with 49 additions and 23 deletions.
1 change: 1 addition & 0 deletions demo/UIProject/assets/Basics/Demo_Text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,6 @@
<Button title="Get Input"/>
</component>
<text id="n26_rqas" name="n26" xy="476,107" size="172,32" fontSize="22" color="#ffffff" align="center" vAlign="middle" shadowColor="#000000" shadowOffset="3,3" text="Text with shadow"/>
<text id="n27_7kgc" name="n27" xy="817,64" size="139,32" fontSize="22" leading="-10" autoSize="height" singleLine="true" text="单列设置行距"/>
</displayList>
</component>
Binary file modified demo/assets/resources/UI/Basics.bin
Binary file not shown.
1 change: 1 addition & 0 deletions demo/assets/script/demo/MainMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default class MainMenu extends Component {

onLoad() {
dynamicAtlasManager.enabled = false;
fgui.UIConfig.enableDelayLoad = false;
fgui.UIConfig.autoReleaseAssets = true;
fgui.UIPackage.loadPackage("UI/MainMenu", this.onUILoaded.bind(this));
}
Expand Down
4 changes: 2 additions & 2 deletions demo/profiles/v2/packages/scene.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
},
"ecb26ae3-1542-423f-939b-f4a0ffce9f0b": {
"position": {
"x": 716.5115404823684,
"y": 613.4622029472674,
"x": 781.5258275057495,
"y": 422.6916018497954,
"z": 5000
},
"rotation": {
Expand Down
2 changes: 1 addition & 1 deletion demo/profiles/v2/packages/utils.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"__version__": "1.0.0",
"information": {
"timestamp": 1698026369765
"timestamp": 1699415473381
},
"network_connected": true
}
1 change: 1 addition & 0 deletions source/build/GImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class GImage extends GObject {
else if (contentItem.scaleByTile)
this._content.type = Sprite.Type.TILED;
if (!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem);
}
else {
Expand Down
1 change: 1 addition & 0 deletions source/build/GLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ export class GLoader extends GObject {
this.sourceHeight = contentItem.height;
contentItem = contentItem.getHighResolution();
if (!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem, itemURL, dirtyVersion);
}
else {
Expand Down
1 change: 1 addition & 0 deletions source/build/GMovieClip.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export class GMovieClip extends GObject {
this.setSize(this.sourceWidth, this.sourceHeight);
contentItem = contentItem.getHighResolution();
if (!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem);
}
else {
Expand Down
10 changes: 7 additions & 3 deletions source/build/GTextField.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,19 +394,23 @@ export class GTextField extends GObject {
}
}
updateOverflow() {
const uiComp = this._node._uiProps.uiTransformComp;
if (this._autoSize == AutoSizeType.Both)
this._label.overflow = Label.Overflow.NONE;
else if (this._autoSize == AutoSizeType.Height) {
this._label.overflow = Label.Overflow.RESIZE_HEIGHT;
this._node._uiProps.uiTransformComp.width = this._width;
uiComp.width = this._width;
if (this.singleLine) {
this._label.lineHeight = this._fontSize + this._leading;
}
}
else if (this._autoSize == AutoSizeType.Shrink) {
this._label.overflow = Label.Overflow.SHRINK;
this._node._uiProps.uiTransformComp.setContentSize(this._width, this._height);
uiComp.setContentSize(this._width, this._height);
}
else {
this._label.overflow = Label.Overflow.CLAMP;
this._node._uiProps.uiTransformComp.setContentSize(this._width, this._height);
uiComp.setContentSize(this._width, this._height);
}
}
markSizeChanged() {
Expand Down
4 changes: 1 addition & 3 deletions source/build/UIPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,13 @@ export class UIPackage {
let path;
let onProgress;
let onComplete;
let delayLoad = false;
let bundle;
if (args[0] instanceof AssetManager.Bundle) {
bundle = args[0];
path = args[1];
if (args.length > 3) {
onProgress = args[2];
onComplete = args[3];
delayLoad = args[4];
}
else
onComplete = args[2];
Expand All @@ -103,7 +101,7 @@ export class UIPackage {
onComplete === null || onComplete === void 0 ? void 0 : onComplete.call(this, null, p);
return;
}
delayLoad = delayLoad != null ? delayLoad : UIConfig.enableDelayLoad;
const delayLoad = UIConfig.enableDelayLoad;
bundle = bundle || resources;
bundle.load(path, Asset, onProgress, (err, asset) => {
if (err) {
Expand Down
1 change: 1 addition & 0 deletions source/build/tween/GTweener.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export declare class GTweener {
private _elapsedTime;
private _normalizedTime;
constructor();
get elapsedTime(): number;
setDelay(value: number): GTweener;
get delay(): number;
setDuration(value: number): GTweener;
Expand Down
3 changes: 3 additions & 0 deletions source/build/tween/GTweener.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export class GTweener {
this._deltaValue = new TweenValue();
this._reset();
}
get elapsedTime() {
return this._elapsedTime;
}
setDelay(value) {
this._delay = value;
return this;
Expand Down
1 change: 1 addition & 0 deletions source/dist/fairygui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,7 @@ declare module 'fairygui-cc/tween/GTweener' {
_killed: boolean;
_paused: boolean;
constructor();
get elapsedTime(): number;
setDelay(value: number): GTweener;
get delay(): number;
setDuration(value: number): GTweener;
Expand Down
2 changes: 1 addition & 1 deletion source/dist/fairygui.min.mjs

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions source/dist/fairygui.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,9 @@ class GTweener {
this._deltaValue = new TweenValue();
this._reset();
}
get elapsedTime() {
return this._elapsedTime;
}
setDelay(value) {
this._delay = value;
return this;
Expand Down Expand Up @@ -4208,6 +4211,7 @@ class GImage extends GObject {
else if (contentItem.scaleByTile)
this._content.type = Sprite.Type.TILED;
if (!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem);
}
else {
Expand Down Expand Up @@ -4606,6 +4610,7 @@ class GMovieClip extends GObject {
this.setSize(this.sourceWidth, this.sourceHeight);
contentItem = contentItem.getHighResolution();
if (!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem);
}
else {
Expand Down Expand Up @@ -5270,15 +5275,13 @@ class UIPackage {
let path;
let onProgress;
let onComplete;
let delayLoad = false;
let bundle;
if (args[0] instanceof AssetManager.Bundle) {
bundle = args[0];
path = args[1];
if (args.length > 3) {
onProgress = args[2];
onComplete = args[3];
delayLoad = args[4];
}
else
onComplete = args[2];
Expand All @@ -5297,7 +5300,7 @@ class UIPackage {
onComplete === null || onComplete === void 0 ? void 0 : onComplete.call(this, null, p);
return;
}
delayLoad = delayLoad != null ? delayLoad : UIConfig.enableDelayLoad;
const delayLoad = UIConfig.enableDelayLoad;
bundle = bundle || resources;
bundle.load(path, Asset, onProgress, (err, asset) => {
if (err) {
Expand Down Expand Up @@ -6712,19 +6715,23 @@ class GTextField extends GObject {
}
}
updateOverflow() {
const uiComp = this._node._uiProps.uiTransformComp;
if (this._autoSize == AutoSizeType.Both)
this._label.overflow = Label.Overflow.NONE;
else if (this._autoSize == AutoSizeType.Height) {
this._label.overflow = Label.Overflow.RESIZE_HEIGHT;
this._node._uiProps.uiTransformComp.width = this._width;
uiComp.width = this._width;
if (this.singleLine) {
this._label.lineHeight = this._fontSize + this._leading;
}
}
else if (this._autoSize == AutoSizeType.Shrink) {
this._label.overflow = Label.Overflow.SHRINK;
this._node._uiProps.uiTransformComp.setContentSize(this._width, this._height);
uiComp.setContentSize(this._width, this._height);
}
else {
this._label.overflow = Label.Overflow.CLAMP;
this._node._uiProps.uiTransformComp.setContentSize(this._width, this._height);
uiComp.setContentSize(this._width, this._height);
}
}
markSizeChanged() {
Expand Down Expand Up @@ -12762,6 +12769,7 @@ class GLoader extends GObject {
this.sourceHeight = contentItem.height;
contentItem = contentItem.getHighResolution();
if (!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem, itemURL, dirtyVersion);
}
else {
Expand Down
1 change: 1 addition & 0 deletions source/src/GImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class GImage extends GObject {
this._content.type = Sprite.Type.TILED;

if(!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem);
}else{
contentItem.loadAsync().then(()=>{
Expand Down
1 change: 1 addition & 0 deletions source/src/GLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ export class GLoader extends GObject {
contentItem = contentItem.getHighResolution();

if(!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem, itemURL, dirtyVersion);
}else{
contentItem.loadAsync().then(()=>{
Expand Down
1 change: 1 addition & 0 deletions source/src/GMovieClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ export class GMovieClip extends GObject {

contentItem = contentItem.getHighResolution();
if(!UIConfig.enableDelayLoad || contentItem.__loaded && contentItem.decoded) {
contentItem.load();
this.init(contentItem);
}else{
contentItem.loadAsync().then(()=>{
Expand Down
8 changes: 5 additions & 3 deletions source/src/GTextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ export class GTextField extends GObject {

protected updateFontSize() {
let font: any = this._label.font;

if (font instanceof BitmapFont) {
let fntConfig = font.fntConfig;
if (fntConfig.resizable)
Expand All @@ -493,19 +494,20 @@ export class GTextField extends GObject {
}

protected updateOverflow() {
const uiComp = this._node._uiProps.uiTransformComp;
if (this._autoSize == AutoSizeType.Both)
this._label.overflow = Label.Overflow.NONE;
else if (this._autoSize == AutoSizeType.Height) {
this._label.overflow = Label.Overflow.RESIZE_HEIGHT;
this._node._uiProps.uiTransformComp.width = this._width;
uiComp.width = this._width;
}
else if (this._autoSize == AutoSizeType.Shrink) {
this._label.overflow = Label.Overflow.SHRINK;
this._node._uiProps.uiTransformComp.setContentSize(this._width, this._height);
uiComp.setContentSize(this._width, this._height);
}
else {
this._label.overflow = Label.Overflow.CLAMP;
this._node._uiProps.uiTransformComp.setContentSize(this._width, this._height);
uiComp.setContentSize(this._width, this._height);
}
}

Expand Down
5 changes: 1 addition & 4 deletions source/src/UIPackage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,13 @@ export class UIPackage {
let path: string;
let onProgress: (finish: number, total: number, item: AssetManager.RequestItem) => void;
let onComplete: (error: Error, pkg: UIPackage) => void;
let delayLoad: boolean = false;
let bundle: AssetManager.Bundle;
if (args[0] instanceof AssetManager.Bundle) {
bundle = args[0];
path = args[1];
if (args.length > 3) {
onProgress = args[2];
onComplete = args[3];
delayLoad = args[4];
}
else
onComplete = args[2];
Expand All @@ -162,8 +160,7 @@ export class UIPackage {
return;
}

delayLoad = delayLoad != null ? delayLoad : UIConfig.enableDelayLoad;

const delayLoad = UIConfig.enableDelayLoad;
bundle = bundle || resources;
bundle.load(path, Asset, onProgress, (err: Error | null, asset: Asset) => {
if (err) {
Expand Down
4 changes: 4 additions & 0 deletions source/src/tween/GTweener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ export class GTweener {
this._reset();
}

public get elapsedTime() {
return this._elapsedTime;
}

public setDelay(value: number): GTweener {
this._delay = value;
return this;
Expand Down

0 comments on commit 1b7e0aa

Please sign in to comment.