Skip to content

Commit

Permalink
Continued menu cleanup:
Browse files Browse the repository at this point in the history
* Implemented MNF_FOCUS and MNF_DEFAULT (focus) flags.
* Added predefined fonts and colors to the menu render state.
* In order to calculate an object's dimensions the page on which it is present must be known. Refactored class hierarchy accordingly and removed the now redundant "current page" concept from the menu renderer.
* Reinstated the FinaleResponder export which I mistakenly removed in an earlier commit. This needs to be addressed, however. We shouldn't be asking the game to route ddevent_ts to FinaleInterpreter.
  • Loading branch information
danij-deng committed May 3, 2011
1 parent c47b413 commit b6d812e
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 200 deletions.
1 change: 1 addition & 0 deletions doomsday/engine/api/dd_api.h
Expand Up @@ -83,6 +83,7 @@ typedef struct {
void (*Ticker) (timespan_t ticLength);

// Responders.
int (*FinaleResponder) (const void* ddev);
int (*PrivilegedResponder) (event_t* ev);
int (*Responder) (event_t* ev);
int (*FallbackResponder) (event_t* ev);
Expand Down
4 changes: 4 additions & 0 deletions doomsday/engine/portable/src/dd_input.c
Expand Up @@ -876,6 +876,10 @@ static void dispatchEvents(timespan_t ticLength)
if(gx.PrivilegedResponder)
if(gx.PrivilegedResponder(&ev))
continue;

if(gx.FinaleResponder)
if(gx.FinaleResponder((void*)ddev))
continue;
}

if(UI_Responder(ddev))
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/src/finaleinterpreter.c
Expand Up @@ -1179,7 +1179,7 @@ int FinaleInterpreter_Responder(finaleinterpreter_t* fi, const ddevent_t* ev)
}
}

// If we can't skip, there'fi no interaction of any kind.
// If we can't skip, there's no interaction of any kind.
if(!fi->flags.can_skip && !fi->flags.paused)
return false;

Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/include/fi_lib.h
Expand Up @@ -93,6 +93,6 @@ boolean FI_RequestSkip(void);
/// @return @c true iff the event should open the menu.
boolean FI_IsMenuTrigger(void);

boolean FI_PrivilegedResponder(const void* ev);
int FI_PrivilegedResponder(const void* ev);

