本文整理匯總了C++中EXTRADATA函數的典型用法代碼示例。如果您正苦於以下問題:C++ EXTRADATA函數的具體用法?C++ EXTRADATA怎麽用?C++ EXTRADATA使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了EXTRADATA函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: EXTRADATA
void uiSequenceNode::onWindowOpened (uiNode_t* node, linkedList_t* params)
{
if (EXTRADATA(node).context == nullptr)
EXTRADATA(node).context = SEQ_AllocContext();
if (EXTRADATA(node).source != nullptr) {
SEQ_InitContext(EXTRADATA(node).context, EXTRADATA(node).source);
EXTRADATA(node).playing = true;
}
}
示例2: switch
void uiBaseInventoryNode::onMouseDown (uiNode_t* node, int x, int y, int button)
{
switch (button) {
case K_MOUSE1:
{
/* start drag and drop */
int fromX, fromY;
dragInfoIC = UI_BaseInventoryNodeGetItem(node, x, y, &fromX, &fromY);
if (dragInfoIC) {
dragInfoFromX = fromX;
dragInfoFromY = fromY;
oldMouseX = x;
oldMouseY = y;
UI_SetMouseCapture(node);
EXTRADATA(node).super.lastSelectedId = dragInfoIC->def()->idx;
if (EXTRADATA(node).super.onSelect) {
UI_ExecuteEventActions(node, EXTRADATA(node).super.onSelect);
}
if (EXTRADATA(node).super.lua_onSelect != LUA_NOREF) {
UI_ExecuteLuaEventScript(node, EXTRADATA(node).super.lua_onSelect);
}
}
break;
}
case K_MOUSE2:
if (UI_DNDIsDragging()) {
UI_DNDAbort();
} else {
/* auto place */
UI_ContainerNodeAutoPlace(node, x, y);
}
break;
default:
break;
}
}
示例3: UI_ClientLayout
/**
* Update the client zone
*/
static void UI_ClientLayout (uiNode_t *node)
{
int width = 0;
int height = 0;
uiNode_t *child;
qboolean updated;
for (child = node->firstChild; child; child = child->next) {
int value;
value = child->pos[0] + child->size[0];
if (value > width)
width = value;
value = child->pos[1] + child->size[1];
if (value > height)
height = value;
}
width += node->padding;
height += node->padding;
updated = UI_SetScroll(&EXTRADATA(node).super.scrollX, -1, node->size[0], width);
updated = UI_SetScroll(&EXTRADATA(node).super.scrollY, -1, node->size[1], height) || updated;
if (updated && EXTRADATA(node).super.onViewChange)
UI_ExecuteEventActions(node, EXTRADATA(node).super.onViewChange);
}
示例4: UI_BaseLayoutNodeDraw
/**
* @brief Draw a small square with the layout of the given base
*/
static void UI_BaseLayoutNodeDraw (uiNode_t * node)
{
base_t *base;
int height, width, y;
int row, col;
const vec4_t c_gray = {0.5, 0.5, 0.5, 1.0};
vec2_t nodepos;
int totalMarge;
if (EXTRADATA(node).baseid >= MAX_BASES || EXTRADATA(node).baseid < 0)
return;
totalMarge = node->padding * (BASE_SIZE + 1);
width = (node->size[0] - totalMarge) / BASE_SIZE;
height = (node->size[1] - totalMarge) / BASE_SIZE;
UI_GetNodeAbsPos(node, nodepos);
base = B_GetBaseByIDX(EXTRADATA(node).baseid);
y = nodepos[1] + node->padding;
for (row = 0; row < BASE_SIZE; row++) {
int x = nodepos[0] + node->padding;
for (col = 0; col < BASE_SIZE; col++) {
if (B_IsTileBlocked(base, col, row)) {
UI_DrawFill(x, y, width, height, c_gray);
} else if (B_GetBuildingAt(base, col, row) != NULL) {
/* maybe destroyed in the meantime */
if (base->founded)
UI_DrawFill(x, y, width, height, node->color);
}
x += width + node->padding;
}
y += height + node->padding;
}
}
示例5: UI_SetMouseCapture
/**
* @brief Handles selectboxes clicks
*/
void uiSelectBoxNode::onLeftClick (uiNode_t* node, int x, int y)
{
/* dropdown the node */
if (UI_GetMouseCapture() == nullptr) {
UI_SetMouseCapture(node);
return;
}
vec2_t pos;
UI_GetNodeAbsPos(node, pos);
int clickedAtOption = (y - pos[1]);
/* we click outside */
if (x < pos[0] || y < pos[1] || x >= pos[0] + node->box.size[0] || y >= pos[1] + node->box.size[1] * (EXTRADATA(node).count + 1)) {
UI_MouseRelease();
return;
}
/* we click on the head */
if (clickedAtOption < node->box.size[1]) {
UI_MouseRelease();
return;
}
clickedAtOption = (clickedAtOption - node->box.size[1]) / node->box.size[1];
if (clickedAtOption < 0 || clickedAtOption >= EXTRADATA(node).count)
return;
if (UI_AbstractOptionGetCurrentValue(node) == nullptr)
return;
/* select the right option */
uiNode_t* option = UI_AbstractOptionGetFirstOption(node);
for (; option; option = option->next) {
if (option->invis)
continue;
if (clickedAtOption == 0)
break;
clickedAtOption--;
}
/* update the status */
if (option)
UI_AbstractOptionSetCurrentValue(node, OPTIONEXTRADATA(option).value);
/* close the dropdown */
UI_MouseRelease();
}
示例6: UI_RadioButtonNodeIsSelected
static qboolean UI_RadioButtonNodeIsSelected (uiNode_t *node)
{
if (EXTRADATA(node).string == NULL) {
const float current = UI_GetReferenceFloat(node, EXTRADATA(node).cvar);
return current > EXTRADATA(node).value - EPSILON && current < EXTRADATA(node).value + EPSILON;
} else {
const char *current = UI_GetReferenceString(node, EXTRADATA(node).cvar);
return Q_streq(current, EXTRADATA(node).string);
}
}
示例7: getCellAtPos
/**
* @brief Draws a base.
*/
void uiBaseMapNode::draw (uiNode_t * node)
{
int col, row;
bool hover = node->state;
getCellAtPos(node, mousePosX, mousePosY, &col, &row);
if (col == -1)
hover = false;
const int width = node->box.size[0] / BASE_SIZE;
const int height = node->box.size[1] / BASE_SIZE + BASE_IMAGE_OVERLAY;
vec2_t nodePos;
UI_GetNodeAbsPos(node, nodePos);
GAME_DrawBase(EXTRADATA(node).baseid, nodePos[0], nodePos[1], width, height, col, row, hover, BASE_IMAGE_OVERLAY);
}
示例8: onFocusLost
/**
* @brief Called when the node lost the focus
*/
void uiTextEntryNode::onFocusLost (uiNode_t* node)
{
/* already aborted/changed with the keyboard */
if (editedCvar == nullptr)
return;
/* release the keyboard */
if (isAborted || EXTRADATA(node).clickOutAbort) {
UI_TextEntryNodeAbortEdition(node);
} else {
UI_TextEntryNodeValidateEdition(node);
}
#if SDL_VERSION_ATLEAST(2,0,0)
SDL_StopTextInput();
#endif
}
示例9: 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));
}
示例10: EXTRADATA
/**
* @brief Called when the node is captured by the mouse
*/
void uiVScrollbarNode::onCapturedMouseMove (uiNode_t* node, int x, int y)
{
if (capturedElement != 2)
return;
const int posSize = EXTRADATA(node).fullsize;
const int graphicSize = node->box.size[1] - (4 * ELEMENT_HEIGHT);
/* compute mouse mouse */
y -= oldMouseY;
/* compute pos projection */
const int pos = oldPos + (((float)y * (float)posSize) / (float)graphicSize);
UI_VScrollbarNodeSet(node, pos);
}
示例11: UI_BaseInventoryNodeDraw2
/**
* @brief Draw the inventory of the base
*/
static void UI_BaseInventoryNodeDraw2 (uiNode_t* node, const objDef_t* highlightType)
{
bool updateScroll = false;
int visibleHeight = 0;
int needHeight = 0;
vec2_t screenPos;
UI_GetNodeScreenPos(node, screenPos);
UI_PushClipRect(screenPos[0], screenPos[1], node->box.size[0], node->box.size[1]);
needHeight = UI_BaseInventoryNodeDrawItems(node, highlightType);
UI_PopClipRect();
visibleHeight = node->box.size[1];
#if 0
R_FontDrawString("f_verysmall", ALIGN_UL,
node->box.pos[0], node->box.pos[1], node->box.pos[0], node->box.pos[1],
0, 0, /* maxWidth/maxHeight */
0, va("%i %i/%i", EXTRADATA(node).scrollCur, visibleRows, totalRows), 0, 0, nullptr, false, 0);
#endif
/* Update display of scroll buttons if something changed. */
if (visibleHeight != EXTRADATA(node).scrollY.viewSize || needHeight != EXTRADATA(node).scrollY.fullSize) {
EXTRADATA(node).scrollY.fullSize = needHeight;
EXTRADATA(node).scrollY.viewSize = visibleHeight;
updateScroll = true;
}
if (EXTRADATA(node).scrollY.viewPos > needHeight - visibleHeight) {
EXTRADATA(node).scrollY.viewPos = needHeight - visibleHeight;
updateScroll = true;
}
if (EXTRADATA(node).scrollY.viewPos < 0) {
EXTRADATA(node).scrollY.viewPos = 0;
updateScroll = true;
}
if (updateScroll)
UI_BaseInventoryNodeUpdateScroll(node);
}
示例12: UI_ContainerNodeDrawGrid
/**
* @brief Draw a grip container
*/
static void UI_ContainerNodeDrawGrid (uiNode_t *node, const objDef_t *highlightType)
{
const invList_t *ic;
vec3_t pos;
UI_GetNodeAbsPos(node, pos);
pos[2] = 0;
for (ic = ui_inventory->c[EXTRADATA(node).container->id]; ic; ic = ic->next) {
assert(ic->item.item);
if (highlightType && INVSH_LoadableInWeapon(highlightType, ic->item.item))
UI_DrawItem(node, pos, &ic->item, ic->x, ic->y, scale, colorLoadable);
else
UI_DrawItem(node, pos, &ic->item, ic->x, ic->y, scale, colorDefault);
}
}
示例13: Vector4Set
/**
* @brief Called before loading. Used to set default attribute values
*/
void uiGeoscapeNode::onLoading (uiNode_t* node)
{
Vector4Set(node->color, 1, 1, 1, 1);
OBJZERO(EXTRADATA(node));
EXTRADATA(node).angles[YAW] = GLOBE_ROTATE;
EXTRADATA(node).center[0] = EXTRADATA(node).center[1] = 0.5;
EXTRADATA(node).zoom = 1.0;
Vector2Set(EXTRADATA(node).smoothFinal2DGeoscapeCenter, 0.5, 0.5);
VectorSet(EXTRADATA(node).smoothFinalGlobeAngle, 0, GLOBE_ROTATE, 0);
/* @todo: allocate this on a per node basis - and remove the global variable geoscapeData */
EXTRADATA(node).geoscapeData = &geoscapeData;
/* EXTRADATA(node).geoscapeData = Mem_AllocType(geoscapeData_t); */
/** this is the data that is used with r_dayandnightTexture */
EXTRADATA(node).r_dayandnightAlpha = Mem_AllocTypeN(byte, DAN_WIDTH * DAN_HEIGHT);
r_dayandnightTexture = R_LoadImageData("***r_dayandnighttexture***", nullptr, DAN_WIDTH, DAN_HEIGHT, it_effect);
r_radarTexture = R_LoadImageData("***r_radarTexture***", nullptr, RADAR_WIDTH, RADAR_HEIGHT, it_effect);
r_xviTexture = R_LoadImageData("***r_xvitexture***", nullptr, XVI_WIDTH, XVI_HEIGHT, it_effect);
}
示例14: UI_NodeAbsoluteToRelativePos
/**
* @brief call when the mouse move is the node is captured
* @todo we can remove the loop if we save the current element in the node
*/
void uiSelectBoxNode::onCapturedMouseMove (uiNode_t* node, int x, int y)
{
UI_NodeAbsoluteToRelativePos(node, &x, &y);
/* test bounded box */
if (x < 0 || y < 0 || x > node->box.size[0] || y > node->box.size[1] * (EXTRADATA(node).count + 1)) {
return;
}
int posy = node->box.size[1];
for (uiNode_t* option = UI_AbstractOptionGetFirstOption(node); option; option = option->next) {
if (option->invis)
continue;
OPTIONEXTRADATA(option).hovered = (posy <= y && y < posy + node->box.size[1]);
posy += node->box.size[1];
}
}
示例15: EXTRADATA
void uiModelNode::onCapturedMouseMove (uiNode_t* node, int x, int y)
{
float* rotateAngles = EXTRADATA(node).angles;
/* rotate a model */
rotateAngles[YAW] -= ROTATE_SPEED * (x - oldMousePosX);
rotateAngles[ROLL] += ROTATE_SPEED * (y - oldMousePosY);
/* clamp the angles */
rotateAngles[YAW] -= floor(rotateAngles[YAW] / 360.0) * 360.0;
if (rotateAngles[ROLL] < 0.0)
rotateAngles[ROLL] = 0.0;
else if (rotateAngles[ROLL] > 180.0)
rotateAngles[ROLL] = 180.0;
oldMousePosX = x;
oldMousePosY = y;
}