-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df8531f
commit d51cbbf
Showing
8 changed files
with
108 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
ReUI.Implementation/Systems/AttributeSystems/UpdateElementParentSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using Rentitas; | ||
using ReUI.Api; | ||
using UnityEngine; | ||
|
||
namespace ReUI.Implementation | ||
{ | ||
public class UpdateElementParentSystem : AbstractAttributeUpdateSystem | ||
{ | ||
protected Pool<IUIPool> UIPool; | ||
|
||
protected override Type[] EnsureTypes => new[] {typeof (ChildrenType), typeof (Ready)}; | ||
protected override Type[] AttributeTypes => new[] {typeof (Parent)}; | ||
|
||
protected override void SetupAttribute(Entity<IUIPool> uiEntity, IView view, GameObject go) | ||
{ | ||
Debug.Log($"Update parent for {uiEntity.GetAttribute<Name, string>()}"); | ||
var parentId = uiEntity.Get<Parent>().Id; | ||
var parent = UIPool.GetElement(parentId); | ||
var parentView = ViewPool.GetByIdentity(parent.Get<ViewLink>().Id); | ||
view.SetParent(parentView); | ||
} | ||
|
||
public override void SetPool(Pool<IUIPool> pool) | ||
{ | ||
UIPool = pool; | ||
base.SetPool(pool); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
ReUI.Implementation/Systems/XmlSystems/ReadAttributesSystems/SetupNestedHierarchySystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System; | ||
using System.Linq; | ||
using Rentitas; | ||
using ReUI.Api; | ||
|
||
namespace ReUI.Implementation.Systems | ||
{ | ||
public class SetupNestedHierarchySystem : AbstractSetupAttributeSystem, ISetPool<IUIPool> | ||
{ | ||
private Pool<IUIPool> _pool; | ||
protected override Type[] EnsureTypes => new[] {typeof (HierarchyType), typeof(Ready) }; | ||
|
||
protected override void SetupFor(Entity<IUIPool> entity, XmlElement xml) | ||
{ | ||
var scope = _pool.GetScope(entity); | ||
var embed = _pool.GetParent(scope); | ||
|
||
var children = _pool.GetChildren(embed).Where(c => c.Has<ChildrenType>()); | ||
if (!children.Any()) | ||
return; | ||
|
||
var child = children.First(); | ||
|
||
var parent = child.Need<Parent>(); | ||
parent.Id = entity.Get<Element>().Id; | ||
|
||
child.ReplaceInstance(parent); | ||
|
||
|
||
// Have no sub hierarchy case | ||
// if (!embed.Has<XmlSubHierarchy>()) | ||
// return; | ||
|
||
// var root = embed.Get<XmlSubHierarchy>().Root; | ||
// var doc = entity.CreateComponent<XmlDocument>(); | ||
// doc.Root = root; | ||
// entity.AddInstance(doc); | ||
} | ||
|
||
public void SetPool(Pool<IUIPool> typedPool) | ||
{ | ||
_pool = typedPool; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters