diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SearchWindow.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SearchWindow.cs index b3c9d9b0..693c9572 100644 --- a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SearchWindow.cs +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SearchWindow.cs @@ -104,7 +104,10 @@ public void UpdateSprite() { if (CurrentItemID < 0) return; - Texture2D toSet = SpriteBehaviour.ItemToTexture2D(Convert.ToUInt16(CurrentItemID), Convert.ToUInt16(SetController.FCount.text), out var col); + + var toUseVariation = ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)) == ItemKind.Kind_Fence ? SetController.FUses.text : SetController.FCount.text; + Debug.Log(toUseVariation); + Texture2D toSet = SpriteBehaviour.ItemToTexture2D(Convert.ToUInt16(CurrentItemID), Convert.ToUInt16(toUseVariation), out var col); SpriteImageMain.texture = toSet; col.a = toSet == null ? 0.0f : 0.75f; SpriteImageMain.color = col; @@ -294,7 +297,8 @@ public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem) } CurrentSelectedIndex = spawnedObjects.IndexOf(sItem); - if (ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)).IsFlowerGene()) + var itemKind = ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)); + if (itemKind.IsFlowerGene()) { FlowerButtonRoot.SetActive(true); } @@ -309,11 +313,13 @@ public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem) else TreeButtonRoot.gameObject.SetActive(false);*/ //uncomment this if you want star tree editor again for whatever reason + + SetController.SpawnVariationsButton.gameObject.SetActive(false); short remakeIndex = ItemRemakeUtil.GetRemakeIndex(Convert.ToUInt16(CurrentItemID)); if (remakeIndex < 0) { - SetController.CreateBody(new string[0]); + SetController.CreateBody(new string[0], false); SetController.CreateFabric(new string[0]); } else @@ -328,11 +334,11 @@ public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem) "\r", "\n" }, StringSplitOptions.None); - SetController.CreateBody(values); + SetController.CreateBody(values, itemKind == ItemKind.Kind_Fence); } else { - SetController.CreateBody(new string[0]); + SetController.CreateBody(new string[0], itemKind == ItemKind.Kind_Fence); } string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, false, false); if (fabricSummary.Length != 0) @@ -416,6 +422,10 @@ public void LoadItem(Item item) else { SetController.FCount.text = item.Count.ToString(); + + if (itemKind == ItemKind.Kind_Fence) + SetController.FUses.text = item.UseCount.ToString(); + SetController.CompileBodyFabricFromCount(); SetController.FUses.text = item.UseCount.ToString(); SetController.FFlagZero.text = item.SystemParam.ToString(); diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SetControl.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SetControl.cs index d9a4ed62..055af77a 100644 --- a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SetControl.cs +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SetControl.cs @@ -29,10 +29,16 @@ public class UI_SetControl : MonoBehaviour private float maxStackIntervalTimer = -1; private int maxStackTapCount = 0; + private Vector3 bCountStartPos; + private Vector3 bCountFencePos; + private bool fenceMode = false; + public static int CurrentVariationCount = 0; private void Start() { + bCountStartPos = BCount.transform.position; + bCountFencePos = BUses.transform.position; BCount.onValueChanged.AddListener(delegate { CompileCountFromBodyFabric(); @@ -119,9 +125,9 @@ public void CompileBodyFabricFromCount() // probably unreadable now due to il re { return; } - int num = int.Parse(FCount.text); - int num2 = -1; - int num3 = -1; + int variation = fenceMode ? int.Parse(FUses.text) : int.Parse(FCount.text); + int selectedVariation = -1; + int selectedFabricVariation = -1; List list = new List(); if (BCount.gameObject.activeInHierarchy) // if off, this doesn't have any body values { @@ -129,15 +135,15 @@ public void CompileBodyFabricFromCount() // probably unreadable now due to il re { int num4 = int.Parse(GetUntilOrEmpty(BCount.options[i].text)); list.Add(num4); - if (num4 == num) + if (num4 == variation) { - num2 = i; - } + selectedVariation = i; + } } } - if (num2 != -1) + if (selectedVariation != -1) { - BCount.value=(num2); + BCount.value=selectedVariation; BCount.RefreshShownValue(); } if (!BUses.gameObject.activeSelf) @@ -149,23 +155,23 @@ public void CompileBodyFabricFromCount() // probably unreadable now due to il re { int num5 = int.Parse(GetUntilOrEmpty(BUses.options[j].text)); list2.Add(num5); - if (num5 == num) + if (num5 == variation) { - num3 = j; + selectedFabricVariation = j; } } - if (num3 != -1) + if (selectedFabricVariation != -1) { - BCount.value=(0); + BCount.value=0; BCount.RefreshShownValue(); - BUses.value=(num3); + BUses.value=(selectedFabricVariation); BUses.RefreshShownValue(); return; } int num6 = 0; for (int k = 0; k < list2.Count; k++) { - if (list2[k] > num6 && list2[k] < num) + if (list2[k] > num6 && list2[k] < variation) { num6 = list2[k]; } @@ -173,9 +179,9 @@ public void CompileBodyFabricFromCount() // probably unreadable now due to il re BUses.value=list2.IndexOf(num6); BUses.RefreshShownValue(); if (num6 == 0) - BCount.value = num; + BCount.value = variation; else - BCount.value=(num % num6); + BCount.value=(variation % num6); BCount.RefreshShownValue(); } @@ -191,13 +197,18 @@ public void CompileCountFromBodyFabric() { num += result; } - FCount.text=(num.ToString()); + + if (!fenceMode) + FCount.text = num.ToString(); + else + FUses.text = num.ToString(); } - public void CreateBody(string[] values) + public void CreateBody(string[] values, bool fence) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown + fenceMode = fence; if (values.Length == 0) { FCount.gameObject.SetActive(true); @@ -205,7 +216,12 @@ public void CreateBody(string[] values) return; } values = values.TruncateEndInvalidValues(); - FCount.gameObject.SetActive(false); + + if (!fenceMode) + FCount.gameObject.SetActive(false); + else + FUses.gameObject.SetActive(false); + BCount.gameObject.SetActive(true); BCount.ClearOptions(); foreach (string text in values) @@ -222,6 +238,8 @@ public void CreateBody(string[] values) CurrentVariationCount = BCount.options.Count; SpawnVariationsButton.gameObject.SetActive(true); + + BCount.transform.position = fenceMode ? bCountFencePos : bCountStartPos; } public void CreateFabric(string[] values) @@ -230,7 +248,8 @@ public void CreateFabric(string[] values) //IL_006c: Expected O, but got Unknown if (values.Length == 0 || values.IsInvalidFabricArray()) { - FUses.gameObject.SetActive(true); + if (!fenceMode) + FUses.gameObject.SetActive(true); BUses.gameObject.SetActive(false); return; } diff --git a/ACNHMS_Source/Assets/Scripts/SpriteLoading/SpriteBehaviour.cs b/ACNHMS_Source/Assets/Scripts/SpriteLoading/SpriteBehaviour.cs index 857d9090..fee60e99 100644 --- a/ACNHMS_Source/Assets/Scripts/SpriteLoading/SpriteBehaviour.cs +++ b/ACNHMS_Source/Assets/Scripts/SpriteLoading/SpriteBehaviour.cs @@ -227,8 +227,12 @@ static void InitParser(bool force = false) public static Texture2D ItemToTexture2D(ushort itemId, ushort count, out Color c) { + var isFence = ItemInfo.GetItemKind(Convert.ToUInt16(itemId)) == ItemKind.Kind_Fence; Item tempItem = new Item(itemId); - tempItem.Count = count; + if (!isFence) + tempItem.Count = count; + else + tempItem.UseCount = count; return ItemToTexture2D(tempItem, out c); } @@ -260,7 +264,8 @@ public static Texture2D ItemToTexture2D(Item tr, out Color c) if (SpritesExist()) { InitParser(); - var tx = SpriteParser.CurrentInstance.GetTexture(t.ItemId, t.Count); + ItemKind itemKind = ItemInfo.GetItemKind(Convert.ToUInt16(t.ItemId)); + var tx = SpriteParser.CurrentInstance.GetTexture(t.ItemId, itemKind == ItemKind.Kind_Fence ? t.UseCount : t.Count); if (tx != null) { toAssignImage = tx;