forked from twig33/ynoclient
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathwindow.h
296 lines (242 loc) · 5.98 KB
/
window.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_WINDOW_H
#define EP_WINDOW_H
// Headers
#include "system.h"
#include "drawable.h"
#include "rect.h"
/**
* Window class.
*/
class Window : public Drawable {
public:
Window(Drawable::Flags flags = Drawable::Flags::Default);
void Draw(Bitmap& dst) override;
void Update();
BitmapRef const& GetWindowskin() const;
void SetWindowskin(BitmapRef const& nwindowskin);
BitmapRef GetContents() const;
void SetContents(BitmapRef const& ncontents);
bool GetStretch() const;
void SetStretch(bool nstretch);
Rect const& GetCursorRect() const;
void SetCursorRect(Rect const& ncursor_rect);
bool GetActive() const;
void SetActive(bool nactive);
bool GetPause() const;
void SetPause(bool npause);
bool GetUpArrow() const;
void SetUpArrow(bool nup_arrow);
bool GetDownArrow() const;
void SetDownArrow(bool ndown_arrow);
bool GetLeftArrow() const;
void SetLeftArrow(bool nleft_arrow);
bool GetRightArrow() const;
void SetRightArrow(bool nright_arrow);
int GetX() const;
void SetX(int nx);
int GetY() const;
void SetY(int ny);
int GetWidth() const;
void SetWidth(int nwidth);
int GetHeight() const;
void SetHeight(int nheight);
int GetOx() const;
void SetOx(int nox);
int GetOy() const;
void SetOy(int noy);
int GetBorderX() const;
void SetBorderX(int nox);
int GetBorderY() const;
void SetBorderY(int noy);
int GetOpacity() const;
void SetOpacity(int nopacity);
int GetBackOpacity() const;
void SetBackOpacity(int nback_opacity);
int GetContentsOpacity() const;
void SetContentsOpacity(int ncontents_opacity);
void SetOpenAnimation(int frames);
void SetCloseAnimation(int frames);
bool IsOpening() const;
bool IsClosing() const;
bool IsOpeningOrClosing() const;
protected:
virtual bool IsSystemGraphicUpdateAllowed() const;
unsigned long ID;
BitmapRef windowskin, contents;
bool stretch = true;
Rect cursor_rect;
bool active = true;
bool closing = false;
bool up_arrow = false;
bool down_arrow = false;
bool left_arrow = false;
bool right_arrow = false;
int x = 0;
int y = 0;
int width = 0;
int height = 0;
int ox = 0;
int oy = 0;
int border_x = 8;
int border_y = 8;
int opacity = 255;
int back_opacity = 255;
int contents_opacity = 255;
private:
BitmapRef
background, frame_down,
frame_up, frame_left, frame_right, cursor1, cursor2;
void RefreshBackground();
void RefreshFrame();
void RefreshCursor();
bool background_needs_refresh;
bool frame_needs_refresh;
bool cursor_needs_refresh;
bool pause = false;
int cursor_frame = 0;
int pause_frame = 0;
int animation_frames = 0;
double animation_count = 0.0;
double animation_increment = 0.0;
};
inline bool Window::IsOpening() const {
return animation_frames > 0 && !closing;
}
inline bool Window::IsClosing() const {
return animation_frames > 0 && closing;
}
inline bool Window::IsOpeningOrClosing() const {
return animation_frames > 0;
}
inline BitmapRef const& Window::GetWindowskin() const {
return windowskin;
}
inline BitmapRef Window::GetContents() const {
return contents;
}
inline void Window::SetContents(BitmapRef const& ncontents) {
contents = ncontents;
}
inline bool Window::GetStretch() const {
return stretch;
}
inline Rect const& Window::GetCursorRect() const {
return cursor_rect;
}
inline bool Window::GetActive() const {
return active;
}
inline void Window::SetActive(bool nactive) {
active = nactive;
}
inline bool Window::GetPause() const {
return pause;
}
inline void Window::SetPause(bool npause) {
pause = npause;
pause_frame = 0;
}
inline bool Window::GetUpArrow() const {
return up_arrow;
}
inline void Window::SetUpArrow(bool nup_arrow) {
up_arrow = nup_arrow;
}
inline bool Window::GetDownArrow() const {
return down_arrow;
}
inline void Window::SetDownArrow(bool ndown_arrow) {
down_arrow = ndown_arrow;
}
inline bool Window::GetLeftArrow() const {
return left_arrow;
}
inline void Window::SetLeftArrow(bool nleft_arrow) {
left_arrow = nleft_arrow;
}
inline bool Window::GetRightArrow() const {
return right_arrow;
}
inline void Window::SetRightArrow(bool nright_arrow) {
right_arrow = nright_arrow;
}
inline int Window::GetX() const {
return x;
}
inline void Window::SetX(int nx) {
x = nx;
}
inline int Window::GetY() const {
return y;
}
inline void Window::SetY(int ny) {
y = ny;
}
inline int Window::GetWidth() const {
return width;
}
inline int Window::GetHeight() const {
return height;
}
inline int Window::GetOx() const {
return ox;
}
inline void Window::SetOx(int nox) {
ox = nox;
}
inline int Window::GetOy() const {
return oy;
}
inline void Window::SetOy(int noy) {
oy = noy;
}
inline int Window::GetBorderX() const {
return border_x;
}
inline void Window::SetBorderX(int x) {
border_x = x;
}
inline int Window::GetBorderY() const {
return border_y;
}
inline void Window::SetBorderY(int y) {
border_y = y;
}
inline int Window::GetOpacity() const {
return opacity;
}
inline void Window::SetOpacity(int nopacity) {
opacity = nopacity;
}
inline int Window::GetBackOpacity() const {
return back_opacity;
}
inline void Window::SetBackOpacity(int nback_opacity) {
back_opacity = nback_opacity;
}
inline int Window::GetContentsOpacity() const {
return contents_opacity;
}
inline void Window::SetContentsOpacity(int ncontents_opacity) {
contents_opacity = ncontents_opacity;
}
inline bool Window::IsSystemGraphicUpdateAllowed() const {
return !IsClosing();
}
#endif