-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
1,318 additions
and
75 deletions.
There are no files selected for viewing
1,255 changes: 1,187 additions & 68 deletions
1,255
src/Visual novel/Assets/Data/Addressables/Screens/DialogueScreen.prefab
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 17 additions & 1 deletion
18
src/Visual novel/Assets/Scripts/Infrastructure/ScenesManagers/Core/HistoryManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,25 @@ | ||
namespace Infrastructure.ScenesManagers.Core | ||
using UI.Dialogue; | ||
|
||
namespace Infrastructure.ScenesManagers.Core | ||
{ | ||
public class HistoryManager | ||
{ | ||
public HistoryManager(HistoryUI historyUI) | ||
{ | ||
_historyUI = historyUI; | ||
} | ||
|
||
private readonly HistoryUI _historyUI; | ||
|
||
public void OpenDialogHistory() | ||
{ | ||
_historyUI.SetActivePanel(true); | ||
_historyUI.RegisterBackButtonCallback(() => _historyUI.SetActivePanel(false)); | ||
} | ||
|
||
public void AddedDialogInHistory(string id,string name, string text) | ||
{ | ||
_historyUI.CreateHistoryPhrase(id, name, text); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/Visual novel/Assets/Scripts/UI/Dialogue/HistoryPhraseUI.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using TMPro; | ||
using UnityEngine; | ||
|
||
namespace UI.Dialogue | ||
{ | ||
public class HistoryPhraseUI : MonoBehaviour | ||
{ | ||
[field: SerializeField] public TextMeshProUGUI NameText; | ||
[field: SerializeField] public TextMeshProUGUI TextText; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Visual novel/Assets/Scripts/UI/Dialogue/HistoryPhraseUI.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Units.Tools; | ||
using UnityEngine; | ||
using UnityEngine.Events; | ||
using UnityEngine.UI; | ||
|
||
namespace UI.Dialogue | ||
{ | ||
public class HistoryUI : MonoBehaviour | ||
{ | ||
[SerializeField] private GameObject _historyPhrasePrefab; | ||
[SerializeField] private Transform _contentTransform; | ||
[SerializeField] private GameObject _historyGameObject; | ||
[SerializeField] private Button _backButton; | ||
|
||
private readonly Dictionary<string, GameObject> _historyPhrases = new(); | ||
|
||
public void SetActivePanel(bool value) => _historyGameObject.SetActive(value); | ||
|
||
public void RegisterBackButtonCallback(UnityAction action) => _backButton.RegisterNewCallback(action); | ||
|
||
public void CreateHistoryPhrase(string id, string name, string text) | ||
{ | ||
var historyPhraseInstantiate = Instantiate(_historyPhrasePrefab, _contentTransform); | ||
historyPhraseInstantiate.SetActive(true); | ||
_historyPhrases.Add(id, historyPhraseInstantiate); | ||
|
||
if (historyPhraseInstantiate.TryGetComponent(out HistoryPhraseUI historyPhraseUI)) | ||
{ | ||
historyPhraseUI.NameText.text = name; | ||
historyPhraseUI.TextText.text = text; | ||
} | ||
else throw new Exception("No HistoryPhraseUI in instance historyPhrasePrefab"); | ||
|
||
var contentPanelRT = _contentTransform.GetComponent<RectTransform>(); | ||
var panel = historyPhraseInstantiate.GetComponent<RectTransform>(); | ||
|
||
var scrollSizeDelta = contentPanelRT.sizeDelta; | ||
scrollSizeDelta.y += contentPanelRT.childCount == 1 | ||
? panel.sizeDelta.y | ||
: panel.sizeDelta.y * 1.5f; | ||
|
||
contentPanelRT.sizeDelta = scrollSizeDelta; | ||
|
||
var panelAnchoredPosition = panel.anchoredPosition; | ||
panelAnchoredPosition.y = - scrollSizeDelta.y + panel.sizeDelta.y * 0.5f; | ||
panel.anchoredPosition = panelAnchoredPosition; | ||
} | ||
|
||
public void DestroyHistoryPhrase(string id) | ||
{ | ||
if (_historyPhrases.TryGetValue(id, out var go)) | ||
{ | ||
Destroy(go); | ||
_historyPhrases.Remove(id); | ||
} | ||
else throw new Exception($"No id {id} in dictionary history phrases"); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/Visual novel/Assets/Scripts/UI/Dialogue/HistoryUI.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.