diff --git a/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModeObject.cs b/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModeObject.cs index 44d8256..a698cb3 100644 --- a/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModeObject.cs +++ b/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModeObject.cs @@ -1,95 +1,14 @@ -using MU3.CustomUI; -using System; -using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; +using UnityEngine; namespace MU3.TestMode; class patch_TestModeObject: TestModeObject { - private List _titleList; - private List _itemList; - + protected extern void orig_initializeParamater(); protected override void initializeParamater() { - if(_font != null) { - _defaultFont = _font; - } - _canvasSize = new Vector2(Screen.width, Screen.height); + orig_initializeParamater(); - CanvasScaler canvasScaler = Utility.findParentRecursive(transform); - canvasScaler.uiScaleMode = CanvasScaler.ScaleMode.ConstantPixelSize; - canvasScaler.enabled = true; - canvasScaler.scaleFactor = scaleCorrection(); - - _topPositionY = _canvasSize.y * (1f - _topMargin); - _labelPositionX = _canvasSize.x * _leftMargin; - _labelSizeX = _canvasSize.x * _labelWidth; - _labelFullSizeX = _canvasSize.x * (1f - _leftMargin - _rightMargin); - _valuePositionX = _canvasSize.x * (_leftMargin + _labelWidth); - _valueSizeX = _canvasSize.x * (1f - _leftMargin - _rightMargin - _labelWidth); - } - - protected extern void orig_createTitle(); - protected override void createTitle() { - orig_createTitle(); - - float num = _canvasSize.y * (1f - _topMargin); - foreach(var title in _titleList) { - title.transform.position = new Vector3(title.transform.position.x, num, 0f); - num -= 36f * scaleCorrection(); - } - } - - protected extern void orig_createItems(); - protected override void createItems() { - orig_createItems(); - - for(int i = 0; i < _itemNum; i++) { - float y = _topPositionY - (float)((i + _itemTopLine) * 36f * scaleCorrection()); - var item = _itemList[i]; - item.labelText.transform.position = new Vector3(item.labelText.transform.position.x, y, 0f); - foreach(var value in item.valueTextList) { - value.transform.position = new Vector3(value.transform.position.x, y); - } - } - } - - protected extern void orig_createInstruction(); - protected new void createInstruction() { - orig_createInstruction(); - - float y = _canvasSize.y * _bottomMargin + 36f * scaleCorrection(); - _instructionText.transform.position = new Vector3(_instructionText.transform.position.x, y, 0f); - } - - protected extern MU3Text orig_makeText(); - protected new MU3Text makeText() { - var mU3Text = orig_makeText(); - - if(Screen.height < 1920.0f - float.Epsilon) { - mU3Text.fontSize = (int)Math.Round(32 * ppiCorrection()); - } else { - mU3Text.fontSize = 32; - } - - return mU3Text; - } - - protected float scaleCorrection() { - return Screen.height / 1920.0f; - } - - protected float ppiCorrection() { - return Mathf.Sqrt(scaleCorrection()); - } - - public new void changeTextLayoutHorizontal(MU3Text text, float left, float width) { - RectTransform rectTransform = text.transform as RectTransform; - Vector3 position = rectTransform.transform.position; - Vector2 sizeDelta = rectTransform.sizeDelta; - position.x = 1080f * left; - sizeDelta.x = 1080f * width; - rectTransform.transform.position = position; - rectTransform.sizeDelta = sizeDelta; + Canvas canvas = Utility.findParentRecursive(transform); + canvas.transform.localScale = new Vector2(1, 1); + canvas.transform.localPosition = new Vector2(540, 960); } } diff --git a/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModePage.cs b/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModePage.cs index 27e0d3d..8421093 100644 --- a/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModePage.cs +++ b/Fixes/TestMenuScaling/MU3.TestMode/patch_TestModePage.cs @@ -1,29 +1,14 @@ -using MonoMod; -using UnityEngine; +using UnityEngine; namespace MU3.TestMode; class patch_TestModePage: TestModePage { - private ItemDefine[] _itemDefines; + private Vector3 _cursorOffset; - [MonoModIgnore] - protected extern float scaleCorrection(); + protected extern void orig_initializeParamater(); + protected override void initializeParamater() { + orig_initializeParamater(); - protected extern void orig_createItems(); - - protected override void createItems() { - orig_createItems(); - - for(int i = 0; i < _itemDefines.Length; i++) { - ItemDefine itemDefine = _itemDefines[i]; - Item item = _itemList[i]; - float y = _topPositionY - (float)((itemDefine.lineNumber + _itemTopLine) * 36f * scaleCorrection()); - item.labelText.transform.position = new Vector3(item.labelText.transform.position.x, y, 0f); - - foreach(var valueItem in item.valueTextList) { - Vector2 sizeDelta = valueItem.rectTransform.sizeDelta; - valueItem.transform.position = new Vector3(valueItem.transform.position.x, y, 0f); - } - } + _cursorOffset = new Vector3(-48f * Screen.height / 1920f, 0f, 0f); } }