src/hcode/include/coolmenu.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coolmenu_type

Defines

#define MAX_MENU_LENGTH   400
#define MAX_MENU_WIDTH   240
#define MENU_CHAR_WIDTH   78
#define CM_ONE   0x001
#define CM_TWO   0x002
#define CM_THREE   0x004
#define CM_FOUR   0x008
#define CM_CENTER   0x010
#define CM_TOGGLE   0x020
#define CM_NUMBER   0x040
#define CM_LINE   0x080
#define CM_STRING   0x100
#define CM_NO_HILITE   0x200
#define CM_NOTOG   0x400
#define CM_NORIGHT   0x800
#define CM_NOCUT   0x1000
#define LETTERFIRST   (CM_TOGGLE|CM_NUMBER|CM_STRING)
#define RIGHTEDGES   (CM_TOGGLE|CM_NUMBER)
#define CreateMenuEntry_VSimple(c, text)   CreateMenuEntry_Normal(c, text, CM_ONE, 0, 999)
#define CreateMenuEntry_Simple(c, text, flag)   CreateMenuEntry_Normal(c, text, flag, 0, 999)
#define CreateMenuEntry_Normal(c, text, flag, id, mv)   CreateMenuEntry_Killer(c, text, flag, id, 0, mv)
#define AutoCol_Menu(hea, stri, typ)   SelCol_Menu(-1,hea,stri,typ,0)
#define AutoCol_StringMenu(head, str)   AutoCol_Menu(head,str,0)
#define AutoCol_FunStringMenuK(hea, fun, las)   SelCol_FunStringMenuK(-1,hea,fun,las)
#define AutoCol_FunStringMenu(hea, fun)   SelCol_FunStringMenuK(-1,hea,fun)
#define SelCol_StringMenu(col, head, str)   SelCol_Menu(col,head,str,0,0)

Typedefs

typedef coolmenu_type coolmenu

Functions

void CreateMenuEntry_Killer (coolmenu **c, char *text, int flag, int id, int value, int maxvalue)
void KillCoolMenu (coolmenu *c)
void ShowCoolMenu (dbref player, coolmenu *c)
char ** MakeCoolMenuText (coolmenu *c)
int CoolMenu_FPWBit (int number, int maxlen)
coolmenuSelCol_Menu (int columns, char *heading, char **strings, int type, int max)
coolmenuSelCol_FunStringMenuK (int columns, char *heading, char *(*fun)(), int last)
coolmenuSelCol_FunStringMenu (int columns, char *heading, char *(*fun)())


Define Documentation

#define AutoCol_FunStringMenu ( hea,
fun   )     SelCol_FunStringMenuK(-1,hea,fun)

Definition at line 93 of file coolmenu.h.

#define AutoCol_FunStringMenuK ( hea,
fun,
las   )     SelCol_FunStringMenuK(-1,hea,fun,las)

Definition at line 91 of file coolmenu.h.

#define AutoCol_Menu ( hea,
stri,
typ   )     SelCol_Menu(-1,hea,stri,typ,0)

Definition at line 89 of file coolmenu.h.

#define AutoCol_StringMenu ( head,
str   )     AutoCol_Menu(head,str,0)

Definition at line 90 of file coolmenu.h.

Referenced by DumpMechSpecialObjects().

#define CM_CENTER   0x010

Definition at line 40 of file coolmenu.h.

Referenced by display_string(), DoSpecialObjectHelp(), list_matching(), mech_list_maker(), SelCol_FunStringMenuK(), and SelCol_Menu().

#define CM_FOUR   0x008

Definition at line 39 of file coolmenu.h.

Referenced by CoolMenu_FPWBit(), DoSpecialObjectHelp(), list_xcodestuff(), and number_of_entries().

#define CM_LINE   0x080

Definition at line 43 of file coolmenu.h.

Referenced by display_entry(), DoSpecialObjectHelp(), list_matching(), SelCol_FunStringMenuK(), and SelCol_Menu().

#define CM_NO_HILITE   0x200

Definition at line 45 of file coolmenu.h.

Referenced by display_entry(), display_number_end(), and display_toggle_end().

#define CM_NOCUT   0x1000

Definition at line 48 of file coolmenu.h.

Referenced by display_entry(), and display_string().

