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

feat: ✨ options for game version validation #536

Draft
wants to merge 3 commits into
base: 4.x
Choose a base branch
from

Conversation

KANAjetzt
Copy link
Member

@KANAjetzt KANAjetzt commented Jan 31, 2025

Two new options:

disable_game_version_validation

Simple if check in ModManifest

custom_game_version_validation

This option also requires:

  • custom_game_version_validation_callable
  • customize_script_path

The script at customize_script_path is loaded in ModLoaderStore at the end of _update_ml_options_from_options_resource().
https://github.com/KANAjetzt/godot-mod-loader/blob/541e1d0756fc634bf3de77a11cc9c3074a581e8a/addons/mod_loader/mod_loader_store.gd#L177-L178

The ModLoaderStore instance is passed to this script to allow access during _init().
In this customization script, the custom_game_version_validation_callable can be set.

Example script:

extends RefCounted


func _init(mod_loader_store: ModLoaderStore) -> void:
	mod_loader_store.ml_options.custom_game_version_validation_callable = custom_is_game_version_compatible


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":
		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 false

	return true

@KANAjetzt KANAjetzt added enhancement New feature or request validation Feature to make things safe and predictable 4.x labels Jan 31, 2025
@KANAjetzt KANAjetzt added this to the 4.x - 7.0.0 milestone Jan 31, 2025
@KANAjetzt KANAjetzt self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.x enhancement New feature or request validation Feature to make things safe and predictable
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

1 participant