/** * @brief Call after the script initialized the node */ static void UI_ConFuncNodeLoaded (uiNode_t *node) { /* register confunc non inherited */ if (node->super == NULL) { /* don't add a callback twice */ if (!Cmd_Exists(node->name)) { Cmd_AddCommand(node->name, UI_ConfuncCommand_f, "Confunc callback"); Cmd_AddUserdata(node->name, node); } else { Com_Printf("UI_ParseNodeBody: Command name for confunc '%s' already registered\n", UI_GetPath(node)); } } else { uiNode_t *dummy; /* convert a confunc to an "inherited" confunc if it is possible */ if (Cmd_Exists(node->name)) { if (UI_ConFuncIsVirtual(node)) return; } dummy = UI_AllocNode(node->name, "confunc", qfalse); Cmd_AddCommand(node->name, UI_ConfuncCommand_f, "Inherited confunc callback"); Cmd_AddUserdata(dummy->name, dummy); } }
/** * @brief Callback every time the parent window is opened (pushed into the active window stack) */ static void UI_ConFuncNodeInit (uiNode_t *node, linkedList_t *params) { if (UI_ConFuncIsVirtual(node)) { const value_t *property = UI_GetPropertyFromBehaviour(node->behaviour, "onClick"); uiNode_t *userData = (uiNode_t*) Cmd_GetUserdata(node->name); UI_AddListener(userData, property, node); } }
/** * @brief Callback every time the parent window is closed (pop from the active window stack) */ static void UI_ConFuncNodeClose (uiNode_t *node) { if (UI_ConFuncIsVirtual(node)) { const value_t *property = UI_GetPropertyFromBehaviour(node->behaviour, "onClick"); uiNode_t *userData = (uiNode_t*) Cmd_GetUserdata(node->name); UI_RemoveListener(userData, property, node); } }
/** * @brief Callback every time the parent window is closed (pop from the active window stack) */ void uiConFuncNode::onWindowClosed (uiNode_t* node) { if (UI_ConFuncIsVirtual(node)) { const value_t* property = UI_GetPropertyFromBehaviour(node->behaviour, "onClick"); uiNode_t* userData = static_cast<uiNode_t*>(Cmd_GetUserdata(node->name)); UI_RemoveListener(userData, property, node); } }