示例#1
0
void CombatGameInst::draw(GameState *gs) {
	GameView& view = gs->view();
	SpriteEntry& spr = game_sprite_data[sprite];
	Colour draw_colour = effects().effected_colour();

	if (cooldowns().is_hurting()) {
		float s = 1 - hurt_alpha_value(cooldowns().hurt_cooldown);
		draw_colour = draw_colour.multiply(Colour(255, 255 * s, 255 * s));
	}

	int sx = x - spr.width() / 2, sy = y - spr.height() / 2;
	gl_draw_sprite(view, sprite, sx, sy, vx, vy, gs->frame(), draw_colour);

	effects().draw_effect_sprites(gs, Pos(sx, sy));

	if (is_resting) {
		GLimage& restimg =
				game_sprite_data[get_sprite_by_name("resting")].img();
		gl_draw_image(view, restimg, x - spr.width() / 2, y - spr.height() / 2);
	}
	CoreStats& ecore = effective_stats().core;

	//Draw health bar
	int healthbar_offsety = 20;
	if (target_radius > 16)
		healthbar_offsety = target_radius + 8;
	if (ecore.hp < ecore.max_hp) {
		const BBox statbox(x - 10, y - healthbar_offsety, x + 10,
				y - healthbar_offsety + 5);
		gl_draw_statbar(view, statbox, ecore.hp, ecore.max_hp);
	}
}
示例#2
0
void FeatureInst::draw(GameState* gs) {
	Colour drawcolour = COL_WHITE;
	if (last_seen_spr > -1) {
		SpriteEntry& spr_entry = game_sprite_data.at(last_seen_spr);
		GLimage& img = spr_entry.img(sprite_frame);
		gl_draw_image(gs->view(), img, x - TILE_SIZE / 2, y - TILE_SIZE / 2,
				drawcolour);
	}
}
示例#3
0
static void draw_player_inventory_slot(GameState* gs, ItemSlot& itemslot, int x,
		int y) {
	if (itemslot.amount > 0) {
		ItemEntry& ientry = itemslot.item.item_entry();
		GLimage& itemimg = game_sprite_data[ientry.sprite].img();
		gl_draw_image(itemimg, x, y);
		if (ientry.stackable) {
			gl_printf(gs->primary_font(), Colour(255, 255, 255), x + 1, y + 1,
					"%d", itemslot.amount);
		}
	}
}
示例#4
0
void gl_draw_sprite(const GameView& view, sprite_id sprite, int x, int y,
		float dx, float dy, int steps, const Colour& c) {
	float PI = 3.1415921;
	SpriteEntry& entry = game_sprite_data.at(sprite);
	GLimage* img;
	if (entry.type == SpriteEntry::DIRECTIONAL) {
		float direction = PI * 2.5 + atan2(dy, dx);
		int nimgs = entry.images.size();
		float bucket_size = PI * 2 / nimgs;
		int bucket = round(direction / bucket_size);
		bucket = bucket % nimgs;
		img = &entry.img(bucket);
	} else { //if (entry.type == SpriteEntry::ANIMATED) {
		img = &entry.img();
	}
	gl_draw_image(view, *img, x, y, c);
}
示例#5
0
/* General gl_print function for others to delegate to */
static Dim gl_print_impl(const font_data& font, const Colour& colour, Pos p,
		int max_width, bool center_x, bool center_y, bool actually_print,
		const char* fmt, va_list ap) {
	char text[512];
	vsnprintf(text, 512, fmt, ap);
	va_end(ap);

	Dim offset(0, 0);

	std::vector<int> line_splits;
	int measured_width = process_string(font, text, max_width, line_splits);

	if (center_x) {
		p.x -= measured_width / 2;
	}
	if (center_y) {
		p.y -= font.h * line_splits.size() / 2;
	}

	for (int linenum = 0, i = 0; linenum < line_splits.size(); linenum++) {
		int len = 0;
		int eol = line_splits[linenum];

		offset.h += font.h;

		for (; i < eol; i++) {
			unsigned char chr = text[i];
			if (chr == '\n') {
				continue; //skip newline char
			}
			char_data &cdata = *font.data[chr];
			len += cdata.advance;
			if (actually_print) {
				gl_draw_image(cdata.img,
						p.x + len - (cdata.advance - cdata.left),
						p.y + offset.h - cdata.move_up, colour);
			}
		}
		offset.w = std::max(len, offset.w);
		offset.h += 1;
	}
	return offset;
}
void LLFloaterColorPicker::draw()
{
	LLRect swatch_rect;
	mSwatch->localRectToOtherView(mSwatch->getLocalRect(), &swatch_rect, this);
	// draw context cone connecting color picker with color swatch in parent floater
	LLRect local_rect = getLocalRect();
	if (gFocusMgr.childHasKeyboardFocus(this) && mSwatch->isInVisibleChain() && mContextConeOpacity > 0.001f)
	{
		gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
		LLGLEnable(GL_CULL_FACE);
		gGL.begin(LLRender::QUADS);
		{
			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
			gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mTop);
			gGL.vertex2i(swatch_rect.mRight, swatch_rect.mTop);
			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
			gGL.vertex2i(local_rect.mRight, local_rect.mTop);
			gGL.vertex2i(local_rect.mLeft, local_rect.mTop);

			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
			gGL.vertex2i(local_rect.mLeft, local_rect.mTop);
			gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
			gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mBottom);
			gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mTop);

			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
			gGL.vertex2i(local_rect.mRight, local_rect.mBottom);
			gGL.vertex2i(local_rect.mRight, local_rect.mTop);
			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
			gGL.vertex2i(swatch_rect.mRight, swatch_rect.mTop);
			gGL.vertex2i(swatch_rect.mRight, swatch_rect.mBottom);

			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_OUT_ALPHA * mContextConeOpacity);
			gGL.vertex2i(local_rect.mLeft, local_rect.mBottom);
			gGL.vertex2i(local_rect.mRight, local_rect.mBottom);
			gGL.color4f(0.f, 0.f, 0.f, CONTEXT_CONE_IN_ALPHA * mContextConeOpacity);
			gGL.vertex2i(swatch_rect.mRight, swatch_rect.mBottom);
			gGL.vertex2i(swatch_rect.mLeft, swatch_rect.mBottom);
		}
		gGL.end();
	}

	if (gFocusMgr.childHasMouseCapture(getDragHandle()))
	{
		mContextConeOpacity = lerp(mContextConeOpacity, gSavedSettings.getF32("PickerContextOpacity"), LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
	}
	else
	{
		mContextConeOpacity = lerp(mContextConeOpacity, 0.f, LLCriticalDamp::getInterpolant(CONTEXT_FADE_TIME));
	}

	mPipetteBtn->setToggleState(LLToolMgr::getInstance()->getCurrentTool() == LLToolPipette::getInstance());
	mApplyImmediateCheck->setEnabled(mActive && mCanApplyImmediately);
	mSelectBtn->setEnabled(mActive);

	// base floater stuff
	LLFloater::draw ();

	// draw image for RGB area (not really RGB but you'll see what I mean...
	gl_draw_image ( mRGBViewerImageLeft, mRGBViewerImageTop - mRGBViewerImageHeight, mRGBImage, LLColor4::white );

	// update 'cursor' into RGB Section
	S32 xPos = ( S32 ) ( ( F32 )mRGBViewerImageWidth * getCurH () ) - 8;
	S32 yPos = ( S32 ) ( ( F32 )mRGBViewerImageHeight * getCurS () ) - 8;
	gl_line_2d ( mRGBViewerImageLeft + xPos,
				 mRGBViewerImageTop - mRGBViewerImageHeight + yPos + 8,
				 mRGBViewerImageLeft + xPos + 16,
				 mRGBViewerImageTop - mRGBViewerImageHeight + yPos + 8,
				 LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ) );

	gl_line_2d ( mRGBViewerImageLeft + xPos + 8,
				 mRGBViewerImageTop - mRGBViewerImageHeight + yPos,
				 mRGBViewerImageLeft + xPos + 8,
				 mRGBViewerImageTop - mRGBViewerImageHeight + yPos + 16,
				 LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ) );

	// create rgb area outline
	gl_rect_2d ( mRGBViewerImageLeft,
				 mRGBViewerImageTop - mRGBViewerImageHeight,
				 mRGBViewerImageLeft + mRGBViewerImageWidth + 1,
				 mRGBViewerImageTop,
				 LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
				 FALSE );

	// draw luminance slider
	for ( S32 y = 0; y < mLumRegionHeight; ++y )
	{
		F32 rValSlider, gValSlider, bValSlider;
		hslToRgb ( getCurH (), getCurS (), ( F32 )y / ( F32 )mLumRegionHeight, rValSlider, gValSlider, bValSlider );

		gl_rect_2d( mLumRegionLeft, 
			mLumRegionTop - mLumRegionHeight + y, 
				mLumRegionLeft + mLumRegionWidth, 
					mLumRegionTop - mLumRegionHeight + y - 1, 
						LLColor4 ( rValSlider, gValSlider, bValSlider, 1.0f ) );
	}


	// draw luninance marker
	S32 startX = mLumRegionLeft + mLumRegionWidth;
	S32 startY = mLumRegionTop - mLumRegionHeight + ( S32 ) ( mLumRegionHeight * getCurL () );
	gl_triangle_2d ( startX, startY,
			startX + mLumMarkerSize, startY - mLumMarkerSize,
				startX + mLumMarkerSize, startY + mLumMarkerSize,
					LLColor4 ( 0.75f, 0.75f, 0.75f, 1.0f ), TRUE );

	// draw luminance slider outline
	gl_rect_2d ( mLumRegionLeft,
				 mLumRegionTop - mLumRegionHeight,
				 mLumRegionLeft + mLumRegionWidth + 1,
				 mLumRegionTop,
				 LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
				 FALSE );

	// draw selected color swatch
	gl_rect_2d ( mSwatchRegionLeft,
				 mSwatchRegionTop - mSwatchRegionHeight,
				 mSwatchRegionLeft + mSwatchRegionWidth,
				 mSwatchRegionTop,
				 LLColor4 ( getCurR (), getCurG (), getCurB (), 1.0f ),
				 TRUE );

	// draw selected color swatch outline
	gl_rect_2d ( mSwatchRegionLeft,
				 mSwatchRegionTop - mSwatchRegionHeight,
				 mSwatchRegionLeft + mSwatchRegionWidth + 1,
				 mSwatchRegionTop,
				 LLColor4 ( 0.0f, 0.0f, 0.0f, 1.0f ),
				 FALSE );

	// color palette code is a little more involved so break it out into its' own method
	drawPalette ();
}
示例#7
0
void gl_draw_image(const GameView& view, GLimage& img, int x, int y,
		const Colour& c) {
	gl_draw_image(img, x - view.x, y - view.y, c);
}
示例#8
0
void gl_draw_sprite(sprite_id sprite, int x, int y, const Colour& c) {
	SpriteEntry& entry = game_sprite_data.at(sprite);
	gl_draw_image(entry.img(), x, y, c.multiply(entry.drawcolour));
}