Skip to content

Commit

Permalink
Fix wrong cell prefab being used
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoco007 committed Feb 23, 2024
1 parent 34c0a7a commit a465fbe
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions BeatSaberMarkupLanguage/Components/CustomListTableData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class CustomListTableData : MonoBehaviour, TableView.IDataSource

public bool expandCell = false;

private LevelListTableCell songListTableCellInstance;
private LevelPackCell levelPackTableCellInstance;
private SimpleTextTableCell simpleTextTableCellInstance;
private LevelListTableCell songListTableCellPrefab;
private LevelPackCell levelPackTableCellPrefab;
private SimpleTextTableCell simpleTextTableCellPrefab;
private ListStyle listStyle = ListStyle.List;

public enum ListStyle
Expand Down Expand Up @@ -57,12 +57,12 @@ public LevelListTableCell GetTableCell()
LevelListTableCell tableCell = (LevelListTableCell)tableView.DequeueReusableCellForIdentifier(reuseIdentifier);
if (!tableCell)
{
if (songListTableCellInstance == null)
if (songListTableCellPrefab == null)
{
songListTableCellInstance = Resources.FindObjectsOfTypeAll<LevelListTableCell>().Where(x => x.name == "LevelListTableCell").First();
songListTableCellPrefab = BeatSaberUI.DiContainer.Resolve<LevelCollectionViewController>().GetComponentInChildren<LevelCollectionTableView>()._levelCellPrefab;
}

tableCell = Instantiate(songListTableCellInstance);
tableCell = Instantiate(songListTableCellPrefab);
}

tableCell._notOwned = false;
Expand All @@ -76,12 +76,12 @@ public BSMLBoxTableCell GetBoxTableCell()
BSMLBoxTableCell tableCell = (BSMLBoxTableCell)tableView.DequeueReusableCellForIdentifier(reuseIdentifier);
if (!tableCell)
{
if (levelPackTableCellInstance == null)
if (levelPackTableCellPrefab == null)
{
levelPackTableCellInstance = Resources.FindObjectsOfTypeAll<LevelPackCell>().Where(x => x.name == "AnnotatedBeatmapLevelCollectionCell").First();
levelPackTableCellPrefab = BeatSaberUI.DiContainer.Resolve<AnnotatedBeatmapLevelCollectionsViewController>().GetComponentInChildren<AnnotatedBeatmapLevelCollectionsGridView>()._cellPrefab;
}

tableCell = InstantiateBoxTableCell(levelPackTableCellInstance);
tableCell = InstantiateBoxTableCell(levelPackTableCellPrefab);
}

tableCell.name = nameof(BSMLBoxTableCell);
Expand Down Expand Up @@ -118,12 +118,12 @@ public SimpleTextTableCell GetSimpleTextTableCell()
SimpleTextTableCell tableCell = (SimpleTextTableCell)tableView.DequeueReusableCellForIdentifier(reuseIdentifier);
if (!tableCell)
{
if (simpleTextTableCellInstance == null)
if (simpleTextTableCellPrefab == null)
{
simpleTextTableCellInstance = Resources.FindObjectsOfTypeAll<SimpleTextTableCell>().Where(x => x.name == "SimpleTextTableCell").First();
simpleTextTableCellPrefab = BeatSaberUI.DiContainer.Resolve<PlayerOptionsViewController>().GetComponentInChildren<SimpleTextDropdown>()._cellPrefab;
}

tableCell = Instantiate(simpleTextTableCellInstance);
tableCell = Instantiate(simpleTextTableCellPrefab);
}

tableCell.name = $"BSML{nameof(SimpleTextTableCell)}";
Expand Down Expand Up @@ -184,13 +184,6 @@ public int NumberOfCells()
return data.Count();
}

private void OnDestroy()
{
Destroy(songListTableCellInstance);
Destroy(levelPackTableCellInstance);
Destroy(simpleTextTableCellInstance);
}

public class CustomCellInfo
{
public string text;
Expand Down

0 comments on commit a465fbe

Please sign in to comment.