mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-22 12:01:25 +00:00
tweak the binds menu. adding spacers, titles, and tooltips.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4653 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
6cc33d7d08
commit
d39708f043
4 changed files with 27 additions and 14 deletions
|
@ -665,16 +665,14 @@ static void MenuDraw(menu_t *menu)
|
|||
|
||||
menutext_t *MC_AddWhiteText(menu_t *menu, int lhs, int rhs, int y, const char *text, qboolean rightalign)
|
||||
{
|
||||
menutext_t *n = Z_Malloc(sizeof(menutext_t));
|
||||
menutext_t *n = Z_Malloc(sizeof(menutext_t) + (text?strlen(text):0)+1);
|
||||
n->common.type = mt_text;
|
||||
n->common.iszone = true;
|
||||
n->common.posx = lhs;
|
||||
n->common.posy = y;
|
||||
n->common.width = rhs?rhs-lhs:0;
|
||||
n->text = text;
|
||||
|
||||
if (rightalign && text)
|
||||
n->common.posx -= strlen(text)*8;
|
||||
n->common.width = (rhs && rightalign)?rhs-lhs:0;
|
||||
n->text = (char*)(n+1);
|
||||
strcpy((char*)(n+1), (text?text:""));
|
||||
|
||||
n->common.next = menu->options;
|
||||
menu->options = (menuoption_t *)n;
|
||||
|
@ -704,14 +702,14 @@ menutext_t *MC_AddBufferedText(menu_t *menu, int lhs, int rhs, int y, const char
|
|||
menutext_t *MC_AddRedText(menu_t *menu, int lhs, int rhs, int y, const char *text, qboolean rightalign)
|
||||
{
|
||||
menutext_t *n;
|
||||
n = MC_AddWhiteText(menu, lhs, rhs, y, text, false);
|
||||
n = MC_AddWhiteText(menu, lhs, rhs, y, text, rightalign);
|
||||
n->isred = true;
|
||||
return n;
|
||||
}
|
||||
|
||||
menubind_t *MC_AddBind(menu_t *menu, int cx, int bx, int y, const char *caption, char *command)
|
||||
menubind_t *MC_AddBind(menu_t *menu, int cx, int bx, int y, const char *caption, char *command, char *tooltip)
|
||||
{
|
||||
menubind_t *n = Z_Malloc(sizeof(*n) + strlen(caption)+1 + strlen(command)+1);
|
||||
menubind_t *n = Z_Malloc(sizeof(*n) + strlen(caption)+1 + strlen(command)+1 + (tooltip?strlen(tooltip)+1:0));
|
||||
n->common.type = mt_bind;
|
||||
n->common.iszone = true;
|
||||
n->common.posx = cx;
|
||||
|
@ -721,6 +719,11 @@ menubind_t *MC_AddBind(menu_t *menu, int cx, int bx, int y, const char *caption,
|
|||
strcpy(n->caption, caption);
|
||||
n->command = n->caption+strlen(n->caption)+1;
|
||||
strcpy(n->command, command);
|
||||
if (tooltip)
|
||||
{
|
||||
n->common.tooltip = n->command+strlen(n->command)+1;
|
||||
strcpy(n->common.tooltip, tooltip);
|
||||
}
|
||||
n->common.width = n->captionwidth + 64;
|
||||
n->common.height = 8;
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ void M_MenuS_Bind_f (void)
|
|||
if (!*caption)
|
||||
caption = command;
|
||||
|
||||
MC_AddBind(menu_script, x, x+160, y, command, caption);
|
||||
MC_AddBind(menu_script, x, x+160, y, command, caption, NULL);
|
||||
}
|
||||
|
||||
void M_MenuS_Comboi_f (void)
|
||||
|
|
|
@ -435,9 +435,19 @@ void M_Menu_Keys_f (void)
|
|||
char line[1024];
|
||||
while(VFS_GETS(bindslist, line, sizeof(line)))
|
||||
{
|
||||
char *cmd, *desc, *tip;
|
||||
Cmd_TokenizeString(line, false, false);
|
||||
MC_AddBind(menu, 16, 170, y, Cmd_Argv(1), Cmd_Argv(0));
|
||||
y += 8;
|
||||
cmd = Cmd_Argv(0);
|
||||
desc = Cmd_Argv(1);
|
||||
tip = Cmd_Argv(2);
|
||||
if (*cmd)
|
||||
{
|
||||
if (strcmp(cmd, "-")) //lines with a command of "-" are spacers/comments.
|
||||
MC_AddBind(menu, (320-(int)vid.width)/2, 170, y, desc, cmd, tip);
|
||||
else if (*desc)
|
||||
MC_AddRedText(menu, (320-(int)vid.width)/2, 170, y, desc, true);
|
||||
y += 8;
|
||||
}
|
||||
}
|
||||
VFS_CLOSE(bindslist);
|
||||
return;
|
||||
|
@ -445,7 +455,7 @@ void M_Menu_Keys_f (void)
|
|||
|
||||
while (bindnames->name)
|
||||
{
|
||||
MC_AddBind(menu, 16, 170, y, bindnames->name, bindnames->command);
|
||||
MC_AddBind(menu, 16, 170, y, bindnames->name, bindnames->command, NULL);
|
||||
y += 8;
|
||||
|
||||
bindnames++;
|
||||
|
|
|
@ -293,7 +293,7 @@ typedef struct menu_s {
|
|||
menutext_t *MC_AddBufferedText(menu_t *menu, int lhs, int rhs, int y, const char *text, qboolean rightalign, qboolean red);
|
||||
menutext_t *MC_AddRedText(menu_t *menu, int lhs, int rhs, int y, const char *text, qboolean rightalign);
|
||||
menutext_t *MC_AddWhiteText(menu_t *menu, int lhs, int rhs, int y, const char *text, qboolean rightalign);
|
||||
menubind_t *MC_AddBind(menu_t *menu, int cx, int bx, int y, const char *caption, char *command);
|
||||
menubind_t *MC_AddBind(menu_t *menu, int cx, int bx, int y, const char *caption, char *command, char *tooltip);
|
||||
menubox_t *MC_AddBox(menu_t *menu, int x, int y, int width, int height);
|
||||
menupicture_t *MC_AddPicture(menu_t *menu, int x, int y, int width, int height, char *picname);
|
||||
menupicture_t *MC_AddSelectablePicture(menu_t *menu, int x, int y, char *picname);
|
||||
|
|
Loading…
Reference in a new issue