| 1 | // SuperTux |
| 2 | // Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com> |
| 3 | // |
| 4 | // This program is free software: you can redistribute it and/or modify |
| 5 | // it under the terms of the GNU General Public License as published by |
| 6 | // the Free Software Foundation, either version 3 of the License, or |
| 7 | // (at your option) any later version. |
| 8 | // |
| 9 | // This program is distributed in the hope that it will be useful, |
| 10 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | // GNU General Public License for more details. |
| 13 | // |
| 14 | // You should have received a copy of the GNU General Public License |
| 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | #include <string> |
| 18 | |
| 19 | #include "util/log.hpp" |
| 20 | #include "video/blend.hpp" |
| 21 | |
| 22 | Blend |
| 23 | Blend_from_string(const std::string& text) |
| 24 | { |
| 25 | if (text == "none" ) |
| 26 | { |
| 27 | return Blend::NONE; |
| 28 | } |
| 29 | else if (text == "blend" ) |
| 30 | { |
| 31 | return Blend::BLEND; |
| 32 | } |
| 33 | else if (text == "add" ) |
| 34 | { |
| 35 | return Blend::ADD; |
| 36 | } |
| 37 | else if (text == "mod" ) |
| 38 | { |
| 39 | return Blend::MOD; |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | log_warning << "unknown blend mode: '" << text << "'" << std::endl; |
| 44 | return Blend::BLEND; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | std::string |
| 49 | Blend_to_string(Blend blend) |
| 50 | { |
| 51 | if (blend == Blend::NONE) |
| 52 | { |
| 53 | return "none" ; |
| 54 | } |
| 55 | else if (blend == Blend::BLEND) |
| 56 | { |
| 57 | return "blend" ; |
| 58 | } |
| 59 | else if (blend == Blend::ADD) |
| 60 | { |
| 61 | return "add" ; |
| 62 | } |
| 63 | else if (blend == Blend::MOD) |
| 64 | { |
| 65 | return "mod" ; |
| 66 | } |
| 67 | else |
| 68 | { |
| 69 | log_warning << "unknown blend mode: " << static_cast<int>(blend) << std::endl; |
| 70 | return "blend" ; |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | /* EOF */ |
| 75 | |