-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmployeesCommand.cpp
More file actions
73 lines (61 loc) · 1.93 KB
/
Copy pathEmployeesCommand.cpp
File metadata and controls
73 lines (61 loc) · 1.93 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
#include "Company.h"
#include "EmployeesCommand.h"
#include "MasterState.h"
#include "Person.h"
#include "Trait.h"
EmployeesCommand::EmployeesCommand(MasterState *masterState) : CommandFunctor(masterState, "employees", "Hire an employee to work in your business.") {
}
void EmployeesCommand::executeCommand(const char *line) {
int n_choices = this->_masterState->getPlayerCompany()->getEmployees()->size();
keypad(stdscr, TRUE);
MENU *my_menu = this->setupMenu((vector<NamedObject *> *)(this->_masterState->getPlayerCompany()->getEmployees()));
WINDOW *my_menu_win = this->setupWindow(my_menu, "Employees");
refresh();
WINDOW *my_details_win = newwin(10, 30, 4, 44);
box(my_details_win, 0, 0);
mvwprintw(my_details_win, 1, 2, "Details");
mvwaddch(my_details_win, 2, 0, ACS_LTEE);
mvwhline(my_details_win, 2, 1, ACS_HLINE, 38);
mvwaddch(my_details_win, 2, 39, ACS_RTEE);
int c;
int done = 0;
while(!done) {
ITEM *currentItem = current_item(my_menu);
if (currentItem) {
Person *p = (Person *)item_userptr(currentItem);
list<Trait *> *realTraits = p->getRealTraits();
int down = 3;
for(list<Trait *>::iterator it = realTraits->begin(); it != realTraits->end(); ++it) {
Trait *t = *it;
char message[30];
sprintf(message, "%10s: %s", t->getName().c_str(), t->getDiscoveryModifiedText().c_str());
wmove(my_details_win, down, 2);
down++;
wprintw(my_details_win, message);
}
}
wrefresh(my_details_win);
c = wgetch(my_menu_win);
switch(c) {
case KEY_DOWN:
menu_driver(my_menu, REQ_DOWN_ITEM);
break;
case KEY_UP:
menu_driver(my_menu, REQ_UP_ITEM);
break;
case 27:
done = 1;
break;
}
wrefresh(my_menu_win);
}
/* Unpost and free all the memory taken up */
unpost_menu(my_menu);
ITEM **my_items = menu_items(my_menu);
for(int i = 0; i < n_choices; ++i)
free_item(my_items[i]);
endwin();
free_menu(my_menu);
}
EmployeesCommand::~EmployeesCommand() {
}