Skip to content

Commit

Permalink
add uistyleapplier to text/number
Browse files Browse the repository at this point in the history
  • Loading branch information
misternebula committed Feb 20, 2024
1 parent 54a0c6e commit 36cdf0a
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions src/OWML.ModHelper.Menus/NewMenuSystem/OptionsMenuManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,11 +522,12 @@ public SubmitAction CreateButtonWithLabel(Menu menu, string label, string button

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

newHorizLayout.transform
var labelComponent = newHorizLayout.transform
.Find("LabelBlock")
.Find("HorizontalLayoutGroup")
.Find("Label")
.GetComponent<Text>().text = label;
.GetComponent<Text>();
labelComponent.text = label;

var controlBlock = newHorizLayout.transform.Find("ControlBlock");
Object.Destroy(controlBlock.Find("OptionSelectorBG").gameObject);
Expand Down Expand Up @@ -558,6 +559,46 @@ public SubmitAction CreateButtonWithLabel(Menu menu, string label, string button

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

var leftArrow = newHorizLayout.transform
.Find("LabelBlock")
.Find("HorizontalLayoutGroup")
.Find("LeftArrow").GetComponent<Image>();

var rightArrow = newHorizLayout.transform
.Find("LabelBlock")
.Find("HorizontalLayoutGroup")
.Find("RightArrow").GetComponent<Image>();

var uiStyleApplier = newButtonObj.AddComponent<UIStyleApplier>();
uiStyleApplier._textItems = new Text[] { labelComponent };
uiStyleApplier._foregroundGraphics = new Graphic[] { labelComponent };
uiStyleApplier._backgroundGraphics = new Graphic[] { };
uiStyleApplier._onOffGraphicList = new UIStyleApplier.OnOffGraphic[]
{
new UIStyleApplier.OnOffGraphic()
{
graphic = leftArrow,
visibleNormal = false,
visibleIntermediate = false,
visibleHighlighted = true,
visiblePressed = true,
visibleDisabled = false,
visibleMouseRollover = true
},
new UIStyleApplier.OnOffGraphic()
{
graphic = rightArrow,
visibleNormal = false,
visibleIntermediate = false,
visibleHighlighted = true,
visiblePressed = true,
visibleDisabled = false,
visibleMouseRollover = true
}
};

newButton.AddComponent<SelectableAudioPlayer>();

var menuOption = newButton.GetComponent<MenuOption>();
menuOption._tooltipTextType = UITextType.None;
menuOption._overrideTooltipText = tooltip;
Expand Down

0 comments on commit 36cdf0a

Please sign in to comment.