diff --git a/ColdMint.Traveler.csproj b/ColdMint.Traveler.csproj index 49b333a..dafdfc5 100644 --- a/ColdMint.Traveler.csproj +++ b/ColdMint.Traveler.csproj @@ -7,7 +7,4 @@ ColdMint enable - - - \ No newline at end of file diff --git a/locals/UI.csv b/locals/UI.csv index 27e8618..0f22d2d 100644 --- a/locals/UI.csv +++ b/locals/UI.csv @@ -22,4 +22,7 @@ default_room_name,房间{0},Room{0},部屋{0}です room_template_collection_prompt,房间模板集(每一行被认为是一条房间模板地址。),Room template set (Each row is considered to be one room template address.),お部屋テンプレートセット(各行がお部屋テンプレートアドレスとされています。) error_specifying_room_template_line,位于{0}错误,文件不存在。,"Located at {0} error, file does not exist.",{0}エラーに位置し、ファイルは存在しません。 line_errors_must_start_with_res,位于{0}错误,必须以res://开头。,"Located at {0} error, must start with res://.",{0}エラーに位置し、res://で始めなければなりません。 -display_current_page_data,显示当前页面数据,Displays the current page data,現在のページデータを表示します \ No newline at end of file +open_the_export_directory,打开导出目录,Open the export directory,エクスポートディレクトリを開きます +save,保存,Save,保留 +filename,文件名,File name,ファイル名 +cancel,取消,Cancel,キャンセル \ No newline at end of file diff --git a/locals/UI.en.translation b/locals/UI.en.translation index 63f638f..7add425 100644 Binary files a/locals/UI.en.translation and b/locals/UI.en.translation differ diff --git a/locals/UI.jp.translation b/locals/UI.jp.translation index 4582fc9..b887b84 100644 Binary files a/locals/UI.jp.translation and b/locals/UI.jp.translation differ diff --git a/locals/UI.zh.translation b/locals/UI.zh.translation index e18f24e..b5dd9ce 100644 Binary files a/locals/UI.zh.translation and b/locals/UI.zh.translation differ diff --git a/scenes/LevelGraphEditor.tscn b/scenes/LevelGraphEditor.tscn index 544e7cb..70a343e 100644 --- a/scenes/LevelGraphEditor.tscn +++ b/scenes/LevelGraphEditor.tscn @@ -152,9 +152,13 @@ offset_right = -15.0 offset_bottom = 47.0 grow_horizontal = 0 -[node name="DisplayCurrentPageData" type="Button" parent="HBoxContainer"] +[node name="OpenExportFolderButton" type="Button" parent="HBoxContainer"] layout_mode = 2 -text = "display_current_page_data" +text = "open_the_export_directory" + +[node name="SaveButton" type="Button" parent="HBoxContainer"] +layout_mode = 2 +text = "save" [node name="ShowCreateRoomPanelButton" type="Button" parent="HBoxContainer"] layout_mode = 2 @@ -163,3 +167,75 @@ text = "create_room" [node name="ReturnButton" type="Button" parent="HBoxContainer"] layout_mode = 2 text = "close" + +[node name="SaveOrloadPanel" type="Panel" parent="."] +visible = false +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = 232.0 +offset_top = 202.0 +offset_right = -121.0 +offset_bottom = -155.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label" type="Label" parent="SaveOrloadPanel"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -18.5 +offset_top = 15.0 +offset_right = 21.5 +offset_bottom = 40.0 +grow_horizontal = 2 +text = "save" + +[node name="LineEdit" type="LineEdit" parent="SaveOrloadPanel"] +layout_mode = 1 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_left = 18.0 +offset_top = -5.0 +offset_right = -18.0 +offset_bottom = 28.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Label2" type="Label" parent="SaveOrloadPanel"] +layout_mode = 1 +anchors_preset = 4 +anchor_top = 0.5 +anchor_bottom = 0.5 +offset_left = 20.0 +offset_top = -38.0 +offset_right = 80.0 +offset_bottom = -13.0 +grow_vertical = 2 +text = "filename" + +[node name="HBoxContainer" type="HBoxContainer" parent="SaveOrloadPanel"] +layout_mode = 1 +anchors_preset = 3 +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_left = -117.0 +offset_top = -50.0 +offset_right = -19.0 +offset_bottom = -10.0 +grow_horizontal = 0 +grow_vertical = 0 + +[node name="CancelButton" type="Button" parent="SaveOrloadPanel/HBoxContainer"] +layout_mode = 2 +text = "cancel" + +[node name="ActionButton" type="Button" parent="SaveOrloadPanel/HBoxContainer"] +layout_mode = 2 +text = "save" diff --git a/scripts/Config.cs b/scripts/Config.cs index c5d343e..81fac7f 100644 --- a/scripts/Config.cs +++ b/scripts/Config.cs @@ -79,13 +79,13 @@ public static class Config /// 单个物品栏最大堆叠的物品数量 /// public const int MaxStackQuantity = 99; - + /// /// Operation prompts, function key text color /// 操作提示内,功能键文本颜色 /// public const string OperationTipActionColor = "#2b8a3e"; - + /// /// Company/Creator name @@ -133,6 +133,85 @@ public static class Config return OS.HasFeature("debug"); } + public enum OsEnum + { + //unknown + //未知 + Unknown, + + //Runs on Android (non-web browser) + //在 Android 上运行(非 Web 浏览器) + Android, + + //Runs on Linux (non-web browser) + //在 Linux 上运行(非 Web 浏览器) + Linux, + + //Runs on macOS (non-Web browser) + //在 macOS 上运行(非 Web 浏览器) + Macos, + + //Runs on iOS (non-Web browser) + //在 iOS 上运行(非 Web 浏览器) + Ios, + + //Runs on Windows + //在 Windows 上运行 + Windows, + + //The host operating system is a web browser + //宿主操作系统是网页浏览器 + Web, + + //Editor + //编辑器 + // Editor + } + + /// + /// Get what platform is currently running on + /// 获取当前在什么平台上运行 + /// + /// + public static OsEnum GetOs() + { + // if (OS.HasFeature("editor")) + // { + // return OsEnum.Editor; + // } + + if (OS.HasFeature("windows")) + { + return OsEnum.Windows; + } + + if (OS.HasFeature("android")) + { + return OsEnum.Android; + } + + if (OS.HasFeature("linux")) + { + return OsEnum.Linux; + } + + if (OS.HasFeature("web")) + { + return OsEnum.Web; + } + + if (OS.HasFeature("macos")) + { + return OsEnum.Macos; + } + + if (OS.HasFeature("ios")) + { + return OsEnum.Ios; + } + return OsEnum.Unknown; + } + public static string GetVersion() { var stringBuilder = new StringBuilder(); @@ -162,6 +241,17 @@ public static class Config } } + + /// + /// Get the export directory for the level graph + /// 获取关卡图的导出目录 + /// + /// + public static string GetLevelGraphExportDirectory() + { + return Path.Join(GetGameDataDirectory(), "LevelGraphs"); + } + /// /// The initial year of creating this game /// 创建此游戏的初始年份 @@ -215,11 +305,6 @@ public static class Config /// public const int HorizontalSpeedOfDamageNumbers = 3; - /// - /// The file name of the packet's manifest - /// 数据包的清单文件名 - /// - public const string DataPackManifestName = "DataPackManifest.json"; /// /// VerticalVelocityOfDamageNumbers diff --git a/scripts/levelGraphEditor/ConnectionData.cs b/scripts/levelGraphEditor/ConnectionData.cs index b256880..7d56c11 100644 --- a/scripts/levelGraphEditor/ConnectionData.cs +++ b/scripts/levelGraphEditor/ConnectionData.cs @@ -2,8 +2,8 @@ public class ConnectionData { - public IRoomNodeData? From { get; set; } - public IRoomNodeData? To { get; set; } + public string? FromId { get; set; } + public string? ToId { get; set; } public int FromPort { get; set; } public int ToPort { get; set; } } \ No newline at end of file diff --git a/scripts/levelGraphEditor/IRoomNodeData.cs b/scripts/levelGraphEditor/IRoomNodeData.cs index e20acff..495f822 100644 --- a/scripts/levelGraphEditor/IRoomNodeData.cs +++ b/scripts/levelGraphEditor/IRoomNodeData.cs @@ -2,12 +2,14 @@ public interface IRoomNodeData { + string Id { get; set; } + /// /// Title /// 标题 /// string Title { get; set; } - + /// /// 描述 /// Description diff --git a/scripts/levelGraphEditor/LevelGraphEditorSaveData.cs b/scripts/levelGraphEditor/LevelGraphEditorSaveData.cs index 74c98cc..566ae3c 100644 --- a/scripts/levelGraphEditor/LevelGraphEditorSaveData.cs +++ b/scripts/levelGraphEditor/LevelGraphEditorSaveData.cs @@ -8,5 +8,7 @@ namespace ColdMint.scripts.levelGraphEditor; /// public class LevelGraphEditorSaveData { - public List? ConnectionData { get; set; } + public List? ConnectionDataList { get; set; } + + public List? RoomNodeDataList { get; set; } } \ No newline at end of file diff --git a/scripts/levelGraphEditor/RoomNodeData.cs b/scripts/levelGraphEditor/RoomNodeData.cs index 80ff294..ef29d74 100644 --- a/scripts/levelGraphEditor/RoomNodeData.cs +++ b/scripts/levelGraphEditor/RoomNodeData.cs @@ -2,6 +2,7 @@ public class RoomNodeData : IRoomNodeData { + public string Id { get; set; } public string Title { get; set; } public string Description { get; set; } } \ No newline at end of file diff --git a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs index e09b8c4..cb9f015 100644 --- a/scripts/loader/uiLoader/LevelGraphEditorLoader.cs +++ b/scripts/loader/uiLoader/LevelGraphEditorLoader.cs @@ -1,11 +1,12 @@ using System.Collections.Generic; -using System.Text.Json; -using ColdMint.scripts.debug; +using System.Diagnostics; +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; @@ -34,13 +35,20 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate private int _roomIndex = 1; private TextEdit? _roomTemplateCollectionTextEdit; private Label? _roomTemplateTipsLabel; - private Button? _displayCurrentPageData; + private Button? _saveButton; + private Button? _openExportFolderButton; + private HBoxContainer? _hBoxContainer; 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); + } } @@ -53,7 +61,16 @@ public partial class LevelGraphEditorLoader : UiLoaderTemplate _roomTemplateTipsLabel.Text = string.Empty; } - _displayCurrentPageData = GetNode