Cleanup compile warnings, cleanup logs, spruce up level selection menu

This commit is contained in:
Michal Pikulski
2025-10-28 14:31:17 +01:00
parent a5b1a4f8a0
commit 43779c560e
67 changed files with 4814 additions and 1050 deletions

View File

@@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppleHills.Core.Settings;
using Core;
using UnityEngine;
namespace Bootstrap
@@ -56,7 +58,7 @@ namespace Bootstrap
IsBootComplete = true;
Debug.Log("[BootCompletionService] Boot process completed, executing initialization actions");
LogDebugMessage("Boot process completed, executing initialization actions");
// Execute initialization actions in priority order (lower number = higher priority)
ExecuteInitializationActions();
@@ -67,7 +69,7 @@ namespace Bootstrap
// Complete the task for async waiters
_bootCompletionTask.TrySetResult(true);
Debug.Log("[BootCompletionService] All boot completion handlers executed");
LogDebugMessage("All boot completion handlers executed");
}
/// <summary>
@@ -90,21 +92,21 @@ namespace Bootstrap
if (IsBootComplete)
{
// If boot is already complete, execute immediately
Debug.Log($"[BootCompletionService] Executing late registration: {name} (Priority: {priority})");
LogDebugMessage($"Executing late registration: {name} (Priority: {priority})");
try
{
action();
}
catch (Exception ex)
{
Debug.LogError($"[BootCompletionService] Error executing init action '{name}': {ex}");
LogDebugMessage($"Error executing init action '{name}': {ex}");
}
}
else
{
// Otherwise add to the queue
_initializationActions.Add(initAction);
Debug.Log($"[BootCompletionService] Registered init action: {name} (Priority: {priority})");
LogDebugMessage($"Registered init action: {name} (Priority: {priority})");
}
}
@@ -134,17 +136,26 @@ namespace Bootstrap
{
try
{
Debug.Log($"[BootCompletionService] Executing: {action.Name} (Priority: {action.Priority})");
LogDebugMessage($"Executing: {action.Name} (Priority: {action.Priority})");
action.Action();
}
catch (Exception ex)
{
Debug.LogError($"[BootCompletionService] Error executing init action '{action.Name}': {ex}");
LogDebugMessage($"Error executing init action '{action.Name}': {ex}");
}
}
// Clear the list after execution
_initializationActions.Clear();
}
private static void LogDebugMessage(string message)
{
if (DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().bootstrapLogVerbosity <=
LogVerbosity.Debug)
{
Logging.Debug($"[BootCompletionService] {message}");
}
}
}
}

View File

