fostorial / Legedit2

10 stars 13 forks source link

Refactor the different ElementXXX classes #46

Open bloodwurm opened 4 years ago

bloodwurm commented 4 years ago

For starters, those classes should be responsible for loading their own data (from templates or project file). It complexifies the code for nothing when an external class drives the loading of xml data. Since only each class really knows of its internal data, it should be the one driving the reading/saving of that data.

Furthermore, with the feature of Global Attributes, some classes will need to be adjusted to properly support it. For instance, those classes must call CustomElement::resolveAttributes on the required strings. Furthermore, those classes must continue to save the strings with Attributes tag in them (%TAG%) to file if we want the feature to fully function (until the user sets a custom string that is).

Consider creating a String class which would support some getFormattedString/getRawString API to encompasses some of the common functionalities that would end up being copy/pasted everywhere.

Look at ElementCardName, ElementText and CustomElement for the changes that were required to deal with the described issues.