Esempio n. 1
0
/**
 * @brief Loads a localization file
 * @param[in] language
 */
void I18N_SetLanguage(const char *language)
{
	// TODO: check if there is a localization file available for the selected language
	dictionary.set_language(tinygettext::Language::from_env(std::string(language)));
	dictionary_mod.set_language(tinygettext::Language::from_env(std::string(language)));

	Com_Printf("Language set to %s\n", dictionary.get_language().get_name().c_str());
	Com_sprintf(cl_lang_last, sizeof(cl_lang_last), "%s", language);

	if (!Q_stricmp(cl_lang->string, "en"))
	{
		doTranslate = qfalse;
	}
	else
	{
		doTranslate = qtrue;
	}

	strings.clear();
}
Esempio n. 2
0
void
PingusMain::apply_args()
{
  // FIXME: merge cmd_options with stuff read from config file here
  auto& options = cmd_options;

  // Mode toggles
  if (options.list_languages.is_set() &&
      options.list_languages.get())
  { // language listing only works after the data path has been set
    std::cout << "Available languages are:" << std::endl;
    std::cout << "========================" << std::endl;
    std::set<tinygettext::Language> lst = dictionary_manager.get_languages();
    for (std::set<tinygettext::Language>::iterator i = lst.begin(); i != lst.end(); ++i)
      std::cout << i->get_name() << " (" << i->str() << ")" << std::endl;

    std::cout << "\nLanguages can be used via:\n\n    pingus --language de\n" << std::endl; 

    exit(EXIT_SUCCESS);
  }

  if (options.software_cursor.is_set())
    globals::software_cursor = options.software_cursor.get();

  // Sound
  if (options.disable_music.is_set())
    globals::music_enabled = !options.disable_music.get();

  if (options.disable_sound.is_set())
    globals::sound_enabled = !options.disable_sound.get();

  // Misc
  if (options.language.is_set())
    dictionary_manager.set_language(tinygettext::Language::from_name(options.language.get()));

  if (options.auto_scrolling.is_set())
    globals::auto_scrolling = options.auto_scrolling.get();

  if (options.drag_drop_scrolling.is_set())
    globals::drag_drop_scrolling = options.drag_drop_scrolling.get();
  
  if (options.developer_mode.is_set())
    globals::developer_mode = options.developer_mode.get();

  if (options.speed.is_set())
    globals::game_speed = options.speed.get();

  if (options.desiredfps.is_set())
    globals::desired_fps = options.desiredfps.get();

  if (options.tile_size.is_set())
    globals::tile_size = options.tile_size.get();
}
Esempio n. 3
0
void
ConfigManager::set_language(const tinygettext::Language& v)
{
  log_info("%1%", v.str());

  if (v != get_language())
  {
    dictionary_manager.set_language(v);
    on_language_change(v);
  }

  m_opts.language.set(v.str());
}
Esempio n. 4
0
int
PingusMain::run(int argc, char** argv)
{
  g_logger.set_log_level(Logger::kWarning);

  tinygettext::Log::set_log_info_callback(0);

  try
  {
    // FIXME force set language using System::get_language() to get it from env
    dictionary_manager.set_language(tinygettext::Language::from_env(System::get_language()));
    
    parse_args(argc, argv); // here language and po dir isn't set, no traslation in command line
    init_path_finder(); // here init language path
    read_rc_file(); // here set language if ~/.pingus/config exist and language value is set
    apply_args(); // here set language if arg -l is specified
    
    print_greeting_message();
    
    // init the display
    FramebufferType fbtype = SDL_FRAMEBUFFER; 
    if (cmd_options.framebuffer_type.is_set())
    {
      fbtype = cmd_options.framebuffer_type.get();
    }

    bool fullscreen = cmd_options.fullscreen.is_set() ? cmd_options.fullscreen.get() : false;
    bool resizable  = cmd_options.resizable.is_set()  ? cmd_options.resizable.get()  : true;

    Size screen_size(800, 600);
    if (fullscreen)
    {
      if (cmd_options.fullscreen_resolution.is_set())
      {
        screen_size = cmd_options.fullscreen_resolution.get();
      }
    }
    else
    {
      if (cmd_options.geometry.is_set())
      {
        screen_size = cmd_options.geometry.get();
      }
    }

    SDLSystem system;
    try
    {
      system.create_window(fbtype, screen_size, fullscreen, resizable);
    }
    catch(const std::exception& err)
    {
      if (fbtype == SDL_FRAMEBUFFER)
      {
        throw;
      }
      else
      {
        log_error("couldn't create window, falling back to SDL: " << err.what());
        system.create_window(SDL_FRAMEBUFFER, screen_size, fullscreen, resizable);
        config_manager.set_renderer(SDL_FRAMEBUFFER);
      }
    }

    // init other components
    SavegameManager savegame_manager("savegames/savegames.scm");
    StatManager stat_manager("savegames/variables.scm");

    // FIXME: turn these into RAII 
    Resource::init();
    Fonts::init();
    Sound::PingusSound::init();
    
    config_manager.apply(cmd_options);

    // start and run the actual game
    start_game();
  }
  catch (const std::bad_alloc&) 
  {
    std::cout << _("Pingus: Out of memory!") << std::endl;
  }
  catch (const std::exception& a) 
  {
    std::cout << _("Pingus: Standard exception caught!:\n") << a.what() << std::endl;
  }
  catch (...) 
  {
    std::cout << _("Pingus: Unknown throw caught!") << std::endl;
  }

  Sound::PingusSound::deinit();
  Fonts::deinit();
  WorldObjFactory::deinit();
  Resource::deinit();

  return 0;
}