@@ -1,4 +1,5 @@
using System;
using AppleHills.Core.Settings;
using UnityEngine;
using UI;
using Core;
@@ -27,10 +28,11 @@ namespace Bootstrap
private bool _bootComplete = false;
private bool _hasStartedLoading = false;
private float _sceneLoadingProgress = 0f;
private LogVerbosity _logVerbosity = LogVerbosity.Warning;
private void Start()
{
Debug.Log("[BootSceneController] Boot scene started");
LogDebugMessage("Boot scene started");
// Ensure the initial loading screen exists
if (initialLoadingScreen == null)
@@ -56,6 +58,8 @@ namespace Bootstrap
50, // Higher priority (lower number)
"BootSceneController.OnBootCompleted"
);
_logVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().bootstrapLogVerbosity;
// In debug mode, log additional information
if (debugMode)
@@ -69,12 +73,12 @@ namespace Bootstrap
/// </summary>
private void OnInitialLoadingComplete()
{
Debug.Log("[BootSceneController] Initial loading screen fully hidden, boot sequence completed");
LogDebugMessage("Initial loading screen fully hidden, boot sequence completed");
// Play the intro cinematic if available
if (CinematicsManager.Instance != null)
{
Debug.Log("[BootSceneController] Attempting to play intro cinematic");
LogDebugMessage("Attempting to play intro cinematic");
// Use LoadAndPlayCinematic to play the intro sequence
CinematicsManager.Instance.LoadAndPlayCinematic("IntroSequence");
@@ -131,13 +135,13 @@ namespace Bootstrap
{
if (debugMode)
{
Debug.Log($"[BootSceneController] Bootstrap progress: {progress:P0}, Combined: {GetCombinedProgress():P0}");
LogDebugMessage($"Bootstrap progress: {progress:P0}, Combined: {GetCombinedProgress():P0}");
}
}
private void LogDebugInfo()
{
Debug.Log($"[BootSceneController] Debug - Phase: {_currentPhase}, Bootstrap: {CustomBoot.CurrentProgress:P0}, " +
LogDebugMessage($"Debug - Phase: {_currentPhase}, Bootstrap: {CustomBoot.CurrentProgress:P0}, " +
$"Scene: {_sceneLoadingProgress:P0}, Combined: {GetCombinedProgress():P0}, Boot Complete: {_bootComplete}");
}
@@ -146,7 +150,7 @@ namespace Bootstrap
// Unsubscribe to prevent duplicate calls
CustomBoot.OnBootCompleted -= OnBootCompleted;
Debug.Log("[BootSceneController] Boot process completed");
LogDebugMessage("Boot process completed");
_bootComplete = true;
// After a small delay, start loading the main menu
@@ -166,7 +170,7 @@ namespace Bootstrap
private async void LoadMainScene()
{
Debug.Log($"[BootSceneController] Loading main menu scene: {mainSceneName}");
LogDebugMessage($"Loading main menu scene: {mainSceneName}");
try
{
@@ -180,7 +184,7 @@ namespace Bootstrap
if (debugMode)
{
Debug.Log($"[BootSceneController] Scene loading raw: {value:P0}, Combined: {GetCombinedProgress():P0}");
LogDebugMessage($"Scene loading raw: {value:P0}, Combined: {GetCombinedProgress():P0}");
}
});
@@ -229,7 +233,7 @@ namespace Bootstrap
Scene currentScene = SceneManager.GetActiveScene();
string startingSceneName = currentScene.name;
Debug.Log($"[BootSceneController] Unloading StartingScene: {startingSceneName}");
LogDebugMessage($"Unloading StartingScene: {startingSceneName}");
// Unload the StartingScene
await SceneManager.UnloadSceneAsync(startingSceneName);
@@ -238,7 +242,7 @@ namespace Bootstrap
Scene mainMenuScene = SceneManager.GetSceneByName(mainSceneName);
SceneManager.SetActiveScene(mainMenuScene);
Debug.Log($"[BootSceneController] Transition complete: {startingSceneName} unloaded, {mainSceneName} is now active");
LogDebugMessage($"Transition complete: {startingSceneName} unloaded, {mainSceneName} is now active");
// Destroy the boot scene controller since its job is done
Destroy(gameObject);
@@ -266,5 +270,13 @@ namespace Bootstrap
_progressAction?.Invoke(value);
}
}
private void LogDebugMessage(string message)
{
if ( _logVerbosity <= LogVerbosity.Debug)
{
Logging.Debug($"[BootSceneController] {message}");
}
}
}
}

View File

@@ -1,5 +1,7 @@
using System;
using System.Threading.Tasks;
using AppleHills.Core.Settings;
using Core;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
@@ -99,7 +101,7 @@ namespace Bootstrap
if (Application.isPlaying)
{
// Direct call to boot completion service
Debug.Log("[CustomBoot] Calling BootCompletionService.HandleBootCompleted()");
LogDebugMessage("Calling BootCompletionService.HandleBootCompleted()");
BootCompletionService.HandleBootCompleted();
}
}
@@ -119,7 +121,7 @@ namespace Bootstrap
if (Application.isPlaying)
{
// Direct call to boot completion service
Debug.Log("[CustomBoot] Calling BootCompletionService.HandleBootCompleted()");
LogDebugMessage("Calling BootCompletionService.HandleBootCompleted()");
BootCompletionService.HandleBootCompleted();
}
}
@@ -227,7 +229,16 @@ namespace Bootstrap
{
CurrentProgress = Mathf.Clamp01(progress);
OnBootProgressChanged?.Invoke(CurrentProgress);
Debug.Log($"[CustomBoot] Progress: {CurrentProgress:P0}");
LogDebugMessage($"Progress: {CurrentProgress:P0}");
}
private static void LogDebugMessage(string message)
{
if (DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().bootstrapLogVerbosity <=
LogVerbosity.Debug)
{
Logging.Debug($"[CustomBoot] {message}");
}
}
}
}

