shameless quick menu collision hack

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3819 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2011-06-16 21:41:05 +00:00
parent 174ba9f64b
commit 2fe74cfda3
2 changed files with 55 additions and 86 deletions

View File

@ -345,7 +345,7 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
{ {
if (mousemoved && !bindingactive && !option->common.ishidden) if (mousemoved && !bindingactive && !option->common.ishidden)
{ {
if (omousex > xpos+option->common.posx && omousex < xpos+option->common.posx+option->common.width) if (omousex > xpos+option->common.posx-option->common.extracollide && omousex < xpos+option->common.posx+option->common.width)
{ {
if (omousey > ypos+option->common.posy && omousey < ypos+option->common.posy+option->common.height) if (omousey > ypos+option->common.posy && omousey < ypos+option->common.posy+option->common.height)
{ {
@ -2050,12 +2050,20 @@ void M_Menu_Main_f (void)
int MC_AddBulk(struct menu_s *menu, menubulk_t *bulk, int xstart, int xtextend, int y) int MC_AddBulk(struct menu_s *menu, menubulk_t *bulk, int xstart, int xtextend, int y)
{ {
int x;
int selectedy = y; int selectedy = y;
menuoption_t *selected = NULL; menuoption_t *selected = NULL;
while (bulk) while (bulk)
{ {
qboolean selectable = true;
menuoption_t *control;
int x = xtextend;
int xleft;
if (bulk->text)
x -= strlen(bulk->text) * 8;
xleft = x - xstart;
switch (bulk->type) switch (bulk->type)
{ {
case mt_text: case mt_text:
@ -2065,14 +2073,12 @@ int MC_AddBulk(struct menu_s *menu, menubulk_t *bulk, int xstart, int xtextend,
bulk = NULL; bulk = NULL;
continue; continue;
case 0: // white text case 0: // white text
x = xtextend - strlen(bulk->text) * 8; control = (union menuoption_s *)MC_AddWhiteText(menu, x, y, bulk->text, bulk->rightalign);
MC_AddWhiteText(menu, x, y, bulk->text, bulk->rightalign); selectable = false;
y += 8;
break; break;
case 1: // red text case 1: // red text
x = xtextend - strlen(bulk->text) * 8; control = (union menuoption_s *)MC_AddRedText(menu, x, y, bulk->text, bulk->rightalign);
MC_AddRedText(menu, x, y, bulk->text, bulk->rightalign); selectable = false;
y += 8;
break; break;
case 2: // spacing case 2: // spacing
y += bulk->spacing; y += bulk->spacing;
@ -2080,97 +2086,48 @@ int MC_AddBulk(struct menu_s *menu, menubulk_t *bulk, int xstart, int xtextend,
} }
break; break;
case mt_button: case mt_button:
switch (bulk->variant)
{ {
menubutton_t *button; default:
x = xtextend - strlen(bulk->text) * 8; case 0: // console command
switch (bulk->variant) control = (union menuoption_s *)MC_AddConsoleCommand(menu, x, y, bulk->text, bulk->consolecmd);
{ break;
default: case 1: // function command
case 0: // console command control = (union menuoption_s *)MC_AddCommand(menu, x, y, bulk->text, bulk->command);
button = MC_AddConsoleCommand(menu, x, y, bulk->text, bulk->consolecmd); break;
break;
case 1: // function command
button = MC_AddCommand(menu, x, y, bulk->text, bulk->command);
break;
}
if (!selected)
selected = (union menuoption_s *)button;
if (bulk->tooltip)
button->common.tooltip = bulk->tooltip;
y += 8;
} }
break; break;
case mt_checkbox: case mt_checkbox:
x = xtextend - strlen(bulk->text) * 8; control = (union menuoption_s *)MC_AddCheckBox(menu, x, y, bulk->text, bulk->cvar, bulk->flags);
{ control->check.func = bulk->func;
menucheck_t *check = MC_AddCheckBox(menu, x, y, bulk->text, bulk->cvar, bulk->flags);
check->func = bulk->func;
if (bulk->ret)
*bulk->ret = (union menuoption_s *)check;
if (!selected)
selected = (union menuoption_s *)check;
if (bulk->tooltip)
check->common.tooltip = bulk->tooltip;
}
y += 8;
break; break;
case mt_slider: case mt_slider:
x = xtextend - strlen(bulk->text) * 8; control = (union menuoption_s *)MC_AddSlider(menu, x, y, bulk->text, bulk->cvar, bulk->min, bulk->max, bulk->delta);
{
menuslider_t *slider = MC_AddSlider(menu, x, y, bulk->text, bulk->cvar, bulk->min, bulk->max, bulk->delta);
if (!selected)
selected = (union menuoption_s *)slider;
if (bulk->tooltip)
slider->common.tooltip = bulk->tooltip;
}
y += 8;
break; break;
case mt_combo: case mt_combo:
switch (bulk->variant)
{ {
menucombo_t *combo; default:
x = xtextend - strlen(bulk->text) * 8; case 0: // cvar combo
switch (bulk->variant) control = (union menuoption_s *)MC_AddCvarCombo(menu, x, y, bulk->text, bulk->cvar, bulk->options, bulk->values);
{ break;
default: case 1: // combo with return value
case 0: // cvar combo control = (union menuoption_s *)MC_AddCombo(menu, x, y, bulk->text, bulk->options, bulk->selectedoption);
combo = MC_AddCvarCombo(menu, x, y, bulk->text, bulk->cvar, bulk->options, bulk->values); break;
break;
case 1: // combo with return value
combo = MC_AddCombo(menu, x, y, bulk->text, bulk->options, bulk->selectedoption);
break;
}
if (bulk->ret)
*bulk->ret = (union menuoption_s *)combo;
if (!selected)
selected = (union menuoption_s *)combo;
if (bulk->tooltip)
combo->common.tooltip = bulk->tooltip;
y += 8;
} }
break; break;
case mt_edit: case mt_edit:
switch (bulk->variant)
{ {
menuedit_t *edit; default:
x = xtextend - strlen(bulk->text) * 8; case 0:
switch (bulk->variant) y += 4;
{ control = (union menuoption_s *)MC_AddEditCvar(menu, x, y, bulk->text, bulk->cvarname);
default: y += 4;
case 0: break;
y += 4; case 1:
edit = MC_AddEditCvar(menu, x, y, bulk->text, bulk->cvarname); control = (union menuoption_s *)MC_AddEditCvarSlim(menu, x, y, bulk->text, bulk->cvarname);
y += 4; break;
break;
case 1:
edit = MC_AddEditCvarSlim(menu, x, y, bulk->text, bulk->cvarname);
break;
}
if (bulk->ret)
*bulk->ret = (union menuoption_s *)edit;
if (!selected)
selected = (union menuoption_s *)edit;
if (bulk->tooltip)
edit->common.tooltip = bulk->tooltip;
y += 8;
} }
break; break;
default: default:
@ -2178,6 +2135,17 @@ int MC_AddBulk(struct menu_s *menu, menubulk_t *bulk, int xstart, int xtextend,
bulk = NULL; bulk = NULL;
continue; continue;
} }
if (bulk->ret)
*bulk->ret = control;
if (selectable && !selected)
selected = control;
if (bulk->tooltip)
control->common.tooltip = bulk->tooltip;
if (xleft > 0)
control->common.extracollide = xleft;
y += 8;
bulk++; bulk++;
} }

View File

@ -144,6 +144,7 @@ typedef struct { //must be first of each structure type.
int posy; int posy;
int width; int width;
int height; int height;
int extracollide; // dirty hack to stretch collide box left (the real fix is to have separate collide/render rects)
char *tooltip; char *tooltip;
qboolean noselectionsound:1; qboolean noselectionsound:1;
qboolean iszone:1; qboolean iszone:1;