-
Notifications
You must be signed in to change notification settings - Fork 4
/
view_handler.h
54 lines (36 loc) · 1.12 KB
/
view_handler.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
//
// view_handler.h
// GameOfLive
//
// Created by Кирилл on 10.10.17.
// Copyright © 2017 Кирилл. All rights reserved.
//
#ifndef VIEW_HANDLER_H
#define VIEW_HANDLER_H
#include <ncurses.h>
#include "game_handler.h"
const std::vector<std::string> PROMPTS = {
"Q Exit", "N Next turn", "B Step Back", "R Reset", "C Command mode"};
class CursesViewHandler : public ViewHandler {
public:
CursesViewHandler();
void updateField(const GameField& field, size_t stepsCount) override;
void updateKeyboardCursor(size_t posX, size_t posY) override;
void updateCommandLine(const std::string& commandOutput) override;
std::string readCommandInput() override;
const InputResult waitForInput(uint8_t timeout) override;
bool canCrateFieldWithSizes(size_t width, size_t height) override;
~CursesViewHandler();
private:
WINDOW* fieldWin;
// Commandline output
std::string commandLine;
// Keyboard cursor position
size_t cursorX = 0;
size_t cursorY = 0;
// Current field dimentions
size_t gameWidth = 0;
size_t gameHeight = 0;
void drawCommandLine() const;
};
#endif /* VIEW_HANDLER_H */