View File

@@ -1,8 +1,9 @@
using System;
using System.Collections;
using AppleHills.Core.Settings;
using Core;
using UnityEngine;
using UnityEngine.UI;
using Core;
namespace Bootstrap
{
@@ -40,7 +41,9 @@ namespace Bootstrap
/// Current progress provider being used for the loading screen
/// </summary>
private ProgressProvider _currentProgressProvider;
private LogVerbosity _logVerbosity = LogVerbosity.Warning;
/// <summary>
/// Default progress provider that returns 0 (or 1 if loading is complete)
/// </summary>
@@ -62,7 +65,12 @@ namespace Bootstrap
loadingScreenContainer.SetActive(false);
}
}
private void Start()
{
_logVerbosity = DeveloperSettingsProvider.Instance.GetSettings<DebugSettings>().bootstrapLogVerbosity;
}
/// <summary>
/// Shows the loading screen and resets the progress bar to zero
/// </summary>
@@ -130,7 +138,7 @@ namespace Bootstrap
float displayProgress = Mathf.Min(steadyProgress, actualProgress);
// Log the progress values for debugging
Debug.Log($"[InitialLoadingScreen] Progress - Default: {steadyProgress:F2}, Actual: {actualProgress:F2}, Display: {displayProgress:F2}");
LogDebugMessage($"Progress - Default: {steadyProgress:F2}, Actual: {actualProgress:F2}, Display: {displayProgress:F2}");
// Directly set the progress bar fill amount without smoothing
if (progressBarImage != null)
@@ -143,7 +151,7 @@ namespace Bootstrap
if (steadyProgress >= 1.0f && displayProgress >= 1.0f)
{
_animationComplete = true;
Debug.Log("[InitialLoadingScreen] Animation complete");
LogDebugMessage("Animation complete");
break;
}
@@ -155,7 +163,7 @@ namespace Bootstrap
if (progressBarImage != null)
{
progressBarImage.fillAmount = 1.0f;
Debug.Log("[InitialLoadingScreen] Final progress set to 1.0");
LogDebugMessage("Final progress set to 1.0");
}
// Hide the screen if loading is also complete
@@ -164,7 +172,7 @@ namespace Bootstrap
if (loadingScreenContainer != null)
{
loadingScreenContainer.SetActive(false);
Debug.Log("[InitialLoadingScreen] Animation AND loading complete, hiding screen");
LogDebugMessage("Animation AND loading complete, hiding screen");
// Invoke the callback when fully hidden
_onLoadingScreenFullyHidden?.Invoke();
@@ -181,7 +189,7 @@ namespace Bootstrap
/// </summary>
public void HideLoadingScreen()
{
Debug.Log("[InitialLoadingScreen] Loading complete, marking loading as finished");
LogDebugMessage("Loading complete, marking loading as finished");
// Mark that loading is complete
_loadingComplete = true;
@@ -192,7 +200,7 @@ namespace Bootstrap
if (loadingScreenContainer != null)
{
loadingScreenContainer.SetActive(false);
Debug.Log("[InitialLoadingScreen] Animation already complete, hiding screen immediately");
LogDebugMessage("Animation already complete, hiding screen immediately");
// Invoke the callback when fully hidden
_onLoadingScreenFullyHidden?.Invoke();
@@ -202,7 +210,7 @@ namespace Bootstrap
}
else
{
Debug.Log("[InitialLoadingScreen] Animation still in progress, waiting for it to complete");
LogDebugMessage("Animation still in progress, waiting for it to complete");
// The coroutine will handle hiding when animation completes
}
}
@@ -236,5 +244,13 @@ namespace Bootstrap
return tcs.Task;
}
private void LogDebugMessage(string message)
{
if ( _logVerbosity <= LogVerbosity.Debug)
{
Logging.Debug($"[InitialLoadingScreen] {message}");
}
}
}
}