-
Notifications
You must be signed in to change notification settings - Fork 1
/
Field.cpp
89 lines (79 loc) · 1.41 KB
/
Field.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
80
81
82
83
84
85
86
87
88
89
#include "Field.h"
#include <ncurses.h>
using namespace std;
//Constructor
Field::Field(string sName, bool bStringValue) : MenuItem(sName)
{
m_bStringValue = bStringValue;
m_iIntValue = 0;
}
//Getters
Item* Field::getItemBeingModified() const
{
return m_iItemBeingModified;
}
int Field::getIntValue() const
{
return m_iIntValue;
}
string Field::getStringValue() const
{
return m_sStringValue;
}
//Setters
void Field::setItemBeingModified(Item* iItemBeingModified)
{
m_iItemBeingModified = iItemBeingModified;
}
void Field::setIntValue(int iIntValue)
{
m_iIntValue = iIntValue;
}
void Field::setStringValue(string sStringValue)
{
m_sStringValue = sStringValue;
}
//Other methods
void Field::draw()
{
addstr(getName().c_str());
addstr(" = ");
if (!m_bStringValue)
addstr(to_string(m_iIntValue).c_str());
else
addstr(m_sStringValue.c_str());
}
void Field::run()
{
clear();
addstr(getName().c_str());
addstr(" = ");
refresh();
char cInput = getch();
//Take in the int as a string. We'll convert it later
char* cStringValue;
char* cIntValue;
// if (m_bStringValue)
// {
if (m_bStringValue)
{
echo();
getstr(cStringValue);
m_sStringValue = cStringValue;
// m_sStringValue += cInput;
}
else
{
echo();
getstr(cIntValue);
m_iIntValue = atoi(cIntValue);
// sIntValue += cInput;
}
/* refresh();
cInput = getch();
clear();
addstr(getName().c_str());
addstr(" = ");
*/
// }
}