diff --git a/locals/Log.csv b/locals/Log.csv
index 13d482d..1d732ec 100644
--- a/locals/Log.csv
+++ b/locals/Log.csv
@@ -117,4 +117,5 @@ log_contact_with_tiles_disables_damage,与瓦片接触禁用伤害。,"Disabling
log_hide_all_node,隐藏{0}个节点。,Hide {0} nodes.,{0}ノードを非表示にします。
log_show_all_node,显示{0}个节点。,Show {0} nodes.,{0}ノードが表示されます。
log_enter_the_screen,进入屏幕。,Enter screen,画面に移動。
-log_exit_the_screen,退出屏幕。,Exit screen,画面を終了します。
\ No newline at end of file
+log_exit_the_screen,退出屏幕。,Exit screen,画面を終了します。
+log_failed_to_create_room_preview,创建{0}的房间预览图失败。,Failed to create a room preview of the {0}.,{0}の部屋のプレビューを作成できませんでした。
\ No newline at end of file
diff --git a/scenes/mapContainer.tscn b/scenes/mapContainer.tscn
index 89618e6..155524c 100644
--- a/scenes/mapContainer.tscn
+++ b/scenes/mapContainer.tscn
@@ -28,10 +28,10 @@ anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
-offset_left = -174.0
-offset_top = -177.0
-offset_right = -24.0
-offset_bottom = -27.0
+offset_left = -1102.0
+offset_top = -525.0
+offset_right = -952.0
+offset_bottom = -375.0
grow_horizontal = 0
grow_vertical = 0
texture = ExtResource("1_h88bi")
diff --git a/scripts/Config.cs b/scripts/Config.cs
index 9d2ab59..e9a2f9e 100644
--- a/scripts/Config.cs
+++ b/scripts/Config.cs
@@ -82,6 +82,12 @@ public static class Config
///
public const float ThrownItemsHitEnemiesReduceSpeedByPercentage = 0.5f;
+ ///
+ /// Scale of the room preview view
+ /// 房间预览图的缩放
+ ///
+ public const float RoomPreviewScale = 1f;
+
///
/// How much blood does a heart represent
/// 一颗心代表多少血量
diff --git a/scripts/map/MapGenerator.cs b/scripts/map/MapGenerator.cs
index 8c91c46..d134b21 100644
--- a/scripts/map/MapGenerator.cs
+++ b/scripts/map/MapGenerator.cs
@@ -341,24 +341,15 @@ public static class MapGenerator
return false;
}
- //Create a room preview image.
- //创建房间预览图。
- var image = RoomPreview.CreateImage(roomPlacementData.NewRoom.GetTileMapLayer(Config.TileMapLayerName.Ground));
- if (GameSceneDepend.MiniMapContainerNode == null || roomPlacementData.Position == null ||
- image == null)
+ var tileMapLayer = roomPlacementData.NewRoom.GetTileMapLayer(Config.TileMapLayerName.Ground);
+ if (!CreateRoomPreview(tileMapLayer,
+ CalculateRelativePositionOnTheMinimap(tileMapLayer, roomPlacementData)))
{
+ LogCat.LogWithFormat("failed_to_create_room_preview", LogCat.LogLabel.Default, LogCat.UploadFormat,
+ roomNodeDataId);
return false;
}
- var sprite = new Sprite2D();
- sprite.Scale = new Vector2(5, 5);
- sprite.Texture = image;
- //TODO:Calculate the coordinates of the room preview view.
- //TODO:计算房间预览图的坐标。
- sprite.Position = GameSceneDepend.MiniMapMidpointCoordinate +
- roomPlacementData.Position.Value / Config.CellSize;
- NodeUtils.CallDeferredAddChild(GameSceneDepend.MiniMapContainerNode, sprite);
-
//Rooms are added to the dictionary only after the preview is created.
//创建预览图后才将房间添加到字典。
dictionary.Add(roomNodeDataId, roomPlacementData.NewRoom);
@@ -366,4 +357,59 @@ public static class MapGenerator
roomPlacementData.Position.ToString());
return true;
}
+
+ ///
+ /// CalculateRelativePositionOnTheMinimap
+ /// 计算在迷你地图上的相对位置
+ ///
+ ///
+ ///Returns the position relative to the point in the minimap container
+ ///返回相对对于迷你地图容器中点的位置
+ ///
+ private static Vector2? CalculateRelativePositionOnTheMinimap(TileMapLayer? groundTileMapLayer,
+ RoomPlacementData roomPlacementData)
+ {
+ if (groundTileMapLayer == null || roomPlacementData.Position == null)
+ {
+ return null;
+ }
+
+
+
+ return roomPlacementData.Position.Value / Config.CellSize * Config.RoomPreviewScale;
+ }
+
+ ///
+ /// Create a room preview image.
+ /// 创建房间预览图
+ ///
+ ///
+ ///Layers that need to be drawn onto a minimap
+ ///需要绘制到迷你地图上的图层
+ ///
+ ///
+ ///Relative to the position of the point in the minimap container
+ ///相对于迷你地图容器中点的位置
+ ///
+ ///
+ private static bool CreateRoomPreview(TileMapLayer? groundTileMapLayer, Vector2? position)
+ {
+ if (GameSceneDepend.MiniMapContainerNode == null || position == null)
+ {
+ return false;
+ }
+
+ var image = RoomPreview.CreateImage(groundTileMapLayer);
+ if (image == null)
+ {
+ return false;
+ }
+
+ var sprite = new Sprite2D();
+ sprite.Scale = new Vector2(Config.RoomPreviewScale, Config.RoomPreviewScale);
+ sprite.Texture = image;
+ sprite.Position = GameSceneDepend.MiniMapMidpointCoordinate + position.Value;
+ NodeUtils.CallDeferredAddChild(GameSceneDepend.MiniMapContainerNode, sprite);
+ return true;
+ }
}
\ No newline at end of file
diff --git a/scripts/map/preview/RoomPreview.cs b/scripts/map/preview/RoomPreview.cs
index 8164f45..e6b50ac 100644
--- a/scripts/map/preview/RoomPreview.cs
+++ b/scripts/map/preview/RoomPreview.cs
@@ -55,7 +55,7 @@ public static class RoomPreview
//Create an image.
//创建image。
var image = Image.CreateEmpty(width + 1, height + 1, false, Image.Format.Rgba8);
- //image.Fill(Colors.Green);
+ image.Fill(Colors.Green);
//Fill in pixels
//填充像素点
foreach (var vector2I in cellsArray)