Skip to content

Commit

Permalink
Configurable rows for lists in some menus
Browse files Browse the repository at this point in the history
  • Loading branch information
Tirlititi committed Sep 11, 2023
1 parent e459698 commit cfc7cce
Show file tree
Hide file tree
Showing 30 changed files with 811 additions and 530 deletions.
3 changes: 2 additions & 1 deletion Assembly-CSharp/Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@
<Compile Include="Global\battle\BattleHUD\BattleHUD.cs" />
<Compile Include="Global\battle\BattleHUD\BattleHUD.UI.HUDAutoAttack.cs" />
<Compile Include="Global\battle\BattleHUD\BattleHUD.UI.PanelParty.cs" />
<Compile Include="Global\battle\BattleHUD\BattleHUD.UI.ScrollablePanel.cs" />
<Compile Include="Global\battle\BattleHUD\BattleHUD.UI.PanelTarget.cs" />
<Compile Include="Global\battle\BattleHUD\BattleHUD.UI.PanelCommand.cs" />
<Compile Include="Global\battle\BattleHUD\BattleHUD.UI.ContainerStatus.cs" />
Expand Down Expand Up @@ -355,6 +354,8 @@
<Compile Include="Memoria\Scenes\ControlPanel\ControlSlider.cs" />
<Compile Include="Memoria\Scenes\ControlPanel\ControlToggle.cs" />
<Compile Include="Memoria\Scenes\GOButtonPrefab.cs" />
<Compile Include="Memoria\Scenes\MenuHUD\MenuUIControlPanel.cs" />
<Compile Include="Memoria\Scenes\GOScrollablePanel.cs" />
<Compile Include="Memoria\Speedrun\AutoSplitterPipe.cs" />
<Compile Include="Memoria\Speedrun\Split.cs" />
<Compile Include="Memoria\Speedrun\SpeedrunSettings.cs" />
Expand Down
59 changes: 47 additions & 12 deletions Assembly-CSharp/Global/AbilityUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Linq;
using Memoria;
using Memoria.Assets;
using Memoria.Scenes;
using Memoria.Data;
using Memoria.Database;
using Memoria.Field;
Expand Down Expand Up @@ -75,6 +76,8 @@ public class AbilityUI : UIScene
private Boolean canMultiTarget;
private Dictionary<Int32, Int32> equipmentPartInAbilityDict;
private Dictionary<Int32, RegularItem[]> equipmentIdInAbilityDict;
private GOScrollablePanel _abilityPanel;
private GOScrollablePanel _supportPanel;

