From f2afc8bb0d27d9dcc6ca568b99e8ea28ae75ed2e Mon Sep 17 00:00:00 2001 From: "Cyril B." <53737317+Cykyrios@users.noreply.github.com> Date: Sat, 27 Sep 2025 21:35:23 +0200 Subject: [PATCH] Make GISModule abstract Also makes _initialize_module() abstract. --- src/modules/gis_module.gd | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/modules/gis_module.gd b/src/modules/gis_module.gd index 449b645..0b26602 100644 --- a/src/modules/gis_module.gd +++ b/src/modules/gis_module.gd @@ -1,4 +1,4 @@ -class_name GISModule +@abstract class_name GISModule extends MarginContainer ## Base class for GIS Hub modules. All modules inherit from it. @@ -94,7 +94,7 @@ var subscribe_to_all_modules := false # Can only be set once. var _module_name := "": set(value): - if not _module_name.is_empty(): + if not _module_name.is_empty() and _module_name != _DEFAULT_MODULE_NAME: return _module_name = value # The module's version, can be fetched or displayed for identification. @@ -109,6 +109,11 @@ var _dependencies: Array[String] = [] func _init() -> void: + set_module_name(_DEFAULT_MODULE_NAME) + set_module_version(0, 1, 0) + var gis_hub_version := GISHub.get_gis_hub_version() + set_gis_hub_version(gis_hub_version["major"] as int, gis_hub_version["minor"] as int) + set_insim_requirements(LocalRemote.LOCAL, 0, -1) _initialize_module() if not _module_name.strip_edges(): _module_name = _DEFAULT_MODULE_NAME @@ -133,22 +138,19 @@ func _initialize_config() -> GISModuleConfig: ## Performs module initialization, which happens in the module's ## [code skip-lint]_init()[/code] function.[br] -## This method must return the module's name, which defaults to [code]GIS Module[/code].[br] -## It also [i]should[/i] set both the module's own version and the minimum compatible -## GIS Hub version, by calling [method set_module_version] and [method set_gis_hub_version]. +## This method is abstract and must be implemented to set the module's name, +## which defaults to [code]GIS Module[/code]. It [i]should[/i] also set both +## the module's own version and the minimum compatible GIS Hub version, by calling +## [method set_module_version] and [method set_gis_hub_version]. ## For instance, you could define your module as follows: ## [codeblock] ## func _initialize_module() -> void: ## set_module_name("My Module") ## set_module_version(1, 2, 3) ## set_gis_hub_version(1, 0) -## +## set_insim_requirements(LocalRemote.LOCAL, 0, -1) ## [/codeblock] -func _initialize_module() -> void: - set_module_name(_DEFAULT_MODULE_NAME) - set_module_version(0, 1, 0) - set_gis_hub_version(1, 0) - set_insim_requirements(LocalRemote.LOCAL, 0, -1) +@abstract func _initialize_module() -> void ## Override to implement configuration loading; the configuration resource is already loaded @@ -861,7 +863,7 @@ func get_module_metadata() -> GISModuleMetadata: ) -## Returns the module's public name, which is the one returned in [method _initialize_module]. +## Returns the module's public name, which is the one set in [method _initialize_module]. func get_module_name() -> String: return _module_name @@ -990,7 +992,7 @@ func set_module_dependencies(dependencies: Array[String]) -> void: ## Sets the module's name. Must be called in [method _initialize_module], ## and is ignored anywhere else. func set_module_name(module_name: String) -> void: - if not _module_name.is_empty(): + if not _module_name.is_empty() and _module_name != _DEFAULT_MODULE_NAME: return _module_name = module_name -- GitLab