//  SuperTux
//  Copyright (C) 2009 Ingo Ruhnke <grumbel@gmail.com>
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.

#include "direction.hpp"

#include "editor/object_settings.hpp"
#include "util/log.hpp"

namespace worldmap {

Direction reverse_dir(Direction direction)
{
  switch(direction)
  {
    case D_WEST:
      return D_EAST;
    case D_EAST:
      return D_WEST;
    case D_NORTH:
      return D_SOUTH;
    case D_SOUTH:
      return D_NORTH;
    case D_NONE:
      return D_NONE;
  }
  return D_NONE;
}

std::string
direction_to_string(Direction direction)
{
  switch(direction)
  {
    case D_WEST:
      return "west";
    case D_EAST:
      return "east";
    case D_NORTH:
      return "north";
    case D_SOUTH:
      return "south";
    default:
      return "none";
  }
}

Direction
string_to_direction(const std::string& directory)
{
  if (directory == "west")
    return D_WEST;
  else if (directory == "east")
    return D_EAST;
  else if (directory == "north")
    return D_NORTH;
  else if (directory == "south")
    return D_SOUTH;
  else if (directory == "none")
    return D_NONE;
  else {
    log_warning << "unknown direction: \"" << directory << "\"" << std::endl;
    return D_NONE;
  }
}

ObjectOption
dir_option(Direction *dir) {
  ObjectOption result(MN_STRINGSELECT, _("Direction"), dir);
  result.select.push_back(_("none"));
  result.select.push_back(_("west"));
  result.select.push_back(_("east"));
  result.select.push_back(_("north"));
  result.select.push_back(_("south"));
  return result;
}

} // namespace worldmap

/* EOF */
