00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00022 #include "Icon.h"
00023
00024 Icon::Icon() : Rect(Vec2D(0.0,0.0), Vec2D(0.0,0.0)),
00025 m_img(0),
00026 m_center(Vec2D(0.0,0.0)),
00027 m_size(Vec2D(0.0,0.0))
00028 {
00029 }
00030
00031 Icon::Icon(Vec2D& ul, Vec2D& lr, ATexture img) : Rect(ul,lr), m_img(img)
00032 {
00033 m_size.x = m_lr.x - m_ul.x;
00034 m_size.y = m_lr.y - m_ul.y;
00035 m_center.x = m_ul.x + m_size.x/2;
00036 m_center.y = m_ul.y + m_size.y/2;
00037 }
00038
00039 void Icon::setBounds(const Vec2D& ul, const Vec2D &lr)
00040 {
00041 m_bounds[0] = m_ul = ul;
00042 m_bounds[1] = m_lr = lr;
00043 m_size.x = m_lr.x - m_ul.x;
00044 m_size.y = m_lr.y - m_ul.y;
00045 m_center.x = m_ul.x + m_size.x/2;
00046 m_center.y = m_ul.y + m_size.y/2;
00047 }
00048
00049 void Icon::drawOutline( Vec3D color ) const
00050 {
00051 overlay_rect( bounds()[0], bounds()[1], false, color,
00052 BlendModes::NONE, 1.0f, 6 );
00053 }
00054
00055 void Icon::drawHelpString() const
00056 {
00057
00058
00059 Vec2D mousePos( input_getMouseX(), input_getMouseY() );
00060 if( !contains(mousePos) ) return;
00061
00062 string s( m_helpString );
00063 if( s.length()==0 ) s = "No Help Yet\nFix me plz";
00064 int lineCount = 0;
00065 for( UINT i=0; i<s.length(); i++ )
00066 if( s[i] == '\n' ) lineCount++;
00067 if( s[s.length()-1] != '\n' ) lineCount++;
00068
00069 FLOAT width = 0.37f;
00070 FLOAT height = lineCount*0.037f;
00071 Vec2D drawPos( mousePos );
00072 if( mousePos.y > 0.98f-height ) drawPos.y -= height;
00073 if( mousePos.x > 0.98f-width ) drawPos.x -= width;
00074 Vec2D drawPos2( drawPos+Vec2D(width,height) );
00075
00076 overlay_rect( drawPos, drawPos2, true, Colors::gray, BlendModes::MIX, 0.7f, 7 );
00077 overlay_rect( drawPos, drawPos2, false, Colors::white, BlendModes::NONE, 1.0f, 7 );
00078 overlay_text() << s;
00079 overlay_textOut( drawPos+Vec2D(0.003f,0.003f), 1.0f, Colors::white, NULL, 7 );
00080 }