From e04db31a98af728f58813101cb5cc6c2e3fd0f00 Mon Sep 17 00:00:00 2001 From: Michal Pikulski Date: Mon, 24 Nov 2025 14:18:56 +0100 Subject: [PATCH] Settings cleaned up, working on dragging etc. --- .../AssetGroups/Settings.asset | 2 +- .../Core/Settings/SettingsInterfaces.cs | 4 ++ .../Core/Settings/StatueDressupSettings.cs | 11 ++++- .../Controllers/DecorationMenuController.cs | 43 ++++++++++++++----- Assets/Settings/StatueDressupSettings.asset | 13 +++++- 5 files changed, 60 insertions(+), 13 deletions(-) diff --git a/Assets/AddressableAssetsData/AssetGroups/Settings.asset b/Assets/AddressableAssetsData/AssetGroups/Settings.asset index 3d33d562..cac13c80 100644 --- a/Assets/AddressableAssetsData/AssetGroups/Settings.asset +++ b/Assets/AddressableAssetsData/AssetGroups/Settings.asset @@ -21,7 +21,7 @@ MonoBehaviour: m_SerializedLabels: [] FlaggedDuringContentUpdateRestriction: 0 - m_GUID: 359004e51663d6442b7d2b960d12b459 - m_Address: Assets/Settings/StatueDressupSettings.asset + m_Address: Settings/StatueDressupSettings m_ReadOnly: 0 m_SerializedLabels: [] FlaggedDuringContentUpdateRestriction: 0 diff --git a/Assets/Scripts/Core/Settings/SettingsInterfaces.cs b/Assets/Scripts/Core/Settings/SettingsInterfaces.cs index b5842967..99f7ae15 100644 --- a/Assets/Scripts/Core/Settings/SettingsInterfaces.cs +++ b/Assets/Scripts/Core/Settings/SettingsInterfaces.cs @@ -1,5 +1,6 @@ using UnityEngine; using System.Collections.Generic; +using Minigames.StatueDressup.Data; namespace AppleHills.Core.Settings { @@ -170,6 +171,9 @@ namespace AppleHills.Core.Settings Vector2 DefaultIconSize { get; } Vector2 DefaultAuthoredSize { get; } + // Decoration Content + List AllDecorations { get; } + // Menu Configuration int ItemsPerPage { get; } int GridColumns { get; } diff --git a/Assets/Scripts/Core/Settings/StatueDressupSettings.cs b/Assets/Scripts/Core/Settings/StatueDressupSettings.cs index bdaf9527..9038f218 100644 --- a/Assets/Scripts/Core/Settings/StatueDressupSettings.cs +++ b/Assets/Scripts/Core/Settings/StatueDressupSettings.cs @@ -1,4 +1,6 @@ -using AppleHills.Core.Settings; +using System.Collections.Generic; +using AppleHills.Core.Settings; +using Minigames.StatueDressup.Data; using UnityEngine; namespace Core.Settings @@ -16,6 +18,10 @@ namespace Core.Settings [Tooltip("Default full size for decorations when placed on statue")] [SerializeField] private Vector2 defaultAuthoredSize = new Vector2(128f, 128f); + [Header("Decoration Content")] + [Tooltip("List of all available decoration data assets")] + [SerializeField] private List allDecorations = new List(); + [Header("Menu Configuration")] [Tooltip("Number of decoration items to display per page (2 columns x 5 rows = 10)")] [SerializeField] private int itemsPerPage = 10; @@ -77,6 +83,9 @@ namespace Core.Settings public Vector2 DefaultIconSize => defaultIconSize; public Vector2 DefaultAuthoredSize => defaultAuthoredSize; + // IStatueDressupSettings implementation - Decoration Content + public List AllDecorations => allDecorations; + // IStatueDressupSettings implementation - Menu Configuration public int ItemsPerPage => itemsPerPage; public int GridColumns => gridColumns; diff --git a/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs b/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs index 244c507b..f6c93145 100644 --- a/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs +++ b/Assets/Scripts/Minigames/StatueDressup/Controllers/DecorationMenuController.cs @@ -23,10 +23,6 @@ namespace Minigames.StatueDressup.Controllers [SerializeField] private Transform statueParent; // Parent for placed decorations [SerializeField] private StatueDecorationController statueController; // Controller for registration - [Header("Configuration")] - [SerializeField] private List allDecorations = new List(); - [SerializeField] private int itemsPerPage = 10; // 2 columns x 5 rows - [Header("Layout")] [SerializeField] private GridLayoutGroup gridLayout; @@ -50,10 +46,9 @@ namespace Minigames.StatueDressup.Controllers // Get settings early _settings = GameManager.GetSettingsObject(); - // Override itemsPerPage with settings value if available - if (_settings != null) + if (_settings == null) { - itemsPerPage = _settings.ItemsPerPage; + Logging.Error("[DecorationMenuController] Failed to load StatueDressupSettings!"); } } @@ -64,11 +59,28 @@ namespace Minigames.StatueDressup.Controllers { base.OnManagedStart(); - Logging.Debug($"[DecorationMenuController] Initializing with {allDecorations.Count} decorations"); + if (_settings == null) + { + Logging.Error("[DecorationMenuController] Cannot initialize without settings!"); + return; + } + + var allDecorations = _settings.AllDecorations; + int itemsPerPage = _settings.ItemsPerPage; + + Logging.Debug($"[DecorationMenuController] Initializing with {allDecorations?.Count ?? 0} decorations"); // Calculate total pages - _totalPages = Mathf.CeilToInt((float)allDecorations.Count / itemsPerPage); - Logging.Debug($"[DecorationMenuController] Total pages: {_totalPages}"); + if (allDecorations != null && allDecorations.Count > 0) + { + _totalPages = Mathf.CeilToInt((float)allDecorations.Count / itemsPerPage); + Logging.Debug($"[DecorationMenuController] Total pages: {_totalPages}"); + } + else + { + Logging.Warning("[DecorationMenuController] No decorations found in settings!"); + _totalPages = 0; + } // Setup buttons if (nextPageButton != null) @@ -93,6 +105,17 @@ namespace Minigames.StatueDressup.Controllers /// private void PopulateCurrentPage() { + if (_settings == null) return; + + var allDecorations = _settings.AllDecorations; + int itemsPerPage = _settings.ItemsPerPage; + + if (allDecorations == null || allDecorations.Count == 0) + { + Logging.Warning("[DecorationMenuController] No decorations to populate"); + return; + } + Logging.Debug($"[DecorationMenuController] Populating page {_currentPage + 1}/{_totalPages}"); // Clear existing items diff --git a/Assets/Settings/StatueDressupSettings.asset b/Assets/Settings/StatueDressupSettings.asset index 0ec0ad52..2a7a1887 100644 --- a/Assets/Settings/StatueDressupSettings.asset +++ b/Assets/Settings/StatueDressupSettings.asset @@ -14,7 +14,18 @@ MonoBehaviour: m_EditorClassIdentifier: AppleHillsScripts::Core.Settings.StatueDressupSettings defaultIconSize: {x: 64, y: 64} defaultAuthoredSize: {x: 128, y: 128} - itemsPerPage: 10 + allDecorations: + - {fileID: 11400000, guid: 2ea75de9ff6dbfb4b8c246a654868479, type: 2} + - {fileID: 11400000, guid: ca949a6208ce5b5488e90ea3e2eed6df, type: 2} + - {fileID: 11400000, guid: 5efa934e009bc234e920904b05db3c2f, type: 2} + - {fileID: 11400000, guid: 8819ec8b1f4910a4494755cf043636d1, type: 2} + - {fileID: 11400000, guid: b09b79db8ef15144bb2138ec59f26a9c, type: 2} + - {fileID: 11400000, guid: 8838477f768600848813a215ab6a46fe, type: 2} + - {fileID: 11400000, guid: f0df83df3cff9d84ba9fd4895e5d1b58, type: 2} + - {fileID: 11400000, guid: 4101d48e428899d409df02f24c83571f, type: 2} + - {fileID: 11400000, guid: b01ee8334ee052b4784225337e9a5ece, type: 2} + - {fileID: 11400000, guid: a5d493c2c7c9cf74cab038023b401273, type: 2} + itemsPerPage: 8 gridColumns: 2 gridSpacing: {x: 10, y: 10} dragScaleTransitionDuration: 0.2