-
Notifications
You must be signed in to change notification settings - Fork 0
/
menuitems.c
100 lines (86 loc) · 1.62 KB
/
menuitems.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
/* file created on Wed Aug 28 13:32:02 CEST 2002 by doom */
#include <stdbool.h>
#include "menuitems.h"
#include <string.h>
#include <stdlib.h>
/* menu items */
void
menu_items_set_bitmap_for (MenuItems mi,
const char *name, SDL_Surface * bitmap)
{
int i = 0;
while (mi[i].name) {
if (!strcmp (mi[i].name, name)) {
mi[i].bitmap = bitmap;
return;
}
i++;
}
}
SDL_Surface *
menu_items_get_bitmap (MenuItems mi, const char *name)
{
int i = 0;
while (mi[i].name) {
if (!strcmp (mi[i].name, name)) {
return mi[i].bitmap;
}
i++;
}
return NULL;
}
void
menu_items_set_font_for (MenuItems mi, const char *name, SoFont * font)
{
int i = 0;
while (mi[i].name) {
if (!strcmp (mi[i].name, name)) {
mi[i].font = font;
return;
}
i++;
}
}
SoFont *
menu_items_get_font (MenuItems mi, const char *name)
{
int i = 0;
while (mi[i].name) {
if (!strcmp (mi[i].name, name)) {
return mi[i].font;
}
i++;
}
return NULL;
}
void
menu_items_set_value_for (MenuItems mi, const char *name, const char *value)
{
int i = 0;
while (mi[i].name) {
if (!strcmp (mi[i].name, name)) {
if (mi[i].value)
free (mi[i].value);
if (value) {
mi[i].value = (char *)malloc (strlen (value) + 1);
strcpy (mi[i].value, value);
}
else
mi[i].value = NULL;
return;
}
i++;
}
}
const char *
menu_items_get_value (MenuItems mi, const char *name)
{
int i = 0;
while (mi[i].name) {
if (!strcmp (mi[i].name, name)) {
return mi[i].value;
}
i++;
}
return NULL;
}