#define CM_NORIGHT   0x800

Definition at line 47 of file coolmenu.h.

Referenced by display_entry().

#define CM_NOTOG   0x400

Definition at line 46 of file coolmenu.h.

Referenced by CreateMenuEntry_Killer(), display_entry(), and list_matching().

#define CM_NUMBER   0x040

Definition at line 42 of file coolmenu.h.

Referenced by display_entry(), list_matching(), update_entry(), and update_entry_set().

#define CM_ONE   0x001

Definition at line 36 of file coolmenu.h.

Referenced by CoolMenu_FPWBit(), DoSpecialObjectHelp(), list_matching(), list_xcodestuff(), mech_list_maker(), number_of_entries(), SelCol_FunStringMenuK(), and SelCol_Menu().

#define CM_STRING   0x100

Definition at line 44 of file coolmenu.h.

Referenced by update_entry_set().

#define CM_THREE   0x004

Definition at line 38 of file coolmenu.h.

Referenced by CoolMenu_FPWBit(), and number_of_entries().

#define CM_TOGGLE   0x020

Definition at line 41 of file coolmenu.h.

Referenced by display_entry(), and update_entry_toggle().

#define CM_TWO   0x002

Definition at line 37 of file coolmenu.h.

Referenced by CoolMenu_FPWBit(), list_matching(), list_xcodestuff(), and number_of_entries().

#define CreateMenuEntry_Normal ( c,
text,
flag,
id,
mv   )     CreateMenuEntry_Killer(c, text, flag, id, 0, mv)

Definition at line 67 of file coolmenu.h.

Referenced by SelCol_FunStringMenuK(), and SelCol_Menu().

#define CreateMenuEntry_Simple ( c,
text,
flag   )     CreateMenuEntry_Normal(c, text, flag, 0, 999)

Definition at line 65 of file coolmenu.h.

Referenced by list_matching(), SelCol_FunStringMenuK(), and SelCol_Menu().

#define CreateMenuEntry_VSimple ( c,
text   )     CreateMenuEntry_Normal(c, text, CM_ONE, 0, 999)

Definition at line 63 of file coolmenu.h.

#define LETTERFIRST   (CM_TOGGLE|CM_NUMBER|CM_STRING)

Definition at line 50 of file coolmenu.h.

Referenced by CreateMenuEntry_Killer(), and display_entry().

#define MAX_MENU_LENGTH   400

Definition at line 19 of file coolmenu.h.

Referenced by MakeCoolMenuText().

#define MAX_MENU_WIDTH   240

Definition at line 20 of file coolmenu.h.

Referenced by MakeCoolMenuText().

#define MENU_CHAR_WIDTH   78

Definition at line 21 of file coolmenu.h.

Referenced by display_entries().

#define RIGHTEDGES   (CM_TOGGLE|CM_NUMBER)

Definition at line 51 of file coolmenu.h.

Referenced by display_entry().

#define SelCol_StringMenu ( col,
head,
str   )     SelCol_Menu(col,head,str,0,0)

Definition at line 95 of file coolmenu.h.

Referenced by CriticalStatus().


Typedef Documentation

typedef struct coolmenu_type coolmenu


Function Documentation

int CoolMenu_FPWBit ( int  number,
int  maxlen 
)

Definition at line 315 of file coolmenu.c.

00316 {
00317         if(number <= maxlen)
00318                 return CM_ONE;
00319         if(number <= (maxlen * 2))
00320                 return CM_TWO;
00321         if(number <= (maxlen * 3))
00322                 return CM_THREE;
00323         return CM_FOUR;
00324 }

void CreateMenuEntry_Killer ( coolmenu **  c,
char *  text,
int  flag,
int  id,
int  value,
int  maxvalue 
)

Definition at line 264 of file coolmenu.c.

