当前位置: 首页>>代码示例>>C++>>正文


C++ UI_GetPath函数代码示例

本文整理汇总了C++中UI_GetPath函数的典型用法代码示例。如果您正苦于以下问题:C++ UI_GetPath函数的具体用法?C++ UI_GetPath怎么用?C++ UI_GetPath使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UI_GetPath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UI_AddListener

/**
 * @brief Add a callback of a function into a node event. There can be more than on listener.
 * @param[in,out] node The node to add the listener to.
 * @param[in] property The property of the node to add the listener to.
 * @param[in] functionNode The node of the listener callback.
 */
void UI_AddListener (uiNode_t *node, const value_t *property, const uiNode_t *functionNode)
{
	uiAction_t *lastAction;
	uiAction_t *action;
	uiAction_t *value;

	if (node->dynamic) {
		Com_Printf("UI_AddListener: '%s' is a dynamic node. We can't listen it.\n", UI_GetPath(node));
		return;
	}
	if (functionNode->dynamic) {
		Com_Printf("UI_AddListener: '%s' is a dynamic node. It can't be a listener callback.\n", UI_GetPath(functionNode));
		return;
	}

	/* create the call action */
	action = (uiAction_t*) Mem_PoolAlloc(sizeof(*action), ui_sysPool, 0);
	value = (uiAction_t*) Mem_PoolAlloc(sizeof(*action), ui_sysPool, 0);
	value->d.terminal.d1.constString = Mem_PoolStrDup(UI_GetPath(functionNode), ui_sysPool, 0);
	value->next = NULL;
	action->type = EA_LISTENER;
	action->d.nonTerminal.left = value;
	/** @todo It is a hack, we should remove that */
	action->d.terminal.d2.constData = &functionNode->onClick;
	action->next = NULL;

	/* insert the action */
	lastAction = *(uiAction_t**)((char*)node + property->ofs);
	if (lastAction) {
		while (lastAction->next)
			lastAction = lastAction->next;
		lastAction->next = action;
	} else
		*(uiAction_t**)((char*)node + property->ofs) = action;
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:41,代码来源:ui_actions.c

示例2: UI_AddListener

/**
 * @brief Add a callback of a function into a node event. There can be more than on listener.
 * @param[in,out] node The node to add the listener to.
 * @param[in] property The property of the node to add the listener to.
 * @param[in] functionNode The node of the listener callback.
 */
void UI_AddListener (uiNode_t *node, const value_t *property, const uiNode_t *functionNode)
{
	if (node->dynamic) {
		Com_Printf("UI_AddListener: '%s' is a dynamic node. We can't listen it.\n", UI_GetPath(node));
		return;
	}
	if (functionNode->dynamic) {
		Com_Printf("UI_AddListener: '%s' is a dynamic node. It can't be a listener callback.\n", UI_GetPath(functionNode));
		return;
	}

	/* create the call action */
	uiAction_t* const action = Mem_PoolAllocType(uiAction_t, ui_sysPool);
	uiAction_t* const value  = Mem_PoolAllocType(uiAction_t, ui_sysPool);
	value->d.terminal.d1.constString = Mem_PoolStrDup(UI_GetPath(functionNode), ui_sysPool, 0);
	value->next = NULL;
	action->type = EA_LISTENER;
	action->d.nonTerminal.left = value;
	/** @todo It is a hack, we should remove that */
	action->d.terminal.d2.constData = &functionNode->onClick;
	action->next = NULL;

	/* insert the action */
	uiAction_t** anchor = &Com_GetValue<uiAction_t*>(node, property);
	while (*anchor)
		anchor = &(*anchor)->next;
	*anchor = action;
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:34,代码来源:ui_actions.cpp

示例3: UI_InitRawActionValue

/**
 * Parse a string according to a property type, and allocate a raw value to the static memory
 *
 * @param action Action to initialize
 * @param node Current node we are parsing, only used for error message
 * @param property Type of the value to parse, if nullptr the string is not stored as string
 * @param string String value to parse
 * @return True if the action is initialized
 * @todo remove node param and catch error where we call that function
 */
bool UI_InitRawActionValue (uiAction_t* action, uiNode_t* node, const value_t* property, const char* string)
{
	if (property == nullptr) {
		action->type = EA_VALUE_STRING;
		action->d.terminal.d1.data = UI_AllocStaticString(string, 0);
		action->d.terminal.d2.integer = 0;
		return true;
	}

	if (property->type == V_UI_SPRITEREF) {
		uiSprite_t* sprite = UI_GetSpriteByName(string);
		if (sprite == nullptr) {
			Com_Printf("UI_ParseSetAction: sprite '%s' not found (%s)\n", string, UI_GetPath(node));
			return false;
		}
		action->type = EA_VALUE_RAW;
		action->d.terminal.d1.data = sprite;
		action->d.terminal.d2.integer = property->type;
		return true;
	} else {
		const int baseType = property->type & V_UI_MASK;
		if (baseType != 0 && baseType != V_UI_CVAR) {
			Com_Printf("UI_ParseRawValue: setter for property '%s' (type %d, 0x%X) is not supported (%s)\n", property->string, property->type, property->type, UI_GetPath(node));
			return false;
		}
		ui_global.curadata = (byte*) Com_AlignPtr(ui_global.curadata, (valueTypes_t) (property->type & V_BASETYPEMASK));
		action->type = EA_VALUE_RAW;
		action->d.terminal.d1.data = ui_global.curadata;
		action->d.terminal.d2.integer = property->type;
		/** @todo we should hide use of ui_global.curadata */
		ui_global.curadata += Com_EParseValue(ui_global.curadata, string, (valueTypes_t) (property->type & V_BASETYPEMASK), 0, property->size);
		return true;
	}
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:44,代码来源:ui_parse.cpp

示例4: UI_ParseEventProperty

static bool UI_ParseEventProperty (uiNode_t* node, const value_t* event, const char** text, const char** token, const char* errhead)
{
	/* add new actions to end of list */
	uiAction_t** action = &Com_GetValue<uiAction_t*>(node, event);
	for (; *action; action = &(*action)->next) {}

	/* get the action body */
	*token = Com_EParse(text, errhead, node->name);
	if (!*text)
		return false;

	if ((*token)[0] != '{') {
		Com_Printf("UI_ParseEventProperty: Event '%s' without body (%s)\n", event->string, UI_GetPath(node));
		return false;
	}

	*action = UI_ParseActionList(node, text, token);
	if (*action == nullptr)
		return false;

	/* block terminal already read */
	assert((*token)[0] == '}');

	return true;
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:25,代码来源:ui_parse.cpp

示例5: UI_GetFloatFromNodeProperty

/**
 * @brief Return a float from a node property
 * @param[in] node Requested node
 * @param[in] property Requested property
 * @return Return the float value of a property, else 0, if the type is not supported
 * @note If the type is not supported, a waring is reported to the console
 */
float UI_GetFloatFromNodeProperty (const uiNode_t* node, const value_t* property)
{
	assert(node);

	if (property->type == V_FLOAT) {
		return Com_GetValue<float>(node, property);
	} else if ((property->type & V_UI_MASK) == V_UI_CVAR) {
		void* const b = Com_GetValue<void*>(node, property);
		if (char const* const cvarName = Q_strstart((char const*)b, "*cvar:")) {
			const cvar_t* cvar = Cvar_Get(cvarName, "", 0, "UI script cvar property");
			return cvar->value;
		} else if (property->type == V_CVAR_OR_FLOAT) {
			return *(const float*) b;
		} else if (property->type == V_CVAR_OR_STRING) {
			return atof((const char*)b);
		}
	} else if (property->type == V_INT) {
		return Com_GetValue<int>(node, property);
	} else if (property->type == V_BOOL) {
		return Com_GetValue<bool>(node, property);
	} else {
#ifdef DEBUG
		Com_Printf("UI_GetFloatFromNodeProperty: Unimplemented float getter for property '%[email protected]%s'. If it should return a float, request it.\n", UI_GetPath(node), property->string);
#else
		Com_Printf("UI_GetFloatFromNodeProperty: Property '%[email protected]%s' can't return a float\n", UI_GetPath(node), property->string);
#endif
	}

	return 0;
}
开发者ID:ufoai,项目名称:ufoai,代码行数:37,代码来源:ui_node.cpp

示例6: UI_GetNodeScreenPos

/**
 * @brief Returns the absolute position of a node in the screen.
 * Screen position is not used for the node rendering cause we use OpenGL
 * translations. But this function is need for some R_functions methodes.
 * @param[in] node Context node
 * @param[out] pos Absolute position into the screen
 */
void UI_GetNodeScreenPos (const uiNode_t* node, vec2_t pos)
{
	assert(node);
	assert(pos);

	/* if we request the position of a non drawable node, there is a problem */
	if (node->behaviour->isVirtual)
		Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' doesn't have a position", node->name);

	Vector2Set(pos, 0, 0);
	while (node) {
#ifdef DEBUG
		if (node->box.pos[0] != (int)node->box.pos[0] || node->box.pos[1] != (int)node->box.pos[1])
			Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' position %f,%f is not integer", UI_GetPath(node), node->box.pos[0], node->box.pos[1]);
#endif
		pos[0] += node->box.pos[0];
		pos[1] += node->box.pos[1];
		node = node->parent;

		if (node && UI_Node_IsScrollableContainer(node)) {
			vec2_t clientPosition = {0, 0};
			UI_Node_GetClientPosition(node, clientPosition);
			pos[0] += clientPosition[0];
			pos[1] += clientPosition[1];
		}
	}
}
开发者ID:ufoai,项目名称:ufoai,代码行数:34,代码来源:ui_node.cpp

示例7: UI_Node_GetText

const char* UI_Node_GetText (uiNode_t* node) {
	#ifdef DEBUG
	if (node->text == nullptr) {
		Com_Printf("warning: requesting uninitialized node->text from [%s]\n", UI_GetPath(node));
	}
	#endif // DEBUG
	return (node->text? node->text : "");
}
开发者ID:ufoai,项目名称:ufoai,代码行数:8,代码来源:ui_node.cpp

示例8: UI_ExecuteSetAction

static inline void UI_ExecuteSetAction (const uiAction_t* action, const uiCallContext_t *context)
{
	const char* path;
	uiNode_t *node;
	const value_t *property;
	const uiAction_t *left;
	uiAction_t *right;

	left = action->d.nonTerminal.left;
	if (left == NULL) {
		Com_Printf("UI_ExecuteSetAction: Action without left operand skipped.\n");
		return;
	}

	right = action->d.nonTerminal.right;
	if (right == NULL) {
		Com_Printf("UI_ExecuteSetAction: Action without right operand skipped.\n");
		return;
	}

	if (left->type == EA_VALUE_CVARNAME || left->type == EA_VALUE_CVARNAME_WITHINJECTION) {
		const char *cvarName;
		const char* textValue;

		if (left->type == EA_VALUE_CVARNAME)
			cvarName = left->d.terminal.d1.constString;
		else
			cvarName = UI_GenInjectedString(left->d.terminal.d1.constString, false, context);

		textValue = UI_GetStringFromExpression(right, context);

		if (textValue[0] == '_')
			textValue = _(textValue + 1);

		Cvar_ForceSet(cvarName, textValue);
		return;
	}

	/* search the node */
	if (left->type == EA_VALUE_PATHPROPERTY)
		path = left->d.terminal.d1.constString;
	else if (left->type == EA_VALUE_PATHPROPERTY_WITHINJECTION)
		path = UI_GenInjectedString(left->d.terminal.d1.constString, false, context);
	else
		Com_Error(ERR_FATAL, "UI_ExecuteSetAction: Property setter with wrong type '%d'", left->type);

	UI_ReadNodePath(path, context->source, &node, &property);
	if (!node) {
		Com_Printf("UI_ExecuteSetAction: node \"%s\" doesn't exist (source: %s)\n", path, UI_GetPath(context->source));
		return;
	}
	if (!property) {
		Com_Printf("UI_ExecuteSetAction: property \"%s\" doesn't exist (source: %s)\n", path, UI_GetPath(context->source));
		return;
	}

	UI_NodeSetPropertyFromActionValue(node, property, context, right);
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:58,代码来源:ui_actions.cpp

示例9: UI_ParseNodeProperties

/**
 * @sa UI_ParseNodeProperties
 * @brief parse all sequencial properties into a block
 * @note allow to use an extra block
 * @code
 * foobehaviour foonode {
 *   { properties }
 *   // the function stop reading here
 *   nodes
 * }
 * foobehaviour foonode {
 *   properties
 *   // the function stop reading here
 *   nodes
 * }
 * @endcode
 */
static bool UI_ParseNodeProperties (uiNode_t* node, const char** text, const char** token)
{
	const char* errhead = "UI_ParseNodeProperties: unexpected end of file (node";
	bool nextTokenAlreadyRead = false;

	if ((*token)[0] != '{')
		nextTokenAlreadyRead = true;

	do {
		const value_t* val;
		int result;

		/* get new token */
		if (!nextTokenAlreadyRead) {
			*token = Com_EParse(text, errhead, node->name);
			if (!*text)
				return false;
		} else {
			nextTokenAlreadyRead = false;
		}

		/* is finished */
		if ((*token)[0] == '}')
			break;

		/* find the property */
		val = UI_GetPropertyFromBehaviour(node->behaviour, *token);
		if (!val) {
			/* unknown token, print message and continue */
			Com_Printf("UI_ParseNodeProperties: unknown property \"%s\", node ignored (node %s)\n",
					*token, UI_GetPath(node));
			return false;
		}

		/* get parameter values */
		result = UI_ParseProperty(node, val, node->name, text, token);
		if (!result) {
			Com_Printf("UI_ParseNodeProperties: Problem with parsing of node property '%[email protected]%s'. See upper\n",
					UI_GetPath(node), val->string);
			return false;
		}
	} while (*text);

	return true;
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:62,代码来源:ui_parse.cpp

示例10: UI_ExecuteActions

/**
 * @brief Execute a tree of actions from a source
 * @param[in] context Context node
 * @param[in] firstAction Action to execute
 */
static void UI_ExecuteActions (const uiAction_t* firstAction, uiCallContext_t* context)
{
	static int callnumber = 0;
	if (callnumber++ > 20) {
		Com_Printf("UI_ExecuteActions: Break possible infinite recursion, source [%s]\n", UI_GetPath(context->source));
		return;
	}
	for (const uiAction_t* action = firstAction; action && !context->breakLoop; action = action->next) {
		UI_ExecuteAction(action, context);
	}
	callnumber--;
}
开发者ID:hwoarangmy,项目名称:ufoai,代码行数:17,代码来源:ui_actions.cpp

示例11: EXTRADATA

void uiTextNode::onLoaded (uiNode_t* node)
{
	int lineheight = EXTRADATA(node).lineHeight;
	/* auto compute lineheight */
	/* we don't overwrite EXTRADATA(node).lineHeight, because "0" is dynamically replaced by font height on draw function */
	if (lineheight == 0) {
		/* the font is used */
		const char* font = UI_GetFontFromNode(node);
		lineheight = UI_FontGetHeight(font);
	}

	/* auto compute rows (super.viewSizeY) */
	if (EXTRADATA(node).super.scrollY.viewSize == 0) {
		if (node->box.size[1] != 0 && lineheight != 0) {
			EXTRADATA(node).super.scrollY.viewSize = node->box.size[1] / lineheight;
		} else {
			EXTRADATA(node).super.scrollY.viewSize = 1;
			Com_Printf("UI_TextNodeLoaded: node '%s' has no rows value\n", UI_GetPath(node));
		}
	}

	/* auto compute height */
	if (node->box.size[1] == 0) {
		node->box.size[1] = EXTRADATA(node).super.scrollY.viewSize * lineheight;
	}

	/* is text slot exists */
	if (EXTRADATA(node).dataID >= UI_MAX_DATAID)
		Com_Error(ERR_DROP, "Error in node %s - max shared data id num exceeded (num: %i, max: %i)", UI_GetPath(node), EXTRADATA(node).dataID, UI_MAX_DATAID);

#ifdef DEBUG
	if (EXTRADATA(node).super.scrollY.viewSize != (int)(node->box.size[1] / lineheight)) {
		Com_Printf("UI_TextNodeLoaded: rows value (%i) of node '%s' differs from size (%.0f) and format (%i) values\n",
			EXTRADATA(node).super.scrollY.viewSize, UI_GetPath(node), node->box.size[1], lineheight);
	}
#endif

	if (node->text == nullptr && EXTRADATA(node).dataID == TEXT_NULL)
		Com_Printf("UI_TextNodeLoaded: 'textid' property of node '%s' is not set\n", UI_GetPath(node));
}
开发者ID:XenderPL,项目名称:ufoai,代码行数:40,代码来源:ui_node_text.cpp

示例12: UI_DeleteNode

/**
 * Delete the node and remove it from his parent
 * @param node The node we want to delete
 */
void UI_DeleteNode (uiNode_t* node)
{
	if (!node->dynamic) {
		Com_Printf("UI_DeleteNode: Can't delete the static node '%s'\n", UI_GetPath(node));
		return;
	}

	UI_BeforeDeletingNode(node);

	UI_DeleteAllChild(node);
	if (node->firstChild != nullptr) {
		Com_Printf("UI_DeleteNode: Node '%s' contain static nodes. We can't delete it.\n", UI_GetPath(node));
		return;
	}

	if (node->parent)
		UI_RemoveNode(node->parent, node);

	/* delete all allocated properties */
	for (uiBehaviour_t* behaviour = node->behaviour; behaviour; behaviour = behaviour->super) {
		const value_t** property = behaviour->localProperties;
		if (property == nullptr)
			continue;
		while (*property) {
			if (((*property)->type & V_UI_MASK) == V_UI_CVAR) {
				if (void*& mem = Com_GetValue<void*>(node, *property)) {
					UI_FreeStringProperty(mem);
					mem = 0;
				}
			}

			/** @todo We must delete all EA_LISTENER too */

			property++;
		}
	}

	UI_Node_DeleteNode(node);
}
开发者ID:ufoai,项目名称:ufoai,代码行数:43,代码来源:ui_nodes.cpp

示例13: UI_CvarListenerNodeBind

/**
 * @brief Callback every time the parent window is opened (pushed into the active window stack)
 */
static void UI_CvarListenerNodeBind (uiNode_t* node)
{
    cvarChangeListener_t* l;
    l = Cvar_RegisterChangeListener(node->name, UI_CvarListenerNodeCallback);
    if (l == nullptr) {
        Com_Printf("Node %s is not binded: cvar %s not found\n", UI_GetPath(node), node->name);
        return;
    }

    if (LIST_GetPointer(static_cast<linkedList_t*>(l->data), node) == nullptr) {
        LIST_AddPointer(reinterpret_cast<linkedList_t**>(&l->data), node);
    }
}
开发者ID:rxadmin,项目名称:ufoai,代码行数:16,代码来源:ui_node_special.cpp

示例14: UI_DeleteNode

/**
 * Delete the node and remove it from his parent
 * @param node The node we want to delete
 */
void UI_DeleteNode (uiNode_t* node)
{
	uiBehaviour_t *behaviour;

	if (!node->dynamic)
		return;

	UI_BeforeDeletingNode(node);

	UI_DeleteAllChild(node);
	if (node->firstChild != NULL) {
		Com_Printf("UI_DeleteNode: Node '%s' contain static nodes. We can't delete it.", UI_GetPath(node));
		return;
	}

	if (node->parent)
		UI_RemoveNode(node->parent, node);

	/* delete all allocated properties */
	for (behaviour = node->behaviour; behaviour; behaviour = behaviour->super) {
		const value_t *property = behaviour->properties;
		if (property == NULL)
			continue;
		while (property->string != NULL) {
			if ((property->type & V_UI_MASK) == V_UI_CVAR) {
				void *mem = ((byte *) node + property->ofs);
				if (*(void**)mem != NULL) {
					UI_FreeStringProperty(*(void**)mem);
					*(void**)mem = NULL;
				}
			}

			/** @todo We must delete all EA_LISTENER too */

			property++;
		}
	}

	if (node->behaviour->deleteNode)
		node->behaviour->deleteNode(node);
}
开发者ID:chrisglass,项目名称:ufoai,代码行数:45,代码来源:ui_nodes.c

示例15: EXTRADATA

/**
 * @brief Handled after the end of the load of the node from the script (all data and/or child are set)
 */
void uiImageNode::onLoaded (uiNode_t* node)
{
	/* update the size when its possible */
	if (Vector2Empty(node->box.size)) {
		if (EXTRADATA(node).texl[0] != 0 || EXTRADATA(node).texh[0]) {
			node->box.size[0] = EXTRADATA(node).texh[0] - EXTRADATA(node).texl[0];
			node->box.size[1] = EXTRADATA(node).texh[1] - EXTRADATA(node).texl[1];
		} else if (node->image) {
			const image_t* image = UI_LoadImage(node->image);
			if (image) {
				node->box.size[0] = image->width;
				node->box.size[1] = image->height;
			}
		}
	}
#ifdef DEBUG
	if (Vector2Empty(node->box.size)) {
		if (node->onClick || node->onRightClick || node->onMouseEnter || node->onMouseLeave || node->onWheelUp || node->onWheelDown || node->onWheel || node->onMiddleClick) {
			Com_DPrintf(DEBUG_CLIENT, "Node '%s' is an active image without size\n", UI_GetPath(node));
		}
	}
#endif
}
开发者ID:drone-pl,项目名称:ufoai,代码行数:26,代码来源:ui_node_image.cpp


注:本文中的UI_GetPath函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。