Skip to content

Commit

Permalink
Merge pull request #4 from techno-dwarf-works/feature/refactoring
Browse files Browse the repository at this point in the history
Version 0.0.2
  • Loading branch information
OpOpYaDev authored and OpOpYaDev committed Oct 7, 2024
1 parent c8b700b commit 5ff6d6f
Show file tree
Hide file tree
Showing 29 changed files with 372 additions and 164 deletions.
11 changes: 9 additions & 2 deletions Runtime/BetterUIProcessor.Runtime.asmdef
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"GUID:1862b35041b066d42ab4d3caf773657b",
"GUID:d103b3c6d6cb0564d8d6543e9d797878",
"GUID:af7fffdf1d83bc842b0f6e3a01efda16",
"GUID:35101f455c979e94c9a0a4793484b7fd"
"GUID:35101f455c979e94c9a0a4793484b7fd",
"GUID:d93d03cfdadede7468b389b1aac7ee67"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand All @@ -17,6 +18,12 @@
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"versionDefines": [
{
"name": "com.tdw.better.tweens",
"expression": "0.0.5",
"define": "BETTER_TWEENS"
}
],
"noEngineReferences": false
}
4 changes: 3 additions & 1 deletion Runtime/Data/Overridable/ImplementationOverridable.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Better.Attributes.Runtime.Select;
using UnityEngine;

Expand All @@ -18,9 +18,11 @@ protected override TValue OverridenValue

public ImplementationOverridable()
{

}

public ImplementationOverridable(TValue overridenValue)

{
_overridenValue = overridenValue;
}
Expand Down
14 changes: 11 additions & 3 deletions Runtime/Data/Overridable/ImplementationOverridable.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Runtime/Data/Overridable/OverridableData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using UnityEngine;

namespace Better.Tweens.Runtime.Data
Expand Down
14 changes: 11 additions & 3 deletions Runtime/Data/Overridable/OverridableData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Runtime/Data/SettingsData.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Better.Attributes.Runtime.Select;
using Better.Commons.Runtime.Interfaces;
using Better.Commons.Runtime.Utility;
Expand All @@ -17,7 +17,7 @@ public class SettingsData : ICopyable<SettingsData>

public SettingsData()
{
_defaultSequence = new GradualDefaultSequence();
_defaultSequence = new GradualSequence();
}

public void SetDefaultSequence(Sequence value)
Expand Down
14 changes: 11 additions & 3 deletions Runtime/Data/SettingsData.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 23 additions & 14 deletions Runtime/Implementations/Elements/Element.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public abstract class Element<TView, TModel> : UIMonoBehaviour, IElement, IModel
protected TModel Model { get; private set; }
protected TView View => _view;

bool ISequencable.Displayed
{
get => View.Displayed;
set => View.Displayed = value;
}

