diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-04-03 12:27:09 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-04-03 12:27:09 +0300 |
commit | 2947d6af4334a736eab6ea1ad8147239311ea027 (patch) | |
tree | b58e2f2f5ad4f0ee970821464ad6f01f07c85bd0 /src/gui/theme.cpp | |
parent | da87d0f7ce54182e3ea89a512ce3c24d5d06405e (diff) | |
download | manaplus-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.cpp | 35 |
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; } |