private void UpdateDisplay(BasePlayer player, string oldKey)
{
using CUI cui = new CUI(CuiHandler);
CUI.Handler.UpdatePool elements = cui.UpdatePool();
string currEvent = cachedSelectedEvent[player.userID];
//Event Button - New Selected
elements.Add(cui.UpdateProtectedButton($"MeteorEventUI_eventButton_{currEvent}", BetterColors.GreenBackgroundTransparent, BetterColors.Transparent, "", 1, command: ""));
//Event Button Text - New Selected
elements.Add(cui.UpdateText($"MeteorEventUI_eventButton_{currEvent}_text", BetterColors.GreenText, Lang($"EventName_{currEvent}", player.UserIDString), 11, align: TextAnchor.MiddleLeft));
//Event Button - Old Selected
elements.Add(cui.UpdateProtectedButton($"MeteorEventUI_eventButton_{oldKey}", BetterColors.Transparent, BetterColors.Transparent, "", 1, command: $"UI_MeteorEvent switch {oldKey}"));
//Event Button Text - Old Selected
elements.Add(cui.UpdateText($"MeteorEventUI_eventButton_{oldKey}_text", BetterColors.LightGray, Lang($"EventName_{oldKey}", player.UserIDString), 11, align: TextAnchor.MiddleLeft));
//Event Name
elements.Add(cui.UpdateText("MeteorEventUI_eventName", BetterColors.LightGray, Lang($"EventName_{currEvent}", player.UserIDString), 16, align: TextAnchor.MiddleLeft, font: CUI.Handler.FontTypes.RobotoCondensedBold));
//Event Description
elements.Add(cui.UpdateText("MeteorEventUI_eventDescription", BetterColors.LightGrayTransparent73, Lang($"EventDescription_{currEvent}", player.UserIDString), 8, align: TextAnchor.UpperLeft));
MeteorConfig configValue = config.profiles[currEvent];
//Cooldown Amount
elements.Add(cui.UpdateText("MeteorEventUI_cooldownAmount", BetterColors.LightGrayTransparent73, FormatTime(configValue.purchaseConfig.showerCooldown), 10));
//Meteor Amount Text
elements.Add(cui.UpdateText("MeteorEventUI_meteorAmount", BetterColors.LightGrayTransparent73, configValue.purchaseConfig.showerMeteorAmount.ToString(), 10));
bool hasRequiredItem;
if (configValue.purchaseConfig.requiredShortname == "")
hasRequiredItem = HaveCurrency(player, configValue.purchaseConfig.economyPlugin, configValue.purchaseConfig.economyCurrency) >= configValue.purchaseConfig.showerItemAmount;
else
{
int itemAmount = 0;
foreach (var item in player.inventory.AllItems())
if (item.info.shortname == configValue.purchaseConfig.requiredShortname && item.skin == configValue.purchaseConfig.requiredSkin)
itemAmount += item.amount;
hasRequiredItem = itemAmount >= configValue.purchaseConfig.showerItemAmount;
}
string textColor = hasRequiredItem ? BetterColors.LightGrayTransparent73 : BetterColors.RedText;
//Requirement Text
elements.Add(cui.UpdateText("MeteorEventUI_requirementsText", textColor, Lang($"ItemRequirement_{currEvent}", player.UserIDString, configValue.purchaseConfig.showerItemAmount), 12, align: TextAnchor.MiddleLeft));
if (permission.UserHasPermission(player.UserIDString, "meteorevent.admin"))
{
//Admin Spawn Input
var inputField = cui.UpdateProtectedInputField("MeteorEventUI_adminSetInput", BetterColors.RedText, "0", 15, 3, false, align: TextAnchor.MiddleCenter, font: CUI.Handler.FontTypes.RobotoCondensedBold, command: $"UI_MeteorEvent forceStart {currEvent}", lineType: InputField.LineType.MultiLineSubmit);
elements.Add(inputField);
}
bool onCooldown = cooldowns.ContainsKey(player.userID) && cooldowns[player.userID].ContainsKey(currEvent);
string bottomText;
if (!hasRequiredItem)
bottomText = Lang("NoRequiredItems", player.UserIDString);
else if (onCooldown)
bottomText = Lang("EventOnCooldown", player.UserIDString, FormatTime(cooldowns[player.userID][currEvent]));
else
bottomText = Lang("CanStartEventInfo", player.UserIDString);
bool locked = !hasRequiredItem || onCooldown;
string buttonColor = locked ? BetterColors.RedBackgroundTransparent : BetterColors.GreenBackgroundTransparent;
string buttonTextColor = locked ? BetterColors.RedText : BetterColors.GreenText;
string buttonTextText = locked ? Lang("EventLocked", player.UserIDString) : Lang("RunEvent", player.UserIDString);
string command = locked ? "" : $"UI_MeteorEvent start {currEvent}";
//Info Text
elements.Add(cui.UpdateText("MeteorEventUI_bottomInfoText", BetterColors.LightGrayTransparent73, bottomText, 7, align: TextAnchor.MiddleLeft, font: CUI.Handler.FontTypes.RobotoCondensedBold));
//Run Button
elements.Add(cui.UpdateProtectedButton("MeteorEventUI_runButton", buttonColor, BetterColors.Transparent, "", 15, command: command));
elements.Add(cui.UpdateText("MeteorEventUI_runButtonText", buttonTextColor, buttonTextText, 15, font: CUI.Handler.FontTypes.RobotoCondensedBold));
elements.Send(player);
}