artbook added to drawing
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Darkmatter.Core;
|
||||||
using Darkmatter.Core.Data.Signals.Features.ShapeBuilder;
|
using Darkmatter.Core.Data.Signals.Features.ShapeBuilder;
|
||||||
using Darkmatter.Libs.Observer;
|
using Darkmatter.Libs.Observer;
|
||||||
using VContainer.Unity;
|
using VContainer.Unity;
|
||||||
@@ -22,11 +23,18 @@ namespace Darkmatter.Features.Coloring.UI
|
|||||||
{
|
{
|
||||||
_view.HideInstant();
|
_view.HideInstant();
|
||||||
_assembledSub = _bus.Subscribe<ShapeAssembledSignal>(_ => _view.Show());
|
_assembledSub = _bus.Subscribe<ShapeAssembledSignal>(_ => _view.Show());
|
||||||
|
_view.OnArtbookClicked += HandleArtbookClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleArtbookClicked()
|
||||||
|
{
|
||||||
|
_bus.Publish(new OpenArtBookSignal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_assembledSub?.Dispose();
|
_assembledSub?.Dispose();
|
||||||
|
_view.OnArtbookClicked -= HandleArtbookClicked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
using System;
|
||||||
using PrimeTween;
|
using PrimeTween;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace Darkmatter.Features.Coloring.UI
|
namespace Darkmatter.Features.Coloring.UI
|
||||||
{
|
{
|
||||||
@@ -8,6 +10,7 @@ namespace Darkmatter.Features.Coloring.UI
|
|||||||
{
|
{
|
||||||
[SerializeField] private RectTransform spawnRoot;
|
[SerializeField] private RectTransform spawnRoot;
|
||||||
[SerializeField] private RectTransform animatedRoot;
|
[SerializeField] private RectTransform animatedRoot;
|
||||||
|
[SerializeField] private Button artbookButton;
|
||||||
[SerializeField] private float showDuration = 0.35f;
|
[SerializeField] private float showDuration = 0.35f;
|
||||||
[SerializeField] private float hideDuration = 0.25f;
|
[SerializeField] private float hideDuration = 0.25f;
|
||||||
[SerializeField] private Vector2 hiddenOffset = new(1500f, 0f);
|
[SerializeField] private Vector2 hiddenOffset = new(1500f, 0f);
|
||||||
@@ -17,9 +20,16 @@ namespace Darkmatter.Features.Coloring.UI
|
|||||||
private Sequence _activeSequence;
|
private Sequence _activeSequence;
|
||||||
private bool _refsReady;
|
private bool _refsReady;
|
||||||
|
|
||||||
|
public event Action OnArtbookClicked;
|
||||||
public RectTransform SpawnRoot => spawnRoot;
|
public RectTransform SpawnRoot => spawnRoot;
|
||||||
|
|
||||||
private void Awake() => EnsureRefs();
|
private void Awake()
|
||||||
|
{
|
||||||
|
EnsureRefs();
|
||||||
|
if (artbookButton != null) artbookButton.onClick.AddListener(HandleArtbookClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleArtbookClicked() => OnArtbookClicked?.Invoke();
|
||||||
|
|
||||||
private void EnsureRefs()
|
private void EnsureRefs()
|
||||||
{
|
{
|
||||||
@@ -80,5 +90,10 @@ namespace Darkmatter.Features.Coloring.UI
|
|||||||
{
|
{
|
||||||
KillActive();
|
KillActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
if (artbookButton != null) artbookButton.onClick.RemoveListener(HandleArtbookClicked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Darkmatter.Core;
|
||||||
using Darkmatter.Core.Data.Signals.Features.ShapeBuilder;
|
using Darkmatter.Core.Data.Signals.Features.ShapeBuilder;
|
||||||
using Darkmatter.Libs.Observer;
|
using Darkmatter.Libs.Observer;
|
||||||
using VContainer.Unity;
|
using VContainer.Unity;
|
||||||
@@ -24,12 +25,19 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
|||||||
_view.HideInstant();
|
_view.HideInstant();
|
||||||
_startedSub = _bus.Subscribe<ShapeBuilderStartedSignal>(_ => _view.Show());
|
_startedSub = _bus.Subscribe<ShapeBuilderStartedSignal>(_ => _view.Show());
|
||||||
_assembledSub = _bus.Subscribe<ShapeAssembledSignal>(_ => _view.Hide());
|
_assembledSub = _bus.Subscribe<ShapeAssembledSignal>(_ => _view.Hide());
|
||||||
|
_view.OnArtbookClicked += HandleArtbookClicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleArtbookClicked()
|
||||||
|
{
|
||||||
|
_bus.Publish(new OpenArtBookSignal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
_startedSub?.Dispose();
|
_startedSub?.Dispose();
|
||||||
_assembledSub?.Dispose();
|
_assembledSub?.Dispose();
|
||||||
|
_view.OnArtbookClicked -= HandleArtbookClicked;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,8 @@
|
|||||||
|
using System;
|
||||||
|
using Darkmatter.Features.ShapeBuilder.Systems;
|
||||||
using PrimeTween;
|
using PrimeTween;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace Darkmatter.Features.ShapeBuilder.UI
|
namespace Darkmatter.Features.ShapeBuilder.UI
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
|||||||
{
|
{
|
||||||
[SerializeField] private RectTransform spawnRoot;
|
[SerializeField] private RectTransform spawnRoot;
|
||||||
[SerializeField] private RectTransform animatedRoot;
|
[SerializeField] private RectTransform animatedRoot;
|
||||||
|
[SerializeField] private Button artbookButton;
|
||||||
[SerializeField] private float showDuration = 0.35f;
|
[SerializeField] private float showDuration = 0.35f;
|
||||||
[SerializeField] private float hideDuration = 0.25f;
|
[SerializeField] private float hideDuration = 0.25f;
|
||||||
[SerializeField] private Vector2 hiddenOffset = new(1500f, 0f);
|
[SerializeField] private Vector2 hiddenOffset = new(1500f, 0f);
|
||||||
@@ -15,6 +19,7 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
|||||||
private CanvasGroup _canvasGroup;
|
private CanvasGroup _canvasGroup;
|
||||||
private Vector2 _shownAnchoredPos;
|
private Vector2 _shownAnchoredPos;
|
||||||
private Sequence _activeSequence;
|
private Sequence _activeSequence;
|
||||||
|
public event Action OnArtbookClicked;
|
||||||
|
|
||||||
public RectTransform SpawnRoot => spawnRoot;
|
public RectTransform SpawnRoot => spawnRoot;
|
||||||
public float SpawnWidth => spawnRoot.rect.width;
|
public float SpawnWidth => spawnRoot.rect.width;
|
||||||
@@ -24,6 +29,12 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
|||||||
_canvasGroup = GetComponent<CanvasGroup>();
|
_canvasGroup = GetComponent<CanvasGroup>();
|
||||||
if (animatedRoot == null) animatedRoot = (RectTransform)transform;
|
if (animatedRoot == null) animatedRoot = (RectTransform)transform;
|
||||||
_shownAnchoredPos = animatedRoot.anchoredPosition;
|
_shownAnchoredPos = animatedRoot.anchoredPosition;
|
||||||
|
artbookButton.onClick.AddListener(HandleArtbookClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleArtbookClicked()
|
||||||
|
{
|
||||||
|
OnArtbookClicked?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sequence Show()
|
public Sequence Show()
|
||||||
@@ -73,5 +84,10 @@ namespace Darkmatter.Features.ShapeBuilder.UI
|
|||||||
{
|
{
|
||||||
KillActive();
|
KillActive();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
artbookButton.onClick.RemoveListener(HandleArtbookClicked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ namespace Darkmatter.Services.Capture
|
|||||||
{
|
{
|
||||||
var paperCanvas = GetRootCanvas(captureObject);
|
var paperCanvas = GetRootCanvas(captureObject);
|
||||||
var disabledCanvases = DisableOtherRootCanvases(paperCanvas);
|
var disabledCanvases = DisableOtherRootCanvases(paperCanvas);
|
||||||
|
var disabledGraphics = HideNonPaperGraphics(captureObject != null ? captureObject.transform : null);
|
||||||
var cam = Camera.main;
|
var cam = Camera.main;
|
||||||
CameraClearFlags prevFlags = default;
|
CameraClearFlags prevFlags = default;
|
||||||
Color prevBg = default;
|
Color prevBg = default;
|
||||||
@@ -26,7 +27,21 @@ namespace Darkmatter.Services.Capture
|
|||||||
|
|
||||||
await UniTask.WaitForEndOfFrame(cancellationToken);
|
await UniTask.WaitForEndOfFrame(cancellationToken);
|
||||||
|
|
||||||
var fullScreen = ScreenCapture.CaptureScreenshotAsTexture();
|
int sw = Screen.width;
|
||||||
|
int sh = Screen.height;
|
||||||
|
var captureRT = RenderTexture.GetTemporary(sw, sh, 0, RenderTextureFormat.ARGB32);
|
||||||
|
ScreenCapture.CaptureScreenshotIntoRenderTexture(captureRT);
|
||||||
|
|
||||||
|
var prevActive = RenderTexture.active;
|
||||||
|
RenderTexture.active = captureRT;
|
||||||
|
var fullScreen = new Texture2D(sw, sh, TextureFormat.RGBA32, mipChain: false);
|
||||||
|
fullScreen.ReadPixels(new Rect(0, 0, sw, sh), 0, 0);
|
||||||
|
fullScreen.Apply();
|
||||||
|
RenderTexture.active = prevActive;
|
||||||
|
RenderTexture.ReleaseTemporary(captureRT);
|
||||||
|
|
||||||
|
FlipVertical(fullScreen);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Rect crop = ComputeCropRect(captureObject, fullScreen.width, fullScreen.height);
|
Rect crop = ComputeCropRect(captureObject, fullScreen.width, fullScreen.height);
|
||||||
@@ -62,6 +77,7 @@ namespace Darkmatter.Services.Capture
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Object.Destroy(fullScreen);
|
Object.Destroy(fullScreen);
|
||||||
|
foreach (var g in disabledGraphics) if (g != null) g.enabled = true;
|
||||||
foreach (var c in disabledCanvases) if (c != null) c.enabled = true;
|
foreach (var c in disabledCanvases) if (c != null) c.enabled = true;
|
||||||
if (cam != null)
|
if (cam != null)
|
||||||
{
|
{
|
||||||
@@ -91,6 +107,21 @@ namespace Darkmatter.Services.Capture
|
|||||||
return disabled;
|
return disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<UnityEngine.UI.Graphic> HideNonPaperGraphics(Transform paper)
|
||||||
|
{
|
||||||
|
var disabled = new List<UnityEngine.UI.Graphic>();
|
||||||
|
if (paper == null) return disabled;
|
||||||
|
var all = Object.FindObjectsByType<UnityEngine.UI.Graphic>(FindObjectsSortMode.None);
|
||||||
|
foreach (var g in all)
|
||||||
|
{
|
||||||
|
if (g == null || !g.enabled) continue;
|
||||||
|
if (g.transform.IsChildOf(paper)) continue;
|
||||||
|
g.enabled = false;
|
||||||
|
disabled.Add(g);
|
||||||
|
}
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
|
||||||
private static Rect ComputeCropRect(GameObject target, int screenW, int screenH)
|
private static Rect ComputeCropRect(GameObject target, int screenW, int screenH)
|
||||||
{
|
{
|
||||||
if (target == null || target.transform is not RectTransform rt)
|
if (target == null || target.transform is not RectTransform rt)
|
||||||
@@ -106,6 +137,18 @@ namespace Darkmatter.Services.Capture
|
|||||||
return Rect.MinMaxRect(minX, minY, maxX, maxY);
|
return Rect.MinMaxRect(minX, minY, maxX, maxY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void FlipVertical(Texture2D tex)
|
||||||
|
{
|
||||||
|
int w = tex.width, h = tex.height;
|
||||||
|
var pixels = tex.GetPixels();
|
||||||
|
var flipped = new Color[pixels.Length];
|
||||||
|
for (int y = 0; y < h; y++)
|
||||||
|
for (int x = 0; x < w; x++)
|
||||||
|
flipped[(h - 1 - y) * w + x] = pixels[y * w + x];
|
||||||
|
tex.SetPixels(flipped);
|
||||||
|
tex.Apply();
|
||||||
|
}
|
||||||
|
|
||||||
private static Texture2D Resize(Texture2D src, int width, int height)
|
private static Texture2D Resize(Texture2D src, int width, int height)
|
||||||
{
|
{
|
||||||
var rt = RenderTexture.GetTemporary(width, height);
|
var rt = RenderTexture.GetTemporary(width, height);
|
||||||
|
|||||||
8
Assets/Darkmatter/Code/Services/Music.meta
Normal file
8
Assets/Darkmatter/Code/Services/Music.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 27c2e817c276c40b19f6284b7c87860c
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Darkmatter/Code/Services/Music/Installers.meta
Normal file
8
Assets/Darkmatter/Code/Services/Music/Installers.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e1d52cf6530064afd982535de65293bb
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
8
Assets/Darkmatter/Code/Services/Music/Systems.meta
Normal file
8
Assets/Darkmatter/Code/Services/Music/Systems.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bec4745668fea4987809c8370d372048
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
20
Assets/Darkmatter/Code/Services/Music/Systems/MusicConfig.cs
Normal file
20
Assets/Darkmatter/Code/Services/Music/Systems/MusicConfig.cs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Darkmatter.Services.Music.Systems
|
||||||
|
{
|
||||||
|
[Serializable]
|
||||||
|
public readonly struct MusicConfig
|
||||||
|
{
|
||||||
|
public AudioClip DefaultTrack { get; }
|
||||||
|
public float DefaultVolume { get; }
|
||||||
|
public float CrossFadeSeconds { get; }
|
||||||
|
|
||||||
|
public MusicConfig(AudioClip defaultTrack, float defaultVolume, float crossFadeSeconds)
|
||||||
|
{
|
||||||
|
DefaultTrack = defaultTrack;
|
||||||
|
DefaultVolume = defaultVolume;
|
||||||
|
CrossFadeSeconds = crossFadeSeconds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -165,6 +165,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Features.Capture::Darkmatter.Features.Capture.CaptureFeatureModule
|
m_EditorClassIdentifier: Features.Capture::Darkmatter.Features.Capture.CaptureFeatureModule
|
||||||
captureScale: 1
|
captureScale: 1
|
||||||
captureButtonView: {fileID: 376589371}
|
captureButtonView: {fileID: 376589371}
|
||||||
|
gallerySaveView: {fileID: 0}
|
||||||
--- !u!1 &64614225
|
--- !u!1 &64614225
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -2517,6 +2518,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Features.Coloring::Darkmatter.Features.Coloring.UI.ColorPaletteHolderView
|
m_EditorClassIdentifier: Features.Coloring::Darkmatter.Features.Coloring.UI.ColorPaletteHolderView
|
||||||
spawnRoot: {fileID: 2046672212}
|
spawnRoot: {fileID: 2046672212}
|
||||||
animatedRoot: {fileID: 1518670451}
|
animatedRoot: {fileID: 1518670451}
|
||||||
|
artbookButton: {fileID: 206970557}
|
||||||
showDuration: 0.35
|
showDuration: 0.35
|
||||||
hideDuration: 0.25
|
hideDuration: 0.25
|
||||||
hiddenOffset: {x: 1500, y: 0}
|
hiddenOffset: {x: 1500, y: 0}
|
||||||
@@ -2872,6 +2874,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier: Features.ShapeBuilder::Darkmatter.Features.ShapeBuilder.UI.ShapeHolderView
|
m_EditorClassIdentifier: Features.ShapeBuilder::Darkmatter.Features.ShapeBuilder.UI.ShapeHolderView
|
||||||
spawnRoot: {fileID: 1155451091}
|
spawnRoot: {fileID: 1155451091}
|
||||||
animatedRoot: {fileID: 1989194441}
|
animatedRoot: {fileID: 1989194441}
|
||||||
|
artbookButton: {fileID: 2065186227}
|
||||||
showDuration: 0.35
|
showDuration: 0.35
|
||||||
hideDuration: 0.25
|
hideDuration: 0.25
|
||||||
hiddenOffset: {x: 1500, y: 0}
|
hiddenOffset: {x: 1500, y: 0}
|
||||||
|
|||||||
Reference in New Issue
Block a user