LoadingBar.cpp   StelLoadingBar.cpp 
skipping to change at line 20 skipping to change at line 20
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* 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 "Projector.hpp" #include "StelProjector.hpp"
#include "LoadingBar.hpp" #include "StelLoadingBar.hpp"
#include "StelApp.hpp" #include "StelApp.hpp"
#include "StelTextureMgr.hpp" #include "StelTextureMgr.hpp"
#include "StelFontMgr.hpp" #include "StelFontMgr.hpp"
#include "StelLocaleMgr.hpp" #include "StelLocaleMgr.hpp"
#include "StelMainGraphicsView.hpp" #include "StelMainGraphicsView.hpp"
#include "SFont.hpp" #include "StelFont.hpp"
#include "StelPainter.hpp"
#include "StelCore.hpp"
#include <QGLWidget> #include <QGLWidget>
#include <QDebug> #include <QDebug>
LoadingBar::LoadingBar(Projector* _prj, float fontSize, const QString& spl StelLoadingBar::StelLoadingBar(float fontSize, const QString& splashTex,
ashTex, const QString& extraTextString, float extraTextSize,
int screenw, int screenh, const QString& extraTextString, float extr
aTextSize,
float extraTextPosx, float extraTextPosy) : float extraTextPosx, float extraTextPosy) :
prj(_prj), width(512), height(512), barwidth(400), barheight(10), width(512), height(512), barwidth(400), barheight(10),
barfont(StelApp::getInstance().getFontManager().getStandardFont(StelApp::ge tInstance().getLocaleMgr().getAppLanguage(), fontSize)), barfont(StelApp::getInstance().getFontManager().getStandardFont(StelApp::ge tInstance().getLocaleMgr().getAppLanguage(), fontSize)),
extraTextFont(StelApp::getInstance().getFontManager().getStandardFont(StelA pp::getInstance().getLocaleMgr().getAppLanguage(), extraTextSize)), extraTextFont(StelApp::getInstance().getFontManager().getStandardFont(StelA pp::getInstance().getLocaleMgr().getAppLanguage(), extraTextSize)),
extraText(extraTextString) extraText(extraTextString)
{ {
const StelProjectorP prj = StelApp::getInstance().getCore()->getProj
ection2d();
int screenw = prj->getViewportWidth();
int screenh = prj->getViewportHeight();
splashx = prj->getViewportPosX() + (screenw - width)/2; splashx = prj->getViewportPosX() + (screenw - width)/2;
splashy = prj->getViewportPosY() + (screenh - height)/2; splashy = prj->getViewportPosY() + (screenh - height)/2;
barx = prj->getViewportPosX() + (screenw - barwidth)/2; barx = prj->getViewportPosX() + (screenw - barwidth)/2;
bary = splashy + 34; bary = splashy + 34;
StelApp::getInstance().getTextureManager().setDefaultParams(); 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();
} }
LoadingBar::~LoadingBar() StelLoadingBar::~StelLoadingBar()
{ {
} }
void LoadingBar::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); glEnable(GL_TEXTURE_2D);
glColor3f(1, 1, 1); glColor3f(1, 1, 1);
glDisable(GL_CULL_FACE); glDisable(GL_CULL_FACE);
splash->bind(); splash->bind();
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2i(0, 0); // Bottom Left glTexCoord2i(0, 0); // Bottom Left
glVertex3f(splashx, splashy, 0.0f); glVertex2f(splashx, splashy);
glTexCoord2i(1, 0); // Bottom Right glTexCoord2i(1, 0); // Bottom Right
glVertex3f(splashx + width, splashy, 0.0f); glVertex2f(splashx + width, splashy);
glTexCoord2i(1, 1); // Top Right glTexCoord2i(1, 1); // Top Right
glVertex3f(splashx + width, splashy + height, 0.0f); glVertex2f(splashx + width, splashy + height);
glTexCoord2i(0, 1); // Top Left glTexCoord2i(0, 1); // Top Left
glVertex3f(splashx, splashy + height, 0.0f); glVertex2f(splashx, splashy + height);
glEnd(); glEnd();
} }
glDisable(GL_BLEND); glDisable(GL_BLEND);
glDisable(GL_TEXTURE_2D); 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); glColor3f(0, 0, 0);
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
glVertex3f(barx + barwidth, bary-17, 0.0f); glVertex3f(barx + barwidth, bary-17, 0.0f);
glVertex3f(barx, bary-17, 0.0f); glVertex3f(barx, bary-17, 0.0f);
skipping to change at line 113 skipping to change at line 121
glColor3f(0.4f, 0.4f, 0.6f); glColor3f(0.4f, 0.4f, 0.6f);
glBegin(GL_TRIANGLE_STRIP); glBegin(GL_TRIANGLE_STRIP);
glVertex3f(-1 + barx + barwidth * val, bary + barheight - 1, 0.0f); glVertex3f(-1 + barx + barwidth * val, bary + barheight - 1, 0.0f);
glVertex3f(1 + barx, bary + barheight - 1, 0.0f); glVertex3f(1 + barx, bary + barheight - 1, 0.0f);
glVertex3f(-1 + barx + barwidth * val, bary + 1, 0.0f); glVertex3f(-1 + barx + barwidth * val, bary + 1, 0.0f);
glVertex3f(1 + barx, bary + 1, 0.0f); glVertex3f(1 + barx, bary + 1, 0.0f);
glEnd(); glEnd();
glColor3f(1, 1, 1); glColor3f(1, 1, 1);
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
prj->drawText(&barfont, barx, bary-barfont.getLineHeight()-1, messag sPainter.drawText(&barfont, barx, bary-barfont.getLineHeight()-1, me
e); ssage);
prj->drawText(&extraTextFont, splashx + extraTextPos[0], splashy + e sPainter.drawText(&extraTextFont, splashx + extraTextPos[0], splashy
xtraTextPos[1]-extraTextFont.getLineHeight()-1, extraText); + extraTextPos[1]-extraTextFont.getLineHeight()-1, extraText);
StelMainGraphicsView::getInstance().getOpenGLWin()->swapBuffers(); // And swap the buffers StelMainGraphicsView::getInstance().getOpenGLWin()->swapBuffers(); // And swap the buffers
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
} }
 End of changes. 13 change blocks. 
18 lines changed or deleted 26 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/