Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s32 count, v2s32 offset) {
- const video::SColor color(255, 255, 255, 255);
- const video::SColor colors[] = {color, color, color, color};
- video::ITexture *stat_texture = tsrc->getTexture(texture);
- if (!stat_texture)
- return;
- core::dimension2di srcd(stat_texture->getOriginalSize());
- v2s32 p = pos;
- if (corner & HUD_CORNER_LOWER)
- p -= 16;
- p += offset;
- v2s32 steppos;
- switch (drawdir) {
- case HUD_DIR_RIGHT_LEFT:
- steppos = v2s32(-1, 0);
- break;
- case HUD_DIR_TOP_BOTTOM:
- steppos = v2s32(0, 1);
- break;
- case HUD_DIR_BOTTOM_TOP:
- steppos = v2s32(0, -1);
- break;
- default:
- steppos = v2s32(1, 0);
- }
- steppos.X *= 16;
- steppos.Y *= 16;
- for (s32 i = 0; i < count / 2; i++)
- {
- core::rect<s32> srcrect(0, 0, srcd.Width, srcd.Height);
- core::rect<s32> dstrect(0,0,16,16);
- dstrect += p;
- driver->draw2DImage(stat_texture, dstrect, srcrect, NULL, colors, true);
- p += steppos;
- }
- if (count % 2 == 1)
- {
- core::rect<s32> srcrect(0, 0, srcd.Width / 2, srcd.Height);
- core::rect<s32> dstrect(0,0,8,16);
- dstrect += p;
- driver->draw2DImage(stat_texture, dstrect, srcrect, NULL, colors, true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement