added the game

This commit is contained in:
JHDev2006
2025-09-13 16:30:32 +01:00
parent 5ef689109b
commit 3773bdaf64
3616 changed files with 263702 additions and 0 deletions

View File

@@ -0,0 +1,210 @@
@tool
class_name ModToolsPanel
extends Control
# passed from the EditorPlugin
var mod_tool_store: ModToolStore
var editor_plugin: EditorPlugin: set = set_editor_plugin
var context_actions: FileSystemContextActions
var tab_parent_bottom_panel: PanelContainer
var log_richtext_label: RichTextLabel
var log_dock_button: Button
@onready var mod_tool_store_node: ModToolStore = get_node_or_null("/root/ModToolStore")
@onready var tab_container := $"%TabContainer"
@onready var create_mod := $"%CreateMod"
@onready var select_mod := $"%SelectMod"
@onready var label_output := $"%Output"
@onready var mod_id := $"%ModId"
@onready var manifest_editor := $"%Manifest Editor"
@onready var export_path := $"%ExportPath"
@onready var file_dialog := $"%FileDialog"
@onready var hook_gen: ModToolInterfaceHookGen = %HookGen
@onready var hook_restore: ModToolInterfaceHookRestore = %HookRestore
@onready var button_add_hooks: Button = %AddHooks
@onready var button_restore: Button = %Restore
func _ready() -> void:
tab_parent_bottom_panel = get_parent().get_parent() as PanelContainer
get_log_nodes()
if mod_tool_store:
if mod_tool_store.is_hook_generation_done:
button_add_hooks.hide()
else:
button_restore.hide()
# Load manifest.json file
if _ModLoaderFile.file_exists(mod_tool_store.path_manifest):
manifest_editor.load_manifest()
manifest_editor.update_ui()
else:
# Load template Manifest
var template_manifest_data := _ModLoaderFile.get_json_as_dict("res://addons/mod_tool/templates/minimal/manifest.json")
mod_tool_store.manifest_data = ModManifest.new(template_manifest_data, "")
_update_ui()
func set_editor_plugin(plugin: EditorPlugin) -> void:
editor_plugin = plugin
mod_tool_store.editor_plugin = editor_plugin
mod_tool_store.editor_file_system = EditorInterface.get_resource_filesystem()
mod_tool_store.editor_base_control = EditorInterface.get_base_control()
context_actions = FileSystemContextActions.new(
mod_tool_store,
EditorInterface.get_file_system_dock()
)
func get_log_nodes() -> void:
var editor_log := get_parent().get_child(0)
log_richtext_label = editor_log.get_child(1) as RichTextLabel
if not log_richtext_label:
# on project load it can happen that these nodes don't exist yet, wait for parent
await get_parent().ready
log_richtext_label = editor_log.get_child(1) as RichTextLabel
# The button hbox should be last, but here it is second from last for some reason
var dock_tool_button_bar: HBoxContainer = get_parent().get_child(get_parent().get_child_count() -2)
log_dock_button = dock_tool_button_bar.get_child(0).get_child(0)
# Removes the last error line from the output console as if nothing happened
# used in the json validation since the error is displayed right there and
# it causes a lot of clutter otherwise
func discard_last_console_error() -> void:
# If the console is flooded anyway, ignore
var line_count := log_richtext_label.get_line_count()
if line_count > 1000:
return
# The last line is an empty line, remove the one before that
log_richtext_label.remove_line(line_count -2)
log_richtext_label.add_text("\n")
# If there is an error in the console already, leave the circle on the tool button
# All error lines have a space in the beginnig to separate from the circle image
# Not the safest way to check, but it's the only one it seems
for line in log_richtext_label.text.split("\n"):
if (line as String).begins_with(" "):
return
# If there were no other error lines, remove the icon
# Setting to null will crash the editor occasionally, this does not
if log_dock_button:
log_dock_button.icon = CompressedTexture2D.new()
func show_manifest_editor() -> void:
tab_container.current_tab = 0
func show_config_editor() -> void:
tab_container.current_tab = 1
func _update_ui() -> void:
if not mod_tool_store:
return
mod_id.input_text = mod_tool_store.name_mod_dir
export_path.input_text = mod_tool_store.path_export_dir
func _is_mod_dir_valid() -> bool:
# Check if Mod ID is given
if mod_tool_store.name_mod_dir == '':
ModToolUtils.output_error("Please provide a Mod ID")
return false
# Check if mod dir exists
if not _ModLoaderFile.dir_exists(mod_tool_store.path_mod_dir):
ModToolUtils.output_error("Mod folder %s does not exist" % mod_tool_store.path_mod_dir)
return false
return true
func load_mod(name_mod_dir: String) -> void:
# Set the dir name
mod_tool_store.name_mod_dir = name_mod_dir
# Load Manifest
manifest_editor.load_manifest()
manifest_editor.update_ui()
# TODO: Load Mod Config if existing
ModToolUtils.output_info("Mod \"%s\" loaded." % name_mod_dir)
func _on_export_pressed() -> void:
if _is_mod_dir_valid():
var zipper := ModToolZipBuilder.new()
zipper.build_zip(mod_tool_store)
func _on_clear_output_pressed() -> void:
label_output.clear()
func _on_copy_output_pressed() -> void:
DisplayServer.clipboard_set(label_output.text)
func _on_save_manifest_pressed() -> void:
manifest_editor.save_manifest()
func _on_export_settings_create_new_mod_pressed() -> void:
create_mod.popup_centered()
create_mod.clear_mod_id_input()
func _on_CreateMod_mod_dir_created() -> void:
create_mod.hide()
_update_ui()
manifest_editor.load_manifest()
manifest_editor.update_ui()
func _on_ConnectMod_pressed() -> void:
# Opens a popup that displays the mod directory names in the mods-unpacked directory
select_mod.generate_dir_buttons(ModLoaderMod.get_unpacked_dir())
select_mod.popup_centered()
func _on_SelectMod_dir_selected(dir_path: String) -> void:
var mod_dir_name := dir_path.split("/")[-1]
load_mod(mod_dir_name)
select_mod.hide()
_update_ui()
func _on_ButtonExportPath_pressed() -> void:
file_dialog.current_path = mod_tool_store.path_export_dir
file_dialog.popup_centered()
func _on_FileDialog_dir_selected(dir: String) -> void:
mod_tool_store.path_export_dir = dir
export_path.input_text = dir
file_dialog.hide()
func _on_add_hooks_pressed() -> void:
hook_gen.show()
func _on_restore_pressed() -> void:
hook_restore.show()
func _on_hook_gen_hooks_exist_pressed() -> void:
button_add_hooks.hide()
button_restore.show()

