summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-04-03 12:27:09 +0300
committerAndrei Karas <akaras@inbox.ru>2014-04-03 12:27:09 +0300
commit2947d6af4334a736eab6ea1ad8147239311ea027 (patch)
treeb58e2f2f5ad4f0ee970821464ad6f01f07c85bd0 /src/gui/theme.cpp
parentda87d0f7ce54182e3ea89a512ce3c24d5d06405e (diff)
downloadmanaplus-2947d6af4334a736eab6ea1ad8147239311ea027.tar.gz
manaplus-2947d6af4334a736eab6ea1ad8147239311ea027.tar.bz2
manaplus-2947d6af4334a736eab6ea1ad8147239311ea027.tar.xz
manaplus-2947d6af4334a736eab6ea1ad8147239311ea027.zip
Remove duplicate code from theme.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index 6fa007e06..1b1955647 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -1126,6 +1126,19 @@ void Theme::loadColors(std::string file)
}
}
+#define loadGrid() \
+ { \
+ const ImageRect &rect = skin->getBorder(); \
+ for (int f = start; f <= end; f ++) \
+ { \
+ if (rect.grid[f]) \
+ { \
+ image.grid[f] = rect.grid[f]; \
+ image.grid[f]->incRef(); \
+ } \
+ } \
+ }
+
void Theme::loadRect(ImageRect &image,
const std::string &name,
const std::string &name2,
@@ -1135,15 +1148,7 @@ void Theme::loadRect(ImageRect &image,
Skin *const skin = load(name, name2, false);
if (skin)
{
- const ImageRect &rect = skin->getBorder();
- for (int f = start; f <= end; f ++)
- {
- if (rect.grid[f])
- {
- image.grid[f] = rect.grid[f];
- image.grid[f]->incRef();
- }
- }
+ loadGrid();
unload(skin);
}
}
@@ -1156,17 +1161,7 @@ Skin *Theme::loadSkinRect(ImageRect &image,
{
Skin *const skin = load(name, name2);
if (skin)
- {
- const ImageRect &rect = skin->getBorder();
- for (int f = start; f <= end; f ++)
- {
- if (rect.grid[f])
- {
- image.grid[f] = rect.grid[f];
- image.grid[f]->incRef();
- }
- }
- }
+ loadGrid();
return skin;
}