Compare commits

...

3 Commits

Author SHA1 Message Date
Davy Hélard
4e35ed3112 Fix "edit children" activation. 2025-07-24 13:29:31 +02:00
Davy Hélard
9fcd2f4d27 Fix flow 2025-07-24 13:10:08 +02:00
Davy Hélard
db66570de1 Add a deprecation message on children configuration overriding 2025-07-24 12:11:04 +02:00
4 changed files with 51 additions and 36 deletions

View File

@@ -60,6 +60,7 @@ import {
isVariantEditable,
duplicateVariant,
deleteVariant,
ChildrenOverridingDepreciationAlert,
} from '../Editors/CustomObjectPropertiesEditor';
import NewVariantDialog from '../Editors/CustomObjectPropertiesEditor/NewVariantDialog';
import useAlertDialog from '../../UI/Alert/useAlertDialog';
@@ -717,6 +718,11 @@ export const CompactObjectPropertiesEditor = ({
</CompactSelectField>
</ColumnStackLayout>
)}
{shouldDisplayEventsBasedObjectChildren &&
customObjectConfiguration &&
!customObjectConfiguration.isForcedToOverrideEventsBasedObjectChildrenConfiguration() && (
<ChildrenOverridingDepreciationAlert />
)}
{customObjectEventsBasedObject &&
customObjectConfiguration &&
shouldDisplayEventsBasedObjectChildren &&

View File

@@ -62,6 +62,7 @@ import {
unserializeFromJSObject,
} from '../../../Utils/Serializer';
import useAlertDialog from '../../../UI/Alert/useAlertDialog';
import { MarkdownText } from '../../../UI/MarkdownText';
const gd: libGDevelop = global.gd;
@@ -69,6 +70,17 @@ const styles = {
icon: { width: 16, height: 16 },
};
export const ChildrenOverridingDepreciationAlert = () => {
return (
<AlertMessage kind="warning">
<MarkdownText
translatableSource={t`Children configurations are deprecated. This [migration documentation](https://wiki.gdevelop.io/gdevelop5/objects/custom-objects-prefab-template/migrate-to-variants/) can help you use variants instead.`}
isStandaloneText
/>
</AlertMessage>
);
};
export const getVariantName = (
eventBasedObject: gdEventsBasedObject | null,
customObjectConfiguration: gdCustomObjectConfiguration
@@ -538,30 +550,7 @@ const CustomObjectPropertiesEditor = (props: Props) => {
customObjectConfiguration.isForcedToOverrideEventsBasedObjectChildrenConfiguration()) &&
(customObjectEventsBasedObject &&
(!customObjectConfiguration.isForcedToOverrideEventsBasedObjectChildrenConfiguration() &&
!customObjectConfiguration.isMarkedAsOverridingEventsBasedObjectChildrenConfiguration() ? (
<Line alignItems="center">
<Column expand noMargin>
<Text size="block-title">Children objects</Text>
</Column>
<Column alignItems="right">
<FlatButton
label={
<Trans>Override children configuration</Trans>
}
onClick={() => {
customObjectConfiguration.setMarkedAsOverridingEventsBasedObjectChildrenConfiguration(
true
);
customObjectConfiguration.clearChildrenConfiguration();
if (onObjectUpdated) {
onObjectUpdated();
}
forceUpdate();
}}
/>
</Column>
</Line>
) : (
!customObjectConfiguration.isMarkedAsOverridingEventsBasedObjectChildrenConfiguration() ? null : (
<>
<Line alignItems="center">
<Column expand noMargin>
@@ -590,6 +579,9 @@ const CustomObjectPropertiesEditor = (props: Props) => {
</Column>
)}
</Line>
{!customObjectConfiguration.isForcedToOverrideEventsBasedObjectChildrenConfiguration() && (
<ChildrenOverridingDepreciationAlert />
)}
{mapFor(
0,
customObjectEventsBasedObject

View File

@@ -20,7 +20,7 @@ import {
import { type ObjectEditorTab } from '../ObjectEditor/ObjectEditorDialog';
import type { ObjectWithContext } from '../ObjectsList/EnumerateObjects';
import { type HTMLDataset } from '../Utils/HTMLDataset';
import { getVariant } from '../ObjectEditor/Editors/CustomObjectPropertiesEditor';
import { isVariantEditable } from '../ObjectEditor/Editors/CustomObjectPropertiesEditor';
const gd: libGDevelop = global.gd;
@@ -313,6 +313,14 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
project.getCurrentPlatform(),
object.getType()
);
const objectExtensionName = gd.PlatformExtension.getExtensionFromFullObjectType(
object.getType()
);
const customObjectExtension = project.hasEventsFunctionsExtensionNamed(
objectExtensionName
)
? project.getEventsFunctionsExtension(objectExtensionName)
: null;
return [
{
label: i18n._(t`Copy`),
@@ -372,11 +380,11 @@ export class ObjectTreeViewItemContent implements TreeViewItemContent {
project.hasEventsBasedObject(object.getType())
? {
label: i18n._(t`Edit children`),
enabled:
getVariant(
project.getEventsBasedObject(object.getType()),
gd.asCustomObjectConfiguration(object.getConfiguration())
).getAssetStoreAssetId() === '',
enabled: isVariantEditable(
gd.asCustomObjectConfiguration(object.getConfiguration()),
project.getEventsBasedObject(object.getType()),
customObjectExtension
),
click: () => {
const customObjectConfiguration = gd.asCustomObjectConfiguration(
object.getConfiguration()

View File

@@ -81,7 +81,7 @@ import { unserializeFromJSObject } from '../Utils/Serializer';
import { ProjectScopedContainersAccessor } from '../InstructionOrExpression/EventsScope';
import { type TileMapTileSelection } from '../InstancesEditor/TileSetVisualizer';
import { extractAsCustomObject } from './CustomObjectExtractor/CustomObjectExtractor';
import { getVariant } from '../ObjectEditor/Editors/CustomObjectPropertiesEditor';
import { isVariantEditable } from '../ObjectEditor/Editors/CustomObjectPropertiesEditor';
const gd: libGDevelop = global.gd;
@@ -1555,6 +1555,15 @@ export default class SceneEditor extends React.Component<Props, State> {
)
: null;
const objectExtensionName = gd.PlatformExtension.getExtensionFromFullObjectType(
object.getType()
);
const customObjectExtension = project.hasEventsFunctionsExtensionNamed(
objectExtensionName
)
? project.getEventsFunctionsExtension(objectExtensionName)
: null;
return [
...this.getContextMenuInstancesWiseItems(i18n),
{ type: 'separator' },
@@ -1582,11 +1591,11 @@ export default class SceneEditor extends React.Component<Props, State> {
object && project.hasEventsBasedObject(object.getType())
? {
label: i18n._(t`Edit children`),
enabled:
getVariant(
project.getEventsBasedObject(object.getType()),
gd.asCustomObjectConfiguration(object.getConfiguration())
).getAssetStoreAssetId() === '',
enabled: isVariantEditable(
gd.asCustomObjectConfiguration(object.getConfiguration()),
project.getEventsBasedObject(object.getType()),
customObjectExtension
),
click: () => {
const customObjectConfiguration = gd.asCustomObjectConfiguration(
object.getConfiguration()