-
Notifications
You must be signed in to change notification settings - Fork 44
feat: ✨ options for game version validation #536
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
Merged
KANAjetzt
merged 25 commits into
GodotModding:4.x
from
KANAjetzt:feat_setting-to-disable-version-check-or-use-custom-one
Feb 6, 2025
Merged
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
692652c
feat: :sparkles: option to disable game version validation
KANAjetzt 4a743cb
feat: :sparkles: added custom validation option
KANAjetzt 8a19d72
docs: :memo: added missing doc comments
KANAjetzt 2dc7e5a
refactor: :recycle: use ENUM
KANAjetzt d342385
refactor: :recycle: only pass `ml_options`
KANAjetzt 24f723c
refactor: :recycle: move `customize_script_path` out of export group
KANAjetzt 172e0ff
docs: :memo: added example customize script
KANAjetzt 581684f
style: :pencil2: improved spelling
KANAjetzt 67127e3
docs: :memo: reworked comments
KANAjetzt 666f4c6
refactor: :recycle: `ml_options_path` as param
KANAjetzt 00b9292
refactor: :fire: remove example script
KANAjetzt 013b790
refactor: :recycle: removed example added `@tutorial`
KANAjetzt b97fab7
test: :test_tube: added custom validation test
KANAjetzt c354ae0
fix: :test_tube: fixed test setup
KANAjetzt 0743144
fix: :test_tube: removed editor override
KANAjetzt 9ef663b
fix: :bug: set `customize_script_path` outside of for loop
KANAjetzt df193ca
refactor: :truck: added sub dir
KANAjetzt 8b122c3
test: :test_tube: added test for game version validation disabled
KANAjetzt 52c582a
fix: :test_tube: updated custom script path
KANAjetzt 8d12b7a
test: :test_tube: added `test_game_verion_validation_default`
KANAjetzt b8ef08a
fix: :test_tube: replace white space chars with `""`
KANAjetzt c26a4bf
refactor: :recycle: clean up a bit
KANAjetzt d136db4
test: :test_tube: added no callable set test
KANAjetzt b34413e
Update addons/mod_loader/resources/options_profile.gd
KANAjetzt 7eea1d7
Update addons/mod_loader/resources/options_profile.gd
KANAjetzt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| extends RefCounted | ||
|
|
||
| # This is an example script for the ModLoaderOptionsProfile `customize_script_path`. | ||
| # Ideally, place this script outside the `mod_loader` directory to simplify the update process. | ||
|
|
||
| # This script is loaded after `mod_loader_store.ml_options` has been initialized. | ||
| # It receives `ml_options` as an argument, allowing you to apply settings | ||
| # that cannot be configured through the editor UI. | ||
| func _init(ml_options: ModLoaderOptionsProfile) -> void: | ||
| # Use OS.has_feature() to apply changes only for specific platforms, | ||
| # or create multiple customization scripts and set their paths accordingly in the option profiles. | ||
| if OS.has_feature("Steam"): | ||
| pass | ||
| elif OS.has_feature("Epic"): | ||
| pass | ||
| else: | ||
| # Set `custom_game_version_validation_callable` to use a custom validation function. | ||
| ml_options.custom_game_version_validation_callable = custom_is_game_version_compatible | ||
|
|
||
| # Custom validation function | ||
| # See `ModManifest._is_game_version_compatible()` for the default validation logic. | ||
| func custom_is_game_version_compatible(manifest: ModManifest) -> bool: | ||
| print("! ☞゚ヮ゚)☞ CUSTOM VALIDATION HERE ☜゚ヮ゚☜) !") | ||
|
|
||
| var mod_id := manifest.get_mod_id() | ||
|
|
||
| for version in manifest.compatible_game_version: | ||
| if not version == "pizza": | ||
| # Push a warning message displayed after manifest validation is complete. | ||
| manifest.validation_messages_warning.push_back( | ||
| "The mod \"%s\" may not be compatible with the current game version. | ||
| Enable at your own risk. (Current game version: %s, mod compatible with game versions: %s)" % | ||
| [mod_id, "MyGlobalVars.MyGameVersion", manifest.compatible_game_version] | ||
| ) | ||
| return true | ||
|
|
||
| if not version == "pineapple": | ||
| # Push an error message displayed after manifest validation is complete. | ||
| manifest.validation_messages_error.push_back( | ||
| "The mod \"%s\" is incompatible with the current game version. | ||
| (Current game version: %s, mod compatible with game versions: %s)" % | ||
| [mod_id, "MyGlobalVars.MyGameVersion", manifest.compatible_game_version] | ||
| ) | ||
| return false | ||
|
|
||
| return true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.