00266 {
00267         coolmenu *d, *e;
00268         char first = 'a';
00269 
00270         if(!*c) {
00271                 Create(*c, coolmenu, 1);
00272                 d = *c;
00273         } else {
00274                 for(d = *c; d->next; d = d->next);
00275                 Create(d->next, coolmenu, 1);
00276                 d = d->next;
00277         }
00278         if(text)
00279                 d->text = strdup(text);
00280         d->flags = flag;
00281         if((flag & LETTERFIRST) && !(flag & CM_NOTOG)) {
00282                 /* gasp, s'pose we need a letter for this thingy */
00283                 for(e = *c; e; e = e->next)
00284                         if(e->letter)
00285                                 if(e->letter >= first)
00286                                         first = e->letter + 1;
00287                 d->letter = first;
00288         }
00289         d->id = id;
00290         d->value = value;
00291         d->maxvalue = maxvalue;
00292 }

void KillCoolMenu ( coolmenu c  ) 

Definition at line 294 of file coolmenu.c.

00295 {
00296         coolmenu *d;
00297 
00298         for(; c; c = d) {
00299                 d = c->next;
00300                 if(c->text)
00301                         free((void *) c->text);
00302                 free((void *) c);
00303         }
00304 }

char** MakeCoolMenuText ( coolmenu c  ) 

Definition at line 240 of file coolmenu.c.

00241 {
00242         char **m;
00243         int pos = 0;
00244         int n, rn;
00245 
00246         Create(m, char *, MAX_MENU_LENGTH + 1);
00247 
00248         /* Whole whopping menu is ready to be written at.. */
00249         while (c)
00250                 if((n = number_of_entries(c)))
00251                         if((rn = count_following_with(c, n))) {
00252                                 Create(m[pos], char, MAX_MENU_WIDTH);
00253 
00254 /*        display_entries(c,rn,m[pos++]); */
00255                                 display_entries(c, n, rn, m[pos++]);
00256                                 while (rn > 0 && c) {
00257                                         rn--;
00258                                         c = c->next;
00259                                 }
00260                         }
00261         return m;
00262 }

coolmenu* SelCol_FunStringMenu ( int  columns,
char *  heading,
char *(*)()  fun 
)

Definition at line 372 of file coolmenu.c.

00373 {
00374         int co;
00375 
00376         for(co = 0; fun(co); co++);
00377         return SelCol_FunStringMenuK(columns, heading, fun, co);
00378 }

coolmenu* SelCol_FunStringMenuK ( int  columns,
char *  heading,
char *(*)()  fun,
int  last 
)

Definition at line 347 of file coolmenu.c.

00349 {
00350         coolmenu *c = NULL;
00351         int i;
00352         char buf[LBUF_SIZE];
00353         int sick = 0;
00354 
00355         strcpy(buf, heading);
00356         buf[0] = toupper(buf[0]);
00357         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00358         CreateMenuEntry_Simple(&c, buf, CM_ONE | CM_CENTER);
00359         if(fun(0)[0] == '%') {
00360                 CreateMenuEntry_Normal(&c, fun(0), columns, 1, 0);
00361                 sick = 1;
00362         }
00363         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00364         if(columns < 0)
00365                 columns = CoolMenu_FPWBit(last, 18);
00366         for(i = sick; i < last; i++)
00367                 CreateMenuEntry_Normal(&c, fun(i), columns, i + 1 - sick, 0);
00368         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00369         return c;
00370 }

coolmenu* SelCol_Menu ( int  columns,
char *  heading,
char **  strings,
int  type,
int  max 
)

Definition at line 326 of file coolmenu.c.

00328 {
00329         coolmenu *c = NULL;
00330         int i, co = 0;
00331         char buf[LBUF_SIZE];
00332 
00333         strcpy(buf, heading);
00334         buf[0] = toupper(buf[0]);
00335         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00336         CreateMenuEntry_Simple(&c, buf, CM_ONE | CM_CENTER);
00337         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00338         for(co = 0; strings[co]; co++);
00339         if(columns < 0)
00340                 columns = CoolMenu_FPWBit(co, 18);
00341         for(i = 0; i < co; i++)
00342                 CreateMenuEntry_Normal(&c, strings[i], columns | type, i + 1, max);
00343         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00344         return c;
00345 }

void ShowCoolMenu ( dbref  player,
coolmenu c 
)

Definition at line 306 of file coolmenu.c.

00307 {
00308         char **ch;
00309 
00310         ch = MakeCoolMenuText(c);
00311         ShowText(ch, player);
00312         KillText(ch);
00313 }


Generated on Mon May 28 04:25:44 2007 for BattletechMUX by  doxygen 1.4.7