[Fix] Rename Scripts Folder

This commit is contained in:
2026-06-07 00:30:10 +07:00
parent 79a928ae52
commit 6c9cdaf67d
140 changed files with 0 additions and 0 deletions
@@ -0,0 +1,52 @@
using Minesweeper.Config;
using Minesweeper.Core;
using Minesweeper.Presentation.Views;
using UnityEngine;
namespace Minesweeper.Presentation.Factories
{
public sealed class CellViewFactory : ICellViewFactory
{
private readonly MinesweeperUiConfig uiConfig;
public CellViewFactory(MinesweeperUiConfig uiConfig)
{
this.uiConfig = uiConfig;
}
public CellView CreateCell(BoardCellData cell, Transform parent)
{
var prefab = uiConfig.CellButtonPrefab;
if (prefab == null)
{
Debug.LogError("CellViewFactory failed: CellButtonPrefab is not assigned.");
return null;
}
var go = Object.Instantiate(prefab, parent);
go.name = BuildCellName(cell.X, cell.Y, cell.DisplayValue);
var view = go.GetComponent<CellView>();
if (view == null)
{
Debug.LogError($"CellViewFactory failed: '{prefab.name}' is missing CellView.");
Object.Destroy(go);
return null;
}
view.Initialize(cell.X, cell.Y);
return view;
}
public string BuildCellName(int x, int y, int value, bool isMine)
{
return $"bt_{x}_{y}_{(isMine ? "M" : value.ToString())}";
}
public string BuildCellName(int x, int y, string displayValue)
{
return $"bt_{x}_{y}_{displayValue}";
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 681a16a970ddf3546bb4f99d93a184ca
@@ -0,0 +1,13 @@
using Minesweeper.Core;
using Minesweeper.Presentation.Views;
using UnityEngine;
namespace Minesweeper.Presentation.Factories
{
public interface ICellViewFactory
{
CellView CreateCell(BoardCellData cell, Transform parent);
string BuildCellName(int x, int y, int value, bool isMine);
string BuildCellName(int x, int y, string displayValue);
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 34c31a0f01c730440a2bcdac0f775dd8
@@ -0,0 +1,102 @@
using Minesweeper.Config;
using Minesweeper.Presentation.Views;
using UnityEngine;
namespace Minesweeper.Presentation.Factories
{
public sealed class MinesweeperScreenBootstrapper
{
private const string MainMenuPanelName = "MainMenuPanel";
private const string BoardGridName = "BoardGrid";
private const string PausePanelName = "PausePanel";
private const string ResultPanelName = "ResultPanel";
public MinesweeperScreenRefs Spawn(Transform contentRoot, MinesweeperScreenCatalog catalog)
{
if (contentRoot == null)
{
Debug.LogError("Minesweeper screen bootstrap failed: Content root is not assigned.");
return default;
}
if (catalog == null || !catalog.IsValid)
{
Debug.LogError("Minesweeper screen bootstrap failed: screen catalog prefab references are incomplete.");
return default;
}
ClearContent(contentRoot);
var mainMenu = SpawnScreen(catalog.MainMenuPanelPrefab, contentRoot, MainMenuPanelName, 0);
var board = SpawnScreen(catalog.BoardGridPrefab, contentRoot, BoardGridName, 1);
var pause = SpawnScreen(catalog.PausePanelPrefab, contentRoot, PausePanelName, 2);
var result = SpawnScreen(catalog.ResultPanelPrefab, contentRoot, ResultPanelName, 3);
var mainMenuView = RequireComponent<MainMenuView>(mainMenu.transform, MainMenuPanelName);
if (mainMenuView != null)
{
mainMenuView.BindRoot(mainMenu);
}
var boardView = RequireComponent<BoardView>(board.transform, BoardGridName);
var pauseView = RequireComponent<PauseView>(pause.transform, PausePanelName);
var resultView = RequireComponent<ResultView>(result.transform, ResultPanelName);
var refs = new MinesweeperScreenRefs(
mainMenuView,
boardView,
pauseView,
resultView);
mainMenu.SetActive(false);
board.SetActive(false);
pause.SetActive(false);
result.SetActive(false);
return refs;
}
private static GameObject SpawnScreen(GameObject prefab, Transform parent, string expectedName, int siblingIndex)
{
var instance = Object.Instantiate(prefab, parent, false);
instance.name = expectedName;
instance.transform.SetSiblingIndex(siblingIndex);
Stretch(instance.GetComponent<RectTransform>());
return instance;
}
private static void ClearContent(Transform contentRoot)
{
for (var i = contentRoot.childCount - 1; i >= 0; i--)
{
var child = contentRoot.GetChild(i);
child.SetParent(null, false);
Object.Destroy(child.gameObject);
}
}
private static T RequireComponent<T>(Transform root, string ownerName) where T : Component
{
var component = root.GetComponent<T>();
if (component == null)
{
Debug.LogError($"Minesweeper screen bootstrap failed: '{ownerName}' is missing {typeof(T).Name}.");
}
return component;
}
private static void Stretch(RectTransform rectTransform)
{
if (rectTransform == null)
{
return;
}
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.offsetMin = Vector2.zero;
rectTransform.offsetMax = Vector2.zero;
}
}
}
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 38a228c86699cdb499351cf807842dfb