Export Tool Manager
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
@tool
|
||||
extends EditorExportPlugin
|
||||
|
||||
# Config par outil
|
||||
var tool_configs := {
|
||||
"game": {
|
||||
"main_scene": "res://main_game.tscn",
|
||||
"output_name": "kalulu"
|
||||
},
|
||||
"prof_tool": {
|
||||
"main_scene": "res://tools/prof_tool/main.tscn",
|
||||
"output_name": "prof_tool"
|
||||
}
|
||||
}
|
||||
|
||||
func _export_begin(features: PackedStringArray, is_debug: bool, path: String, flags: int) -> void:
|
||||
var selected_tool = EditorInterface.get_editor_settings().get_setting("export_tool_manager/current_tool") as String
|
||||
if selected_tool == "" or not tool_configs.has(selected_tool):
|
||||
push_error("Outil '%s' introuvable dans la configuration." % selected_tool)
|
||||
return
|
||||
|
||||
var config = tool_configs[selected_tool]
|
||||
|
||||
# 1. Mettre à jour la scène principale
|
||||
ProjectSettings.set_setting("application/run/main_scene", config["main_scene"])
|
||||
ProjectSettings.save()
|
||||
|
||||
# 2. Déterminer le nouveau nom de fichier
|
||||
var new_path = _get_output_path(path, config["output_name"])
|
||||
call_deferred("_rename_exported_file", path, new_path)
|
||||
|
||||
func _get_output_path(original_path: String, new_name: String) -> String:
|
||||
var dir = original_path.get_base_dir()
|
||||
var ext = original_path.get_extension()
|
||||
var suffix: String = "." + ext
|
||||
return dir.plus_file(new_name + suffix)
|
||||
|
||||
func _rename_exported_file(old_path: String, new_path: String) -> void:
|
||||
if FileAccess.file_exists(old_path):
|
||||
var success = DirAccess.rename_absolute(old_path, new_path)
|
||||
if success == OK:
|
||||
print("✅ Export renommé : ", new_path)
|
||||
else:
|
||||
push_error("❌ Échec du renommage : ", old_path)
|
||||
else:
|
||||
push_error("❌ Fichier exporté introuvable : " + old_path)
|
||||
@@ -0,0 +1 @@
|
||||
uid://df2pwc685ti38
|
||||
@@ -0,0 +1,43 @@
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
const EXPORTER_PATH := "res://addons/export_tool_manager/export_tool_exporter.gd"
|
||||
|
||||
var tool_selector: OptionButton
|
||||
|
||||
func _enter_tree():
|
||||
tool_selector = OptionButton.new()
|
||||
tool_selector.name = "Tool Exporter"
|
||||
tool_selector.add_item("Game")
|
||||
tool_selector.add_item("Prof Tool")
|
||||
tool_selector.connect("item_selected", _on_tool_selected)
|
||||
|
||||
add_control_to_container(EditorPlugin.CONTAINER_TOOLBAR, tool_selector)
|
||||
|
||||
# Accès sécurisé à l'EditorSettings
|
||||
var settings := get_editor_interface().get_editor_settings()
|
||||
var current := settings.get_setting("export_tool_manager/current_tool")
|
||||
|
||||
var current_tool := "game" # Valeur par défaut
|
||||
if typeof(current) == TYPE_STRING:
|
||||
current_tool = current
|
||||
|
||||
# Appliquer la sélection au menu
|
||||
match current_tool:
|
||||
"prof_tool":
|
||||
tool_selector.select(1)
|
||||
"game", _:
|
||||
tool_selector.select(0)
|
||||
|
||||
# Ajout de l’export plugin
|
||||
add_export_plugin(load(EXPORTER_PATH).new())
|
||||
|
||||
func _exit_tree():
|
||||
remove_control_from_container(EditorPlugin.CONTAINER_TOOLBAR, tool_selector)
|
||||
remove_export_plugin(load(EXPORTER_PATH).new())
|
||||
|
||||
func _on_tool_selected(index: int) -> void:
|
||||
var selected_tool := tool_selector.get_item_text(index).to_lower().replace(" ", "_")
|
||||
|
||||
var settings := get_editor_interface().get_editor_settings()
|
||||
settings.set_setting("export_tool_manager/current_tool", selected_tool)
|
||||
@@ -0,0 +1 @@
|
||||
uid://u7anuc32jxs2
|
||||
@@ -0,0 +1,6 @@
|
||||
[plugin]
|
||||
name="Export Tool Manager"
|
||||
description="Permet de changer la scène principale et le nom de l'exécutable selon l'outil choisi"
|
||||
author="Kalulu Dev"
|
||||
version="1.0"
|
||||
script="export_tool_manager_plugin.gd"
|
||||
+2
-2
@@ -74,8 +74,8 @@ application/icon_interpolation=4
|
||||
application/bundle_identifier="com.excellolab.kalulu"
|
||||
application/signature=""
|
||||
application/app_category="Games"
|
||||
application/short_version="1.2"
|
||||
application/version="1.2"
|
||||
application/short_version="1.3"
|
||||
application/version="1.3"
|
||||
application/copyright=""
|
||||
application/copyright_localized={}
|
||||
application/min_macos_version_x86_64="10.12"
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ window/stretch/mode="canvas_items"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
enabled=PackedStringArray("res://addons/godot-form-validator/plugin.cfg", "res://addons/godot-sqlite/plugin.cfg")
|
||||
enabled=PackedStringArray("res://addons/EnvironmentSwitcher/plugin.cfg", "res://addons/export_tool_manager/plugin.cfg", "res://addons/godot-form-validator/plugin.cfg", "res://addons/godot-sqlite/plugin.cfg")
|
||||
|
||||
[file_customization]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user