feat: Setup MVP
This commit is contained in:
parent
14fdd4558e
commit
1dd490b7ed
27 changed files with 555 additions and 52 deletions
|
@ -1,29 +0,0 @@
|
|||
using SatorImaging.AppWindowUtility;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class ClickTest : MonoBehaviour {
|
||||
[SerializeField] private TMP_Text text;
|
||||
private int _presses;
|
||||
private bool _pressed;
|
||||
|
||||
//VK_OEM_2 = 0xBF | cedilla
|
||||
//https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||
private const int Key = 0xBF;
|
||||
|
||||
private void OnEnable() {
|
||||
AppWindowUtility.AlwaysOnTop = true;
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
if (_pressed && Win32API.GetAsyncKeyState(Key) == 0) {
|
||||
_pressed = false;
|
||||
return;
|
||||
}
|
||||
if (!_pressed && Win32API.GetAsyncKeyState(Key) != 0) {
|
||||
_presses++;
|
||||
text.text = _presses.ToString();
|
||||
_pressed = true;
|
||||
}
|
||||
}
|
||||
}
|
8
Assets/Scripts/Domain.meta
Normal file
8
Assets/Scripts/Domain.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 31f569b778d15a1458d7cd3c75abb2a8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
13
Assets/Scripts/Domain/Model.cs
Normal file
13
Assets/Scripts/Domain/Model.cs
Normal file
|
@ -0,0 +1,13 @@
|
|||
namespace Domain {
|
||||
public class Model {
|
||||
public int Score { private set; get; }
|
||||
|
||||
public Model(int score) {
|
||||
Score = score;
|
||||
}
|
||||
|
||||
public void AddScore(int score) {
|
||||
Score += score;
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Domain/Model.cs.meta
Normal file
3
Assets/Scripts/Domain/Model.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6de5729981004dd98a2b547a5acf3bb2
|
||||
timeCreated: 1712931104
|
3
Assets/Scripts/Domain/SantJordi.Domain.asmdef
Normal file
3
Assets/Scripts/Domain/SantJordi.Domain.asmdef
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"name": "SantJordi.Domain"
|
||||
}
|
7
Assets/Scripts/Domain/SantJordi.Domain.asmdef.meta
Normal file
7
Assets/Scripts/Domain/SantJordi.Domain.asmdef.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 23c7c01f8c5436c429399011615ce636
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Scripts/Domain/Win32API.cs
Normal file
29
Assets/Scripts/Domain/Win32API.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Domain {
|
||||
public static class Win32API {
|
||||
private static bool _cTrencadaWasPressed;
|
||||
private static bool _cTrencadaPressed;
|
||||
//VK_OEM_2 = 0xBF | cedilla
|
||||
//https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes
|
||||
private const int Key = 0xBF;
|
||||
|
||||
public static void UpdateInput() {
|
||||
_cTrencadaWasPressed = _cTrencadaPressed;
|
||||
if (_cTrencadaPressed && GetAsyncKeyState(Key) == 0) {
|
||||
_cTrencadaPressed = false;
|
||||
return;
|
||||
}
|
||||
if (!_cTrencadaPressed && GetAsyncKeyState(Key) != 0) {
|
||||
_cTrencadaPressed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CTrencadaDown() {
|
||||
return _cTrencadaPressed && !_cTrencadaWasPressed;
|
||||
}
|
||||
|
||||
[DllImport("User32.dll")]
|
||||
private static extern short GetAsyncKeyState(int vKey);
|
||||
}
|
||||
}
|
3
Assets/Scripts/Presenter.meta
Normal file
3
Assets/Scripts/Presenter.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a8f42965ba1e4258a0b35587e17f86db
|
||||
timeCreated: 1712930859
|
18
Assets/Scripts/Presenter/CTrencadaClick.cs
Normal file
18
Assets/Scripts/Presenter/CTrencadaClick.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using Domain;
|
||||
|
||||
namespace Presenter {
|
||||
public class CTrencadaClick {
|
||||
private readonly Model _model;
|
||||
private readonly ICTrencadaInput _view;
|
||||
|
||||
public CTrencadaClick(Model model, ICTrencadaInput view) {
|
||||
_model = model;
|
||||
_view = view;
|
||||
}
|
||||
|
||||
public void Execute() {
|
||||
_model.AddScore(1);
|
||||
_view.UpdateView(_model.Score);
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/Presenter/CTrencadaClick.cs.meta
Normal file
3
Assets/Scripts/Presenter/CTrencadaClick.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6cbffd8965b14583b8d2b3d4dc852e8d
|
||||
timeCreated: 1712930886
|
5
Assets/Scripts/Presenter/ICTrencadaInput.cs
Normal file
5
Assets/Scripts/Presenter/ICTrencadaInput.cs
Normal file
|
@ -0,0 +1,5 @@
|
|||
namespace Presenter {
|
||||
public interface ICTrencadaInput {
|
||||
void UpdateView(int score);
|
||||
}
|
||||
}
|
3
Assets/Scripts/Presenter/ICTrencadaInput.cs.meta
Normal file
3
Assets/Scripts/Presenter/ICTrencadaInput.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ad480317372b4bde9e61c8cf5b56ba72
|
||||
timeCreated: 1712931293
|
4
Assets/Scripts/Presenter/SantJordi.Presenter.asmdef
Normal file
4
Assets/Scripts/Presenter/SantJordi.Presenter.asmdef
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "SantJordi.Presenter",
|
||||
"references":[ "GUID:23c7c01f8c5436c429399011615ce636" ]
|
||||
}
|
7
Assets/Scripts/Presenter/SantJordi.Presenter.asmdef.meta
Normal file
7
Assets/Scripts/Presenter/SantJordi.Presenter.asmdef.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d9011953b32919841a6c357880a50fb3
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Scripts/View.meta
Normal file
8
Assets/Scripts/View.meta
Normal file
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c9bbab33dc7baf84c96e55ad7ae6f129
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Scripts/View/CTrencadaInput.cs
Normal file
32
Assets/Scripts/View/CTrencadaInput.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using Domain;
|
||||
using Presenter;
|
||||
using SatorImaging.AppWindowUtility;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace View {
|
||||
public class CTrencadaInput : MonoBehaviour, ICTrencadaInput {
|
||||
[SerializeField] private TMP_Text text;
|
||||
private CTrencadaClick _click;
|
||||
|
||||
private void Start() {
|
||||
AppWindowUtility.AlwaysOnTop = true;
|
||||
|
||||
_click = FindObjectOfType<Dependencies>().CTrencadaClick;
|
||||
}
|
||||
|
||||
private void Update() {
|
||||
CheckInput();
|
||||
}
|
||||
|
||||
private void CheckInput() {
|
||||
Win32API.UpdateInput();
|
||||
if (Win32API.CTrencadaDown())
|
||||
_click.Execute();
|
||||
}
|
||||
|
||||
public void UpdateView(int score) {
|
||||
text.text = score.ToString();
|
||||
}
|
||||
}
|
||||
}
|
20
Assets/Scripts/View/CloseButton.cs
Normal file
20
Assets/Scripts/View/CloseButton.cs
Normal file
|
@ -0,0 +1,20 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace View {
|
||||
public class CloseButton : MonoBehaviour {
|
||||
private Button _button;
|
||||
|
||||
private void Start() {
|
||||
_button = GetComponent<Button>();
|
||||
_button.onClick.AddListener(CloseClicked);
|
||||
}
|
||||
|
||||
private void CloseClicked() {
|
||||
#if UNITY_EDITOR
|
||||
Debug.Log("Quit");
|
||||
#endif
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/View/CloseButton.cs.meta
Normal file
11
Assets/Scripts/View/CloseButton.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f297a9343fac1cf42b0de26c43db994f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
18
Assets/Scripts/View/Dependencies.cs
Normal file
18
Assets/Scripts/View/Dependencies.cs
Normal file
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using Domain;
|
||||
using Presenter;
|
||||
using UnityEngine;
|
||||
|
||||
namespace View {
|
||||
public class Dependencies : MonoBehaviour {
|
||||
public CTrencadaClick CTrencadaClick { private set; get; }
|
||||
public Model Model { private set; get; }
|
||||
|
||||
private void Awake() {
|
||||
Model = new Model(0);
|
||||
|
||||
ICTrencadaInput input = FindObjectOfType<CTrencadaInput>();
|
||||
CTrencadaClick = new CTrencadaClick(Model, input);
|
||||
}
|
||||
}
|
||||
}
|
3
Assets/Scripts/View/Dependencies.cs.meta
Normal file
3
Assets/Scripts/View/Dependencies.cs.meta
Normal file
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2892d40567e945b585f5986911ae2bcd
|
||||
timeCreated: 1712931517
|
19
Assets/Scripts/View/SantJordi.View.asmdef
Normal file
19
Assets/Scripts/View/SantJordi.View.asmdef
Normal file
|
@ -0,0 +1,19 @@
|
|||
{
|
||||
"name": "SantJordi.View",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:23c7c01f8c5436c429399011615ce636",
|
||||
"GUID:d9011953b32919841a6c357880a50fb3",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:1220ccfff01d26041a9bb8cd7ae584af"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
7
Assets/Scripts/View/SantJordi.View.asmdef.meta
Normal file
7
Assets/Scripts/View/SantJordi.View.asmdef.meta
Normal file
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fcb674ef5c27916468ce43c3ae3e4ccd
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,6 +0,0 @@
|
|||
using System.Runtime.InteropServices;
|
||||
|
||||
public static class Win32API {
|
||||
[DllImport("User32.dll")]
|
||||
public static extern short GetAsyncKeyState(int vKey);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue