diff --git a/locals/Error.csv b/locals/Error.csv deleted file mode 100644 index 5fb7974..0000000 --- a/locals/Error.csv +++ /dev/null @@ -1,10 +0,0 @@ -id,zh,en,jp -Object reference not set to an instance of an object.,尝试在空对象上调用虚拟方法。,Object reference not set to an instance of an object.,空のオブジェクト上で仮想メソッドを呼び出してみます。 -missing_parameters,缺少参数。,Missing parameters.,パラメータが不足しています。 -room_root_node_must_be_node2d,房间根节点必须是 Node2D。,Room root node must be Node2D.,ルートノードはNode2Dでなければなりません。 -width_or_height_of_room_slot_must_be_1,房间槽的宽度或高度必须为1。,The width or height of the room slot must be 1.,部屋の溝の幅または高さは1でなければなりません。 -connected_room_timeout,连接房间超时。,Connecting the room timed out.,接続部屋はタイムアウトです。 -projectiles_is_empty,未设置抛射体。,The projectile is not set.,射出体は設置されていません。 -map_generator_missing_parameters,地图生成器缺少参数。,Map generator missing parameters.,マップジェネレータが不足しています。 -map_generator_attempts_to_parse_empty_layout_diagrams,地图生成器尝试解析空的布局图。,Map generator attempts to parse empty layout diagrams.,マップジェネレータは空のレイアウト図を解析しようとしています。 -map_generator_has_no_starting_room_data,地图生成器没有起点房间数据。,Map generator has no starting room data.,マップ生成器に起点部屋データはありません。 \ No newline at end of file diff --git a/locals/Error.csv.import b/locals/Error.csv.import deleted file mode 100644 index 0745731..0000000 --- a/locals/Error.csv.import +++ /dev/null @@ -1,17 +0,0 @@ -[remap] - -importer="csv_translation" -type="Translation" -uid="uid://nmtkvo0t7p7n" - -[deps] - -files=["res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/Error.jp.translation"] - -source_file="res://locals/Error.csv" -dest_files=["res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/Error.jp.translation"] - -[params] - -compress=true -delimiter=0 diff --git a/locals/Error.en.translation b/locals/Error.en.translation deleted file mode 100644 index 64b0440..0000000 Binary files a/locals/Error.en.translation and /dev/null differ diff --git a/locals/Error.jp.translation b/locals/Error.jp.translation deleted file mode 100644 index 1192517..0000000 Binary files a/locals/Error.jp.translation and /dev/null differ diff --git a/locals/Error.zh.translation b/locals/Error.zh.translation deleted file mode 100644 index b15f408..0000000 Binary files a/locals/Error.zh.translation and /dev/null differ diff --git a/locals/Log.csv b/locals/Log.csv index 1c60c93..2c63795 100644 --- a/locals/Log.csv +++ b/locals/Log.csv @@ -1 +1,18 @@ -id,zh,en,jp \ No newline at end of file +id,zh,en,jp +map_generator_is_running,地图生成器正在运行中,请稍后重试。,"Map Generator is running, please try again later.",マップ生成器が動作中ですので、後ほどリトライしてください。 +missing_parameters,缺少参数。,Missing parameters.,パラメータが不足しています。 +room_root_node_must_be_node2d,房间根节点必须是 Node2D。,Room root node must be Node2D.,ルートノードはNode2Dでなければなりません。 +width_or_height_of_room_slot_must_be_1,房间槽的宽度或高度必须为1。,The width or height of the room slot must be 1.,部屋の溝の幅または高さは1でなければなりません。 +connected_room_timeout,连接房间超时。,Connecting the room timed out.,接続部屋はタイムアウトです。 +projectiles_is_empty,未设置抛射体。,The projectile is not set.,射出体は設置されていません。 +map_generator_missing_parameters,地图生成器缺少参数。,Map generator missing parameters.,マップジェネレータが不足しています。 +map_generator_attempts_to_parse_empty_layout_diagrams,地图生成器尝试解析空的布局图。,Map generator attempts to parse empty layout diagrams.,マップジェネレータは空のレイアウト図を解析しようとしています。 +map_generator_has_no_starting_room_data,地图生成器没有起点房间数据。,Map generator has no starting room data.,マップ生成器に起点部屋データはありません。 +room_placement_strategy_terminates_map_generation,房间的放置策略终止了地图生成。,The room placement strategy terminates map generation.,部屋の配置ポリシーはマップ作成を終了します。 +start_room_placement_information_returns_empty,起始房间放置信息返回空。,Start room placement information returns empty.,スタートルーム放置情報は空に戻ります。 +start_room_placement_failed,起始房间放置失败。,Start room placement failed.,スタートルーム放置失敗です。 +room_data_missing,房间数据缺失。,Room data missing.,部屋データが欠落しています。 +failed_to_calculate_the_room_location,计算房间{0}位置时失败。,Failed to calculate the location of room {0}.,部屋{0}の位置を計算するのに失敗します。 +place_existing_rooms,放置已存在的房间{0}。,Place existing rooms {0}.,既存の部屋を置きます{0}。 +room_placement_failed,房间{0}放置失败。,Room {0} placement failed.,部屋{0}の放置に失敗します。 +room_placement_information,房间{0}已被成功放置在{1}。,Room {0} has been successfully placed in {1}.,部屋{0}を{1}に配置しました。 \ No newline at end of file diff --git a/locals/Log.en.translation b/locals/Log.en.translation index 0b1c04f..51b0b48 100644 Binary files a/locals/Log.en.translation and b/locals/Log.en.translation differ diff --git a/locals/Log.jp.translation b/locals/Log.jp.translation index 1ba2594..ef41ed4 100644 Binary files a/locals/Log.jp.translation and b/locals/Log.jp.translation differ diff --git a/locals/Log.zh.translation b/locals/Log.zh.translation index 72fed09..dccd558 100644 Binary files a/locals/Log.zh.translation and b/locals/Log.zh.translation differ diff --git a/locals/UI.csv b/locals/UI.csv index 8df7ea3..1152037 100644 --- a/locals/UI.csv +++ b/locals/UI.csv @@ -29,4 +29,5 @@ cancel,取消,Cancel,キャンセル load,加载,Load,ろーど delete_selected_node,删除选中的节点,Delete selected node,選択されたノードを削除します re_create_map,重新创建地图,Re-create map,地図を再作成します -seed_info,种子:{0},Seed: {0},シード:{0} \ No newline at end of file +seed_info,种子:{0},Seed: {0},シード:{0} +tags,标签,Tags,と呼ぶ \ No newline at end of file diff --git a/locals/UI.en.translation b/locals/UI.en.translation index 5f3f490..9da8a62 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 662454a..d78dd25 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 9242f7e..13e9ac6 100644 Binary files a/locals/UI.zh.translation and b/locals/UI.zh.translation differ diff --git a/project.godot b/project.godot index 93617b2..41005f1 100644 --- a/project.godot +++ b/project.godot @@ -146,8 +146,7 @@ hotbar_previous={ [internationalization] -locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/Error.zh.translation", "res://locals/Error.en.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/Error.jp.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation") -locale/test="jp" +locale/translations=PackedStringArray("res://locals/UI.en.translation", "res://locals/UI.zh.translation", "res://locals/slogan.en.translation", "res://locals/slogan.zh.translation", "res://locals/Log.en.translation", "res://locals/Log.zh.translation", "res://locals/Weapon.en.translation", "res://locals/Weapon.zh.translation", "res://locals/InputMapping.en.translation", "res://locals/InputMapping.zh.translation", "res://locals/InputMapping.jp.translation", "res://locals/Log.jp.translation", "res://locals/slogan.jp.translation", "res://locals/UI.jp.translation", "res://locals/Weapon.jp.translation") [layer_names] diff --git a/scenes/LevelGraphEditor.tscn b/scenes/LevelGraphEditor.tscn index 4cb585a..a6e08aa 100644 --- a/scenes/LevelGraphEditor.tscn +++ b/scenes/LevelGraphEditor.tscn @@ -135,11 +135,22 @@ grow_vertical = 0 text = "creation" [node name="RoomTemplateCollectionTextEdit" type="TextEdit" parent="CreateOrEditorPanel"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_left = 9.0 +offset_top = 184.0 +offset_right = -11.0 +offset_bottom = 298.0 +grow_horizontal = 2 + +[node name="Label5" type="Label" parent="CreateOrEditorPanel"] layout_mode = 0 -offset_left = 16.0 -offset_top = 187.0 -offset_right = 1111.0 -offset_bottom = 303.0 +offset_left = 21.0 +offset_top = 354.0 +offset_right = 61.0 +offset_bottom = 379.0 +text = "tags" [node name="HBoxContainer" type="HBoxContainer" parent="."] layout_mode = 1 diff --git a/scripts/debug/LogCat.cs b/scripts/debug/LogCat.cs index 3271c90..66adaa5 100644 --- a/scripts/debug/LogCat.cs +++ b/scripts/debug/LogCat.cs @@ -68,6 +68,7 @@ public static class LogCat StringBuilder.Append("INFO"); break; } + StringBuilder.Append(DateTime.Now.ToString(" yyyy-M-d HH:mm:ss : ")); StringBuilder.Append(TranslationServerUtils.Translate(message)); return StringBuilder; @@ -120,7 +121,7 @@ public static class LogCat return; } - GD.PrintErr(HandleMessage(WarningLogLevel, message)); + GD.Print(HandleMessage(WarningLogLevel, message)); } public static void LogErrorWithFormat(string message, params object?[] args) @@ -144,6 +145,16 @@ public static class LogCat GD.Print(string.Format(HandleMessage(InfoLogLevel, message).ToString(), args)); } + public static void LogWarningWithFormat(string message, params object?[] args) + { + if (_minLogLevel > InfoLogLevel) + { + return; + } + + GD.Print(string.Format(HandleMessage(WarningLogLevel, message).ToString(), args)); + } + /// /// This method is called when an exception is caught /// 当捕获异常后调用此方法 diff --git a/scripts/map/MapGenerator.cs b/scripts/map/MapGenerator.cs index f375907..4986f66 100644 --- a/scripts/map/MapGenerator.cs +++ b/scripts/map/MapGenerator.cs @@ -27,6 +27,8 @@ public static class MapGenerator /// private static ILayoutStrategy? _layoutStrategy; + private static bool _running; + /// /// Map root node /// 地图根节点 @@ -89,16 +91,26 @@ public static class MapGenerator /// public static async Task GenerateMap() { + if (_running) + { + LogCat.LogWarning("map_generator_is_running"); + return; + } + + _running = true; if (_layoutStrategy == null || _roomPlacementStrategy == null || _layoutParsingStrategy == null || _mapRoot == null) { LogCat.LogError("map_generator_missing_parameters"); + _running = false; return; } NodeUtils.DeleteAllChild(_mapRoot); if (!await _roomPlacementStrategy.StartGeneration(_mapRoot)) { + LogCat.LogError("room_placement_strategy_terminates_map_generation"); + _running = false; return; } @@ -109,6 +121,7 @@ public static class MapGenerator levelGraphEditorSaveData.RoomNodeDataList.Count == 0) { LogCat.LogError("map_generator_attempts_to_parse_empty_layout_diagrams"); + _running = false; return; } @@ -123,6 +136,7 @@ public static class MapGenerator if (startRoomNodeData == null || string.IsNullOrEmpty(startRoomNodeData.Id)) { LogCat.LogError("map_generator_has_no_starting_room_data"); + _running = false; return; } @@ -131,12 +145,16 @@ public static class MapGenerator startRoomNodeData); if (startingRoomPlacementData == null) { + LogCat.LogError("start_room_placement_information_returns_empty"); + _running = false; return; } var placeSuccess = await PlaceRoomAndAddRecord(startRoomNodeData.Id, startingRoomPlacementData, roomDictionary); if (!placeSuccess) { + LogCat.LogError("start_room_placement_failed"); + _running = false; return; } @@ -147,6 +165,7 @@ public static class MapGenerator var roomNodeData = await _layoutParsingStrategy.Next(); if (roomNodeData == null || string.IsNullOrEmpty(roomNodeData.Id)) { + LogCat.LogWarning("room_data_missing"); continue; } @@ -167,14 +186,17 @@ public static class MapGenerator roomNodeData); if (roomPlacementData == null) { + LogCat.LogWithFormat("failed_to_calculate_the_room_location", roomNodeData.Id); continue; } await PlaceRoomAndAddRecord(roomNodeData.Id, roomPlacementData, roomDictionary); } + //All rooms have been placed. //所有房间已放置完毕。 await _roomPlacementStrategy.GeneratedComplete(_mapRoot); + _running = false; } /// @@ -198,15 +220,18 @@ public static class MapGenerator if (dictionary.ContainsKey(roomNodeDataId)) { + LogCat.LogWithFormat("place_existing_rooms", roomNodeDataId); return false; } if (!await _roomPlacementStrategy.PlaceRoom(_mapRoot, roomPlacementData)) { + LogCat.LogWarningWithFormat("room_placement_failed", roomNodeDataId); return false; } dictionary.Add(roomNodeDataId, roomPlacementData.Room); + LogCat.LogWithFormat("room_placement_information",roomNodeDataId,roomPlacementData.Position.ToString()); return true; } } \ No newline at end of file diff --git a/scripts/map/room/RoomFactory.cs b/scripts/map/room/RoomFactory.cs index 3c9d6f3..0ef6993 100644 --- a/scripts/map/room/RoomFactory.cs +++ b/scripts/map/room/RoomFactory.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.IO; +using ColdMint.scripts.utils; using Godot; using FileAccess = Godot.FileAccess; @@ -74,7 +75,7 @@ public static class RoomFactory var room = new Room { - RoomScene = GD.Load(resPath) + RoomScene = GD.Load(ResUtils.GetAbsolutePath(resPath)) }; return room; } diff --git a/scripts/utils/ResUtils.cs b/scripts/utils/ResUtils.cs new file mode 100644 index 0000000..5c022bb --- /dev/null +++ b/scripts/utils/ResUtils.cs @@ -0,0 +1,18 @@ +using System; + +namespace ColdMint.scripts.utils; + +public class ResUtils +{ + /// + /// The game returns the res directory with a.remap suffix at runtime, causing an error while loading the resource + /// 游戏在运行时返回res目录后带有.remap后缀,导致加载资源时出错 + /// + /// + /// + public static string GetAbsolutePath(string path) + { + var index = path.LastIndexOf(".remap", StringComparison.Ordinal); + return index > -1 ? path[..index] : path; + } +} \ No newline at end of file