diff --git a/src/menu.c b/src/menu.c
index e80e43612c2911159f50070bd163bd2692d71993..40384c85fc97ec654b0ca94d40383ab413cc4965 100644 (file)
--- a/src/menu.c
+++ b/src/menu.c
}
}
}
}
-static int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
+int GM_init_int0 (new_msg_t *msg, int i, int a, int b, int s) {
assert(msg != NULL);
assert(msg != NULL);
- assert(a <= b);
- assert(s >= 0);
- msg->integer.i = min(max(i, a), b);
+ msg->integer.i = i;
msg->integer.a = a;
msg->integer.b = b;
msg->integer.s = s;
return 1;
}
msg->integer.a = a;
msg->integer.b = b;
msg->integer.s = s;
return 1;
}
-static int GM_init_str (new_msg_t *msg, char *str, int maxlen) {
+int GM_init_int (new_msg_t *msg, int i, int a, int b, int s) {
+ assert(msg != NULL);
+ assert(a <= b);
+ assert(s >= 0);
+ return GM_init_int0(msg, min(max(i, a), b), a, b, s);
+}
+
+int GM_init_str (new_msg_t *msg, char *str, int maxlen) {
assert(msg != NULL);
assert(str != NULL);
assert(maxlen >= 0);
assert(msg != NULL);
assert(str != NULL);
assert(maxlen >= 0);
return 0;
}
return 0;
}
+static int GM_options_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
+ switch (msg->type) {
+ case GM_SELECT: GM_push(R_menu()); return 1;
+ }
+ return 0;
+}
+
static int GM_exit_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
switch (msg->type) {
case GM_ENTER:
static int GM_exit_handler (new_msg_t *msg, const new_menu_t *m, void *data) {
switch (msg->type) {
case GM_ENTER:
}, options_menu = {
GM_BIG, "Options", NULL, NULL,
{
}, options_menu = {
GM_BIG, "Options", NULL, NULL,
{
- //{ GM_BUTTON, "Video", NULL, NULL, NULL },
+ { GM_BUTTON, "Video", NULL, &GM_options_handler, NULL },
{ GM_BUTTON, "Sound", NULL, NULL, &sound_menu },
{ GM_BUTTON, "Music", NULL, NULL, &music_menu },
{ 0, NULL, NULL, NULL, NULL } // end
{ GM_BUTTON, "Sound", NULL, NULL, &sound_menu },
{ GM_BUTTON, "Music", NULL, NULL, &music_menu },
{ 0, NULL, NULL, NULL, NULL } // end
}
}
}
}
+static int count_menu_entries (const new_menu_t *m) {
+ assert(m != NULL);
+ int i = 0;
+ while (m->entries[i].type != 0) {
+ i += 1;
+ }
+ return i;
+}
+
int GM_send_this (const new_menu_t *m, new_msg_t *msg) {
assert(m != NULL);
assert(msg != NULL);
int GM_send_this (const new_menu_t *m, new_msg_t *msg) {
assert(m != NULL);
assert(msg != NULL);
- if (m->handler != NULL) {
- GM_normalize_message(msg);
- return m->handler(msg, m, m->data);
+ int n;
+ switch (msg->type) {
+ case GM_QUERY:
+ n = count_menu_entries(m);
+ return GM_init_int0(msg, GM_geti(), n, n, m->type);
+ case GM_GETTITLE:
+ return GM_init_str(msg, m->title, strlen(m->title));
+ default:
+ if (m->handler != NULL) {
+ GM_normalize_message(msg);
+ return m->handler(msg, m, m->data);
+ }
}
return 0;
}
}
return 0;
}
assert(i >= 0);
assert(msg != NULL);
const new_var_t *v = &m->entries[i];
assert(i >= 0);
assert(msg != NULL);
const new_var_t *v = &m->entries[i];
- if (v->handler != NULL) {
- GM_normalize_message(msg);
- return v->handler(msg, m, v->data);
+ switch (msg->type) {
+ case GM_GETENTRY: return GM_init_int0(msg, v->type, 0, 0, 0);
+ case GM_GETCAPTION: return GM_init_str(msg, v->caption, strlen(v->caption));
+ default:
+ if (v->handler != NULL) {
+ GM_normalize_message(msg);
+ return v->handler(msg, m, v->data);
+ }
}
return 0;
}
}
return 0;
}
Z_sound(s,128);
}
Z_sound(s,128);
}
-static int count_menu_entries (const new_menu_t *m) {
- assert(m != NULL);
- int i = 0;
- while (m->entries[i].type != 0) {
- i += 1;
- }
- return i;
-}
-
static int strnlen (const char *s, int len) {
int i = 0;
while (i < len && s[i] != 0) {
static int strnlen (const char *s, int len) {
int i = 0;
while (i < len && s[i] != 0) {