Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
guidefs.cpp File Reference
#include "vegastrike.h"
#include "xml_support.h"
#include "vs_globals.h"
#include "config_xml.h"
#include "guidefs.h"

Go to the source code of this file.

Functions

GFXColor getConfigColor (const char *name, GFXColor defaul)
 
GFXColor SaturatedColor (float r, float g, float b, float a)
 
GFXColor GUI_OPAQUE_BLACK ()
 
GFXColor GUI_OPAQUE_WHITE ()
 
GFXColor GUI_OPAQUE_LIGHT_GRAY ()
 
GFXColor GUI_OPAQUE_MEDIUM_GRAY ()
 
GFXColor GUI_OPAQUE_DARK_GRAY ()
 
void drawRect (const Rect &rect, const GFXColor &color)
 
void drawRectOutline (const Rect &rect, const GFXColor &color, float lineWidth)
 
void drawUpLeftShadow (const Rect &rect, const GFXColor &color, float lineWidth)
 
void drawLowRightShadow (const Rect &rect, const GFXColor &color, float lineWidth)
 
void drawFilledPolygon (const std::vector< Point > &coords, const GFXColor &color)
 

Function Documentation

void drawFilledPolygon ( const std::vector< Point > &  coords,
const GFXColor color 
)

Definition at line 134 of file guidefs.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, i, and GFXColor::r.

Referenced by ScrollerButton::draw().

135 {
136  glDisable( GL_TEXTURE_2D );
137 
138  glBegin( GL_POLYGON );
139  glColor4f( color.r, color.g, color.b, color.a );
140  for (std::vector< Point >::const_iterator i = coords.begin(); i != coords.end(); i++)
141  glVertex2f( i->x, i->y );
142  glEnd();
143 
144  glEnable( GL_TEXTURE_2D );
145 }
void drawLowRightShadow ( const Rect rect,
const GFXColor color,
float  lineWidth 
)

Definition at line 118 of file guidefs.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, Size::height, Rect::origin, GFXColor::r, Rect::size, Size::width, Point::x, and Point::y.

Referenced by NewButton::draw().

119 {
120  glDisable( GL_TEXTURE_2D );
121  glLineWidth( lineWidth );
122 
123  glBegin( GL_LINE_STRIP );
124  glColor4f( color.r, color.g, color.b, color.a );
125  glVertex2f( rect.origin.x, rect.origin.y );
126  glVertex2f( rect.origin.x+rect.size.width, rect.origin.y );
127  glVertex2f( rect.origin.x+rect.size.width, rect.origin.y+rect.size.height );
128  glEnd();
129 
130  glEnable( GL_TEXTURE_2D );
131 }
void drawRect ( const Rect rect,
const GFXColor color 
)

Definition at line 74 of file guidefs.cpp.

References GFXColor::a, GFXColor::b, Rect::bottom(), GFXColor::g, Rect::left(), GFXColor::r, Rect::right(), and Rect::top().

Referenced by Slider::draw(), Picker::draw(), NewButton::draw(), Control::drawBackground(), and Window::drawBackground().

75 {
76  glDisable( GL_TEXTURE_2D );
77 
78  glColor4f( color.r, color.g, color.b, color.a );
79  glRectf( rect.left(), rect.bottom(), rect.right(), rect.top() );
80 
81  glEnable( GL_TEXTURE_2D );
82 }
void drawRectOutline ( const Rect rect,
const GFXColor color,
float  lineWidth 
)

Definition at line 85 of file guidefs.cpp.

References GFXColor::a, GFXColor::b, Rect::bottom(), GFXColor::g, Rect::left(), GFXColor::r, Rect::right(), and Rect::top().

Referenced by Slider::draw(), Control::drawBackground(), Window::drawBackground(), and NewButton::drawCycleBorder().

86 {
87  glDisable( GL_TEXTURE_2D );
88  glLineWidth( lineWidth );
89 
90  glBegin( GL_LINE_LOOP );
91  glColor4f( color.r, color.g, color.b, color.a );
92  glVertex2f( rect.left(), rect.top() );
93  glVertex2f( rect.right(), rect.top() );
94  glVertex2f( rect.right(), rect.bottom() );
95  glVertex2f( rect.left(), rect.bottom() );
96  glEnd();
97 
98  glEnable( GL_TEXTURE_2D );
99 }
void drawUpLeftShadow ( const Rect rect,
const GFXColor color,
float  lineWidth 
)

