Definition at line 17 of file NodeDrawer.h.
Public Member Functions | |
NodeDrawer () | |
virtual | ~NodeDrawer () |
void | setScreen (SDL_Surface *screen) |
void | drawNode (const LevelNode *node) const |
Draw blinking dot centred on node position. | |
void | drawEdge (const LevelNode *start, const LevelNode *end) const |
void | drawSelected (const std::string &levelname) const |
|
Definition at line 23 of file NodeDrawer.cpp. 00024 { 00025 //TODO: allow to set font and color 00026 m_font = new Font(Path::dataReadPath("font/font_menu.ttf"), 22); 00027 00028 m_imagePack = new ResImagePack(); 00029 m_imagePack->addImage("solved", 00030 Path::dataReadPath("images/menu/n0.png")); 00031 00032 m_imagePack->addImage("open", 00033 Path::dataReadPath("images/menu/n1.png")); 00034 m_imagePack->addImage("open", 00035 Path::dataReadPath("images/menu/n2.png")); 00036 m_imagePack->addImage("open", 00037 Path::dataReadPath("images/menu/n3.png")); 00038 m_imagePack->addImage("open", 00039 Path::dataReadPath("images/menu/n4.png")); 00040 00041 m_imagePack->addImage("far", 00042 Path::dataReadPath("images/menu/n_far.png")); 00043 }
|
|
Definition at line 45 of file NodeDrawer.cpp. 00046 { 00047 m_imagePack->removeAll(); 00048 delete m_imagePack; 00049 delete m_font; 00050 }
|
|
Definition at line 122 of file NodeDrawer.cpp. 00123 { 00124 //TODO: nice curves 00125 Sint16 x1 = start->getLoc().getX(); 00126 Sint16 y1 = start->getLoc().getY(); 00127 Sint16 x2 = end->getLoc().getX(); 00128 Sint16 y2 = end->getLoc().getY(); 00129 00130 Uint32 colorRGBA = 0xffff00ff; 00131 aalineColor(m_screen, x1, y1, x2, y2, colorRGBA); 00132 aalineColor(m_screen, x1 - 1, y1 - 1 , x2 - 1, y2 - 1, colorRGBA); 00133 aalineColor(m_screen, x1 + 1, y1 + 1 , x2 + 1, y2 + 1, colorRGBA); 00134 aalineColor(m_screen, x1 - 1, y1 + 1 , x2 - 1, y2 + 1, colorRGBA); 00135 aalineColor(m_screen, x1 + 1, y1 - 1 , x2 + 1, y2 - 1, colorRGBA); 00136 }
|
|
Draw blinking dot centred on node position.
Definition at line 56 of file NodeDrawer.cpp. 00057 { 00058 V2 loc = node->getLoc(); 00059 drawDot(m_imagePack->getRes("far"), loc); 00060 00061 SDL_Surface *dot = NULL; 00062 switch (node->getState()) { 00063 case LevelNode::STATE_FAR: 00064 return; 00065 case LevelNode::STATE_OPEN: 00066 { 00067 int phase = TimerAgent::agent()->getCycles() % 10; 00068 if (phase > 4) { 00069 phase--; 00070 } 00071 if (phase > 7) { 00072 phase--; 00073 } 00074 if (phase >= 4) { 00075 phase = 7 - phase; 00076 } 00077 dot = m_imagePack->getRes("open", phase); 00078 } 00079 break; 00080 case LevelNode::STATE_SOLVED: 00081 dot = m_imagePack->getRes("solved"); 00082 break; 00083 default: 00084 LOG_WARNING(ExInfo("don't know how to draw node") 00085 .addInfo("state", node->getState())); 00086 return; 00087 } 00088 drawDot(dot, loc); 00089 }
|
|
Definition at line 106 of file NodeDrawer.cpp. 00107 { 00108 //TODO: draw deflected text 00109 int text_width = m_font->calcTextWidth(levelname); 00110 00111 SDL_Rect rect; 00112 rect.x = (m_screen->w - text_width) / 2; 00113 rect.y = m_screen->h - 50; 00114 00115 SDL_Color color = {255, 255, 0, 255}; 00116 SDL_Surface *surface = m_font->renderTextOutlined(levelname, color); 00117 SDL_BlitSurface(surface, NULL, m_screen, &rect); 00118 SDL_FreeSurface(surface); 00119 }
|
|
Definition at line 27 of file NodeDrawer.h. 00027 { m_screen = screen; }
|