StelLoadingBar.cpp   StelLoadingBar.cpp 
skipping to change at line 25 skipping to change at line 25
* 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 "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelMainGraphicsView.hpp"
#include "StelPainter.hpp" #include "StelPainter.hpp"
#include "StelCore.hpp" #include "StelCore.hpp"
#include <QDebug> #include <QDebug>
#include <QtOpenGL> #include <QtOpenGL>
StelLoadingBar::StelLoadingBar(float fontSize, const QString& splashTex, StelLoadingBar::StelLoadingBar(const QString& splashTex,
const QString& extraTextString, float extraTextSize, const QString& extraTextString, float extraTextSize,
float extraTextPosx, float extraTextPosy) : float extraTextPosx, float extraTextPosy, int aWidth, int aHeight) :
width(512), height(512), barwidth(400), barheight(10), extraText(ext width(aWidth), height(aHeight), extraText(extraTextString), sPainter
raTextString), sPainter(NULL) (NULL)
{ {
barfont.setPixelSize(fontSize);
extraTextFont.setPixelSize(extraTextSize); extraTextFont.setPixelSize(extraTextSize);
sPainter = new StelPainter(StelApp::getInstance().getCore()->getProj ection2d()); sPainter = new StelPainter(StelApp::getInstance().getCore()->getProj ection2d());
int screenw = sPainter->getProjector()->getViewportWidth(); int screenw = sPainter->getProjector()->getViewportWidth();
int screenh = sPainter->getProjector()->getViewportHeight(); int screenh = sPainter->getProjector()->getViewportHeight();
splashx = sPainter->getProjector()->getViewportPosX() + (screenw - w idth)/2; splashx = sPainter->getProjector()->getViewportPosX() + (screenw - w idth)/2;
splashy = sPainter->getProjector()->getViewportPosY() + (screenh - h eight)/2; splashy = sPainter->getProjector()->getViewportPosY() + (screenh - h eight)/2;
barx = sPainter->getProjector()->getViewportPosX() + (screenw - barw
idth)/2;
bary = splashy + 34;
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();
} }
StelLoadingBar::~StelLoadingBar() StelLoadingBar::~StelLoadingBar()
{ {
delete sPainter; delete sPainter;
} }
void StelLoadingBar::Draw(float val) void StelLoadingBar::draw()
{ {
// Ensure that the refresh frequency is not too high sPainter->setColor(1.f, 1.f, 1.f);
// (display may be very slow when no 3D acceleration works) sPainter->enableTexture2d(true);
if (StelApp::getInstance().getTotalRunTime()-timeCounter<0.050) glEnable(GL_BLEND);
return; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
timeCounter = StelApp::getInstance().getTotalRunTime();
if (val>1.)
val = 1.;
// Draw the splash screen if available // Draw the splash screen if available
if (splash) if (splash)
{ {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
sPainter->enableTexture2d(true);
sPainter->setColor(1., 1., 1.);
splash->bind(); splash->bind();
sPainter->drawRect2d(splashx, splashy, width, height); sPainter->drawRect2d(splashx, splashy, width, height);
} }
sPainter->enableTexture2d(false);
// black out background of text for redraws (so can keep sky unalter
ed)
sPainter->setColor(0, 0, 0, 1);
sPainter->drawRect2d(barx, bary-5, barwidth, 12., false);
sPainter->setColor(0.8, 0.8, 1, 1);
sPainter->drawRect2d(barx, bary, barwidth, barheight, false);
sPainter->setColor(0.4f, 0.4f, 0.6f, 1.f);
sPainter->drawRect2d(barx+1, bary+1, barwidth * val-2, barheight-2,
false);
sPainter->setColor(1, 1, 1, 1);
sPainter->enableTexture2d(true);
glEnable(GL_BLEND);
sPainter->setFont(barfont);
sPainter->drawText(barx, bary-sPainter->getFontMetrics().height()-1,
message);
sPainter->setFont(extraTextFont); sPainter->setFont(extraTextFont);
sPainter->drawText(splashx + extraTextPos[0], splashy + extraTextPos [1]-sPainter->getFontMetrics().height()-1, extraText); sPainter->drawText(splashx + extraTextPos[0], splashy + extraTextPos [1]-sPainter->getFontMetrics().height()-1, extraText);
StelPainter::swapBuffer(); // And swap the buffers
StelMainGraphicsView::getInstance().swapBuffer(); // And swap
the buffers
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT);
} }
 End of changes. 13 change blocks. 
45 lines changed or deleted 10 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/