Skip to content

Commit

Permalink
CombatIndicator: Fix resolution jank for real
Browse files Browse the repository at this point in the history
  • Loading branch information
AuriRex committed Jul 11, 2023
1 parent 1442540 commit 0c77e0a
Showing 1 changed file with 4 additions and 32 deletions.
36 changes: 4 additions & 32 deletions TheArchive.IL2CPP/Features/Hud/CombatIndicator.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Linq;
using TheArchive.Core.Attributes;
using TheArchive.Core.Attributes.Feature.Settings;
using TheArchive.Core.Attributes;
using TheArchive.Core.FeaturesAPI;
using TheArchive.Features.Dev;
using TheArchive.Interfaces;
Expand Down Expand Up @@ -28,26 +26,11 @@ public class CombatIndicatorSettings
{
public CombatIndicatorStyle Style { get; set; } = CombatIndicatorStyle.Simple;

[FSDisplayName("Special Screen Settings")]
[FSDescription("<#F00>Don't touch unless the combat indicator looks wrong!</color>\n\nMain purpouse is for weird screen resolution combinations that mess up the indicators scale.")]
public SpecialSettings Special { get; set; } = new SpecialSettings();

public enum CombatIndicatorStyle
{
Simple,
Detailed
}

public class SpecialSettings
{
[FSDisplayName("Override CI Scale")]
[FSDescription("Enable this if the combat indicator is missing entirely or scaled incorrectly.")]
public bool HelpIHaveAWeirdScreenSetupAndItsScaledInproperly { get; set; } = false;

[FSDisplayName("Size Multiplier")]
[FSDescription("Scales the Combat Indicators text element")]
public float SizeMultiplierFrom1080pBase { get; set; } = 1f;
}
}

/*
Expand Down Expand Up @@ -110,26 +93,15 @@ public static bool GetOrSetupCombatIndicator(PUI_LocalPlayerStatus localPlayerSt

combatIndicatorTMP.transform.SetParent(localPlayerStatus.transform);

combatIndicatorTMP.transform.localPosition = new Vector3(263.5f, 30, 0); // 263.5 = 301 (edge position) - 37.5 (half of it's OG size 75)
combatIndicatorTMP.transform.localPosition = new Vector3(292f, 27.5f, 0);

float scale;

if(Settings.Special.HelpIHaveAWeirdScreenSetupAndItsScaledInproperly)
{
scale = 0.5f * Settings.Special.SizeMultiplierFrom1080pBase;
}
else
{
var bigRes = Screen.resolutions.ToArray().OrderByDescending(res => res.height).First();
scale = bigRes.height / 1080 * 0.5f;
}

float scale = .625f;
combatIndicatorTMP.transform.localScale = new Vector3(scale, scale, scale);

combatIndicatorTMP.GetComponent<RectTransform>().sizeDelta = new Vector2(150, 25); // double it's size

combatIndicatorTMP.alignment = TMPro.TextAlignmentOptions.Right;
combatIndicatorTMP.fontSize = 15;
//combatIndicatorTMP.fontSize = 15;
combatIndicatorTMP.characterSpacing = -4.5f;
combatIndicatorTMP.text = GetStateString(DramaManager.CurrentStateEnum);

Expand Down

0 comments on commit 0c77e0a

Please sign in to comment.