1
0
Fork 0
forked from fte/fteqw

isolated selectable menu pictures (Q2), solves strange problem where a massive fps drop occurs with the first Q1 main menu option selected

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2272 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
TimeServ 2006-05-11 00:41:47 +00:00
parent 640524e990
commit 5c7cae1ffe
2 changed files with 61 additions and 10 deletions

View file

@ -232,22 +232,25 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
p = Draw_SafeCachePic(va(menudotstyle, i+mindot )); p = Draw_SafeCachePic(va(menudotstyle, i+mindot ));
Draw_TransPic(xpos+option->common.posx, ypos+option->common.posy+dotofs, p); Draw_TransPic(xpos+option->common.posx, ypos+option->common.posy+dotofs, p);
break; break;
case mt_picture: case mt_picturesel:
p = NULL; p = NULL;
if (menu->selecteditem && menu->selecteditem->common.posx == option->common.posx && menu->selecteditem->common.posy == option->common.posy) if (menu->selecteditem && menu->selecteditem->common.posx == option->common.posx && menu->selecteditem->common.posy == option->common.posy)
{ {
char selname[MAX_QPATH]; char selname[MAX_QPATH];
Q_strncpyz(selname, option->picture.picturename, sizeof(selname)); Q_strncpyz(selname, option->picture.picturename, sizeof(selname));
COM_StripExtension(selname, selname, sizeof(selname)); COM_StripExtension(selname, selname, sizeof(selname));
p = Draw_SafeCachePic(va("%s_sel", selname)); Q_strncatz(selname, "_sel", sizeof(selname));
p = Draw_SafeCachePic(selname);
} }
if (!p) if (!p)
p = Draw_SafeCachePic(option->picture.picturename); p = Draw_SafeCachePic(option->picture.picturename);
Draw_TransPic (xpos+option->common.posx, ypos+option->common.posy, p); Draw_TransPic (xpos+option->common.posx, ypos+option->common.posy, p);
break; break;
case mt_picture:
p = Draw_SafeCachePic(option->picture.picturename);
Draw_TransPic (xpos+option->common.posx, ypos+option->common.posy, p);
break;
case mt_strechpic: case mt_strechpic:
p = Draw_SafeCachePic(option->picture.picturename); p = Draw_SafeCachePic(option->picture.picturename);
if (p) Draw_ScalePic(xpos+option->common.posx, ypos+option->common.posy, option->common.width, option->common.height, p); if (p) Draw_ScalePic(xpos+option->common.posx, ypos+option->common.posy, option->common.width, option->common.height, p);
@ -488,6 +491,34 @@ menubind_t *MC_AddBind(menu_t *menu, int x, int y, const char *caption, char *co
return n; return n;
} }
menupicture_t *MC_AddSelectablePicture(menu_t *menu, int x, int y, char *picname)
{
char selname[MAX_QPATH];
menupicture_t *n;
if (!qrenderer)
return NULL;
Q_strncpyz(selname, picname, sizeof(selname));
COM_StripExtension(selname, selname, sizeof(selname));
Q_strncatz(selname, "_sel", sizeof(selname));
Draw_SafeCachePic(picname);
Draw_SafeCachePic(selname);
n = Z_Malloc(sizeof(menupicture_t) + strlen(picname)+1);
n->common.type = mt_picturesel;
n->common.iszone = true;
n->common.posx = x;
n->common.posy = y;
n->picturename = (char *)(n+1);
strcpy(n->picturename, picname);
n->common.next = menu->options;
menu->options = (menuoption_t *)n;
return n;
}
menupicture_t *MC_AddPicture(menu_t *menu, int x, int y, char *picname) menupicture_t *MC_AddPicture(menu_t *menu, int x, int y, char *picname)
{ {
menupicture_t *n; menupicture_t *n;
@ -1526,11 +1557,11 @@ void M_Menu_Main_f (void)
if (!p) if (!p)
return; return;
MC_AddPicture(mainm, 0, 173, "pics/m_main_logo"); MC_AddPicture(mainm, 0, 173, "pics/m_main_logo");
MC_AddPicture(mainm, 68, 13, "pics/m_main_game"); MC_AddSelectablePicture(mainm, 68, 13, "pics/m_main_game");
MC_AddPicture(mainm, 68, 53, "pics/m_main_multiplayer"); MC_AddSelectablePicture(mainm, 68, 53, "pics/m_main_multiplayer");
MC_AddPicture(mainm, 68, 93, "pics/m_main_options"); MC_AddSelectablePicture(mainm, 68, 93, "pics/m_main_options");
MC_AddPicture(mainm, 68, 133, "pics/m_main_video"); MC_AddSelectablePicture(mainm, 68, 133, "pics/m_main_video");
MC_AddPicture(mainm, 68, 173, "pics/m_main_quit"); MC_AddSelectablePicture(mainm, 68, 173, "pics/m_main_quit");
b = MC_AddConsoleCommand (mainm, 68, 13, "", "menu_single\n"); b = MC_AddConsoleCommand (mainm, 68, 13, "", "menu_single\n");
mainm->selecteditem = (menuoption_t *)b; mainm->selecteditem = (menuoption_t *)b;

View file

@ -116,7 +116,26 @@ struct menu_s;
typedef enum {m_none, m_complex, m_help, m_keys, m_slist, m_media, m_plugin, m_menu_dat} m_state_t; typedef enum {m_none, m_complex, m_help, m_keys, m_slist, m_media, m_plugin, m_menu_dat} m_state_t;
extern m_state_t m_state; extern m_state_t m_state;
typedef enum {mt_childwindow, mt_button, mt_qbuttonbigfont, mt_hexen2buttonbigfont, mt_box, mt_colouredbox, mt_line, mt_edit, mt_text, mt_slider, mt_combo, mt_bind, mt_checkbox, mt_picture, mt_strechpic, mt_menudot, mt_custom} menutype_t; typedef enum {
mt_childwindow,
mt_button,
mt_qbuttonbigfont,
mt_hexen2buttonbigfont,
mt_box,
mt_colouredbox,
mt_line,
mt_edit,
mt_text,
mt_slider,
mt_combo,
mt_bind,
mt_checkbox,
mt_picture,
mt_picturesel,
mt_strechpic,
mt_menudot,
mt_custom
} menutype_t;
typedef struct { //must be first of each structure type. typedef struct { //must be first of each structure type.
menutype_t type; menutype_t type;
@ -256,6 +275,7 @@ menutext_t *MC_AddWhiteText(menu_t *menu, int x, int y, const char *text, qboole
menubind_t *MC_AddBind(menu_t *menu, int x, int y, const char *caption, char *command); menubind_t *MC_AddBind(menu_t *menu, int x, int y, const char *caption, char *command);
menubox_t *MC_AddBox(menu_t *menu, int x, int y, int width, int height); 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, char *picname); menupicture_t *MC_AddPicture(menu_t *menu, int x, int y, char *picname);
menupicture_t *MC_AddSelectablePicture(menu_t *menu, int x, int y, char *picname);
menupicture_t *MC_AddStrechPicture(menu_t *menu, int x, int y, int width, int height, char *picname); menupicture_t *MC_AddStrechPicture(menu_t *menu, int x, int y, int width, int height, char *picname);
menupicture_t *MC_AddCenterPicture(menu_t *menu, int y, char *picname); menupicture_t *MC_AddCenterPicture(menu_t *menu, int y, char *picname);
menupicture_t *MC_AddCursor(menu_t *menu, int x, int y); menupicture_t *MC_AddCursor(menu_t *menu, int x, int y);