예제 #1
0
void CToolboxApplication::PostInit()
{
	SAFE_DELETE(m_pStartupSplash);

	IFFont *pRobotoFont = gEnv->pCryFont->NewFont("roboto");
	if(!pRobotoFont->Load("Fonts/roboto.xml"))
	{
		CryMessageBox("Failed to load Roboto font!", "Roboto font load failed!!", 0);
	}

	SetupDefaultStyle();
	//SetupDarkStyle();

	RECT workAreaRect;
	SystemParametersInfo(SPI_GETWORKAREA, 0, &workAreaRect, 0);

	int width = workAreaRect.right - workAreaRect.left;
	int height = workAreaRect.bottom - workAreaRect.top;

	m_pMainWindow = static_cast<CMainWindow *>(m_pWindowManager->SpawnWindow("MainWindow", "CryENGINE Community Toolbox", width, height, 0, 0));

	StartGameContext(true);

	m_bInitialized = true;

	Redraw();

	Run();
}
예제 #2
0
int CryWatchFunc(const char *message)
{
	// Fran: we need these guards for the testing framework to work
	if(gEnv && gEnv->pRenderer && g_pGameCVars && g_pGameCVars->watch_enabled)
	{
		float color[4] = {1,1,1,1};
		IFFont *pFont = gEnv->pCryFont->GetFont("default");
		float xscale = g_pGameCVars->watch_text_render_size*g_pGameCVars->watch_text_render_fxscale;
		STextDrawContext ctx;
		ctx.SetSize(Vec2(xscale, xscale));
		float width = pFont->GetTextSize(message, true, ctx).x;

		if(width>s_max_width_this_col)
			s_max_width_this_col = width;

		float yPos = GetWatchTextYPos(); // also updates s_watchTextXPos
		gEnv->pRenderer->Draw2dLabel(g_pGameCVars->watch_text_render_start_pos_x+s_watchTextXPos, yPos, g_pGameCVars->watch_text_render_size, color, false, "%s", message);
		return 1;
	}

	return 0;
}
예제 #3
0
void CPersistantDebug::UpdateTags(float frameTime, SObj& obj, bool doFirstPass)
{
    if (!doFirstPass)
    {
        // Every update calls itself recursively first to calculate the widths of each column
        // for multicolumn mode. Not the prettiest thing, but it's the best idea I've got so far!
        UpdateTags(frameTime, obj, true);
        frameTime = 0.f;

        for (int i=0; i<obj.columns.size(); ++i)
            obj.columns[i].height = 0.f;
    }

    IFFont *pFont = gEnv->pCryFont->GetFont("default");
    assert(pFont);
    STextDrawContext ctx;
    ctx.SetSizeIn800x600(false);
    ctx.SetProportional(true);

    for (TListTag::iterator iterList = obj.tags.begin(); iterList != obj.tags.end(); ++iterList)
    {
        if (iterList->vScreenPos.IsZero())
            continue;

        float tagMaxDist = iterList->params.viewDistance;
        float fontSize = iterList->params.size * m_pETFontSizeMultiplier->GetFVal();

        // Calculate size of text on screen (so we can place it properly)
        ctx.SetSize(Vec2(12*fontSize, 12*fontSize));
        Vec2 textBoxSize = pFont->GetTextSize(iterList->params.text.c_str(), true, ctx);

        if (doFirstPass)
        {
            int pos(iterList->params.column - 1);
            obj.columns[pos].width = max(obj.columns[pos].width, textBoxSize.x + 15.f);
        }
        else
        {
            // Determine position
            SColumn &column = obj.columns[iterList->params.column - 1];
            Vec3 screenPos(iterList->vScreenPos);
            screenPos.x = screenPos.x*0.01f*gEnv->pRenderer->GetWidth();
            screenPos.y = screenPos.y*0.01f*gEnv->pRenderer->GetHeight() - textBoxSize.y - column.height;
            column.height += textBoxSize.y;

            // Adjust X value for multi-columns
            if (obj.columns.size() > 1)
            {
                int centerLine = obj.columns.size() / 2;
                if (iterList->params.column <= centerLine)
                    for (int i=iterList->params.column-1; i<centerLine; ++i)
                        screenPos.x -= obj.columns[i].width;
                else
                    for (int i=centerLine; i<iterList->params.column-1; ++i)
                        screenPos.x += obj.columns[i].width;

                if (obj.columns.size() % 2 != 0)
                    screenPos.x -= textBoxSize.x*0.5f;
            }
            else
            {
                screenPos.x -= textBoxSize.x*0.5f;
            }

            // Determine color
            ColorF clr = iterList->params.color;
            if (1==m_pETColorOverrideEnable->GetIVal())
            {
                clr.r = max(0.f, min(1.f, m_pETColorOverrideR->GetFVal()));
                clr.g = max(0.f, min(1.f, m_pETColorOverrideG->GetFVal()));
                clr.b = max(0.f, min(1.f, m_pETColorOverrideB->GetFVal()));
            }
            clr.a *= iterList->params.fadeTime / iterList->totalFadeTime; // Apply fade out time to alpha

            float clrAry[4] = {clr.r, clr.g, clr.b, clr.a};
            gEnv->pRenderer->Draw2dLabel( screenPos.x, screenPos.y, fontSize, clrAry, true, "%s", iterList->params.text.c_str() );
        }
    }
}