64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using System;
|
|
using Godot;
|
|
using RobotAndDonkey.Game;
|
|
using RobotAndDonkey.Game.Modifiers;
|
|
|
|
public partial class ModifierIcon : TextureRect
|
|
{
|
|
public override void _Ready()
|
|
{
|
|
UpdateTooltip();
|
|
}
|
|
|
|
public void Configure(Modifier modifier)
|
|
{
|
|
Name = $"Modifier_{modifier.Id}";
|
|
m_Modifier = modifier;
|
|
Refresh();
|
|
}
|
|
|
|
public void Refresh()
|
|
{
|
|
if (m_Modifier == null)
|
|
return;
|
|
|
|
Texture = GD.Load<Texture2D>(m_Modifier.Id switch
|
|
{
|
|
EModifierId.Corrupt => "res://images/corrupt.png",
|
|
EModifierId.Unreliable => "res://images/unreliable.png",
|
|
EModifierId.RaceCondition => "res://images/race-condition.png",
|
|
EModifierId.Throttled => "res://images/throttled.png",
|
|
EModifierId.Effective => "res://images/effective.png",
|
|
EModifierId.Optimized => "res://images/optimized.png",
|
|
EModifierId.Efficient => "res://images/efficient.png",
|
|
EModifierId.Persistent => "res://images/persistent.png",
|
|
EModifierId.Analytic => string.Empty, //"res://images/analytic.png",
|
|
EModifierId.Rain => "res://images/rain.png",
|
|
EModifierId.Drought => "res://images/drought.png",
|
|
EModifierId.Pest => "res://images/pest.png",
|
|
EModifierId.Gravity => "res://images/gravity.png",
|
|
EModifierId.HeatWave => "res://images/heat-wave.png",
|
|
EModifierId.CourierOverspill => string.Empty, //"res://images/courier-overspill.png",
|
|
EModifierId.RangerFertileRest => string.Empty, //"res://images/ranger-fertile-rest.png",
|
|
EModifierId.GlobalImmunity => string.Empty, //"res://images/global-immunity.png",
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
});
|
|
Description = $"{m_Modifier.Id}\n{m_Modifier.ToolTip}";
|
|
UpdateTooltip();
|
|
}
|
|
|
|
private void UpdateTooltip()
|
|
{
|
|
if (!string.IsNullOrEmpty(Description))
|
|
TooltipText = Description;
|
|
else
|
|
TooltipText = m_Modifier.Id.ToString();
|
|
}
|
|
|
|
[Export(PropertyHint.MultilineText)]
|
|
public string Description { get; set; } = string.Empty;
|
|
|
|
public Modifier Modifier => m_Modifier;
|
|
|
|
private Modifier m_Modifier;
|
|
} |