Artt book tweaks
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f69d14fcc0bdd4b93aeb1717d030a9ca
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Darkmatter.Core.Data.Signals.Features.Capture
|
||||
{
|
||||
public record struct GallerySaveCompletedSignal(bool Success);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 04fbdae933fab4011879c232a1041042
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Darkmatter.Core.Data.Signals.Features.Capture
|
||||
{
|
||||
public record struct GallerySaveStartedSignal;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cff479845a55e4dd0a6d66043c91f661
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core
|
||||
{
|
||||
public record struct OpenArtBookSignal;
|
||||
}
|
||||
public record struct OpenArtBookSignal(Action OnClose);
|
||||
}
|
||||
@@ -26,7 +26,7 @@ namespace Darkmatter.Features.Artbook
|
||||
private readonly List<ArtbookEntry> _entries = new();
|
||||
private readonly List<Sprite> _ownedSprites = new();
|
||||
private readonly List<Texture2D> _ownedTextures = new();
|
||||
|
||||
private Action _onClose;
|
||||
private CancellationTokenSource _cts;
|
||||
private IDisposable _openSubscription;
|
||||
private int _currentSpread;
|
||||
@@ -60,10 +60,12 @@ namespace Darkmatter.Features.Artbook
|
||||
|
||||
private void HandleOpenArtbookEvent(OpenArtBookSignal signal)
|
||||
{
|
||||
_onClose = null;
|
||||
_view.Show();
|
||||
_cts?.Cancel();
|
||||
_cts?.Dispose();
|
||||
_cts = new CancellationTokenSource();
|
||||
_onClose = signal.OnClose;
|
||||
LoadAndShowAsync(_cts.Token).Forget();
|
||||
}
|
||||
|
||||
@@ -164,7 +166,7 @@ namespace Darkmatter.Features.Artbook
|
||||
|
||||
private void HandleBackButtonClicked()
|
||||
{
|
||||
_eventBus.Publish(new OpenColorBookSignal());
|
||||
_onClose?.Invoke();
|
||||
_view.Hide();
|
||||
}
|
||||
|
||||
@@ -198,4 +200,4 @@ namespace Darkmatter.Features.Artbook
|
||||
ClearOwnedAssets();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
"references": [
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:b4c9f7fbf1e144933a1797dc208ece5f",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace Darkmatter.Features.Capture
|
||||
{
|
||||
[SerializeField, Range(0.1f, 2f)] private float captureScale = 1f;
|
||||
[SerializeField] private CaptureButtonView captureButtonView;
|
||||
[SerializeField] private GallerySaveView gallerySaveView;
|
||||
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
@@ -19,6 +20,9 @@ namespace Darkmatter.Features.Capture
|
||||
|
||||
if (captureButtonView != null)
|
||||
builder.RegisterEntryPoint<CaptureButtonPresenter>().WithParameter(captureButtonView);
|
||||
|
||||
if (gallerySaveView != null)
|
||||
builder.RegisterEntryPoint<GallerySavePresenter>().WithParameter(gallerySaveView);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ using Darkmatter.Core.Contracts.Features.Capture;
|
||||
using Darkmatter.Core.Contracts.Features.GameplayFlow;
|
||||
using Darkmatter.Core.Contracts.Services.Capture;
|
||||
using Darkmatter.Core.Contracts.Services.Gallery;
|
||||
using Darkmatter.Core.Data.Signals.Features.Capture;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Features.Capture
|
||||
@@ -14,17 +16,20 @@ namespace Darkmatter.Features.Capture
|
||||
private readonly ICaptureService _captureService;
|
||||
private readonly IGalleryService _galleryService;
|
||||
private readonly IGameplaySceneRefs _refs;
|
||||
private readonly IEventBus _bus;
|
||||
private readonly CaptureConfig _config;
|
||||
|
||||
public CaptureSystem(
|
||||
ICaptureService captureService,
|
||||
IGalleryService galleryService,
|
||||
IGameplaySceneRefs refs,
|
||||
IEventBus bus,
|
||||
CaptureConfig config)
|
||||
{
|
||||
_captureService = captureService;
|
||||
_galleryService = galleryService;
|
||||
_refs = refs;
|
||||
_bus = bus;
|
||||
_config = config;
|
||||
}
|
||||
|
||||
@@ -34,15 +39,21 @@ namespace Darkmatter.Features.Capture
|
||||
if (!saveToGallery || png == null || png.Length == 0) return png;
|
||||
|
||||
var tex = new Texture2D(2, 2, TextureFormat.RGBA32, mipChain: false);
|
||||
var success = false;
|
||||
try
|
||||
{
|
||||
if (tex.LoadImage(png))
|
||||
{
|
||||
_bus.Publish(new GallerySaveStartedSignal());
|
||||
await _galleryService.SaveImageAsync(tex,
|
||||
$"colorbook_{DateTime.UtcNow:yyyyMMdd_HHmmss}.png", ct);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
UnityEngine.Object.Destroy(tex);
|
||||
_bus.Publish(new GallerySaveCompletedSignal(success));
|
||||
}
|
||||
return png;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Data.Signals.Features.Capture;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Capture.UI
|
||||
{
|
||||
public class GallerySavePresenter : IStartable, IDisposable
|
||||
{
|
||||
private readonly GallerySaveView _view;
|
||||
private readonly IEventBus _bus;
|
||||
|
||||
private IDisposable _startedSub;
|
||||
private IDisposable _completedSub;
|
||||
private CancellationTokenSource _popupCts;
|
||||
|
||||
public GallerySavePresenter(GallerySaveView view, IEventBus bus)
|
||||
{
|
||||
_view = view;
|
||||
_bus = bus;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_startedSub = _bus.Subscribe<GallerySaveStartedSignal>(OnStarted);
|
||||
_completedSub = _bus.Subscribe<GallerySaveCompletedSignal>(OnCompleted);
|
||||
}
|
||||
|
||||
private void OnStarted(GallerySaveStartedSignal _)
|
||||
{
|
||||
CancelPopup();
|
||||
_view.ShowSaving();
|
||||
}
|
||||
|
||||
private void OnCompleted(GallerySaveCompletedSignal signal)
|
||||
{
|
||||
_view.HideSaving();
|
||||
if (!signal.Success) return;
|
||||
CancelPopup();
|
||||
_popupCts = new CancellationTokenSource();
|
||||
ShowPopupAsync(_popupCts.Token).Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid ShowPopupAsync(CancellationToken ct)
|
||||
{
|
||||
_view.ShowSuccess();
|
||||
try
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromSeconds(_view.PopupAutoHideSeconds), cancellationToken: ct);
|
||||
}
|
||||
catch (OperationCanceledException) { return; }
|
||||
_view.HideSuccess();
|
||||
}
|
||||
|
||||
private void CancelPopup()
|
||||
{
|
||||
_popupCts?.Cancel();
|
||||
_popupCts?.Dispose();
|
||||
_popupCts = null;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_startedSub?.Dispose();
|
||||
_completedSub?.Dispose();
|
||||
CancelPopup();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71d8cccc7b3a3436ba83ca3683fbea9f
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Features.Capture.UI
|
||||
{
|
||||
public class GallerySaveView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject savingIndicator;
|
||||
[SerializeField] private GameObject successPopup;
|
||||
[SerializeField, Min(0f)] private float popupAutoHideSeconds = 1.5f;
|
||||
|
||||
public float PopupAutoHideSeconds => popupAutoHideSeconds;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (savingIndicator != null) savingIndicator.SetActive(false);
|
||||
if (successPopup != null) successPopup.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowSaving()
|
||||
{
|
||||
if (savingIndicator != null) savingIndicator.SetActive(true);
|
||||
if (successPopup != null) successPopup.SetActive(false);
|
||||
}
|
||||
|
||||
public void HideSaving()
|
||||
{
|
||||
if (savingIndicator != null) savingIndicator.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowSuccess()
|
||||
{
|
||||
if (successPopup != null) successPopup.SetActive(true);
|
||||
}
|
||||
|
||||
public void HideSuccess()
|
||||
{
|
||||
if (successPopup != null) successPopup.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bbcc5a579d90f4763a781379f5213d6e
|
||||
@@ -70,7 +70,7 @@ namespace Darkmatter.Features.DrawingCatalog
|
||||
|
||||
private void OnArtBookBtnClicked()
|
||||
{
|
||||
_eventBus.Publish(new OpenArtBookSignal());
|
||||
_eventBus.Publish(new OpenArtBookSignal(()=> _view.Show()));
|
||||
_view.Hide();
|
||||
}
|
||||
|
||||
|
||||
3146
Assets/Darkmatter/Content/Colorbook UI/Prefabs/UI/ArtBookView.prefab
Normal file
3146
Assets/Darkmatter/Content/Colorbook UI/Prefabs/UI/ArtBookView.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4dd2a1cb2754a410f9f807f563a55e7c
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@@ -657,6 +657,51 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Features.GameplayFlow::Darkmatter.Features.GameplayFlow.UI.NextButtonView
|
||||
nextButton: {fileID: 259035379}
|
||||
--- !u!1 &339691221
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 339691222}
|
||||
- component: {fileID: 339691223}
|
||||
m_Layer: 0
|
||||
m_Name: ArtbookFeatureServiceModule
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &339691222
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 339691221}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -40.146973, y: -385.9893, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1965442263}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &339691223
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 339691221}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e42bea53c6fa23c45a7c85e9b025bed7, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Features.Artbook::Darkmatter.Features.Artbook.ArtBookFeatureModule
|
||||
artbookView: {fileID: 2022514149}
|
||||
--- !u!1 &357588033
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2045,6 +2090,7 @@ MonoBehaviour:
|
||||
- {fileID: 1991184380}
|
||||
- {fileID: 1867428030}
|
||||
- {fileID: 26318080}
|
||||
- {fileID: 339691223}
|
||||
--- !u!1 &1281354567
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2610,6 +2656,7 @@ Transform:
|
||||
- {fileID: 1991184379}
|
||||
- {fileID: 1867428029}
|
||||
- {fileID: 26318079}
|
||||
- {fileID: 339691222}
|
||||
m_Father: {fileID: 1224714932}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1982732271
|
||||
@@ -3023,6 +3070,123 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2014087207}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1001 &2022514147
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
serializedVersion: 3
|
||||
m_TransformParent: {fileID: 2069155641}
|
||||
m_Modifications:
|
||||
- target: {fileID: 3521470624751981147, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: ArtBookView
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3521470624751981147, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_Pivot.x
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_Pivot.y
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_AnchorMax.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_AnchorMin.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_AnchorMin.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_RemovedGameObjects: []
|
||||
m_AddedGameObjects: []
|
||||
m_AddedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
--- !u!224 &2022514148 stripped
|
||||
RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 3765577967584406493, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
m_PrefabInstance: {fileID: 2022514147}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &2022514149 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 3299125903084573743, guid: 4dd2a1cb2754a410f9f807f563a55e7c, type: 3}
|
||||
m_PrefabInstance: {fileID: 2022514147}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d635629f252db53479e66347a37c4f0b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Features.Artbook::Darkmatter.Features.Artbook.ArtbookView
|
||||
--- !u!1 &2046672211
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3436,6 +3600,7 @@ RectTransform:
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 201822947}
|
||||
- {fileID: 2022514148}
|
||||
m_Father: {fileID: 0}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
|
||||
Reference in New Issue
Block a user