示例#1
0
文件: cg_window.c 项目: GenaSG/ET
// Main window-drawing handler
void CG_windowDraw(void)
{
	int h, x, y, i, j, milli, t_offset, tmp;
	cg_window_t *w;
	qboolean fCleanup = qfalse;
	// Gordon: FIXME, the limbomenu var no longer exists
	qboolean fAllowMV = (cg.snap != NULL && cg.snap->ps.pm_type != PM_INTERMISSION /*&& !cg.limboMenu*/);
	vec4_t *bg;
	vec4_t textColor, borderColor, bgColor;

	if(cg.winHandler.numActiveWindows == 0) {
		// Draw these for demoplayback no matter what
		CG_demoAviFPSDraw();
		CG_demoTimescaleDraw();
		return;
	}

	milli = trap_Milliseconds();
	memcpy(textColor, colorWhite, sizeof(vec4_t));

	// Mouse cursor position for MV highlighting (offset for cursor pointer position)
	// Also allow for swingcam toggling
	if(cg.mvTotalClients > 0 && fAllowMV) {
		CG_cursorUpdate();
	}

	for(i=0; i<cg.winHandler.numActiveWindows; i++) {
		w = &cg.winHandler.window[cg.winHandler.activeWindows[i]];

		if(!w->inuse || w->state == WSTATE_OFF) {
			fCleanup = qtrue;
			continue;
		}

		// Multiview rendering has its own handling

		if(w->effects & WFX_MULTIVIEW) {
			if(w != cg.mvCurrentMainview && fAllowMV) CG_mvDraw(w);
			continue;
		}

		if(w->effects & WFX_TEXTSIZING) {
			CG_windowNormalizeOnText(w);
			w->effects &= ~WFX_TEXTSIZING;
		}

		bg = ((w->effects & WFX_FLASH) && (milli % w->flashPeriod) > w->flashMidpoint) ? &w->colorBackground2 : &w->colorBackground;

		h = w->h;
		x = w->x;
		y = w->y;
		t_offset = milli - w->time;
		textColor[3] = 1.0f;
		memcpy(&borderColor, w->colorBorder, sizeof(vec4_t));
		memcpy(&bgColor, bg, sizeof(vec4_t));

		// TODO: Add in support for ALL scrolling effects
		if(w->state == WSTATE_START) {
			tmp = w->targetTime - t_offset;
			if(w->effects & WFX_SCROLLUP) {
				if(tmp > 0) {
					y += (480 - y) * tmp / w->targetTime;//(100 * tmp / w->targetTime) / 100;
				} else {
					w->state = WSTATE_COMPLETE;
				}
				
				w->curY = y;
			}
			if(w->effects & WFX_FADEIN) {
				if(tmp > 0) textColor[3] = (float)((float)t_offset / (float)w->targetTime);
				else w->state = WSTATE_COMPLETE;
			}
		} else if(w->state == WSTATE_SHUTDOWN) {
			tmp = w->targetTime - t_offset;
			if(w->effects & WFX_SCROLLUP) {
				if(tmp > 0) y = w->curY + (480 - w->y) * t_offset / w->targetTime;//(100 * t_offset / w->targetTime) / 100;
				if(tmp < 0 || y >= 480) {
					w->state = WSTATE_OFF;
					fCleanup = qtrue;
					continue;
				}
			}
			if(w->effects & WFX_FADEIN) {
				if(tmp > 0) {
					textColor[3] -= (float)((float)t_offset / (float)w->targetTime);
				} else {
					textColor[3] = 0.0f;
					w->state = WSTATE_OFF;
				}
			}
		}

		borderColor[3] *= textColor[3];
		bgColor[3] *= textColor[3];

		CG_FillRect(x, y, w->w, h, bgColor);
		CG_DrawRect(x, y, w->w, h, 1, borderColor);

		x += 5;
		y -= (w->effects & WFX_TRUETYPE) ? 3 : 0;

		for(j=w->lineCount-1; j>=0; j--) {
			if(w->effects & WFX_TRUETYPE) {
//				CG_Text_Paint(x, y + h, w->fontScale, textColor, (char*)w->lineText[j], 0.0f, 0, 0);
				CG_Text_Paint_Ext(x, y + h, w->fontScaleX, w->fontScaleY, textColor,
								  (char*)w->lineText[j], 0.0f, 0, 0, &cgs.media.limboFont2);
			}

			h -= (w->lineHeight[j] + 3);

			if(!(w->effects & WFX_TRUETYPE)) {
				CG_DrawStringExt2(x, y + h, (char*)w->lineText[j], textColor,
								  qfalse, qtrue, w->fontWidth, w->fontHeight, 0);
			}
		}
	}

	// Wedge in MV info overlay
	if(cg.mvTotalClients > 0 && fAllowMV) CG_mvOverlayDisplay();

	// Extra rate info
	CG_demoAviFPSDraw();
	CG_demoTimescaleDraw();

	// Mouse cursor lays on top of everything
	if(cg.mvTotalClients > 0 && cg.time < cgs.cursorUpdate && fAllowMV) {
		//CG_DrawPic(cgs.cursorX - CURSOR_OFFSETX, cgs.cursorY - CURSOR_OFFSETY, 32, 32, cgs.media.cursor);
		CG_DrawPic( cgDC.cursorx, cgDC.cursory, 32, 32, cgs.media.cursorIcon );
	}

	if(fCleanup) {
		CG_windowCleanup();
	}
}
示例#2
0
文件: cg_window.c 项目: ETrun/ETrun
// Main window-drawing handler
void CG_windowDraw(void) {
    int         h, x, y, i, j, milli, t_offset, tmp;
    cg_window_t *w;
    qboolean    fCleanup = qfalse;
    // Gordon: FIXME, the limbomenu var no longer exists
    vec4_t *bg;
    vec4_t textColor, borderColor, bgColor;

    if (cg.winHandler.numActiveWindows == 0) {
        // Draw these for demoplayback no matter what
        CG_demoAviFPSDraw();
        CG_demoTimescaleDraw();
        return;
    }

    milli = trap_Milliseconds();
    memcpy(textColor, colorWhite, sizeof (vec4_t));

    // Mouse cursor position for MV highlighting (offset for cursor pointer position)
    // Also allow for swingcam toggling
    for (i = 0; i < cg.winHandler.numActiveWindows; ++i) {
        w = &cg.winHandler.window[cg.winHandler.activeWindows[i]];

        if (!w->inuse || w->state == WSTATE_OFF) {
            fCleanup = qtrue;
            continue;
        }

        if (w->effects & WFX_TEXTSIZING) {
            CG_windowNormalizeOnText(w);
            w->effects &= ~WFX_TEXTSIZING;
        }

        bg = ((w->effects & WFX_FLASH) && (milli % w->flashPeriod) > w->flashMidpoint) ? &w->colorBackground2 : &w->colorBackground;

        h            = w->h;
        x            = w->x;
        y            = w->y;
        t_offset     = milli - w->time;
        textColor[3] = 1.0f;
        memcpy(&borderColor, w->colorBorder, sizeof (vec4_t));
        memcpy(&bgColor, bg, sizeof (vec4_t));

        // TODO: Add in support for ALL scrolling effects
        if (w->state == WSTATE_START) {
            tmp = w->targetTime - t_offset;
            if (w->effects & WFX_SCROLLUP) {
                if (tmp > 0) {
                    y += (480 - y) * tmp / w->targetTime;
                } else {
                    w->state = WSTATE_COMPLETE;
                }

                w->curY = y;
            }
            if (w->effects & WFX_FADEIN) {
                if (tmp > 0) {
                    textColor[3] = (float)((float)t_offset / (float)w->targetTime);
                } else {
                    w->state = WSTATE_COMPLETE;
                }
            }
        } else if (w->state == WSTATE_SHUTDOWN) {
            tmp = w->targetTime - t_offset;
            if (w->effects & WFX_SCROLLUP) {
                if (tmp > 0) {
                    y = w->curY + (480 - w->y) * t_offset / w->targetTime;
                }
                if (tmp < 0 || y >= 480) {
                    w->state = WSTATE_OFF;
                    fCleanup = qtrue;
                    continue;
                }
            }
            if (w->effects & WFX_FADEIN) {
                if (tmp > 0) {
                    textColor[3] -= (float)((float)t_offset / (float)w->targetTime);
                } else {
                    textColor[3] = 0.0f;
                    w->state     = WSTATE_OFF;
                }
            }
        }

        borderColor[3] *= textColor[3];
        bgColor[3]     *= textColor[3];

        CG_FillRect(x, y, w->w, h, bgColor);
        CG_DrawRect(x, y, w->w, h, 1, borderColor);

        x += 5;
        y -= (w->effects & WFX_TRUETYPE) ? 3 : 0;

        for (j = w->lineCount - 1; j >= 0; --j) {
            if (w->effects & WFX_TRUETYPE) {
                CG_Text_Paint_Ext(x, y + h, w->fontScaleX, w->fontScaleY, textColor,
                                  (char *)w->lineText[j], 0.0f, 0, 0, &cgs.media.limboFont2);
            }

            h -= (w->lineHeight[j] + 3);

            if (!(w->effects & WFX_TRUETYPE)) {
                CG_DrawStringExt2(x, y + h, (char *)w->lineText[j], textColor,
                                  qfalse, qtrue, w->fontWidth, w->fontHeight, 0);
            }
        }
    }

    // Extra rate info
    CG_demoAviFPSDraw();
    CG_demoTimescaleDraw();

    if (fCleanup) {
        CG_windowCleanup();
    }
}