-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathButton.h
90 lines (74 loc) · 1.36 KB
/
Button.h
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
#ifndef BUTTON_H
#define BUTTON_H
#include "DiskPart.h"
#include "ValidChar.h"
#include "PosChart.h"
#include "enums.h"
int getPosOfChar(const char *array, char c);
void getLocOfChar(char c, int &loop, int &row);
//Holds every aspect of a button
class Button
{
DiskPart buttonShape;
ValidChar writing;
public:
Button();
Button(ValidChar inpWriting);
DiskPart& getButtonShape();
ValidChar& getWriting();
};
Button::Button()
{
}
Button::Button(ValidChar inpWriting)
{
writing = inpWriting;
int loop, row;
getLocOfChar(writing.getChar(), loop, row);
buttonShape = DiskPart(loop, row);
}
DiskPart& Button::getButtonShape()
{
return buttonShape;
}
ValidChar& Button::getWriting()
{
return writing;
}
int getPosOfChar(const char *array, char c)
{
size_t size = 26; //not cool
const char* end = array + size;
const char* match = std::find(array, end, c);
return (end == match) ? -1 : (match - array);
}
void getLocOfChar(char c, int &loop, int &row)
{
int noOfChar = getPosOfChar(firstScreenChars, c);
if (noOfChar == -1)
noOfChar = getPosOfChar(secondScreenChars, c);
//middle loop
if (noOfChar < 2)
{
loop = 0;
//first half
if (noOfChar == 0)
row = 0;
//second half
else
row = 1;
}
//second ring
else if (noOfChar < 14)
{
loop = 1;
row = (noOfChar - 2) % 12;
}
//third ring
else
{
loop = 2;
row = (noOfChar - 2) % 12;
}
}
#endif