Ejemplo n.º 1
0
void UI_DrawTextBox(int x, int y, int width, int lines)
{
    UI_FillRect(x + BIGCHAR_WIDTH / 2, y + BIGCHAR_HEIGHT / 2, (width + 1) * BIGCHAR_WIDTH,
                (lines + 1) * BIGCHAR_HEIGHT, colorBlack);
    UI_DrawRect(x + BIGCHAR_WIDTH / 2, y + BIGCHAR_HEIGHT / 2, (width + 1) * BIGCHAR_WIDTH,
                (lines + 1) * BIGCHAR_HEIGHT, colorWhite, uiInfo.uiDC.whiteShader);
}
void JKG_Slice_DrawGridSummary(int slot, float x, float y, float w, float h) {
	static const vec4_t topcol = {.2, 1, .2, 0.2f};
	static const vec4_t botcol = {1, 0.2, 0.2, 0.2f};

	int orientation = (slot >> 3) & 1;		// 0 = Columns, 1 = Rows
	int index = slot & 7;

	vec4_t color;

	const char *text;

	float w2;

	if ((orientation == 0 && index >= sliceData.width) || (orientation == 1 && index >= sliceData.height) ) {
		UI_DrawRect(x, y, w, h, disabled);
		return;
	} else {
		UI_FillRect(x, y, w, h/2, topcol);
		UI_FillRect(x, y + (0.5f * h), w, h/2, botcol);
		if (sliceData.inputState == INPUTSTATE_AWAITINGLINE) {
			float phase = 0.7f + sin((float)trap->Milliseconds() / 150.0f) * 0.1f;
			MAKERGBA(color, phase, phase, phase, 1.0f);
			UI_DrawRect(x, y, w, h, color);
		} else {
			UI_DrawRect(x, y, w, h, black);
		}
	}


	if (sliceData.summariesKnown) {
		text = va("%i", sliceData.summaries[slot].value);
		w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.4f;
		DC->drawText(x + (w/2) - (w2/2), y-1, 0.4f, const_cast<float *>(white), text, 0, 0, 0, 0 );

		text = va("%i", sliceData.summaries[slot].alarms);
		w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.4f;
		DC->drawText(x + (w/2) - (w2/2), y+(h*0.5f)-1, 0.4f, const_cast<float *>(white), text, 0, 0, 0, 0 );
	} else {
		text = "?";
		w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.4f;
		DC->drawText(x + (w/2) - (w2/2), y-1, 0.4f, const_cast<float *>(white), text, 0, 0, 0, 0 );

		w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.4f;
		DC->drawText(x + (w/2) - (w2/2), y+(h*0.5f)-1, 0.4f, const_cast<float *>(white), text, 0, 0, 0, 0 );
	}

}
/**
 * @param node The node to draw
 */
