Skip to content

Commit

Permalink
let local rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Mar 19, 2024
1 parent 32dfec3 commit 60856fd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public OptionsMenuManager(IModConsole console, IModUnityEvents unityEvents, IPop
var newMenu = Object.Instantiate(existingMenu);
newMenu.transform.parent = existingMenu.transform.parent;
newMenu.transform.localScale = Vector3.one;
newMenu.transform.localRotation = Quaternion.identity;
var rt = newMenu.GetComponent<RectTransform>();
var ert = existingMenu.GetComponent<RectTransform>();
rt.anchorMin = ert.anchorMin;
Expand Down Expand Up @@ -80,6 +81,7 @@ public OptionsMenuManager(IModConsole console, IModUnityEvents unityEvents, IPop
var newSubMenu = Object.Instantiate(existingTabbedSubMenu);
newSubMenu.transform.parent = existingTabbedSubMenu.transform.parent;
newSubMenu.transform.localScale = Vector3.one;
newSubMenu.transform.localRotation = Quaternion.identity;
var rectTransform = newSubMenu.GetComponent<RectTransform>();
rectTransform.anchorMin = existingTabbedSubMenu.GetComponent<RectTransform>().anchorMin;
rectTransform.anchorMax = existingTabbedSubMenu.GetComponent<RectTransform>().anchorMax;
Expand Down Expand Up @@ -163,6 +165,7 @@ public void RemoveTab(Menu tab)
var newSubMenuTabButton = Object.Instantiate(existingSubMenuTabButton);
newSubMenuTabButton.transform.parent = menu.transform.Find("SubMenuTabs");
newSubMenuTabButton.transform.localScale = Vector3.one;
newSubMenuTabButton.transform.localRotation = Quaternion.identity;
newSubMenuTabButton.transform.SetSiblingIndex(newSubMenuTabButton.transform.parent.childCount - 2);
newSubMenuTabButton.name = $"Button-{name}Tab";
Object.Destroy(newSubMenuTabButton.GetComponentInChildren<LocalizedText>());
Expand All @@ -172,6 +175,7 @@ public void RemoveTab(Menu tab)
newSubMenu.transform.parent = menu.transform;
newSubMenu.transform.localScale = Vector3.one;
newSubMenu.name = $"Menu{name}";
newSubMenu.transform.localRotation = Quaternion.identity;

var rt = newSubMenu.GetComponent<RectTransform>();
var ert = existingSubMenu.GetComponent<RectTransform>();
Expand Down Expand Up @@ -230,6 +234,7 @@ public IOWMLToggleElement AddCheckboxInput(Menu menu, string label, string toolt
newCheckbox.transform.parent = GetParentForAddedElements(menu);
newCheckbox.transform.localScale = Vector3.one;
newCheckbox.transform.name = $"UIElement-{label}";
newCheckbox.transform.localRotation = Quaternion.identity;

Object.Destroy(newCheckbox.GetComponentInChildren<LocalizedText>());

Expand Down Expand Up @@ -277,6 +282,7 @@ public IOWMLTwoButtonToggleElement AddToggleInput(Menu menu, string label, strin
newToggle.transform.parent = GetParentForAddedElements(menu);
newToggle.transform.localScale = Vector3.one;
newToggle.transform.name = $"UIElement-{label}";
newToggle.transform.localRotation = Quaternion.identity;

// no idea why, but the prefab doesnt have this
newToggle.GetComponent<LayoutElement>().preferredHeight = 70;
Expand Down Expand Up @@ -325,6 +331,7 @@ public IOWMLOptionsSelectorElement AddSelectorInput(Menu menu, string label, str
newSelector.transform.parent = GetParentForAddedElements(menu);
newSelector.transform.localScale = Vector3.one;
newSelector.transform.name = $"UIElement-{label}";
newSelector.transform.localRotation = Quaternion.identity;

Object.Destroy(newSelector.GetComponentInChildren<LocalizedText>());

Expand Down Expand Up @@ -372,6 +379,7 @@ public IOWMLSliderElement AddSliderInput(Menu menu, string label, float lower, f
newSlider.transform.parent = GetParentForAddedElements(menu);
newSlider.transform.localScale = Vector3.one;
newSlider.transform.name = $"UIElement-{label}";
newSlider.transform.localRotation = Quaternion.identity;

Object.Destroy(newSlider.GetComponentInChildren<LocalizedText>());

Expand Down Expand Up @@ -461,6 +469,7 @@ public SubmitAction CreateButton(Menu menu, string buttonLabel, string tooltip,
newButtonObj.transform.parent = GetParentForAddedElements(menu);
newButtonObj.transform.localScale = Vector3.one;
newButtonObj.name = $"UIElement-Button-{buttonLabel}";
newButtonObj.transform.localRotation = Quaternion.identity;

// the thing we're copying is already LEFT, so dont need to handle it
if (side == MenuSide.CENTER)
Expand Down Expand Up @@ -517,6 +526,7 @@ public SubmitAction CreateButtonWithLabel(Menu menu, string label, string button
var newHorizLayout = Object.Instantiate(existingHorizLayout);
newHorizLayout.transform.parent = newButtonObj.transform;
newHorizLayout.transform.localScale = Vector3.one;
newHorizLayout.transform.localRotation = Quaternion.identity;

var hrt = newHorizLayout.GetComponent<RectTransform>();
var ohrt = existingHorizLayout.GetComponent<RectTransform>();
Expand Down Expand Up @@ -552,6 +562,7 @@ public SubmitAction CreateButtonWithLabel(Menu menu, string label, string button
newButton.transform.parent = controlBlock;
newButton.transform.localScale = Vector3.one;
newButton.name = $"UIElement-{label}";
newButton.transform.localRotation = Quaternion.identity;

var rt = newButton.GetComponent<RectTransform>();
var ort = existingHorizLayout.transform.Find("ControlBlock").Find("HorizontalLayoutGroup").GetComponent<RectTransform>();
Expand Down Expand Up @@ -694,6 +705,7 @@ private TabButton CreateTabButton(string name, Menu menu)
newButton.transform.localScale = Vector3.one;
newButton.transform.SetSiblingIndex(newButton.transform.parent.childCount - 2);
newButton.name = $"Button-{name}";
newButton.transform.localRotation = Quaternion.identity;

RecalculateNavigation(newButton.transform.parent.GetComponentsInChildren<Button>(true).ToList());

Expand Down
2 changes: 2 additions & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/PauseMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public Menu MakePauseListMenu(string title)
newMenu.transform.parent = GameObject.Find("PauseMenuBlock").transform;
newMenu.transform.localScale = Vector3.one;
newMenu.transform.localPosition = Vector3.zero;
newMenu.transform.localRotation = Quaternion.identity;
newMenu.GetComponent<RectTransform>().SetLeft(0);
newMenu.GetComponent<RectTransform>().SetRight(0);
newMenu.GetComponent<RectTransform>().SetTop(0);
Expand Down Expand Up @@ -167,6 +168,7 @@ private GameObject CreateBase(string name, int index, bool fromTop, Menu customM
pauseButton.transform.SetSiblingIndex(pauseButton.transform.GetSiblingIndex() - 1); // -1 because no spacer in pause menu
pauseButton.SetActive(false);
pauseButton.name = $"Button-{name}";
pauseButton.transform.localRotation = Quaternion.identity;

if (customMenu.GetSelectOnActivate() == null)
{
Expand Down
7 changes: 7 additions & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/PopupMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public PopupMenu CreateTwoChoicePopup(string message, string confirmText, string

newPopup.transform.localPosition = Vector3.zero;
newPopup.transform.localScale = Vector3.one;
newPopup.transform.localRotation = Quaternion.identity;
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(x => Object.Destroy(x));

var popup = newPopup.GetComponent<PopupMenu>();
Expand Down Expand Up @@ -111,6 +112,7 @@ public PopupMenu CreateInfoPopup(string message, string continueButtonText)

newPopup.transform.localPosition = Vector3.zero;
newPopup.transform.localScale = Vector3.one;
newPopup.transform.localRotation = Quaternion.identity;
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(Object.Destroy);

var popup = newPopup.GetComponent<PopupMenu>();
Expand Down Expand Up @@ -145,6 +147,7 @@ public IOWMLThreeChoicePopupMenu CreateThreeChoicePopup(string message, string c

newPopup.transform.localPosition = Vector3.zero;
newPopup.transform.localScale = Vector3.one;
newPopup.transform.localRotation = Quaternion.identity;
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(Object.Destroy);

var originalPopup = newPopup.GetComponent<PopupMenu>();
Expand Down Expand Up @@ -201,6 +204,7 @@ public IOWMLPopupInputMenu CreateInputFieldPopup(string message, string placehol

newPopup.transform.localPosition = Vector3.zero;
newPopup.transform.localScale = Vector3.one;
newPopup.transform.localRotation = Quaternion.identity;
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(x => Object.Destroy(x));

var oldpopup = newPopup.GetComponent<PopupInputMenu>();
Expand Down Expand Up @@ -270,6 +274,7 @@ public IOWMLFourChoicePopupMenu CreateFourChoicePopup(string message, string con

newPopup.transform.localPosition = Vector3.zero;
newPopup.transform.localScale = Vector3.one;
newPopup.transform.localRotation = Quaternion.identity;
newPopup.GetComponentsInChildren<LocalizedText>().ToList().ForEach(Object.Destroy);

var originalPopup = newPopup.GetComponent<PopupMenu>();
Expand All @@ -278,9 +283,11 @@ public IOWMLFourChoicePopupMenu CreateFourChoicePopup(string message, string con

var ok2Button = Object.Instantiate(ok1Button, ok1Button.transform.parent);
ok2Button.transform.SetSiblingIndex(1);
ok2Button.transform.localRotation = Quaternion.identity;

var ok3Button = Object.Instantiate(ok1Button, ok1Button.transform.parent);
ok3Button.transform.SetSiblingIndex(2);
ok3Button.transform.localRotation = Quaternion.identity;

var popup = newPopup.AddComponent<OWMLFourChoicePopupMenu>();
popup._labelText = originalPopup._labelText;
Expand Down
1 change: 1 addition & 0 deletions src/OWML.ModHelper.Menus/NewMenuSystem/TitleMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public SubmitAction CreateTitleButton(string text, int index, bool fromTop)
var newButton = Object.Instantiate(existingTitleButton.gameObject);
newButton.transform.parent = existingTitleButton.transform.parent;
newButton.transform.localScale = existingTitleButton.transform.localScale;
newButton.transform.localRotation = Quaternion.identity;
newButton.name = $"Button-{text}";

Object.Destroy(newButton.GetComponent<SubmitActionConfirm>());
Expand Down

0 comments on commit 60856fd

Please sign in to comment.