Пример #1
0
void LoadCurrentCover(int id, struct discHdr *gameList)
{
	#ifndef TEST_MODE
	void *imgData;// = (void *)no_cover_png;

	char filepath[128];
	char titleID[7];

	s32  ret;
	struct discHdr *header = &gameList[id];

	//sprintf(filepath, USBLOADER_PATH "/disks/%c%c%c%c%c%c.png", header->id[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5]);
	sprintf(filepath, "%s/%c%c%c%c%c%c.png", dynPath.dir_disks, header->id[0],header->id[1],header->id[2],header->id[3],header->id[4],header->id[5]);

	ret = Fat_ReadFile(filepath, &imgData);
	
	sprintf(titleID, "%s", header->id);
	getGameSettings(titleID, &gameSetting);
	
	if (ret > 0)
	{
		BufferImageToSlot(&current_cover_texture,(const unsigned char*)imgData,10);

		CFFree(imgData);
	}
	else
	{
		//sprintf(filepath, USBLOADER_PATH "/disks/%c%c%c%c%c%c.png", header->id[0],header->id[1],header->id[2], header->id[3],header->id[4],header->id[5]);
		sprintf(filepath, "%s/%c%c%c%c%c%c.png", dynPath.dir_disks, header->id[0],header->id[1],header->id[2], header->id[3],header->id[4],header->id[5]);

		ret = Fat_ReadFile(filepath, &imgData);
		
		if (ret > 0)
		{
			BufferImageToSlot(&current_cover_texture,(const unsigned char*)imgData,10);
			CFFree(imgData);
		}
		else
		{
			BufferImageToSlot(&current_cover_texture,no_disc_png,10);
		}
	}
	
	#else
	BufferImageToSlot(&current_cover_texture,no_disc_png,10);
	#endif
}
Пример #2
0
void LootState::load(YAML::Node& settings) {
  lock_guard<mutex> guard(mutex_);

  LootSettings::load(settings);

  // Enable/disable debug logging in case it has changed.
  boost::log::core::get()->set_logging_enabled(isDebugLoggingEnabled());

  // Update existing games, add new games.
  std::unordered_set<string> newGameFolders;
  BOOST_LOG_TRIVIAL(trace) << "Updating existing games and adding new games.";
  for (const auto &game : getGameSettings()) {
    auto pos = find(games_.begin(), games_.end(), game);

    if (pos != games_.end()) {
      pos->SetName(game.Name())
        .SetMaster(game.Master())
        .SetRepoURL(game.RepoURL())
        .SetRepoBranch(game.RepoBranch())
        .SetGamePath(game.GamePath())
        .SetRegistryKey(game.RegistryKey());
    } else {
      BOOST_LOG_TRIVIAL(trace) << "Adding new game entry for: " << game.FolderName();
      games_.push_back(game);
    }

    newGameFolders.insert(game.FolderName());
  }

  // Remove deleted games. As the current game is stored using its index,
  // removing an earlier game may invalidate it.
  BOOST_LOG_TRIVIAL(trace) << "Removing deleted games.";
  for (auto it = games_.begin(); it != games_.end();) {
    if (newGameFolders.find(it->FolderName()) == newGameFolders.end()) {
      BOOST_LOG_TRIVIAL(trace) << "Removing game: " << it->FolderName();
      it = games_.erase(it);
    } else
      ++it;
  }

  // Re-initialise the current game in case the game path setting was changed.
  currentGame_->Init(true);
  // Update game path in settings object.
  storeGameSettings(toGameSettings(games_));
}
Пример #3
0
void LootState::init(const std::string& cmdLineGame) {
    // Do some preliminary locale / UTF-8 support setup here, in case the settings file reading requires it.
    //Boost.Locale initialisation: Specify location of language dictionaries.
  boost::locale::generator gen;
  gen.add_messages_path(LootPaths::getL10nPath().string());
  gen.add_messages_domain("loot");

  //Boost.Locale initialisation: Generate and imbue locales.
  locale::global(gen(Language(LanguageCode::english).GetLocale() + ".UTF-8"));
  boost::filesystem::path::imbue(locale());

  // Check if the LOOT local app data folder exists, and create it if not.
  if (!fs::exists(LootPaths::getLootDataPath())) {
    BOOST_LOG_TRIVIAL(info) << "Local app data LOOT folder doesn't exist, creating it.";
    try {
      fs::create_directory(LootPaths::getLootDataPath());
    } catch (exception& e) {
      initErrors_.push_back((format(translate("Error: Could not create LOOT settings file. %1%")) % e.what()).str());
    }
  }
  if (fs::exists(LootPaths::getSettingsPath())) {
    try {
      LootSettings::load(LootPaths::getSettingsPath());
    } catch (exception& e) {
      initErrors_.push_back((format(translate("Error: Settings parsing failed. %1%")) % e.what()).str());
    }
  }

  //Set up logging.
  boost::log::add_file_log(
    boost::log::keywords::file_name = LootPaths::getLogPath().string().c_str(),
    boost::log::keywords::auto_flush = true,
    boost::log::keywords::format = (
      boost::log::expressions::stream
      << "[" << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%H:%M:%S") << "]"
      << " [" << boost::log::trivial::severity << "]: "
      << boost::log::expressions::smessage
      )
  );
  boost::log::add_common_attributes();
  boost::log::core::get()->set_logging_enabled(isDebugLoggingEnabled());

  // Log some useful info.
  BOOST_LOG_TRIVIAL(info) << "LOOT Version: " << LootVersion::major << "." << LootVersion::minor << "." << LootVersion::patch;
  BOOST_LOG_TRIVIAL(info) << "LOOT Build Revision: " << LootVersion::revision;
