Skip to content

Commit

Permalink
Remove TooltipGetter
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed Oct 15, 2024
1 parent eeb819b commit 642fd63
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 77 deletions.
6 changes: 1 addition & 5 deletions Fika.Core/UI/Custom/MainMenuUIScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,9 @@ private void SetupPlayers(ref FikaPlayerPresence[] responses)
{
RaidInformation information = presence.RaidInformation.Value;
string side = information.Side == EFT.ESideType.Pmc ? "PMC" : "Scav";
TooltipTextGetter tooltipTextGetter = new()
{
TooltipText = $"Playing as a {side} on {ColorUtils.ColorizeText(Colors.BLUE, information.Location.Localized())}"
};
HoverTooltipArea tooltip = newPlayer.AddComponent<HoverTooltipArea>();
tooltip.enabled = true;
tooltip.SetMessageText(tooltipTextGetter.GetText);
tooltip.SetMessageText($"Playing as a {side} on {ColorUtils.ColorizeText(Colors.BLUE, information.Location.Localized())}");
}
newPlayer.SetActive(true);
players.Add(newPlayer);
Expand Down
73 changes: 11 additions & 62 deletions Fika.Core/UI/Custom/MatchMakerUIScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,9 @@ private void CreateMatchMakerUI()
dedicatedText.color = new(1f, 1f, 1f, 0.5f);
}

TooltipTextGetter dediTooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_NO_DEDICATED_CLIENTS.Localized()
};

HoverTooltipArea dediTooltipArea = fikaMatchMakerUi.DedicatedToggle.GetOrAddComponent<HoverTooltipArea>();
dediTooltipArea.enabled = true;
dediTooltipArea.SetMessageText(dediTooltipTextGetter.GetText);
dediTooltipArea.SetMessageText(LocaleUtils.UI_NO_DEDICATED_CLIENTS.Localized());
}

TMP_Text matchmakerUiHostRaidText = fikaMatchMakerUi.RaidGroupHostButton.GetComponentInChildren<TMP_Text>();
Expand Down Expand Up @@ -324,14 +319,9 @@ private void CreateMatchMakerUI()

fikaMatchMakerUi.RefreshButton.onClick.AddListener(ManualRefresh);

TooltipTextGetter tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_REFRESH_RAIDS.Localized()
};

HoverTooltipArea tooltipArea = fikaMatchMakerUi.RefreshButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_REFRESH_RAIDS.Localized());

acceptButton.gameObject.SetActive(false);
acceptButton.enabled = false;
Expand Down Expand Up @@ -572,18 +562,11 @@ private void RefreshUI()
}, localPlayerInRaid));
});

TooltipTextGetter tooltipTextGetter;
HoverTooltipArea tooltipArea;
Image image = server.GetComponent<Image>();

if (raidSettings.LocationId != entry.Location && !(raidSettings.LocationId.ToLower().StartsWith("sandbox") && entry.Location.ToLower().StartsWith("sandbox")))
{
tooltipTextGetter = new()
{
TooltipText = string.Format(LocaleUtils.UI_CANNOT_JOIN_RAID_OTHER_MAP.Localized(),
ColorUtils.ColorizeText(Colors.BLUE, entry.Location.Localized()))
};

button.enabled = false;
if (image != null)
{
Expand All @@ -592,18 +575,14 @@ private void RefreshUI()

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(string.Format(LocaleUtils.UI_CANNOT_JOIN_RAID_OTHER_MAP.Localized(),
ColorUtils.ColorizeText(Colors.BLUE, entry.Location.Localized())));

continue;
}

if (raidSettings.SelectedDateTime != entry.Time)
{
tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_CANNOT_JOIN_RAID_OTHER_TIME.Localized()
};

button.enabled = false;
if (image != null)
{
Expand All @@ -612,7 +591,7 @@ private void RefreshUI()

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_CANNOT_JOIN_RAID_OTHER_TIME.Localized());

continue;
}
Expand All @@ -629,11 +608,6 @@ private void RefreshUI()
errorText = LocaleUtils.UI_CANNOT_JOIN_RAID_PMC_AS_SCAV.Localized();
}

tooltipTextGetter = new()
{
TooltipText = errorText
};

button.enabled = false;
if (image != null)
{
Expand All @@ -642,7 +616,7 @@ private void RefreshUI()

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(errorText);

continue;
}
Expand All @@ -651,11 +625,6 @@ private void RefreshUI()
{
case LobbyEntry.ELobbyStatus.LOADING:
{
tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_HOST_STILL_LOADING.Localized()
};

button.enabled = false;
if (image != null)
{
Expand All @@ -664,17 +633,12 @@ private void RefreshUI()

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_HOST_STILL_LOADING.Localized());
}
break;
case LobbyEntry.ELobbyStatus.IN_GAME:
if (!localPlayerInRaid)
{
tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_RAID_IN_PROGRESS.Localized()
};

button.enabled = false;
if (image != null)
{
Expand All @@ -683,28 +647,18 @@ private void RefreshUI()

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_RAID_IN_PROGRESS.Localized());
}
else
{
if (!localPlayerDead)
{
tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_REJOIN_RAID.Localized()
};

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_REJOIN_RAID.Localized());
}
else
{
tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_CANNOT_REJOIN_RAID_DIED.Localized()
};

button.enabled = false;
if (image != null)
{
Expand All @@ -713,19 +667,14 @@ private void RefreshUI()

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_CANNOT_REJOIN_RAID_DIED.Localized());
}
}
break;
case LobbyEntry.ELobbyStatus.COMPLETE:
tooltipTextGetter = new()
{
TooltipText = LocaleUtils.UI_JOIN_RAID.Localized()
};

tooltipArea = joinButton.GetOrAddComponent<HoverTooltipArea>();
tooltipArea.enabled = true;
tooltipArea.SetMessageText(tooltipTextGetter.GetText);
tooltipArea.SetMessageText(LocaleUtils.UI_JOIN_RAID.Localized());
break;
default:
break;
Expand Down
10 changes: 0 additions & 10 deletions Fika.Core/UI/FikaUIUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ public static GClass3388 ShowFikaMessage(this ErrorScreen errorScreen, string ti
return errorScreenHandler.context;
}

public class TooltipTextGetter
{
public string GetText()
{
return TooltipText;
}

public string TooltipText;
}

public enum EFikaRaidPresence
{
IN_MENU,
Expand Down

0 comments on commit 642fd63

Please sign in to comment.