View File

@@ -0,0 +1 @@
uid://ckydauahlpir7

View File

@@ -0,0 +1,242 @@
[gd_scene load_steps=13 format=3 uid="uid://jgayt8758anm"]
[ext_resource type="PackedScene" uid="uid://glui2s46v4x4" path="res://addons/mod_tool/interface/create_mod/create_mod.tscn" id="1"]
[ext_resource type="PackedScene" uid="uid://hpefgw6k5qpq" path="res://addons/mod_tool/interface/manifest_editor/manifest_editor.tscn" id="2"]
[ext_resource type="Script" path="res://addons/mod_tool/interface/panel/tools_panel.gd" id="3"]
[ext_resource type="PackedScene" uid="uid://icwo58h0rdb5" path="res://addons/mod_tool/interface/global/input_string.tscn" id="4"]
[ext_resource type="PackedScene" uid="uid://dyunxqcmy4esi" path="res://addons/mod_tool/interface/global/input_options.tscn" id="6"]
[ext_resource type="PackedScene" uid="uid://du17jjwqtopix" path="res://addons/mod_tool/interface/global/directory_selection/select_directory.tscn" id="7"]
[ext_resource type="PackedScene" path="res://addons/mod_tool/interface/global/input_string_with_button.tscn" id="8"]
[ext_resource type="PackedScene" uid="uid://cpll5clcnemyj" path="res://addons/mod_tool/interface/hook_gen/hook_gen.tscn" id="8_k13cs"]
[ext_resource type="PackedScene" uid="uid://camcc83bvu086" path="res://addons/mod_tool/interface/hook_restore/hook_restore.tscn" id="9_2cgta"]
[sub_resource type="StyleBoxEmpty" id="14"]
[sub_resource type="Shortcut" id="12"]
resource_name = "Copy Selection"
[sub_resource type="Shortcut" id="13"]
resource_name = "Clear Output"
[node name="ModToolsPanel" type="Control"]
custom_minimum_size = Vector2(0, 400)
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("3")
[node name="Panel" type="PanelContainer" parent="."]
layout_mode = 0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -4.0
offset_top = -6.0
offset_right = 4.0
offset_bottom = 4.0
[node name="VSplit" type="VSplitContainer" parent="Panel"]
layout_mode = 2
[node name="TabContainer" type="TabContainer" parent="Panel/VSplit"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
theme_override_styles/panel = SubResource("14")
current_tab = 0
[node name="Manifest Editor" parent="Panel/VSplit/TabContainer" instance=ExtResource("2")]
layout_mode = 2
metadata/_tab_index = 0
[node name="Export" type="PanelContainer" parent="Panel/VSplit"]
layout_mode = 2
[node name="HSplit" type="HSplitContainer" parent="Panel/VSplit/Export"]
layout_mode = 2
theme_override_constants/separation = 10
[node name="Console" type="VBoxContainer" parent="Panel/VSplit/Export/HSplit"]
visible = false
layout_mode = 2
size_flags_horizontal = 3
[node name="HBox" type="HBoxContainer" parent="Panel/VSplit/Export/HSplit/Console"]
layout_mode = 2
[node name="Label" type="Label" parent="Panel/VSplit/Export/HSplit/Console/HBox"]
layout_mode = 2
size_flags_horizontal = 3
text = "Output:"
[node name="CopyOutput" type="Button" parent="Panel/VSplit/Export/HSplit/Console/HBox"]
layout_mode = 2
shortcut = SubResource("12")
text = "Copy"
[node name="ClearOutput" type="Button" parent="Panel/VSplit/Export/HSplit/Console/HBox"]
layout_mode = 2
shortcut = SubResource("13")
text = "Clear"
[node name="Output" type="RichTextLabel" parent="Panel/VSplit/Export/HSplit/Console"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 3
focus_mode = 2
bbcode_enabled = true
scroll_following = true
selection_enabled = true
[node name="Settings" type="HBoxContainer" parent="Panel/VSplit/Export/HSplit"]
custom_minimum_size = Vector2(300, 0)
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.5
[node name="VBox" type="VBoxContainer" parent="Panel/VSplit/Export/HSplit/Settings"]
layout_mode = 2
size_flags_horizontal = 3
theme_override_constants/separation = 5
[node name="Category" type="LineEdit" parent="Panel/VSplit/Export/HSplit/Settings/VBox"]
layout_mode = 2
mouse_filter = 2
mouse_default_cursor_shape = 0
text = "Export"
editable = false
context_menu_enabled = false
virtual_keyboard_enabled = false
shortcut_keys_enabled = false
middle_mouse_paste_enabled = false
[node name="ModId" parent="Panel/VSplit/Export/HSplit/Settings/VBox" instance=ExtResource("4")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "ID of the mod to be exported.
Format: Namespace-ModName
(Often Author-ModName)"
mouse_default_cursor_shape = 16
is_editable = false
input_text = "Test-Test"
is_required = true
label_text = "Mod ID"
editor_icon_name = ""
hint_text = "ID of the mod to be exported.
Format: Namespace-ModName
(Often Author-ModName)"
[node name="ExportType" parent="Panel/VSplit/Export/HSplit/Settings/VBox" instance=ExtResource("6")]
unique_name_in_owner = true
visible = false
layout_mode = 2
is_required = true
key = "export_type"
label_text = "Export Type"
[node name="ExportPath" parent="Panel/VSplit/Export/HSplit/Settings/VBox" instance=ExtResource("8")]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "The directory to which the final mod zip is exported."
mouse_default_cursor_shape = 16
input_text = "C:/Users/Kai/Documents/godot/Brotato/mods/Mods/exports"
is_required = true
key = "path_export_dir"
label_text = "Export Path"
hint_text = "The directory to which the final mod zip is exported."
[node name="Align" type="HBoxContainer" parent="Panel/VSplit/Export/HSplit/Settings/VBox"]
layout_mode = 2
theme_override_constants/separation = 10
alignment = 2
[node name="ExportStatus" type="Label" parent="Panel/VSplit/Export/HSplit/Settings/VBox/Align"]
unique_name_in_owner = true
layout_mode = 2
text = "Export Status OK"
[node name="Export" type="Button" parent="Panel/VSplit/Export/HSplit/Settings/VBox/Align"]
layout_mode = 2
text = "Export Mod"
[node name="VBox" type="VBoxContainer" parent="Panel/VSplit/Export/HSplit"]
custom_minimum_size = Vector2(300, 0)
layout_mode = 2
theme_override_constants/separation = 5
[node name="Category" type="LineEdit" parent="Panel/VSplit/Export/HSplit/VBox"]
layout_mode = 2
mouse_filter = 2
mouse_default_cursor_shape = 0
text = "More Actions"
editable = false
context_menu_enabled = false
virtual_keyboard_enabled = false
shortcut_keys_enabled = false
middle_mouse_paste_enabled = false
[node name="CreateMod" type="Button" parent="Panel/VSplit/Export/HSplit/VBox"]
layout_mode = 2
text = "Create new Mod"
[node name="ConnectMod" type="Button" parent="Panel/VSplit/Export/HSplit/VBox"]
layout_mode = 2
text = "Connect existing Mod"
[node name="AddHooks" type="Button" parent="Panel/VSplit/Export/HSplit/VBox"]
unique_name_in_owner = true
layout_mode = 2
text = "Add Hooks to all Scripts"
[node name="Restore" type="Button" parent="Panel/VSplit/Export/HSplit/VBox"]
unique_name_in_owner = true
layout_mode = 2
text = "Restore non Hooked Scripts"
[node name="CreateMod" parent="." instance=ExtResource("1")]
unique_name_in_owner = true
initial_position = 2
size = Vector2i(400, 300)
visible = false
[node name="SelectMod" parent="." instance=ExtResource("7")]
unique_name_in_owner = true
visible = false
[node name="SelectModTemplate" parent="." instance=ExtResource("7")]
unique_name_in_owner = true
visible = false
[node name="HookGen" parent="." instance=ExtResource("8_k13cs")]
unique_name_in_owner = true
visible = false
[node name="HookRestore" parent="." instance=ExtResource("9_2cgta")]
unique_name_in_owner = true
visible = false
[node name="FileDialog" type="FileDialog" parent="."]
unique_name_in_owner = true
title = "Open a Directory"
initial_position = 1
size = Vector2i(800, 500)
ok_button_text = "Select Current Folder"
file_mode = 2
access = 2
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/Console/HBox/CopyOutput" to="." method="_on_copy_output_pressed"]
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/Console/HBox/ClearOutput" to="." method="_on_clear_output_pressed"]
[connection signal="button_pressed" from="Panel/VSplit/Export/HSplit/Settings/VBox/ExportPath" to="." method="_on_ButtonExportPath_pressed"]
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/Settings/VBox/Align/Export" to="." method="_on_export_pressed"]
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/VBox/CreateMod" to="." method="_on_export_settings_create_new_mod_pressed"]
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/VBox/ConnectMod" to="." method="_on_ConnectMod_pressed"]
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/VBox/AddHooks" to="." method="_on_add_hooks_pressed"]
[connection signal="pressed" from="Panel/VSplit/Export/HSplit/VBox/Restore" to="." method="_on_restore_pressed"]
[connection signal="mod_dir_created" from="CreateMod" to="." method="_on_CreateMod_mod_dir_created"]
[connection signal="dir_selected" from="SelectMod" to="." method="_on_SelectMod_dir_selected"]
[connection signal="hooks_exist_pressed" from="HookGen" to="." method="_on_hook_gen_hooks_exist_pressed"]
[connection signal="dir_selected" from="FileDialog" to="." method="_on_FileDialog_dir_selected"]