#ifdef _WIN32
        // Check if LOOT is being run through Mod Organiser.
  bool runFromMO = GetModuleHandle(ToWinWide("hook.dll").c_str()) != NULL;
  if (runFromMO) {
    BOOST_LOG_TRIVIAL(info) << "LOOT is being run through Mod Organiser.";
  }
#endif

        // The CEF debug log is appended to, not overwritten, so it gets really long.
        // Delete the current CEF debug log.
  fs::remove(LootPaths::getLootDataPath() / "CEFDebugLog.txt");

  // Now that settings have been loaded, set the locale again to handle translations.
  if (getLanguage().GetCode() != LanguageCode::english) {
    BOOST_LOG_TRIVIAL(debug) << "Initialising language settings.";
    Language lang(getLanguage());
    BOOST_LOG_TRIVIAL(debug) << "Selected language: " << lang.GetName();

    //Boost.Locale initialisation: Generate and imbue locales.
    locale::global(gen(lang.GetLocale() + ".UTF-8"));
    boost::filesystem::path::imbue(locale());
  }

  // Detect games & select startup game
  //-----------------------------------

  //Detect installed games.
  BOOST_LOG_TRIVIAL(debug) << "Detecting installed games.";
  games_ = toGames(getGameSettings());

  try {
    BOOST_LOG_TRIVIAL(debug) << "Selecting game.";
    selectGame(cmdLineGame);
    BOOST_LOG_TRIVIAL(debug) << "Initialising game-specific settings.";
    currentGame_->Init(true);
    // Update game path in settings object.
    storeGameSettings(toGameSettings(games_));
  } catch (GameDetectionError& e) {
    initErrors_.push_back(e.what());
  } catch (std::exception& e) {
    BOOST_LOG_TRIVIAL(error) << "Game-specific settings could not be initialised. " << e.what();
    initErrors_.push_back((format(translate("Error: Game-specific settings could not be initialised. %1%")) % e.what()).str());
  }
  BOOST_LOG_TRIVIAL(debug) << "Game selected is " << currentGame_->Name();
}