Skip to content

Commit

Permalink
ENGINES: Use ScopedPtr in LoadProgress
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Oct 26, 2016
1 parent ea524e7 commit 6467885
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
19 changes: 7 additions & 12 deletions src/engines/aurora/loadprogress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@

namespace Engines {

LoadProgress::LoadProgress(size_t steps) : _steps(steps), _currentStep(0), _currentAmount(0.0f),
_startTime(0), _description(0), _barUpper(0), _barLower(0), _progressbar(0), _percent(0) {
LoadProgress::LoadProgress(size_t steps) : _steps(steps), _currentStep(0),
_currentAmount(0.0f), _startTime(0) {

assert(_steps >= 2);

Expand All @@ -51,11 +51,11 @@ LoadProgress::LoadProgress(size_t steps) : _steps(steps), _currentStep(0), _curr
const Common::UString barLowerStr = createProgressbarLower(kBarLength);
const Common::UString barStr = createProgressbar(kBarLength, _currentAmount);

_description = new Graphics::Aurora::Text(font, "");
_barUpper = new Graphics::Aurora::Text(font, barUpperStr);
_barLower = new Graphics::Aurora::Text(font, barLowerStr);
_progressbar = new Graphics::Aurora::Text(font, barStr);
_percent = new Graphics::Aurora::Text(font, "");
_description.reset(new Graphics::Aurora::Text(font, ""));
_barUpper.reset (new Graphics::Aurora::Text(font, barUpperStr));
_barLower.reset (new Graphics::Aurora::Text(font, barLowerStr));
_progressbar.reset(new Graphics::Aurora::Text(font, barStr));
_percent.reset (new Graphics::Aurora::Text(font, ""));

_description->setPosition(0.0f, font.getFont().getHeight());
_percent ->setPosition(0.0f, -font.getFont().getHeight());
Expand All @@ -66,11 +66,6 @@ LoadProgress::LoadProgress(size_t steps) : _steps(steps), _currentStep(0), _curr
}

LoadProgress::~LoadProgress() {
delete _description;
delete _barUpper;
delete _barLower;
delete _progressbar;
delete _percent;
}

void LoadProgress::step(const Common::UString &description) {
Expand Down
11 changes: 6 additions & 5 deletions src/engines/aurora/loadprogress.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <boost/noncopyable.hpp>

#include "src/common/scopedptr.h"
#include "src/common/ustring.h"

namespace Graphics {
Expand Down Expand Up @@ -72,15 +73,15 @@ class LoadProgress : boost::noncopyable {
uint32 _startTime; ///< The timestamp the first step happened.

/** The text containing the description of the current step. */
Graphics::Aurora::Text *_description;
Common::ScopedPtr<Graphics::Aurora::Text> _description;

// The progress bar, in three parts
Graphics::Aurora::Text *_barUpper; ///< The upper border of the progress bar.
Graphics::Aurora::Text *_barLower; ///< The lower border of the progress bar.
Graphics::Aurora::Text *_progressbar; ///< The actual progress bar.
Common::ScopedPtr<Graphics::Aurora::Text> _barUpper; ///< The upper border of the progress bar.
Common::ScopedPtr<Graphics::Aurora::Text> _barLower; ///< The lower border of the progress bar.
Common::ScopedPtr<Graphics::Aurora::Text> _progressbar; ///< The actual progress bar.

/** The text containing the current percentage of done-ness. */
Graphics::Aurora::Text *_percent;
Common::ScopedPtr<Graphics::Aurora::Text> _percent;


static Common::UString createProgressbar(size_t length, double filled);
Expand Down

0 comments on commit 6467885

Please sign in to comment.