2016-02-29 22:28:18 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2015 Dimok
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
#include "ProgressWindow.h"
|
2019-08-15 10:53:52 +02:00
|
|
|
#include <gui/video/CVideo.h>
|
2016-02-29 22:28:18 +01:00
|
|
|
|
|
|
|
ProgressWindow::ProgressWindow(const std::string & title)
|
|
|
|
: GuiFrame(0, 0)
|
|
|
|
, bgImageData(Resources::GetImageData("progressWindow.png"))
|
|
|
|
, bgImage(bgImageData)
|
2019-08-15 10:53:52 +02:00
|
|
|
, progressImageBlack(bgImage.getWidth(), bgImage.getHeight()/2, (GX2Color) {
|
|
|
|
0, 0, 0, 255
|
|
|
|
})
|
|
|
|
, progressImageColored(bgImage.getWidth(), bgImage.getHeight()/2, (GX2Color) {
|
|
|
|
0, 0, 0, 255
|
|
|
|
}) {
|
2016-11-04 20:47:39 +01:00
|
|
|
titleChanged = false;
|
|
|
|
currentTitle = title;
|
2016-02-29 22:28:18 +01:00
|
|
|
width = bgImage.getWidth();
|
|
|
|
height = bgImage.getHeight();
|
|
|
|
|
|
|
|
append(&progressImageBlack);
|
|
|
|
append(&progressImageColored);
|
|
|
|
append(&bgImage);
|
|
|
|
|
|
|
|
progressImageColored.setAlignment(ALIGN_TOP_LEFT);
|
2019-08-15 10:53:52 +02:00
|
|
|
progressImageColored.setImageColor((GX2Color) {
|
|
|
|
42, 159, 217, 255
|
|
|
|
}, 0);
|
|
|
|
progressImageColored.setImageColor((GX2Color) {
|
|
|
|
42, 159, 217, 255
|
|
|
|
}, 1);
|
|
|
|
progressImageColored.setImageColor((GX2Color) {
|
|
|
|
13, 104, 133, 255
|
|
|
|
}, 2);
|
|
|
|
progressImageColored.setImageColor((GX2Color) {
|
|
|
|
13, 104, 133, 255
|
|
|
|
}, 3);
|
2016-02-29 22:28:18 +01:00
|
|
|
|
|
|
|
titleText.setColor(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
|
|
|
titleText.setFontSize(36);
|
|
|
|
titleText.setAlignment(ALIGN_LEFT | ALIGN_MIDDLE);
|
|
|
|
titleText.setPosition(50, 0);
|
|
|
|
titleText.setBlurGlowColor(5.0f, glm::vec4(0.0, 0.0, 0.0f, 1.0f));
|
2016-11-04 20:47:39 +01:00
|
|
|
titleText.setText(currentTitle.c_str());
|
2016-02-29 22:28:18 +01:00
|
|
|
append(&titleText);
|
|
|
|
|
|
|
|
progressImageColored.setParent(&progressImageBlack);
|
|
|
|
titleText.setParent(&progressImageBlack);
|
|
|
|
|
|
|
|
setProgress(0.0f);
|
|
|
|
}
|
|
|
|
|
2019-08-15 10:53:52 +02:00
|
|
|
ProgressWindow::~ProgressWindow() {
|
2016-02-29 22:28:18 +01:00
|
|
|
Resources::RemoveImageData(bgImageData);
|
|
|
|
}
|
|
|
|
|
2019-08-15 10:53:52 +02:00
|
|
|
void ProgressWindow::setTitle(const std::string & title) {
|
2016-11-04 20:47:39 +01:00
|
|
|
titleMutex.lock();
|
|
|
|
currentTitle = title;
|
|
|
|
titleChanged = true;
|
|
|
|
titleMutex.unlock();
|
2016-02-29 22:28:18 +01:00
|
|
|
}
|
|
|
|
|
2019-08-15 10:53:52 +02:00
|
|
|
void ProgressWindow::setProgress(float percent) {
|
2016-02-29 22:28:18 +01:00
|
|
|
progressImageColored.setSize(percent * 0.01f * progressImageBlack.getWidth(), progressImageColored.getHeight());
|
|
|
|
}
|
2016-11-04 20:47:39 +01:00
|
|
|
|
2019-08-15 10:53:52 +02:00
|
|
|
void ProgressWindow::draw(CVideo * v) {
|
|
|
|
if(titleChanged) {
|
2016-11-04 20:47:39 +01:00
|
|
|
titleMutex.lock();
|
|
|
|
titleChanged = false;
|
|
|
|
titleText.setText(currentTitle.c_str());
|
|
|
|
titleMutex.unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
GuiFrame::draw(v);
|
|
|
|
}
|