Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I rename property in Custom Types Editor, it do not rename changed property on the object in map. #4011

Open
ludek17052 opened this issue Jul 16, 2024 · 4 comments
Labels
bug Broken behavior.

Comments

@ludek17052
Copy link

ludek17052 commented Jul 16, 2024

Describe the bug
When I rename property in Custom Types Editor, it do not rename changed property on the object in map.

To Reproduce
Steps to reproduce the behavior:

  1. Custom Types Editor -> Add Class "MyClass" -> Add Member "MyMember" (string)
  2. Add "MyClass" to any object "MyObject" in Tileset (*.tsx) / Property name = "MMPropName"
  3. Add "MyObject" into map (*.tmx)
  4. Change value of "MyMember" on the object in the map (*.tmx). Value = "MMValue"
  5. Rename "MyMember" to "MyNewMember" in Custom Types Editor
  6. In map we can see "MyNewMember" on the object, but old value (MMValue) is missing and the value is empty. And now we will change value of "MyNewMember" on the object in the map. Value = "MnewMValue"

In map file (*.tmx) is still "MyMember" with value "MMValue":
<property name="MMPropName" type="class" propertytype="MyClass">
<properties>
<property name="MyMember" value="MMValue"/> <--- THIS ROW SHOULD BE REMOVED, because we renamed "MyMember" and paramater with this name no more exists
<property name="MyNewMember" value="MnewMValue"/>
</properties>
</property>

If I will repeat steps 4-5-6 there will be more and more parameters that already not exists.

Expected behavior
In map file (*.tmx) parameter "MyMember" will be renamed to "MyNewMember" and old value will stay there. And old parametr "MyMember" will be removed.

EDIT: And probably : when I remove "MyClass" from the object in Tileset (*.tsx), it should remove "MyClass" from the object in the map (*.tmx) too. Now "MyClass" is still on the object in map even the object in *.tsx no more contains the "MyClass".

Specifications:

  • OS: Windows 10
  • Tiled Version: 1.11.0
@ludek17052 ludek17052 added the bug Broken behavior. label Jul 16, 2024
@bjorn
Copy link
Member

bjorn commented Jul 16, 2024

In map file (*.tmx) parameter "MyMember" will be renamed to "MyNewMember" and old value will stay there. And old parametr "MyMember" will be removed.

I agree this would certainly be nice to do, though the question is how to go about it. The class value is stored as a string/value map and it could be anywhere (ideally part of open file, but it could also be just a script value or a value stored in a file that's not currently loaded).

So to make this work I think we'd need to store the history of class member rename actions along with the class. Then, when loading properties and/or when displaying them in the UI, we can apply these renames as needed.

Of course there should probably also be some way to apply the renames project-wide and possibly to clear the rename history once the user is sure that it is no longer necessary.

THIS ROW SHOULD BE REMOVED, because we renamed "MyMember" and paramater with this name no more exists

Right now, that value is not automatically removed since that would potentially mean a silent loss of data. After renaming a member, you might be able to use search & replace to update existing files to the new name.

@eishiya
Copy link
Contributor

eishiya commented Jul 16, 2024

Of course there should probably also be some way to apply the renames project-wide and possibly to clear the rename history once the user is sure that it is no longer necessary.

This is what I'd like to see. I'd even be happy with the rename history only being saved while the Custom Types Editor is open, and it asking if you want to update all your files when you try to close it. Of course, letting the user decide when to perform this potentially lengthy operation (due to all the file loads required) would be best.

@ludek17052
Copy link
Author

Ok. I understand.
But this property could be visible in Property Toolbar. If object in map have got a property, that do not exists in Tileset object or in Custom Types, the property could be still visible in Property Toolbar. Maybe with color backgroud?
Now the property is "hidden" and can be found only in file. Like a "silent loss of data" this is "silent keeping of data" and it is not ideal too.

@bjorn
Copy link
Member

bjorn commented Jul 17, 2024

If object in map have got a property, that do not exists in Tileset object or in Custom Types, the property could be still visible in Property Toolbar. Maybe with color background? Now the property is "hidden" and can be found only in file. Like a "silent loss of data" this is "silent keeping of data" and it is not ideal too.

Yes, I agree it would be nice to still show this property, possibly in italics or strike-through. It is a little tricky, since at the moment the child properties are added only based on the class but then it depends on the value as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

No branches or pull requests

3 participants