Task IElement.InitializeAsync(CancellationToken cancellationToken)
{
View.Interactable = false;
Expand All @@ -50,12 +44,12 @@ void IModelAssignable<TModel>.AssignModel(TModel model)

#region ISequencable

Task ISequencable.PrepareShowAsync(CancellationToken cancellationToken)
Task ISequencable.PreShowAsync(CancellationToken cancellationToken)
{
return OnPrepareShowAsync(cancellationToken);
return OnPreShowAsync(cancellationToken);
}

protected abstract Task OnPrepareShowAsync(CancellationToken cancellationToken);
protected abstract Task OnPreShowAsync(CancellationToken cancellationToken);

async Task ISequencable.ShowAsync(CancellationToken cancellationToken)
{
Expand All @@ -69,19 +63,26 @@ async Task ISequencable.ShowAsync(CancellationToken cancellationToken)
}

protected abstract Task OnShowAsync(CancellationToken cancellationToken);

Task ISequencable.PostShowAsync(CancellationToken cancellationToken)
{
View.Displayed = true;
return OnPostShowAsync(cancellationToken);
}

Task ISequencable.PrepareHideAsync(CancellationToken cancellationToken)
protected abstract Task OnPostShowAsync(CancellationToken cancellationToken);


Task ISequencable.PreHideAsync(CancellationToken cancellationToken)
{
View.Interactable = false;
return OnPrepareHideAsync(cancellationToken);
return OnPreHideAsync(cancellationToken);
}

protected abstract Task OnPrepareHideAsync(CancellationToken cancellationToken);
protected abstract Task OnPreHideAsync(CancellationToken cancellationToken);

async Task ISequencable.HideAsync(CancellationToken cancellationToken)
{
View.Interactable = false;

await View.HideAsync(cancellationToken);
if (!cancellationToken.IsCancellationRequested)
{
Expand All @@ -91,6 +92,14 @@ async Task ISequencable.HideAsync(CancellationToken cancellationToken)

protected abstract Task OnHideAsync(CancellationToken cancellationToken);

Task ISequencable.PostHideAsync(CancellationToken cancellationToken)
{
View.Displayed = false;
return OnPostHideAsync(cancellationToken);
}

protected abstract Task OnPostHideAsync(CancellationToken cancellationToken);

#endregion
}
}
5 changes: 2 additions & 3 deletions Runtime/Implementations/UIProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ private async Task PrewarmOpenedElementAsync(IElement prewarmedElement)
_transitionsQueue.Enqueue(transitionInfo);

await prewarmedElement.InitializeAsync(CancellationToken.None);
await prewarmedElement.PrepareShowAsync(CancellationToken.None);
await prewarmedElement.PreShowAsync(CancellationToken.None);
await prewarmedElement.ShowAsync(CancellationToken.None);
prewarmedElement.Displayed = true;
await prewarmedElement.PostShowAsync(CancellationToken.None);

OpenedElement = prewarmedElement;

Expand Down Expand Up @@ -221,7 +221,6 @@ private async Task<ProcessResult<IElement>> ProcessTransitionAsync(IElement from
return new ProcessResult<IElement>(toElement);
}


private async Task<ProcessResult<IElement>> ProcessSequenceAsync(IElement fromElement, IElement toElement, TransitionInfo transitionInfo)
{
if (transitionInfo.IsCanceled)
Expand Down
8 changes: 5 additions & 3 deletions Runtime/Interfaces/ISequencable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ namespace Better.UIProcessor.Runtime.Interfaces
public interface ISequencable
{
public RectTransform RectTransform { get; }
public bool Displayed { get; set; }

public Task PrepareShowAsync(CancellationToken cancellationToken);
public Task PreShowAsync(CancellationToken cancellationToken);
public Task ShowAsync(CancellationToken cancellationToken);
public Task PrepareHideAsync(CancellationToken cancellationToken);
public Task PostShowAsync(CancellationToken cancellationToken);

public Task PreHideAsync(CancellationToken cancellationToken);
public Task HideAsync(CancellationToken cancellationToken);
public Task PostHideAsync(CancellationToken cancellationToken);
}
}
6 changes: 5 additions & 1 deletion Runtime/Modules/HistoricalModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ protected internal override async Task<ProcessResult<IElement>> TryGetTransition
if (popResult.IsSuccessful)
{
_unreleasedBuffer.Add(popResult.Result);
return new ProcessResult<IElement>(popResult.Result.Element);

var element = popResult.Result.Element;
element.RectTransform.SetParent(processor.Container);
element.RectTransform.SetAsLastSibling();
return new ProcessResult<IElement>(element);
}
}

Expand Down
3 changes: 0 additions & 3 deletions Runtime/Sequences/Defaults.meta

This file was deleted.

68 changes: 0 additions & 68 deletions Runtime/Sequences/Defaults/DefaultSequence.cs

This file was deleted.

22 changes: 0 additions & 22 deletions Runtime/Sequences/Defaults/GradualDefaultSequence.cs

This file was deleted.

26 changes: 0 additions & 26 deletions Runtime/Sequences/Defaults/ParallelDefaultSequence.cs

This file was deleted.

3 changes: 3 additions & 0 deletions Runtime/Sequences/Fade.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5ff6d6f

Please sign in to comment.