Ejemplo n.º 1
0
void Effect::Render(const position_t *pos, bool overlayed) {
    switch (effecttype) {
        case MAGICEFFECT:
            if (!overlayed) Thing::Render();
            break;
        case TEXT:
            glColor4f(textcolor.r, textcolor.g, textcolor.b, textcolor.a);
            glRotatef(180,1,0,0);
            if (overlayed) glictFontRender(text.c_str(), "system", 16 - glictFontSize(text.c_str(), "system")/2., -64);
            glRotatef(180,1,0,0);
            glColor4f(1., 1., 1., 1.);
            break;
        case ANIMATEDTEXT:
            glColor4f(textcolor.r, textcolor.g, textcolor.b, textcolor.a);
            glRotatef(180,1,0,0);
            if (overlayed) glictFontRender(text.c_str(), "system", 0, -64-animationpercent/3.);
            glRotatef(180,1,0,0);
            glColor4f(1., 1., 1., 1.);
            break;
		case DISTANCESHOT: {

			glTranslatef((distdelta.x*animationpercent/100.  * 32.), -(distdelta.y*animationpercent/100. * 32.), 0);


			position_t p;


			if (distdelta.x < 0) p.x = 0;
			if (distdelta.x == 0) p.x = 1;
			if (distdelta.x > 0) p.x = 2;

			if (distdelta.y < 0) p.y = 0;
			if (distdelta.y == 0) p.y = 1;
			if (distdelta.y > 0) p.y = 2;

			if (overlayed) {
				sprgfx->Render(&p);
				//std::stringstream s;
				//s << (distdelta.x*animationpercent/100.*32.) << " " << (distdelta.y*animationpercent/100.*32.) << " - " << distdelta.x << "x" << distdelta.y << " => " << animationpercent/100.;
				//console.insert(s.str());
				//printf("%s\n", s.str().c_str());

			}


			break;
		}
        default:
            printf("Still don't know how to render this magic effect\n");
    }
}
Ejemplo n.º 2
0
void Engine::drawText(const char* text, const char* font, int x, int y, oRGBA color)
{
    YATCFont *f = (YATCFont*)(glictFindFont(font)->GetFontParam());
	if (f)
	{
        if (color.r == color.g && color.g == color.b && color.b == 1.)
        {
            f->resetColor();
        }
        else
        {
            f->addColor(color.r/255, color.g/255, color.b/255);
        }
    }
    glictFontRender(text, font, x, y);
}
Ejemplo n.º 3
0
void Engine::drawText(const char* text, const char* font, int x, int y, uint8_t color)
{
	YATCFont *f = (YATCFont*)(glictFindFont(font)->GetFontParam());
	if (f)
    {
        float r = (color / 36) / 5.;
        float g = ((color / 6) % 6) / 5.;
        float b = (color % 6) / 5.;

        if (color == 255) // we'll just use otherwise useless 255 for drawing with 0.75, 0.75, 0.75 if needed
            f->addColor(0.75, 0.75, 0.75);
        else if (color!=215)
            f->addColor(r,g,b);
        else
            f->resetColor();
    }
    glictFontRender(text, font, x, y);
}
Ejemplo n.º 4
0
void Engine::drawTextGW(const char* text, const char* font, int x, int y, float scale, oRGBA color)
{
    // NOTE (nfries88): keeps all rendering in the game area.
    //x = std::min(std::max(1, x), (m_width - 176) - (int)sizeText(text, font));
    //y = std::max(1, y);

    YATCFont *f = (YATCFont*)(glictFindFont(font)->GetFontParam());
	if (f)
    {
        if (color.r == color.g && color.g == color.b && color.b == 1.)
        {
            f->resetColor();
        }
        else
        {
            f->addColor(color.r/255, color.g/255, color.b/255);
        }
    }

    std::string temp_text = text;
    std::string new_line_text, old_line_text;
    new_line_text = old_line_text = temp_text;
    int linecount = 1;
    size_t iter_pos, temp_x, temp_y;

    // NOTE (Kilouco): Here we centralize all the message and handle positions so it will never go offscreen.
    while (1) {
        iter_pos = old_line_text.find_first_of("\n");
        temp_x = x;
        temp_y = y;

        if(iter_pos == std::string::npos || iter_pos <= 0) {
            int text_size = sizeText(old_line_text.c_str(), font);
            volatile float centralizationoffset =  text_size / 2;
            if (temp_x + centralizationoffset > (480 * scale) + 2)
                temp_x = (480 * scale - 2) - text_size;
            else if (x - centralizationoffset < 2)
                temp_x = 2;
            else
                temp_x -= centralizationoffset;

            if (temp_y < 2)
                temp_y = 2;

            glictFontRender(old_line_text.c_str(), font, temp_x, temp_y + (12 * (linecount - 1)));
            break;
        }
        else {
            new_line_text = old_line_text.substr(iter_pos+1);
            old_line_text.resize(iter_pos);
            int text_size = sizeText(old_line_text.c_str(), font);
            volatile float centralizationoffset =  text_size / 2;
            if (temp_x + centralizationoffset > (480 * scale) + 2)
                temp_x = (480 * scale - 2) - text_size;
            else if (x - centralizationoffset < 2)
                temp_x = 2;
            else
                temp_x -= centralizationoffset;

            if (temp_y < 2)
                temp_y = 2;

            glictFontRender(old_line_text.c_str(), font, temp_x, temp_y + (12 * (linecount - 1)));
            old_line_text = new_line_text;
            linecount++;
        }
    }
}
Ejemplo n.º 5
0
void Engine::drawTextGW(const char* text, const char* font, int x, int y, float scale, uint8_t color)
{
    // NOTE (nfries88): keeps all rendering in the game area.
    //x = std::min(std::max(1, x), (m_width - 176) - (int)sizeText(text, font)); // NOTE (Kilouco): Doesn't works this way anymore.
    //y = std::max(1, y);

	YATCFont *f = (YATCFont*)(glictFindFont(font)->GetFontParam());
    if (f)
    {
        float r = (color / 36) / 5.;
        float g = ((color / 6) % 6) / 5.;
        float b = (color % 6) / 5.;

        if (color == 255) // we'll just use otherwise useless 255 for drawing with 0.75, 0.75, 0.75 if needed
            f->addColor(0.75, 0.75, 0.75);
        else if (color!=215)
            f->addColor(r,g,b);
        else
            f->resetColor();
    }

    std::string temp_text = text;
    std::string new_line_text, old_line_text;
    new_line_text = old_line_text = temp_text;
    int linecount = 1;
    size_t iter_pos, temp_x, temp_y;

    // NOTE (Kilouco): Here we centralize all the message and handle positions so it will never go offscreen.
    while (1) {
        iter_pos = old_line_text.find_first_of("\n");
        temp_x = x;
        temp_y = y;

        if(iter_pos == std::string::npos || iter_pos <= 0) {
            int text_size = sizeText(old_line_text.c_str(), font);
            volatile float centralizationoffset =  text_size / 2;
            if (temp_x + centralizationoffset > (480 * scale) + 2)
                temp_x = (480 * scale - 2) - text_size;
            else if (x - centralizationoffset < 2)
                temp_x = 2;
            else
                temp_x -= centralizationoffset;

            if (temp_y < 2)
                temp_y = 2;

            glictFontRender(old_line_text.c_str(), font, temp_x, temp_y + (12 * (linecount - 1)));
            break;
        }
        else {
            new_line_text = old_line_text.substr(iter_pos+1);
            old_line_text.resize(iter_pos);
            int text_size = sizeText(old_line_text.c_str(), font);
            volatile float centralizationoffset =  text_size / 2;
            if (temp_x + centralizationoffset > (480 * scale) + 2)
                temp_x = (480 * scale - 2) - text_size;
            else if (x - centralizationoffset < 2)
                temp_x = 2;
            else
                temp_x -= centralizationoffset;

            if (temp_y < 2)
                temp_y = 2;

            glictFontRender(old_line_text.c_str(), font, temp_x, temp_y + (12 * (linecount - 1)));
            old_line_text = new_line_text;
            linecount++;
        }
    }
}
Ejemplo n.º 6
0
void Creature::RenderOverlay() {
	bool wasmoving = false;
    if (moving) {
		wasmoving = true;
        glPushMatrix();
        CauseAnimOffset(true);

    }
    if (sprgfx->sli.unknown>1) // FIXME (Khaos#3#) ==9414== Conditional jump or move depends on uninitialised value(s)
		glTranslatef(-(sprgfx->sli.width-1)*32, (sprgfx->sli.height-1)*32, 0);
    glColor3f(.3, .3, .3);
    glBegin(GL_QUADS);
    glVertex2f(0 - 8, 32+11 + 8);
    glVertex2f( 32 - 8, 32+11 + 8);
    glVertex2f( 32 - 8 , 32+16 + 8);
    glVertex2f(0 - 8, 32+16 + 8);
    glEnd();

    if (hp >= 50.0) {
        glColor3f(  (50. / hp), hp / 50. , 0.);
    } else {
        glColor3f(  1., hp / 50. , 0.);
    }
    glBegin(GL_QUADS);
    glVertex2f(0 - 8, 32+11 + 8);
    glVertex2f(hp * 32 / 100 - 8, 32+11 + 8);
    glVertex2f(hp * 32 / 100 - 8, 32+16 + 8);
    glVertex2f(0 - 8, 32+16 + 8);
    glEnd();

	glRotatef(180,1,0,0);
    glictFontRender(GetName().c_str(), "system", -8, -32 - 10- 8);
    glRotatef(180,1,0,0);

    /*{
	glRotatef(180,1,0,0);
	std::stringstream nargh;
	nargh << this->GetCreatureID();
    glictFontRender(nargh.str().c_str(), "system", -8, -32 - 20- 8);
    glRotatef(180,1,0,0);
    }*/


    if (this->skull) {
        texSkull->Bind();
        switch (this->skull) {
            case SKULL_YELLOW:
                glColor4f(1., 1., 0., 1.);
                break;
            case SKULL_GREEN:
                glColor4f(0., 1., 0., 1.);
                break;
            case SKULL_WHITE:
                glColor4f(1., 1., 1., 1.);
                break;
            case SKULL_RED:
                glColor4f(1., 0., 0., 1.);
                break;
            default:
                glColor4f(.4, .4, .4, 1.);
                break;
        }
        glEnable(GL_TEXTURE_2D);
        StillEffect(32-8-8, 32, 32-8, 32+8, 10, 10, false, false, true);

        glDisable(GL_TEXTURE_2D);
    }
	if (sprgfx->sli.unknown>1) glTranslatef((sprgfx->sli.width-1)*32, -(sprgfx->sli.height-1)*32, 0);
    glColor4f(1.,1.,1.,1.);
    if (wasmoving) glPopMatrix();

}