|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
/* $Id: menu.c,v 1.34 2004/01/04 03:22:49 stpohle Exp $
|
|
|
|
|
/* $Id: menu.c,v 1.35 2004/01/04 19:45:56 stpohle Exp $
|
|
|
|
|
* Menuhandling */
|
|
|
|
|
|
|
|
|
|
#include "basic.h"
|
|
|
|
@ -10,7 +10,7 @@
|
|
|
|
|
|
|
|
|
|
_menuitem menuitems[MENU_MAXENTRYS];
|
|
|
|
|
_menu menu;
|
|
|
|
|
|
|
|
|
|
int menu_looprunning = 0;
|
|
|
|
|
|
|
|
|
|
/* delete all informations and create a totally new menuscreen */
|
|
|
|
|
void menu_new (char *title, int x, int y) {
|
|
|
|
@ -35,6 +35,8 @@ void menu_new (char *title, int x, int y) {
|
|
|
|
|
menu.oldscreenpos.w = x + 2*menu.images[0]->w;
|
|
|
|
|
menu.oldscreenpos.h = y + 2*menu.images[0]->h;
|
|
|
|
|
menu.oldscreen = gfx_copyscreen (&menu.oldscreenpos);
|
|
|
|
|
menu.focus = NULL;
|
|
|
|
|
menu_looprunning = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -47,7 +49,7 @@ void menu_delete () {
|
|
|
|
|
|
|
|
|
|
menuitems[0].next = NULL;
|
|
|
|
|
menu.items = NULL;
|
|
|
|
|
|
|
|
|
|
menu_looprunning = 0;
|
|
|
|
|
if (GS_RUNNING)
|
|
|
|
|
draw_field ();
|
|
|
|
|
};
|
|
|
|
@ -165,6 +167,7 @@ void menu_draw_border () {
|
|
|
|
|
* to be called before the menu is drawed on the screen */
|
|
|
|
|
void menu_draw () {
|
|
|
|
|
_menuitem *m;
|
|
|
|
|
if (!menu_looprunning) return;
|
|
|
|
|
|
|
|
|
|
menu_draw_border ();
|
|
|
|
|
|
|
|
|
@ -176,6 +179,7 @@ void menu_draw () {
|
|
|
|
|
|
|
|
|
|
/* draw an item on the screen */
|
|
|
|
|
inline void menu_draw_menuitem (_menuitem *m) {
|
|
|
|
|
if (!menu_looprunning) return;
|
|
|
|
|
switch (m->type) {
|
|
|
|
|
case (MENU_label):
|
|
|
|
|
menu_draw_label (m);
|
|
|
|
@ -266,6 +270,7 @@ void menu_change_focus (_menuitem *newfocus) {
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* lose focus */
|
|
|
|
|
if (menu.focus != NULL) {
|
|
|
|
|
switch (menu.focus->type) {
|
|
|
|
|
case (MENU_entryfloat):
|
|
|
|
|
case (MENU_entryint16):
|
|
|
|
@ -274,10 +279,12 @@ void menu_change_focus (_menuitem *newfocus) {
|
|
|
|
|
menu_entry_lose_focus (menu.focus);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* draw the old and the new element */
|
|
|
|
|
oldmi = menu.focus;
|
|
|
|
|
menu.focus = newfocus;
|
|
|
|
|
if (oldmi != NULL)
|
|
|
|
|
menu_draw_menuitem (oldmi);
|
|
|
|
|
menu_draw_menuitem (menu.focus);
|
|
|
|
|
|
|
|
|
@ -336,15 +343,19 @@ int menu_loop () {
|
|
|
|
|
Uint8 *keys;
|
|
|
|
|
int keypressed = 0, done = 0, eventstate = 0, reorder = 0;
|
|
|
|
|
|
|
|
|
|
menu_looprunning = 1;
|
|
|
|
|
|
|
|
|
|
/* check if the focus is set to something, if not
|
|
|
|
|
* set the focus to the first item */
|
|
|
|
|
if (menu.focus == NULL)
|
|
|
|
|
if (menu.focus == NULL) {
|
|
|
|
|
menu.focus = menu.items;
|
|
|
|
|
menu_focus_id (0);
|
|
|
|
|
}
|
|
|
|
|
if (menu.focus == NULL) {
|
|
|
|
|
d_fatal ("menu_loop: focus == NULL, something went wrong\n");
|
|
|
|
|
menu_looprunning = 0;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
menu_focus_id (0);
|
|
|
|
|
|
|
|
|
|
keys = SDL_GetKeyState (NULL);
|
|
|
|
|
if (keys[SDLK_RETURN] || keys[SDLK_ESCAPE])
|
|
|
|
@ -420,6 +431,8 @@ int menu_loop () {
|
|
|
|
|
s_calctimesync ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menu_looprunning = 0;
|
|
|
|
|
|
|
|
|
|
if (reorder)
|
|
|
|
|
return -2;
|
|
|
|
|
|
|
|
|
|