Data Tables
by
tzainten
| Summary | A prototype inspired by Data Tables from Unreal Engine |
|---|---|
| Description |
How to Use Data Tables provides you with a custom resource type that holds a list of data entries. You can then easily query data from this resource in C#. You define your Data Structure in C# like so: public class ExampleStruct : RowStruct { public string Text { get; set; } public Dictionary<string, SoundEvent> Sounds { get; set; } public List<string> Strings { get; set; } } And then query data from a Data Table like this: ExampleStruct Struct = Table.Get<ExampleStruct>( "NewEntry_0" ); Log.Info( Struct.Text ); When you make a change to your Data Table, those changes will be reflected in-game immediately after you save the file. [Image] Custom Attributes The [JsonTypeAnnotate] attribute will tell the serializer to also store this property's type, allowing for this property to be properly deserialized later. Combining the above attribute with the [Instanced] attribute provides you with a dropdown in the editor. You can now select any class that inherits from the property's type. public class BaseClass {} public class A : BaseClass { public int Integer { get; set; } } public class B : BaseClass { public bool Boolean { get; set; } } public class ExampleStruct : RowStruct { [JsonTypeAnnotate, Instanced] public List<BaseClass> List; } [Image] Report Issues If you encounter a bug or you want something added, your options are: • Submit a Bug Report / Feature Request right here on sbox.game • Submit an issue @ https://github.com/tzainten/DataTables/issues • I'm in the s&box Discord @tzaintenHow to Use
Data Tables provides you with a custom resource type that holds a list of data entries. You can then easily query data from this resource in C#.
You define your Data Structure in C# like so:
public class ExampleStruct : RowStruct
{
public string Text { get; set; }
public Dictionary<string, SoundEvent> Sounds { get; set; }
public List<string> Strings { get; set; }
}
And then query data from a Data Table like this:
ExampleStruct Struct = Table.Get<ExampleStruct>( "NewEntry_0" );
Log.Info( Struct.Text );
When you make a change to your Data Table, those changes will be reflected in-game immediately after you save the file.
[Image]
Custom Attributes
The [JsonTypeAnnotate] attribute will tell the serializer to also store this property's type, allowing for this property to be properly deserialized later.
Combining the above attribute with the [Instanced] attribute provides you with a dropdown in the editor. You can now select any class that inherits from the property's type.
public class BaseClass {}
public class A : BaseClass
{
public int Integer { get; set; }
}
public class B : BaseClass
{
public bool Boolean { get; set; }
}
public class ExampleStruct : RowStruct
{
[JsonTypeAnnotate, Instanced]
public List<BaseClass> List;
}
[Image]
Report Issues
If you encounter a bug or you want something added, your options are:
• Submit a Bug Report / Feature Request right here on sbox.game
• Submit an issue @ https://github.com/tzainten/DataTables/issues
• I'm in the s&box Discord @tzainten
|
| Votes | 👍9 👎1 ❤️4 |
| Error Rate | 0% |
| Data | {} |
| Version | Created | Size (modified) | Files | Changes |
|---|---|---|---|---|
| 84092 | 107.7 KB (15.5 KB) | 30 ~3 | These control widgets should also only show with if both JsonTypeAnnotate and Instanced are present | |
| 84090 | 107.6 KB (42.4 KB) | 30 ~4 | Changes on 2025-01-13 | |
| 83899 | 106.9 KB (11 KB) | 30 ~2 | Changes on 2025-01-11 | |
| 83896 | 107 KB (19.1 KB) | 30 ~3 -1 | Use ListView.Update instead of adding a dummy widget and then removing it | |
| 83871 | 108.9 KB (7.7 KB) | 31 ~2 | Changes on 2025-01-10 | |
| 83868 | 109 KB (53.7 KB) | 31 ~5 | Add TypeLibrary.GetFieldsAndProperties and move WeakTable into DataTable | |
| 83825 | 109.9 KB (52.4 KB) | 31 ~5 | Actually, I think this is a better way to support both fields and properties. Totally won't revert this later! | |
| 83823 | 106 KB (37.6 KB) | 31 ~4 | We now officially only support properties! Fields will NOT show up in the Control Sheet! | |
| 83821 | 106.7 KB (30.3 KB) | 31 ~2 | Keep a WeakReference to all of our structs. This *should* let us safely remove Restricted mode. Fingers crossed! | |
| 83820 | 106.1 KB (23.8 KB) | 31 ~4 | Fields should now be supported? | |
| 83816 | 105.1 KB (16.7 KB) | 31 ~3 | Fix a bug in MergeDictionary/MergeList where some types didn't merge correctly | |
| 83801 | 104.7 KB (22.3 KB) | 31 ~3 | Only support properties that have public get/set methods | |
| 83798 | 104.8 KB (15.9 KB) | 31 +1 ~4 | Separate JsonTypeAnnotateAttribute and InstancedAttribute | |
| 83796 | 104.6 KB (42.6 KB) | 30 ~4 | Add a context menu to the Table View | |
| 83762 | 103 KB (28.4 KB) | 30 ~2 | Attempt to restore the ControlSheet when restoring EditorState | |
| 83756 | 102.7 KB (28.1 KB) | 30 ~2 | Use Insert instead of Add to preserve the index in the List | |
| 83755 | 102.5 KB (27.9 KB) | 30 ~2 | Clear the ControlSheet before calling UpdateViewAndEditor | |
| 83753 | 102.4 KB (30.3 KB) | 30 ~3 | Call DataTable.Fix() when opening the editor | |
| 83751 | 102.4 KB (30.7 KB) | 30 ~3 | Save EntryCount in EditorState | |
| 83749 | 102.2 KB (44.9 KB) | 30 ~4 | Improve Json.DeserializeDictionary logic | |
| 83737 | 101.1 KB (27.5 KB) | 30 ~2 | Do the same thing for the Tool Bar | |
| 83736 | 101 KB (27.5 KB) | 30 ~2 | Use the same icons that Editor.EditorMainWindow uses | |
| 83729 | 101.1 KB (60.2 KB) | 30 +1 ~8 | Changes on 2025-01-08 | |
| 83625 | 93 KB (12.8 KB) | 29 +1 ~1 -1 | Rename TypeLibraryHelperExtensions | |
| 83621 | 93 KB (51.8 KB) | 29 ~9 -2 | Rename InstancedAttribute to JsonTypeAnnotateAttribute | |
| 83582 | 100.9 KB (25.2 KB) | 31 ~4 | Fix ValueTypes not Cloning properly | |
| 83580 | 100.6 KB (44.6 KB) | 31 ~5 | Resource properties should now serialize properly (fingers crossed!) | |
| 83508 | 99.5 KB (61.1 KB) | 31 +5 ~6 -3 | Changes to the Data Table should now merge only when saving | |
| 83287 | 75.9 KB (4.4 KB) | 29 ~2 | Don't log the icon when painting | |
| 83283 | 75.9 KB (13.5 KB) | 29 ~4 | Improve the styling for Struct Types in the launcher | |
| 83274 | 75.7 KB (17.3 KB) | 29 ~2 | Save the editor's layout between sessions | |
| 83270 | 75.5 KB (17.2 KB) | 29 ~2 | Hotfix | |
| 83269 | 75.5 KB (19.7 KB) | 29 ~4 | Switched to using DockManager. UI is now much more consistent with other tools | |
| 83265 | 74.5 KB (46.1 KB) | 29 +3 ~7 | Changes on 2025-01-04 | |
| 82726 | 67.5 KB (14.8 KB) | 26 ~3 | Changes on 2024-12-31 | |
| 82510 | 66.3 KB (26.4 KB) | 26 +1 ~5 | Only use our custom serialization for StructEntries. Let s&box handle the rest! | |
| 81731 | 65 KB (5.2 KB) | 25 ~2 | Remove <T> from DataTable.Add | |
| 81712 | 65 KB (15.6 KB) | 25 ~4 | References should be working now | |
| 81711 | 65 KB (6.3 KB) | 25 +1 ~2 | Add DataTable.Add<T> | |
| 81705 | 63.5 KB (23.6 KB) | 24 +1 ~5 | Add a closing dialog to prevent losing unsaved changes | |
| 81703 | 60.8 KB (11.8 KB) | 23 ~2 | Add an indicator when changes haven't been saved | |
| 81648 | 60.2 KB (21.5 KB) | 23 +1 ~5 | Enabled MultiSelect | |
| 81620 | 56.7 KB (9 KB) | 22 ~2 | Changes on 2024-12-18 | |
| 81585 | 56.6 KB (20.2 KB) | 22 +1 ~4 | Changes on 2024-12-18 | |
| 81572 | 55.8 KB (4.3 KB) | 21 ~2 | Changes on 2024-12-18 | |
| 81570 | 55.8 KB (12.7 KB) | 21 ~3 | Changes on 2024-12-18 | |
| 81568 | 55.7 KB | 21 +21 | Changes on 2024-12-18 |
Loading history…