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

Enhancement: re-implement StructureUtil #2716

Closed
cyn0x8 opened this issue Jun 9, 2024 · 2 comments
Closed

Enhancement: re-implement StructureUtil #2716

cyn0x8 opened this issue Jun 9, 2024 · 2 comments
Labels
status: resolved The issue has been fixed or the suggestion has been implemented. type: enhancement Involves an enhancement or new feature.

Comments

@cyn0x8
Copy link
Contributor

cyn0x8 commented Jun 9, 2024

Please check for duplicates or similar issues before creating this issue.

What is your suggestion, and why should it be implemented?

StructureUtil was removed in the latest release, leaving no easy way to dynamically merge/deep-merge structures (iirc Reflect is blacklisted in hxc)

i was using it for backwards-compatible save data for a mod im working on... re-implementing this class would be extremely helpful so i dont have to null check a ton of variables lol

or, if anyone knows an alternative, please reply with it !!

@cyn0x8 cyn0x8 added the type: enhancement Involves an enhancement or new feature. label Jun 9, 2024
@EliteMasterEric EliteMasterEric added status: pending triage Awaiting review. and removed type: enhancement Involves an enhancement or new feature. labels Jun 17, 2024
@NotHyper-474
Copy link
Contributor

NotHyper-474 commented Jun 19, 2024

If it's anything of use I found out StructureUtil was originally used in the SaveDataMigrator, but now it's been replaced by thx.Objects and uses its deepCombine function. I wonder if that could be used as a replacement for mods too.

Note: I'm in no way versed in FNF modding lol

@cyn0x8
Copy link
Contributor Author

cyn0x8 commented Jun 25, 2024

If it's anything of use I found out StructureUtil was originally used in the SaveDataMigrator, but now it's been replaced by thx.Objects and uses its deepCombine function. I wonder if that could be used as a replacement for mods too.

Note: I'm in no way versed in FNF modding lol

this works!! i was able to get it working with thx.Objects and thx.Types

// in utils hxc

public function obj_merge(a:Dynamic, b:Dynamic, exclusive:Bool = false):Dynamic {
    var ret:Dynamic = Objects.clone(a);
    
    for (path in obj_paths(exclusive ? a : b)) {
        Objects.setPath(ret, path, Objects.getPath(b, path));
    }
    
    return ret;
}

public function obj_paths(obj:Dynamic):Array<String> {
    var ret:Array<String> = [];
    
    for (key in Objects.fields(obj)) {
        ret.push(key);
        
        var val:Dynamic = Objects.getPath(obj, key);
        if (Types.isAnonymousObject(val)) {
            for (sub_key in obj_paths(val)) {
                ret.push(key + "." + sub_key);
            }
        }
    }
    
    return ret;
}
// in save hxc

save_data = ModuleHandler.getModule("SEVENTEEN_Util").scriptCall("obj_merge", [save_data, Save.instance.modOptions.get("17bucks"), clean_save]);

thoughhhh this essentially is doing what Reflect would be doing... i hope these classes dont get blacklisted either lol

@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 25, 2024
@AbnormalPoof AbnormalPoof added the status: resolved The issue has been fixed or the suggestion has been implemented. label Jan 22, 2025
@github-actions github-actions bot removed the status: pending triage Awaiting review. label Jan 22, 2025
@Hundrec Hundrec added the type: enhancement Involves an enhancement or new feature. label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: resolved The issue has been fixed or the suggestion has been implemented. type: enhancement Involves an enhancement or new feature.
Projects
None yet
Development

No branches or pull requests

5 participants