From 858e49e1d99dcdc1a32177f133542f7365bbe223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gerard=20Gasc=C3=B3n?= <52170489+GerardGascon@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:28:39 +0200 Subject: [PATCH] refactor: Cleaned up score view interface --- Assets/Scripts/Presenter/ExpressionClick.cs | 6 +- Assets/Scripts/Presenter/IExpressionInput.cs | 5 -- Assets/Scripts/Presenter/IScoreView.cs | 5 ++ ...essionInput.cs.meta => IScoreView.cs.meta} | 0 .../Scripts/Presenter/SaveSystem/LoadGame.cs | 8 +- .../Collections/ExpressionInputCollection.cs | 16 ---- .../View/Collections/ScoreViewCollection.cs | 16 ++++ ...on.cs.meta => ScoreViewCollection.cs.meta} | 0 Assets/Scripts/View/Dependencies.cs | 6 +- .../UI/{ExpressionInput.cs => ScoreView.cs} | 4 +- ...ressionInput.cs.meta => ScoreView.cs.meta} | 0 Assets/Scripts/View/UI/UIVisibility.cs | 4 +- fmod_editor.log | 89 +------------------ 13 files changed, 36 insertions(+), 123 deletions(-) delete mode 100644 Assets/Scripts/Presenter/IExpressionInput.cs create mode 100644 Assets/Scripts/Presenter/IScoreView.cs rename Assets/Scripts/Presenter/{IExpressionInput.cs.meta => IScoreView.cs.meta} (100%) delete mode 100644 Assets/Scripts/View/Collections/ExpressionInputCollection.cs create mode 100644 Assets/Scripts/View/Collections/ScoreViewCollection.cs rename Assets/Scripts/View/Collections/{ExpressionInputCollection.cs.meta => ScoreViewCollection.cs.meta} (100%) rename Assets/Scripts/View/UI/{ExpressionInput.cs => ScoreView.cs} (81%) rename Assets/Scripts/View/UI/{ExpressionInput.cs.meta => ScoreView.cs.meta} (100%) diff --git a/Assets/Scripts/Presenter/ExpressionClick.cs b/Assets/Scripts/Presenter/ExpressionClick.cs index da60471..e04c9b7 100644 --- a/Assets/Scripts/Presenter/ExpressionClick.cs +++ b/Assets/Scripts/Presenter/ExpressionClick.cs @@ -3,14 +3,14 @@ namespace Presenter { public class ExpressionClick { private readonly Score _score; - private readonly IExpressionInput _view; + private readonly IScoreView _view; private readonly IRoseGrow _grow; private readonly IInputCallback _onInputReceived; private readonly IRoseSpawner _spawner; private bool CanSpawn => _score.Value % (_score.GrowIterations * _score.SpawnRate) == 0; - public ExpressionClick(Score score, IExpressionInput view, IRoseSpawner spawner, IRoseGrow grow, IInputCallback inputCallback) { + public ExpressionClick(Score score, IScoreView view, IRoseSpawner spawner, IRoseGrow grow, IInputCallback inputCallback) { _score = score; _view = view; _spawner = spawner; @@ -20,7 +20,7 @@ namespace Presenter { public void Execute() { _score.Add(); - _view.UpdateView(_score.Value, _score.GrowPercentage); + _view.UpdateView(_score.Value); _onInputReceived.OnInputReceived(); if (CanSpawn) diff --git a/Assets/Scripts/Presenter/IExpressionInput.cs b/Assets/Scripts/Presenter/IExpressionInput.cs deleted file mode 100644 index d4938f9..0000000 --- a/Assets/Scripts/Presenter/IExpressionInput.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Presenter { - public interface IExpressionInput { - void UpdateView(int score, float growPercentage); - } -} \ No newline at end of file diff --git a/Assets/Scripts/Presenter/IScoreView.cs b/Assets/Scripts/Presenter/IScoreView.cs new file mode 100644 index 0000000..3e15aa0 --- /dev/null +++ b/Assets/Scripts/Presenter/IScoreView.cs @@ -0,0 +1,5 @@ +namespace Presenter { + public interface IScoreView { + void UpdateView(int score); + } +} \ No newline at end of file diff --git a/Assets/Scripts/Presenter/IExpressionInput.cs.meta b/Assets/Scripts/Presenter/IScoreView.cs.meta similarity index 100% rename from Assets/Scripts/Presenter/IExpressionInput.cs.meta rename to Assets/Scripts/Presenter/IScoreView.cs.meta diff --git a/Assets/Scripts/Presenter/SaveSystem/LoadGame.cs b/Assets/Scripts/Presenter/SaveSystem/LoadGame.cs index 13ab70d..962c4b2 100644 --- a/Assets/Scripts/Presenter/SaveSystem/LoadGame.cs +++ b/Assets/Scripts/Presenter/SaveSystem/LoadGame.cs @@ -4,14 +4,14 @@ namespace Presenter.SaveSystem { public class LoadGame { private readonly IGameRepository _repository; private readonly Score _score; - private readonly IExpressionInput _expressionInput; + private readonly IScoreView _scoreView; private readonly IRoseSpawner _spawner; private readonly IRoseGrow _growAnimation; - public LoadGame(IGameRepository repository, Score score, IExpressionInput expressionInput, IRoseSpawner spawner, IRoseGrow growAnimation) { + public LoadGame(IGameRepository repository, Score score, IScoreView scoreView, IRoseSpawner spawner, IRoseGrow growAnimation) { _repository = repository; _score = score; - _expressionInput = expressionInput; + _scoreView = scoreView; _spawner = spawner; _growAnimation = growAnimation; } @@ -19,7 +19,7 @@ namespace Presenter.SaveSystem { public void Run() { Score newScore = _repository.LoadScore(); _score.SetFromOtherScore(newScore); - _expressionInput.UpdateView(_score.Value, _score.GrowPercentage); + _scoreView.UpdateView(_score.Value); _growAnimation.GrowStep(); int roses = _score.Value / (_score.SpawnRate * _score.GrowIterations); diff --git a/Assets/Scripts/View/Collections/ExpressionInputCollection.cs b/Assets/Scripts/View/Collections/ExpressionInputCollection.cs deleted file mode 100644 index 320969f..0000000 --- a/Assets/Scripts/View/Collections/ExpressionInputCollection.cs +++ /dev/null @@ -1,16 +0,0 @@ -using Presenter; - -namespace View.Collections { - public class ExpressionInputCollection : IExpressionInput { - private readonly IExpressionInput[] _inputs; - - public ExpressionInputCollection(IExpressionInput[] inputs) { - _inputs = inputs; - } - - public void UpdateView(int score, float growPercentage) { - foreach (IExpressionInput input in _inputs) - input.UpdateView(score, growPercentage); - } - } -} \ No newline at end of file diff --git a/Assets/Scripts/View/Collections/ScoreViewCollection.cs b/Assets/Scripts/View/Collections/ScoreViewCollection.cs new file mode 100644 index 0000000..0bc6176 --- /dev/null +++ b/Assets/Scripts/View/Collections/ScoreViewCollection.cs @@ -0,0 +1,16 @@ +using Presenter; + +namespace View.Collections { + public class ScoreViewCollection : IScoreView { + private readonly IScoreView[] _inputs; + + public ScoreViewCollection(IScoreView[] inputs) { + _inputs = inputs; + } + + public void UpdateView(int score) { + foreach (IScoreView input in _inputs) + input.UpdateView(score); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/View/Collections/ExpressionInputCollection.cs.meta b/Assets/Scripts/View/Collections/ScoreViewCollection.cs.meta similarity index 100% rename from Assets/Scripts/View/Collections/ExpressionInputCollection.cs.meta rename to Assets/Scripts/View/Collections/ScoreViewCollection.cs.meta diff --git a/Assets/Scripts/View/Dependencies.cs b/Assets/Scripts/View/Dependencies.cs index e573d0f..e27a17d 100644 --- a/Assets/Scripts/View/Dependencies.cs +++ b/Assets/Scripts/View/Dependencies.cs @@ -19,9 +19,9 @@ namespace View { private void Awake() { Score = new Score(10, 10); - IExpressionInput input = FindObjectOfType(); - IExpressionInput visibility = FindObjectOfType(); - IExpressionInput inputCollections = new ExpressionInputCollection(new[] { input, visibility }); + IScoreView input = FindObjectOfType(); + IScoreView visibility = FindObjectOfType(); + IScoreView inputCollections = new ScoreViewCollection(new[] { input, visibility }); IRoseSpawner spawner = FindObjectOfType(); diff --git a/Assets/Scripts/View/UI/ExpressionInput.cs b/Assets/Scripts/View/UI/ScoreView.cs similarity index 81% rename from Assets/Scripts/View/UI/ExpressionInput.cs rename to Assets/Scripts/View/UI/ScoreView.cs index 0561415..6dd2dad 100644 --- a/Assets/Scripts/View/UI/ExpressionInput.cs +++ b/Assets/Scripts/View/UI/ScoreView.cs @@ -4,7 +4,7 @@ using TMPro; using UnityEngine; namespace View.UI { - public class ExpressionInput : MonoBehaviour, IExpressionInput { + public class ScoreView : MonoBehaviour, IScoreView { [SerializeField] private TMP_Text text; private ExpressionClick _click; @@ -18,7 +18,7 @@ namespace View.UI { private void Update() => CheckInput(); - public void UpdateView(int score, float growPercentage) => + public void UpdateView(int score) => text.text = score.ToString(); private void CheckInput() { diff --git a/Assets/Scripts/View/UI/ExpressionInput.cs.meta b/Assets/Scripts/View/UI/ScoreView.cs.meta similarity index 100% rename from Assets/Scripts/View/UI/ExpressionInput.cs.meta rename to Assets/Scripts/View/UI/ScoreView.cs.meta diff --git a/Assets/Scripts/View/UI/UIVisibility.cs b/Assets/Scripts/View/UI/UIVisibility.cs index 7bb04da..5cdd32d 100644 --- a/Assets/Scripts/View/UI/UIVisibility.cs +++ b/Assets/Scripts/View/UI/UIVisibility.cs @@ -5,7 +5,7 @@ using UnityEngine.EventSystems; using UnityEngine.UI; namespace View.UI { - public class UIVisibility : MonoBehaviour, IExpressionInput { + public class UIVisibility : MonoBehaviour, IScoreView { [SerializeField] private CanvasGroup ui; [SerializeField] private float fadeDuration = .5f; @@ -31,7 +31,7 @@ namespace View.UI { } } - public void UpdateView(int score, float growPercentage) { + public void UpdateView(int score) { if (!_titleVisible) return; _titleVisible = false; diff --git a/fmod_editor.log b/fmod_editor.log index f9fa3fa..223aa2f 100644 --- a/fmod_editor.log +++ b/fmod_editor.log @@ -7,97 +7,10 @@ [LOG] OutputWASAPI::init : Output buffer size: 4096 samples, latency: 0.00ms, period: 10.67ms, DSP buffer: 1024 * 4 [LOG] Thread::initThread : Init FMOD stream thread. Affinity: 0x4000000000000003, Priority: 0xFFFF7FFB, Stack Size: 98304, Semaphore: No, Sleep Time: 10, Looping: Yes. [LOG] Thread::initThread : Init FMOD mixer thread. Affinity: 0x4000000000000001, Priority: 0xFFFF7FFA, Stack Size: 81920, Semaphore: No, Sleep Time: 0, Looping: Yes. -[LOG] AsyncManager::init : manager 0000020359CFD0D8 isAsync 0 updatePeriod 0.02 +[LOG] AsyncManager::init : manager 000002035DC49838 isAsync 0 updatePeriod 0.02 [LOG] AsyncManager::init : done [LOG] PlaybackSystem::init : [LOG] Thread::initThread : Init FMOD Studio sample load thread. Affinity: 0x4000000000000003, Priority: 0xFFFF7FFD, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No. [LOG] PlaybackSystem::init : done [LOG] Thread::initThread : Init FMOD Studio bank load thread. Affinity: 0x4000000000000003, Priority: 0xFFFF7FFD, Stack Size: 98304, Semaphore: No, Sleep Time: 1, Looping: No. [LOG] Manager::init : done. -[LOG] SystemI::createSound : filename = Assets/Audio/Master.bank : mode 02010082 -[LOG] SystemI::createSound : FMOD_NONBLOCKING specified. Putting into queue to be opened asynchronously! -[LOG] Thread::initThread : Init FMOD nonblocking thread (0). Affinity: 0x4000000000000003, Priority: 0xFFFF7FFC, Stack Size: 114688, Semaphore: Yes, Sleep Time: 0, Looping: Yes. -[LOG] SystemI::createSound : setdata soundi = 00000202A2449798 : node = 00000202A9AFA2E0 -[LOG] SystemI::createSound : add node to async list : head = 000002023A6557E8. list count = 0 -[LOG] AsyncThread::threadFunc : Starting Asynchronous operation on sound 00000202A2449798 -[LOG] SystemI::createSound : filename = Assets/Audio/Master.bank : mode 02010082 -[LOG] SystemI::createSound : FMOD_NONBLOCKING specified. Putting into queue to be opened asynchronously! -[LOG] SystemI::createSoundInternal : Create name='Assets/Audio/Master.bank', mode=0x02010082 -[LOG] SystemI::createSound : setdata soundi = 00000202A2449948 : node = 00000202A9AFA6A0 -[LOG] SystemI::createSoundInternal : exinfo->cbsize = 224 -[LOG] SystemI::createSound : add node to async list : head = 000002023A6557E8. list count = 0 -[LOG] SystemI::createSoundInternal : exinfo->length = 27574784 -[LOG] SystemI::createSoundInternal : exinfo->fileoffset = 10144 -[LOG] SystemI::createSoundInternal : exinfo->numsubsounds = 1 -[LOG] SystemI::createSound : filename = Assets/Audio/Master.bank : mode 02010082 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlist = 00000202A9AFA3F0 -[LOG] SystemI::createSound : FMOD_NONBLOCKING specified. Putting into queue to be opened asynchronously! -[LOG] SystemI::createSoundInternal : exinfo->inclusionlistnum = 1 -[LOG] SystemI::createSound : setdata soundi = 00000202A2449AF8 : node = 00000202A9AFA060 -[LOG] SystemI::createSoundInternal : exinfo->suggestedsoundtype = 5 -[LOG] SystemI::createSound : add node to async list : head = 000002023A6557E8. list count = 1 -[LOG] SystemI::createSoundInternal : exinfo->initialseekpostype = 1 -[LOG] SystemI::createSoundInternal : Create name='', mode=0x02000202 -[LOG] SystemI::createSoundInternal : exinfo->cbsize = 224 -[LOG] SystemI::createSoundInternal : exinfo->length = 27574784 -[LOG] SystemI::createSoundInternal : exinfo->fileoffset = 10144 -[LOG] SystemI::createSoundInternal : exinfo->numsubsounds = 1 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlist = 0000003163DFF568 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlistnum = 1 -[LOG] SystemI::createSoundInternal : exinfo->suggestedsoundtype = 5 -[LOG] SystemI::createSoundInternal : exinfo->useropen = 00007FFBF0674660 -[LOG] SystemI::createSoundInternal : exinfo->userclose = 00007FFBF0674630 -[LOG] SystemI::createSoundInternal : exinfo->userread = 00007FFBF0674730 -[LOG] SystemI::createSoundInternal : exinfo->userseek = 00007FFBF06747F0 -[LOG] SystemI::createSoundInternal : exinfo->fileuserdata = 000002035A1A08B8 -[LOG] SystemI::createSoundInternal : exinfo->initialseekpostype = 1 -[LOG] SystemI::createSoundInternal : Stream 0/1: name='Rosa_Melo_02', format=5, channels=2, frequency=48000, lengthbytes=3260640, lengthpcm=17145600, pcmblocksize=0, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.248419. -[LOG] SystemI::DSPCodecPoolRegister : register codec pool for pool type 5 -[LOG] SystemI::createSoundInternal : Sample 0/1: name='foliage_dry_crush_squeeze_crunchy_crispy_001_55111', format=5, channels=2, frequency=48000, lengthbytes=34880, lengthpcm=101376, pcmblocksize=0, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.731995. -[LOG] Thread::initThread : Init FMOD file thread. Affinity: 0x4000000000000003, Priority: 0xFFFF7FFC, Stack Size: 65536, Semaphore: No, Sleep Time: 10, Looping: Yes. -[LOG] AsyncThread::threadFunc : Finished Asynchronous operation on sound 00000202A2449798 -[LOG] AsyncThread::threadFunc : Starting Asynchronous operation on sound 00000202A2449948 -[LOG] SystemI::createSoundInternal : Create name='Assets/Audio/Master.bank', mode=0x02010082 -[LOG] SystemI::createSoundInternal : exinfo->cbsize = 224 -[LOG] SystemI::createSoundInternal : exinfo->length = 27574784 -[LOG] SystemI::createSoundInternal : exinfo->fileoffset = 10144 -[LOG] SystemI::createSoundInternal : exinfo->numsubsounds = 1 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlist = 00000202A9AFA7B0 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlistnum = 1 -[LOG] SystemI::createSoundInternal : exinfo->suggestedsoundtype = 5 -[LOG] SystemI::createSoundInternal : exinfo->initialseekpostype = 1 -[LOG] SystemI::createSoundInternal : Stream 0/1: name='Rosa_Base_01', format=5, channels=2, frequency=48000, lengthbytes=3775680, lengthpcm=17193600, pcmblocksize=0, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.174706. -[LOG] AsyncThread::threadFunc : Finished Asynchronous operation on sound 00000202A2449948 -[LOG] AsyncThread::threadFunc : Starting Asynchronous operation on sound 00000202A2449AF8 -[LOG] SystemI::createSoundInternal : Create name='Assets/Audio/Master.bank', mode=0x02010082 -[LOG] SystemI::createSoundInternal : exinfo->cbsize = 224 -[LOG] SystemI::createSoundInternal : exinfo->length = 27574784 -[LOG] SystemI::createSoundInternal : exinfo->fileoffset = 10144 -[LOG] SystemI::createSoundInternal : exinfo->numsubsounds = 1 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlist = 00000202A9AFA170 -[LOG] SystemI::createSoundInternal : exinfo->inclusionlistnum = 1 -[LOG] SystemI::createSoundInternal : exinfo->suggestedsoundtype = 5 -[LOG] SystemI::createSoundInternal : exinfo->initialseekpostype = 1 -[LOG] SystemI::createSoundInternal : Stream 0/1: name='Rosa_Ambient_Birds_01', format=5, channels=2, frequency=48000, lengthbytes=3372608, lengthpcm=17049600, pcmblocksize=0, loopstart=0, loopend=0, mode=0x00000000, channelmask=0x00000000, channelorder=0, peakvolume=0.007681. -[LOG] AsyncThread::threadFunc : Finished Asynchronous operation on sound 00000202A2449AF8 -[LOG] SoundI::release : Rosa_Ambient_Birds_01 (00000202A2449AF8) -[LOG] SoundI::release : Rosa_Ambient_Birds_01 (00000202A1232718) -[LOG] SoundI::release : Rosa_Ambient_Birds_01 (0000020235D40CE8) -[LOG] SoundI::release : Rosa_Base_01 (00000202A2449948) -[LOG] SoundI::release : Rosa_Base_01 (00000202A1232098) -[LOG] SoundI::release : Rosa_Base_01 (0000020235D40B38) -[LOG] SoundI::release : Rosa_Melo_02 (00000202A2449798) -[LOG] SoundI::release : Rosa_Melo_02 (00000202A1231A18) -[LOG] SoundI::release : Rosa_Melo_02 (0000020235D40628) -[LOG] SoundI::release : (00000202A4073688) -[LOG] SoundI::release : foliage_dry_crush_squeeze_crunchy_crispy_001_55111 (00000202A3AD7F48) -[LOG] Thread::callback : FMOD Studio update thread finished. -[LOG] Thread::callback : FMOD Studio bank load thread finished. -[LOG] Profile::disconnectAll : Profiler disconnecting all clients -[LOG] Thread::callback : FMOD Studio sample load thread finished. -[LOG] LiveUpdate::release : -[LOG] LiveUpdate::reset : Reset connection (reason Disconnected) -[LOG] Thread::callback : FMOD stream thread finished. -[LOG] Thread::callback : FMOD mixer thread finished. -[LOG] Profile::disconnectAll : Profiler disconnecting all clients -[LOG] SystemI::close : Closed.