home *** CD-ROM | disk | FTP | other *** search
- //-------------------------------------
- //
- // SuperCode (c) 1996 by T.Kühn
- //
- // Programmiersprache: ANSI-C
- // Projektstart: 27.12.94
- //
- // Modul: MenuHandling.c
- //
- //-------------------------------------
-
-
-
- //-------------------------------------
- #include <pragma/gadtools_lib.h>
- #include <libraries/gadtools.h>
-
- #include <Struct.h>
- //-------------------------------------
-
-
-
- //-------------------------------------
- // VARS
- //------------------------------------
-
- #define NM_BAR IM_ITEM,-1,0
-
- struct tkMenu Menu_Main;
- struct tkNewMenu Desc_Main[]=
- {
- {NM_TITLE, TXT_MENUPROGRAM, },
- {NM_ITEM, TXT_MENUNEWGAME, supercode_newgame },
- {NM_ITEM, TXT_MENUNEWPLAYER, supercode_newplayer },
- {NM_BAR },
- {NM_ITEM, TXT_MENUGIVEUP, supercode_giveup },
- {NM_BAR },
- {NM_ITEM, TXT_MENUGAMELOAD, supercode_loadgame },
- {NM_ITEM, TXT_MENUGAMESAVE, supercode_savegame },
- {NM_BAR },
- {NM_ITEM, TXT_MENUHIGHSCORES, score_display },
- {NM_ITEM, TXT_MENUABOUT, supercode_about },
- {NM_BAR },
- {NM_ITEM, TXT_MENUQUIT, Quit },
-
- {NM_TITLE, TXT_MENUSETTINGS, },
- {NM_ITEM, TXT_MENUSETTINGS, prefs_windowopen },
- {NM_BAR },
- {NM_ITEM, TXT_MENUPREFSLOAD, (APTR)prefs_load },
- {NM_ITEM, TXT_MENUPREFSSAVE, prefs_save },
- {NM_END }
- };
-
- struct tkList Head_Menu;
-
- //-------------------------------------
-
-
-
- //-------------------------------------
- BOOL Menu_Create(struct tkMenu *Menu,struct tkNewMenu *NewMenu)
- {
- ULONG c,Num=0;
- struct tkNewMenu *Src;
- struct NewMenu *Dst;
- UBYTE *Txt;
- BOOL Back=FALSE;
-
- while(NewMenu[Num].Type) Num++;
-
- if (Num>0)
- {
- Menu->OrgMenu=NewMenu;
-
- List_AddTail(&Head_Menu,&Menu->Node);
- Menu->Number=Num;
- Menu->Mem=(struct NewMenu *)Memory_Alloc( (Num+1) * sizeof(struct NewMenu));
- if (Menu->Mem)
- {
- for(c=0;c<Num;c++)
- {
- Src=&NewMenu[c];
- Dst=&Menu->Mem[c];
-
- Dst->nm_Type=Src->Type;
- if (Src->Type&MENU_IMAGE)
- {
- Dst->nm_Label=(STRPTR)Src->LocText;
- }
- else
- {
- Txt=CatStr(Src->LocText);
- if (Txt[1]=='|')
- {
- Src->CommKey[0]=Txt[0];
- Dst->nm_CommKey=Src->CommKey;
- Txt+=2;
- }
- Dst->nm_Label=Txt;
- }
- Dst->nm_UserData=Src;
- Dst->nm_Flags=0;
-
- if (Src->Type==NM_ITEM && !Src->Func) Dst->nm_Flags|=NM_ITEMDISABLED;
-
- if (Src->Toggle) Dst->nm_Flags|=CHECKIT|MENUTOGGLE;
- }
- Dst[c].nm_Type=0;
-
- Menu->Menu = CreateMenus(Menu->Mem,
- GTMN_FullMenu,TRUE,
- // GTMN_SecondaryError,,
- TAG_END);
-
- }
- }
- return(Back);
- }
- //-------------------------------------
- VOID Menu_FreeOne(struct tkMenu *Menu)
- {
- if (Menu)
- {
- if (Menu->Menu) FreeMenus(Menu->Menu);
- if (Menu->Mem) Memory_Free((UBYTE**)&Menu->Mem);
- }
- }
- //-------------------------------------
-
-
- //-------------------------------------
- VOID Menu_Layout()
- {
- BOOL back=0;
- struct tkMenu *menu=(APTR)Head_Menu.lh_Head;
-
- for (;menu->Node.ln_Succ;menu=(APTR)menu->Node.ln_Succ)
- {
- do { back=LayoutMenus(menu->Menu,Scrn.Visual,
- GTMN_TextAttr,Scrn.Scrn->Font,
- GTMN_NewLookMenus,TRUE,
- TAG_END);
- } while((!back) && ASK_AGAIN==display_error(ERR_MENU,ASK_EXIT|ASK_AGAIN|ASK_CONT))
- }
- }
- //-------------------------------------
- VOID Menu_Init()
- {
- List_Init(&Head_Menu,NT_Menu,0);
-
- Menu_Create(&Menu_Main,Desc_Main);
-
- }
- //-------------------------------------
- VOID Menu_Free()
- {
- struct tkMenu *menu=(APTR)Head_Menu.lh_Head;
-
- for (;menu->Node.ln_Succ;menu=(APTR)menu->Node.ln_Succ)
- {
- Menu_FreeOne(menu);
- }
- }
- //-------------------------------------
-
-
-