コード例 #1
0
void CConsole::DrawHistory()
{
	int i = 1;

	std::deque<std::wstring>::iterator Iter; //History iterator

	CScopeLock lock(m_Mutex); // needed for safe access to m_deqMsgHistory

	glPushMatrix();
		glColor3f(1.0f, 1.0f, 1.0f); //Set color of text
		glTranslatef(9.0f, (float)m_iFontOffset, 0.0f); //move away from the border

		// Draw the text upside-down, because it's aligned with
		// the GUI (which uses the top-left as (0,0))
		glScalef(1.0f, -1.0f, 1.0f);

		for (Iter = m_deqMsgHistory.begin();
			 Iter != m_deqMsgHistory.end()
				 && (((i - m_iMsgHistPos + 1) * m_iFontHeight) < m_fHeight);
			 Iter++)
		{
			if (i >= m_iMsgHistPos){
				glTranslatef(0.0f, -(float)m_iFontHeight, 0.0f);

				glPushMatrix();
					glwprintf(L"%ls", Iter->c_str());
				glPopMatrix();
			}

			i++;
		}
	glPopMatrix();
}
コード例 #2
0
ファイル: Scarry-Draw.cpp プロジェクト: msakuta/VastSpace
void GLWdock::draw(GLwindowState &ws, double t){
	typedef Entity::Dockable Dockable;
	int ix;
	if(!docker)
		return;
	GLWrect cr = clientRect();
	glColor4ub(255,255,255,255);
	glwpos2d(cr.x0, cr.y0 + 1 * getFontHeight());
	glwprintf("Resource Units: %.0lf", docker->e->getRU());
	glColor4ub(255,255,0,255);
	int fonth = getFontHeight();
	int iy = 0;

	if(!docker)
		return;
	glColor4ub(255,255,255,255);
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Cool: %lg", docker->baycool);
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Remain docked: %s", docker->remainDocked ? "Yes" : "No");
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Grouping: %s", grouping ? "Yes" : "No");
	glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
	glwprintf("Docked:");
	glColor4ub(255,255,255,255);

	int mx = ws.mx - cr.x0, my = ws.my - cr.y0;
	/* Mouse cursor highlights */
	if(!modal && 0 < mx && mx < width && (iy - 2 <= my / fonth && my / fonth <= iy - 1 || (1 + iy) * fonth < my)){
		glColor4ub(0,0,255,127);
		glRecti(cr.x0, cr.y0 + (my / fonth) * fonth, cr.x1, cr.y0 + (my / fonth + 1) * fonth);
		glColor4ub(255,255,255,255);
	}

	if(grouping){
		std::map<cpplib::dstring, int> map;

		for(WarField::EntityList::iterator it = docker->el.begin(); it != docker->el.end(); it++) if(*it){
			Entity *e = (*it)->toDockable();
			if(e)
				map[e->dispname()]++;
		}
		for(std::map<cpplib::dstring, int>::iterator it = map.begin(); it != map.end(); it++){
			glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
			glwprintf("%d X %s", it->second, (const char*)it->first);
		}
	}
	else{
		for(WarField::EntityList::iterator it = docker->el.begin(); it != docker->el.end(); it++) if(*it){
			Entity *e = (*it)->toDockable();
			if(!e)
				continue;
			if(height < (2 + iy) * fonth)
				return;
			glwpos2d(cr.x0, cr.y0 + (2 + iy++) * fonth);
			glwprintf("%d X %s %lg m^3", 1, e->dispname(), e->getHitRadius() * e->getHitRadius() * e->getHitRadius());
		}
	}
}
コード例 #3
0
//Renders the buffer to the screen.
void CConsole::DrawBuffer(void)
{
	if (m_fHeight < m_iFontHeight) return;

	glPushMatrix();
		glColor3f(1.0f, 1.0f, 0.0f);
		glTranslatef(2.0f, (float)m_iFontOffset, 0);
		glScalef(1.0f, -1.0f, 1.0f);

		glwprintf(L"]");

		glColor3f(1.0f, 1.0f, 1.0f);
		if (m_iBufferPos==0) DrawCursor();

		for (int i = 0; i < m_iBufferLength; i++){
				glwprintf(L"%lc", m_szBuffer[i]);
				if (m_iBufferPos-1==i) DrawCursor();
		}
	glPopMatrix();
}
コード例 #4
0
void CConsole::DrawCursor(void)
{
	// (glPushMatrix is necessary because glwprintf does glTranslatef)
	glPushMatrix();
		// Slightly translucent yellow
		glColor4f(1.0f, 1.0f, 0.0f, 0.8f);

		// Cursor character is chosen to be an underscore
		glwprintf(L"_");

		// Revert to the standard text colour
		glColor3f(1.0f, 1.0f, 1.0f);
	glPopMatrix();
}
コード例 #5
0
ファイル: ProfileViewer.cpp プロジェクト: Marlinc/0ad
// Render
void CProfileViewer::RenderProfile()
{
    if (!m->profileVisible)
        return;

    if (!m->path.size())
    {
        m->profileVisible = false;
        return;
    }

    PROFILE3_GPU("profile viewer");

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    AbstractProfileTable* table = m->path[m->path.size() - 1];
    const std::vector<ProfileColumn>& columns = table->GetColumns();
    size_t numrows = table->GetNumberRows();

    CFont font(L"mono-stroke-10");
    font.Bind();
    int lineSpacing = font.GetLineSpacing();

    // Render background
    GLint estimate_height;
    GLint estimate_width;

    estimate_width = 50;
    for(size_t i = 0; i < columns.size(); ++i)
        estimate_width += (GLint)columns[i].width;

    estimate_height = 3 + (GLint)numrows;
    if (m->path.size() > 1)
        estimate_height += 2;
    estimate_height = lineSpacing*estimate_height;

    glDisable(GL_TEXTURE_2D);
    glColor4ub(0,0,0,128);
    glBegin(GL_QUADS);
    glVertex2i(estimate_width, g_yres);
    glVertex2i(0, g_yres);
    glVertex2i(0, g_yres-estimate_height);
    glVertex2i(estimate_width, g_yres-estimate_height);
    glEnd();
    glEnable(GL_TEXTURE_2D);

    // Print table and column titles
    glPushMatrix();
    glTranslatef(2.0f, g_yres - lineSpacing, 0.0f );
    glScalef(1.0f, -1.0f, 1.0f);
    glColor3ub(255, 255, 255);

    glPushMatrix();
    glwprintf(L"%hs", table->GetTitle().c_str());
    glPopMatrix();
    glTranslatef( 20.0f, lineSpacing, 0.0f );

    glPushMatrix();
    for(size_t col = 0; col < columns.size(); ++col)
    {
        CStr text = columns[col].title;
        int w, h;
        font.CalculateStringSize(text.FromUTF8(), w, h);
        glPushMatrix();
        if (col > 0) // right-align all but the first column
            glTranslatef(columns[col].width - w, 0, 0);
        glwprintf(L"%hs", text.c_str());
        glPopMatrix();
        glTranslatef(columns[col].width, 0, 0);
    }
    glPopMatrix();
    glTranslatef( 0.0f, lineSpacing, 0.0f );

    // Print rows
    int currentExpandId = 1;

    for(size_t row = 0; row < numrows; ++row)
    {
        glPushMatrix();

        glDisable(GL_TEXTURE_2D);
        if (row % 2)
            glColor4ub(255, 255, 255, 16);
        else
            glColor4ub(0, 0, 0, 16);
        glBegin(GL_QUADS);
        glVertex2i(-22.f, 2.f);
        glVertex2i(estimate_width-22.f, 2.f);
        glVertex2i(estimate_width-22.f, 2.f-lineSpacing);
        glVertex2i(-22.f, 2.f-lineSpacing);
        glEnd();
        glEnable(GL_TEXTURE_2D);

        if (table->IsHighlightRow(row))
            glColor3ub(255, 128, 128);
        else
            glColor3ub(255, 255, 255);

        if (table->GetChild(row))
        {
            glPushMatrix();
            glTranslatef( -15.0f, 0.0f, 0.0f );
            glwprintf(L"%d", currentExpandId);
            glPopMatrix();
            currentExpandId++;
        }

        for(size_t col = 0; col < columns.size(); ++col)
        {
            CStr text = table->GetCellText(row, col);
            int w, h;
            font.CalculateStringSize(text.FromUTF8(), w, h);
            glPushMatrix();
            if (col > 0) // right-align all but the first column
                glTranslatef(columns[col].width - w, 0, 0);
            glwprintf(L"%hs", text.c_str());
            glPopMatrix();
            glTranslatef(columns[col].width, 0, 0);
        }

        glPopMatrix();
        glTranslatef( 0.0f, lineSpacing, 0.0f );
    }
    glColor3ub(255, 255, 255);

    if (m->path.size() > 1)
    {
        glTranslatef( 0.0f, lineSpacing, 0.0f );
        glPushMatrix();
        glPushMatrix();
        glTranslatef( -15.0f, 0.0f, 0.0f );
        glwprintf( L"0" );
        glPopMatrix();
        glwprintf( L"back to parent" );
        glPopMatrix();
    }

    glPopMatrix();

    glDisable(GL_BLEND);
}