Started reusing objects in SexStatusViewModel

This commit is contained in:
amevarashi 2023-07-09 12:02:20 +05:00
parent 4e44d42c4f
commit 5138e11cb2
5 changed files with 128 additions and 109 deletions

View file

@ -3,33 +3,69 @@ using Verse;
namespace RJWSexperience.SexHistory.UI
{
public readonly struct BarInfo
public class BarInfo
{
public readonly string label;
public readonly float fillPercent;
public readonly Texture2D fillTexture;
public readonly TipSignal tooltip;
public readonly string labelRight;
public readonly Texture2D border;
private string _label;
private float _fillPercent;
private string _labelRight;
public string Label
{
get => _label;
set => _label = value.CapitalizeFirst();
}
public float FillPercent
{
get => _fillPercent;
set => _fillPercent = Mathf.Clamp01(value);
}
public Texture2D FillTexture { get; set; }
public TipSignal Tooltip { get; set; }
public string LabelRight
{
get => _labelRight;
set => _labelRight = value.CapitalizeFirst();
}
public Texture2D Border { get; set; }
public BarInfo()
{
_label = "";
_fillPercent = 0f;
FillTexture = Texture2D.grayTexture;
Tooltip = default;
_labelRight = "";
Border = null;
}
public BarInfo(Texture2D fillTexture)
{
_label = "";
_fillPercent = 0f;
FillTexture = fillTexture;
Tooltip = default;
_labelRight = "";
Border = null;
}
public BarInfo(string label, float fillPercent, Texture2D fillTexture, TipSignal tooltip, string labelRight = "", Texture2D border = null)
{
this.label = label.CapitalizeFirst();
this.fillPercent = Mathf.Clamp01(fillPercent);
this.fillTexture = fillTexture;
this.tooltip = tooltip;
this.labelRight = labelRight.CapitalizeFirst();
this.border = border;
_label = label.CapitalizeFirst();
_fillPercent = Mathf.Clamp01(fillPercent);
FillTexture = fillTexture;
Tooltip = tooltip;
_labelRight = labelRight.CapitalizeFirst();
Border = border;
}
public BarInfo(string label, float fillPercent, Texture2D fillTexture, string labelRight = "")
{
this.label = label.CapitalizeFirst();
this.fillPercent = Mathf.Clamp01(fillPercent);
this.fillTexture = fillTexture;
this.tooltip = default;
this.labelRight = labelRight.CapitalizeFirst();
this.border = null;
_label = label.CapitalizeFirst();
_fillPercent = Mathf.Clamp01(fillPercent);
FillTexture = fillTexture;
Tooltip = default;
_labelRight = labelRight.CapitalizeFirst();
Border = null;
}
}
}