forked from zombieCraig/UDSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gui.h
164 lines (153 loc) · 4.07 KB
/
gui.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
#ifndef UDSSIM_GUI_H
#define UDSSIM_GUI_H
#include <vector>
#include <iostream>
#include <string>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include "gamedata.h"
#include "module.h"
#include "icon-button.h"
using namespace std;
#define MAX_LOG_ENTRIES 22
#define MAX_RANDOM_ATTEMPTS 20 // Used for Module placement
// The region of the vehicle on the screen
#define CAR_REGION_X 245
#define CAR_REGION_Y 58
#define CAR_REGION_H 327
#define CAR_REGION_W 165
// Log window region
#define LOG_REGION_X 450
#define LOG_REGION_Y 40
#define LOG_REGION_H 446
#define LOG_REGION_W 270
// Toolbar region
#define TOOLBAR_REGION_X 450
#define TOOLBAR_REGION_Y 0
#define TOOLBAR_REGION_H 50
#define TOOLBAR_REGION_W 270
// Status region
#define STATUS_REGION_X 2
#define STATUS_REGION_Y 466
#define STATUS_REGION_H 20
#define STATUS_REGION_W 240
// Info Card region
#define CARD_REGION_X 0
#define CARD_REGION_Y 50
#define CARD_REGION_H 410
#define CARD_REGION_W 240
// Save Icon
#define ICON_SAVE_X 453
#define ICON_SAVE_Y 0
#define ICON_SAVE_H 50
#define ICON_SAVE_W 50
// Mode Icon
#define ICON_MODE_X 506
#define ICON_MODE_Y 0
#define ICON_MODE_H 50
#define ICON_MODE_W 50
// Fuzz Icon
#define ICON_FUZZ_X 559
#define ICON_FUZZ_Y 0
#define ICON_FUZZ_H 50
#define ICON_FUZZ_W 50
// Card Options
#define CARD_FAKE_RESP_X 20
#define CARD_FAKE_RESP_Y 420
#define CARD_FAKE_RESP_H 20
#define CARD_FAKE_RESP_W 20
#define CARD_IGNORE_X 172
#define CARD_IGNORE_Y 420
#define CARD_IGNORE_H 20
#define CARD_IGNORE_W 20
#define CARD_FUZZ_VIN_X 20
#define CARD_FUZZ_VIN_Y 360
#define CARD_FUZZ_VIN_H 20
#define CARD_FUZZ_VIN_W 20
#define CARD_FUZZ_LEVEL_X 80
#define CARD_FUZZ_LEVEL_Y 380
#define CARD_FUZZ_LEVEL_H 15
#define CARD_FUZZ_LEVEL_W 95
#define CARD_FUZZ_LEVEL_STEPS 4
#define FUZZ_SLIDER_W 20
#define FUZZ_SLIDER_H 20
// Animation states
#define CARD_NOANIM 0
#define CARD_ADVANCE 1
#define CARD_RETRACT 2
class GameData;
class Module;
extern GameData gd;
class Gui {
public:
Gui();
~Gui();
void setWidth(int w) { width = w; }
void setHeight(int h) { height = h; }
int getWidth() { return width; }
int getHeight() { return height; }
int Init();
void setVerbose(int v) { verbose = v; }
void setData(string s) { data_path = s; }
void setFontPath(string f) { font_path = f; }
void setFullscreen(bool t) { _fullscreen = t; }
void toggleFullscreen();
string getData() { return data_path; }
string getFontPath() { return font_path; }
SDL_Surface *load_image(string);
TTF_Font *load_font(string, int);
bool isModuleOverlapping(Module *);
void setRandomModulePosition(Module *);
void setStatus(string);
void Redraw();
void DrawModules(bool b = false);
void DrawLog();
void DrawToolbar();
void DrawStatus();
void DrawInfoCard();
int HandleEvents();
void HandleAnimations();
void Msg(string);
void setCardState(int s) { _card_state = s; }
int getCardState() { return _card_state; }
void AdvanceCard();
void RetractCard();
private:
void HandleMouseMotions(SDL_MouseMotionEvent);
void HandleMouseClick(SDL_MouseButtonEvent);
bool isOverCarRegion(int, int);
bool isOverToolbarRegion(int, int);
bool isOverCardRegion(int, int);
int width = 720;
int height = 486;
int verbose = 0;
int module_selected = -1;
unsigned int _ticks = 0;
unsigned int _lastTicks = 0;
unsigned int _CardAnimationTicks = 10;
int _card_current_x = -CARD_REGION_W;
int _card_state = CARD_NOANIM;
bool _fullscreen = false;
string data_path;
string font_path;
IconButton *saveButton = NULL;
IconButton *modeButton = NULL;
IconButton *fuzzButton = NULL;
SDL_Texture *logbuff[MAX_LOG_ENTRIES];
SDL_Window *window = NULL;
SDL_Surface *screen = NULL;
SDL_Renderer *renderer = NULL;
SDL_Texture *base_texture = NULL;
SDL_Texture *module_texture = NULL;
SDL_Texture *module_unk_texture = NULL;
SDL_Texture *info_card_texture = NULL;
SDL_Texture *_status = NULL;
SDL_Texture *check_texture = NULL;
SDL_Texture *slider_texture = NULL;
SDL_Event event;
TTF_Font *module_ttf = NULL;
TTF_Font *log_ttf = NULL;
TTF_Font *title_ttf = NULL;
};
#endif