This commit is contained in:
2025-08-18 09:22:24 +08:00
commit cef5623ab0
1333 changed files with 305844 additions and 0 deletions
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 41e1a65c7b96d03498c2b6c910ff6748
folderAsset: yes
timeCreated: 1606210561
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 57ccde6a849ccca4188519c929e776d2
folderAsset: yes
timeCreated: 1606210561
licenseType: Store
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
namespace Com.ForbiddenByte.OSA.CustomAdapters.GridView.Specialized.GridWithCategories
{
public enum CellType
{
VALID,
FOR_ROW_COMPLETION,
IN_ROW_SEPARATING_CATEGORIES
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: dae9c5a81d044ef408cbf2496982fed3
timeCreated: 1606210561
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
namespace Com.ForbiddenByte.OSA.CustomAdapters.GridView.Specialized.GridWithCategories
{
public class GridWithCategoriesUtil
{
static T CreateItemModelForRowCompletion<T>(ICategoryModel parentCategory) where T : ICellModel, new()
{
return new T
{
ParentCategory = parentCategory,
Id = -1,
Type = CellType.FOR_ROW_COMPLETION
};
}
static T CreateItemModelInRowSeparatingCategories<T>(ICategoryModel parentCategory) where T : ICellModel, new()
{
return new T
{
ParentCategory = parentCategory,
Id = -1,
Type = CellType.IN_ROW_SEPARATING_CATEGORIES
};
}
/// <summary>
/// Converts your user-level data structure to an OSA Grid-compatible list of items, which will also include "filler" items for the spaces between the categories and empty spaces.
/// This approach has the advantage of reusing the OSA's GridAdapter completely, at the expense of creating/managing few additional items at the user-level
/// </summary>
public static void ConvertCategoriesToListOfItemModels<TCategory, TCell>(int itemSlotsPerRow, List<TCategory> categories, out List<TCell> cells)
where TCategory : ICategoryModel
where TCell : ICellModel, new()
{
cells = new List<TCell>();
for (int i = 0; i < categories.Count; i++)
{
var cat = categories[i];
// Insert an empty row of items to make room for the category's header
for (int j = 0; j < itemSlotsPerRow; j++)
{
var m = CreateItemModelInRowSeparatingCategories<TCell>(cat);
cells.Add(m);
}
// Add the actual cells
for (int j = 0; j < cat.Count; j++)
cells.Add((TCell)cat[j]);
// If the category's last row is not full, fill it with empty slots, so they won't be occupied with the ones from the next category
while (cells.Count % itemSlotsPerRow != 0)
cells.Add(CreateItemModelForRowCompletion<TCell>(cat));
}
}
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 3015ac1d7f1fd374ca2280b1b3196003
timeCreated: 1606210561
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
namespace Com.ForbiddenByte.OSA.CustomAdapters.GridView.Specialized.GridWithCategories
{
public interface ICategoryModel
{
int Count { get; }
ICellModel this[int index] { get; }
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 486ee90ba4b16014ebe95094ecde8c98
timeCreated: 1606210561
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
namespace Com.ForbiddenByte.OSA.CustomAdapters.GridView.Specialized.GridWithCategories
{
public interface ICellModel
{
ICategoryModel ParentCategory { get; set; }
int Id { get; set; }
CellType Type { get; set; }
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 0167959a452670147a41bbac4d2b6cc7
timeCreated: 1606210561
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: