-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
Merege develop to master
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,23 +26,32 @@ jobs: | |
run: | | ||
git fetch --unshallow | ||
lastTag=$(git describe --tags --abbrev=0) | ||
currentTag=$(git tag --contains) | ||
lastTagMainVersion=$(sed -n 's/^\([0-9]*\.[0-9]*\).*/\1/p' <<<"$lastTag") | ||
currentVersion=$(cat VERSION) | ||
currentMainVersion=$(sed -n 's/^\([0-9]*\.[0-9]*\).*/\1/p' <VERSION) | ||
if [ "$lastTagMainVersion" = "$currentMainVersion" ] | ||
if [ "$lastTag" = "$currentTag" ] | ||
then | ||
echo "Version the same." | ||
lastTagBuildVersion=$(sed -n 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p' <<<"$lastTag") | ||
newBuildVersion=$((lastTagBuildVersion+1)) | ||
newVersion="$lastTagMainVersion"."$newBuildVersion" | ||
echo "Build from tagged commit" | ||
newVersion=$lastTag | ||
echo "newVersion=$newVersion" | ||
echo "newVersion=$newVersion" >> $GITHUB_ENV | ||
else | ||
echo "New version!" | ||
newVersion="$currentMainVersion".1 | ||
VersionPrefix=$newVersion | ||
echo "newVersion=$newVersion" | ||
echo "newVersion=$newVersion" >> $GITHUB_ENV | ||
if [ "$lastTagMainVersion" = "$currentMainVersion" ] | ||
then | ||
echo "Version the same." | ||
lastTagBuildVersion=$(sed -n 's/^[0-9]*\.[0-9]*\.\([0-9]*\).*/\1/p' <<<"$lastTag") | ||
newBuildVersion=$((lastTagBuildVersion+1)) | ||
newVersion="$lastTagMainVersion"."$newBuildVersion" | ||
echo "newVersion=$newVersion" | ||
echo "newVersion=$newVersion" >> $GITHUB_ENV | ||
else | ||
echo "New version!" | ||
newVersion="$currentMainVersion".1 | ||
VersionPrefix=$newVersion | ||
echo "newVersion=$newVersion" | ||
echo "newVersion=$newVersion" >> $GITHUB_ENV | ||
fi | ||
fi | ||
sed -i '' -e "s/\(<Version>\)\(.*\)\(<\/Version>\)/\1$newVersion\3/" src/UnityMVVM/UnityMVVM.csproj | ||
- name: Run tests | ||
|
@@ -75,8 +84,14 @@ jobs: | |
- name: Tag non-release | ||
if: github.ref != 'refs/heads/master' | ||
run: | | ||
git tag ${{ env.newVersion }} | ||
git push --tags | ||
lastTag=$(git describe --tags --abbrev=0) | ||
currentTag=$(git tag --contains) | ||
if [ "$lastTag" != "$currentTag" ] | ||
then | ||
echo "New tag ${{ env.newVersion }}" | ||
git tag ${{ env.newVersion }} | ||
git push --tags | ||
fi | ||
- name: Expose as artifact | ||
uses: actions/[email protected] | ||
with: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
using AsyncReactAwait.Bindable; | ||
using AsyncReactAwait.Bindable.BindableExtensions; | ||
|
||
namespace CCG.Core.Camera | ||
{ | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using AsyncReactAwait.Bindable; | ||
using UnityMVVM.ViewModelCore; | ||
|
||
namespace CCG.MVVM.TimeCounter | ||
{ | ||
public interface ITimeCounterViewModel : IViewModel | ||
{ | ||
IBindable<float> TimeInSeconds { get; } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using TMPro; | ||
using UnityEngine; | ||
using UnityMVVM; | ||
|
||
namespace CCG.MVVM.TimeCounter | ||
{ | ||
public class TimeCounterView : ViewBehaviour<ITimeCounterViewModel> | ||
{ | ||
[SerializeField] private TMP_Text _text; | ||
|
||
protected override void OnViewModelSet() | ||
{ | ||
base.OnViewModelSet(); | ||
ViewModel!.TimeInSeconds.Bind(OnTimeChanged); | ||
} | ||
|
||
private void OnTimeChanged(float time) | ||
{ | ||
_text.text = time.ToString("0.0"); | ||
} | ||
|
||
protected override void OnViewModelClear() | ||
{ | ||
base.OnViewModelClear(); | ||
ViewModel!.TimeInSeconds.Unbind(OnTimeChanged); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using AsyncReactAwait.Bindable; | ||
using CCG.Core; | ||
using SurvivedWarrior.MVVM.Models.Time; | ||
using UnityMVVM.ViewManager; | ||
using UnityMVVM.ViewModelCore; | ||
using Zenject; | ||
|
||
namespace CCG.MVVM.TimeCounter | ||
{ | ||
public class TimeCounterViewModel : ViewModel, | ||
IInitializable, | ||
ITimeCounterViewModel | ||
{ | ||
private readonly IViewManager _viewManager; | ||
private readonly ITimeManager _timeManager; | ||
|
||
private bool _isCounting; | ||
|
||
private readonly IMutable<float> _timeInSeconds = new Mutable<float>(); | ||
|
||
public IBindable<float> TimeInSeconds => _timeInSeconds; | ||
|
||
public TimeCounterViewModel( | ||
IViewManager viewManager, | ||
ITimeManager timeManager) | ||
{ | ||
_viewManager = viewManager; | ||
_timeManager = timeManager; | ||
} | ||
|
||
public void Initialize() | ||
{ | ||
_viewManager.HighestBusyLayer.Bind(OnHighestLayerChanged); | ||
_timeManager.CurrentTimestamp.Bind(OnTimeChanged); | ||
} | ||
|
||
private void OnTimeChanged(long prevVal, long newVal) | ||
{ | ||
if (_isCounting) | ||
{ | ||
_timeInSeconds.Value += (newVal - prevVal) / (float)TimeSpan.TicksPerSecond; | ||
} | ||
} | ||
|
||
private void OnHighestLayerChanged(string layer) | ||
{ | ||
_isCounting = layer == ViewLayerIds.MainUI; | ||
} | ||
|
||
protected override void OnDestroyInternal() | ||
{ | ||
base.OnDestroyInternal(); | ||
_viewManager.HighestBusyLayer.Unbind(OnHighestLayerChanged); | ||
_timeManager.CurrentTimestamp.Unbind(OnTimeChanged); | ||
_isCounting = false; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using JetBrains.Annotations; | ||
|
||
namespace SurvivedWarrior.MVVM.Models.Time | ||
{ | ||
public class CallbackCancelSource | ||
{ | ||
private readonly Action _cancelAction; | ||
|
||
public CallbackCancelSource([NotNull] Action cancelAction) | ||
{ | ||
_cancelAction = cancelAction ?? throw new ArgumentNullException(nameof(cancelAction)); | ||
} | ||
|
||
public void Cancel() => _cancelAction(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using AsyncReactAwait.Bindable; | ||
using AsyncReactAwait.Promises; | ||
|
||
namespace SurvivedWarrior.MVVM.Models.Time | ||
{ | ||
public interface ITimeManager | ||
{ | ||
IBindable<long> CurrentTimestamp { get; } | ||
long TimestampSinceStart { get; } | ||
long LocalTimeOffset { get; } | ||
void Pause(string timeline); | ||
void Resume(string timeline); | ||
CallbackCancelSource AddCallback(long timestamp, Action callback, string timeLine = "Default"); | ||
DateTime TimestampToLocalTime(long timestamp); | ||
IPromise Await(float seconds); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System; | ||
|
||
namespace SurvivedWarrior.MVVM.Models.Time | ||
{ | ||
public interface ITimeline | ||
{ | ||
void AddTime(long ticks); | ||
CallbackCancelSource AddCallbackIn(long ticksDelay, Action callback); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.