void uiMaterialEditorNode::draw (uiNode_t *node)
{
	int i;
	vec2_t pos;
	int cnt = 0;
	int cntView = 0;
	const int imagesPerLine = (node->box.size[0] - node->padding) / (IMAGE_WIDTH + node->padding);

	if (isSizeChange(node))
		updateView(node, false);

	/* width too small to display anything */
	if (imagesPerLine <= 0)
		return;

	UI_GetNodeAbsPos(node, pos);

	/* display images */
	for (i = 0; i < r_numImages; i++) {
		image_t *image = R_GetImageAtIndex(i);
		vec2_t imagepos;

#ifndef ANYIMAGES
		/* filter */
		if (image->type != it_world)
			continue;

		if (strstr(image->name, "tex_common"))
			continue;
#endif

		/* skip images before the scroll position */
		if (cnt / imagesPerLine < EXTRADATA(node).scrollY.viewPos) {
			cnt++;
			continue;
		}

		/** @todo do it incremental. Don't need all this math */
		imagepos[0] = pos[0] + node->padding + (cntView % imagesPerLine) * (IMAGE_WIDTH + node->padding);
		imagepos[1] = pos[1] + node->padding + (cntView / imagesPerLine) * (IMAGE_WIDTH + node->padding);

		/* vertical overflow */
		if (imagepos[1] + IMAGE_WIDTH + node->padding >= pos[1] + node->box.size[1])
			break;

		if (i == node->num) {
#define MARGIN 3
			UI_DrawRect(imagepos[0] - MARGIN, imagepos[1] - MARGIN, IMAGE_WIDTH + MARGIN * 2, IMAGE_WIDTH + MARGIN * 2, node->selectedColor, 2, 0xFFFF);
#undef MARGIN
		}

		UI_DrawNormImage(false, imagepos[0], imagepos[1], IMAGE_WIDTH, IMAGE_WIDTH, 0, 0, 0, 0, image);

		cnt++;
		cntView++;
	}
}
Ejemplo n.º 4
0
static void UI_EditorNodeHighlightNode (uiNode_t* node, const vec4_t color, bool displayAnchor)
{
	vec2_t pos;
	UI_GetNodeAbsPos(node, pos);

	UI_DrawRect(pos[0] - 1, pos[1] - 1, node->box.size[0] + 2, node->box.size[1] + 2, color, 1.0, 0x3333);

	if (displayAnchor) {
		UI_DrawFill(pos[0] - anchorSize, pos[1] - anchorSize, anchorSize, anchorSize, color);
		UI_DrawFill(pos[0] - anchorSize, pos[1] + node->box.size[1], anchorSize, anchorSize, color);
		UI_DrawFill(pos[0] + node->box.size[0], pos[1] + node->box.size[1], anchorSize, anchorSize, color);
		UI_DrawFill(pos[0] + node->box.size[0], pos[1] - anchorSize, anchorSize, anchorSize, color);
	}
}
void JKG_Slice_DrawSecurityClearance(int slot, float x, float y, float w, float h) {

	const char *text;

	float w2;

	if (slot >= sliceData.securityLevels) {
		UI_DrawRect(x, y, w, h, disabled);
		return;
	} else {
		switch (sliceData.securityState[slot])
		{
			case 0:
				UI_FillRect(x, y, w, h, red);
				break;
			case 1:
				UI_FillRect(x, y, w, h, orange);
				break;
			case 2:
				UI_FillRect(x, y, w, h, yellow);
				break;
			case 3:
				UI_FillRect(x, y, w, h, green);
				break;
		}

		UI_DrawRect(x, y, w, h, black);
	}


	text = va("%i", slot + 1);
	
	w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.5f;
	DC->drawText(x + (w/2) - (w2/2), y+(h*0.2f), 0.5f, const_cast<float *>(white), text, 0, 0, 0, 0 );

}
Ejemplo n.º 6
0
/*
=================
Menu_Draw
=================
*/
void Menu_Draw(menuframework_s* menu) {
    int             i;
    menucommon_s*    itemptr;

    // draw menu
    for (i = 0; i < menu->nitems; i++) {
        itemptr = (menucommon_s*)menu->items[i];

        if (itemptr->flags & QMF_HIDDEN)
            continue;

        if (itemptr->ownerdraw) {
            // total subclassing, owner draws everything
            itemptr->ownerdraw(itemptr);
        } else {
            switch (itemptr->type) {
                case MTYPE_RADIOBUTTON:
                    RadioButton_Draw((menuradiobutton_s*)itemptr);
                    break;

                case MTYPE_FIELD:
                    MenuField_Draw((menufield_s*)itemptr);
                    break;

                case MTYPE_SLIDER:
                    Slider_Draw((menuslider_s*)itemptr);
                    break;

                case MTYPE_SPINCONTROL:
                    SpinControl_Draw((menulist_s*)itemptr);
                    break;

                case MTYPE_ACTION:
                    Action_Draw((menuaction_s*)itemptr);
                    break;

                case MTYPE_BITMAP:
                    Bitmap_Draw((menubitmap_s*)itemptr);
                    break;

                case MTYPE_TEXT:
                    Text_Draw((menutext_s*)itemptr);
                    break;

                case MTYPE_SCROLLLIST:
                    ScrollList_Draw((menulist_s*)itemptr);
                    break;

                case MTYPE_PTEXT:
                    PText_Draw((menutext_s*)itemptr);
                    break;

                case MTYPE_BTEXT:
                    BText_Draw((menutext_s*)itemptr);
                    break;

                default:
                    trap_Error(va("Menu_Draw: unknown type %d", itemptr->type));
            }
        }
#ifndef NDEBUG
        if (uis.debug) {
            int x;
            int y;
            int w;
            int h;

            if (!(itemptr->flags & QMF_INACTIVE)) {
                x = itemptr->left;
                y = itemptr->top;
                w = itemptr->right - itemptr->left + 1;
                h = itemptr->bottom - itemptr->top + 1;

                if (itemptr->flags & QMF_HASMOUSEFOCUS) {
                    UI_DrawRect(x, y, w, h, colorYellow);
                } else {
                    UI_DrawRect(x, y, w, h, colorWhite);
                }
            }
        }
#endif
    }

    itemptr = Menu_ItemAtCursor(menu);
    if (itemptr && itemptr->statusbar)
        itemptr->statusbar((void*) itemptr);
}
Ejemplo n.º 7
0
//==========================================================================
// DD_Progress
//  Draws a progress bar. Flags consists of one or more PBARF_* flags.
//==========================================================================
void Con_Progress(int count, int flags)
{
	int     x, y, w, h, bor = 2, bar = 10;
	int     maxWidth = 500;
	int     mainBor = 5;
	int     fonthgt;

	if(!progress_active || isDedicated || !progress_enabled)
		return;

	if(flags & PBARF_SET)
		progress = count;
	else
		progress += count;

	// Make sure it's in range.
	if(progress < 0)
		progress = 0;
	if(progress > progress_max)
		progress = progress_max;

	// Update the startup window progress bar.
	SW_SetBarPos(progress);

	// If GL is not available, we cannot proceed any further.
	if(!GL_IsInited())
		return;

	if(flags & PBARF_DONTSHOW && progress < progress_max &&
	   progress_shown + 5 >= progress)
		return;					// Don't show yet.

	progress_shown = progress;

	if(!(flags & PBARF_NOBACKGROUND))
	{
		// This'll redraw the startup screen to this page (necessary
		// if page flipping is used by the display adapter).
		Con_DrawStartupScreen(false);

		// If we're in the User Interface, this'll redraw it.
		UI_Drawer();
	}

	fonthgt = FR_TextHeight("A");

	// Go into screen projection mode.
	gl.MatrixMode(DGL_PROJECTION);
	gl.PushMatrix();
	gl.LoadIdentity();
	// 1-to-1 mapping for the whole window.
	gl.Ortho(0, 0, screenWidth, screenHeight, -1, 1);

	// Calculate the size and dimensions of the progress window.
	w = screenWidth - 30;
	if(w < 50)
		w = 50;					// An unusual occurance...
	if(w > maxWidth)
		w = maxWidth;			// Restrict width to the case of 640x480.
	x = (screenWidth - w) / 2;	// Center on screen.
	h = 2 * bor + fonthgt + 15 + bar;
	y = screenHeight - 15 - h;

	/*x = 15;
	   w = screenWidth - 2*x;
	   h = 2*bor + fonthgt + 15 + bar;
	   y = screenHeight - 15 - h; */

	// Draw the (opaque black) shadow.
	UI_GradientEx(x, y, w, h, mainBor, UI_COL(UIC_SHADOW), 0, 1, 1);

	// Background.
	UI_GradientEx(x, y, w, h, mainBor, UI_COL(UIC_BG_MEDIUM),
				  UI_COL(UIC_BG_LIGHT), 1, 1);
	UI_DrawRect(x, y, w, h, mainBor, UI_COL(UIC_BRD_HI), 1);
	x += bor;
	y += bor;
	w -= 2 * bor;
	h -= 2 * bor;

	// Title.
	x += 5;
	y += 5;
	w -= 10;
	gl.Color4f(0, 0, 0, .5f);
	FR_TextOut(progress_title, x + 3, y + 3);
	gl.Color3f(1, 1, 1);
	FR_TextOut(progress_title, x + 1, y + 1);
	y += fonthgt + 5;

	// Bar.
	UI_GradientEx(x, y, w, bar, 4, UI_COL(UIC_SHADOW), 0, .7f, .3f);
	UI_GradientEx(x + 1, y + 1, 8 + (w - 8) * progress / progress_max - 2,
				  bar - 2, 4, UI_COL(UIC_BG_LIGHT), UI_COL(UIC_BRD_LOW),
				  progress / (float) progress_max, -1);
	UI_DrawRect(x + 1, y + 1, 8 + (w - 8) * progress / progress_max - 2,
				bar - 2, 4, UI_COL(UIC_TEXT), 1);

	// Show what was drawn.
	if(!(flags & PBARF_NOBLIT))
		gl.Show();

	// Restore old projection matrix.
	gl.MatrixMode(DGL_PROJECTION);
	gl.PopMatrix();
}
void JKG_Slice_DrawGridSlot(int slot, float x, float y, float w, float h)
{
	vec4_t color;
	vec4_t color2;

	int row = slot >> 3;
	int col = slot & 7;

	const char *text = NULL;
	float w2;

	if (row >= sliceData.height || col >= sliceData.width) {
		UI_DrawRect(x, y, w, h, disabled);
	} else {
		if (sliceData.grid[row][col].active) {
			// Determine the color to show
			switch (sliceData.grid[row][col].type) {
				case 0:	// Alarm node
					VectorCopy4M(red, color2);
					text = NULL;
					break;
				case 1:	// Relay node
					VectorCopy4M(orange, color2);
					text = NULL;
					break;
				case 2: // Reset node
					VectorCopy4M(yellow, color2);
					text = "R";
					break;
				case 3: // Access level 1
				case 4:	// Access level 2
				case 5:	// Access level 3
				case 6:	// Access level 4
				case 7: // Access level 5
					VectorCopy4M(green, color2);
					text = va("%i", sliceData.grid[row][col].type - 2);
					break;
			}

			if (sliceData.grid[row][col].revealTime) {
				float phase = (float)(trap->Milliseconds() - sliceData.grid[row][col].revealTime) / 250.0f;
				if (phase > 1.0f) phase = 1.0f;

				if (trap->Milliseconds() > sliceData.grid[row][col].revealTime + 250) {
					sliceData.grid[row][col].revealTime = 0;
				}

				LerpColor((float *)white, color2, color, phase);
				UI_FillRect(x, y, w, h, color);
				
				if (text) {
					color[0] = color[1] = color[2] = 1.0f;
					color[3] = phase;
					w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.4f;
					DC->drawText(x + (w/2) - (w2/2), y+(h*0.2f), 0.4f, color, text, 0, 0, 0, 0 );
				}
			} else {
				UI_FillRect(x, y, w, h, color2);
				if (text) {
					w2 = trap->R_Font_StrLenPixels(text, MenuFontToHandle(0), 1.0f) * 0.4f;
					DC->drawText(x + (w/2) - (w2/2), y+(h*0.2f), 0.4f, (float *)(white), text, 0, 0, 0, 0 );
				}
			}
		} else {
			if (sliceData.grid[row][col].blinkTime) {
				int delta = trap->Milliseconds() - sliceData.grid[row][col].blinkTime;
				float phase;
				if (delta > 2350) {	 // ~(7.5 * PI)*100, so the node blinks 4 times and stops when faded out
					sliceData.grid[row][col].blinkTime = 0;
				}

				phase = 0.5f + (sin((float)delta / 100.0f) * 0.5);

				if (sliceData.grid[row][col].blinkColor) {
					LerpColor((float *)offcolor, (float *)green, color, phase);
				} else {
					LerpColor((float *)offcolor, (float *)red, color, phase);
				}

				UI_FillRect(x, y, w, h, color);
			} else {
				if (sliceData.grid[row][col].marked) {
					if (sliceData.grid[row][col].marked == 1) {
						MAKERGBA(color, 0.3f, 0.3f, 1.0f, 0.7f + sin((float)trap->Milliseconds() / 150.0f) * 0.1f);
					} else {
						MAKERGBA(color, 1.0f, 0.3f, .3f, 0.7f + sin((float)trap->Milliseconds() / 150.0f) * 0.1f);
					}
					UI_FillRect(x, y, w, h, color);
				} else {
					UI_FillRect(x, y, w, h, offcolor);
				}
			}
		}

		if (sliceData.inputState == INPUTSTATE_AWAITINGNODE || (sliceData.inputState == INPUTSTATE_AWAITINGINACTIVENODE && !sliceData.grid[row][col].active)) {
			float phase = 0.7f + sin((float)trap->Milliseconds() / 150.0f) * 0.1f;
			MAKERGBA(color, phase, phase, phase, 1.0f);
			UI_DrawRect(x, y, w, h, color);
		} else {
			UI_DrawRect(x, y, w, h, black);
		}
	}
}