#endif /* LIBCOMMON_INFINE_LIB */
94 changes: 58 additions & 36 deletions doomsday/plugins/common/include/m_defs.h
Expand Up @@ -5,7 +5,6 @@
*
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*\author Copyright © 1993-1996 by id Software, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -73,9 +72,9 @@ typedef enum {
//#define MNF_PAUSED 0x4 // Ticker not called.
#define MNF_CLICKED 0x8
#define MNF_INACTIVE 0x10 // Object active.
//#define MNF_FOCUS 0x20 // Has focus.
#define MNF_FOCUS 0x20 // Has focus.
#define MNF_NO_FOCUS 0x40 // Can't receive focus.
//#define MNF_DEFAULT 0x80 // Has focus by default.
#define MNF_DEFAULT 0x80 // Has focus by default.
//#define MNF_LEFT_ALIGN 0x100
//#define MNF_FADE_AWAY 0x200 // Fade UI away while the control is active.
//#define MNF_NEVER_FADE 0x400
Expand All @@ -86,23 +85,60 @@ typedef enum {
#define MNF_ID3 0x80000000
/*@}*/

/**
* MNObject. Abstract base from which all menu page objects must be derived.
*/
typedef struct mn_object_s {
mn_obtype_e type; // Type of the object.
/// Type of the object.
mn_obtype_e type;

/// Object group identifier.
int group;
int flags; // @see menuObjectFlags.

/// @see menuObjectFlags.
int flags;

/// Used in various ways depending on the context.
/// \todo Does not belong here, move it out.
const char* text;

/// Index of the predefined page font to use when drawing this.
/// \todo Does not belong here, move it out.
int pageFontIdx;

/// Index of the predefined page color to use when drawing this.
/// \todo Does not belong here, move it out.
int pageColorIdx;

/// Patch to be used when drawing this.
/// \todo Does not belong here, move it out.
patchid_t* patch;
void (*dimensions) (const struct mn_object_s* obj, int* width, int* height);

/// Calculate dimensions for this when visible on the specified page.
void (*dimensions) (const struct mn_object_s* obj, struct mn_page_s* page, int* width, int* height);

/// Draw this at the specified offset within the owning view-space.
/// Can be @c NULL in which case this will never be drawn.
void (*drawer) (struct mn_object_s* obj, int x, int y);

/// "Action" callback to be exectued as directed by the logic of the
/// responder callbacks. Can be @c NULL.
void (*action) (struct mn_object_s* obj);

/// Respond to the given (menu) @a command. Can be @c NULL.
/// @return @c true if the command is eaten.
int (*cmdResponder) (struct mn_object_s* obj, menucommand_e command);

/// Respond to the given (input) event @a ev. Can be @c NULL.
/// @return @c true if the event is eaten.
int (*responder) (struct mn_object_s* obj, event_t* ev);

/// Respond to the given (input) event @a ev. Can be @c NULL.
/// @return @c true if the event is eaten.
int (*privilegedResponder) (struct mn_object_s* obj, event_t* ev);

void* data; // Pointer to extra data.
int data2; // Extra numerical data.
//int timer;
} mn_object_t;

/**
Expand Down Expand Up @@ -176,7 +212,7 @@ int MNPage_PredefinedFont(mn_page_t* page, mn_page_fontid_t id);
* Text objects.
*/
void MNText_Drawer(mn_object_t* obj, int x, int y);
void MNText_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNText_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);

/**
* Two-state button.
Expand All @@ -188,7 +224,7 @@ typedef struct mndata_button_s {

void MNButton_Drawer(mn_object_t* obj, int x, int y);
int MNButton_CommandResponder(mn_object_t* obj, menucommand_e command);
void MNButton_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNButton_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);

/**
* Edit field.
Expand All @@ -208,7 +244,7 @@ typedef struct mndata_edit_s {
void MNEdit_Drawer(mn_object_t* obj, int x, int y);
int MNEdit_CommandResponder(mn_object_t* obj, menucommand_e command);
int MNEdit_Responder(mn_object_t* obj, const event_t* ev);
void MNEdit_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNEdit_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);
void MNEdit_SetText(mn_object_t* obj, const char* string);

/**
Expand All @@ -232,14 +268,14 @@ typedef struct mndata_list_s {

void MNList_Drawer(mn_object_t* obj, int x, int y);
int MNList_CommandResponder(mn_object_t* obj, menucommand_e command);
void MNList_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNList_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);
int MNList_FindItem(const mn_object_t* obj, int dataValue);

typedef mndata_list_t mndata_listinline_t;

void MNListInline_Drawer(mn_object_t* obj, int x, int y);
int MNListInline_CommandResponder(mn_object_t* obj, menucommand_e command);
void MNListInline_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNListInline_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);

/**
* Color preview box.
Expand All @@ -255,7 +291,7 @@ typedef struct mndata_colorbox_s {

void MNColorBox_Drawer(mn_object_t* obj, int x, int y);
int MNColorBox_CommandResponder(mn_object_t* obj, menucommand_e command);
void MNColorBox_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNColorBox_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);

/**
* Graphical slider.
Expand Down Expand Up @@ -284,8 +320,8 @@ typedef struct mndata_slider_s {
void MNSlider_Drawer(mn_object_t* obj, int x, int y);
void MNSlider_TextualValueDrawer(mn_object_t* obj, int x, int y);
int MNSlider_CommandResponder(mn_object_t* obj, menucommand_e command);
void MNSlider_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNSlider_TextualValueDimensions(const mn_object_t* obj, int* width, int* height);
void MNSlider_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);
void MNSlider_TextualValueDimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);
int MNSlider_ThumbPos(const mn_object_t* obj);

/**
Expand All @@ -312,7 +348,7 @@ typedef struct mndata_bindings_s {
void MNBindings_Drawer(mn_object_t* obj, int x, int y);
int MNBindings_CommandResponder(mn_object_t* obj, menucommand_e command);
int MNBindings_PrivilegedResponder(mn_object_t* obj, event_t* ev);
void MNBindings_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNBindings_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);
void MNBindings_IterateBinds(mn_object_t* obj, const char* bindings, int flags, void* paramaters,
void (*callback)(bindingitertype_t type, int bid, const char* event, boolean isInverse, void* paramaters));

Expand All @@ -332,32 +368,18 @@ typedef struct mndata_mobjpreview_s {
} mndata_mobjpreview_t;

void MNMobjPreview_Drawer(mn_object_t* obj, int x, int y);
void MNMobjPreview_Dimensions(const mn_object_t* obj, int* width, int* height);
void MNMobjPreview_Dimensions(const mn_object_t* obj, mn_page_t* page, int* width, int* height);

// Menu render state:
typedef struct mn_rendstate_s {
float page_alpha;
float text_glitter;
float text_shadow;
float pageAlpha;
float textGlitter;
float textShadow;
float textColors[MENU_COLOR_COUNT][4];
gamefontid_t textFonts[MENU_FONT_COUNT];
} mn_rendstate_t;
extern const mn_rendstate_t* mnRendState;

/**
* Retrieve the current menu page. Note that this is the menu systems'
* state-defined current page and NOT the active page, which may or may
* not be the same.
* @return Current menu page.
*/
mn_page_t* MN_CurrentPage(void);

/**
* Change the current menu page. Note that this is the menu systems'
* state-defined current page and NOT the active page, which may or may
* not be the same.
* @return New current menu page, for caller convenience.
*/
mn_page_t* MN_SetCurrentPage(mn_page_t* page);

/**
* Execute a menu navigation/action command.
*/
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/common/src/am_map.c
Expand Up @@ -1759,7 +1759,7 @@ void M_DrawAutomapMenu(mn_page_t* page, int x, int y)
{
DGL_Enable(DGL_TEXTURE_2D);

DGL_Color4f(cfg.menuTextColors[0][0], cfg.menuTextColors[0][1], cfg.menuTextColors[0][2], mnRendState->page_alpha);
DGL_Color4f(cfg.menuTextColors[0][0], cfg.menuTextColors[0][1], cfg.menuTextColors[0][2], mnRendState->pageAlpha);
M_DrawMenuText3("Automap OPTIONS", SCREENWIDTH/2, y-26, GF_FONTB, DTF_ALIGN_TOP);

/*#if __JHERETIC__ || __JHEXEN__
Expand Down
7 changes: 2 additions & 5 deletions doomsday/plugins/common/src/g_game.c
Expand Up @@ -971,8 +971,8 @@ int G_UIResponder(event_t* ev)
if(!Hu_MenuIsActive())
{
// Any key/button down pops up menu if in demos.
if((G_GetGameAction() == GA_NONE && !singledemo && Get(DD_PLAYBACK)) ||
(G_GetGameState() == GS_INFINE && FI_IsMenuTrigger()))
if((G_GetGameAction() == GA_NONE && !singledemo && Get(DD_PLAYBACK))/* ||
(G_GetGameState() == GS_INFINE && FI_IsMenuTrigger())*/)
{
Hu_MenuCommand(MCMD_OPEN);
return true;
Expand Down Expand Up @@ -1280,9 +1280,6 @@ int G_PrivilegedResponder(event_t* ev)
if(GA_QUIT == G_GetGameAction())
return false;

if(FI_PrivilegedResponder(ev))
return true;

if(Hu_MenuPrivilegedResponder(ev))
return true;

Expand Down

0 comments on commit b6d812e

Please sign in to comment.