using System;
using UnityEngine;
namespace Phantom.XRMOD.UnityFusion.Editor
{
///
/// Represents a class that is responsible for determining the header content to show in the Inspector
/// by default for all components of type .
///
/// Header content consists of a , and .
///
/// The default header content specified by this class can still be overriden for individual components
/// using the rename functionality in the Inspector, or by calling the
/// extension method in code.
///
///
///
///
/// Type of the components whose default header content is determined by this class.
///
public abstract class CustomHeader : ICustomHeader where TComponent : Component
{
///
/// Specifies the execution order of this custom header relative to other custom headers targeting the same component.
///
/// If multiple custom headers affect the same header content field (name, suffix or tooltip) on the same component,
/// then the content returned by the custom header with the largest will override the
/// ones returned by custom headers with smaller ones.
///
/// Custom headers can also modify components' pre-existing header content, instead of completely replacing them.
/// The target component's pre-existing header content can be acquired using the ,
/// and properties.
///
/// Default value is 0.
///
///
public virtual int ExecutionOrder => 0;
protected Name Name { get; private set; }
protected Suffix Suffix { get; private set; }
protected Tooltip Tooltip { get; private set; }
protected Name DefaultName { get; private set; }
protected Suffix DefaultSuffix { get; private set; }
protected Tooltip DefaultTooltip { get; private set; }
///
/// Gets the default name to show for the in the Inspector.
///
public virtual Name GetName(TComponent target) => null;
///
/// Gets the default suffix to show after the name of the in the Inspector.
///
/// The suffix will be drawn in a grey color inside parentheses.
/// >
///
/// The component whose suffix to get.
///
/// A object containing the text to draw as a suffix in the Inspector.
///
/// if no suffix should be drawn in the Inspector.
///
///
/// if the type name of the component should be drawn as a suffix in the Inspector.
///
///
public virtual Suffix GetSuffix(TComponent target) => null;
///
/// Gets the default tooltip to show when the title of the is mouseovered in the Inspector.
///
/// The component whose tooltip to get.
///
/// A object containing the text to draw when the title is mouseovered.
///
/// if no tooltip should be drawn when the title is mouseovered.
///
///
/// if the summary of the component class should be drawn when the title is mouseovered.
///
///
public virtual Tooltip GetTooltip(TComponent target) => null;
///
/// Gets the default header content to show for the in the Inspector.
///
/// The component whose header content to get.
///
/// A object containing the ,
/// and to show for the in the Inspector.
///
private HeaderContent Get(TComponent target) => new(GetName(target), GetSuffix(target), GetTooltip(target));
void ICustomHeader.Init(Name name, Suffix suffix, Tooltip tooltip, Name defaultName, Suffix defaultSuffix, Tooltip defaultTooltip)
{
Name = name;
Suffix = suffix;
Tooltip = tooltip;
DefaultName = defaultName;
DefaultSuffix = defaultSuffix;
DefaultTooltip = defaultTooltip;
}
Name ICustomHeader.GetName(Component target) => GetName((TComponent)target);
Suffix ICustomHeader.GetSuffix(Component target) => GetSuffix((TComponent)target);
Tooltip ICustomHeader.GetTooltip(Component target) => GetTooltip((TComponent)target);
int IComparable.CompareTo(ICustomHeader other) => ExecutionOrder.CompareTo(other.ExecutionOrder);
}
}