Skip to content

Commit

Permalink
Game Menu: Inline lists are new object types (MN_LISTINLINE)
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Dec 30, 2011
1 parent 23fadd6 commit e45e595
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 24 deletions.
12 changes: 7 additions & 5 deletions doomsday/plugins/common/include/hu_lib.h
Expand Up @@ -62,6 +62,7 @@ typedef enum {
MN_BUTTON,
MN_EDIT,
MN_LIST,
MN_LISTINLINE,
MN_SLIDER,
MN_COLORBOX,
MN_BINDINGS,
Expand Down Expand Up @@ -434,8 +435,8 @@ void MNEdit_SetText(mn_object_t* obj, int flags, const char* string);
/**
* List selection.
*/
#define MNDATA_LIST_LEADING .5f /// Inter-item leading factor (does not apply to MNList_InlineDrawer).
#define MNDATA_LIST_NONSELECTION_LIGHT .7f /// Light value multiplier for non-selected items (does not apply to MNList_InlineDrawer).
#define MNDATA_LIST_LEADING .5f /// Inter-item leading factor (does not apply to MNListInline_Drawer).
#define MNDATA_LIST_NONSELECTION_LIGHT .7f /// Light value multiplier for non-selected items (does not apply to MNListInline_Drawer).

#define NUMLISTITEMS(x) (sizeof(x)/sizeof(mndata_listitem_t))

Expand All @@ -444,6 +445,7 @@ typedef struct {
int data;
} mndata_listitem_t;

/// \note Also used for MN_LISTINLINE!
typedef struct mndata_list_s {
void* items;
int count; // Number of items.
Expand All @@ -455,13 +457,13 @@ typedef struct mndata_list_s {
} mndata_list_t;

void MNList_Drawer(mn_object_t* obj, const Point2Raw* origin);
void MNList_InlineDrawer(mn_object_t* obj, const Point2Raw* origin);
void MNListInline_Drawer(mn_object_t* obj, const Point2Raw* origin);

int MNList_CommandResponder(mn_object_t* obj, menucommand_e command);
int MNList_InlineCommandResponder(mn_object_t* obj, menucommand_e command);
int MNListInline_CommandResponder(mn_object_t* obj, menucommand_e command);

void MNList_UpdateGeometry(mn_object_t* obj, mn_page_t* page);
void MNList_InlineUpdateGeometry(mn_object_t* obj, mn_page_t* page);
void MNListInline_UpdateGeometry(mn_object_t* obj, mn_page_t* page);

/// @return Index of the currently selected item else -1.
int MNList_Selection(mn_object_t* obj);
Expand Down
15 changes: 8 additions & 7 deletions doomsday/plugins/common/src/hu_lib.c
Expand Up @@ -1060,7 +1060,8 @@ void MNPage_Initialize(mn_page_t* page)

break;
}
case MN_LIST: {
case MN_LIST:
case MN_LISTINLINE: {
mndata_list_t* list = obj->_typedata;
int j;
for(j = 0; j < list->count; ++j)
Expand Down Expand Up @@ -1838,11 +1839,11 @@ boolean MNList_SelectItemByValue(mn_object_t* obj, int flags, int dataValue)
return MNList_SelectItem(obj, flags, MNList_FindItem(obj, dataValue));
}

void MNList_InlineDrawer(mn_object_t* obj, const Point2Raw* origin)
void MNListInline_Drawer(mn_object_t* obj, const Point2Raw* origin)
{
const mndata_list_t* list = (mndata_list_t*)obj->_typedata;
const mndata_listitem_t* item = ((const mndata_listitem_t*)list->items) + list->selection;
assert(obj->_type == MN_LIST);
assert(obj->_type == MN_LISTINLINE);

DGL_Enable(DGL_TEXTURE_2D);
FR_SetFont(rs.textFonts[obj->_pageFontIdx]);
Expand All @@ -1852,10 +1853,10 @@ void MNList_InlineDrawer(mn_object_t* obj, const Point2Raw* origin)
DGL_Disable(DGL_TEXTURE_2D);
}

int MNList_InlineCommandResponder(mn_object_t* obj, menucommand_e cmd)
int MNListInline_CommandResponder(mn_object_t* obj, menucommand_e cmd)
{
mndata_list_t* list = (mndata_list_t*)obj->_typedata;
assert(obj->_type == MN_LIST);
assert(obj->_type == MN_LISTINLINE);

switch(cmd)
{
Expand Down Expand Up @@ -1919,11 +1920,11 @@ void MNList_UpdateGeometry(mn_object_t* obj, mn_page_t* page)
}
}

void MNList_InlineUpdateGeometry(mn_object_t* obj, mn_page_t* page)
void MNListInline_UpdateGeometry(mn_object_t* obj, mn_page_t* page)
{
mndata_list_t* list = (mndata_list_t*)obj->_typedata;
mndata_listitem_t* item = ((mndata_listitem_t*) list->items) + list->selection;
assert(obj->_type == MN_LIST);
assert(obj->_type == MN_LISTINLINE);

FR_SetFont(MNPage_PredefinedFont(page, obj->_pageFontIdx));
FR_TextSize(&obj->_geometry.size, item->text);
Expand Down
23 changes: 11 additions & 12 deletions doomsday/plugins/common/src/hu_menu.c
Expand Up @@ -901,7 +901,7 @@ static mn_object_t HudMenuObjects[] = {

{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR2, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_crosshair },
{ MN_TEXT, 0, 0, 'c',MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_xhair_symbol },
{ MN_LIST, 0, 0, 0, MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_hud_xhair_symbol },
{ MN_LISTINLINE, 0, 0, 0, MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_hud_xhair_symbol },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_xhair_size },
{ MN_SLIDER, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNSlider_UpdateGeometry, MNSlider_Drawer, { Hu_MenuCvarSlider, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNSlider_CommandResponder, NULL, NULL, &sld_hud_xhair_size },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_xhair_opacity },
Expand All @@ -921,11 +921,11 @@ static mn_object_t HudMenuObjects[] = {
#if __JDOOM__ || __JDOOM64__ || __JHERETIC__
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR2, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_counters },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_cntr_kills },
{ MN_LIST, 0, 0, 'k',MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_hud_cntr_kills },
{ MN_LISTINLINE, 0, 0, 'k',MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_hud_cntr_kills },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_cntr_items },
{ MN_LIST, 0, 0, 'i',MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_hud_cntr_items },
{ MN_LISTINLINE, 0, 0, 'i',MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_hud_cntr_items },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_cntr_secrets },
{ MN_LIST, 0, 0, 's',MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_hud_cntr_secrets },
{ MN_LISTINLINE, 0, 0, 's',MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_hud_cntr_secrets },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_hud_cntr_size },
{ MN_SLIDER, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNSlider_UpdateGeometry, MNSlider_Drawer, { Hu_MenuCvarSlider, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNSlider_CommandResponder, NULL, NULL, &sld_hud_cntr_size },
#endif
Expand Down Expand Up @@ -1121,11 +1121,11 @@ static mn_object_t WeaponMenuObjects[] = {

{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR2, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_weapons_autoswitch },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_weapons_aswch_pickup_weapon },
{ MN_LIST, 0, 0, 'w',MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_weapons_autoswitch_pickup },
{ MN_LISTINLINE, 0, 0, 'w',MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_weapons_autoswitch_pickup },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_weapons_aswch_pickup_weapon_ifnot_firing },
{ MN_BUTTON, 0, 0, 'f',MENU_FONT1, MENU_COLOR3, MNButton_UpdateGeometry, MNButton_Drawer, { Hu_MenuCvarButton, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNButton_CommandResponder, NULL, NULL, &btn_weapons_aswch_pickup_weapon_ifnot_firing },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_weapons_aswch_pickup_ammo },
{ MN_LIST, 0, 0, 'a',MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_weapons_autoswitch_pickupammo },
{ MN_LISTINLINE, 0, 0, 'a',MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_weapons_autoswitch_pickupammo },
#if __JDOOM__ || __JDOOM64__
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_weapons_aswch_pickup_berserk },
{ MN_BUTTON, 0, 0, 'b',MENU_FONT1, MENU_COLOR3, MNButton_UpdateGeometry, MNButton_Drawer, { Hu_MenuCvarButton, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNButton_CommandResponder, NULL, NULL, &btn_weapons_aswch_pickup_berserk },
Expand Down Expand Up @@ -1216,13 +1216,13 @@ mn_object_t AutomapMenuObjects[] = {
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_line_opacity },
{ MN_SLIDER, 0, 0, 'l', MENU_FONT1, MENU_COLOR1, MNSlider_UpdateGeometry, MNSlider_Drawer, { Hu_MenuCvarSlider, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNSlider_CommandResponder, NULL, NULL, &sld_map_lineopacity },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_hud_display },
{ MN_LIST, 0, 0, 'h', MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &lst_map_statusbar },
{ MN_LISTINLINE, 0, 0, 'h', MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &lst_map_statusbar },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_door_colors },
{ MN_BUTTON, 0, 0, 'c', MENU_FONT1, MENU_COLOR3, MNButton_UpdateGeometry, MNButton_Drawer, { Hu_MenuCvarButton, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNButton_CommandResponder, NULL, NULL, &btn_map_door_colors },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_door_glow },
{ MN_SLIDER, 0, 0, 'g', MENU_FONT1, MENU_COLOR1, MNSlider_UpdateGeometry, MNSlider_Drawer, { Hu_MenuCvarSlider, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNSlider_CommandResponder, NULL, NULL, &sld_map_doorglow },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_use_custom_colors },
{ MN_LIST, 0, 0, 0, MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &lst_map_customcolors },
{ MN_LISTINLINE, 0, 0, 0, MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuCvarList, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &lst_map_customcolors },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_color_wall },
{ MN_COLORBOX, 0, 0, 'w', MENU_FONT1, MENU_COLOR1, MNColorBox_UpdateGeometry, MNColorBox_Drawer, { Hu_MenuCvarColorBox, NULL, Hu_MenuActivateColorWidget, NULL, NULL, Hu_MenuDefaultFocusAction }, MNColorBox_CommandResponder, NULL, NULL, &cbox_map_line_solid_color },
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_map_color_floor_height_change },
Expand Down Expand Up @@ -1473,10 +1473,10 @@ mn_object_t PlayerSetupMenuObjects[] = {
{ MN_EDIT, 0, MNF_ID1, 0, MENU_FONT1, MENU_COLOR1, MNEdit_UpdateGeometry, MNEdit_Drawer, { NULL, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNEdit_CommandResponder, MNEdit_Responder, NULL, &edit_player_name },
#if __JHEXEN__
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_player_class },
{ MN_LIST, 0, MNF_ID2, 'c', MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuSelectPlayerSetupPlayerClass, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_player_class },
{ MN_LISTINLINE, 0, MNF_ID2, 'c', MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuSelectPlayerSetupPlayerClass, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_player_class },
#endif
{ MN_TEXT, 0, 0, 0, MENU_FONT1, MENU_COLOR1, MNText_UpdateGeometry, MNText_Drawer, { NULL }, NULL, NULL, NULL, &txt_player_color },
{ MN_LIST, 0, MNF_ID3, 0, MENU_FONT1, MENU_COLOR3, MNList_InlineUpdateGeometry, MNList_InlineDrawer, { Hu_MenuSelectPlayerColor, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNList_InlineCommandResponder, NULL, NULL, &list_player_color },
{ MN_LISTINLINE,0, MNF_ID3, 0, MENU_FONT1, MENU_COLOR3, MNListInline_UpdateGeometry, MNListInline_Drawer, { Hu_MenuSelectPlayerColor, NULL, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNListInline_CommandResponder, NULL, NULL, &list_player_color },
{ MN_BUTTON, 0, 0, 's', MENU_FONT2, MENU_COLOR1, MNButton_UpdateGeometry, MNButton_Drawer, { NULL, Hu_MenuSelectAcceptPlayerSetup, NULL, NULL, NULL, Hu_MenuDefaultFocusAction }, MNButton_CommandResponder, NULL, NULL, &btn_player_save_changes },
{ MN_NONE }
};
Expand Down Expand Up @@ -1665,8 +1665,7 @@ static boolean Hu_MenuHasCursorRotation(mn_object_t* obj)
{
assert(obj);
return (!(MNObject_Flags(obj) & MNF_DISABLED) &&
((MNObject_Type(obj) == MN_LIST && obj->cmdResponder == MNList_InlineCommandResponder) ||
MNObject_Type(obj) == MN_SLIDER));
(MNObject_Type(obj) == MN_LISTINLINE || MNObject_Type(obj) == MN_SLIDER));
}

/// To be called to re-evaluate the state of the cursor (e.g., when focus changes).
Expand Down

0 comments on commit e45e595

Please sign in to comment.