draw health bars but still incorrect

This commit is contained in:
Eduardo Bart 2011-08-19 10:23:35 -03:00
parent 817234a660
commit 7b13161036
3 changed files with 176 additions and 148 deletions

View File

@ -21,10 +21,16 @@ public:
RGBA rgba() const { return color; } RGBA rgba() const { return color; }
const uint8* rgbaPtr() const { return (const uint8*)&color; } const uint8* rgbaPtr() const { return (const uint8*)&color; }
void setAlpha(uint8 a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); } void setRed(int r) { color = (r & 0xff) | (color & 0xffffff00); }
void setBlue(uint8 b) { color = ((b & 0xff)<<16) | (color & 0xff00ffff); } void setGreen(int g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); }
void setGreen(uint8 g) { color = ((g & 0xff)<<8) | (color & 0xffff00ff); } void setBlue(int b) { color = ((b & 0xff)<<16) | (color & 0xff00ffff); }
void setRed(uint8 r) { color = (r & 0xff) | (color & 0xffffff00); } void setAlpha(int a) { color = ((a & 0xff)<<24) | (color & 0x00ffffff); }
void setRed(float r) { setRed(int(r*255.0f)); }
void setGreen(float g) { setGreen(int(g*255.0f)); }
void setBlue(float b) { setBlue(int(b*255.0f)); }
void setAlpha(float a) { setAlpha(int(a*255.0f)); }
void setRGBA(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) { color = ((a & 0xff)<<24) | ((b & 0xff)<<16) | ((g & 0xff)<<8) | (r & 0xff); } void setRGBA(uint8 r, uint8 g, uint8 b, uint8 a = 0xFF) { color = ((a & 0xff)<<24) | ((b & 0xff)<<16) | ((g & 0xff)<<8) | (r & 0xff); }
void setABGR(uint32 abgr) { color = ((abgr>>24) & 0xff) | ((abgr>>16) & 0xff) << 8 | ((abgr>>8) & 0xff) << 16 | (abgr & 0xff) << 24; } void setABGR(uint32 abgr) { color = ((abgr>>24) & 0xff) | ((abgr>>16) & 0xff) << 8 | ((abgr>>8) & 0xff) << 16 | (abgr & 0xff) << 24; }
void setRGBA(uint32 rgba) { color = rgba; } void setRGBA(uint32 rgba) { color = rgba; }

View File

