1 | // SuperTux |
---|---|
2 | // Copyright (C) 2009 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 "worldmap/direction.hpp" |
18 | |
19 | #include "editor/object_option.hpp" |
20 | #include "util/gettext.hpp" |
21 | #include "util/log.hpp" |
22 | |
23 | namespace worldmap { |
24 | |
25 | Direction reverse_dir(Direction direction) |
26 | { |
27 | switch (direction) |
28 | { |
29 | case Direction::WEST: |
30 | return Direction::EAST; |
31 | case Direction::EAST: |
32 | return Direction::WEST; |
33 | case Direction::NORTH: |
34 | return Direction::SOUTH; |
35 | case Direction::SOUTH: |
36 | return Direction::NORTH; |
37 | case Direction::NONE: |
38 | return Direction::NONE; |
39 | } |
40 | return Direction::NONE; |
41 | } |
42 | |
43 | std::string |
44 | direction_to_string(Direction direction) |
45 | { |
46 | switch (direction) |
47 | { |
48 | case Direction::WEST: |
49 | return "west"; |
50 | case Direction::EAST: |
51 | return "east"; |
52 | case Direction::NORTH: |
53 | return "north"; |
54 | case Direction::SOUTH: |
55 | return "south"; |
56 | default: |
57 | return "none"; |
58 | } |
59 | } |
60 | |
61 | Direction |
62 | string_to_direction(const std::string& directory) |
63 | { |
64 | if (directory == "west") |
65 | return Direction::WEST; |
66 | else if (directory == "east") |
67 | return Direction::EAST; |
68 | else if (directory == "north") |
69 | return Direction::NORTH; |
70 | else if (directory == "south") |
71 | return Direction::SOUTH; |
72 | else if (directory == "none") |
73 | return Direction::NONE; |
74 | else { |
75 | log_warning << "unknown direction: \""<< directory << "\""<< std::endl; |
76 | return Direction::NONE; |
77 | } |
78 | } |
79 | |
80 | } // namespace worldmap |
81 | |
82 | /* EOF */ |
83 |