-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlabel.c
executable file
·56 lines (47 loc) · 1.35 KB
/
label.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
/* .c */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <raylib.h>
#include <lua.h>
#include "baize.h"
#include "pile.h"
#include "array.h"
#include "label.h"
static struct PileVtable labelVtable = {
&PileInertCanMoveTail,
&PileInertCanAcceptCard,
&PileInertCanAcceptTail,
&InertTailTapped,
&PileInertCollect,
&PileInertComplete,
&PileInertUnsortedPairs,
&PileReset,
&PileUpdate,
&LabelDraw,
&PileFree,
};
struct Label* LabelNew(struct Baize *const baize, Vector2 slot, enum FanType fan)
{
struct Label* self = calloc(1, sizeof(struct Label));
if ( self ) {
PileCtor(baize, (struct Pile*)self, "Label", slot, fan);
self->super.vtable = &labelVtable;
}
return self;
}
void LabelDraw(struct Pile *const self)
{
if (self->label[0] == '\0') {
return;
}
extern float fontSpacing;
// extern Color baizeHighlightColor;
struct Baize *baize = PileOwner(self);
struct Pack *pack = baize->pack;
// center the label in the Pile screen rect
Vector2 labelmte = MeasureTextEx(pack->pileFont, self->label, (float)pack->labelFontSize, fontSpacing);
Rectangle r = PileScreenRect(self);
Vector2 cpos = UtilCenterTextInRectangle(r, labelmte.x, labelmte.y);
DrawTextEx(pack->pileFont, self->label, cpos, pack->labelFontSize, fontSpacing, WHITE);
}