コード例 #1
0
void BuddyPlayer::draw(Graphics::Bitmap * work, int rel_x, int rel_y){
    Character::draw(work, rel_x, rel_y);

    int x1, y1;
    NamePlacer::getPlacement(x1, y1, name_id);

    if (icon){
        icon->draw(x1, y1, *work);
    }

    int hasIcon = icon ? icon->getWidth() : 0;

    if (show_life < 0){
        show_life = 0;
    }

    const Font & player_font = Font::getDefaultFont(20, 20);
    const string & name = getName();
    int nameHeight = player_font.getHeight(name) / 2;
    nameHeight = 20 / 2;
    FontRender * render = FontRender::getInstance();
    render->addMessage(player_font, (hasIcon + x1) * 2, y1 * 2, Graphics::makeColor(255,255,255), Graphics::MaskColor(), name);
    drawLifeBar(hasIcon + x1, y1 + nameHeight, work);
    // int max = getMaxHealth() < 100 ? getMaxHealth() : 100;
    // render->addMessage( player_font, (x1 + hasIcon + max + 5) * 2, y1 + nameHeight, Bitmap::makeColor(255,255,255), -1, "x %d", getLives() );

}
コード例 #2
0
ファイル: chat-widget.cpp プロジェクト: marstau/shinsango
void ChatWidget::drawChat(Graphics::Bitmap * work, int start){
    const Font & font = Font::getDefaultFont(18, 18);
    FontRender * render = FontRender::getInstance();

    // int y = work->getHeight() * 2 - 1 - font.getHeight() * 2 - 1;
    int y = start - font.getHeight();

    if (chatInput.isEnabled()){
        const Graphics::Color green = Graphics::makeColor(0, 255, 0);
        // render->addMessage(font, 1, y, green, -1, string("Say: ") + chatInput.getText());
        render->addMessage(font, 1, y, Graphics::makeColor(255, 255, 0), Graphics::MaskColor(), string("Say: "));
        render->addMessage(font, 1 + font.textLength("Say: "), y, green, Graphics::MaskColor(), chatInput.getText());
        y -= font.getHeight() + 1;
    }

    for (deque<Message>::reverse_iterator it = chatMessages.rbegin(); it < chatMessages.rend(); it++){
        const Message & message = *it;
        int trans = message.life;
        if (trans < 255){
            render->addMessage(font, 1, y, Graphics::makeColor(255, 255, 255), Graphics::MaskColor(), trans, message.text);
        } else {
            render->addMessage(font, 1, y, Graphics::makeColor(255, 255, 255), Graphics::MaskColor(), message.text);
        }
        y -= font.getHeight() + 1;
    }
}
コード例 #3
0
ファイル: player.cpp プロジェクト: boyjimeking/paintown
void Player::drawFront(Graphics::Bitmap * work, int rel_x){

	int x1, y1;
	NamePlacer::getPlacement(x1, y1, name_id);
	
	if ( icon )
		icon->draw( x1, y1, *work );

	int hasIcon = icon ? icon->getWidth() : 0;

	if ( show_life < 0 ){
		show_life = 0;
	}

        /* TODO: make 'show_buttons' an option somewhere */
        bool show_buttons = false;
        if (show_buttons){
            drawButtons(work, 5, work->getHeight() - 5);
        }

	// Font * player_font = FontFactory::getFont( NAME_FONT );
	// const Font & player_font = Font::getFont( NAME_FONT );
	const Font & player_font = Font::getDefaultFont(20, 20 );
	const string & name = getName();
	int nameHeight = player_font.getHeight(name) / 2;
	nameHeight = 20 / 2;
	// cout << "Height: " << player_font.getHeight( name ) << endl;
	// Font * player_font = FontFactory::getFont( "bios" );

	// work->printf( ky + x1, y1, Bitmap::makeColor(255,255,255), player_font, getName() );
	FontRender * render = FontRender::getInstance();
	render->addMessage( player_font, (hasIcon + x1) * 2, y1 * 2, Graphics::makeColor(255,255,255), Graphics::MaskColor(), name );

        ostringstream score_s;
        score_s << getScore();
        int attack_color = (int)(attack_bonus * 10);
        if (attack_color > num_attack_gradient - 1){
            attack_color = num_attack_gradient - 1;
        }

        // int attack_x = (hasIcon + x1) * 2 + player_font.textLength(name.c_str()) + 5;
        int attack_x = (int)((hasIcon + x1) * 2 + 100 * Graphics::Bitmap::getScale() - player_font.textLength(score_s.str().c_str()));

        render->addMessage(player_font, attack_x, y1 * 2, attack_gradient[attack_color], Graphics::MaskColor(), score_s.str().c_str());

	// cout << "Draw name at " << y1 * 2 << endl;
	// player_font.printf( (hasIcon + x1) * 2, y1, Bitmap::makeColor(255,255,255), *work, getName() );
	// drawLifeBar( hasIcon + x1, y1 + player_font.getHeight() / 2, show_life, work );
	drawLifeBar( hasIcon + x1, y1 + nameHeight + 1, work );
	// cout << "Y1: " << y1 << " Height: " << player_font.getHeight() << " new y1: " << (y1 + player_font.getHeight() / 2) << endl;
	// work->printf( hasIcon + x1 + getMaxHealth() + 5, y1 + player_font->getHeight(), Bitmap::makeColor(255,255,255), player_font, "x %d", 3 );
        if (!ignoringLives()){
            int max = getMaxHealth() < 100 ? getMaxHealth() : 100;
            render->addMessage( player_font, (x1 + hasIcon + max + 5) * 2, y1 + nameHeight, Graphics::makeColor(255,255,255), Graphics::MaskColor(), "x %d", getLives() );
        }

	// work->rectangle( x1, y1, x1 + 100, y1 + nameHeight + 1, Graphics::Bitmap::makeColor( 255, 255, 255 ) );
}
コード例 #4
0
void NetworkCharacter::drawFront(Graphics::Bitmap * work, int rel_x){
    if ( show_name_time > 0 || show_name_time == -1 ){
        int x1, y1;
        NamePlacer::getPlacement( x1, y1, name_id );

        if ( icon )
            icon->draw( x1, y1, *work );

        int hasIcon = icon ? icon->getWidth() : 0;

        const Font & player_font = Font::getDefaultFont(20, 20 );
        const string & name = getName();
        int nameHeight = player_font.getHeight( name ) / 2;
        nameHeight = 20 / 2;
        FontRender * render = FontRender::getInstance();
        render->addMessage( player_font, (hasIcon + x1) * 2, y1 * 2, Graphics::makeColor(255,255,255), Graphics::MaskColor(), name );
        drawLifeBar( hasIcon + x1, y1 + nameHeight, work );
        if ( show_name_time > 0 ){
            show_name_time -= 1;
        }
    } else {
        Global::debug( 2 ) << "Show name time for " << getId() << " is " << show_name_time << endl;
    }
}