-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBoard.cs
More file actions
78 lines (68 loc) · 1.78 KB
/
Board.cs
File metadata and controls
78 lines (68 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine.InputSystem;
namespace BookmarksModNS
{
public class Board
{
public string Id;
public PanAndZoom[] marks = new PanAndZoom[6];
private static Key[] keys = new Key[6] { Key.Digit5, Key.Digit6, Key.Digit7, Key.Digit8, Key.Digit9, Key.Digit0 };
public Board()
{
for (int i = 0; i < marks.Length; ++i)
{
marks[i] = new() { key = keys[i] };
}
UpdateKeys();
}
public void UpdateKeys()
{
for (int i = 0; i < marks.Length; ++i)
{
if (marks[i] is null)
{
marks[i] = new();
}
marks[i].key = keys[i];
}
}
}
[JsonObject(MemberSerialization.OptIn)]
public class SaveBoard
{
[JsonProperty]
public string id;
[JsonProperty]
public List<SavePanAndZoom> marks = new();
public SaveBoard()
{ }
public SaveBoard(Board board)
{
id = board.Id;
if (board.marks == null) return;
for (int i = 0; i < board.marks.Length; ++i)
{
if (board.marks[i].IsSet)
{
SavePanAndZoom spz = new(i, board.marks[i]);
marks.Add(spz);
}
}
}
public Board ToBoard()
{
Board board = new()
{
Id = id
};
marks?.ForEach(pz => {
board.marks[pz.idx] = pz.ToPanAndZoom();
});
board.UpdateKeys();
return board;
}
}
}