Just playing around with yoga and unity to see if we could build a ui with it
This commit is contained in:
1 parent
15d5b17fd2
commit
6ad1cd7aa8
60 files changed
+3930
-3
No files matched your search
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Vocaluxe.UI.AbstractElements;
|
||||
|
||||
namespace Vocaluxe.UI
|
||||
{
|
||||
public static class CUiElementFactory
|
||||
{
|
||||
private delegate CUiElement CreateElementDelgate(Dictionary<string, string> properties, IEnumerable<(CUiElement uiElement, string bindingId)> children);
|
||||
|
||||
private static readonly Dictionary<string, CreateElementDelgate> _Mapping = new Dictionary<string, CreateElementDelgate>()
|
||||
{
|
||||
{"screenmain", Screens.ScreenMain.CUiScreenMain.CreateInstance},
|
||||
{"button", BasicElements.Button.CUiElementButton.CreateInstance},
|
||||
{"text", BasicElements.Text.CUiElementText.CreateInstance}
|
||||
};
|
||||
|
||||
public static CUiElement CreateElement(string type, Dictionary<string, string> properties, IEnumerable<(CUiElement uiElement, string bindingId)> children)
|
||||
{
|
||||
_Mapping.TryGetValue(type.ToLower(), out var factoryFunction);
|
||||
|
||||
if (factoryFunction == null)
|
||||
{
|
||||
throw new ArgumentException("The given id does not match any known element type");
|
||||
}
|
||||
|
||||
return factoryFunction(properties, children);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user