- Bring text to text buttons (not fully working)
- Refactoring of unity element creation - copy Vocaluxe.UI.dll to unity assets automatically
This commit is contained in:
1 parent
4373f82935
commit
c6d221d6c0
8 files changed
+21
-149
No files matched your search
@@ -10,7 +10,10 @@ namespace Vocaluxe.UI.BasicElements.Text
|
||||
|
||||
public static CUiElementText CreateInstance(Dictionary<string, string> properties, IEnumerable<(CUiElement uiElement, string bindingId)> children)
|
||||
{
|
||||
return CUiElement.CreateInstance<CUiElementText>(properties, children);
|
||||
var instance = CUiElement.CreateInstance<CUiElementText>(properties, children);
|
||||
properties.TryGetValue("value", out string value);
|
||||
instance.Controller.Text = value;
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,47 +8,6 @@ namespace Vocaluxe.UI.Parser
|
||||
{
|
||||
public static class CUiScreenParser
|
||||
{
|
||||
public static CUiScreen ParseOld(string path)
|
||||
{
|
||||
if(!File.Exists(path))
|
||||
throw new FileNotFoundException(path);
|
||||
|
||||
using (XmlReader reader = XmlReader.Create(path, new XmlReaderSettings { IgnoreWhitespace = true }))
|
||||
{
|
||||
return _ParseElementOld(reader)[0].Item1 as CUiScreen ?? throw new ArgumentException("First node must be a screen element");
|
||||
}
|
||||
}
|
||||
|
||||
private static List<(CUiElement uiElement, string bindingId)> _ParseElementOld(XmlReader reader)
|
||||
{
|
||||
List<(CUiElement, string)> elementList = new List<(CUiElement uiElement, string bindingId)>();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
continue;
|
||||
|
||||
string elementName = reader.Name;
|
||||
|
||||
var subtreeReader = reader.ReadSubtree();
|
||||
subtreeReader.Read();
|
||||
List<(CUiElement uiElement, string bindingId)> childElements = _ParseElementOld(subtreeReader);
|
||||
|
||||
Dictionary<string, string> attributes = new Dictionary<string, string>();
|
||||
for (var attrIndex = 0; attrIndex < reader.AttributeCount; attrIndex++)
|
||||
{
|
||||
reader.MoveToAttribute(attrIndex);
|
||||
attributes.Add(reader.Name, reader.Value);
|
||||
}
|
||||
|
||||
attributes.TryGetValue("bindingId", out string bindingId);
|
||||
elementList.Add((CUiElementFactory.CreateElement(elementName, attributes, childElements), bindingId));
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
return elementList;
|
||||
}
|
||||
|
||||
public static CUiScreen Parse(string path)
|
||||
{
|
||||
if (!File.Exists(path))
|
||||
@@ -68,12 +27,18 @@ namespace Vocaluxe.UI.Parser
|
||||
return resultElement;
|
||||
|
||||
List<(CUiElement uiElement, string bindingId)> childElements = new List<(CUiElement uiElement, string bindingId)>();
|
||||
foreach (XmlElement childNode in node.ChildNodes)
|
||||
Dictionary<string, string> attributes = new Dictionary<string, string>();
|
||||
foreach (XmlNode childNode in node.ChildNodes)
|
||||
{
|
||||
childElements.Add(_ParseElement(childNode));
|
||||
if(!(childNode is XmlElement))
|
||||
{
|
||||
attributes.Add("value", childNode.Value);
|
||||
continue;
|
||||
}
|
||||
childElements.Add(_ParseElement((XmlElement)childNode));
|
||||
}
|
||||
|
||||
Dictionary<string, string> attributes = new Dictionary<string, string>();
|
||||
|
||||
foreach (XmlAttribute attribute in node.Attributes)
|
||||
{
|
||||
attributes.Add(attribute.Name, attribute.Value);
|
||||
|
||||
@@ -119,4 +119,8 @@
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\packages\Facebook.Yoga.1.5.0-pre1\build\net45\Facebook.Yoga.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Facebook.Yoga.1.5.0-pre1\build\net45\Facebook.Yoga.targets'))" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>copy /Y "$(TargetDir)$(ProjectName).dll" "$(SolutionDir)Vocaluxe.UI.Unity\Assets\$(ProjectName).dll"
|
||||
copy /Y "$(TargetDir)$(ProjectName).pdb" "$(SolutionDir)Vocaluxe.UI.Unity\Assets\$(ProjectName).pdb"</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in new issue
Block a user