mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-08-24 22:31:30 -04:00
Fix the type of variables added from the drop-down menu (#8725)
This commit is contained in:
@@ -331,20 +331,6 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
|
||||
[updateAutocompletions]
|
||||
);
|
||||
|
||||
const isSwitchableInstruction =
|
||||
instruction &&
|
||||
gd.VariableInstructionSwitcher.isSwitchableVariableInstruction(
|
||||
instruction.getType()
|
||||
);
|
||||
const variableType =
|
||||
project && instruction && isSwitchableInstruction
|
||||
? gd.VariableInstructionSwitcher.getVariableTypeFromParameters(
|
||||
project.getCurrentPlatform(),
|
||||
projectScopedContainersAccessor.get(),
|
||||
instruction
|
||||
)
|
||||
: null;
|
||||
|
||||
const openVariableEditor = React.useCallback(
|
||||
() => {
|
||||
if (!onOpenDialog) {
|
||||
@@ -362,10 +348,16 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
|
||||
shouldCreate:
|
||||
!!fieldCurrentValue &&
|
||||
!isRootVariableDeclared(fieldCurrentValue, variablesContainers),
|
||||
variableType: getVariableTypeName(variableType),
|
||||
variableType: instruction
|
||||
? getVariableTypeName(
|
||||
gd.VariableInstructionSwitcher.getSwitchableInstructionVariableType(
|
||||
instruction.getType()
|
||||
)
|
||||
)
|
||||
: 'number',
|
||||
});
|
||||
},
|
||||
[onChange, onOpenDialog, value, variableType, variablesContainers]
|
||||
[instruction, onChange, onOpenDialog, value, variablesContainers]
|
||||
);
|
||||
|
||||
const openParameterEditor = React.useCallback(
|
||||
@@ -386,7 +378,13 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
|
||||
fieldCurrentValue,
|
||||
variablesContainers
|
||||
),
|
||||
variableType: getVariableTypeName(variableType),
|
||||
variableType: instruction
|
||||
? getVariableTypeName(
|
||||
gd.VariableInstructionSwitcher.getSwitchableInstructionVariableType(
|
||||
instruction.getType()
|
||||
)
|
||||
)
|
||||
: 'number',
|
||||
});
|
||||
},
|
||||
[
|
||||
@@ -394,7 +392,7 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
|
||||
value,
|
||||
onChange,
|
||||
variablesContainers,
|
||||
variableType,
|
||||
instruction,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -465,6 +463,20 @@ export default (React.forwardRef<Props, VariableFieldInterface>(
|
||||
? t`This variable has the same name as an object. Consider renaming one or the other.`
|
||||
: null;
|
||||
|
||||
const isSwitchableInstruction =
|
||||
instruction &&
|
||||
gd.VariableInstructionSwitcher.isSwitchableVariableInstruction(
|
||||
instruction.getType()
|
||||
);
|
||||
const variableType =
|
||||
project && instruction && isSwitchableInstruction
|
||||
? gd.VariableInstructionSwitcher.getVariableTypeFromParameters(
|
||||
project.getCurrentPlatform(),
|
||||
projectScopedContainersAccessor.get(),
|
||||
instruction
|
||||
)
|
||||
: null;
|
||||
|
||||
const needManualTypeSwitcher =
|
||||
isSwitchableInstruction &&
|
||||
variableType !== gd.Variable.Number &&
|
||||
|
||||
Reference in New Issue
Block a user