using System.Collections.Generic; using System.IO; using ColdMint.scripts.levelGraphEditor; using ColdMint.scripts.serialization; using ColdMint.scripts.utils; using Godot; using Godot.Collections; using FileAccess = Godot.FileAccess; namespace ColdMint.scripts.loader.uiLoader; /// /// Level graph editor /// 关卡图编辑器 /// public partial class LevelGraphEditorLoader : UiLoaderTemplate { private GraphEdit? _graphEdit; /// /// Button to display the room creation panel. /// 用于展示房间创建面板的按钮。 /// private Button? _showCreateRoomPanelButton; private PackedScene? _roomNodeScene; private Panel? _createOrEditorPanel; private Button? _hideCreateRoomPanelButton; private LineEdit? _roomNameLineEdit; private LineEdit? _roomDescriptionLineEdit; private Button? _createRoomButton; private Button? _returnButton; private string? _defaultRoomName; /// /// Index of the room /// 房间的索引 /// private int _roomIndex = 1; private TextEdit? _roomTemplateCollectionTextEdit; private Label? _roomTemplateTipsLabel; private Button? _showSavePanelButton; private Button? _openExportFolderButton; private HBoxContainer? _hBoxContainer; private Panel? _saveOrLoadPanel; private Button? _cancelButton; private Button? _actionButton; private Label? _saveOrLoadPanelTitleLabel; private LineEdit? _fileNameLineEdit; private Button? _showLoadPanelButton; /// /// Offset to append when a new node is created. /// 创建新节点时追加的偏移量。 /// private Vector2 _positionOffset = new Vector2(100, 100); /// /// Is the press event of an active button saved? /// 活动按钮的按下事件是否为保存? /// private bool _saveMode; public override void InitializeData() { base.InitializeData(); _roomNodeScene = (PackedScene)GD.Load("res://prefab/ui/RoomNode.tscn"); _defaultRoomName = TranslationServer.Translate("default_room_name"); var folder = Config.GetLevelGraphExportDirectory(); if (!Directory.Exists(folder)) { Directory.CreateDirectory(folder); } } public override void InitializeUi() { base.InitializeUi(); _roomTemplateTipsLabel = GetNode