@@ -71,71 +71,57 @@ private static void PopupButtonContainer_SetButtonData(PopupButtonContainer __in
7171 [ HarmonyPatch ( typeof ( StartScreen ) , nameof ( StartScreen . Start ) ) ]
7272 private static void StartScreen_Start ( StartScreen __instance )
7373 {
74- Il2CppInterop . Runtime . InteropTypes . Arrays . Il2CppReferenceArray < UnityEngine . Object > allLocalizers = GameObject . FindObjectsOfTypeAll ( Il2CppType . From ( typeof ( TMPLocalizer ) ) ) ;
74+ var bottomBar = __instance . settingsButton . transform . parent ;
75+ var bottomBarHorizontalLayoutGroup = bottomBar . GetComponent < HorizontalLayoutGroup > ( ) ;
76+ bottomBarHorizontalLayoutGroup . childAlignment = TextAnchor . LowerCenter ;
77+ bottomBarHorizontalLayoutGroup . childForceExpandWidth = false ;
78+ bottomBarHorizontalLayoutGroup . childForceExpandHeight = false ;
79+ bottomBarHorizontalLayoutGroup . padding . left = 120 ;
80+ bottomBarHorizontalLayoutGroup . padding . right = bottomBarHorizontalLayoutGroup . padding . left ;
7581
76- foreach ( UnityEngine . Object item in allLocalizers )
77- {
78- TMPLocalizer ? localizer = item . TryCast < TMPLocalizer > ( ) ;
79- if ( localizer == null )
80- {
81- continue ;
82- }
82+ GameObject versionTextObject = GameObject . Instantiate ( __instance . settingsButton . label . gameObject , bottomBar ) ;
83+ versionTextObject . name = "PolyModVersion" ;
84+ versionTextObject . SetActive ( true ) ;
8385
84- Transform ? parent = localizer ? . gameObject ? . transform ? . parent ;
85- if ( parent == null )
86- {
87- continue ;
88- }
86+ LayoutElement versionTextLayoutElement = versionTextObject . GetComponent < LayoutElement > ( )
87+ ?? versionTextObject . AddComponent < LayoutElement > ( ) ;
88+ versionTextLayoutElement . ignoreLayout = true ;
8989
90- string parentName = parent . name ;
90+ RectTransform versionTextRectTransform = versionTextObject . GetComponent < RectTransform > ( ) ;
91+ versionTextRectTransform . anchorMin = Vector2 . zero ;
92+ versionTextRectTransform . anchorMax = Vector2 . zero ;
93+ versionTextRectTransform . pivot = Vector2 . zero ;
94+ versionTextRectTransform . anchoredPosition = new Vector2 ( 5f , 5f ) ;
9195
92- if ( parentName == "SettingsButton" )
93- {
94- Transform ? textTransform = parent . FindChild ( "DescriptionText" ) ;
95- if ( textTransform == null )
96- {
97- return ;
98- }
96+ TextMeshProUGUI versionTextComponent = versionTextObject . GetComponent < TextMeshProUGUI > ( ) ;
97+ versionTextComponent . fontSize = 18f ;
98+ versionTextComponent . alignment = TextAlignmentOptions . MidlineLeft ;
99+ versionTextComponent . enableWordWrapping = true ;
99100
100- GameObject originalText = textTransform . gameObject ;
101- GameObject text = GameObject . Instantiate ( originalText , originalText . transform . parent . parent . parent ) ;
102- text . name = "PolyModVersion" ;
101+ versionTextRectTransform . sizeDelta = new Vector2 ( 110f , 50f ) ;
103102
104- RectTransform rect = text . GetComponent < RectTransform > ( ) ;
105- rect . anchoredPosition = new Vector2 ( 265 , 40 ) ;
106- rect . sizeDelta = new Vector2 ( 500 , rect . sizeDelta . y ) ;
107- rect . anchorMax = Vector2 . zero ;
108- rect . anchorMin = Vector2 . zero ;
103+ versionTextObject . GetComponent < TMPLocalizer > ( ) . Text = $ "PolyMod { Plugin . VERSION } ";
109104
110- TextMeshProUGUI textComponent = text . GetComponent < TextMeshProUGUI > ( ) ;
111- textComponent . fontSize = 18 ;
112- textComponent . alignment = TextAlignmentOptions . BottomLeft ;
105+ GameObject originalButton = __instance . newsButton . gameObject ;
106+ GameObject button = GameObject . Instantiate ( originalButton , originalButton . transform . parent ) ;
107+ button . name = "PolyModHubButton" ;
113108
114- text . GetComponent < TMPLocalizer > ( ) . Text = $ "PolyMod { Plugin . VERSION } ";
115- text . AddComponent < LayoutElement > ( ) . ignoreLayout = true ;
116- }
117- else if ( parentName == "NewsButton" )
118- {
119- GameObject originalButton = parent . gameObject ;
120- GameObject button = GameObject . Instantiate ( originalButton , originalButton . transform . parent ) ;
121- button . name = "PolyModHubButton" ;
122- button . transform . position = originalButton . transform . position - new Vector3 ( 90 , 0 , 0 ) ;
109+ RectTransform originalButtonRectTransform = originalButton . GetComponent < RectTransform > ( ) ;
110+ button . transform . position = originalButton . transform . position - new Vector3 ( originalButtonRectTransform . rect . width * 1.5f , 0 , 0 ) ;
123111
124- UIRoundButton buttonComponent = button . GetComponent < UIRoundButton > ( ) ;
125- buttonComponent . bg . sprite = Visual . BuildSprite ( Plugin . GetResource ( "polymod_icon.png" ) . ReadBytes ( ) ) ;
126- buttonComponent . bg . transform . localScale = new Vector3 ( 1.2f , 1.2f , 0 ) ;
127- buttonComponent . bg . color = Color . white ;
112+ UIRoundButton buttonComponent = button . GetComponent < UIRoundButton > ( ) ;
113+ buttonComponent . bg . sprite = Visual . BuildSprite ( Plugin . GetResource ( "polymod_icon.png" ) . ReadBytes ( ) ) ;
114+ buttonComponent . bg . transform . localScale = buttonComponent . bg . transform . localScale * 1.2f ;
115+ buttonComponent . bg . color = Color . white ;
128116
129- GameObject . Destroy ( buttonComponent . icon . gameObject ) ;
130- GameObject . Destroy ( buttonComponent . outline . gameObject ) ;
117+ GameObject . Destroy ( buttonComponent . icon . gameObject ) ;
118+ GameObject . Destroy ( buttonComponent . outline . gameObject ) ;
131119
132- Transform descriptionText = button . transform . Find ( "DescriptionText" ) ;
133- descriptionText . gameObject . SetActive ( true ) ;
134- descriptionText . GetComponentInChildren < TMPLocalizer > ( ) . Key = "polymod.hub" ;
120+ Transform descriptionText = button . transform . Find ( "DescriptionText" ) ;
121+ descriptionText . gameObject . SetActive ( true ) ;
122+ descriptionText . GetComponentInChildren < TMPLocalizer > ( ) . Key = "polymod.hub" ;
135123
136- buttonComponent . OnClicked += ( UIButtonBase . ButtonAction ) PolyModHubButtonClicked ;
137- }
138- }
124+ buttonComponent . OnClicked += ( UIButtonBase . ButtonAction ) PolyModHubButtonClicked ;
139125
140126 static void PolyModHubButtonClicked ( int buttonId , BaseEventData eventData )
141127 {
0 commit comments