diff --git a/doomsday/plugins/common/include/hu_lib.h b/doomsday/plugins/common/include/hu_lib.h index c08396165b..6e6b628d1c 100644 --- a/doomsday/plugins/common/include/hu_lib.h +++ b/doomsday/plugins/common/include/hu_lib.h @@ -144,6 +144,7 @@ struct mn_actioninfo_t */ struct mn_object_t { +public: /// Type of the object. mn_obtype_e _type; @@ -207,91 +208,92 @@ struct mn_object_t mn_page_t *_page; int timer; -}; -mn_obtype_e MNObject_Type(mn_object_t const *ob); +public: + mn_obtype_e type() const; -mn_page_t *MNObject_Page(mn_object_t const *ob); + mn_page_t *page() const; -int MNObject_Flags(mn_object_t const *ob); + int flags() const; -/** - * Retrieve the current geometry of object within the two-dimensioned - * coordinate space of the owning object. - * - * @return Rectangluar region of the parent space. - */ -Rect const *MNObject_Geometry(mn_object_t const *ob); + /** + * Retrieve the current geometry of object within the two-dimensioned + * coordinate space of the owning object. + * + * @return Rectangluar region of the parent space. + */ + Rect const *geometry() const; -/** - * Retrieve the origin of the object within the two-dimensioned coordinate - * space of the owning object. - * @return Origin point within the parent space. - */ -Point2 const *MNObject_Origin(mn_object_t const *ob); + /** + * Retrieve the origin of the object within the two-dimensioned coordinate + * space of the owning object. + * @return Origin point within the parent space. + */ + Point2 const *origin() const; -/** - * Retrieve the boundary dimensions of the object expressed as units of - * the coordinate space of the owning object. - * @return Size of this object in units of the parent's coordinate space. - */ -Size2 const *MNObject_Size(mn_object_t const *ob); + /** + * Retrieve the boundary dimensions of the object expressed as units of + * the coordinate space of the owning object. + * @return Size of this object in units of the parent's coordinate space. + */ + Size2 const *size() const; -/** - * Retreive the current fixed origin coordinates. - * - * @param ob MNObject-derived instance. - * @return Fixed origin. - */ -Point2Raw const *MNObject_FixedOrigin(mn_object_t const *ob); -int MNObject_FixedX(mn_object_t const *ob); -int MNObject_FixedY(mn_object_t const *ob); + /** + * Retreive the current fixed origin coordinates. + * + * @param ob MNObject-derived instance. + * @return Fixed origin. + */ + Point2Raw const *fixedOrigin() const; + int fixedX() const; + int fixedY() const; -/** - * Change the current fixed origin coordinates. - * - * @param ob MNObject-derived instance. - * @param origin New origin coordinates. - * @return Same as @a ob for caller convenience. - */ -mn_object_t *MNObject_SetFixedOrigin(mn_object_t *ob, Point2Raw const *origin); -mn_object_t *MNObject_SetFixedX(mn_object_t *ob, int x); -mn_object_t *MNObject_SetFixedY(mn_object_t *ob, int y); + /** + * Change the current fixed origin coordinates. + * + * @param ob MNObject-derived instance. + * @param origin New origin coordinates. + * @return Same as @a ob for caller convenience. + */ + mn_object_t *setFixedOrigin(Point2Raw const *origin); + mn_object_t *setFixedX(int x); + mn_object_t *setFixedY(int y); -/// @return Flags value post operation for caller convenience. -int MNObject_SetFlags(mn_object_t *ob, flagop_t op, int flags); + /// @return Flags value post operation for caller convenience. + int setFlags(flagop_t op, int flags); -int MNObject_Shortcut(mn_object_t *ob); + int shortcut(); -void MNObject_SetShortcut(mn_object_t *ob, int ddkey); + void setShortcut(int ddkey); -/// @return Index of the font used from the owning/active page. -int MNObject_Font(mn_object_t *ob); + /// @return Index of the font used from the owning/active page. + int font(); -/// @return Index of the color used from the owning/active page. -int MNObject_Color(mn_object_t *ob); + /// @return Index of the color used from the owning/active page. + int color(); -dd_bool MNObject_IsGroupMember(mn_object_t const *ob, int group); + dd_bool isGroupMember(int group) const; -int MNObject_DefaultCommandResponder(mn_object_t *ob, menucommand_e command); + /** + * Lookup the unique ActionInfo associated with the identifier @a id. + * @return Associated info if found else @c NULL. + */ + mn_actioninfo_t const *action(mn_actionid_t action); -/** - * Lookup the unique ActionInfo associated with the identifier @a id. - * @return Associated info if found else @c NULL. - */ -mn_actioninfo_t const *MNObject_Action(mn_object_t *ob, mn_actionid_t action); + /// @return @c true if this object has a registered executeable action + /// associated with the unique identifier @a action. + dd_bool hasAction(mn_actionid_t action); -/// @return @c true if this object has a registered executeable action -/// associated with the unique identifier @a action. -dd_bool MNObject_HasAction(mn_object_t *ob, mn_actionid_t action); + /** + * Execute the action associated with @a id + * @param action Identifier of the action to be executed (if found). + * @param parameters Passed to the action callback. + * @return Return value of the executed action else @c -1 if NOP. + */ + int execAction(mn_actionid_t action, void *parameters); +}; -/** - * Execute the action associated with @a id - * @param action Identifier of the action to be executed (if found). - * @param parameters Passed to the action callback. - * @return Return value of the executed action else @c -1 if NOP. - */ -int MNObject_ExecAction(mn_object_t *ob, mn_actionid_t action, void *parameters); +int MNObject_DefaultCommandResponder(mn_object_t *ob, menucommand_e command); #endif // __cplusplus diff --git a/doomsday/plugins/common/src/hu_lib.cpp b/doomsday/plugins/common/src/hu_lib.cpp index 87b607b213..092eb9220e 100644 --- a/doomsday/plugins/common/src/hu_lib.cpp +++ b/doomsday/plugins/common/src/hu_lib.cpp @@ -770,7 +770,7 @@ static void updatePageObjectGeometries(mn_page_t *page) { mn_object_t *ob = &page->objects()[i]; - if(MNObject_Type(ob) == MN_NONE) continue; + if(ob->type() == MN_NONE) continue; FR_PushAttrib(); if(ob->updateGeometry) @@ -785,7 +785,7 @@ static void updatePageObjectGeometries(mn_page_t *page) /// @return @c true iff this object is drawable (potentially visible). dd_bool MNObject_IsDrawable(mn_object_t *ob) { - return !(MNObject_Type(ob) == MN_NONE || !ob->drawer || (MNObject_Flags(ob) & MNF_HIDDEN)); + return !(ob->type() == MN_NONE || !ob->drawer || (ob->flags() & MNF_HIDDEN)); } int mn_page_t::lineHeight(int *lineOffset) @@ -848,7 +848,7 @@ void mn_page_t::applyPageLayout() // If the object has a fixed position, we will ignore it while doing // dynamic layout. - if(MNObject_Flags(ob) & MNF_POSITION_FIXED) + if(ob->flags() & MNF_POSITION_FIXED) { Rect_SetXY(ob->_geometry, ob->_origin.x, ob->_origin.y); Rect_Unite(geometry, ob->_geometry); @@ -859,7 +859,7 @@ void mn_page_t::applyPageLayout() } // An additional offset requested? - if(MNObject_Flags(ob) & MNF_LAYOUT_OFFSET) + if(ob->flags() & MNF_LAYOUT_OFFSET) { origin.x += ob->_origin.x; origin.y += ob->_origin.y; @@ -871,14 +871,14 @@ void mn_page_t::applyPageLayout() // vertical dividing line, with the label on the left, other object // on the right. // @todo Do not assume pairing, an object should designate it's pair. - if(MNObject_Type(ob) == MN_TEXT && nextOb) + if(ob->type() == MN_TEXT && nextOb) { if(MNObject_IsDrawable(nextOb) && - (MNObject_Type(nextOb) == MN_BUTTON || - MNObject_Type(nextOb) == MN_LISTINLINE || - MNObject_Type(nextOb) == MN_COLORBOX || - MNObject_Type(nextOb) == MN_BINDINGS || - (MNObject_Type(nextOb) == MN_SLIDER && nextOb->drawer == MNSlider_TextualValueDrawer))) + (nextOb->type() == MN_BUTTON || + nextOb->type() == MN_LISTINLINE || + nextOb->type() == MN_COLORBOX || + nextOb->type() == MN_BINDINGS || + (nextOb->type() == MN_SLIDER && nextOb->drawer == MNSlider_TextualValueDrawer))) { int const margin = lineOffset * 2; RectRaw united; @@ -1023,18 +1023,18 @@ void MN_DrawPage(mn_page_t *page, float alpha, dd_bool showFocusCursor) // Determine the origin and dimensions of the cursor. /// @todo Each object should define a focus origin... cursorOrigin.x = -1; - cursorOrigin.y = Point2_Y(MNObject_Origin(focusObj)); + cursorOrigin.y = Point2_Y(focusObj->origin()); /// @kludge /// We cannot yet query the subobjects of the list for these values /// so we must calculate them ourselves, here. - if(MN_LIST == MNObject_Type(focusObj) && (MNObject_Flags(focusObj) & MNF_ACTIVE) && + if(MN_LIST == focusObj->type() && (focusObj->flags() & MNF_ACTIVE) && MNList_SelectionIsVisible(focusObj)) { mndata_list_t const *list = (mndata_list_t *)focusObj->_typedata; FR_PushAttrib(); - FR_SetFont(page->predefinedFont(mn_page_fontid_t(MNObject_Font(focusObj)))); + FR_SetFont(page->predefinedFont(mn_page_fontid_t(focusObj->font()))); focusObjHeight = FR_CharHeight('A') * (1+MNDATA_LIST_LEADING); cursorOrigin.y += (list->selection - list->first) * focusObjHeight; FR_PopAttrib(); @@ -1077,10 +1077,10 @@ void MN_DrawPage(mn_page_t *page, float alpha, dd_bool showFocusCursor) mn_object_t *ob = &page->objects()[i]; RectRaw geometry; - if(MNObject_Type(ob) == MN_NONE || !ob->drawer) continue; - if(MNObject_Flags(ob) & MNF_HIDDEN) continue; + if(ob->type() == MN_NONE || !ob->drawer) continue; + if(ob->flags() & MNF_HIDDEN) continue; - Rect_Raw(MNObject_Geometry(ob), &geometry); + Rect_Raw(ob->geometry(), &geometry); FR_PushAttrib(); MN_DrawObject(ob, &geometry.origin); @@ -1149,7 +1149,7 @@ mn_page_t::~mn_page_t() Str_Free(&title); if(geometry) Rect_Delete(geometry); - for(mn_object_t *ob = _objects; MNObject_Type(ob) != MN_NONE; ob++) + for(mn_object_t *ob = _objects; ob->type() != MN_NONE; ob++) { if(ob->_geometry) Rect_Delete(ob->_geometry); } @@ -1196,7 +1196,7 @@ void mn_page_t::clearFocusObject() if(focus >= 0) { mn_object_t *ob = &_objects[focus]; - if(MNObject_Flags(ob) & MNF_ACTIVE) + if(ob->flags() & MNF_ACTIVE) { return; } @@ -1205,7 +1205,7 @@ void mn_page_t::clearFocusObject() mn_object_t *ob = _objects; for(int i = 0; i < _objectsCount; ++i, ob++) { - MNObject_SetFlags(ob, FO_CLEAR, MNF_FOCUS); + ob->setFlags(FO_CLEAR, MNF_FOCUS); } refocus(); } @@ -1213,7 +1213,7 @@ void mn_page_t::clearFocusObject() int mn_page_t::cursorSize() { mn_object_t *focusOb = focusObject(); - int focusObHeight = focusOb? Size2_Height(MNObject_Size(focusOb)) : 0; + int focusObHeight = focusOb? Size2_Height(focusOb->size()) : 0; // Ensure the cursor is at least as tall as the effective line height for // the page. This is necessary because some mods replace the menu button @@ -1226,9 +1226,9 @@ int mn_page_t::cursorSize() mn_object_t *mn_page_t::findObject(int group, int flags) { mn_object_t *ob = _objects; - for(; MNObject_Type(ob) != MN_NONE; ob++) + for(; ob->type() != MN_NONE; ob++) { - if(MNObject_IsGroupMember(ob, group) && (MNObject_Flags(ob) & flags) == flags) + if(ob->isGroupMember(group) && (ob->flags() & flags) == flags) return ob; } return 0; // Not found. @@ -1257,11 +1257,11 @@ void mn_page_t::giveChildFocus(mn_object_t *ob, dd_bool allowRefocus) if(ob != _objects + focus) { mn_object_t *oldFocusOb = _objects + focus; - if(MNObject_HasAction(oldFocusOb, MNA_FOCUSOUT)) + if(oldFocusOb->hasAction(MNA_FOCUSOUT)) { - MNObject_ExecAction(oldFocusOb, MNA_FOCUSOUT, NULL); + oldFocusOb->execAction(MNA_FOCUSOUT, NULL); } - MNObject_SetFlags(oldFocusOb, FO_CLEAR, MNF_FOCUS); + oldFocusOb->setFlags(FO_CLEAR, MNF_FOCUS); } else if(!allowRefocus) { @@ -1270,10 +1270,10 @@ void mn_page_t::giveChildFocus(mn_object_t *ob, dd_bool allowRefocus) } focus = ob - _objects; - MNObject_SetFlags(ob, FO_SET, MNF_FOCUS); - if(MNObject_HasAction(ob, MNA_FOCUS)) + ob->setFlags(FO_SET, MNF_FOCUS); + if(ob->hasAction(MNA_FOCUS)) { - MNObject_ExecAction(ob, MNA_FOCUS, NULL); + ob->execAction(MNA_FOCUS, NULL); } } @@ -1301,7 +1301,7 @@ void mn_page_t::refocus() for(i = 0; i < _objectsCount; ++i) { mn_object_t *ob = &_objects[i]; - if((MNObject_Flags(ob) & MNF_DEFAULT) && !(MNObject_Flags(ob) & (MNF_DISABLED|MNF_NO_FOCUS))) + if((ob->flags() & MNF_DEFAULT) && !(ob->flags() & (MNF_DISABLED|MNF_NO_FOCUS))) { giveFocus = i; } @@ -1312,7 +1312,7 @@ void mn_page_t::refocus() for(i = 0; i < _objectsCount; ++i) { mn_object_t *ob = &_objects[i]; - if(!(MNObject_Flags(ob) & (MNF_DISABLED|MNF_NO_FOCUS))) + if(!(ob->flags() & (MNF_DISABLED|MNF_NO_FOCUS))) { giveFocus = i; break; @@ -1347,14 +1347,14 @@ void mn_page_t::initialize() // Reset object timer. ob->timer = 0; - switch(MNObject_Type(ob)) + switch(ob->type()) { case MN_BUTTON: { mndata_button_t *btn = (mndata_button_t *)ob->_typedata; if(btn->staydownMode) { dd_bool const activate = (*(char *) ob->data1); - MNObject_SetFlags(ob, (activate? FO_SET:FO_CLEAR), MNF_ACTIVE); + ob->setFlags((activate? FO_SET:FO_CLEAR), MNF_ACTIVE); } break; } @@ -1390,7 +1390,7 @@ void mn_page_t::initObjects() { _objectsCount = 0; - for(mn_object_t *ob = _objects; MNObject_Type(ob) != MN_NONE; ob++) + for(mn_object_t *ob = _objects; ob->type() != MN_NONE; ob++) { _objectsCount += 1; @@ -1398,20 +1398,20 @@ void mn_page_t::initObjects() ob->_geometry = Rect_New(); ob->timer = 0; - MNObject_SetFlags(ob, FO_CLEAR, MNF_FOCUS); + ob->setFlags(FO_CLEAR, MNF_FOCUS); if(0 != ob->_shortcut) { int shortcut = ob->_shortcut; ob->_shortcut = 0; // Clear invalid defaults. - MNObject_SetShortcut(ob, shortcut); + ob->setShortcut(shortcut); } - switch(MNObject_Type(ob)) + switch(ob->type()) { case MN_TEXT: { mndata_text_t *txt = (mndata_text_t *)ob->_typedata; - MNObject_SetFlags(ob, FO_SET, MNF_NO_FOCUS); + ob->setFlags(FO_SET, MNF_NO_FOCUS); if(txt->text && (PTR2INT(txt->text) > 0 && PTR2INT(txt->text) < NUMTEXT)) { @@ -1420,14 +1420,14 @@ void mn_page_t::initObjects() break; } case MN_BUTTON: { - /*mn_actioninfo_t const *action = MNObject_Action(ob, MNA_MODIFIED);*/ + /*mn_actioninfo_t const *action = ob->action(MNA_MODIFIED);*/ mndata_button_t *btn = (mndata_button_t *)ob->_typedata; if(btn->text && (PTR2INT(btn->text) > 0 && PTR2INT(btn->text) < NUMTEXT)) { btn->text = GET_TXT(PTR2INT(btn->text)); /// @todo Should not be done here. - MNObject_SetShortcut(ob, btn->text[0]); + ob->setShortcut(btn->text[0]); } break; } @@ -1466,7 +1466,7 @@ void mn_page_t::initObjects() break; } case MN_MOBJPREVIEW: - MNObject_SetFlags(ob, FO_SET, MNF_NO_FOCUS); + ob->setFlags(FO_SET, MNF_NO_FOCUS); break; default: break; @@ -1477,17 +1477,17 @@ void mn_page_t::initObjects() /// Main task is to update objects linked to cvars. void mn_page_t::updateObjects() { - for(mn_object_t *ob = _objects; MNObject_Type(ob) != MN_NONE; ob++) + for(mn_object_t *ob = _objects; ob->type() != MN_NONE; ob++) { - switch(MNObject_Type(ob)) + switch(ob->type()) { case MN_TEXT: case MN_MOBJPREVIEW: - MNObject_SetFlags(ob, FO_SET, MNF_NO_FOCUS); + ob->setFlags(FO_SET, MNF_NO_FOCUS); break; case MN_BUTTON: { - mn_actioninfo_t const *action = MNObject_Action(ob, MNA_MODIFIED); + mn_actioninfo_t const *action = ob->action(MNA_MODIFIED); mndata_button_t *btn = (mndata_button_t *)ob->_typedata; if(action && action->callback == Hu_MenuCvarButton) @@ -1521,7 +1521,7 @@ void mn_page_t::updateObjects() case MN_LIST: case MN_LISTINLINE: { - mn_actioninfo_t const *action = MNObject_Action(ob, MNA_MODIFIED); + mn_actioninfo_t const *action = ob->action(MNA_MODIFIED); mndata_list_t *list = (mndata_list_t *) ob->_typedata; if(action && action->callback == Hu_MenuCvarList) @@ -1531,7 +1531,7 @@ void mn_page_t::updateObjects() break; } case MN_EDIT: { - mn_actioninfo_t const *action = MNObject_Action(ob, MNA_MODIFIED); + mn_actioninfo_t const *action = ob->action(MNA_MODIFIED); mndata_edit_t *edit = (mndata_edit_t *) ob->_typedata; if(action && action->callback == Hu_MenuCvarEdit) @@ -1541,7 +1541,7 @@ void mn_page_t::updateObjects() break; } case MN_SLIDER: { - mn_actioninfo_t const *action = MNObject_Action(ob, MNA_MODIFIED); + mn_actioninfo_t const *action = ob->action(MNA_MODIFIED); mndata_slider_t *sldr = (mndata_slider_t *) ob->_typedata; if(action && action->callback == Hu_MenuCvarSlider) { @@ -1556,7 +1556,7 @@ void mn_page_t::updateObjects() case MN_COLORBOX: { mndata_colorbox_t *cbox = (mndata_colorbox_t *) ob->_typedata; - mn_actioninfo_t const *action = MNObject_Action(ob, MNA_MODIFIED); + mn_actioninfo_t const *action = ob->action(MNA_MODIFIED); if(action && action->callback == Hu_MenuCvarColorBox) { @@ -1580,7 +1580,7 @@ void mn_page_t::tick() mn_object_t *ob = _objects; for(int i = 0; i < _objectsCount; ++i, ob++) { - if((MNObject_Flags(ob) & MNF_PAUSED) || (MNObject_Flags(ob) & MNF_HIDDEN)) + if((ob->flags() & MNF_PAUSED) || (ob->flags() & MNF_HIDDEN)) continue; if(ob->ticker) @@ -1622,131 +1622,112 @@ int mn_page_t::timer() return _timer; } -mn_obtype_e MNObject_Type(const mn_object_t *ob) +mn_obtype_e mn_object_t::type() const { - DENG2_ASSERT(ob); - return ob->_type; + return _type; } -mn_page_t *MNObject_Page(const mn_object_t *ob) +mn_page_t *mn_object_t::page() const { - DENG2_ASSERT(ob); - return ob->_page; + return _page; } -int MNObject_Flags(const mn_object_t *ob) +int mn_object_t::flags() const { - DENG2_ASSERT(ob); - return ob->_flags; + return _flags; } -const Rect* MNObject_Geometry(const mn_object_t *ob) +Rect const *mn_object_t::geometry() const { - DENG2_ASSERT(ob); - return ob->_geometry; + return _geometry; } -const Point2* MNObject_Origin(const mn_object_t *ob) +Point2 const *mn_object_t::origin() const { - DENG2_ASSERT(ob); - return Rect_Origin(ob->_geometry); + return Rect_Origin(_geometry); } -const Size2* MNObject_Size(const mn_object_t *ob) +Size2 const *mn_object_t::size() const { - DENG2_ASSERT(ob); - return Rect_Size(ob->_geometry); + return Rect_Size(_geometry); } -const Point2Raw* MNObject_FixedOrigin(const mn_object_t *ob) +Point2Raw const *mn_object_t::fixedOrigin() const { - DENG2_ASSERT(ob); - return &ob->_origin; + return &_origin; } -int MNObject_FixedX(const mn_object_t *ob) +int mn_object_t::fixedX() const { - DENG2_ASSERT(ob); - return ob->_origin.x; + return _origin.x; } -int MNObject_FixedY(const mn_object_t *ob) +int mn_object_t::fixedY() const { - DENG2_ASSERT(ob); - return ob->_origin.y; + return _origin.y; } -mn_object_t *MNObject_SetFixedOrigin(mn_object_t *ob, const Point2Raw* origin) +mn_object_t *mn_object_t::setFixedOrigin(Point2Raw const *newOrigin) { - DENG2_ASSERT(ob); - if(origin) + if(newOrigin) { - ob->_origin.x = origin->x; - ob->_origin.y = origin->y; + _origin.x = newOrigin->x; + _origin.y = newOrigin->y; } - return ob; + return this; } -mn_object_t *MNObject_SetFixedX(mn_object_t *ob, int x) +mn_object_t *mn_object_t::setFixedX(int newX) { - DENG2_ASSERT(ob); - ob->_origin.x = x; - return ob; + _origin.x = newX; + return this; } -mn_object_t *MNObject_SetFixedY(mn_object_t *ob, int y) +mn_object_t *mn_object_t::setFixedY(int newY) { - DENG2_ASSERT(ob); - ob->_origin.y = y; - return ob; + _origin.y = newY; + return this; } -int MNObject_SetFlags(mn_object_t *ob, flagop_t op, int flags) +int mn_object_t::setFlags(flagop_t op, int flagsToChange) { - DENG2_ASSERT(ob != 0); switch(op) { - case FO_CLEAR: ob->_flags &= ~flags; break; - case FO_SET: ob->_flags |= flags; break; - case FO_TOGGLE: ob->_flags ^= flags; break; - default: - Con_Error("MNObject::SetFlags: Unknown op %i\n", op); - exit(1); // Unreachable. + case FO_CLEAR: _flags &= ~flagsToChange; break; + case FO_SET: _flags |= flagsToChange; break; + case FO_TOGGLE: _flags ^= flagsToChange; break; + + default: DENG2_ASSERT(!"MNObject::SetFlags: Unknown op."); } - return ob->_flags; + return _flags; } -int MNObject_Shortcut(mn_object_t *ob) +int mn_object_t::shortcut() { - DENG2_ASSERT(ob); - return ob->_shortcut; + return _shortcut; } -void MNObject_SetShortcut(mn_object_t *ob, int ddkey) +void mn_object_t::setShortcut(int ddkey) { - DENG2_ASSERT(ob); if(isalnum(ddkey)) { - ob->_shortcut = tolower(ddkey); + _shortcut = tolower(ddkey); } } -int MNObject_Font(mn_object_t *ob) +int mn_object_t::font() { - DENG2_ASSERT(ob); - return ob->_pageFontIdx; + return _pageFontIdx; } -int MNObject_Color(mn_object_t *ob) +int mn_object_t::color() { - DENG2_ASSERT(ob); - return ob->_pageColorIdx; + return _pageColorIdx; } -dd_bool MNObject_IsGroupMember(const mn_object_t *ob, int group) +dd_bool mn_object_t::isGroupMember(int group) const { - DENG2_ASSERT(ob); - return (ob->_group == group); + return (_group == group); } int MNObject_DefaultCommandResponder(mn_object_t *ob, menucommand_e cmd) @@ -1758,53 +1739,51 @@ int MNObject_DefaultCommandResponder(mn_object_t *ob, menucommand_e cmd) if(!(ob->_flags & MNF_ACTIVE)) { ob->_flags |= MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVE)) + if(ob->hasAction(MNA_ACTIVE)) { - MNObject_ExecAction(ob, MNA_ACTIVE, NULL); + ob->execAction(MNA_ACTIVE, NULL); } } ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVEOUT)) + if(ob->hasAction(MNA_ACTIVEOUT)) { - MNObject_ExecAction(ob, MNA_ACTIVEOUT, NULL); + ob->execAction(MNA_ACTIVEOUT, NULL); } return true; } return false; // Not eaten. } -static mn_actioninfo_t* MNObject_FindActionInfoForId(mn_object_t *ob, mn_actionid_t id) +static mn_actioninfo_t *MNObject_FindActionInfoForId(mn_object_t *ob, mn_actionid_t id) { - DENG2_ASSERT(ob); + DENG2_ASSERT(ob != 0); if(VALID_MNACTION(id)) { return &ob->actions[id]; } - return NULL; // Not found. + return 0; // Not found. } -const mn_actioninfo_t* MNObject_Action(mn_object_t *ob, mn_actionid_t id) +mn_actioninfo_t const *mn_object_t::action(mn_actionid_t id) { - return MNObject_FindActionInfoForId(ob, id); + return MNObject_FindActionInfoForId(this, id); } -dd_bool MNObject_HasAction(mn_object_t *ob, mn_actionid_t id) +dd_bool mn_object_t::hasAction(mn_actionid_t id) { - mn_actioninfo_t* info = MNObject_FindActionInfoForId(ob, id); + mn_actioninfo_t *info = MNObject_FindActionInfoForId(this, id); return (info && MNActionInfo_IsActionExecuteable(info)); } -int MNObject_ExecAction(mn_object_t *ob, mn_actionid_t id, void* paramaters) +int mn_object_t::execAction(mn_actionid_t id, void *parameters) { - mn_actioninfo_t* info = MNObject_FindActionInfoForId(ob, id); + mn_actioninfo_t *info = MNObject_FindActionInfoForId(this, id); if(info && MNActionInfo_IsActionExecuteable(info)) { - return info->callback(ob, id, paramaters); + return info->callback(this, id, parameters); } -#if _DEBUG - Con_Error("MNObject::ExecAction: Attempt to execute non-existent action #%i on object %p.", (int) id, ob); -#endif + DENG2_ASSERT(!"MNObject::ExecAction: Attempt to execute non-existent action."); /// @todo Need an error handling mechanic. return -1; // NOP } @@ -2162,9 +2141,9 @@ int MNEdit_CommandResponder(mn_object_t *ob, menucommand_e cmd) ob->timer = 0; // Store a copy of the present text value so we can restore it. Str_Copy(&edit->oldtext, &edit->text); - if(MNObject_HasAction(ob, MNA_ACTIVE)) + if(ob->hasAction(MNA_ACTIVE)) { - MNObject_ExecAction(ob, MNA_ACTIVE, NULL); + ob->execAction(MNA_ACTIVE, NULL); } } else @@ -2172,9 +2151,9 @@ int MNEdit_CommandResponder(mn_object_t *ob, menucommand_e cmd) S_LocalSound(SFX_MENU_ACCEPT, NULL); Str_Copy(&edit->oldtext, &edit->text); ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVEOUT)) + if(ob->hasAction(MNA_ACTIVEOUT)) { - MNObject_ExecAction(ob, MNA_ACTIVEOUT, NULL); + ob->execAction(MNA_ACTIVEOUT, NULL); } } return true; @@ -2187,9 +2166,9 @@ int MNEdit_CommandResponder(mn_object_t *ob, menucommand_e cmd) case MCMD_NAV_OUT: Str_Copy(&edit->text, &edit->oldtext); ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_CLOSE)) + if(ob->hasAction(MNA_CLOSE)) { - MNObject_ExecAction(ob, MNA_CLOSE, NULL); + ob->execAction(MNA_CLOSE, NULL); } return true; @@ -2254,9 +2233,9 @@ void MNEdit_SetText(mn_object_t *ob, int flags, const char* string) { Str_Copy(&edit->oldtext, &edit->text); } - if(!(flags & MNEDIT_STF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNEDIT_STF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } @@ -2286,9 +2265,9 @@ int MNEdit_Responder(mn_object_t *ob, event_t* ev) if(!Str_IsEmpty(&edit->text)) { Str_Truncate(&edit->text, Str_Length(&edit->text)-1); - if(MNObject_HasAction(ob, MNA_MODIFIED)) + if(ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } return true; @@ -2307,9 +2286,9 @@ int MNEdit_Responder(mn_object_t *ob, event_t* ev) if(!edit->maxLength || (unsigned)Str_Length(&edit->text) < edit->maxLength) { Str_AppendChar(&edit->text, ch); - if(MNObject_HasAction(ob, MNA_MODIFIED)) + if(ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } return true; @@ -2439,9 +2418,9 @@ int MNList_CommandResponder(mn_object_t *ob, menucommand_e cmd) if(list->selection != oldSelection) { S_LocalSound(cmd == MCMD_NAV_DOWN? SFX_MENU_NAV_DOWN : SFX_MENU_NAV_UP, NULL); - if(MNObject_HasAction(ob, MNA_MODIFIED)) + if(ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } return true; @@ -2453,9 +2432,9 @@ int MNList_CommandResponder(mn_object_t *ob, menucommand_e cmd) { S_LocalSound(SFX_MENU_CANCEL, NULL); ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_CLOSE)) + if(ob->hasAction(MNA_CLOSE)) { - MNObject_ExecAction(ob, MNA_CLOSE, NULL); + ob->execAction(MNA_CLOSE, NULL); } return true; } @@ -2466,18 +2445,18 @@ int MNList_CommandResponder(mn_object_t *ob, menucommand_e cmd) { S_LocalSound(SFX_MENU_ACCEPT, NULL); ob->_flags |= MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVE)) + if(ob->hasAction(MNA_ACTIVE)) { - MNObject_ExecAction(ob, MNA_ACTIVE, NULL); + ob->execAction(MNA_ACTIVE, NULL); } } else { S_LocalSound(SFX_MENU_ACCEPT, NULL); ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVEOUT)) + if(ob->hasAction(MNA_ACTIVEOUT)) { - MNObject_ExecAction(ob, MNA_ACTIVEOUT, NULL); + ob->execAction(MNA_ACTIVEOUT, NULL); } } return true; @@ -2546,9 +2525,9 @@ dd_bool MNList_SelectItem(mn_object_t *ob, int flags, int itemIndex) list->selection = itemIndex; if(list->selection == oldSelection) return false; - if(!(flags & MNLIST_SIF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNLIST_SIF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } return true; } @@ -2638,9 +2617,9 @@ int MNListInline_CommandResponder(mn_object_t *ob, menucommand_e cmd) if(oldSelection != list->selection) { S_LocalSound(SFX_MENU_SLIDER_MOVE, NULL); - if(MNObject_HasAction(ob, MNA_MODIFIED)) + if(ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } return true; @@ -2780,9 +2759,9 @@ int MNButton_CommandResponder(mn_object_t *ob, menucommand_e cmd) S_LocalSound(SFX_MENU_CYCLE, NULL); ob->_flags |= MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVE)) + if(ob->hasAction(MNA_ACTIVE)) { - MNObject_ExecAction(ob, MNA_ACTIVE, NULL); + ob->execAction(MNA_ACTIVE, NULL); } } @@ -2791,9 +2770,9 @@ int MNButton_CommandResponder(mn_object_t *ob, menucommand_e cmd) // We are not going to receive an "up event" so action that now. S_LocalSound(SFX_MENU_ACCEPT, NULL); ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVEOUT)) + if(ob->hasAction(MNA_ACTIVEOUT)) { - MNObject_ExecAction(ob, MNA_ACTIVEOUT, NULL); + ob->execAction(MNA_ACTIVEOUT, NULL); } } else @@ -2807,18 +2786,18 @@ int MNButton_CommandResponder(mn_object_t *ob, menucommand_e cmd) void* data = ob->data1; *((char*)data) = (ob->_flags & MNF_ACTIVE) != 0; - if(MNObject_HasAction(ob, MNA_MODIFIED)) + if(ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } if(!justActivated && !(ob->_flags & MNF_ACTIVE)) { S_LocalSound(SFX_MENU_CYCLE, NULL); - if(MNObject_HasAction(ob, MNA_ACTIVEOUT)) + if(ob->hasAction(MNA_ACTIVEOUT)) { - MNObject_ExecAction(ob, MNA_ACTIVEOUT, NULL); + ob->execAction(MNA_ACTIVEOUT, NULL); } } } @@ -3036,18 +3015,18 @@ int MNColorBox_CommandResponder(mn_object_t *ob, menucommand_e cmd) { S_LocalSound(SFX_MENU_CYCLE, NULL); ob->_flags |= MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVE)) + if(ob->hasAction(MNA_ACTIVE)) { - MNObject_ExecAction(ob, MNA_ACTIVE, NULL); + ob->execAction(MNA_ACTIVE, NULL); } } else { S_LocalSound(SFX_MENU_CYCLE, NULL); ob->_flags &= ~MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVEOUT)) + if(ob->hasAction(MNA_ACTIVEOUT)) { - MNObject_ExecAction(ob, MNA_ACTIVEOUT, NULL); + ob->execAction(MNA_ACTIVEOUT, NULL); } } return true; @@ -3174,9 +3153,9 @@ dd_bool MNColorBox_SetRedf(mn_object_t *ob, int flags, float red) cbox->r = red; if(cbox->r != oldRed) { - if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } return true; } @@ -3192,9 +3171,9 @@ dd_bool MNColorBox_SetGreenf(mn_object_t *ob, int flags, float green) cbox->g = green; if(cbox->g != oldGreen) { - if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } return true; } @@ -3210,9 +3189,9 @@ dd_bool MNColorBox_SetBluef(mn_object_t *ob, int flags, float blue) cbox->b = blue; if(cbox->b != oldBlue) { - if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } return true; } @@ -3230,9 +3209,9 @@ dd_bool MNColorBox_SetAlphaf(mn_object_t *ob, int flags, float alpha) cbox->a = alpha; if(cbox->a != oldAlpha) { - if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } return true; } @@ -3254,9 +3233,9 @@ dd_bool MNColorBox_SetColor4f(mn_object_t *ob, int flags, float red, float green if(0 == setComps) return false; - if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && MNObject_HasAction(ob, MNA_MODIFIED)) + if(!(flags & MNCOLORBOX_SCF_NO_ACTION) && ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } return true; } @@ -3443,9 +3422,9 @@ int MNSlider_CommandResponder(mn_object_t *ob, menucommand_e cmd) if(oldvalue != sldr->value) { S_LocalSound(SFX_MENU_SLIDER_MOVE, NULL); - if(MNObject_HasAction(ob, MNA_MODIFIED)) + if(ob->hasAction(MNA_MODIFIED)) { - MNObject_ExecAction(ob, MNA_MODIFIED, NULL); + ob->execAction(MNA_MODIFIED, NULL); } } return true; diff --git a/doomsday/plugins/common/src/hu_menu.cpp b/doomsday/plugins/common/src/hu_menu.cpp index 8f4ab270ee..34d475a1bf 100644 --- a/doomsday/plugins/common/src/hu_menu.cpp +++ b/doomsday/plugins/common/src/hu_menu.cpp @@ -659,8 +659,8 @@ mn_page_t *Hu_MenuFindPageByName(char const *name) static dd_bool Hu_MenuHasCursorRotation(mn_object_t *ob) { DENG2_ASSERT(ob != 0); - return (!(MNObject_Flags(ob) & MNF_DISABLED) && - (MNObject_Type(ob) == MN_LISTINLINE || MNObject_Type(ob) == MN_SLIDER)); + return (!(ob->flags() & MNF_DISABLED) && + (ob->type() == MN_LISTINLINE || ob->type() == MN_SLIDER)); } /// To be called to re-evaluate the state of the cursor (e.g., when focus changes). @@ -4417,10 +4417,10 @@ void Hu_MenuInit() if(gameModeBits & GM_ANY_DOOM2) { mn_object_t *ob = MN_MustFindObjectOnPage(Hu_MenuFindPageByName("Main"), 0, MNF_ID0); // Read This! - MNObject_SetFlags(ob, FO_SET, MNF_DISABLED|MNF_HIDDEN|MNF_NO_FOCUS); + ob->setFlags(FO_SET, MNF_DISABLED|MNF_HIDDEN|MNF_NO_FOCUS); ob = MN_MustFindObjectOnPage(Hu_MenuFindPageByName("Main"), 0, MNF_ID1); // Quit Game - MNObject_SetFixedY(ob, MNObject_FixedY(ob) - FIXED_LINE_HEIGHT); + ob->setFixedY(ob->fixedY() - FIXED_LINE_HEIGHT); } #endif @@ -4677,9 +4677,9 @@ void Hu_MenuDrawer() // First determine whether the focus cursor should be visible. mn_object_t *focusOb = Hu_MenuActivePage()->focusObject(); dd_bool showFocusCursor = true; - if(focusOb && (MNObject_Flags(focusOb) & MNF_ACTIVE)) + if(focusOb && (focusOb->flags() & MNF_ACTIVE)) { - if(MNObject_Type(focusOb) == MN_COLORBOX || MNObject_Type(focusOb) == MN_BINDINGS) + if(focusOb->type() == MN_COLORBOX || focusOb->type() == MN_BINDINGS) { showFocusCursor = false; } @@ -4700,9 +4700,9 @@ void Hu_MenuDrawer() GL_EndBorderedProjection(&bp); // Drawing any overlays? - if(focusOb && (MNObject_Flags(focusOb) & MNF_ACTIVE)) + if(focusOb && (focusOb->flags() & MNF_ACTIVE)) { - switch(MNObject_Type(focusOb)) + switch(focusOb->type()) { case MN_COLORBOX: case MN_BINDINGS: @@ -4710,7 +4710,7 @@ void Hu_MenuDrawer() GL_BeginBorderedProjection(&bp); beginOverlayDraw(); - if(MNObject_Type(focusOb) == MN_BINDINGS) + if(focusOb->type() == MN_BINDINGS) { Hu_MenuControlGrabDrawer(MNBindings_ControlName(focusOb), 1); } @@ -4816,12 +4816,12 @@ static void initAllObjectsOnAllPages() int Hu_MenuColorWidgetCmdResponder(mn_page_t *page, menucommand_e cmd) { - DENG2_ASSERT(page); + DENG2_ASSERT(page != 0); switch(cmd) { case MCMD_NAV_OUT: { - mn_object_t *obj = (mn_object_t*)page->userData; - MNObject_SetFlags(obj, FO_CLEAR, MNF_ACTIVE); + mn_object_t *ob = (mn_object_t *)page->userData; + ob->setFlags(FO_CLEAR, MNF_ACTIVE); S_LocalSound(SFX_MENU_CANCEL, NULL); colorWidgetActive = false; @@ -4829,27 +4829,28 @@ int Hu_MenuColorWidgetCmdResponder(mn_page_t *page, menucommand_e cmd) cursorAngle = 0; // Stop cursor rotation animation dead (don't rewind). Hu_MenuUpdateCursorState(); /// kludge end. - return true; - } + return true; } + case MCMD_NAV_PAGEUP: case MCMD_NAV_PAGEDOWN: return true; // Eat these. + case MCMD_SELECT: { - mn_object_t *obj = (mn_object_t*)page->userData; - MNObject_SetFlags(obj, FO_CLEAR, MNF_ACTIVE); + mn_object_t *ob = (mn_object_t *)page->userData; + ob->setFlags(FO_CLEAR, MNF_ACTIVE); S_LocalSound(SFX_MENU_ACCEPT, NULL); colorWidgetActive = false; - MNColorBox_CopyColor(obj, 0, MN_MustFindObjectOnPage(page, 0, MNF_ID0)); + MNColorBox_CopyColor(ob, 0, MN_MustFindObjectOnPage(page, 0, MNF_ID0)); /// @kludge We should re-focus on the object instead. cursorAngle = 0; // Stop cursor rotation animation dead (don't rewind). Hu_MenuUpdateCursorState(); /// kludge end. - return true; - } - default: - break; + return true; } + + default: break; } + return false; } @@ -4865,10 +4866,9 @@ static void fallbackCommandResponder(mn_page_t *page, menucommand_e cmd) break; case MCMD_NAV_UP: - case MCMD_NAV_DOWN: { - mn_object_t *obj = page->focusObject(); + case MCMD_NAV_DOWN: // An object on this page must have focus in order to navigate. - if(obj) + if(page->focusObject()) { int i = 0, giveFocus = page->focus; do @@ -4878,7 +4878,7 @@ static void fallbackCommandResponder(mn_page_t *page, menucommand_e cmd) giveFocus = page->objectsCount() - 1; else if(giveFocus >= page->objectsCount()) giveFocus = 0; - } while(++i < page->objectsCount() && (MNObject_Flags(&page->objects()[giveFocus]) & (MNF_DISABLED | MNF_NO_FOCUS | MNF_HIDDEN))); + } while(++i < page->objectsCount() && (page->objects()[giveFocus].flags() & (MNF_DISABLED | MNF_NO_FOCUS | MNF_HIDDEN))); if(giveFocus != page->focus) { @@ -4887,7 +4887,7 @@ static void fallbackCommandResponder(mn_page_t *page, menucommand_e cmd) } } break; - } + case MCMD_NAV_OUT: if(!page->previous) { @@ -4914,39 +4914,33 @@ static menucommand_e translateCommand(menucommand_e cmd) // "active" widget - interpret the command instead as "navigate out". if(menuActive && (cmd == MCMD_CLOSE || cmd == MCMD_CLOSEFAST)) { - mn_object_t *obj = Hu_MenuActivePage()->focusObject(); - if(obj) + if(mn_object_t *ob = Hu_MenuActivePage()->focusObject()) { - switch(MNObject_Type(obj)) + switch(ob->type()) { case MN_EDIT: case MN_LIST: case MN_COLORBOX: - if(MNObject_Flags(obj) & MNF_ACTIVE) + if(ob->flags() & MNF_ACTIVE) { cmd = MCMD_NAV_OUT; } break; - default: - break; + + default: break; } } } + return cmd; } void Hu_MenuCommand(menucommand_e cmd) { - mn_page_t *page; - mn_object_t *ob; - cmd = translateCommand(cmd); // Determine the page which will respond to this command. - if(colorWidgetActive) - page = Hu_MenuFindPageByName("ColorWidget"); - else - page = Hu_MenuActivePage(); + mn_page_t *page = colorWidgetActive? Hu_MenuFindPageByName("ColorWidget") : Hu_MenuActivePage(); if(cmd == MCMD_CLOSE || cmd == MCMD_CLOSEFAST) { @@ -4959,7 +4953,8 @@ void Hu_MenuCommand(menucommand_e cmd) Hu_FogEffectSetAlphaTarget(0); if(cmd == MCMD_CLOSEFAST) - { // Hide the menu instantly. + { + // Hide the menu instantly. mnAlpha = mnTargetAlpha = 0; } else @@ -4968,7 +4963,9 @@ void Hu_MenuCommand(menucommand_e cmd) } if(cmd != MCMD_CLOSEFAST) + { S_LocalSound(SFX_MENU_CLOSE, NULL); + } menuActive = false; @@ -4989,8 +4986,7 @@ void Hu_MenuCommand(menucommand_e cmd) if(MCMD_OPEN == cmd) { // If anyone is currently chatting; the menu cannot be opened. - int i; - for(i = 0; i < MAXPLAYERS; ++i) + for(int i = 0; i < MAXPLAYERS; ++i) { if(ST_ChatIsActive(i)) return; @@ -5016,7 +5012,7 @@ void Hu_MenuCommand(menucommand_e cmd) } // Try the current focus object. - ob = page->focusObject(); + mn_object_t *ob = page->focusObject(); if(ob && ob->cmdResponder) { if(ob->cmdResponder(ob, cmd)) @@ -5033,32 +5029,32 @@ void Hu_MenuCommand(menucommand_e cmd) fallbackCommandResponder(page, cmd); } -int Hu_MenuPrivilegedResponder(event_t* ev) +int Hu_MenuPrivilegedResponder(event_t *ev) { if(Hu_MenuIsActive()) { - mn_object_t *obj = Hu_MenuActivePage()->focusObject(); - if(obj && !(MNObject_Flags(obj) & MNF_DISABLED)) + mn_object_t *ob = Hu_MenuActivePage()->focusObject(); + if(ob && !(ob->flags() & MNF_DISABLED)) { - if(obj->privilegedResponder) + if(ob->privilegedResponder) { - return obj->privilegedResponder(obj, ev); + return ob->privilegedResponder(ob, ev); } } } return false; } -int Hu_MenuResponder(event_t* ev) +int Hu_MenuResponder(event_t *ev) { if(Hu_MenuIsActive()) { - mn_object_t *obj = Hu_MenuActivePage()->focusObject(); - if(obj && !(MNObject_Flags(obj) & MNF_DISABLED)) + mn_object_t *ob = Hu_MenuActivePage()->focusObject(); + if(ob && !(ob->flags() & MNF_DISABLED)) { - if(obj->responder) + if(ob->responder) { - return obj->responder(obj, ev); + return ob->responder(ob, ev); } } } @@ -5077,13 +5073,13 @@ int Hu_MenuFallbackResponder(event_t *ev) { for(int i = 0; i < page->objectsCount(); ++i) { - mn_object_t *obj = &page->objects()[i]; - if(MNObject_Flags(obj) & (MNF_DISABLED | MNF_NO_FOCUS | MNF_HIDDEN)) + mn_object_t *ob = &page->objects()[i]; + if(ob->flags() & (MNF_DISABLED | MNF_NO_FOCUS | MNF_HIDDEN)) continue; - if(MNObject_Shortcut(obj) == ev->data1) + if(ob->shortcut() == ev->data1) { - page->setFocus(obj); + page->setFocus(ob); return true; } } @@ -5190,7 +5186,7 @@ void Hu_MenuPlayerClassBackgroundTicker(mn_object_t *ob) // Determine our selection according to the current focus object. /// @todo Do not search for the focus object, flag the "random" /// state through a focus action. - if(mn_object_t *mop = MNObject_Page(ob)->focusObject()) + if(mn_object_t *mop = ob->page()->focusObject()) { playerclass_t pClass = (playerclass_t) mop->data2; if(pClass == PCLASS_NONE) @@ -5221,7 +5217,7 @@ void Hu_MenuPlayerClassPreviewTicker(mn_object_t *ob) // Determine our selection according to the current focus object. /// @todo Do not search for the focus object, flag the "random" /// state through a focus action. - if(mn_object_t *mop = MNObject_Page(ob)->focusObject()) + if(mn_object_t *mop = ob->page()->focusObject()) { playerclass_t pClass = (playerclass_t) mop->data2; if(pClass == PCLASS_NONE) @@ -5517,8 +5513,8 @@ int Hu_MenuActivateColorWidget(mn_object_t *ob, mn_actionid_t action, void * /*c MNSlider_SetValue(sldrBlue, MNSLIDER_SVF_NO_ACTION, MNColorBox_Bluef(ob)); MNSlider_SetValue(sldrAlpha, MNSLIDER_SVF_NO_ACTION, MNColorBox_Alphaf(ob)); - MNObject_SetFlags(textAlpha, (MNColorBox_RGBAMode(ob)? FO_CLEAR : FO_SET), MNF_DISABLED|MNF_HIDDEN); - MNObject_SetFlags(sldrAlpha, (MNColorBox_RGBAMode(ob)? FO_CLEAR : FO_SET), MNF_DISABLED|MNF_HIDDEN); + textAlpha->setFlags((MNColorBox_RGBAMode(ob)? FO_CLEAR : FO_SET), MNF_DISABLED|MNF_HIDDEN); + sldrAlpha->setFlags((MNColorBox_RGBAMode(ob)? FO_CLEAR : FO_SET), MNF_DISABLED|MNF_HIDDEN); return 0; } @@ -5794,7 +5790,7 @@ int Hu_MenuSelectPlayerSetupPlayerClass(mn_object_t *ob, mn_actionid_t action, v int selection = MNList_Selection(ob); if(selection >= 0) { - mn_object_t *mop = MN_MustFindObjectOnPage(MNObject_Page(ob), 0, MNF_ID0); + mn_object_t *mop = MN_MustFindObjectOnPage(ob->page(), 0, MNF_ID0); MNMobjPreview_SetPlayerClass(mop, selection); MNMobjPreview_SetMobjType(mop, PCLASS_INFO(selection)->mobjType); } @@ -5810,7 +5806,7 @@ int Hu_MenuSelectPlayerColor(mn_object_t *ob, mn_actionid_t action, void * /*con int selection = MNList_ItemData(ob, MNList_Selection(ob)); if(selection >= 0) { - mn_object_t *mop = MN_MustFindObjectOnPage(MNObject_Page(ob), 0, MNF_ID0); + mn_object_t *mop = MN_MustFindObjectOnPage(ob->page(), 0, MNF_ID0); MNMobjPreview_SetTranslationMap(mop, selection); } return 0; @@ -5818,11 +5814,11 @@ int Hu_MenuSelectPlayerColor(mn_object_t *ob, mn_actionid_t action, void * /*con int Hu_MenuSelectAcceptPlayerSetup(mn_object_t *ob, mn_actionid_t action, void * /*context*/) { - mn_object_t *plrNameEdit = MN_MustFindObjectOnPage(MNObject_Page(ob), 0, MNF_ID1); + mn_object_t *plrNameEdit = MN_MustFindObjectOnPage(ob->page(), 0, MNF_ID1); #if __JHEXEN__ - mn_object_t *plrClassList = MN_MustFindObjectOnPage(MNObject_Page(ob), 0, MNF_ID2); + mn_object_t *plrClassList = MN_MustFindObjectOnPage(ob->page(), 0, MNF_ID2); #endif - mn_object_t *plrColorList = MN_MustFindObjectOnPage(MNObject_Page(ob), 0, MNF_ID3); + mn_object_t *plrColorList = MN_MustFindObjectOnPage(ob->page(), 0, MNF_ID3); #if __JHEXEN__ cfg.netClass = MNList_Selection(plrClassList); @@ -5950,27 +5946,27 @@ int Hu_MenuSelectPlayerClass(mn_object_t *ob, mn_actionid_t action, void * /*con skillObj = MN_MustFindObjectOnPage(skillPage, 0, MNF_ID0); text = GET_TXT(PCLASS_INFO(mnPlrClass)->skillModeNames[SM_BABY]); ((mndata_button_t *)skillObj->_typedata)->text = text; - MNObject_SetShortcut(skillObj, text[0]); + skillObj->setShortcut(text[0]); skillObj = MN_MustFindObjectOnPage(skillPage, 0, MNF_ID1); text = GET_TXT(PCLASS_INFO(mnPlrClass)->skillModeNames[SM_EASY]); ((mndata_button_t *)skillObj->_typedata)->text = text; - MNObject_SetShortcut(skillObj, text[0]); + skillObj->setShortcut(text[0]); skillObj = MN_MustFindObjectOnPage(skillPage, 0, MNF_ID2); text = GET_TXT(PCLASS_INFO(mnPlrClass)->skillModeNames[SM_MEDIUM]); ((mndata_button_t *)skillObj->_typedata)->text = text; - MNObject_SetShortcut(skillObj, text[0]); + skillObj->setShortcut(text[0]); skillObj = MN_MustFindObjectOnPage(skillPage, 0, MNF_ID3); text = GET_TXT(PCLASS_INFO(mnPlrClass)->skillModeNames[SM_HARD]); ((mndata_button_t *)skillObj->_typedata)->text = text; - MNObject_SetShortcut(skillObj, text[0]); + skillObj->setShortcut(text[0]); skillObj = MN_MustFindObjectOnPage(skillPage, 0, MNF_ID4); text = GET_TXT(PCLASS_INFO(mnPlrClass)->skillModeNames[SM_NIGHTMARE]); ((mndata_button_t *)skillObj->_typedata)->text = text; - MNObject_SetShortcut(skillObj, text[0]); + skillObj->setShortcut(text[0]); switch(mnPlrClass) { @@ -5988,7 +5984,7 @@ int Hu_MenuFocusOnPlayerClass(mn_object_t *ob, mn_actionid_t action, void *conte if(MNA_FOCUS != action) return 1; - mn_object_t *mop = MN_MustFindObjectOnPage(MNObject_Page(ob), 0, MNF_ID0); + mn_object_t *mop = MN_MustFindObjectOnPage(ob->page(), 0, MNF_ID0); MNMobjPreview_SetPlayerClass(mop, plrClass); MNMobjPreview_SetMobjType(mop, (PCLASS_NONE == plrClass? MT_NONE : PCLASS_INFO(plrClass)->mobjType)); diff --git a/doomsday/plugins/common/src/m_ctrl.cpp b/doomsday/plugins/common/src/m_ctrl.cpp index aac76b85d1..3fb72edc4c 100644 --- a/doomsday/plugins/common/src/m_ctrl.cpp +++ b/doomsday/plugins/common/src/m_ctrl.cpp @@ -599,9 +599,9 @@ int MNBindings_CommandResponder(mn_object_t *ob, menucommand_e cmd) case MCMD_SELECT: S_LocalSound(SFX_MENU_CYCLE, NULL); ob->_flags |= MNF_ACTIVE; - if(MNObject_HasAction(ob, MNA_ACTIVE)) + if(ob->hasAction(MNA_ACTIVE)) { - MNObject_ExecAction(ob, MNA_ACTIVE, NULL); + ob->execAction(MNA_ACTIVE, NULL); return true; } break; diff --git a/doomsday/plugins/common/src/saveslots.cpp b/doomsday/plugins/common/src/saveslots.cpp index 602990367a..40f9cf7279 100644 --- a/doomsday/plugins/common/src/saveslots.cpp +++ b/doomsday/plugins/common/src/saveslots.cpp @@ -99,11 +99,11 @@ DENG2_PIMPL_NOREF(SaveSlots::Slot) } DENG2_ASSERT(ob->_type == MN_EDIT); - MNObject_SetFlags(ob, FO_SET, MNF_DISABLED); + ob->setFlags(FO_SET, MNF_DISABLED); if(status == Loadable) { MNEdit_SetText(ob, MNEDIT_STF_NO_ACTION, session->metadata().gets("userDescription", "").toUtf8().constData()); - MNObject_SetFlags(ob, FO_CLEAR, MNF_DISABLED); + ob->setFlags(FO_CLEAR, MNF_DISABLED); } else {