Functional feature for object editing dialog window

This commit is contained in:
Neyl
2025-01-08 11:59:59 +01:00
parent ba65a1bc56
commit 37e43c5f33
8 changed files with 39 additions and 20 deletions

View File

@@ -53,7 +53,8 @@ std::map<gd::String, gd::PropertyDescriptor> CustomConfigurationHelper::GetPrope
if (configurationContent.HasChild(propertyName)) {
if (propertyType == "String" || propertyType == "Choice" ||
propertyType == "Color" || propertyType == "Behavior" ||
propertyType == "Resource" || propertyType == "LeaderboardId") {
propertyType == "Resource" || propertyType == "LeaderboardId" ||
propertyType == "AnimationName") {
newProperty.SetValue(
configurationContent.GetChild(propertyName).GetStringValue());
} else if (propertyType == "Number") {
@@ -89,7 +90,8 @@ bool CustomConfigurationHelper::UpdateProperty(
if (propertyType == "String" || propertyType == "Choice" ||
propertyType == "Color" || propertyType == "Behavior" ||
propertyType == "Resource" || propertyType == "LeaderboardId") {
propertyType == "Resource" || propertyType == "LeaderboardId"
|| propertyType == "AnimationName") {
element.SetStringValue(newValue);
} else if (propertyType == "Number") {
element.SetDoubleValue(newValue.To<double>());

View File

@@ -833,6 +833,7 @@ interface ObjectConfiguration {
void UnserializeFrom([Ref] Project project, [Const, Ref] SerializerElement element);
unsigned long GetAnimationsCount();
[Const, Ref] DOMString GetAnimationName(unsigned long index);
};
interface UniquePtrObjectConfiguration {

View File

@@ -12,6 +12,7 @@ declare class gdObjectConfiguration {
serializeTo(element: gdSerializerElement): void;
unserializeFrom(project: gdProject, element: gdSerializerElement): void;
getAnimationsCount(): number;
getAnimationName(index: number): string;
delete(): void;
ptr: number;
};

View File

@@ -1,4 +1,5 @@
// @flow
import { ProjectScopedContainersAccessor } from '../../InstructionOrExpression/EventsScope';
import { type ResourceManagementProps } from '../../ResourcesList/ResourceSource';
/**

View File

@@ -63,6 +63,7 @@ const BehaviorPropertiesEditor = ({
behavior.getProperties(),
behavior => behavior.getProperties(),
(behavior, name, value) => {
console.log("bbb ", name, value);
behavior.updateProperty(name, value);
},
object,

View File

@@ -950,11 +950,7 @@ export default function EventsBasedBehaviorPropertiesEditor({
)}
/>
)}
{property.getType() === 'AnimationName' && (
<SelectField value = {'value'}
/>
//<SelectOption />
)}
<ResponsiveLineStackLayout noMargin>
<SemiControlledTextField
commitOnBlur

View File

@@ -222,21 +222,40 @@ const createField = (
};
} else if(valueType ==='animationname')
{
function getChoices()
{
if(!object)
{ return [{value:"Object is not valid !", label:"Object is not valid !"}] }
let animationArray = [];
for(let i = 0; i < object.getConfiguration().getAnimationsCount(); i++ )
{
animationArray.push(object.getConfiguration().getAnimationName(i));
}
return animationArray.map(value => ({ value, label: value }));
}
return {
name,
valueType: 'animationname',
valueType: 'string',
getValue: (instance: Instance): string => {
console.log("aaa", getProperties(instance)
.get(name)
.getValue(), name);
return getProperties(instance)
.get(name)
.getValue();
},
setValue: (instance: Instance, newValue: string) => {
console.log(instance, name, newValue);
onUpdateProperty(instance, name, newValue);
},
getLabel,
getDescription,
getChoices,
}
}
else {
console.error(
`A property with type=${valueType} could not be mapped to a field. Ensure that this type is correct and understood by the IDE.`

View File

@@ -128,6 +128,7 @@ const getFieldValue = ({
if (!getValue) return null;
let value = getValue(instances[0]);
console.log("ccc", value);
for (var i = 1; i < instances.length; ++i) {
if (value !== getValue(instances[i])) {
if (typeof defaultValue !== 'undefined') value = defaultValue;
@@ -306,18 +307,8 @@ const PropertiesEditor = ({
style={styles.field}
/>
);
} else if(field.valueType === 'animationname')
{
//TODO: Populate with proper animation names
//TODO: When there is a change, save new values
return(
<SelectField value ="test">
<SelectOption key={"option1"} value="choix 1" label="Premier choix" />
<SelectOption key={"option1"} value="test" label="Deuxième choix" />
</SelectField>
)
}
}
else {
const {
onEditButtonBuildMenuTemplate,
@@ -377,6 +368,7 @@ return(
const renderSelectField = React.useCallback(
(field: ValueField) => {
console.log(field);
if (!field.getChoices || !field.getValue) return;
const choices = field.getChoices();
@@ -414,6 +406,11 @@ return(
);
} else if (field.valueType === 'string') {
const { setValue } = field;
console.log("field value : ", getFieldValue({
instances,
field,
defaultValue: '(Multiple values)',
}));
return (
<SelectField
value={getFieldValue({
@@ -607,6 +604,7 @@ return(
} else if (field.valueType === 'leaderboardId') {
return renderLeaderboardField(field);
} else {
console.log(field);
if (field.getChoices && field.getValue) return renderSelectField(field);
if (field.getValue) return renderInputField(field);
}