From 392cca545b6f4a3585f69b13bbb92fb538bc424c Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 22 Sep 2020 15:23:13 +0200 Subject: [PATCH] Now modules can be disabled. Also now player ui will automatically call set_player on windows (if the method exists). --- game/player/GUI.gd | 1 - game/scripts/game_modules/DataManager.gd | 5 +++-- game/scripts/game_modules/GameModule.gd | 2 ++ game/ui/character/game_module.tres | 1 + game/ui/player_ui/player_ui.gd | 10 ++++++++++ game/ui/player_ui/player_ui.tscn | 2 +- 6 files changed, 17 insertions(+), 4 deletions(-) diff --git a/game/player/GUI.gd b/game/player/GUI.gd index 2d2f370f..e2d60ad8 100644 --- a/game/player/GUI.gd +++ b/game/player/GUI.gd @@ -28,7 +28,6 @@ func _ready() -> void: if player_path != null: var player = get_node(player_path) - for child_path in child_controls: var child = get_node(child_path) diff --git a/game/scripts/game_modules/DataManager.gd b/game/scripts/game_modules/DataManager.gd index 0f715cf9..ff6f7f7e 100644 --- a/game/scripts/game_modules/DataManager.gd +++ b/game/scripts/game_modules/DataManager.gd @@ -49,8 +49,9 @@ func load_modules_at(path : String) -> void: res = ResourceLoader.load(path + file_name) else: res = ResourceLoader.load(path + "/" + file_name) - - _modules.append(res) + + if res.enabled: + _modules.append(res) file_name = dir.get_next() else: diff --git a/game/scripts/game_modules/GameModule.gd b/game/scripts/game_modules/GameModule.gd index 2453119e..d6b0629e 100644 --- a/game/scripts/game_modules/GameModule.gd +++ b/game/scripts/game_modules/GameModule.gd @@ -1,6 +1,8 @@ extends Resource class_name GameModule +export(bool) var enabled : bool = true + export(ESSResourceDB) var resource_db : ESSResourceDB func load_module(): diff --git a/game/ui/character/game_module.tres b/game/ui/character/game_module.tres index 8ce41600..baa21aa6 100644 --- a/game/ui/character/game_module.tres +++ b/game/ui/character/game_module.tres @@ -6,5 +6,6 @@ [resource] script = ExtResource( 1 ) +enabled = true character_scene = ExtResource( 2 ) opener_button_texture = ExtResource( 3 ) diff --git a/game/ui/player_ui/player_ui.gd b/game/ui/player_ui/player_ui.gd index 87d3fbbb..2f5d99d5 100644 --- a/game/ui/player_ui/player_ui.gd +++ b/game/ui/player_ui/player_ui.gd @@ -20,6 +20,9 @@ extends CanvasLayer # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +export (String) var player_path : String = "../.." + + export(NodePath) var gui_base_path : NodePath export(NodePath) var buttons_path : NodePath export(NodePath) var windows_path : NodePath @@ -33,6 +36,13 @@ var loot_window : Control func _ready(): initialize() + + if player_path != null: + var player = get_node(player_path) + + for c in windows.get_children(): + if c.has_method("set_player"): + c.set_player(player) func initialize(): gui_base = get_node(gui_base_path) diff --git a/game/ui/player_ui/player_ui.tscn b/game/ui/player_ui/player_ui.tscn index f506bf27..102c76a0 100644 --- a/game/ui/player_ui/player_ui.tscn +++ b/game/ui/player_ui/player_ui.tscn @@ -48,7 +48,7 @@ script = ExtResource( 1 ) __meta__ = { "_edit_lock_": true } -child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Windows/SpellBookWindow"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("Windows/Inventory"), NodePath("Windows/LootWindow"), NodePath("Windows/TalentWindow"), NodePath("Windows/CraftingWindow"), NodePath("IngameMenu/KeybindWindow"), NodePath("Windows/CharacterWindow"), NodePath("Windows/TrainerWindow"), NodePath("IngameMenu/InterfaceOptions"), NodePath("Windows/VendorWindow") ] +child_controls = [ NodePath("Unitframes"), NodePath("Actionbars"), NodePath("Buttons"), NodePath("Castbar"), NodePath("AuraFrame"), NodePath("IngameMenu/KeybindWindow"), NodePath("IngameMenu/InterfaceOptions") ] [node name="TouchTargetControls" type="MarginContainer" parent="GUI"] visible = false