Skip to content

Commit

Permalink
Merge pull request #3 from kekchpek/develop
Browse files Browse the repository at this point in the history
Merege develop to master
  • Loading branch information
kekchpek authored Feb 26, 2024
2 parents 753586d + f83fe52 commit 693ade8
Show file tree
Hide file tree
Showing 64 changed files with 1,750 additions and 150 deletions.
39 changes: 27 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Binary file removed DemoUnityProj/CCG/Assets/.DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions DemoUnityProj/CCG/Assets/Code/Core/Camera/CameraModel.cs
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
{
Expand Down
5 changes: 5 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/Core/CoreInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
using CCG.MVVM.MainScreen3d;
using CCG.MVVM.PlayButton;
using CCG.MVVM.StatsChanger;
using CCG.MVVM.TimeCounter;
using CCG.Services.Game;
using CCG.Services.Startup;
using SurvivedWarrior.MVVM.Models.Time;
using UnityEngine;
using UnityMVVM.DI;
using UnityMVVM.ViewModelCore;
Expand Down Expand Up @@ -46,11 +48,14 @@ public override void InstallBindings()
() => Resources.Load<GameObject>("Prefabs/Views/LoadingPopup"));
Container.InstallView<CoolPopupView, ICoolPopupViewModel, CoolPopupViewModel>(ViewNames.CoolPopup,
() => Resources.Load<GameObject>("Prefabs/Views/CoolPopup/CoolPopup"));
Container.InstallView<TimeCounterView, ITimeCounterViewModel, TimeCounterViewModel>();

Container.Install<ImageSystemInstaller>();

Container.FastBind<IStartupService, StartupService>();

Container.FastBindMono<ITimeManager, TimeManager>();

Container.GetViewsContainer()
.Bind(typeof(ICameraMutableModel), typeof(ICameraModel))
.To<CameraModel>().AsSingle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace CCG.MVVM.CoolPopup
public class CoolPopupView : ViewBehaviour<ICoolPopupViewModel>
{
[SerializeField] private Button _closeBtn;
[SerializeField] private Button _openPopupButton;
[SerializeField] private Button _openOtherBth;
[SerializeField] private Button _openOtherWithErrorBth;
[SerializeField] private Toggle _animationToggle;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,20 @@ public class MainScreenView : ViewBehaviour<IMainScreenViewModel>, IPoolableView
[SerializeField] private Button _mainMenuButton;

[SerializeField] private Transform _cardsContainer;

[SerializeField] private Button _popupBtn;

protected override void OnViewModelSet()
{
base.OnViewModelSet();
ViewModel!.SetCardsContainer(_cardsContainer);
_mainMenuButton.onClick.AddListener(() => ViewModel.OnMainMenuButtonClicked());
_popupBtn.onClick.AddListener(OnPopupBtn);
}

private void OnPopupBtn()
{
ViewModel!.OnPopupButtonClicked();
}

protected override void OnViewModelClear()
Expand All @@ -35,6 +43,8 @@ public void OnReturnToPool()
transform.SetParent(null);
var go = gameObject;
go.SetActive(false);
_mainMenuButton.onClick.RemoveAllListeners();
_popupBtn.onClick.RemoveListener(OnPopupBtn);
DontDestroyOnLoad(go);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace CCG.MVVM.MainScreen.ViewModel
{
public interface IMainScreenViewModel : IViewModel
{
void OnPopupButtonClicked();
void OnMainMenuButtonClicked();
void SetCardsContainer(Transform container);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using CCG.Models.ImageModel;
using CCG.MVVM.Card.Model;
using CCG.MVVM.Card.ViewModel;
using CCG.MVVM.CoolPopup.Payload;
using CCG.Services.Game;
using UnityEngine;
using UnityMVVM.ViewManager;
Expand Down Expand Up @@ -66,6 +67,12 @@ private void IntiGame()
});
}

public void OnPopupButtonClicked()
{
_viewManager.Open(ViewLayerIds.Popup, ViewNames.CoolPopup, new CoolPopupPayload(false))
.OnFail(Debug.LogException);
}

public async void OnMainMenuButtonClicked()
{
await _gameService.OpenMainMenu();
Expand Down
3 changes: 3 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/MVVM/TimeCounter.meta

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.

28 changes: 28 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/MVVM/TimeCounter/TimeCounterView.cs
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.

17 changes: 17 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/Models/Time/CallbackCancelSource.cs
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.

18 changes: 18 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/Models/Time/ITimeManager.cs
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.

10 changes: 10 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/Models/Time/ITimeline.cs
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);
}
}
3 changes: 3 additions & 0 deletions DemoUnityProj/CCG/Assets/Code/Models/Time/ITimeline.cs.meta

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

Loading

0 comments on commit 693ade8

Please sign in to comment.