Skip to content

Commit

Permalink
put offsets in own class, sprites in buttons and variations now show …
Browse files Browse the repository at this point in the history
…correctly (#8)
  • Loading branch information
berichan committed Jul 3, 2020
1 parent 440b21a commit c025842
Show file tree
Hide file tree
Showing 10 changed files with 155 additions and 17 deletions.
77 changes: 75 additions & 2 deletions ACNHMS_Source/Assets/Scenes/MainScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -34838,7 +34838,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 41b314fe2ff09544092d888e73f07217, type: 3}
m_Name:
m_EditorClassIdentifier:
LastEditorDateTime: 2020/07/03 16:28:46
LastEditorDateTime: 2020/07/03 20:05:14
TextToSet: {fileID: 1900255556}
--- !u!1 &1387983482
GameObject:
Expand Down Expand Up @@ -41709,7 +41709,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 888191203}
m_HandleRect: {fileID: 888191202}
m_Direction: 2
m_Value: 0
m_Value: 1
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down Expand Up @@ -43209,6 +43209,7 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1766635570}
- {fileID: 2124842292}
m_Father: {fileID: 1743923195}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -43311,6 +43312,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
SelectionButton: {fileID: 1763291442}
SelectionText: {fileID: 1766635571}
ItemImage: {fileID: 2124842293}
RawValue:
ProcessedValue:
ItemId: 0
Expand Down Expand Up @@ -51759,6 +51761,77 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2115689376}
m_CullTransparentMesh: 0
--- !u!1 &2124842291
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2124842292}
- component: {fileID: 2124842294}
- component: {fileID: 2124842293}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2124842292
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2124842291}
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: 1763291441}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 61.6, y: -37.830685}
m_SizeDelta: {x: 67.52292, y: 67.52292}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2124842293
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2124842291}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Texture: {fileID: 0}
m_UVRect:
serializedVersion: 2
x: 0
y: 0
width: 1
height: 1
--- !u!222 &2124842294
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2124842291}
m_CullTransparentMesh: 0
--- !u!1 &2125503430
GameObject:
m_ObjectHideFlags: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class UI_MoneyMiles : IUI_Additional
{
public const int ENCRYPTIONSIZE = 0x8;

public static string MoneyValueAddress = "ABA86BC4"; // ABA86BC4
public static string MilesAddress = "ABA2DD28"; // has miles current then miles total after it :) ABA2DD28
public static string WalletAddress = "ABA52760"; // has storage a bit after it in ram ABA52760
public static string MoneyValueAddress = OffsetHelper.BankAddress.ToString("X"); // ABA86BC4
public static string MilesAddress = OffsetHelper.MilesAddress.ToString("X"); // has miles current then miles total after it :) ABA2DD28
public static string WalletAddress = OffsetHelper.WalletAddress.ToString("X"); // has storage a bit after it in ram ABA52760
public static uint CurrentMoneyAddress { get { return StringUtil.GetHexValue(MoneyValueAddress); } }
public static uint CurrentMilesAddress { get { return StringUtil.GetHexValue(MilesAddress); } }
public static uint CurrentWalletAddress { get { return StringUtil.GetHexValue(WalletAddress); } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class UI_TurnipStonk : IUI_Additional
{
public static string TurnipValuesAddress = "AA890CB0";
public static string TurnipValuesAddress = OffsetHelper.TurnipAddress.ToString("X");
public static uint CurrentTurnipAddress { get { return StringUtil.GetHexValue(TurnipValuesAddress); } }

//info
Expand Down
8 changes: 8 additions & 0 deletions ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SearchItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class UI_SearchItem : MonoBehaviour

public Text SelectionText;

public RawImage ItemImage;

[HideInInspector]
public string RawValue;

Expand Down Expand Up @@ -45,6 +47,12 @@ public void InitialiseFor(string val, string contains, int itemId, ItemFilter ui
{
SetSelection();
});

// Sprite image
Color c;
Texture2D t2d = SpriteBehaviour.ItemToTexture2D((ushort)itemId, 0, out c);
ItemImage.texture = t2d;
ItemImage.color = c;
}

public void SetSelection()
Expand Down
4 changes: 2 additions & 2 deletions ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SearchWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem)
else
{
ItemRemakeInfo itemRemakeInfo = ItemRemakeInfoData.List[remakeIndex];
string bodySummary = itemRemakeInfo.GetBodySummary(GameInfo.Strings, tryGetDescriptor: false);
string bodySummary = itemRemakeInfo.GetBodySummary(GameInfo.Strings, false, false);
if (bodySummary.Length != 0)
{
string[] values = bodySummary.Split(new string[3]
Expand All @@ -270,7 +270,7 @@ public void SelectItem(ItemFilter itemF, int id, UI_SearchItem sItem)
{
SetController.CreateBody(new string[0]);
}
string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, tryGetDescriptor: false);
string fabricSummary = itemRemakeInfo.GetFabricSummary(GameInfo.Strings, false, false);
if (fabricSummary.Length != 0)
{
string[] values2 = fabricSummary.Split(new string[3]
Expand Down
38 changes: 34 additions & 4 deletions ACNHMS_Source/Assets/Scripts/ACNHMS/UI_SetControl.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using NHSE.Core;
using System;
using System.Collections.Generic;
using UnityEngine;
Expand Down Expand Up @@ -141,15 +142,16 @@ public void CreateBody(string[] values)
BCount.gameObject.SetActive(false);
return;
}
FCount.gameObject.SetActive(false);
values = values.TruncateEndInvalidValues();
FCount.gameObject.SetActive(false);
BCount.gameObject.SetActive(true);
BCount.ClearOptions();
foreach (string text in values)
{
if (text.Length != 0)
{
Dropdown.OptionData val = new Dropdown.OptionData();
val.text =text;
val.text = text.ClearInvalidText();
BCount.options.Add(val);
}
}
Expand All @@ -161,12 +163,13 @@ public void CreateFabric(string[] values)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
if (values.Length == 0)
if (values.Length == 0 || values.IsInvalidFabricArray())
{
FUses.gameObject.SetActive(true);
BUses.gameObject.SetActive(false);
return;
}
values = values.TruncateEndInvalidValues();
FUses.gameObject.SetActive(false);
BUses.gameObject.SetActive(true);
BUses.ClearOptions();
Expand All @@ -175,7 +178,7 @@ public void CreateFabric(string[] values)
if (text.Length != 0)
{
Dropdown.OptionData val = new Dropdown.OptionData();
val.text = text;
val.text = text.ClearInvalidText() ;
BUses.options.Add(val);
}
}
Expand All @@ -196,3 +199,30 @@ public string GetUntilOrEmpty(string text, string stopAt = "=")
return string.Empty;
}
}

public static class InvalidRemakeStringsUtil
{
// some string functions to clear out invalids
public static bool IsInvalidFabricArray(this string[] fa)
{
foreach (string f in fa)
if (!(f.EndsWith("=" + ItemRemakeInfo.InvalidCheck) || f == string.Empty))
return false;
return true;
}

public static string[] TruncateEndInvalidValues(this string[] sa)
{
List<string> ls = new List<string>(sa);
for (int i = ls.Count-1; i > 0; --i)
{
if (ls[i].EndsWith("=" + ItemRemakeInfo.InvalidCheck) || ls[i] == string.Empty)
ls.RemoveAt(i);
else
break;
}
return ls.ToArray();
}

public static string ClearInvalidText(this string s) => s.Replace(string.Format("({0})", ItemRemakeInfo.InvalidCheck), string.Empty);
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public ItemRemakeInfo(short index, ushort id, sbyte count, byte[] bc0, byte[] bc
}

private const string Invalid = nameof(Invalid);
public const string InvalidCheck = Invalid;

public bool HasBodyColor(int variant) => ReBodyPatternColors0[variant] != 14 || ReBodyPatternColors1[variant] != 14;
public bool HasFabricColor(int variant) => ReFabricPatternColors0[variant] != 14 || ReFabricPatternColors1[variant] != 14;
Expand Down Expand Up @@ -93,7 +94,7 @@ private static string GetColorText(byte c0, byte c1)

private static string GetColorText(byte value) => ((ItemCustomColor)value).ToString();

public string GetBodySummary(IRemakeString str, bool tryGetDescriptor = true)
public string GetBodySummary(IRemakeString str, bool tryGetDescriptor = true, bool checkValid = true)
{
var sb = new StringBuilder();
if (tryGetDescriptor)
Expand All @@ -106,7 +107,7 @@ public string GetBodySummary(IRemakeString str, bool tryGetDescriptor = true)
for (int i = 0; i < 8; i++)
{
var cd = GetBodyDescription(i);
if (cd == Invalid)
if (cd == Invalid && checkValid)
continue;

sb.Append(i).Append('=');
Expand All @@ -120,7 +121,7 @@ public string GetBodySummary(IRemakeString str, bool tryGetDescriptor = true)
return sb.ToString();
}

public string GetFabricSummary(IRemakeString str, bool tryGetDescriptor = true)
public string GetFabricSummary(IRemakeString str, bool tryGetDescriptor = true, bool checkValid = true)
{
var sb = new StringBuilder();
if (tryGetDescriptor)
Expand All @@ -133,7 +134,7 @@ public string GetFabricSummary(IRemakeString str, bool tryGetDescriptor = true)
for (int i = 0; i < 8; i++)
{
var cd = GetFabricDescription(i);
if (cd == Invalid)
if (cd == Invalid && checkValid)
continue;

var shifted = (i << 5);
Expand Down
15 changes: 15 additions & 0 deletions ACNHMS_Source/Assets/Scripts/Tools/OffsetHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public static class OffsetHelper
{
public const ulong InventoryOffset = 0xABA526A8;

public const ulong WalletAddress = InventoryOffset + 0xB8;
public const ulong MilesAddress = InventoryOffset - 0x24980;
public const ulong BankAddress = InventoryOffset + 0x3451C;

public const ulong TurnipAddress = 0xAA890CB0;
}
11 changes: 11 additions & 0 deletions ACNHMS_Source/Assets/Scripts/Tools/OffsetHelper.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ACNHMS_Source/Assets/Scripts/Tools/SysBotController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class SysBotController
{
public static string CurrentOffset = "ABA526A8";
public static string CurrentOffset = OffsetHelper.InventoryOffset.ToString("X");// "ABA526A8";

public SysBotController(InjectionType type) => Type = type;

Expand Down

0 comments on commit c025842

Please sign in to comment.