-
Notifications
You must be signed in to change notification settings - Fork 3
/
SelectionArrow.cpp
79 lines (64 loc) · 1.55 KB
/
SelectionArrow.cpp
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
#include "SelectionArrow.h"
#include "Globals.h"
#include "GUI.h"
SelectionLocation::SelectionLocation() {}
SelectionLocation::SelectionLocation( Vector2d* loc )
{
Location = loc;
}
SelectionLocation::~SelectionLocation()
{
delete( Location );
}
SelectionArrow::SelectionArrow() {}
SelectionArrow::SelectionArrow( Vector2d** array, int size )
{
NumberOfPositions = size;
Position = 0;
SelectionLocation* tmp;
for ( int i(0); i < size; i ++ )
{
if ( i == 0 )
{
CurrentSelection = new SelectionLocation( array[i] );
CurrentSelection->Next = CurrentSelection->Previous = CurrentSelection;
FirstLocation = CurrentSelection;
tmp = CurrentSelection;
}
else
{
SelectionLocation* newLocation = new SelectionLocation( array[i] );
newLocation->Previous = tmp;
newLocation->Next = tmp->Next;
tmp->Next = newLocation;
tmp = newLocation;
}
if ( i == (size - 1) )
{
FirstLocation->Previous = tmp;
}
}
}
SelectionArrow::~SelectionArrow()
{
}
void SelectionArrow::Draw()
{
arduboy.drawBitmap( CurrentSelection->Location->x, CurrentSelection->Location->y, SelectionArrow_8_8, 8, 8, 1);
}
void SelectionArrow::SelectionMoveUp()
{
CurrentSelection = CurrentSelection->Previous;
Position--;
Position < 0 ? Position = (NumberOfPositions - 1) : Position;
}
void SelectionArrow::SelectionMoveDown()
{
CurrentSelection = CurrentSelection->Next;
Position++;
Position %= NumberOfPositions;
}
void SelectionArrow::Enable( bool e )
{
_Enabled = e;
}