Snoke
displayHandler.cpp
Go to the documentation of this file.
1 #include "labyrinth.h"
2 
7 void DisplayHandler::displayHandler(int displayMethod)
8 {
9  /*
10  * checking if we are beeing asked to use a certain method
11  */
12  if(displayMethod >= 0)
13  {
14  this->forcedDisplay(displayMethod);
15  }
16  else
17  {
18  this->freeDisplay();
19  }
20  refresh();
21  flushinp();
22 }
27 void DisplayHandler::forcedDisplay(int displayMethod)
28 {
29  /*
30  * Deciding what disply method to use
31  */
32  switch (displayMethod)
33  {
34  case DISPFULL:
35  {
37  {
38  this->displayFull();
39  }
40  else
41  {
42  this->displayPartialy();
43  }
44  break;
45  }
46  case DISPUPD:
47  {
49  {
50  this->displayUpdated();
51  }
52  else
53  {
54  this->displayPartialy();
55  }
56  break;
57  }
58  case DISPPART:
59  {
60  this->displayPartialy();
61  break;
62  }
63  default:
64  {
65  this->displayPartialy();
66  }
67  }
68 }
69 
74 {
75  /*
76  * Deciding what disply method to use
77  */
78  switch (this->prevDisplayMethod)
79  {
80  case DISPFULL:
81  {
83  {
84  this->displayUpdated();
85  }
86  else
87  {
88  this->displayPartialy();
89  }
90  break;
91  }
92  case DISPUPD:
93  {
95  {
96  this->displayUpdated();
97  }
98  else
99  {
100  this->displayPartialy();
101  }
102  break;
103  }
104  case DISPPART:
105  {
107  {
108  this->displayFull();
109  }
110  else
111  {
112  this->displayPartialy();
113  }
114  break;
115  }
116  default:
117  {
118  this->displayPartialy();
119  }
120  }
121 }
122 
127 {
128  for(int j = 0; j < gameFieldSize.y; j++)
129  {
130  mvaddstr(j, 0, labyrinth->labyrinth[j]);
131  }
132  this->prevDisplayMethod = DISPFULL;
133 }
134 
139 {
140  clear();
141  for(int j = labyrinth->start.y; j < labyrinth->end.y; j++)
142  {
143  move(j - labyrinth->start.y, 0);
144  for(int i = labyrinth->start.x; i < labyrinth->end.x; i++)
145  {
146  addch(labyrinth->labyrinth[j][i]);
147  }
148  }
149  this->prevDisplayMethod = DISPPART;
150 }
151 
156 {
157  std::deque<Point> cpChange;
158 
159  Point tmp;
160  labyrinth->change.getRmQueue(&cpChange);
161  for(auto it = cpChange.begin(); it != cpChange.end(); ++it)
162  {
163  tmp = *it;
164  mvaddch(tmp.y, tmp.x, ' ');
165  }
166  labyrinth->change.getAddQueue(&cpChange);
167  for(auto it = cpChange.begin(); it != cpChange.end(); ++it)
168  {
169  tmp = *it;
170  mvaddch(tmp.y, tmp.x, tmp.style.letter);
171  }
172 
173  this->prevDisplayMethod = DISPUPD;
174 }
void getRmQueue(std::deque< Point > *cpChange)
method to get a copy of removal array
Definition: change.cpp:98
Labyrinth * labyrinth
Definition: labyrinth.h:30
short x
Definition: common.h:55
Point end
Definition: labyrinth.h:73
Definitions and prototypes for Labyrinth class.
void freeDisplay()
No extra stimulus, displaying the default way.
Point start
Definition: labyrinth.h:72
void getAddQueue(std::deque< Point > *cpChange)
method to get a copy of addition array
Definition: change.cpp:89
const int DISPPART
the whole labyrinth doesn&#39;t fit, so we are displaying it partialy
Definition: labyrinth.h:48
int prevDisplayMethod
Definition: labyrinth.h:31
void displayFull()
redraw every Point of the labyrinth
const int DISPFULL
the whole labyrinth can fit and was redrawed
Definition: labyrinth.h:44
char ** labyrinth
Definition: labyrinth.h:69
void displayPartialy()
display labyrinth partialy, using the start and end Points
void displayUpdated()
draw only the changed Points when the labyrinth is being fully displayed
Point gameFieldSize
Definition: game.cpp:17
PointStyle style
Definition: common.h:57
Change change
Definition: labyrinth.h:82
void forcedDisplay(int displayMethod)
got an extra stimulus for displaying in a certain method
short y
Definition: common.h:56
char letter
Definition: common.h:40
void displayHandler(int displayMethod)
handler for choosing the approriate display method in the current environment
const int DISPUPD
the whole labyrinth can fit and was already fully redrawn so we just need to redraw the changed Point...
Definition: labyrinth.h:52
Coordinates and style of the cell in console window.
Definition: common.h:52