StelLoadingBar.cpp   StelLoadingBar.cpp 
skipping to change at line 24 skipping to change at line 24
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U SA.
*/ */
#include "StelProjector.hpp" #include "StelProjector.hpp"
#include "StelLoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelFontMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "StelFont.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include <QGLWidget>
#include <QDebug> #include <QDebug>
#include <QtOpenGL>
StelLoadingBar::StelLoadingBar(float fontSize, const QString& splashTex, StelLoadingBar::StelLoadingBar(float fontSize, const QString& splashTex,
const QString& extraTextString, float extraTextSize, const QString& extraTextString, float extraTextSize,
float extraTextPosx, float extraTextPosy) : float extraTextPosx, float extraTextPosy) :
width(512), height(512), barwidth(400), barheight(10), width(512), height(512), barwidth(400), barheight(10), extraText(ext
barfont(StelApp::getInstance().getFontManager().getStandardFont(StelApp::ge raTextString), sPainter(NULL)
tInstance().getLocaleMgr().getAppLanguage(), fontSize)),
extraTextFont(StelApp::getInstance().getFontManager().getStandardFont(StelA
pp::getInstance().getLocaleMgr().getAppLanguage(), extraTextSize)),
extraText(extraTextString)
{ {
const StelProjectorP prj = StelApp::getInstance().getCore()->getProj barfont.setPixelSize(fontSize);
ection2d(); extraTextFont.setPixelSize(extraTextSize);
int screenw = prj->getViewportWidth(); sPainter = new StelPainter(StelApp::getInstance().getCore()->getProj
int screenh = prj->getViewportHeight(); ection2d());
splashx = prj->getViewportPosX() + (screenw - width)/2; int screenw = sPainter->getProjector()->getViewportWidth();
splashy = prj->getViewportPosY() + (screenh - height)/2; int screenh = sPainter->getProjector()->getViewportHeight();
barx = prj->getViewportPosX() + (screenw - barwidth)/2; splashx = sPainter->getProjector()->getViewportPosX() + (screenw - w
idth)/2;
splashy = sPainter->getProjector()->getViewportPosY() + (screenh - h
eight)/2;
barx = sPainter->getProjector()->getViewportPosX() + (screenw - barw
idth)/2;
bary = splashy + 34; bary = splashy + 34;
StelApp::getInstance().getTextureManager().setDefaultParams();
if (!splashTex.isEmpty()) if (!splashTex.isEmpty())
splash = StelApp::getInstance().getTextureManager().createTe xture(splashTex); splash = StelApp::getInstance().getTextureManager().createTe xture(splashTex);
extraTextPos.set(extraTextPosx, extraTextPosy); extraTextPos.set(extraTextPosx, extraTextPosy);
timeCounter = StelApp::getInstance().getTotalRunTime(); timeCounter = StelApp::getInstance().getTotalRunTime();
} }
StelLoadingBar::~StelLoadingBar() StelLoadingBar::~StelLoadingBar()
{ {
delete sPainter;
} }
void StelLoadingBar::Draw(float val) void StelLoadingBar::Draw(float val)
{ {
// Ensure that the refresh frequency is not too high // Ensure that the refresh frequency is not too high
// (display may be very slow when no 3D acceleration works) // (display may be very slow when no 3D acceleration works)
if (StelApp::getInstance().getTotalRunTime()-timeCounter<0.050) if (StelApp::getInstance().getTotalRunTime()-timeCounter<0.050)
return; return;
timeCounter = StelApp::getInstance().getTotalRunTime(); timeCounter = StelApp::getInstance().getTotalRunTime();
if (val>1.) if (val>1.)
val = 1.; val = 1.;
StelPainter sPainter(StelApp::getInstance().getCore()->getProjection
2d());
// Draw the splash screen if available // Draw the splash screen if available
if (splash) if (splash)
{ {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_TEXTURE_2D); sPainter->enableTexture2d(true);
glColor3f(1, 1, 1); sPainter->setColor(1., 1., 1.);
glDisable(GL_CULL_FACE);
splash->bind(); splash->bind();
glBegin(GL_QUADS); sPainter->drawRect2d(splashx, splashy, width, height);
glTexCoord2i(0, 0); // Bottom Left
glVertex2f(splashx, splashy);
glTexCoord2i(1, 0); // Bottom Right
glVertex2f(splashx + width, splashy);
glTexCoord2i(1, 1); // Top Right
glVertex2f(splashx + width, splashy + height);
glTexCoord2i(0, 1); // Top Left
glVertex2f(splashx, splashy + height);
glEnd();
} }
glDisable(GL_BLEND); sPainter->enableTexture2d(false);
glDisable(GL_TEXTURE_2D);
// black out background of text for redraws (so can keep sky unalter ed) // black out background of text for redraws (so can keep sky unalter ed)
glColor3f(0, 0, 0); sPainter->setColor(0, 0, 0, 1);
glBegin(GL_TRIANGLE_STRIP); sPainter->drawRect2d(barx, bary-5, barwidth, 12., false);
glVertex3f(barx + barwidth, bary-17, 0.0f); sPainter->setColor(0.8, 0.8, 1, 1);
glVertex3f(barx, bary-17, 0.0f); sPainter->drawRect2d(barx, bary, barwidth, barheight, false);
glVertex3f(barx + barwidth, bary-5, 0.0f); sPainter->setColor(0.4f, 0.4f, 0.6f, 1.f);
glVertex3f(barx, bary-5, 0.0f); sPainter->drawRect2d(barx+1, bary+1, barwidth * val-2, barheight-2,
glEnd(); false);
glColor3f(0.8, 0.8, 1);
glBegin(GL_TRIANGLE_STRIP); sPainter->setColor(1, 1, 1, 1);
glVertex3f(barx + barwidth, bary + barheight, 0.0f); sPainter->enableTexture2d(true);
glVertex3f(barx, bary + barheight, 0.0f); glEnable(GL_BLEND);
glVertex3f(barx + barwidth, bary, 0.0f); sPainter->setFont(barfont);
glVertex3f(barx, bary, 0.0f); sPainter->drawText(barx, bary-sPainter->getFontMetrics().height()-1,
glEnd(); message);
glColor3f(0.4f, 0.4f, 0.6f); sPainter->setFont(extraTextFont);
glBegin(GL_TRIANGLE_STRIP); sPainter->drawText(splashx + extraTextPos[0], splashy + extraTextPos
glVertex3f(-1 + barx + barwidth * val, bary + barheight - 1, [1]-sPainter->getFontMetrics().height()-1, extraText);
0.0f);
glVertex3f(1 + barx, bary + barheight - 1, 0.0f);
glVertex3f(-1 + barx + barwidth * val, bary + 1, 0.0f);
glVertex3f(1 + barx, bary + 1, 0.0f);
glEnd();
glColor3f(1, 1, 1);
glEnable(GL_TEXTURE_2D);
sPainter.drawText(&barfont, barx, bary-barfont.getLineHeight()-1, me
ssage);
sPainter.drawText(&extraTextFont, splashx + extraTextPos[0], splashy
+ extraTextPos[1]-extraTextFont.getLineHeight()-1, extraText);
StelMainGraphicsView::getInstance().getOpenGLWin()->swapBuffers(); StelMainGraphicsView::getInstance().swapBuffer(); // And swap
// And swap the buffers the buffers
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
 End of changes. 14 change blocks. 
66 lines changed or deleted 40 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/