-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.h
115 lines (85 loc) · 2.26 KB
/
app.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#ifndef ASCII_PAINT_APP_H
#define ASCII_PAINT_APP_H
#include <string>
#include <vector>
#include "app_gui.h"
#include "app_data.h"
#include "libtcod.hpp"
#include "gui/gui.hpp"
#include "brush.h"
#include "color_box.h"
#include "operation.h"
class Operation;
// Basically a vector representing each cell in the canvas/image
// To access the cell at position (x, y) use:
// CanvasImage[x + y * width]
typedef std::vector<Brush> CanvasImage;
class App {
public:
App();
~App();
int exec();
void initBrushes();
void initCanvas();
void initOperations();
void changeOperation(Operation *newOperation);
bool shouldOperationUpdate();
void setCanvasImage(CanvasImage& canvasImg);
CanvasImage* getCanvasImage();
void clearOverlay();
void applyBrushToOverlayCell(int x, int y, Brush *brush);
void applyOverlayToCanvas();
void applyCanvasToOverlay();
void setOverlayFade(float fade);
void addUndo();
void doUndo();
void doRedo();
void resetCanvasView();
public:
AppGui *gui;
AppData *data;
int windowWidth;
int windowHeight;
TCODColor windowBackgroundColor;
std::string fontFilename;
int fontLayout;
int fontType;
bool fullscreen;
int fpsGoal;
int currentFps;
int canvasWidth;
int canvasHeight;
// The distance between the top-left corner of canvas and the top-left
// corner of the screen
int canvasOffsetX;
int canvasOffsetY;
// The cell of the canvas that the mouse is currently over
int canvasMouseX;
int canvasMouseY;
std::string filename;
float mapVersion;
bool canvasModified;
bool isCanvasBeingDragged;
bool quit;
Operation *currentOperation;
Operation *previousOperation;
std::vector<CanvasImage> pastImages; // Undo Images stored here
std::vector<CanvasImage> futureImages; // Redo Images store here
TCODConsole *overlayCon; // Drawn over the canvas
TCODConsole *canvasCon;
TCODConsole *solidCon;
TCODConsole *solidOverlayCon; // This canvas holds proposed writes to solidCon
float overlayFade;
bool inTypingMode;
TCOD_key_t key;
TCOD_mouse_t mouse;
Brush brush1;
Brush brush2;
Brush initBrush1;
Brush initBrush2;
private:
void handleKeyboardShortcuts();
void handleCanvasDragging();
void moveMouseWithKeyBoard();
};
#endif