From 719da5917daf2c4c6db8e12e1c83f3272fafa87c Mon Sep 17 00:00:00 2001 From: ShakeFlower Date: Sun, 17 Nov 2024 10:07:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=9C=B0=E5=9B=BE=E5=B0=BA?= =?UTF-8?q?=E5=AF=B8=E7=9B=B8=E5=85=B3bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ViewModels/Migrator/FloorsMigrator.cs | 37 ++++++++++++++++++--------- 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/ViewModels/Migrator/FloorsMigrator.cs b/ViewModels/Migrator/FloorsMigrator.cs index 0c3d980..5681938 100644 --- a/ViewModels/Migrator/FloorsMigrator.cs +++ b/ViewModels/Migrator/FloorsMigrator.cs @@ -17,8 +17,8 @@ namespace H5MotaUpdate.ViewModels /// public FloorsMigrator(string oldProjectDirectory, string newProjectDirectory, Version ver, int width, int height) { - sourcePath = System.IO.Path.Combine(oldProjectDirectory, FILENAME); - destPath = System.IO.Path.Combine(newProjectDirectory, FILENAME); + sourcePath = Path.Combine(oldProjectDirectory, FILENAME); + destPath = Path.Combine(newProjectDirectory, FILENAME); this.version = ver; this.mapWidth = width; this.mapHeight = height; @@ -91,18 +91,31 @@ namespace H5MotaUpdate.ViewModels jsonObject["autoEvent"] = new JObject(); // 设置每张地图的尺寸。如果自己有就用自己的,否则设为默认长宽。 - JToken width = jsonObject["width"], - height = jsonObject["height"]; - if (width == null) + + int width, height; + + if (jsonObject["width"] != null && jsonObject["width"].Type == JTokenType.Integer) { - jsonObject["width"] = mapWidth; + width = (int)jsonObject["width"]; } - if (height == null) + else { - jsonObject["height"] = mapHeight; + width = mapWidth; + jsonObject["width"] = width; } - #region + if (jsonObject["height"] != null && jsonObject["height"].Type == JTokenType.Integer) + { + height = (int)jsonObject["height"]; + } + else + { + height = mapHeight; + jsonObject["height"] = height; + } + + + #region 楼层贴图 // 楼层贴图:老版本为一字符串或数组,字符串会被自动转为[0,0,str] // 其中t[0],t[1]分别为x,y,t[2]为贴图名字 剩下的不知道干嘛的 JToken oldImages = jsonObject["images"]; @@ -126,15 +139,15 @@ namespace H5MotaUpdate.ViewModels new JProperty("canvas", "bg"), new JProperty("sx", 0), new JProperty("sy", 0), - new JProperty("w", 416), - new JProperty("h", 416) + new JProperty("w", 32 * width), + new JProperty("h", 32 * height) ); jsonObject["images"] = new JArray(newImages); #endregion #region JArray mapMatrix = (JArray)jsonObject["map"]; - JArray zeroBgMatrix = StringUtils.CreateMatrix(mapWidth, mapWidth); + JArray zeroBgMatrix = StringUtils.CreateMatrix(width, height); for (int i = 0; i < mapMatrix.Count; i++) { JArray lineArr = (JArray)mapMatrix[i];