summaryrefslogtreecommitdiff
path: root/src/gui/playerbox.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-21 13:36:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-05-21 13:36:56 +0000
commite5f70463119360222400e6b3529b7ab8748317ae (patch)
tree143f1fabdc6ea5532326b9e1fd1e0266b460f169 /src/gui/playerbox.cpp
parent7267fc408fd21dbc01a621aaa5a9e2115e297ff0 (diff)
downloadmana-e5f70463119360222400e6b3529b7ab8748317ae.tar.gz
mana-e5f70463119360222400e6b3529b7ab8748317ae.tar.bz2
mana-e5f70463119360222400e6b3529b7ab8748317ae.tar.xz
mana-e5f70463119360222400e6b3529b7ab8748317ae.zip
Only load resources once for player box, scroll area and text field. Also
tweaked the look a little, needs to be checked for opaque problem.
Diffstat (limited to 'src/gui/playerbox.cpp')
-rw-r--r--src/gui/playerbox.cpp48
1 files changed, 35 insertions, 13 deletions
diff --git a/src/gui/playerbox.cpp b/src/gui/playerbox.cpp
index b97b37b3..9514d335 100644
--- a/src/gui/playerbox.cpp
+++ b/src/gui/playerbox.cpp
@@ -27,6 +27,9 @@
#include "../main.h"
#include "../resources/resourcemanager.h"
+int PlayerBox::instances = 0;
+ImageRect PlayerBox::background;
+
PlayerBox::PlayerBox():
hairColor(0),
hairStyle(0),
@@ -34,20 +37,39 @@ PlayerBox::PlayerBox():
{
setBorderSize(2);
- // Load the background skin
- ResourceManager *resman = ResourceManager::getInstance();
- Image *textbox = resman->getImage("graphics/gui/textbox.png");
- int bggridx[4] = {0, 9, 16, 25};
- int bggridy[4] = {0, 4, 19, 24};
- int a = 0, x, y;
+ if (instances == 0)
+ {
+ // Load the background skin
+ ResourceManager *resman = ResourceManager::getInstance();
+ Image *textbox = resman->getImage("graphics/gui/deepbox.png");
+ int bggridx[4] = {0, 3, 28, 31};
+ int bggridy[4] = {0, 3, 28, 31};
+ int a = 0, x, y;
+
+ for (y = 0; y < 3; y++) {
+ for (x = 0; x < 3; x++) {
+ background.grid[a] = textbox->getSubImage(
+ bggridx[x], bggridy[y],
+ bggridx[x + 1] - bggridx[x] + 1,
+ bggridy[y + 1] - bggridy[y] + 1);
+ a++;
+ }
+ }
+
+ textbox->decRef();
+ }
+
+ instances++;
+}
- for (y = 0; y < 3; y++) {
- for (x = 0; x < 3; x++) {
- background.grid[a] = textbox->getSubImage(
- bggridx[x], bggridy[y],
- bggridx[x + 1] - bggridx[x] + 1,
- bggridy[y + 1] - bggridy[y] + 1);
- a++;
+PlayerBox::~PlayerBox()
+{
+ instances--;
+
+ if (instances == 0)
+ {
+ for (int a = 0; a < 9; a++) {
+ delete background.grid[a];
}
}
}