-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathNavigation.cs
More file actions
102 lines (87 loc) · 2.24 KB
/
Navigation.cs
File metadata and controls
102 lines (87 loc) · 2.24 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//
// Addressables Build Layout Explorer for Unity. Copyright (c) 2021 Peter Schraut (www.console-dev.de). See LICENSE.md
// https://github.com/pschraut/UnityAddressablesBuildLayoutExplorer
//
using System;
using System.Collections.Generic;
namespace Oddworm.EditorFramework.BuildLayoutExplorer
{
public class NavigationBookmark
{
public NavigationBookmark()
{
}
}
public class NavigationCommand
{
public BuildLayoutView view;
public NavigationBookmark bookmark;
public object target;
public NavigationCommand()
{
}
}
public sealed class NavigationHistory
{
int m_Index;
List<Entry> m_Entries = new List<Entry>();
class Entry
{
public NavigationCommand from;
public NavigationCommand to;
}
public NavigationCommand current
{
get;
private set;
}
public void Add(NavigationCommand from, NavigationCommand to)
{
while (m_Entries.Count > m_Index && m_Index >= 0)
m_Entries.RemoveAt(m_Entries.Count - 1);
var e = new Entry();
e.from = from;
e.to = to;
m_Entries.Add(e);
current = to;
m_Index++;
}
public void Clear()
{
m_Index = -1;
m_Entries.Clear();
current = null;
}
public bool HasBack()
{
var i = m_Index - 1;
if (i < 0)
return false;
return true;
}
public NavigationCommand Back()
{
if (!HasBack())
return null;
m_Index--;
current = m_Entries[m_Index].from;
return current;
}
public bool HasForward()
{
var i = m_Index;
if (i >= m_Entries.Count)
return false;
return true;
}
public NavigationCommand Forward()
{
if (!HasForward())
return null;
var command = m_Entries[m_Index];
m_Index++;
current = command.to;
return current;
}
}
}