Skip to content

Commit

Permalink
remove old diff spawning method (i am free)
Browse files Browse the repository at this point in the history
  • Loading branch information
legoandmars committed Feb 10, 2024
1 parent 7fb4415 commit fab292a
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions LobbyCompatibility/Features/UIHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,78 +244,6 @@ public static void ClearSpawnedDiffSlots(
existingPluginCategorySlots.Clear();
}

/// <summary>
/// Creates a list of <see cref="TextMeshProUGUI" /> from a <see cref="LobbyDiff" />'s plugins
/// </summary>
/// <param name="lobbyDiff"> The <see cref="LobbyDiff" /> to generate text from. </param>
/// <param name="textTemplate"> The <see cref="TextMeshProUGUI" /> to use for the mod text. </param>
/// <param name="headerTextTemplate"> The <see cref="TextMeshProUGUI" /> to use for the category header text. </param>
/// <param name="textSpacing"> The amount of spacing around mod text. </param>
/// <param name="headerSpacing"> The amount of padding around category header text. </param>
/// <param name="startPadding"> The amount of padding to start with. </param>
/// <param name="compactText"> Whether to remove versions from mod names. </param>
/// <param name="maxLines"> The maximum amount of total text lines to generate. </param>
/// <returns> The <see cref="TextMeshProUGUI" /> list, the total UI length, and the amount of plugins used in generation. </returns>
public static (List<TextMeshProUGUI>, float, int) GenerateTextFromDiff(
LobbyDiff lobbyDiff,
TextMeshProUGUI textTemplate,
TextMeshProUGUI headerTextTemplate,
float textSpacing,
float headerSpacing,
float? startPadding = null,
bool compactText = false,
int? maxLines = null)
{
// TODO: Replace with pooling if we need the performance from rapid scrolling
// TODO: Replace this return type with an actual type lol. Need to refactor this a bit

List<TextMeshProUGUI> generatedText = new();
var padding = startPadding ?? 0f;
var lines = 0;
var pluginLines = 0;

foreach (var compatibilityResult in Enum.GetValues(typeof(PluginDiffResult)).Cast<PluginDiffResult>())
{
var plugins = lobbyDiff.PluginDiffs.Where(
pluginDiff => pluginDiff.PluginDiffResult == compatibilityResult).ToList();

if (plugins.Count == 0)
continue;

// adds a few units of extra header padding
padding += headerSpacing - textSpacing;

// end linecount sooner if we're about to create a header - no point in showing a blank header
if (maxLines != null && lines > maxLines - 1)
break;

// Create the category header
var headerText = CreateTextFromTemplate(headerTextTemplate,
LobbyHelper.GetCompatibilityHeader(compatibilityResult) + ":", -padding);

generatedText.Add(headerText);
padding += headerSpacing;
lines++;

// Add each plugin
foreach (var plugin in plugins)
{
if (lines > maxLines)
break;

var modText = CreateTextFromTemplate(textTemplate, compactText ? plugin.GUID : plugin.GetDisplayText(),
-padding, plugin.GetTextColor());
modText.richText = false; // Disable rich text to avoid people injecting weird text into the modlist
generatedText.Add(modText);
padding += textSpacing;
lines++;
pluginLines++;
}
}

return (generatedText, padding, pluginLines);
}

public static void AddVerticalLayoutGroup(GameObject gameObject, bool addContentSizeFitter = true)
{
// Setup ContentSizeFilter and VerticalLayoutGroup so elements are automagically spaced
Expand Down

0 comments on commit fab292a

Please sign in to comment.