Esempio n. 1
0
/**
 * @todo Find  better name
 */
static void UI_CloseWindowByRef (uiNode_t *window)
{
	int i;

	/** @todo If the focus is not on the window we close, we don't need to remove it */
	UI_ReleaseInput();

	assert(ui_global.windowStackPos);
	i = UI_GetWindowPositionFromStackByName(window->name);
	if (i == -1) {
		Com_Printf("Window '%s' is not on the active stack\n", window->name);
		return;
	}

	/* close child */
	while (i + 1 < ui_global.windowStackPos) {
		uiNode_t *m = ui_global.windowStack[i + 1];
		if (WINDOWEXTRADATA(m).parent != window) {
			break;
		}

		UI_Node_WindowClosed(window);
		WINDOWEXTRADATA(m).parent = NULL;
		UI_RemoveWindowAtPositionFromStack(i + 1);
	}

	/* close the window */
	UI_Node_WindowClosed(window);
	WINDOWEXTRADATA(window).parent = NULL;
	UI_RemoveWindowAtPositionFromStack(i);

	UI_InvalidateMouse();
}
Esempio n. 2
0
/**
 * @brief Release the captured node
 */
void UI_MouseRelease (void)
{
	uiNode_t* tmp = capturedNode;

	if (capturedNode == nullptr)
		return;

	capturedNode = nullptr;
	UI_Node_CapturedMouseLost(tmp);
	UI_InvalidateMouse();
}
Esempio n. 3
0
/**
 * @brief Drop the object at the current position
 * @sa UI_DNDStartDrag
 * @sa UI_DNDDrop
 */
void UI_DNDAbort (void)
{
	assert(UI_DNDIsDragging());
	assert(objectType != DND_NOTHING);
	assert(sourceNode != nullptr);

	if (nodeAcceptDND && targetNode) {
		UI_Node_DndLeave(targetNode);
	}
	UI_Node_DndFinished(sourceNode, false);

	UI_DNDCleanup();
	UI_InvalidateMouse();
}
Esempio n. 4
0
/**
 * @brief Call mouse move only if the mouse position change
 */
bool UI_CheckMouseMove (void)
{
	/* is hovered node no more draw */
	if (hoveredNode && (hoveredNode->invis || !UI_CheckVisibility(hoveredNode)))
		UI_InvalidateMouse();

	if (mousePosX != oldMousePosX || mousePosY != oldMousePosY) {
		oldMousePosX = mousePosX;
		oldMousePosY = mousePosY;
		UI_MouseMove(mousePosX, mousePosY);
		return true;
	}

	return false;
}
Esempio n. 5
0
/**
 * @brief Remove the window from the window stack
 * @param[in] window The window to remove from the stack
 * @todo Why dont we call onClose?
 */
static void UI_DeleteWindowFromStack (uiNode_t *window)
{
	int i;

	/* get window index */
	for (i = 0; i < ui_global.windowStackPos; i++) {
		if (ui_global.windowStack[i] == window)
			break;
	}

	/* update stack */
	if (i < ui_global.windowStackPos) {
		ui_global.windowStackPos--;
		for (; i < ui_global.windowStackPos; i++)
			ui_global.windowStack[i] = ui_global.windowStack[i + 1];
		UI_InvalidateMouse();
	}
}
Esempio n. 6
0
/**
 * @brief Drop the object at the current position
 * @sa UI_DNDStartDrag
 * @sa UI_DNDAbort
 */
void UI_DNDDrop (void)
{
	bool result = false;
	assert(UI_DNDIsDragging());
	assert(objectType != DND_NOTHING);
	assert(sourceNode != nullptr);

	if (!positionAcceptDND) {
		UI_DNDAbort();
		return;
	}

	if (targetNode) {
		result = UI_Node_DndDrop(targetNode, mousePosX, mousePosY);
	}
	UI_Node_DndFinished(sourceNode, result);

	UI_PlaySound("item-drop");

	UI_DNDCleanup();
	UI_InvalidateMouse();
}
Esempio n. 7
0
/**
 * @brief Push a window onto the window stack
 * @param[in] name Name of the window to push onto window stack
 * @param[in] parentName Window name to link as parent-child (else NULL)
 * @param[in] params List of string parameters to send to the onWindowOpened method.
 * It can be NULL when there is no parameters, else this object must be freed by the caller.
 * @return A pointer to @c uiNode_t
 */
uiNode_t* UI_PushWindow (const char *name, const char *parentName, linkedList_t *params)
{
	uiNode_t *window;

	UI_ReleaseInput();

	window = UI_GetWindow(name);
	if (window == NULL) {
		Com_Printf("Window \"%s\" not found.\n", name);
		return NULL;
	}

	UI_DeleteWindowFromStack(window);

	if (ui_global.windowStackPos < UI_MAX_WINDOWSTACK)
		if (parentName) {
			const int parentPos = UI_GetWindowPositionFromStackByName(parentName);
			if (parentPos == -1) {
				Com_Printf("Didn't find parent window \"%s\" for window push of \"%s\"\n", parentName, name);
				return NULL;
			}
			UI_InsertWindowIntoStack(window, parentPos + 1);
			WINDOWEXTRADATA(window).parent = ui_global.windowStack[parentPos];
		} else
			ui_global.windowStack[ui_global.windowStackPos++] = window;
	else
		Com_Printf("Window stack overflow\n");

	UI_Node_WindowOpened(window, params);

	/* change from e.g. console mode to game input mode (fetch input) */
	Key_SetDest(key_game);

	UI_InvalidateMouse();
	return window;
}
Esempio n. 8
0
static void UI_BeforeDeletingNode (const uiNode_t* node)
{
	if (UI_GetHoveredNode() == node) {
		UI_InvalidateMouse();
	}
}
Esempio n. 9
0
/**
 * Reinit input and font
 */
void UI_Reinit (void)
{
	UI_InitFonts();
	UI_ReleaseInput();
	UI_InvalidateMouse();
}