00001
00032 #include "llviewerprecompiledheaders.h"
00033
00034 #include "llui.h"
00035 #include "llgl.h"
00036 #include "llfontgl.h"
00037
00038 #include "llagent.h"
00039
00040 #include "llvelocitybar.h"
00041
00042 EWidgetType LLVelocityBar::getWidgetType() const
00043 {
00044 return WIDGET_TYPE_VELOCITY_BAR;
00045 }
00046
00047 LLString LLVelocityBar::getWidgetTag() const
00048 {
00049 return LL_VELOCITY_BAR_TAG;
00050 }
00051
00052 const char tab = '\t';
00053
00054 void LLVelocityBar::draw()
00055 {
00056 const S32 BAR_TOP = 24;
00057 const S32 BAR_BOTTOM = 20;
00058 const S32 TICK_BOTTOM = 15;
00059 const S32 TICK_WIDTH = 2;
00060 const S32 MAGIC_CHAR_WIDTH = 6;
00061
00062 S32 left, top, right, bottom;
00063
00064 if (!getVisible())
00065 {
00066 return;
00067 }
00068
00069
00070
00071
00072
00073 F32 velocity = gAgent.getVelocity().magVec();
00074
00075 LLColor4 bar_color(0.0f, 1.0f, 0.0f, 1.f);
00076
00077
00078
00079
00080
00081 LLGLSNoTexture gls_no_texture;
00082
00083
00084
00085
00086
00087
00088
00089 LLColor4 color(1.f, 1.f, 1.f, 1.f);
00090
00091 top = BAR_BOTTOM - 1;
00092 bottom = TICK_BOTTOM;
00093
00094 left = 0;
00095 right = left + TICK_WIDTH;
00096 gl_rect_2d(left, top, right, bottom, color);
00097
00098 left = (S32) (mRect.getWidth() * 1 / 6);
00099 right = left + TICK_WIDTH;
00100 gl_rect_2d(left, top, right, bottom, color);
00101
00102 left = (S32) (mRect.getWidth() * 2 / 6);
00103 right = left + TICK_WIDTH;
00104 gl_rect_2d(left, top, right, bottom, color);
00105
00106 left = (S32) (mRect.getWidth() * 3 / 6);
00107 right = left + TICK_WIDTH;
00108 gl_rect_2d(left, top, right, bottom, color);
00109
00110 left = (S32) (mRect.getWidth() * 4 / 6);
00111 right = left + TICK_WIDTH;
00112 gl_rect_2d(left, top, right, bottom, color);
00113
00114 left = (S32) (mRect.getWidth() * 5 / 6);
00115 right = left + TICK_WIDTH;
00116 gl_rect_2d(left, top, right, bottom, color);
00117
00118 left = (S32) (mRect.getWidth() * 6 / 6);
00119 right = left + TICK_WIDTH;
00120 gl_rect_2d(left, top, right, bottom, color);
00121
00122
00123
00124 LLGLSTexture gls_texture;
00125
00126 top = BAR_TOP + 15;
00127 left = 0;
00128 char str[80];
00129 snprintf(str, sizeof(str), "Velocity %.3fm/s", velocity);
00130 LLFontGL::sMonospace->renderUTF8(str, 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00131
00132 top = TICK_BOTTOM;
00133
00134 left = - MAGIC_CHAR_WIDTH/2;
00135 LLFontGL::sMonospace->renderUTF8("0", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00136
00137 left = (mRect.getWidth()*1 / 6) - MAGIC_CHAR_WIDTH * 2;
00138 LLFontGL::sMonospace->renderUTF8("1", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00139
00140 left = (mRect.getWidth()*2 / 6) - MAGIC_CHAR_WIDTH;
00141 LLFontGL::sMonospace->renderUTF8("2", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00142
00143 left = (mRect.getWidth()*3 / 6) - MAGIC_CHAR_WIDTH * 2;
00144 LLFontGL::sMonospace->renderUTF8("3", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00145
00146 left = (mRect.getWidth()*4 / 6) - MAGIC_CHAR_WIDTH;
00147 LLFontGL::sMonospace->renderUTF8("4", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00148
00149 left = (mRect.getWidth()*5 / 6) - MAGIC_CHAR_WIDTH * 2;
00150 LLFontGL::sMonospace->renderUTF8("5", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00151
00152 left = (mRect.getWidth()*6 / 6) - MAGIC_CHAR_WIDTH * 3;
00153 LLFontGL::sMonospace->renderUTF8("6 m/s", 0, left, top, color, LLFontGL::LEFT, LLFontGL::TOP);
00154
00155
00156 top = BAR_TOP;
00157 bottom = BAR_BOTTOM;
00158
00159
00160 left = 0;
00161 right = (S32) (left + velocity * 0.33333f * mRect.getWidth() / 2.f);
00162 gl_rect_2d(left, top, right, bottom, bar_color);
00163 }