@ -1,6 +1,8 @@
#ifndef OTCLIENT_CORE_CONST_H #ifndef OTCLIENT_CORE_CONST_H
#define OTCLIENT_CORE_CONST_H #define OTCLIENT_CORE_CONST_H
#include <framework/util/color.h>
enum ThingAttributesGroup { enum ThingAttributesGroup {
THING_GROUP_NONE = 0, THING_GROUP_NONE = 0,
THING_GROUP_GROUND, THING_GROUP_GROUND,
@ -41,4 +43,146 @@ enum SpriteMask {
SpriteMaskNone = 255 SpriteMaskNone = 255
}; };
static const Color OutfitColors[] = {
Color(255,255,255),
Color(255,212,191),
Color(255,233,191),
Color(255,255,191),
Color(233,255,191),
Color(212,255,191),
Color(191,255,191),
Color(191,255,212),
Color(191,255,233),
Color(191,255,255),
Color(191,233,255),
Color(191,212,255),
Color(191,191,255),
Color(212,191,255),
Color(233,191,255),
Color(255,191,255),
Color(255,191,233),
Color(255,191,212),
Color(255,191,191),
Color(128,128,128),
Color(191,159,143),
Color(191,175,143),
Color(191,191,143),
Color(175,191,143),
Color(159,191,143),
Color(143,191,143),
Color(143,191,159),
Color(143,191,175),
Color(143,191,191),
Color(143,175,191),
Color(143,159,191),
Color(143,143,191),
Color(159,143,191),
Color(175,143,191),
Color(191,143,191),
Color(191,143,175),
Color(191,143,159),
Color(191,143,143),
Color(182,182,182),
Color(191,127,95),
Color(191,159,95),
Color(191,191,95),
Color(159,191,95),
Color(127,191,95),
Color(95,191,95),
Color(95,191,127),
Color(95,191,159),
Color(95,191,191),
Color(95,159,191),
Color(95,127,191),
Color(95,95,191),
Color(127,95,191),
Color(159,95,191),
Color(191,95,191),
Color(191,95,159),
Color(191,95,127),
Color(191,95,95),
Color(145,145,145),
Color(191,106,63),
Color(191,148,63),
Color(191,191,63),
Color(148,191,63),
Color(107,191,63),
Color(63,191,63),
Color(63,191,106),
Color(63,191,148),
Color(63,191,191),
Color(63,148,191),
Color(63,106,191),
Color(63,63,191),
Color(106,63,191),
Color(148,63,191),
Color(191,63,191),
Color(191,63,148),
Color(191,63,106),
Color(191,63,63),
Color(109,109,109),
Color(255,85,0),
Color(255,170,0),
Color(255,255,0),
Color(170,255,0),
Color(84,255,0),
Color(0,255,0),
Color(0,255,84),
Color(0,255,170),
Color(0,255,255),
Color(0,169,255),
Color(0,85,255),
Color(0,0,255),
Color(85,0,255),
Color(169,0,255),
Color(254,0,255),
Color(255,0,170),
Color(255,0,85),
Color(255,0,0),
Color(72,72,72),
Color(191,63,0),
Color(191,127,0),
Color(191,191,0),
Color(127,191,0),
Color(63,191,0),
Color(0,191,0),
Color(0,191,63),
Color(0,191,127),
Color(0,191,191),
Color(0,127,191),
Color(0,63,191),
Color(0,0,191),
Color(63,0,191),
Color(127,0,191),
Color(191,0,191),
Color(191,0,127),
Color(191,0,63),
Color(191,0,0),
Color(36,36,36),
Color(127,42,0),
Color(127,85,0),
Color(127,127,0),
Color(85,127,0),
Color(42,127,0),
Color(0,127,0),
Color(0,127,42),
Color(0,127,85),
Color(0,127,127),
Color(0,84,127),
Color(0,42,127),
Color(0,0,127),
Color(42,0,127),
Color(84,0,127),
Color(127,0,127),
Color(191,0,85),
Color(127,0,42),
Color(127,0,0)
};
#endif #endif

View File

@ -18,149 +18,6 @@ void Creature::draw(int x, int y)
// draw outfit // draw outfit
internalDraw(x, y, 0, m_direction, 0, 0, anim); internalDraw(x, y, 0, m_direction, 0, 0, anim);
// TODO: move this shit hahaha
static const Color outfitColors[] = {
Color(255,255,255),
Color(255,212,191),
Color(255,233,191),
Color(255,255,191),
Color(233,255,191),
Color(212,255,191),
Color(191,255,191),
Color(191,255,212),
Color(191,255,233),
Color(191,255,255),
Color(191,233,255),
Color(191,212,255),
Color(191,191,255),
Color(212,191,255),
Color(233,191,255),
Color(255,191,255),
Color(255,191,233),
Color(255,191,212),
Color(255,191,191),
Color(128,128,128),
Color(191,159,143),
Color(191,175,143),
Color(191,191,143),
Color(175,191,143),
Color(159,191,143),
Color(143,191,143),
Color(143,191,159),
Color(143,191,175),
Color(143,191,191),
Color(143,175,191),
Color(143,159,191),
Color(143,143,191),
Color(159,143,191),
Color(175,143,191),
Color(191,143,191),
Color(191,143,175),
Color(191,143,159),
Color(191,143,143),
Color(182,182,182),
Color(191,127,95),
Color(191,159,95),
Color(191,191,95),
Color(159,191,95),
Color(127,191,95),
Color(95,191,95),
Color(95,191,127),
Color(95,191,159),
Color(95,191,191),
Color(95,159,191),
Color(95,127,191),
Color(95,95,191),
Color(127,95,191),
Color(159,95,191),
Color(191,95,191),
Color(191,95,159),
Color(191,95,127),
Color(191,95,95),
Color(145,145,145),
Color(191,106,63),
Color(191,148,63),
Color(191,191,63),
Color(148,191,63),
Color(107,191,63),
Color(63,191,63),
Color(63,191,106),
Color(63,191,148),
Color(63,191,191),
Color(63,148,191),
Color(63,106,191),
Color(63,63,191),
Color(106,63,191),
Color(148,63,191),
Color(191,63,191),
Color(191,63,148),
Color(191,63,106),
Color(191,63,63),
Color(109,109,109),
Color(255,85,0),
Color(255,170,0),
Color(255,255,0),
Color(170,255,0),
Color(84,255,0),
Color(0,255,0),
Color(0,255,84),
Color(0,255,170),
Color(0,255,255),
Color(0,169,255),
Color(0,85,255),
Color(0,0,255),
Color(85,0,255),
Color(169,0,255),
Color(254,0,255),
Color(255,0,170),
Color(255,0,85),
Color(255,0,0),
Color(72,72,72),
Color(191,63,0),
Color(191,127,0),
Color(191,191,0),
Color(127,191,0),
Color(63,191,0),
Color(0,191,0),
Color(0,191,63),
Color(0,191,127),
Color(0,191,191),
Color(0,127,191),
Color(0,63,191),
Color(0,0,191),
Color(63,0,191),
Color(127,0,191),
Color(191,0,191),
Color(191,0,127),
Color(191,0,63),
Color(191,0,0),
Color(36,36,36),
Color(127,42,0),
Color(127,85,0),
Color(127,127,0),
Color(85,127,0),
Color(42,127,0),
Color(0,127,0),
Color(0,127,42),
Color(0,127,85),
Color(0,127,127),
Color(0,84,127),
Color(0,42,127),
Color(0,0,127),
Color(42,0,127),
Color(84,0,127),
Color(127,0,127),
Color(191,0,85),
Color(127,0,42),
Color(127,0,0)
};
const ThingAttributes& attributes = getAttributes(); const ThingAttributes& attributes = getAttributes();
if(attributes.blendframes > 1) { if(attributes.blendframes > 1) {
g_graphics.bindBlendFunc(BLEND_COLORIZING); g_graphics.bindBlendFunc(BLEND_COLORIZING);
@ -177,13 +34,34 @@ void Creature::draw(int x, int y)
else if(mask == SpriteMaskGreen) else if(mask == SpriteMaskGreen)
outfitColorId = m_outfit.feet; outfitColorId = m_outfit.feet;
g_graphics.bindColor(outfitColors[outfitColorId]); g_graphics.bindColor(OutfitColors[outfitColorId]);
internalDraw(x, y, 1, m_direction, 0, 0, anim, (SpriteMask)mask); internalDraw(x, y, 1, m_direction, 0, 0, anim, (SpriteMask)mask);
} }
g_graphics.bindBlendFunc(BLEND_NORMAL); g_graphics.bindBlendFunc(BLEND_NORMAL);
g_graphics.bindColor(Color::white); g_graphics.bindColor(Color::white);
} }
// health bar
// TODO: draw outside framebuffer
Color healthColor = Color::black;
if(m_healthPercent > 60 && m_healthPercent <= 100) {
healthColor.setRed(0.0f);
healthColor.setGreen(0.75f);
} else if(m_healthPercent > 30 && m_healthPercent <= 60) {
healthColor.setRed(0.75f);
healthColor.setGreen(0.75f);
} else if(m_healthPercent > 10 && m_healthPercent <= 30) {
healthColor.setRed(0.75f);
healthColor.setGreen(0.00f);
} else if(m_healthPercent > 0 && m_healthPercent <= 10) {
healthColor.setRed(0.25f);
healthColor.setGreen(0.00f);
}
Rect healthRect = Rect(x - 14, y - 11, 27, 4);
g_graphics.drawBoundingRect(healthRect, Color::black);
g_graphics.drawFilledRect(healthRect.expanded(-1), healthColor);
} }
const ThingAttributes& Creature::getAttributes() const ThingAttributes& Creature::getAttributes()