Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Icon Class Reference

#include <Icon.h>

Inheritance diagram for Icon:

Inheritance graph
[legend]
Collaboration diagram for Icon:

Collaboration graph
[legend]
List of all members.

Public Methods

 Icon ()
 Icon (Vec2D &ul, Vec2D &lr, ATexture img)
const ATexture image () const
void setImage (ATexture img)
void setBounds (const Vec2D &ul, const Vec2D &lr)
void setHelpString (string s)
void render () const
void drawOutline (Vec3D color) const
void drawHelpString () const
virtual const vector< Vec2D > & bounds () const
 returns the bounding points, pts[0] is upper left, pts[1] is lower right

virtual bool contains (const Vec2D &pt) const

Protected Attributes

Vec2D m_ul
Vec2D m_lr
vector< Vec2Dm_bounds

Private Attributes

ATexture m_img
Vec2D m_center
Vec2D m_size
string m_helpString

Constructor & Destructor Documentation

Icon::Icon  
 

Definition at line 24 of file Icon.cpp.

References Vec2D.

00024            : 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 }

Icon::Icon Vec2D   ul,
Vec2D   lr,
ATexture    img
 

Definition at line 31 of file Icon.cpp.

References m_center, Rect::m_lr, m_size, and Rect::m_ul.

00031                                              : 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 }


Member Function Documentation

const vector< Vec2D > & Rect::bounds   const [inline, virtual, inherited]
 

returns the bounding points, pts[0] is upper left, pts[1] is lower right

Definition at line 51 of file Rect.h.

References Rect::m_bounds.

Referenced by drawOutline(), HUD::render(), HUD::translateMiniMapToWorld(), HUD::translateWorldToMiniMap(), and Map::WorldMap::worldToGridCoord().

00051 { return m_bounds; }

bool Rect::contains const Vec2D   pt const [virtual, inherited]
 

Definition at line 42 of file Rect.cpp.

References Rect::m_lr, and Rect::m_ul.

Referenced by drawHelpString(), HUD::isButtonStopClicked(), MilitaryUnit::move(), Overhead::overheadRender(), HUD::processMiniMapInput(), Overhead::processOverheadInput(), HUD::processOverheadInput(), and HUD::render().

00043 {
00044   return pt.x >= m_ul.x && pt.y >= m_ul.y && pt.x <= m_lr.x && pt.y <= m_lr.y;
00045 }

void Icon::drawHelpString   const
 

Definition at line 55 of file Icon.cpp.

References Rect::contains(), input_getMouseX(), input_getMouseY(), overlay_rect(), overlay_text(), overlay_textOut(), UINT, and Vec2D.

Referenced by Overhead::overheadRender(), and HUD::render().

00056 {
00057         //if( input_mouseIdleTime() < 0.3f ) return;                                    // cursor must be idle at least 0.4 sec
00058 
00059         Vec2D mousePos( input_getMouseX(), input_getMouseY() );
00060         if( !contains(mousePos) ) return;                                                       // cursor must be inside this icon
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 );                                              // top-left corner of help box
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) );  // lower-right corner
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 }

void Icon::drawOutline Vec3D    color const
 

Definition at line 49 of file Icon.cpp.

References Rect::bounds(), and overlay_rect().

Referenced by Overhead::overheadRender(), and HUD::render().

00050 {
00051         overlay_rect(   bounds()[0], bounds()[1], false, color,
00052                                         BlendModes::NONE, 1.0f, 6 );
00053 }

const ATexture Icon::image   const [inline]
 

Definition at line 49 of file Icon.h.

References ATexture, and m_img.

00049 { return m_img; }

void Icon::render   const [inline]
 

Definition at line 52 of file Icon.h.

References overlay_image().

Referenced by HUD::render().

00052 { if(m_img)  overlay_image(m_img, m_center, m_size, BlendModes::NONE, 1.0f, 6); }

void Icon::setBounds const Vec2D   ul,
const Vec2D   lr
[virtual]
 

Reimplemented from Rect.

Definition at line 39 of file Icon.cpp.

References Rect::m_bounds, m_center, Rect::m_lr, m_size, and Rect::m_ul.

Referenced by HUD::init().

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 }

void Icon::setHelpString string    s [inline]
 

Definition at line 51 of file Icon.h.

References m_helpString.

Referenced by HUD::init(), Overhead::overhead_init(), and Overhead::overheadRender().

00051 { m_helpString = s; }

void Icon::setImage ATexture    img [inline]
 

Definition at line 50 of file Icon.h.

References m_img.

Referenced by HUD::init().

00050 { m_img = img; }


Member Data Documentation

vector<Vec2D> Rect::m_bounds [protected, inherited]
 

Definition at line 42 of file Rect.h.

Referenced by Rect::bounds(), Rect::Rect(), Rect::setBounds(), and setBounds().

Vec2D Icon::m_center [private]
 

Definition at line 44 of file Icon.h.

Referenced by Icon(), and setBounds().

string Icon::m_helpString [private]
 

Definition at line 46 of file Icon.h.

Referenced by setHelpString().

ATexture Icon::m_img [private]
 

Definition at line 43 of file Icon.h.

Referenced by image(), and setImage().

Vec2D Rect::m_lr [protected, inherited]
 

Definition at line 41 of file Rect.h.

Referenced by Rect::contains(), Icon(), Rect::Rect(), Rect::setBounds(), and setBounds().

Vec2D Icon::m_size [private]
 

Definition at line 45 of file Icon.h.

Referenced by Icon(), and setBounds().

Vec2D Rect::m_ul [protected, inherited]
 

Definition at line 40 of file Rect.h.

Referenced by Rect::contains(), Icon(), Rect::Rect(), Rect::setBounds(), and setBounds().


The documentation for this class was generated from the following files:
Generated on Wed Apr 23 05:52:09 2003 for Modern Warfare by doxygen1.3-rc2