Definition at line 102 of file guidefs.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, Size::height, Rect::origin, GFXColor::r, Rect::size, Size::width, Point::x, and Point::y.

Referenced by NewButton::draw().

103 {
104  glDisable( GL_TEXTURE_2D );
105  glLineWidth( lineWidth );
106 
107  glBegin( GL_LINE_STRIP );
108  glColor4f( color.r, color.g, color.b, color.a );
109  glVertex2f( rect.origin.x, rect.origin.y );
110  glVertex2f( rect.origin.x, rect.origin.y+rect.size.height );
111  glVertex2f( rect.origin.x+rect.size.width, rect.origin.y+rect.size.height );
112  glEnd();
113 
114  glEnable( GL_TEXTURE_2D );
115 }
GFXColor getConfigColor ( const char *  name,
GFXColor  defaul 
)

Definition at line 27 of file guidefs.cpp.

References GFXColor::a, GFXColor::b, GFXColor::g, VegaConfig::getColor(), GFXColor::r, and vs_config.

Referenced by CATEGORY_TEXT_COLOR(), BaseComputer::constructControls(), GameMenu::createControls(), DEFAULT_UPGRADE_COLOR(), DOWNGRADE_OR_NONCOMPAT_COLOR(), GUI_OPAQUE_BLACK(), GUI_OPAQUE_DARK_GRAY(), GUI_OPAQUE_LIGHT_GRAY(), GUI_OPAQUE_MEDIUM_GRAY(), GUI_OPAQUE_WHITE(), ITEM_DESTROYED_COLOR(), MISSION_COLOR(), NO_MONEY_COLOR(), NO_ROOM_COLOR(), and PROHIBITED_COLOR().

28 {
29  float color[4];
30  color[0] = defaul.r;
31  color[1] = defaul.g;
32  color[2] = defaul.b;
33  color[3] = defaul.a;
34  vs_config->getColor( std::string( "default" ), std::string( name ), color, true );
35  return GFXColor( color[0], color[1], color[2], color[3] );
36 }
GFXColor GUI_OPAQUE_DARK_GRAY ( )

Definition at line 67 of file guidefs.cpp.

References getConfigColor().

68 {
69  static GFXColor gui_dark_gray = getConfigColor( "base_dark_gray", GFXColor( .75, .75, .75, 1 ) );
70  return gui_dark_gray;
71 }
GFXColor GUI_OPAQUE_LIGHT_GRAY ( )

Definition at line 57 of file guidefs.cpp.

References getConfigColor().

58 {
59  static GFXColor gui_light_gray = getConfigColor( "base_light_gray", GFXColor( .25, .25, .25, 1 ) );
60  return gui_light_gray;
61 }
GFXColor GUI_OPAQUE_MEDIUM_GRAY ( )

Definition at line 62 of file guidefs.cpp.

References getConfigColor().

Referenced by NavComputer::constructControls(), BaseComputer::constructControls(), ListQuestionDialog::CreateControlsForListWindow(), GameMenu::createNetworkControls(), and NavComputer::RenameConfirm::init().

63 {
64  static GFXColor gui_gray = getConfigColor( "base_gray", GFXColor( .5, .5, .5, 1 ) );
65  return gui_gray;
66 }
GFXColor SaturatedColor ( float  r,
float  g,
float  b,
float  a 
)

Definition at line 38 of file guidefs.cpp.

References VegaConfig::getVariable(), XMLSupport::parse_float(), and vs_config.

Referenced by CreateControlsForAlertWindow(), ListQuestionDialog::CreateControlsForListWindow(), and CreateControlsForYesNoWindow().

39 {
40  static float Saturation = XMLSupport::parse_float( vs_config->getVariable( "graphics", "base_saturation", "1.0" ) );
41 
42  return GFXColor( ( r*Saturation*3+(r+b+g)*(1-Saturation) )/3,
43  ( g*Saturation*3+(r+b+g)*(1-Saturation) )/3,
44  ( b*Saturation*3+(r+b+g)*(1-Saturation) )/3, a );
45 }