public static Color[] BoostedAbilityColor = new Color[]
{
Expand All @@ -88,7 +91,7 @@ public class AbilityUI : UIScene

public Int32 CurrentPartyIndex
{
set { this.currentPartyIndex = value; }
set => this.currentPartyIndex = value;
}

static AbilityUI()
Expand All @@ -113,7 +116,7 @@ public AbilityUI()

public override void Show(SceneVoidDelegate afterFinished = null)
{
SceneVoidDelegate action = () =>
SceneVoidDelegate afterShowAction = () =>
{
PersistenSingleton<UIManager>.Instance.MainMenuScene.SubMenuPanel.SetActive(false);
ButtonGroupState.SetScrollButtonToGroup(this.activeAbilityScrollList.ScrollButton, ActionAbilityGroupButton);
Expand All @@ -129,7 +132,8 @@ public override void Show(SceneVoidDelegate afterFinished = null)
};

SceneDirector.FadeEventSetColor(FadeMode.Sub, Color.black);
base.Show(action);
base.Show(afterShowAction);
this.UpdateUserInterface();
this.SwitchCharacter(true);
this.DisplayHelp();
this.DisplaySubMenuArrow(true);
Expand All @@ -138,9 +142,41 @@ public override void Show(SceneVoidDelegate afterFinished = null)
this.supportAbilityScrollList.ScrollButton.DisplayScrollButton(false, false);
}

public void UpdateUserInterface()
{
if (!Configuration.Interface.IsEnabled)
return;
const Int32 originalLineCount = 6;
const Single buttonOriginalHeight = 92f;
const Single panelOriginalWidth = 1488f;
const Single panelOriginalHeight = originalLineCount * buttonOriginalHeight;
Int32 linePerPage = Configuration.Interface.MenuAbilityRowCount;
Int32 lineHeight = (Int32)Math.Round(panelOriginalHeight / linePerPage);
Single scaleFactor = lineHeight / buttonOriginalHeight;
_abilityPanel.SubPanel.ChangeDims(2, linePerPage, panelOriginalWidth / 2f, lineHeight);
_abilityPanel.SubPanel.ButtonPrefab.NameLabel.SetAnchor(target: _abilityPanel.SubPanel.ButtonPrefab.Transform, relBottom: 0.152f, relTop: 0.848f, relLeft: 0.091f, relRight: 0.795f);
_abilityPanel.SubPanel.ButtonPrefab.NumberLabel.SetAnchor(target: _abilityPanel.SubPanel.ButtonPrefab.Transform, relBottom: 0.152f, relTop: 0.848f, relLeft: 0.8f, relRight: 0.92f);
_abilityPanel.SubPanel.ButtonPrefab.NameLabel.fontSize = (Int32)Math.Round(36f * scaleFactor);
_abilityPanel.SubPanel.ButtonPrefab.NumberLabel.fontSize = (Int32)Math.Round(36f * scaleFactor);
_abilityPanel.SubPanel.RecycleListPopulator.RefreshTableView();
_supportPanel.SubPanel.ChangeDims(2, linePerPage, panelOriginalWidth / 2f, lineHeight);
_supportPanel.SubPanel.ButtonPrefab.IconSprite.SetAnchor(target: _supportPanel.SubPanel.ButtonPrefab.Transform, relBottom: 0.152f, relTop: 0.848f, relLeft: 0.09f, relRight: 0.176f);
_supportPanel.SubPanel.ButtonPrefab.NameLabel.SetAnchor(target: _supportPanel.SubPanel.ButtonPrefab.Transform, relBottom: 0.152f, relTop: 0.848f, relLeft: 0.24f, relRight: 0.795f);
_supportPanel.SubPanel.ButtonPrefab.NumberLabel.SetAnchor(target: _supportPanel.SubPanel.ButtonPrefab.Transform, relBottom: 0.152f, relTop: 0.848f, relLeft: 0.8f, relRight: 0.92f);
_supportPanel.SubPanel.ButtonPrefab.NameLabel.fontSize = (Int32)Math.Round(36f * scaleFactor);
_supportPanel.SubPanel.ButtonPrefab.NumberLabel.fontSize = (Int32)Math.Round(36f * scaleFactor);
_supportPanel.SubPanel.RecycleListPopulator.RefreshTableView();
}

public override void Hide(SceneVoidDelegate afterFinished = null)
{
base.Hide(afterFinished);
UIScene.SceneVoidDelegate afterHideAction = delegate
{
MainMenuUI.UIControlPanel?.ExitMenu();
};
if (afterFinished != null)
afterHideAction += afterFinished;
base.Hide(afterHideAction);
if (this.fastSwitch)
return;
PersistenSingleton<UIManager>.Instance.MainMenuScene.StartSubmenuTweenIn();
Expand Down Expand Up @@ -949,6 +985,7 @@ private void DisplaySADetail(Transform item, ListDataTypeBase data, Int32 index,
ButtonGroupState.SetButtonAnimation(detailWithIconHud.Self, true);
detailWithIconHud.NameLabel.text = FF9TextTool.SupportAbilityName(supportId);
detailWithIconHud.NumberLabel.text = saData.GemsCount.ToString();
detailWithIconHud.IconSprite.preventPixelPerfect = Configuration.Interface.IsEnabled;
detailWithIconHud.IconSprite.color = Color.white;
if (abilityListData.Type == AbilityType.CantSpell)
{
Expand Down Expand Up @@ -1290,19 +1327,16 @@ public SubMenu GetSubMenuFromGameObject(GameObject go)
private void Awake()
{
this.FadingComponent = this.ScreenFadeGameObject.GetComponent<HonoFading>();
UIEventListener uiEventListener1 = UIEventListener.Get(this.UseSubMenu);
uiEventListener1.Click += this.onClick;
UIEventListener uiEventListener2 = UIEventListener.Get(this.EquipSubMenu);
uiEventListener2.Click += this.onClick;
UIEventListener.Get(this.UseSubMenu).Click += this.onClick;
UIEventListener.Get(this.EquipSubMenu).Click += this.onClick;
this.abilityInfoHud = new AbilityInfoHUD(this.AbilityDetailPanel);
this.abilityInfoHud.ClearEquipmentIcon();
this.characterHud = new CharacterDetailHUD(this.CharacterDetailPanel, false);
this.commandLabel = this.CommandPanel.GetChild(0).GetComponent<UILabel>();
foreach (Component component in this.TargetListPanel.transform.GetChild(0).transform)
{
GameObject obj = component.gameObject;
UIEventListener uiEventListener3 = UIEventListener.Get(obj);
uiEventListener3.Click += this.onClick;
UIEventListener.Get(obj).Click += this.onClick;
this.targetHudList.Add(new CharacterDetailHUD(obj, true));
if (FF9StateSystem.MobilePlatform)
gameObject.GetComponent<ButtonGroupState>().Help.TextKey = "TargetHelpMobile";
Expand All @@ -1314,15 +1348,16 @@ private void Awake()
this.allTargetButtonCollider = this.allTargetButton.GetComponent<BoxCollider>();
this.allTargetButtonLabel = this.allTargetButton.GetChild(1).GetComponent<UILabel>();
this.allTargetHitArea = this.TargetListPanel.GetChild(2);
UIEventListener uiEventListener4 = UIEventListener.Get(this.allTargetButton);
uiEventListener4.Click += OnAllTargetClick;
UIEventListener.Get(this.allTargetButton).Click += OnAllTargetClick;
this.useSubMenuLabel = this.UseSubMenu.GetChild(1).GetComponent<UILabel>();
this.equipSubMenuLabel = this.EquipSubMenu.GetChild(1).GetComponent<UILabel>();
this.submenuArrowGameObject = this.SubMenuPanel.GetChild(0);
this.activeAbilityScrollList = this.ActiveAbilityListPanel.GetChild(1).GetComponent<RecycleListPopulator>();
this.supportAbilityScrollList = this.SupportAbilityListPanel.GetChild(1).GetComponent<RecycleListPopulator>();
this.targetTransition = this.TransitionGroup.GetChild(0).GetComponent<HonoTweenPosition>();
this.avatarTransition = this.CharacterDetailPanel.GetChild(0).GetChild(6).GetChild(0).GetComponent<HonoAvatarTweenPosition>();
this._abilityPanel = new GOScrollablePanel(this.ActiveAbilityListPanel);
this._supportPanel = new GOScrollablePanel(this.SupportAbilityListPanel);
}

private Boolean IsSubMenuDisabledByMainMenu(Boolean useMenu)
Expand Down
Loading

0 comments on commit cfc7cce

Please sign in to comment.