Merge pull request 'savya' (#2) from savya into main
Reviewed-on: #2
This commit was merged in pull request #2.
This commit is contained in:
@@ -13,7 +13,7 @@ namespace Darkmatter.App.LifetimeScopes
|
||||
{
|
||||
foreach (var module in serviceModules)
|
||||
{
|
||||
if (module is IServiceModule serviceModule)
|
||||
if (module is IModule serviceModule)
|
||||
serviceModule.Register(builder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f91f821f605f4d1ba438f41e4232df0
|
||||
guid: 2a7bd8ae1404546e58de3fbe788c53c1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.Coloring
|
||||
{
|
||||
public interface IColorPalette
|
||||
{
|
||||
string Id { get; }
|
||||
List<Color> Colors { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9727b71700be94dd5996eae7a4643d45
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68afb1ec24cda44d6a6a57436462a65c
|
||||
guid: 02f4802975f1b45cca88ffc81c71b624
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
|
||||
public interface IDrawingCatalogController
|
||||
{
|
||||
IReadOnlyList<string> VisibleIds { get; }
|
||||
event Action ListChanged;
|
||||
UniTask InitializeAsync(CancellationToken ct);
|
||||
void OnTemplateSelected(string id);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0732a5de2a84833ab4d3252d9e22851
|
||||
timeCreated: 1779881997
|
||||
@@ -0,0 +1,17 @@
|
||||
using System.Collections.Generic;
|
||||
using Darkmatter.Core.Data.Dynamic.Features.Coloring;
|
||||
using Darkmatter.Core.Data.Static.Features.ShapeBuilder;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.DrawingCatalog
|
||||
{
|
||||
public interface IDrawingTemplate
|
||||
{
|
||||
string Id { get; }
|
||||
string DisplayName { get; }
|
||||
Sprite DefaultThumbnail { get; }
|
||||
Sprite PaperBackground { get; }
|
||||
IReadOnlyList<ShapeSO> Pieces { get; }
|
||||
IReadOnlyList<ColorRegionDTO> Regions { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 34c3363cf5c2645bf89a6716881d637d
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.DrawingCatalog
|
||||
{
|
||||
public interface IDrawingTemplateCatalog
|
||||
{
|
||||
UniTask FetchAsync();
|
||||
IReadOnlyList<string> AllTemplateIds { get; }
|
||||
UniTask<Sprite> GetThumbnailAsync(string id);
|
||||
UniTask<IDrawingTemplate> LoadAsync(string id);
|
||||
void ReleaseAll();
|
||||
string GetNextTemplate(string currentId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7932dbf9ea8724ec0962fb38ce70c69a
|
||||
@@ -1,7 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.History
|
||||
{
|
||||
public interface IUndoStack
|
||||
{
|
||||
event Action OnStackChanged;
|
||||
bool CanUndo { get; }
|
||||
bool CanRedo { get; }
|
||||
void Push(ICommand cmd); // executes + appends
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.Paper
|
||||
{
|
||||
public interface IArtInputBridge
|
||||
{
|
||||
bool TryScreenToArtWorld(Vector2 screenPos, out Vector2 artWorldPos);
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39f0c8bfbf53c4b299d6beb0a01fd32b
|
||||
@@ -1,10 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.Paper
|
||||
{
|
||||
public interface IPaperRig
|
||||
{
|
||||
Camera ArtCamera { get; }
|
||||
RectTransform DisplayRect { get; }
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a51496fa9463b41f7baeb4ff40055835
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33ac9f869ed6a48c1a97be5aaad4953d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Data.Dynamic.Features.Progression;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Features.Progression
|
||||
{
|
||||
public interface IProgressionSystem
|
||||
{
|
||||
UniTask LoadAsync();
|
||||
UniTask SaveAsync();
|
||||
IReadOnlyCollection<string> CompletedTemplateIds { get; }
|
||||
void MarkCompleted(string templateId);
|
||||
|
||||
DrawingProgress? GetProgress(string templateId);
|
||||
UniTask SaveProgressAsync(DrawingProgress progress);
|
||||
UniTask SaveProgressAsync(DrawingProgress progress, byte[] thumbnailPng);
|
||||
UniTask ClearProgressAsync(string templateId);
|
||||
|
||||
bool IsCompleted(string templateId);
|
||||
|
||||
UniTask<Texture2D> GetCachedThumbnailAsync(string templateId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01c78ae114b2e4de08c195481bb84875
|
||||
@@ -1,12 +1,12 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Contracts.Services.Capture
|
||||
{
|
||||
public interface ICaptureService
|
||||
{
|
||||
UniTask<byte[]> CapturePngAsync(CancellationToken cancellationToken = default);
|
||||
|
||||
UniTask<byte[]> CaptureThumbnailPngAsync(int size, CancellationToken cancellationToken = default);
|
||||
UniTask<Sprite> CapturePngAsync(GameObject captureObject, float captureSize,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -5,6 +6,7 @@ namespace Darkmatter.Core.Contracts.Services.Gallery
|
||||
{
|
||||
public interface IGalleryService
|
||||
{
|
||||
UniTask SaveImageAsync(Texture2D sprite, string fileName, string albumName = "Colorbook");
|
||||
UniTask SaveImageAsync(Texture2D sprite, string fileName,
|
||||
CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
8
Assets/Darkmatter/Code/Core/Data/Dynamic/Features.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Dynamic/Features.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44c0419b9655e43c5afdf89318ed6c5f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 743e19d2ea5974219a29de329a1b1558
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Data.Dynamic.Features.Coloring
|
||||
{
|
||||
public readonly struct ColorRegionDTO
|
||||
{
|
||||
public string RegionId { get; }
|
||||
public Sprite Sprite { get; }
|
||||
public Vector2 AnchoredPosition { get; }
|
||||
public Color InitialColor { get; }
|
||||
|
||||
public ColorRegionDTO(string regionId, Sprite sprite, Vector2 anchoredPosition, Color initialColor)
|
||||
{
|
||||
RegionId = regionId;
|
||||
Sprite = sprite;
|
||||
AnchoredPosition = anchoredPosition;
|
||||
InitialColor = initialColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1e7ce71b41d94e4085ab76ec3901c9b
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Data.Dynamic.Features.Coloring
|
||||
{
|
||||
public readonly struct PaintCommandDTO
|
||||
{
|
||||
public string RegionId { get; }
|
||||
public Color FromColor { get; }
|
||||
public Color ToColor { get; }
|
||||
|
||||
public PaintCommandDTO(string regionId, Color fromColor, Color toColor)
|
||||
{
|
||||
RegionId = regionId;
|
||||
FromColor = fromColor;
|
||||
ToColor = toColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1705bbb970da44af7b0cdf6c2fe90cfb
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 690eecbb6b1914669ab26662e2cc6a98
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Darkmatter.Core.Enums.Features.Progression;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Data.Dynamic.Features.Progression
|
||||
{
|
||||
[Serializable]
|
||||
public struct DrawingProgress
|
||||
{
|
||||
public string templateId;
|
||||
public DrawingPhase phase;
|
||||
public List<string> SnappedPieces;
|
||||
public List<RegionColorEntry> RegionColors;
|
||||
public bool hasThumbnail;
|
||||
|
||||
public bool hasBeenCompleted;
|
||||
public int completionCount;
|
||||
|
||||
public DateTime UpdatedUtc;
|
||||
public DateTime? FirstCompletedUtc;
|
||||
|
||||
public DrawingProgress(string templateId, DrawingPhase phase, List<string> snappedPieces,
|
||||
List<RegionColorEntry> regionColors, bool hasThumbnail, bool hasBeenCompleted,
|
||||
int completionCount, DateTime updatedUtc, DateTime? firstCompletedUtc)
|
||||
{
|
||||
this.templateId = templateId;
|
||||
this.phase = phase;
|
||||
SnappedPieces = snappedPieces;
|
||||
RegionColors = regionColors;
|
||||
this.hasThumbnail = hasThumbnail;
|
||||
this.hasBeenCompleted = hasBeenCompleted;
|
||||
this.completionCount = completionCount;
|
||||
UpdatedUtc = updatedUtc;
|
||||
FirstCompletedUtc = firstCompletedUtc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26d8ea985632441b09965ff3dc2f6bd7
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Darkmatter.Core.Data.Dynamic.Features.Progression
|
||||
{
|
||||
[Serializable]
|
||||
public struct ProgressionRootDto
|
||||
{
|
||||
public List<DrawingProgress> records;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3c8f422a1719468387c90bdad95cf992
|
||||
timeCreated: 1779887245
|
||||
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace Darkmatter.Core.Data.Dynamic.Features.Progression
|
||||
{
|
||||
[Serializable]
|
||||
public struct RegionColorEntry
|
||||
{
|
||||
public string regionId;
|
||||
public float r, g, b, a;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 659d6e472d07425b86684258dda5644e
|
||||
timeCreated: 1779886727
|
||||
8
Assets/Darkmatter/Code/Core/Data/Signals.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Signals.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 205ffc93dd2bd470f9e0da53a9d65909
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Darkmatter/Code/Core/Data/Signals/Features.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Signals/Features.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f1eaf2d35f914e3d803f2549f298938
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ba28845dcdb22487a992eef060351aaa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Darkmatter.Core.Data.Signals.Features.Drawing
|
||||
{
|
||||
public record struct DrawingSelectedSignal(string TemplateId);
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d6dcdc9678a8433d858eb905dbeeede
|
||||
8
Assets/Darkmatter/Code/Core/Data/Static/Features.meta
Normal file
8
Assets/Darkmatter/Code/Core/Data/Static/Features.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 064db7ec7e054459584db0e034cb8b6f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3953b868e0bd442f781b75f449885c22
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using System.Collections.Generic;
|
||||
using Darkmatter.Core.Contracts.Features.Coloring;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Data.Static.Features.Coloring
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Darkmatter/Coloring/New Color Palette")]
|
||||
public class ColorPaletteSO : ScriptableObject, IColorPalette
|
||||
{
|
||||
[field: SerializeField] public string Id { get; private set; }
|
||||
[field: SerializeField] public List<Color> Colors { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e0a4931af72ae4456a42012c6fc82eb6
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 168f5fe0aa08d4912813b586b93d5229
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Core.Data.Dynamic.Features.Coloring;
|
||||
using Darkmatter.Core.Data.Static.Features.ShapeBuilder;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Data.Static.Features.DrawingTemplate
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Darkmatter/Drawing/New Drawing Template")]
|
||||
public class DrawingTemplateSO : ScriptableObject, IDrawingTemplate
|
||||
{
|
||||
[field: SerializeField] public string Id { get; private set; }
|
||||
[field: SerializeField] public string DisplayName { get; private set; }
|
||||
[field: SerializeField] public Sprite DefaultThumbnail { get; private set; }
|
||||
[field: SerializeField] public Sprite PaperBackground { get; private set; }
|
||||
[field: SerializeField] public IReadOnlyList<ShapeSO> Pieces { get; private set; }
|
||||
[field: SerializeField] public IReadOnlyList<ColorRegionDTO> Regions { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 712e4ea76c27b4cdaab50081d36d953a
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58192c2a0a784950851647d3f0130ad1
|
||||
timeCreated: 1779882018
|
||||
@@ -0,0 +1,11 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Core.Data.Static.Features.ShapeBuilder
|
||||
{
|
||||
[CreateAssetMenu(fileName = "ShapeSO", menuName = "Darkmatter/Drawing/New Shape")]
|
||||
public class ShapeSO : ScriptableObject
|
||||
{
|
||||
[field: SerializeField] public string Id { get; private set; }
|
||||
[field: SerializeField] public Sprite Sprite { get; private set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd4d7742f1ae94c31b7592503ec2bc2f
|
||||
8
Assets/Darkmatter/Code/Core/Enums/Features.meta
Normal file
8
Assets/Darkmatter/Code/Core/Enums/Features.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4f15fee48e26465ca8a0f61bb616940
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed8f13f1e3a5c49d992a8de59bb9ced7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Darkmatter.Core.Enums.Features.Progression
|
||||
{
|
||||
public enum DrawingPhase
|
||||
{
|
||||
ShapeBuilding,
|
||||
Coloring,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ece528f850c24e0f8d3c33a732cc8c6
|
||||
@@ -3,6 +3,7 @@ namespace Darkmatter.Core.Enums.Services.Camera
|
||||
public enum CameraType
|
||||
{
|
||||
MainCamera,
|
||||
UICamera
|
||||
UICamera,
|
||||
CaptureCamera
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,5 @@ namespace Darkmatter.Core.Enums.Services.Scenes
|
||||
Boot,
|
||||
MainMenu,
|
||||
Gameplay,
|
||||
TestTraffic,
|
||||
VehicleTest,
|
||||
}
|
||||
}
|
||||
8
Assets/Darkmatter/Code/Features/ColorbookFlow.meta
Normal file
8
Assets/Darkmatter/Code/Features/ColorbookFlow.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4be5b3e61465b42a597ff023501b4d87
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Features.Colorbook",
|
||||
"rootNamespace": "Darkmatter.Features.Colorbook",
|
||||
"references": [
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce866130b4c60406994fd723c6f571d9
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fc9de3024c914935af320d954bfe829
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using Darkmatter.Features.Colorbook.System;
|
||||
using Darkmatter.Libs.Installers;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Colorbook.Installers
|
||||
{
|
||||
public class ColorbookFlowFeatureModule : MonoBehaviour, IModule
|
||||
{
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
builder.RegisterEntryPoint<ColorbookFlowController>(Lifetime.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7c0cf8383e144b9096adb577b377263
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e78bbba3617a14cd1b33c5df9068920f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.Colorbook.System;
|
||||
|
||||
public class ColorbookFlowController : IAsyncStartable
|
||||
{
|
||||
private readonly IDrawingCatalogController _drawingCatalog;
|
||||
|
||||
public async UniTask StartAsync(CancellationToken cancellation = new CancellationToken())
|
||||
{
|
||||
await _drawingCatalog.InitializeAsync(cancellation);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46c37747ebcd4d0aa9ff3bf9fe9e26fd
|
||||
timeCreated: 1779888455
|
||||
8
Assets/Darkmatter/Code/Features/DrawingCatalog.meta
Normal file
8
Assets/Darkmatter/Code/Features/DrawingCatalog.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1543e11e36b1a414588e088a16a3e88e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Features.DrawingCatalog",
|
||||
"rootNamespace": "Darkmatter.Features.DrawingCatalog",
|
||||
"references": [
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:b4c9f7fbf1e144933a1797dc208ece5f",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb9b7ee4936ff42bebd83ca110182103
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 364ed66782700401dbf48ad43c2792aa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Features.DrawingCatalog.Systems;
|
||||
using Darkmatter.Libs.Installers;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.DrawingCatalog.Installers
|
||||
{
|
||||
public class DrawingCatalogFeatureModule : MonoBehaviour, IModule
|
||||
{
|
||||
[SerializeField] private DrawingCatalogView drawingCatalogView;
|
||||
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
builder.Register<IDrawingCatalogController, DrawingCatalogController>(Lifetime.Singleton);
|
||||
if(drawingCatalogView != null)
|
||||
builder.RegisterEntryPoint<DrawingCatalogPresenter>().WithParameter(drawingCatalogView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a27ff086c35c847439a25f41463be16f
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 387876bf9c3cf4aa58cefa4845801ca1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Core.Contracts.Features.Progression;
|
||||
using Darkmatter.Core.Data.Signals.Features.Drawing;
|
||||
using Darkmatter.Libs.Observer;
|
||||
using ZLinq;
|
||||
|
||||
namespace Darkmatter.Features.DrawingCatalog.Systems;
|
||||
|
||||
public sealed class DrawingCatalogController : IDrawingCatalogController
|
||||
{
|
||||
private readonly IDrawingTemplateCatalog _catalog;
|
||||
private readonly IEventBus _bus;
|
||||
private readonly IProgressionSystem _progression;
|
||||
|
||||
private readonly List<string> _visible = new();
|
||||
public IReadOnlyList<string> VisibleIds => _visible;
|
||||
public event Action ListChanged;
|
||||
|
||||
public DrawingCatalogController(
|
||||
IDrawingTemplateCatalog catalog,
|
||||
IProgressionSystem progression,
|
||||
IEventBus bus)
|
||||
{
|
||||
_catalog = catalog;
|
||||
_progression = progression;
|
||||
_bus = bus;
|
||||
}
|
||||
|
||||
public async UniTask InitializeAsync(CancellationToken ct)
|
||||
{
|
||||
await _catalog.FetchAsync();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void OnTemplateSelected(string id)
|
||||
{
|
||||
_bus.Publish(new DrawingSelectedSignal(id));
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
_visible.Clear();
|
||||
var all = _catalog.AllTemplateIds;
|
||||
foreach (var id in all)
|
||||
if (!_progression.CompletedTemplateIds.AsValueEnumerable().Contains(id))
|
||||
_visible.Add(id);
|
||||
foreach (var id in all)
|
||||
if (_progression.CompletedTemplateIds.AsValueEnumerable().Contains(id))
|
||||
_visible.Add(id);
|
||||
ListChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1252b78470d594aa58188c32f552c52a
|
||||
8
Assets/Darkmatter/Code/Features/DrawingCatalog/UI.meta
Normal file
8
Assets/Darkmatter/Code/Features/DrawingCatalog/UI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae468b5d4d3624234848298a64d4c1e1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Features.DrawingCatalog;
|
||||
|
||||
public struct CatalogItemVM
|
||||
{
|
||||
public string Id { get; }
|
||||
public Sprite Thumbnail { get; }
|
||||
|
||||
public CatalogItemVM(string id, Sprite thumbnail)
|
||||
{
|
||||
Id = id;
|
||||
Thumbnail = thumbnail;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b4274f9a3304610b13c6d01280139dc
|
||||
timeCreated: 1779881383
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.DrawingCatalog;
|
||||
|
||||
public class DrawingCatalogButton : MonoBehaviour
|
||||
{
|
||||
public string Id { get; private set; }
|
||||
[SerializeField] private Image thumbnail;
|
||||
[SerializeField] private Button button;
|
||||
|
||||
public void Initialize(string id,Sprite thumbnailSprite, UnityEngine.Events.UnityAction onClick)
|
||||
{
|
||||
Id = id;
|
||||
thumbnail.sprite = thumbnailSprite;
|
||||
button.onClick.AddListener(onClick);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da23f33bd6fc4bf99f251714180406f1
|
||||
timeCreated: 1779880745
|
||||
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Features.DrawingCatalog.Systems;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.DrawingCatalog
|
||||
{
|
||||
public class DrawingCatalogPresenter : IStartable, IDisposable
|
||||
{
|
||||
private readonly DrawingCatalogView _view;
|
||||
private readonly IDrawingCatalogController _controller;
|
||||
private readonly IDrawingTemplateCatalog _catalog;
|
||||
private readonly CancellationTokenSource _cts = new();
|
||||
|
||||
public DrawingCatalogPresenter(DrawingCatalogView view, DrawingCatalogController controller,
|
||||
IDrawingTemplateCatalog catalog)
|
||||
{
|
||||
_view = view;
|
||||
_controller = controller;
|
||||
_catalog = catalog;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_view.OnItemClicked += OnItemClicked;
|
||||
_controller.ListChanged += OnListChanged;
|
||||
}
|
||||
|
||||
private void OnItemClicked(string id) =>
|
||||
_controller.OnTemplateSelected(id);
|
||||
|
||||
private void OnListChanged() =>
|
||||
RefreshAsync(_cts.Token).Forget();
|
||||
|
||||
private async UniTask RefreshAsync(CancellationToken ct)
|
||||
{
|
||||
var ids = _controller.VisibleIds;
|
||||
var vms = new List<CatalogItemVM>(ids.Count);
|
||||
foreach (var id in ids)
|
||||
{
|
||||
if (ct.IsCancellationRequested) return;
|
||||
var thumb = await _catalog.GetThumbnailAsync(id);
|
||||
vms.Add(new CatalogItemVM(id, thumb));
|
||||
}
|
||||
|
||||
if (ct.IsCancellationRequested) return;
|
||||
_view.SetItems(vms);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_view.OnItemClicked -= OnItemClicked;
|
||||
_controller.ListChanged -= OnListChanged;
|
||||
_cts.Cancel();
|
||||
_cts.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e2adf581811040fd86a5cd0d11cdca0
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Pool;
|
||||
|
||||
namespace Darkmatter.Features.DrawingCatalog
|
||||
{
|
||||
public class DrawingCatalogView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private RectTransform content;
|
||||
[SerializeField] private DrawingCatalogButton buttonPrefab;
|
||||
private readonly List<DrawingCatalogButton> _buttons = new();
|
||||
|
||||
public event Action<string> OnItemClicked;
|
||||
|
||||
public void SetItems(IReadOnlyList<CatalogItemVM> items)
|
||||
{
|
||||
while (_buttons.Count < items.Count)
|
||||
{
|
||||
var button = Instantiate(buttonPrefab, content);
|
||||
var item = items[_buttons.Count];
|
||||
button.Initialize(item.Id, item.Thumbnail,
|
||||
() => { OnItemClicked?.Invoke(item.Id); });
|
||||
_buttons.Add(button);
|
||||
}
|
||||
|
||||
while (_buttons.Count > items.Count)
|
||||
{
|
||||
var last = _buttons[^1];
|
||||
_buttons.RemoveAt(_buttons.Count - 1);
|
||||
Destroy(last.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 37f3d6f10bf1349a382f7ff96cc510b7
|
||||
8
Assets/Darkmatter/Code/Features/DrawingTemplate.meta
Normal file
8
Assets/Darkmatter/Code/Features/DrawingTemplate.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bd0e94708f3eb4fafbc7048b8c1fb5d6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "Features.DrawingTemplates",
|
||||
"rootNamespace": "Darkmatter.Features.DrawingTemplates",
|
||||
"references": [
|
||||
"GUID:6a0a834eb41764f12ba55c3fb04a40cb",
|
||||
"GUID:c1c03c0e5b2f4412b9f2be1c20d6a9b1",
|
||||
"GUID:efcaa22887a6b4471829c3b3878147a2",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:f51ebe6a0ceec4240a699833d6309b23"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a005d98aed1c4439bc4689802fa2e3b
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6935767e9490e43e299d8fc639db3c13
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Features.DrawingTemplates.Systems;
|
||||
using UnityEngine;
|
||||
using Darkmatter.Libs.Installers;
|
||||
using VContainer;
|
||||
|
||||
namespace Darkmatter.Features.DrawingTemplates
|
||||
{
|
||||
public class DrawingTemplateFeatureModule : MonoBehaviour, IModule
|
||||
{
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
builder.Register<IDrawingTemplateCatalog, AddressableDrawingTemplateCatalog>(Lifetime.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa578cd62ad074dbf91b5228c3ac667e
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcb041f2ec610494198cc9b6a367d0f5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,112 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Darkmatter.Core.Contracts.Features.DrawingCatalog;
|
||||
using Darkmatter.Core.Contracts.Features.Progression;
|
||||
using Darkmatter.Core.Contracts.Services.Assets;
|
||||
using Darkmatter.Core.Data.Static.Features.DrawingTemplate;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Features.DrawingTemplates.Systems
|
||||
{
|
||||
public sealed class AddressableDrawingTemplateCatalog : IDrawingTemplateCatalog
|
||||
{
|
||||
private const string DrawingLabel = "drawing";
|
||||
|
||||
private readonly IAssetProviderService _assets;
|
||||
private readonly IProgressionSystem _progression;
|
||||
|
||||
private readonly List<string> _allIds = new();
|
||||
private readonly Dictionary<string, DrawingTemplateSO> _byId = new();
|
||||
private bool _initialized;
|
||||
|
||||
public IReadOnlyList<string> AllTemplateIds => _allIds;
|
||||
|
||||
public AddressableDrawingTemplateCatalog(
|
||||
IAssetProviderService assets,
|
||||
IProgressionSystem progression)
|
||||
{
|
||||
_assets = assets;
|
||||
_progression = progression;
|
||||
}
|
||||
|
||||
public async UniTask FetchAsync()
|
||||
{
|
||||
if (_initialized) return;
|
||||
|
||||
var templates = await _assets.LoadAssetsAsync<DrawingTemplateSO>(
|
||||
key: DrawingLabel,
|
||||
progress: null,
|
||||
cancellationToken: CancellationToken.None);
|
||||
|
||||
_allIds.Clear();
|
||||
_byId.Clear();
|
||||
foreach (var t in templates)
|
||||
{
|
||||
if (t == null || string.IsNullOrEmpty(t.Id)) continue;
|
||||
_allIds.Add(t.Id);
|
||||
_byId[t.Id] = t;
|
||||
}
|
||||
|
||||
_allIds.Sort();
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public UniTask<Sprite> GetThumbnailAsync(string id)
|
||||
{
|
||||
if (!_byId.TryGetValue(id, out var t))
|
||||
throw new KeyNotFoundException($"Template '{id}' not in catalog. Did InitializeAsync run?");
|
||||
return UniTask.FromResult(t.DefaultThumbnail);
|
||||
}
|
||||
|
||||
public UniTask<IDrawingTemplate> LoadAsync(string id)
|
||||
{
|
||||
if (_byId.TryGetValue(id, out var t))
|
||||
return UniTask.FromResult<IDrawingTemplate>(t);
|
||||
|
||||
return LoadIndividualAsync(id);
|
||||
}
|
||||
|
||||
private async UniTask<IDrawingTemplate> LoadIndividualAsync(string id)
|
||||
{
|
||||
var t = await _assets.LoadAssetAsync<DrawingTemplateSO>(
|
||||
id, progress: null, cancellationToken: CancellationToken.None);
|
||||
if (t == null)
|
||||
throw new KeyNotFoundException($"No drawing template at address '{id}'.");
|
||||
_byId[id] = t;
|
||||
if (!_allIds.Contains(id))
|
||||
{
|
||||
_allIds.Add(id);
|
||||
_allIds.Sort();
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
public void ReleaseAll()
|
||||
{
|
||||
if (!_initialized) return;
|
||||
_assets.UnloadAsset(DrawingLabel);
|
||||
_byId.Clear();
|
||||
_allIds.Clear();
|
||||
_initialized = false;
|
||||
}
|
||||
|
||||
public string GetNextTemplate(string currentId)
|
||||
{
|
||||
if (_allIds.Count == 0) return null;
|
||||
|
||||
int startIdx = currentId != null ? _allIds.IndexOf(currentId) : -1;
|
||||
|
||||
for (int i = 1; i <= _allIds.Count; i++)
|
||||
{
|
||||
var idx = (startIdx + i) % _allIds.Count;
|
||||
var candidate = _allIds[idx];
|
||||
if (!_progression.IsCompleted(candidate))
|
||||
return candidate;
|
||||
}
|
||||
|
||||
return _allIds[(startIdx + 1) % _allIds.Count];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efec7b2f8603443098cb058487c51f2d
|
||||
@@ -2,14 +2,20 @@ using Darkmatter.Core.Contracts.Features.History;
|
||||
using Darkmatter.Libs.Installers;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.History
|
||||
{
|
||||
public class HistoryServiceModule : MonoBehaviour,IServiceModule
|
||||
public class HistoryFeatureModule : MonoBehaviour, IModule
|
||||
{
|
||||
[SerializeField] private HistoryButtonsView historyButtonsView;
|
||||
|
||||
public void Register(IContainerBuilder builder)
|
||||
{
|
||||
builder.Register<IUndoStack, UndoStack>(Lifetime.Singleton);
|
||||
|
||||
if (historyButtonsView != null)
|
||||
builder.RegisterEntryPoint<HistoryButtonsPresenter>().WithParameter(historyButtonsView);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Darkmatter.Core.Contracts.Features.History;
|
||||
|
||||
@@ -10,6 +11,7 @@ namespace Darkmatter.Features.History
|
||||
private readonly LinkedList<ICommand> _undo = new();
|
||||
private readonly Stack<ICommand> _redo = new();
|
||||
|
||||
public event Action OnStackChanged;
|
||||
public bool CanUndo => _undo.Count > 0;
|
||||
public bool CanRedo => _redo.Count > 0;
|
||||
|
||||
@@ -19,6 +21,7 @@ namespace Darkmatter.Features.History
|
||||
_undo.AddLast(cmd);
|
||||
if (_undo.Count > Capacity) _undo.RemoveFirst();
|
||||
_redo.Clear();
|
||||
OnStackChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void Undo()
|
||||
@@ -28,6 +31,7 @@ namespace Darkmatter.Features.History
|
||||
_undo.RemoveLast();
|
||||
cmd.Undo();
|
||||
_redo.Push(cmd);
|
||||
OnStackChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void Redo()
|
||||
@@ -36,12 +40,15 @@ namespace Darkmatter.Features.History
|
||||
var cmd = _redo.Pop();
|
||||
cmd.Execute();
|
||||
_undo.AddLast(cmd);
|
||||
OnStackChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
foreach (var cmd in _undo) cmd.Undo();
|
||||
_undo.Clear();
|
||||
_redo.Clear();
|
||||
OnStackChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Assets/Darkmatter/Code/Features/History/UI.meta
Normal file
8
Assets/Darkmatter/Code/Features/History/UI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 659176aa2d382465cbb2c6bc8446d655
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using Darkmatter.Core.Contracts.Features.History;
|
||||
using VContainer.Unity;
|
||||
|
||||
namespace Darkmatter.Features.History
|
||||
{
|
||||
public class HistoryButtonsPresenter : IStartable, IDisposable
|
||||
{
|
||||
private readonly HistoryButtonsView _view;
|
||||
private readonly IUndoStack _undoStack;
|
||||
|
||||
public HistoryButtonsPresenter(IUndoStack undoStack, HistoryButtonsView view)
|
||||
{
|
||||
_undoStack = undoStack;
|
||||
_view = view;
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
_view.OnUndoClicked += HandleUndoClicked;
|
||||
_view.OnRedoClicked += HandleRedoClicked;
|
||||
_view.OnClearClicked += HandleClearClicked;
|
||||
UpdateButtonUI();
|
||||
_undoStack.OnStackChanged += UpdateButtonUI;
|
||||
}
|
||||
|
||||
private void HandleClearClicked()
|
||||
{
|
||||
_undoStack.Clear();
|
||||
}
|
||||
|
||||
private void HandleRedoClicked()
|
||||
{
|
||||
_undoStack.Redo();
|
||||
}
|
||||
|
||||
private void HandleUndoClicked()
|
||||
{
|
||||
_undoStack.Undo();
|
||||
}
|
||||
|
||||
private void UpdateButtonUI()
|
||||
{
|
||||
_view.SetUndoInteractable(_undoStack.CanUndo);
|
||||
_view.SetRedoInteractable(_undoStack.CanRedo);
|
||||
_view.SetClearInteractable(_undoStack.CanUndo || _undoStack.CanRedo);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_view.OnUndoClicked -= HandleUndoClicked;
|
||||
_view.OnRedoClicked -= HandleRedoClicked;
|
||||
_view.OnClearClicked -= HandleClearClicked;
|
||||
_undoStack.OnStackChanged -= UpdateButtonUI;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57867eec53ed04b9a93f0fd65639c98e
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Darkmatter.Features.History
|
||||
{
|
||||
public class HistoryButtonsView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button undoButton;
|
||||
[SerializeField] private Button redoButton;
|
||||
[SerializeField] private Button clearButton;
|
||||
|
||||
public event System.Action OnUndoClicked;
|
||||
public event System.Action OnRedoClicked;
|
||||
public event System.Action OnClearClicked;
|
||||
|
||||
void Start()
|
||||
{
|
||||
undoButton.onClick.AddListener(() => OnUndoClicked?.Invoke());
|
||||
redoButton.onClick.AddListener(() => OnRedoClicked?.Invoke());
|
||||
clearButton.onClick.AddListener(() => OnClearClicked?.Invoke());
|
||||
}
|
||||
|
||||
public void SetUndoInteractable(bool value) => undoButton.interactable = value;
|
||||
public void SetRedoInteractable(bool value) => redoButton.interactable = value;
|
||||
public void SetClearInteractable(bool value) => clearButton.interactable = value;
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
undoButton.onClick.RemoveListener(() => OnUndoClicked?.Invoke());
|
||||
redoButton.onClick.RemoveListener(() => OnRedoClicked?.Invoke());
|
||||
clearButton.onClick.RemoveListener(() => OnClearClicked?.Invoke());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b5751e64fe1947f3b800001d995f817
|
||||
8
Assets/Darkmatter/Code/Features/Progression.meta
Normal file
8
Assets/Darkmatter/Code/Features/Progression.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d1eb9cf328d194c26af62c5ad5c37a9a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user