-
Notifications
You must be signed in to change notification settings - Fork 0
/
armybuilder.c
241 lines (220 loc) · 6.41 KB
/
armybuilder.c
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
void get_label_content_units(int labelid,char *out)
{
switch(labelid)
{
case UNITCOUNT_LABEL:
sprintf(out,"%i",NUMUNITS);
break;
case TEAMCOUNT_LABEL:
sprintf(out,"%i",NUMTEAMS);
break;
}
}
// armybuilder
#define NUMARMYBUILDER_GUI_LABELS 15
enum ARMYBUILDER_GUI_LABELS_SECTIONS
{
SECTION_START = 0,
SECTION_UNITS = 2,
SECTION_UNIT = 7,
SECTION_FIGURE = 15,
};
enum ARMYBUILDER_GUI_LABELS_ID
{
UNITCOUNT_LABEL = 0,
TEAMCOUNT_LABEL = 1,
UNIT_LABEL = 2,
TEAM_LABEL = 3,
COMMANDLEVEL_LABEL = 4,
UFLAGS_LABEL = 5,
FIGURECNT_LABEL = 6,
FIGURE_LABEL = 7,
FP_LABEL = 8,
IV_LABEL = 9,
AT_LABEL = 10,
LV_LABEL = 11,
QUALITY_LABEL = 12,
CONFIDENCE_LABEL = 13,
FFLAGS_LABEL = 14,
// 15 inbetween
FIGURE_TABLE_OFFSET = 30,
};
// armybuilder
Rectangle ARMYBUILDER_LABEL_RECTANGLES[] =
{
// TITLE
{20 ,20 ,100 ,20}, // UNITCOUNT_TITLE
{20 ,50 ,100 ,20}, // TEAMCOUNT_TITLE
{350 ,80 ,100 ,20}, // UNIT_TITLE
{350 ,100,100 ,20}, // TEAM_TITLE
{350 ,120,100 ,20}, // COMMANDLEVEL_TITLE
{350 ,140,100 ,20}, // UFLAGS_TITLE
{350 ,160,100 ,20}, // FIGURECNT_TITLE
{ 350 ,220,100 ,20}, // FIGURE_TITLE
{ 450 ,220,100 ,20}, // FP_TITLE
{ 550 ,220,100 ,20}, // IV_TITLE
{ 650 ,220,100 ,20}, // AT_TITLE
{ 750 ,220,100 ,20}, // LV_TITLE
{ 850 ,220,100 ,20}, // QUALITY_TITLE
{ 950 ,220,100 ,20}, // CONFIDENCE_TITLE
{1050 ,220,100 ,20}, // FFLAGS_TITLE
// CONTENT
{130 ,20 ,100 ,20}, // UNITCOUNT_CONTENT
{130 ,50 ,100 ,20}, // TEAMCOUNT_CONTENT
{430 ,80 ,100 ,20}, // UNIT_CONTENT
{430 ,100,100 ,20}, // TEAM_CONTENT
{430 ,120,100 ,20}, // COMMANDLEVEL_CONTENT
{430 ,140,100 ,20}, // UFLAGS_CONTENT
{430 ,160,100 ,20}, // FIGURECNT_CONTENT
{ 350 ,240,100 ,20}, // FIGURE_CONTENT
{ 450 ,240,100 ,20}, // FP_CONTENT
{ 550 ,240,100 ,20}, // IV_CONTENT
{ 650 ,240,100 ,20}, // AT_CONTENT
{ 750 ,240,100 ,20}, // LV_CONTENT
{ 850 ,240,100 ,20}, // QUALITY_CONTENT
{ 950 ,240,100 ,20}, // CONFIDENCE_CONTENT
{1050 ,240,100 ,20}, // FFLAGS_CONTENT
{0 , 20, 0 , 0}, // FIGURE_TABLE_OFFSET
};
char *ARMYBUILDER_LABEL_TITLE[] =
{
"total unit count:", // UNITCOUNT_TITLE
"unit count for team:", // TEAMCOUNT_TITLE
"unit name:", // UNIT_TITLE
"team #:", // TEAM_TITLE
"commandlevel:", // COMMANDLEVEL_TITLE
"unit flags:", // UFLAGS_TITLE
"figure count:", // FIGURECNT_TITLE
"figure name:", // FIGURE_TITLE
"firepower die:", // FP_TITLE
"impact die:", // IV_TITLE
"armor type:", // AT_TITLE
"leadership value:", // LV_TITLE
"quality:", // QUALITY_TITLE
"confidence:", // CONFIDENCE_TITLE
"figure flags:", // FFLAGS_TITLE
};
void get_label_content_units(int labelid,char *out);
void get_label_content_unit(Unit unit,int labelid,char *out);
void get_label_content_figure(Figure figure,int labelid,char *out);
void draw_gui_elements(Unit *units);
void run_armybuilder(Unit *units);
Rectangle RectangleAdd(Rectangle rec1, Rectangle rec2);
void get_label_content_unit(Unit unit,int labelid,char *out)
{
char in[256];
switch(labelid)
{
case UNIT_LABEL:
strcpy(out,"NAME");
break;
case TEAM_LABEL:
sprintf(out,"%i",unit.team);
break;
case COMMANDLEVEL_LABEL:
commandlevel_enum_to_string(in,unit.commandlevel);
strcpy(out,in);
break;
case UFLAGS_LABEL:
flags_to_string(in,unit.flags);
strcpy(out,in);
break;
case FIGURECNT_LABEL:
sprintf(out,"%i",unit.figurecnt);
break;
}
}
void get_label_content_figure(Figure figure,int labelid,char *out)
{
/*
char in[256];
switch(labelid)
{
case FIGURE_LABEL:
strcpy(out,"NAME");
break;
case FP_LABEL:
sprintf(out,"D%i",figure.FP);
break;
case IV_LABEL:
sprintf(out,"D%i",figure.IV);
break;
case AT_LABEL:
AT_enum_to_string(in,figure.AT);
strcpy(out,in);
break;
case LV_LABEL:
lv_enum_to_string(in,figure.LV);
strcpy(out,in);
break;
case QUALITY_LABEL:
quality_enum_to_string(in,figure.quality);
strcpy(out,in);
break;
case CONFIDENCE_LABEL:
confidence_enum_to_string(in,figure.confidence);
strcpy(out,in);
break;
case FFLAGS_LABEL:
flags_to_string(in,figure.flags);
strcpy(out,in);
break;
}
*/
}
void draw_gui_elements(Unit *units)
{
char content[256];
for(int i=0;i<NUMARMYBUILDER_GUI_LABELS;i++)
{
GuiLabel(ARMYBUILDER_LABEL_RECTANGLES[i], ARMYBUILDER_LABEL_TITLE[i]);
}
for(int i=SECTION_START;i<SECTION_UNITS;i++)
{
get_label_content_units(i,content);
GuiLabel(ARMYBUILDER_LABEL_RECTANGLES[i+NUMARMYBUILDER_GUI_LABELS], content);
}
for(int i=SECTION_UNITS;i<SECTION_UNIT;i++)
{
get_label_content_unit(units[0],i,content);
GuiLabel(ARMYBUILDER_LABEL_RECTANGLES[i+NUMARMYBUILDER_GUI_LABELS], content);
}
Rectangle offset = {0,0,0,0};
Rectangle out = {0,0,0,0};
for(int j=0;j<units[0].figurecnt;j++)
{
for(int i=SECTION_UNIT;i<SECTION_FIGURE;i++)
{
out = RectangleAdd(offset,ARMYBUILDER_LABEL_RECTANGLES[i+NUMARMYBUILDER_GUI_LABELS]);
get_label_content_figure(units[0].figures[j],i,content);
GuiLabel(out,content);
}
offset = RectangleAdd(offset,ARMYBUILDER_LABEL_RECTANGLES[FIGURE_TABLE_OFFSET]);
printf("x: %i, y: %i\n",offset.x,offset.y);
printf("x: %i, y: %i\n",ARMYBUILDER_LABEL_RECTANGLES[FIGURE_TABLE_OFFSET].x,ARMYBUILDER_LABEL_RECTANGLES[FIGURE_TABLE_OFFSET].y);
}
}
void run_armybuilder(Unit *units)
{
/*
int dropdowntextcnt = 2;
int dropdowntextactive = 0;
const char *dropdowntext[2] = {"RAKI","DAWRI"};
*/
while(!WindowShouldClose())
{
BeginDrawing();
ClearBackground(RAYWHITE);
draw_gui_elements(units);
EndDrawing();
}
}
Rectangle RectangleAdd(Rectangle rec1,Rectangle rec2)
{
Rectangle out;
out.x = rec1.x+rec2.x;
out.y = rec1.y+rec2.y;
out.width = rec1.width+rec2.width;
out.height = rec1.height+rec2.height;
return out;
}