コード例 #1
0
KeyboardMenu::KeyboardMenu(InputManager& input_manager) :
  m_input_manager(input_manager)
{
  add_label(_("Setup Keyboard"));
  add_hl();
  add_controlfield(Controller::UP,         _("Up"));
  add_controlfield(Controller::DOWN,       _("Down"));
  add_controlfield(Controller::LEFT,       _("Left"));
  add_controlfield(Controller::RIGHT,      _("Right"));
  add_controlfield(Controller::JUMP,       _("Jump"));
  add_controlfield(Controller::ACTION,     _("Action"));
  add_controlfield(Controller::PEEK_LEFT,  _("Peek Left"));
  add_controlfield(Controller::PEEK_RIGHT, _("Peek Right"));
  add_controlfield(Controller::PEEK_UP,    _("Peek Up"));
  add_controlfield(Controller::PEEK_DOWN,  _("Peek Down"));
  if (g_config->developer_mode) {
    add_controlfield(Controller::CONSOLE, _("Console"));
  }
  if (g_config->developer_mode) {
    add_controlfield(Controller::CHEAT_MENU, _("Cheat Menu"));
  }
  add_hl();
  add_inactive(_("The following feature is deprecated."));
  // l10n: Continuation of string "The following feature is deprecated."
  add_inactive(_("It will be removed from the next release"));
  // l10n: Continuation of string "It will be removed from the next release"
  add_inactive(_("of SuperTux."));
  add_toggle(Controller::CONTROLCOUNT, _("Jump with Up"), &g_config->keyboard_config.jump_with_up_kbd);
  add_hl();
  add_back(_("Back"));
  refresh();
}
コード例 #2
0
ファイル: joystick_menu.cpp プロジェクト: HybridDog/supertux
void
JoystickMenu::recreate_menu()
{
  clear();
  add_label(_("Setup Joystick"));
  add_hl();

  add_toggle(MNID_AUTO_JOYSTICK_CFG, _("Manual Configuration"),
             &m_auto_joystick_cfg)
    .set_help(_("Use manual configuration instead of SDL2's automatic GameController support"));

  if (m_input_manager.use_game_controller())
  {
    m_joysticks_available = false;
  }
  else
  {
    if (m_input_manager.joystick_manager->get_num_joysticks() > 0)
    {
      m_joysticks_available = true;

      add_controlfield(static_cast<int>(Control::UP),          _("Up"));
      add_controlfield(static_cast<int>(Control::DOWN),        _("Down"));
      add_controlfield(static_cast<int>(Control::LEFT),        _("Left"));
      add_controlfield(static_cast<int>(Control::RIGHT),       _("Right"));
      add_controlfield(static_cast<int>(Control::JUMP),        _("Jump"));
      add_controlfield(static_cast<int>(Control::ACTION),      _("Action"));
      add_controlfield(static_cast<int>(Control::START),       _("Pause/Menu"));
      add_controlfield(static_cast<int>(Control::PEEK_LEFT),   _("Peek Left"));
      add_controlfield(static_cast<int>(Control::PEEK_RIGHT),  _("Peek Right"));
      add_controlfield(static_cast<int>(Control::PEEK_UP),     _("Peek Up"));
      add_controlfield(static_cast<int>(Control::PEEK_DOWN),   _("Peek Down"));
      if (g_config->developer_mode) {
        add_controlfield(static_cast<int>(Control::CONSOLE), _("Console"));
      }
      if (g_config->developer_mode) {
        add_controlfield(static_cast<int>(Control::CHEAT_MENU), _("Cheat Menu"));
        add_controlfield(static_cast<int>(Control::DEBUG_MENU), _("Debug Menu"));
      }
      add_toggle(MNID_JUMP_WITH_UP, _("Jump with Up"), &g_config->joystick_config.m_jump_with_up_joy);
    }
    else
    {
      m_joysticks_available = false;

      add_inactive(_("No Joysticks found"));
      add_entry(MNID_SCAN_JOYSTICKS, _("Scan for Joysticks"));
    }
  }

  add_hl();
  add_back(_("Back"));
  refresh();
}
コード例 #3
0
ファイル: addon_menu.cpp プロジェクト: HKingz/supertux
void
AddonMenu::rebuild_menu()
{
  clear();
  add_label(_("Add-ons"));
  add_hl();


  if (m_installed_addons.empty())
  {
    if (!m_repository_addons.empty())
    {
      add_inactive(MNID_NOTHING_NEW, _("No Addons installed"));
    }
    else
    {
      add_inactive(MNID_NOTHING_NEW, _("No Addons found"));
    }
  }
  else
  {
    int idx = 0;
    for (const auto& addon_id : m_installed_addons)
    {
      const Addon& addon = m_addon_manager.get_installed_addon(addon_id);
      std::string text = generate_menu_item_text(addon);
      add_toggle(MAKE_INSTALLED_MENU_ID(idx), text, addon.is_enabled());
      idx += 1;
    }
  }

  add_hl();

  {
    bool have_new_stuff = false;
    int idx = 0;
    for (const auto& addon_id : m_repository_addons)
    {
      const Addon& addon = m_addon_manager.get_repository_addon(addon_id);
      try
      {
        // addon is already installed, so check if they are the same
        Addon& installed_addon = m_addon_manager.get_installed_addon(addon_id);
        if (installed_addon.get_md5() == addon.get_md5() ||
            installed_addon.get_version() > addon.get_version())
        {
          log_debug << "ignoring already installed addon " << installed_addon.get_id() << std::endl;
        }
        else
        {
          log_debug << installed_addon.get_id() << " is installed, but updated: '"
                    << installed_addon.get_md5() << "' vs '" << addon.get_md5() << "'  '"
                    << installed_addon.get_version() << "' vs '" << addon.get_version() << "'"
                    << std::endl;
          std::string text = generate_menu_item_text(addon);
          add_entry(MAKE_REPOSITORY_MENU_ID(idx), str(boost::format( _("Install %s *NEW*") ) % text));
          have_new_stuff = true;
        }
      }
      catch(const std::exception& err)
      {
        // addon is not installed
        std::string text = generate_menu_item_text(addon);
        add_entry(MAKE_REPOSITORY_MENU_ID(idx), str(boost::format( _("Install %s") ) % text));
        have_new_stuff = true;
      }
      idx += 1;
    }

    if (!have_new_stuff && m_addon_manager.has_been_updated())
    {
      add_inactive(MNID_NOTHING_NEW, _("No new Addons found"));
    }
  }

  if (!m_addon_manager.has_online_support())
  {
    add_inactive(MNID_CHECK_ONLINE, std::string(_("Check Online (disabled)")));
  }
  else
  {
    add_entry(MNID_CHECK_ONLINE, std::string(_("Check Online")));
  }

  add_hl();
  add_back(_("Back"));
}
コード例 #4
0
ファイル: options_menu.cpp プロジェクト: bartbarto/supertux
OptionsMenu::OptionsMenu(bool complete) :
  next_magnification(0),
  next_aspect_ratio(0),
  next_resolution(0),
  magnifications(),
  aspect_ratios(),
  resolutions()
{
  add_label(_("Options"));
  add_hl();

  magnifications.clear();
  // These values go from screen:640/projection:1600 to
  // screen:1600/projection:640 (i.e. 640, 800, 1024, 1280, 1600)
  magnifications.push_back(_("auto"));
  magnifications.push_back("40%");
  magnifications.push_back("50%");
  magnifications.push_back("62.5%");
  magnifications.push_back("80%");
  magnifications.push_back("100%");
  magnifications.push_back("125%");
  magnifications.push_back("160%");
  magnifications.push_back("200%");
  magnifications.push_back("250%");
  // Gets the actual magnification:
  if (g_config->magnification != 0.0f) //auto
  {
    std::ostringstream out;
    out << (g_config->magnification*100) << "%";
    std::string magn = out.str();
    size_t count = 0;
    for (std::vector<std::string>::iterator i = magnifications.begin(); i != magnifications.end(); ++i)
    {
      if (*i == magn)
      {
        next_magnification = count;
        magn.clear();
        break;
      }

      ++count;
    }
    if (!magn.empty()) //magnification not in our list but accept anyway
    {
      next_magnification = magnifications.size();
      magnifications.push_back(magn);
    }
  }

  aspect_ratios.clear();
  aspect_ratios.push_back(_("auto"));
  aspect_ratios.push_back("5:4");
  aspect_ratios.push_back("4:3");
  aspect_ratios.push_back("16:10");
  aspect_ratios.push_back("16:9");
  aspect_ratios.push_back("1368:768");
  // Gets the actual aspect ratio:
  if (g_config->aspect_size != Size(0, 0)) //auto
  {
    std::ostringstream out;
    out << g_config->aspect_size.width << ":" << g_config->aspect_size.height;
    std::string aspect_ratio = out.str();
    size_t cnt_ = 0;
    for(std::vector<std::string>::iterator i = aspect_ratios.begin(); i != aspect_ratios.end(); ++i)
    {
      if(*i == aspect_ratio)
      {
        aspect_ratio.clear();
        next_aspect_ratio = cnt_;
        break;
      }
      ++cnt_;
    }

    if (!aspect_ratio.empty())
    {
      next_aspect_ratio = aspect_ratios.size();
      aspect_ratios.push_back(aspect_ratio);
    }
  }

  resolutions.clear();
  int display_mode_count = SDL_GetNumDisplayModes(0);
  std::string last_display_mode;
  for(int i = 0; i < display_mode_count; ++i)
  {
    SDL_DisplayMode mode;
    int ret = SDL_GetDisplayMode(0, i, &mode);
    if (ret != 0)
    {
      log_warning << "failed to get display mode: " << SDL_GetError() << std::endl;
    }
    else
    {
      std::ostringstream out;
      out << mode.w << "x" << mode.h;
      if(mode.refresh_rate)
        out << "@" << mode.refresh_rate;
      if(last_display_mode == out.str())
        continue;
      last_display_mode = out.str();
      resolutions.insert(resolutions.begin(), out.str());
    }
  }
  resolutions.push_back("Desktop");

  std::string fullscreen_size_str = "Desktop";
  {
    std::ostringstream out;
    if (g_config->fullscreen_size != Size(0, 0))
    {
      out << g_config->fullscreen_size.width << "x" << g_config->fullscreen_size.height;
      if (g_config->fullscreen_refresh_rate)
         out << "@" << g_config->fullscreen_refresh_rate;
      fullscreen_size_str = out.str();
    }
  }

  size_t cnt = 0;
  for (std::vector<std::string>::iterator i = resolutions.begin(); i != resolutions.end(); ++i)
  {
    if (*i == fullscreen_size_str)
    {
      fullscreen_size_str.clear();
      next_resolution = cnt;
      break;
    }
    ++cnt;
  }
  if (!fullscreen_size_str.empty())
  {
    next_resolution = resolutions.size();
    resolutions.push_back(fullscreen_size_str);
  }

  if (complete)
  {
    // Language and profile changes are only be possible in the
    // main menu, since elsewhere it might not always work fully
    add_submenu(_("Select Language"), MenuStorage::LANGUAGE_MENU)
      ->set_help(_("Select a different language to display text in"));

    add_submenu(_("Select Profile"), MenuStorage::PROFILE_MENU)
      ->set_help(_("Select a profile to play with"));
  }

  add_toggle(MNID_FULLSCREEN,_("Fullscreen"), &g_config->use_fullscreen)
    ->set_help(_("Fill the entire screen"));

  MenuItem* fullscreen_res = add_string_select(MNID_FULLSCREEN_RESOLUTION, _("Resolution"), &next_resolution, resolutions);
  fullscreen_res->set_help(_("Determine the resolution used in fullscreen mode (you must toggle fullscreen to complete the change)"));

  MenuItem* magnification = add_string_select(MNID_MAGNIFICATION, _("Magnification"), &next_magnification, magnifications);
  magnification->set_help(_("Change the magnification of the game area"));

  MenuItem* aspect = add_string_select(MNID_ASPECTRATIO, _("Aspect Ratio"), &next_aspect_ratio, aspect_ratios);
  aspect->set_help(_("Adjust the aspect ratio"));

  if (SoundManager::current()->is_audio_enabled()) {
    add_toggle(MNID_SOUND, _("Sound"), &g_config->sound_enabled)
      ->set_help(_("Disable all sound effects"));
    add_toggle(MNID_MUSIC, _("Music"), &g_config->music_enabled)
      ->set_help(_("Disable all music"));
  } else {
    add_inactive( _("Sound (disabled)"));
    add_inactive( _("Music (disabled)"));
  }

  add_submenu(_("Setup Keyboard"), MenuStorage::KEYBOARD_MENU)
    ->set_help(_("Configure key-action mappings"));

  add_submenu(_("Setup Joystick"), MenuStorage::JOYSTICK_MENU)
    ->set_help(_("Configure joystick control-action mappings"));

  MenuItem* enable_transitions = add_toggle(MNID_TRANSITIONS, _("Enable transitions"), &g_config->transitions_enabled);
  enable_transitions->set_help(_("Enable screen transitions and smooth menu animation"));

  if (g_config->developer_mode)
  {
    add_toggle(MNID_DEVELOPER_MODE, _("Developer Mode"), &g_config->developer_mode);
  }

  if (g_config->is_christmas() || g_config->christmas_mode)
  {
    add_toggle(MNID_CHRISTMAS_MODE, _("Christmas Mode"), &g_config->christmas_mode);
  }

  add_hl();
  add_back(_("Back"));
}
コード例 #5
0
ファイル: addon_menu.cpp プロジェクト: lowagner/supertux
void
AddonMenu::refresh()
{
  clear();

  AddonManager& adm = AddonManager::get_instance();

  // refresh list of addons
  m_addons = adm.get_addons();
  
  // sort list
  std::sort(m_addons.begin(), m_addons.end(), generate_addons_menu_sorter);


  add_label(_("Add-ons"));
  add_hl();

  // FIXME: don't use macro, use AddonManager::online_available() or so
#ifdef HAVE_LIBCURL
  add_entry(0, std::string(_("Check Online")));
#else
  add_inactive(0, std::string(_("Check Online (disabled)")));
#endif

  //add_hl();

  for (unsigned int i = 0; i < m_addons.size(); i++) 
  {
    const Addon& addon = *m_addons[i];
    std::string text = "";
    
    if (!addon.kind.empty())
    {
      std::string kind = addon.kind;
      if(addon.kind == "Levelset") {
        kind = _("Levelset");
      }
      else if(addon.kind == "Worldmap") {
        kind = _("Worldmap");
      }
      else if(addon.kind == "World") {
        kind = _("World");
      }
      else if(addon.kind == "Level") {
        kind = _("Level");
      }


      if(!addon.author.empty())
      {
        text = str(boost::format(_("%s \"%s\" by \"%s\""))
                   % kind % addon.title % addon.author);
      }
      else
      {
        // Only addon type and name, no need for translation.
        text = str(boost::format("%s \"%s\"")
                   % kind % addon.title);
      }
    }
    else
    {
      if (!addon.author.empty())
      {
        text = str(boost::format(_("\"%s\" by \"%s\""))
                   % addon.title % addon.author);
      }
      else {
        // Only addon name, no need for translation.
        text = str(boost::format("\"%s\"")
                   % addon.title);
      }
    }
    add_toggle(ADDON_LIST_START_ID + i, text, addon.loaded);
  }

  add_hl();
  add_back(_("Back"));
}