using System.Collections.Generic;
using RimWorld;
using UnityEngine;
using Verse;
using Verse.Sound;
namespace BlaxZones
{
/// Package Tab. Design: 1.0 "Delivery zone" > Tab. The delivery zone's tab and its copy/paste gizmos.
public partial class Zone_Delivery
{
/// Vanilla's copy and paste icons (StorageSettingsClipboard.cs:32, 43), loaded on first use on the main thread.
private static Texture2D copyIcon, pasteIcon;
private static Texture2D CopyIcon => copyIcon ??= ContentFinder.Get("UI/Commands/CopySettings", reportFailure: false);
private static Texture2D PasteIcon => pasteIcon ??= ContentFinder.Get("UI/Commands/PasteSettings", reportFailure: false);
/// The shared tab in an array, as Zone_Stockpile keeps its ITabs (Zone_Stockpile.cs:13-16, 70-73): the inspect pane asks every frame.
private static InspectTabBase[] inspectTabs;
/// ITab_Delivery, through InspectTabManager.GetSharedInstance.
public override IEnumerable GetInspectTabs()
{
return inspectTabs ??= new[] { InspectTabManager.GetSharedInstance(typeof(ITab_Delivery)) };
}
/// The base zone gizmos plus copy and paste of the zone's settings (DeliveryClipboard).
public override IEnumerable GetGizmos()
{
foreach (Gizmo g in base.GetGizmos())
yield return g;
yield return new Command_Action
{
icon = CopyIcon,
defaultLabel = "BlaxZones_CopySettings".Translate(),
defaultDesc = "BlaxZones_CopySettingsDesc".Translate(),
hotKey = KeyBindingDefOf.Misc4,
action = () =>
{
SoundDefOf.Tick_High.PlayOneShotOnCamera();
DeliveryClipboard.Copy(this);
Messages.Message("BlaxZones_SettingsCopied".Translate(), MessageTypeDefOf.NeutralEvent, historical: false);
},
};
var paste = new Command_Action
{
icon = PasteIcon,
defaultLabel = "BlaxZones_PasteSettings".Translate(),
defaultDesc = "BlaxZones_PasteSettingsDesc".Translate(),
hotKey = KeyBindingDefOf.Misc5,
action = () =>
{
SoundDefOf.Tick_High.PlayOneShotOnCamera();
DeliveryClipboard.PasteInto(this);
Messages.Message("BlaxZones_SettingsPasted".Translate(), MessageTypeDefOf.NeutralEvent, historical: false);
},
};
if (!DeliveryClipboard.HasCopy)
paste.Disable("BlaxZones_NothingCopied".Translate());
yield return paste;
}
}
}