mirror of
https://github.com/4ian/GDevelop.git
synced 2026-10-12 02:01:17 +00:00
Fix button labels not refreshing when modified from the side panel (#7741)
This commit is contained in:
@@ -508,7 +508,7 @@ module.exports = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
pixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -516,7 +516,7 @@ module.exports = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
pixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
);
|
||||
|
||||
const bbTextStyles = {
|
||||
@@ -555,9 +555,11 @@ module.exports = {
|
||||
gd.ObjectJsImplementation
|
||||
);
|
||||
|
||||
const rawText = this._propertyOverridings.has('Text')
|
||||
? this._propertyOverridings.get('Text')
|
||||
: object.content.text;
|
||||
const propertyOverridings = this.getPropertyOverridings();
|
||||
const rawText =
|
||||
propertyOverridings && propertyOverridings.has('Text')
|
||||
? propertyOverridings.get('Text')
|
||||
: object.content.text;
|
||||
if (rawText !== this._pixiObject.text) {
|
||||
this._pixiObject.text = rawText;
|
||||
}
|
||||
|
||||
@@ -631,7 +631,7 @@ module.exports = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
pixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -639,7 +639,7 @@ module.exports = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
pixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
);
|
||||
|
||||
// We'll track changes of the font to trigger the loading of the new font.
|
||||
@@ -665,9 +665,11 @@ module.exports = {
|
||||
|
||||
// Update the rendered text properties (note: Pixi is only
|
||||
// applying changes if there were changed).
|
||||
this._pixiObject.text = this._propertyOverridings.has('Text')
|
||||
? this._propertyOverridings.get('Text')
|
||||
: object.content.text;
|
||||
const propertyOverridings = this.getPropertyOverridings();
|
||||
this._pixiObject.text =
|
||||
propertyOverridings && propertyOverridings.has('Text')
|
||||
? propertyOverridings.get('Text')
|
||||
: object.content.text;
|
||||
|
||||
const align = object.content.align;
|
||||
this._pixiObject.align = align;
|
||||
|
||||
Vendored
+7
-2
@@ -27,7 +27,7 @@ class RenderedInstance {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>,
|
||||
propertyOverridings: Map<string, string> = new Map<string, string>()
|
||||
getPropertyOverridings: (() => Map<string, string>) | null = null
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -80,6 +80,8 @@ class RenderedInstance {
|
||||
getDefaultHeight(): number;
|
||||
|
||||
getDefaultDepth(): number;
|
||||
|
||||
getPropertyOverridings(): Map<string, string> | null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,7 +109,8 @@ class Rendered3DInstance {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>,
|
||||
getPropertyOverridings: (() => Map<string, string>) | null = null
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -174,6 +177,8 @@ class Rendered3DInstance {
|
||||
* Return the depth of the instance when the instance doesn't have a custom size.
|
||||
*/
|
||||
getDefaultDepth(): number;
|
||||
|
||||
getPropertyOverridings(): Map<string, string> | null;
|
||||
}
|
||||
|
||||
declare type ObjectsRenderingService = {
|
||||
|
||||
@@ -84,7 +84,7 @@ const ObjectsRenderingService = {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group | null,
|
||||
propertyOverridings: Map<string, string> = new Map<string, string>()
|
||||
getPropertyOverridings: (() => Map<string, string>) | null = null
|
||||
): RenderedInstance | Rendered3DInstance {
|
||||
const objectType = associatedObjectConfiguration.getType();
|
||||
if (threeGroup && this.renderers3D.hasOwnProperty(objectType)) {
|
||||
@@ -103,7 +103,7 @@ const ObjectsRenderingService = {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
PixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
);
|
||||
else {
|
||||
if (project.hasEventsBasedObject(objectType)) {
|
||||
@@ -138,7 +138,7 @@ const ObjectsRenderingService = {
|
||||
pixiContainer,
|
||||
threeGroup,
|
||||
PixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ export default class Rendered3DInstance {
|
||||
_threeObject: THREE.Object3D | null;
|
||||
wasUsed: boolean;
|
||||
_wasDestroyed: boolean;
|
||||
_propertyOverridings: Map<string, string>;
|
||||
_getPropertyOverridings: (() => Map<string, string>) | null;
|
||||
|
||||
constructor(
|
||||
project: gdProject,
|
||||
@@ -28,7 +28,7 @@ export default class Rendered3DInstance {
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>,
|
||||
propertyOverridings: Map<string, string> = new Map<string, string>()
|
||||
getPropertyOverridings: (() => Map<string, string>) | null = null
|
||||
) {
|
||||
this._pixiObject = null;
|
||||
this._threeObject = null;
|
||||
@@ -38,7 +38,7 @@ export default class Rendered3DInstance {
|
||||
this._threeGroup = threeGroup;
|
||||
this._project = project;
|
||||
this._pixiResourcesLoader = pixiResourcesLoader;
|
||||
this._propertyOverridings = propertyOverridings;
|
||||
this._getPropertyOverridings = getPropertyOverridings;
|
||||
this.wasUsed = true; //Used by InstancesRenderer to track rendered instance that are not used anymore.
|
||||
this._wasDestroyed = false;
|
||||
}
|
||||
@@ -175,4 +175,8 @@ export default class Rendered3DInstance {
|
||||
getDefaultDepth() {
|
||||
return 32;
|
||||
}
|
||||
|
||||
getPropertyOverridings(): Map<string, string> | null {
|
||||
return this._getPropertyOverridings && this._getPropertyOverridings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
|
||||
pixiContainer: PIXI.Container,
|
||||
threeGroup: THREE.Group,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>,
|
||||
propertyOverridings: Map<string, string>
|
||||
getPropertyOverridings: (() => Map<string, string>) | null = null
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -128,7 +128,7 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
|
||||
pixiContainer,
|
||||
threeGroup,
|
||||
pixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
);
|
||||
|
||||
// Setup the PIXI object:
|
||||
@@ -256,26 +256,31 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
|
||||
this._associatedObjectConfiguration
|
||||
);
|
||||
// Apply property mapping rules on the child instance.
|
||||
const childPropertyOverridings = new Map<string, string>();
|
||||
const customObjectProperties = customObjectConfiguration.getProperties();
|
||||
for (const propertyMappingRule of this._propertyMappingRules) {
|
||||
if (propertyMappingRule.targetChild !== instance.getObjectName()) {
|
||||
continue;
|
||||
const getChildPropertyOverridings = () => {
|
||||
const childPropertyOverridings = new Map<string, string>();
|
||||
|
||||
const propertyOverridings = this.getPropertyOverridings();
|
||||
const customObjectProperties = customObjectConfiguration.getProperties();
|
||||
for (const propertyMappingRule of this._propertyMappingRules) {
|
||||
if (propertyMappingRule.targetChild !== instance.getObjectName()) {
|
||||
continue;
|
||||
}
|
||||
const sourceValue =
|
||||
propertyOverridings &&
|
||||
propertyOverridings.has(propertyMappingRule.sourceProperty)
|
||||
? propertyOverridings.get(propertyMappingRule.sourceProperty)
|
||||
: customObjectProperties
|
||||
.get(propertyMappingRule.sourceProperty)
|
||||
.getValue();
|
||||
if (sourceValue !== undefined) {
|
||||
childPropertyOverridings.set(
|
||||
propertyMappingRule.targetProperty,
|
||||
sourceValue
|
||||
);
|
||||
}
|
||||
}
|
||||
const sourceValue = this._propertyOverridings.has(
|
||||
propertyMappingRule.sourceProperty
|
||||
)
|
||||
? this._propertyOverridings.get(propertyMappingRule.sourceProperty)
|
||||
: customObjectProperties
|
||||
.get(propertyMappingRule.sourceProperty)
|
||||
.getValue();
|
||||
if (sourceValue !== undefined) {
|
||||
childPropertyOverridings.set(
|
||||
propertyMappingRule.targetProperty,
|
||||
sourceValue
|
||||
);
|
||||
}
|
||||
}
|
||||
return childPropertyOverridings;
|
||||
};
|
||||
//...so let's create a renderer.
|
||||
const childObjectConfiguration = this._getChildObjectConfiguration(
|
||||
instance.getObjectName()
|
||||
@@ -287,7 +292,7 @@ export default class RenderedCustomObjectInstance extends Rendered3DInstance
|
||||
childObjectConfiguration,
|
||||
this._pixiObject,
|
||||
this._threeObject,
|
||||
childPropertyOverridings
|
||||
getChildPropertyOverridings
|
||||
)
|
||||
: new RenderedUnknownInstance(
|
||||
this._project,
|
||||
|
||||
@@ -15,7 +15,7 @@ export default class RenderedInstance {
|
||||
_pixiObject: PIXI.DisplayObject;
|
||||
wasUsed: boolean;
|
||||
_wasDestroyed: boolean;
|
||||
_propertyOverridings: Map<string, string>;
|
||||
_getPropertyOverridings: (() => Map<string, string>) | null;
|
||||
|
||||
constructor(
|
||||
project: gdProject,
|
||||
@@ -23,7 +23,7 @@ export default class RenderedInstance {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>,
|
||||
propertyOverridings: Map<string, string> = new Map<string, string>()
|
||||
getPropertyOverridings: (() => Map<string, string>) | null = null
|
||||
) {
|
||||
this._pixiObject = null;
|
||||
this._instance = instance;
|
||||
@@ -31,7 +31,7 @@ export default class RenderedInstance {
|
||||
this._pixiContainer = pixiContainer;
|
||||
this._project = project;
|
||||
this._pixiResourcesLoader = pixiResourcesLoader;
|
||||
this._propertyOverridings = propertyOverridings;
|
||||
this._getPropertyOverridings = getPropertyOverridings;
|
||||
this.wasUsed = true; //Used by InstancesRenderer to track rendered instance that are not used anymore.
|
||||
this._wasDestroyed = false;
|
||||
}
|
||||
@@ -134,4 +134,8 @@ export default class RenderedInstance {
|
||||
getDefaultDepth(): number {
|
||||
return 0;
|
||||
}
|
||||
|
||||
getPropertyOverridings(): Map<string, string> | null {
|
||||
return this._getPropertyOverridings && this._getPropertyOverridings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class RenderedTextInstance extends RenderedInstance {
|
||||
associatedObjectConfiguration: gdObjectConfiguration,
|
||||
pixiContainer: PIXI.Container,
|
||||
pixiResourcesLoader: Class<PixiResourcesLoader>,
|
||||
propertyOverridings: Map<string, string>
|
||||
getPropertyOverridings: (() => Map<string, string>) | null
|
||||
) {
|
||||
super(
|
||||
project,
|
||||
@@ -47,7 +47,7 @@ export default class RenderedTextInstance extends RenderedInstance {
|
||||
associatedObjectConfiguration,
|
||||
pixiContainer,
|
||||
pixiResourcesLoader,
|
||||
propertyOverridings
|
||||
getPropertyOverridings
|
||||
);
|
||||
|
||||
const style = new PIXI.TextStyle({
|
||||
@@ -86,9 +86,11 @@ export default class RenderedTextInstance extends RenderedInstance {
|
||||
const textObjectConfiguration = gd.asTextObjectConfiguration(
|
||||
this._associatedObjectConfiguration
|
||||
);
|
||||
this._pixiObject.text = this._propertyOverridings.has('Text')
|
||||
? this._propertyOverridings.get('Text')
|
||||
: textObjectConfiguration.getText();
|
||||
const propertyOverridings = this.getPropertyOverridings();
|
||||
this._pixiObject.text =
|
||||
propertyOverridings && propertyOverridings.has('Text')
|
||||
? propertyOverridings.get('Text')
|
||||
: textObjectConfiguration.getText();
|
||||
|
||||
//Update style, only if needed to avoid destroying text rendering performances
|
||||
if (
|
||||
|
||||
Reference in New Issue
Block a user