void AppSettings::Initialize(Interface *gi) 
{
   TCHAR iniName[MAX_PATH];
   LPCTSTR pluginDir = gi->GetDir(APP_PLUGCFG_DIR);
   PathCombine(iniName, pluginDir, "MaxNifTools.ini");
   if (-1 != _taccess(iniName, 0)) {
      bool reparse = GetIniValue<bool>("System", "Reparse", false, iniName);
      if (reparse || TheAppSettings.empty()){
         TheAppSettings.clear();
      }

      string Applications = GetIniValue<string>("System", "KnownApplications", "", iniName);
      stringlist apps = TokenizeString(Applications.c_str(), ";");
      for (stringlist::iterator appstr=apps.begin(); appstr != apps.end(); ++appstr){
         AppSettings* setting = FindAppSetting(*appstr);
         if (NULL == setting){
            AppSettingsMap::iterator itr = TheAppSettings.insert(TheAppSettings.end(), AppSettings(*appstr));
            (*itr).ReadSettings(iniName);
         }
      }
   }
}
void AppSettings::Initialize(Interface *gi)
{
	TCHAR iniName[MAX_PATH];
	GetIniFileName(iniName);
	if (-1 != _taccess(iniName, 0)) {
		bool reparse = GetIniValue<bool>(TEXT("System"), TEXT("Reparse"), false, iniName);
		if (reparse || TheAppSettings.empty()) {
			TheAppSettings.clear();
		}
		TheAppSettingsInitialized = true;

		tstring Applications = GetIniValue<tstring>(TEXT("System"), TEXT("KnownApplications"), TEXT(""), iniName);
		tstringlist apps = TokenizeString(Applications.c_str(), TEXT(";"));
		apps.push_back(tstring(TEXT("User"))); // always ensure that user is present
		for (tstringlist::iterator appstr = apps.begin(); appstr != apps.end(); ++appstr) {
			AppSettings* setting = FindAppSetting(*appstr);
			if (nullptr == setting) {
				AppSettingsMap::iterator itr = TheAppSettings.insert(TheAppSettings.end(), AppSettings(*appstr));
				(*itr).ReadSettings(iniName);
			}
		}
	}
}
Beispiel #3
0
AppSettings *Exporter::importAppSettings(std::wstring fname)
{
   AppSettings *appSettings = NULL;
   TCHAR iniName[MAX_PATH];
   GetIniFileName(iniName);

   // Locate which application to use. If Auto, find first app where this file appears in the root path list
   std::wstring curapp = GetIniValue<std::wstring>(NifExportSection, _T("CurrentApp"), _T("AUTO"), iniName);
   if (0 == _tcsicmp(curapp.c_str(), _T("AUTO"))) {
      Exporter::mAutoDetect = true;
      // Scan Root paths
      for (AppSettingsMap::iterator itr = TheAppSettings.begin(), end = TheAppSettings.end(); itr != end; ++itr){
         if ((*itr).IsFileInRootPaths(fname)) {
            appSettings = &(*itr);
            break;
         }
      }
   } else {
      Exporter::mAutoDetect = false;
      appSettings = FindAppSetting(curapp);
   }
   if (appSettings == NULL && !TheAppSettings.empty())
      appSettings = &TheAppSettings.front();

   if (!appSettings)
      return NULL;

   Exporter::mGameName = appSettings->Name;
   Exporter::mNifVersion = appSettings->NiVersion;
   Exporter::mNifUserVersion = appSettings->NiUserVersion;
	Exporter::mNifUserVersion2 = appSettings->NiUserVersion2;
   if (!appSettings->rotate90Degrees.empty())
      Exporter::mRotate90Degrees = appSettings->rotate90Degrees;
   Exporter::mSupportPrnStrings = appSettings->supportPrnStrings;

   return appSettings;
}
Beispiel #4
0
AppSettings * Exporter::exportAppSettings()
{
   TCHAR iniName[MAX_PATH];
   GetIniFileName(iniName);

   // Update the current app version
   AppSettings * appSettings = FindAppSetting(Exporter::mGameName);
   if (appSettings == NULL && !TheAppSettings.empty())
      appSettings = &TheAppSettings.front();

   if (Exporter::mAutoDetect){
      SetIniValue<std::wstring>(NifExportSection, _T("CurrentApp"), _T("AUTO"), iniName);
   } else {
      SetIniValue<std::wstring>(NifExportSection, _T("CurrentApp"), appSettings->Name, iniName);
   }

   appSettings->NiVersion = Exporter::mNifVersion;
   appSettings->NiUserVersion = Exporter::mNifUserVersion;
	appSettings->NiUserVersion2 = Exporter::mNifUserVersion2;
   appSettings->rotate90Degrees = Exporter::mRotate90Degrees;
   appSettings->supportPrnStrings = Exporter::mSupportPrnStrings;

   return appSettings;
}