diff --git a/ACNHMS_Source/Assets/Scenes/MainScene.unity b/ACNHMS_Source/Assets/Scenes/MainScene.unity index ca4ae273..48d32367 100644 --- a/ACNHMS_Source/Assets/Scenes/MainScene.unity +++ b/ACNHMS_Source/Assets/Scenes/MainScene.unity @@ -3154,6 +3154,84 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 107721160} m_CullTransparentMesh: 0 +--- !u!1 &108739611 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 108739612} + - component: {fileID: 108739614} + - component: {fileID: 108739613} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &108739612 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 108739611} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 933963985} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 669.3862, y: 965.89404} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &108739613 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 108739611} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 14 + m_FontStyle: 0 + m_BestFit: 1 + m_MinSize: 10 + m_MaxSize: 47 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: New Text +--- !u!222 &108739614 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 108739611} + m_CullTransparentMesh: 0 --- !u!1 &109855116 GameObject: m_ObjectHideFlags: 0 @@ -7336,6 +7414,80 @@ RectTransform: m_AnchoredPosition: {x: 0, y: -160} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} +--- !u!1 &300760967 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 300760968} + - component: {fileID: 300760970} + - component: {fileID: 300760969} + m_Layer: 5 + m_Name: MainBlocker + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &300760968 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 300760967} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1742749201} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 3181.6802, y: 3181.6802} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &300760969 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 300760967} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.16981131, g: 0.16981131, b: 0.16981131, a: 0} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &300760970 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 300760967} + m_CullTransparentMesh: 0 --- !u!1 &302986186 GameObject: m_ObjectHideFlags: 0 @@ -27577,6 +27729,81 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 930041045} m_CullTransparentMesh: 0 +--- !u!1 &933963984 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 933963985} + - component: {fileID: 933963987} + - component: {fileID: 933963986} + m_Layer: 5 + m_Name: CoverImage + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!224 &933963985 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933963984} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 108739612} + m_Father: {fileID: 1742749201} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 3181.6802, y: 3181.6802} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &933963986 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933963984} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.16981131, g: 0.16981131, b: 0.16981131, a: 0.9411765} + m_RaycastTarget: 1 + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 0} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &933963987 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 933963984} + m_CullTransparentMesh: 0 --- !u!1 &936949937 GameObject: m_ObjectHideFlags: 0 @@ -30605,7 +30832,7 @@ GameObject: - component: {fileID: 1068893979} m_Layer: 5 m_Name: Canvas - m_TagString: Untagged + m_TagString: MainCanvas m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -36587,7 +36814,7 @@ MonoBehaviour: m_LineType: 0 m_HideMobileInput: 0 m_CharacterValidation: 0 - m_CharacterLimit: 0 + m_CharacterLimit: 22 m_OnEndEdit: m_PersistentCalls: m_Calls: [] @@ -38572,7 +38799,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 41b314fe2ff09544092d888e73f07217, type: 3} m_Name: m_EditorClassIdentifier: - LastEditorDateTime: 2020/07/05 03:19:31 + LastEditorDateTime: 2020/07/05 16:37:57 TextToSet: {fileID: 1900255556} --- !u!1 &1387983482 GameObject: @@ -47449,6 +47676,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1742749201} + - component: {fileID: 1742749202} m_Layer: 5 m_Name: Popup m_TagString: Untagged @@ -47466,7 +47694,9 @@ RectTransform: m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} - m_Children: [] + m_Children: + - {fileID: 300760968} + - {fileID: 933963985} m_Father: {fileID: 1068893982} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -47475,6 +47705,21 @@ RectTransform: m_AnchoredPosition: {x: 0, y: 0} m_SizeDelta: {x: 100, y: 100} m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1742749202 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1742749200} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 67b297065d76f964c8876c5f90b298bb, type: 3} + m_Name: + m_EditorClassIdentifier: + Root: {fileID: 933963984} + MainBlocker: {fileID: 300760967} + ToWriteTo: {fileID: 108739613} --- !u!1 &1743923194 GameObject: m_ObjectHideFlags: 0 diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_MoneyMiles.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_MoneyMiles.cs index 63ef68a1..7184a125 100644 --- a/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_MoneyMiles.cs +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_MoneyMiles.cs @@ -63,9 +63,7 @@ public void GetMoneyValues() catch (Exception e) { Debug.LogError(e.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(e.Message); -#endif + PopupHelper.CreateError(e.Message, 2f); } } @@ -96,9 +94,7 @@ public void SetMoneyValues() catch (Exception e) { Debug.LogError(e.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(e.Message); -#endif + PopupHelper.CreateError(e.Message, 2f); } } diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_TurnipStonk.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_TurnipStonk.cs index 670b66d8..cfc058c7 100644 --- a/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_TurnipStonk.cs +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_TurnipStonk.cs @@ -82,9 +82,7 @@ public void SetTurnipValues() catch (Exception e) { Debug.LogError(e.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(e.Message); -#endif + PopupHelper.CreateError(e.Message, 2f); } } @@ -101,9 +99,7 @@ public void GetTurnipValues() catch (Exception e) { Debug.LogError(e.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(e.Message); -#endif + PopupHelper.CreateError(e.Message, 2f); } } diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_Villager.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_Villager.cs index 662d1074..e48b343c 100644 --- a/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_Villager.cs +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/AdditionalPanel/UI_Villager.cs @@ -58,7 +58,7 @@ void Start() VillagerHouseRamOffset.onValueChanged.AddListener(delegate { VillagerHouseAddress = VillagerHouseRamOffset.text; }); } - public void LoadAllVillagers() // gets first 3 bytes of each villager + private void loadAllVillagers() { for (int i = 0; i < 10; ++i) { @@ -73,11 +73,13 @@ public void LoadAllVillagers() // gets first 3 bytes of each villager BlockerRoot.gameObject.SetActive(false); } - public void LoadVillager(int index) + public void LoadAllVillagers() // gets first 3 bytes of each villager { - if (!loadedVillagerShells) - return; + UI_Popup.CurrentInstance.CreatePopupMessage(0.001f, "Loading villagers...", () => { loadAllVillagers(); }); + } + public void loadVillager(int index) + { try { byte[] loaded = CurrentConnection.ReadBytes(CurrentVillagerAddress + (uint)(index * Villager.SIZE), Villager.SIZE); @@ -87,17 +89,28 @@ public void LoadVillager(int index) currentlyLoadedVillagerIndex = index; loadedVillager = new Villager(loaded); + + // get their house + byte[] loadedHouse = CurrentConnection.ReadBytes(CurrentVillagerHouseAddress + (uint)(currentlyLoadedVillagerIndex * VillagerHouse.SIZE), VillagerHouse.SIZE); + loadedVillagerHouse = new VillagerHouse(loadedHouse); + VillagerToUI(loadedVillager); } catch (Exception e) { Debug.LogError(e.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(e.Message); -#endif + PopupHelper.CreateError(e.Message, 2f); } } + public void LoadVillager(int index) + { + if (!loadedVillagerShells) + return; + + UI_Popup.CurrentInstance.CreatePopupMessage(0.001f, "Loading villager...", () => { loadVillager(index); }); + } + public void VillagerToUI(Villager v) { VillagerName.text = GameInfo.Strings.GetVillager(v.InternalName); @@ -108,7 +121,7 @@ public void VillagerToUI(Villager v) SaveVillagerLabel.text = string.Format("Save villager ({0})", VillagerName.text); } - public void SetCurrentVillager(bool includeHouse) + private void setCurrentVillager(bool includeHouse) { if (currentlyLoadedVillagerIndex == -1) return; @@ -120,7 +133,7 @@ public void SetCurrentVillager(bool includeHouse) if (includeHouse) CurrentConnection.WriteBytes(loadedVillagerHouse.Data, CurrentVillagerHouseAddress + (uint)(currentlyLoadedVillagerIndex * VillagerHouse.SIZE)); - + if (UI_ACItemGrid.LastInstanceOfItemGrid != null) UI_ACItemGrid.LastInstanceOfItemGrid.PlayHappyParticles(); @@ -128,12 +141,15 @@ public void SetCurrentVillager(bool includeHouse) catch (Exception e) { Debug.LogError(e.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(e.Message); -#endif + PopupHelper.CreateError(e.Message, 2f); } } + public void SetCurrentVillager(bool includeHouse) + { + UI_Popup.CurrentInstance.CreatePopupMessage(0.001f, "Saving villager...", () => { setCurrentVillager(includeHouse); }); + } + public void RevertCurrentPhraseToOriginal() { if (currentlyLoadedVillagerIndex == -1) @@ -149,23 +165,38 @@ public void ShowSelector() private void loadVillagerFromResource() { - string newVillager = Selector.LastSelectedVillager; - byte[] villagerDump = ((TextAsset)Resources.Load("DefaultVillagers/" + newVillager + "V")).bytes; - byte[] villagerHouse = ((TextAsset)Resources.Load("DefaultVillagers/" + newVillager + "H")).bytes; - if (villagerDump == null || villagerHouse == null) - return; + UI_Popup.CurrentInstance.CreatePopupMessage(0.001f, "Sending villager...", () => { loadVillagerData(); }); + } + + private void loadVillagerData() + { + try + { + string newVillager = Selector.LastSelectedVillager; + byte[] villagerDump = ((TextAsset)Resources.Load("DefaultVillagers/" + newVillager + "V")).bytes; + byte[] villagerHouse = ((TextAsset)Resources.Load("DefaultVillagers/" + newVillager + "H")).bytes; + if (villagerDump == null || villagerHouse == null) + return; + + Villager newV = new Villager(villagerDump); + newV.SetMemories(loadedVillager.GetMemories()); + newV.CatchPhrase = GameInfo.Strings.GetVillagerDefaultPhrase(newVillager); + VillagerHouse newVH = new VillagerHouse(villagerHouse); + newVH.NPC1 = loadedVillagerHouse.NPC1; - Villager newV = new Villager(villagerDump); - //newV.SetMemories(loadedVillager.GetMemories()); - newV.CatchPhrase = GameInfo.Strings.GetVillagerDefaultPhrase(newVillager); - VillagerHouse newVH = new VillagerHouse(villagerHouse); - loadedVillager = newV; - loadedVillagerHouse = newVH; + loadedVillager = newV; + loadedVillagerHouse = newVH; - SetCurrentVillager(true); - TenVillagers[currentlyLoadedVillagerIndex].texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, newVillager); - VillagerToUI(loadedVillager); + SetCurrentVillager(true); + TenVillagers[currentlyLoadedVillagerIndex].texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, newVillager); + VillagerToUI(loadedVillager); + } + catch (Exception e) + { + Debug.LogError(e.Message); + PopupHelper.CreateError(e.Message, 2f); + } } private void resetVillagerSelection() diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers.meta b/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers.meta new file mode 100644 index 00000000..a37cec8d --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3801e936d937d2e44b5ca4a9e5ee1020 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers/PopupHelper.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers/PopupHelper.cs new file mode 100644 index 00000000..f327e98b --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers/PopupHelper.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class PopupHelper +{ + public static void CreateError(string message, float length) + { +#if UNITY_ANDROID && !UNITY_EDITOR + AndroidUSBUtils.CurrentInstance.DebugToast(message); +#else + UI_Popup.CurrentInstance.CreatePopupMessage(length, message, null); +#endif + } +} diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers/PopupHelper.cs.meta b/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers/PopupHelper.cs.meta new file mode 100644 index 00000000..75778bbb --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/Helpers/PopupHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6426ae09e0af7544fb05d33c4d4730bd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_ACItemGrid.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_ACItemGrid.cs index f135ab66..a773b9dd 100644 --- a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_ACItemGrid.cs +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_ACItemGrid.cs @@ -145,19 +145,15 @@ private void AfterRead(InjectionResult r) else { Debug.LogError(r.ToString()); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(r.ToString()); -#endif + PopupHelper.CreateError(r.ToString(), 2f); } } private static void AfterWrite(InjectionResult r) { Debug.Log($"Write result: {r}"); -#if PLATFORM_ANDROID if (r != InjectionResult.Success) - AndroidUSBUtils.CurrentInstance.DebugToast($"Write result: {r}"); -#endif + PopupHelper.CreateError($"Write result: {r}", 2f); } private void set(Item[] items) diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_Popup.cs b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_Popup.cs new file mode 100644 index 00000000..10f5654e --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_Popup.cs @@ -0,0 +1,43 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using System; + +public class UI_Popup : MonoBehaviour +{ + public static UI_Popup CurrentInstance; + + public GameObject Root; + public GameObject MainBlocker; + public Text ToWriteTo; + + void Start() + { + // there can be only one (0_0) + CurrentInstance = this; + } + + public void CreatePopupMessage(float length, string message, Action onStart, bool animate = false) + { + ToWriteTo.text = message; + MainBlocker.SetActive(true); + Root.SetActive(true); + StopAllCoroutines(); + StartCoroutine(waitPop(length, onStart, animate)); + } + + IEnumerator waitPop(float length, Action onStart, bool anim) + { + if (onStart != null) + { + yield return new WaitForEndOfFrame(); + yield return new WaitForEndOfFrame(); + onStart(); + } + + yield return new WaitForSeconds(length); + MainBlocker.SetActive(false); + Root.SetActive(false); + } +} diff --git a/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_Popup.cs.meta b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_Popup.cs.meta new file mode 100644 index 00000000..58f4f282 --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/ACNHMS/UI_Popup.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 67b297065d76f964c8876c5f90b298bb +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ACNHMS_Source/Assets/Scripts/Injection/Injector/AutoInjector.cs b/ACNHMS_Source/Assets/Scripts/Injection/Injector/AutoInjector.cs index 3969c20b..843a5545 100644 --- a/ACNHMS_Source/Assets/Scripts/Injection/Injector/AutoInjector.cs +++ b/ACNHMS_Source/Assets/Scripts/Injection/Injector/AutoInjector.cs @@ -40,9 +40,7 @@ public InjectionResult Read(bool force = false) catch (IndexOutOfRangeException ex) { Debug.WriteLine(ex.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(ex.Message); -#endif + PopupHelper.CreateError(ex.Message, 2f); return InjectionResult.FailConnectionError; } } @@ -60,9 +58,7 @@ public InjectionResult Write(bool force = false) catch (IndexOutOfRangeException ex) { Debug.WriteLine(ex.Message); -#if PLATFORM_ANDROID - AndroidUSBUtils.CurrentInstance.DebugToast(ex.Message); -#endif + PopupHelper.CreateError(ex.Message, 2f); return InjectionResult.FailConnectionError; } } diff --git a/ACNHMS_Source/Assets/Scripts/Tools/Mathfx.cs b/ACNHMS_Source/Assets/Scripts/Tools/Mathfx.cs new file mode 100644 index 00000000..fd9807b7 --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/Tools/Mathfx.cs @@ -0,0 +1,170 @@ +using UnityEngine; + +public sealed class Mathfx +{ + //Ease in out + public static float Hermite(float start, float end, float value) + { + return Mathf.Lerp(start, end, value * value * (3.0f - 2.0f * value)); + } + + public static Vector2 Hermite(Vector2 start, Vector2 end, float value) + { + return new Vector2(Hermite(start.x, end.x, value), Hermite(start.y, end.y, value)); + } + + public static Vector3 Hermite(Vector3 start, Vector3 end, float value) + { + return new Vector3(Hermite(start.x, end.x, value), Hermite(start.y, end.y, value), Hermite(start.z, end.z, value)); + } + + //Ease out + public static float Sinerp(float start, float end, float value) + { + return Mathf.Lerp(start, end, Mathf.Sin(value * Mathf.PI * 0.5f)); + } + + public static Vector2 Sinerp(Vector2 start, Vector2 end, float value) + { + return new Vector2(Mathf.Lerp(start.x, end.x, Mathf.Sin(value * Mathf.PI * 0.5f)), Mathf.Lerp(start.y, end.y, Mathf.Sin(value * Mathf.PI * 0.5f))); + } + + public static Vector3 Sinerp(Vector3 start, Vector3 end, float value) + { + return new Vector3(Mathf.Lerp(start.x, end.x, Mathf.Sin(value * Mathf.PI * 0.5f)), Mathf.Lerp(start.y, end.y, Mathf.Sin(value * Mathf.PI * 0.5f)), Mathf.Lerp(start.z, end.z, Mathf.Sin(value * Mathf.PI * 0.5f))); + } + //Ease in + public static float Coserp(float start, float end, float value) + { + return Mathf.Lerp(start, end, 1.0f - Mathf.Cos(value * Mathf.PI * 0.5f)); + } + + public static Vector2 Coserp(Vector2 start, Vector2 end, float value) + { + return new Vector2(Coserp(start.x, end.x, value), Coserp(start.y, end.y, value)); + } + + public static Vector3 Coserp(Vector3 start, Vector3 end, float value) + { + return new Vector3(Coserp(start.x, end.x, value), Coserp(start.y, end.y, value), Coserp(start.z, end.z, value)); + } + + //Boing + public static float Berp(float start, float end, float value) + { + value = Mathf.Clamp01(value); + value = (Mathf.Sin(value * Mathf.PI * (0.2f + 2.5f * value * value * value)) * Mathf.Pow(1f - value, 2.2f) + value) * (1f + (1.2f * (1f - value))); + return start + (end - start) * value; + } + + public static Vector2 Berp(Vector2 start, Vector2 end, float value) + { + return new Vector2(Berp(start.x, end.x, value), Berp(start.y, end.y, value)); + } + + public static Vector3 Berp(Vector3 start, Vector3 end, float value) + { + return new Vector3(Berp(start.x, end.x, value), Berp(start.y, end.y, value), Berp(start.z, end.z, value)); + } + + //Like lerp with ease in ease out + public static float SmoothStep(float x, float min, float max) + { + x = Mathf.Clamp(x, min, max); + float v1 = (x - min) / (max - min); + float v2 = (x - min) / (max - min); + return -2 * v1 * v1 * v1 + 3 * v2 * v2; + } + + public static Vector2 SmoothStep(Vector2 vec, float min, float max) + { + return new Vector2(SmoothStep(vec.x, min, max), SmoothStep(vec.y, min, max)); + } + + public static Vector3 SmoothStep(Vector3 vec, float min, float max) + { + return new Vector3(SmoothStep(vec.x, min, max), SmoothStep(vec.y, min, max), SmoothStep(vec.z, min, max)); + } + + public static float Lerp(float start, float end, float value) + { + return ((1.0f - value) * start) + (value * end); + } + + public static Vector3 NearestPoint(Vector3 lineStart, Vector3 lineEnd, Vector3 point) + { + Vector3 lineDirection = Vector3.Normalize(lineEnd - lineStart); + float closestPoint = Vector3.Dot((point - lineStart), lineDirection); + return lineStart + (closestPoint * lineDirection); + } + + public static Vector3 NearestPointStrict(Vector3 lineStart, Vector3 lineEnd, Vector3 point) + { + Vector3 fullDirection = lineEnd - lineStart; + Vector3 lineDirection = Vector3.Normalize(fullDirection); + float closestPoint = Vector3.Dot((point - lineStart), lineDirection); + return lineStart + (Mathf.Clamp(closestPoint, 0.0f, Vector3.Magnitude(fullDirection)) * lineDirection); + } + + //Bounce + public static float Bounce(float x) + { + return Mathf.Abs(Mathf.Sin(6.28f * (x + 1f) * (x + 1f)) * (1f - x)); + } + + public static Vector2 Bounce(Vector2 vec) + { + return new Vector2(Bounce(vec.x), Bounce(vec.y)); + } + + public static Vector3 Bounce(Vector3 vec) + { + return new Vector3(Bounce(vec.x), Bounce(vec.y), Bounce(vec.z)); + } + + // test for value that is near specified float (due to floating point inprecision) + // all thanks to Opless for this! + public static bool Approx(float val, float about, float range) + { + return ((Mathf.Abs(val - about) < range)); + } + + // test if a Vector3 is close to another Vector3 (due to floating point inprecision) + // compares the square of the distance to the square of the range as this + // avoids calculating a square root which is much slower than squaring the range + public static bool Approx(Vector3 val, Vector3 about, float range) + { + return ((val - about).sqrMagnitude < range * range); + } + + /* + * CLerp - Circular Lerp - is like lerp but handles the wraparound from 0 to 360. + * This is useful when interpolating eulerAngles and the object + * crosses the 0/360 boundary. The standard Lerp function causes the object + * to rotate in the wrong direction and looks stupid. Clerp fixes that. + */ + public static float Clerp(float start, float end, float value) + { + float min = 0.0f; + float max = 360.0f; + float half = Mathf.Abs((max - min) / 2.0f);//half the distance between min and max + float retval = 0.0f; + float diff = 0.0f; + + if ((end - start) < -half) + { + diff = ((max - start) + end) * value; + retval = start + diff; + } + else if ((end - start) > half) + { + diff = -((max - end) + start) * value; + retval = start + diff; + } + else retval = start + (end - start) * value; + + // Debug.Log("Start: " + start + " End: " + end + " Value: " + value + " Half: " + half + " Diff: " + diff + " Retval: " + retval); + return retval; + } + +} \ No newline at end of file diff --git a/ACNHMS_Source/Assets/Scripts/Tools/Mathfx.cs.meta b/ACNHMS_Source/Assets/Scripts/Tools/Mathfx.cs.meta new file mode 100644 index 00000000..6e9a3907 --- /dev/null +++ b/ACNHMS_Source/Assets/Scripts/Tools/Mathfx.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4d08790026bcca046b3ca5a47cf1b972 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/ACNHMS_Source/Assets/Scripts/Tools/OffsetHelper.cs b/ACNHMS_Source/Assets/Scripts/Tools/OffsetHelper.cs index 9aa891f4..8f3aa0ce 100644 --- a/ACNHMS_Source/Assets/Scripts/Tools/OffsetHelper.cs +++ b/ACNHMS_Source/Assets/Scripts/Tools/OffsetHelper.cs @@ -14,4 +14,6 @@ public static class OffsetHelper public const ulong TurnipAddress = 0xAA890CB0; public const ulong VillagerAddress = TurnipAddress - 0x411F40; public const ulong VillagerHouseAddress = VillagerAddress + 0x40E228; + //public const ulong VillagerHouseBufferDiff = 0xACEDA0; + //public const ulong HeapVillagerHouse = 0x2A9B94A8; } diff --git a/ACNHMS_Source/ProjectSettings/TagManager.asset b/ACNHMS_Source/ProjectSettings/TagManager.asset index 1c92a784..6f16aff7 100644 --- a/ACNHMS_Source/ProjectSettings/TagManager.asset +++ b/ACNHMS_Source/ProjectSettings/TagManager.asset @@ -3,7 +3,8 @@ --- !u!78 &1 TagManager: serializedVersion: 2 - tags: [] + tags: + - MainCanvas layers: - Default - TransparentFX