Mana
Loading...
Searching...
No Matches
progressindicator.cpp
Go to the documentation of this file.
1/*
2 * The Mana Client
3 * Copyright (C) 2010-2012 The Mana Developers
4 *
5 * This file is part of The Mana Client.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "progressindicator.h"
22
23#include "graphics.h"
24#include "gui/gui.h"
25#include "simpleanimation.h"
26
27#include "resources/animation.h"
29#include "resources/theme.h"
30
31#include <guichan/widgets/label.hpp>
32
34{
35 const std::string path = gui->getTheme()->resolvePath("progress-indicator.png");
37
38 Animation anim;
39 for (size_t i = 0; i < mImageSet->size(); ++i)
40 anim.addFrame(mImageSet->get(i), 100, 0, 0);
41
42 mIndicator = std::make_unique<SimpleAnimation>(std::move(anim));
43
44 setSize(32, 32);
45}
46
48
53
55{
56 // Draw the indicator centered on the widget
57 const int x = (getWidth() - 32) / 2;
58 const int y = (getHeight() - 32) / 2;
59 mIndicator->draw(static_cast<Graphics*>(graphics), x, y);
60}
An animation consists of several frames, each with their own delay and offset.
Definition animation.h:47
void addFrame(Image *image, int delay, int offsetX, int offsetY)
Appends a new animation at the end of the sequence.
Definition animation.cpp:29
A central point of control for graphics.
Definition graphics.h:78
Theme * getTheme() const
The global GUI theme.
Definition gui.h:138
Image * get(size_t i) const
Definition imageset.cpp:49
size_t size() const
Definition imageset.h:58
~ProgressIndicator() override
std::unique_ptr< SimpleAnimation > mIndicator
void draw(gcn::Graphics *graphics) override
void logic() override
ResourceRef< ImageSet > mImageSet
static ResourceManager * getInstance()
Returns an instance of the class, creating one if it does not already exist.
ResourceRef< ImageSet > getImageSet(const std::string &imagePath, int w, int h)
Loads a image set based on the image referenced by the given path and the supplied sprite sizes.
std::string resolvePath(const std::string &path) const
Returns the patch to the given GUI resource relative to the theme or, if it isn't in the theme,...
Definition theme.cpp:284
Graphics * graphics
Definition client.cpp:104
Gui * gui
The GUI system.
Definition gui.cpp:50
unsigned deltaTimeMs()
The time in milliseconds since the last frame, but never more than 1000.
Definition time.cpp:39