From 2947d6af4334a736eab6ea1ad8147239311ea027 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 3 Apr 2014 12:27:09 +0300 Subject: Remove duplicate code from theme. --- src/gui/theme.cpp | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3-60-g2f50