[Add] Screen Init & Base new menu
This commit is contained in:
@@ -143,6 +143,31 @@ namespace Minesweeper.Presentation.Views
|
||||
uiConfig = config;
|
||||
}
|
||||
|
||||
public void BindScreens(MinesweeperScreenRefs refs)
|
||||
{
|
||||
if (isActiveAndEnabled)
|
||||
{
|
||||
RemoveButtonListeners();
|
||||
}
|
||||
|
||||
boardPanel = refs.BoardPanel;
|
||||
gridLayoutGroup = refs.BoardGrid;
|
||||
pauseRoot = refs.PauseRoot;
|
||||
restartButton = refs.PauseRestartButton;
|
||||
resumeButton = refs.PauseResumeButton;
|
||||
mainMenuButton = refs.PauseMainMenuButton;
|
||||
resultRoot = refs.ResultRoot;
|
||||
resultRestartButton = refs.ResultRestartButton;
|
||||
resultMainMenuButton = refs.ResultMainMenuButton;
|
||||
resultText = refs.ResultText;
|
||||
ResetResizeTracking();
|
||||
|
||||
if (isActiveAndEnabled)
|
||||
{
|
||||
AddButtonListeners();
|
||||
}
|
||||
}
|
||||
|
||||
public void RebuildBoard(IReadOnlyList<BoardCellData> cells, int width, int height, ICellViewFactory cellViewFactory, bool revealUnflaggedMines)
|
||||
{
|
||||
ClearBoard();
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Minesweeper.Presentation.Views
|
||||
{
|
||||
root = gameObject;
|
||||
}
|
||||
|
||||
AutoBind();
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
@@ -49,5 +51,23 @@ namespace Minesweeper.Presentation.Views
|
||||
{
|
||||
StartClicked?.Invoke();
|
||||
}
|
||||
|
||||
public void Bind(GameObject root, Button startButton)
|
||||
{
|
||||
this.root = root != null ? root : gameObject;
|
||||
this.startButton = startButton;
|
||||
}
|
||||
|
||||
private void AutoBind()
|
||||
{
|
||||
if (startButton == null)
|
||||
{
|
||||
var startButtonTransform = transform.Find("StartButton");
|
||||
if (startButtonTransform != null)
|
||||
{
|
||||
startButton = startButtonTransform.GetComponent<Button>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Minesweeper.Presentation.Views
|
||||
{
|
||||
public readonly struct MinesweeperScreenRefs
|
||||
{
|
||||
public MinesweeperScreenRefs(
|
||||
MainMenuView mainMenuView,
|
||||
RectTransform boardPanel,
|
||||
GridLayoutGroup boardGrid,
|
||||
GameObject pauseRoot,
|
||||
Button pauseRestartButton,
|
||||
Button pauseResumeButton,
|
||||
Button pauseMainMenuButton,
|
||||
GameObject resultRoot,
|
||||
Button resultRestartButton,
|
||||
Button resultMainMenuButton,
|
||||
TMP_Text resultText)
|
||||
{
|
||||
MainMenuView = mainMenuView;
|
||||
BoardPanel = boardPanel;
|
||||
BoardGrid = boardGrid;
|
||||
PauseRoot = pauseRoot;
|
||||
PauseRestartButton = pauseRestartButton;
|
||||
PauseResumeButton = pauseResumeButton;
|
||||
PauseMainMenuButton = pauseMainMenuButton;
|
||||
ResultRoot = resultRoot;
|
||||
ResultRestartButton = resultRestartButton;
|
||||
ResultMainMenuButton = resultMainMenuButton;
|
||||
ResultText = resultText;
|
||||
}
|
||||
|
||||
public MainMenuView MainMenuView { get; }
|
||||
public RectTransform BoardPanel { get; }
|
||||
public GridLayoutGroup BoardGrid { get; }
|
||||
public GameObject PauseRoot { get; }
|
||||
public Button PauseRestartButton { get; }
|
||||
public Button PauseResumeButton { get; }
|
||||
public Button PauseMainMenuButton { get; }
|
||||
public GameObject ResultRoot { get; }
|
||||
public Button ResultRestartButton { get; }
|
||||
public Button ResultMainMenuButton { get; }
|
||||
public TMP_Text ResultText { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a411cd19a61afa45851795dc2794651
|
||||
Reference in New Issue
Block a user