Skip to content

Conversation

@KANAjetzt
Copy link
Member

@KANAjetzt KANAjetzt commented Apr 21, 2023

Move consts from ModLoader to ModLoaderStore

Disclaimer

Not sure if we should do this. Moving const UNPACKED_DIR will break a lot of Brotato Mods because they use this pattern in there mod_main.gd most of the time:
dir = modLoader.UNPACKED_DIR + "Darkly77-ContentLoader/"

And I don't think there is a good way to add a deprecation warning to a const?


  • Moved to ModLoaderStore:
    • MODLOADER_VERSION
    • DEBUG_ENABLE_STORING_FILEPATHS
    • UNPACKED_DIR
    • REQUIRE_CMD_LINE
  • Added get_unpacked_dir() to ModLoaderMod
  • Added get_unpacked_mods_dir_path() to _ModLoaderPath

works towards #153

@KANAjetzt KANAjetzt added refactor / cleanup Improves readability or maintainability breaking Breaking change labels Apr 21, 2023
@KANAjetzt KANAjetzt added this to the v6.0.0 milestone Apr 21, 2023
@KANAjetzt KANAjetzt requested review from a team, Qubus0 and ithinkandicode April 21, 2023 23:52
@KANAjetzt KANAjetzt self-assigned this Apr 21, 2023
@Qubus0
Copy link
Collaborator

Qubus0 commented Apr 22, 2023

found a way to deprecate a const via setget. it has to be made into a var though.

var TEST := "This is a test const" setget ,deprecated_direct_access_const_test

func deprecated_direct_access_const_test():
	ModLoaderDeprecated.deprecated_message("The const TEST was removed, use [proper method] instead")
	return "AAA" # proper method here

it won't work in the same file though unless you access it via self.TEST, since it skips the getter. works everywhere else and that is what we need in this case anyway

func _ready() -> void:
	print(get_node("/root/Main").TEST)

@KANAjetzt
Copy link
Member Author

ty @Qubus0 - for some reason it didn't cross my mind that I can just change the const to a var 😄
I added the deprecation warning 👍

Copy link
Collaborator

@Qubus0 Qubus0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@KANAjetzt KANAjetzt added this pull request to the merge queue Apr 23, 2023
Merged via the queue into GodotModding:development with commit 60d4f3a Apr 23, 2023
@KANAjetzt KANAjetzt deleted the refactor_move_consts branch April 23, 2023 15:08
@Qubus0 Qubus0 mentioned this pull request Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change refactor / cleanup Improves readability or maintainability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants