[Fix] Refactoring (Remove GameView) TEMP
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
using Minesweeper.Config;
|
||||
using Minesweeper.Presentation.Views;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minesweeper.Presentation.Factories
|
||||
{
|
||||
@@ -12,10 +10,6 @@ namespace Minesweeper.Presentation.Factories
|
||||
private const string BoardGridName = "BoardGrid";
|
||||
private const string PausePanelName = "PausePanel";
|
||||
private const string ResultPanelName = "ResultPanel";
|
||||
private const string RestartButtonPath = "RestartButton";
|
||||
private const string ContinueButtonPath = "ContinueButton";
|
||||
private const string MainMenuButtonPath = "MainMenuButton";
|
||||
private const string ResultTextPath = "ResultText";
|
||||
|
||||
public MinesweeperScreenRefs Spawn(Transform contentRoot, MinesweeperScreenCatalog catalog)
|
||||
{
|
||||
@@ -39,20 +33,20 @@ namespace Minesweeper.Presentation.Factories
|
||||
var result = SpawnScreen(catalog.ResultPanelPrefab, contentRoot, ResultPanelName, 3);
|
||||
|
||||
var mainMenuView = RequireComponent<MainMenuView>(mainMenu.transform, MainMenuPanelName);
|
||||
mainMenuView.BindRoot(mainMenu);
|
||||
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,
|
||||
RequireComponent<RectTransform>(board.transform, BoardGridName),
|
||||
RequireComponent<GridLayoutGroup>(board.transform, BoardGridName),
|
||||
pause,
|
||||
RequireChildComponent<Button>(pause.transform, RestartButtonPath),
|
||||
RequireChildComponent<Button>(pause.transform, ContinueButtonPath),
|
||||
RequireChildComponent<Button>(pause.transform, MainMenuButtonPath),
|
||||
result,
|
||||
RequireChildComponent<Button>(result.transform, RestartButtonPath),
|
||||
RequireChildComponent<Button>(result.transform, MainMenuButtonPath),
|
||||
RequireChildComponent<TMP_Text>(result.transform, ResultTextPath));
|
||||
boardView,
|
||||
pauseView,
|
||||
resultView);
|
||||
|
||||
mainMenu.SetActive(false);
|
||||
board.SetActive(false);
|
||||
@@ -92,24 +86,6 @@ namespace Minesweeper.Presentation.Factories
|
||||
return component;
|
||||
}
|
||||
|
||||
private static T RequireChildComponent<T>(Transform root, string path) where T : Component
|
||||
{
|
||||
var child = root.Find(path);
|
||||
if (child == null)
|
||||
{
|
||||
Debug.LogError($"Minesweeper screen bootstrap failed: '{root.name}/{path}' was not found.");
|
||||
return null;
|
||||
}
|
||||
|
||||
var component = child.GetComponent<T>();
|
||||
if (component == null)
|
||||
{
|
||||
Debug.LogError($"Minesweeper screen bootstrap failed: '{root.name}/{path}' is missing {typeof(T).Name}.");
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
private static void Stretch(RectTransform rectTransform)
|
||||
{
|
||||
if (rectTransform == null)
|
||||
|
||||
Reference in New Issue
Block a user