void CChordEaseApp::WinHelp(DWORD dwData, UINT nCmd) { //printf("dwData=%d:%d nCmd=%d\n", HIWORD(dwData), LOWORD(dwData), nCmd); CPathStr HelpPath(GetAppFolder()); HelpPath.Append(CString(m_pszAppName) + _T(".chm")); HWND hMainWnd = GetMain()->m_hWnd; UINT ResID = LOWORD(dwData); int HelpID = FindHelpID(ResID); HWND hWnd = 0; // assume failure if (HelpID) // if context help ID was found hWnd = ::HtmlHelp(hMainWnd, HelpPath, HH_HELP_CONTEXT, HelpID); if (!hWnd) { // if context help wasn't available or failed hWnd = ::HtmlHelp(hMainWnd, HelpPath, HH_DISPLAY_TOC, 0); // show contents if (!hWnd) { // if help file not found CString s; AfxFormatString1(s, IDS_APP_HELP_FILE_MISSING, HelpPath); AfxMessageBox(s); return; } } // ThreadBoost DLL boosts priority of MIDI input callbacks, but also boosts // other normal threads, including HtmlHelp's, which is counterproductive if (m_ThreadBoost.IsLoaded()) { // if boosting normal priority threads DWORD ThreadID = GetWindowThreadProcessId(hWnd, NULL); // obtain set info access to HtmlHelp's thread and set its priority to normal CSafeHandle hThread(OpenThread(THREAD_SET_INFORMATION, FALSE, ThreadID)); if (hThread == NULL || !::SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL)) AfxMessageBox(GetLastErrorString()); } m_HelpInit = TRUE; }
BOOL CTripLightApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #if _MFC_VER < 0x0700 #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif #ifdef _DEBUG Win32Console::Create(); #endif #ifdef PORTABLE_APP // if building portable application // Set profile name to INI file in application folder free((void*)m_pszProfileName); CPathStr IniPath(GetAppFolder()); IniPath.Append(CString(m_pszAppName) + _T(".ini")); m_pszProfileName = _tcsdup(IniPath); #else // Change the registry key under which our settings are stored. SetRegistryKey(_T("Anal Software")); #endif LoadStdProfileSettings(); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CTripLightDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CTripLightView)); AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; }
DWORD CSetupApp::GetFilesToCopy(CStringArray& files) { files.RemoveAll(); ULONGLONG total= 0; CFileFind finder; BOOL b= finder.FindFile(GetAppFolder() + _T("\\windirstat.*")); while (b) { b= finder.FindNextFile(); if (finder.IsDirectory()) continue; files.Add(finder.GetFilePath()); // Retrieve file size total+= finder.GetLength(); } finder.Close(); b= finder.FindFile(GetAppFolder() + _T("\\wdsr*.dll")); while (b) { b= finder.FindNextFile(); if (finder.IsDirectory()) continue; files.Add(finder.GetFilePath()); // Retrieve file size total+= finder.GetLength(); } finder.Close(); b= finder.FindFile(GetAppFolder() + _T("\\wdsh*.chm")); while (b) { b= finder.FindNextFile(); if (finder.IsDirectory()) continue; files.Add(finder.GetFilePath()); // Retrieve file size total+= finder.GetLength(); } finder.Close(); return (DWORD)total; }
void MakeModFolders (const char* pszMission) { ResetModFolders (); if (gameOpts->app.bEnableMods) { if (*pszMission) CFile::SplitPath (pszMission, NULL, gameFolders.szModName, NULL); else { pszMission = gameData.missions.list [gameData.missions.nCurrentMission].szMissionName; if (strstr (pszMission, "Descent: First Strike")) strcpy (gameFolders.szModName, "descent"); else if (strstr (pszMission, "Descent 2: Counterstrike!")) strcpy (gameFolders.szModName, "descent2"); else if (strstr (pszMission, "Descent 2: Vertigo")) strcpy (gameFolders.szModName, "d2x"); else return; } if (!GetAppFolder (gameFolders.szModDir [0], gameFolders.szModDir [1], gameFolders.szModName, "")) { sprintf (gameFolders.szSoundDir [4], "%s/%s", gameFolders.szModDir [1], SOUNDDIR); if (GetAppFolder (gameFolders.szModDir [1], gameFolders.szTextureDir [2], TEXTUREDIR, "*.tga")) *gameFolders.szTextureDir [2] = '\0'; else { sprintf (gameFolders.szTextureCacheDir [2], "%s/%s", gameFolders.szModDir [1], TEXTUREDIR); gameOpts->render.textures.bUseHires [0] = 1; } if (GetAppFolder (gameFolders.szModDir [1], gameFolders.szModelDir [1], MODELDIR, "*.ase") && GetAppFolder (gameFolders.szModDir [1], gameFolders.szModelDir [1], MODELDIR, "*.oof")) *gameFolders.szModelDir [1] = '\0'; else { sprintf (gameFolders.szModelDir [1], "%s/%s", gameFolders.szModDir [1], MODELDIR); sprintf (gameFolders.szModelCacheDir [1], "%s/%s", gameFolders.szModDir [1], MODELDIR); } if (GetAppFolder (gameFolders.szModDir [1], gameFolders.szMusicDir, MUSICDIR, "*.ogg")) *gameFolders.szMusicDir = '\0'; MakeTexSubFolders (gameFolders.szTextureCacheDir [2]); MakeTexSubFolders (gameFolders.szModelCacheDir [1]); gameStates.app.bHaveMod = 1; } else *gameFolders.szModName = '\0'; } }
CString CChordEaseApp::MakeDataFolderPath(LPCTSTR FileName, bool DefaultToAppFolder) { CPathStr path(GetDataFolderPath()); if (!PathFileExists(path)) CreateFolder(path); path.Append(FileName); if (DefaultToAppFolder && !PathFileExists(path)) { path = GetAppFolder(); // default to app folder path.Append(FileName); } return(path); }
CString CChordEaseApp::GetDataFolderPath() { CString path(GetMain()->GetOptions().m_DataFolderPath); if (path.IsEmpty()) { // if default data folder #ifdef PORTABLE_APP // if portable app path = GetAppFolder(); // use app folder #else // not portable app GetAppDataFolder(path); // use app data folder #endif } return(path); }
bool CSetupApp::CheckPrerequisits() { CString wdsexe= GetAppFolder() + _T("\\windirstat.exe"); if (!FileExists(wdsexe)) { CString msg; msg.FormatMessage(IDS_FILEsDOESNOTEXIST, wdsexe); AfxMessageBox(msg); return false; } return true; }
CString CDirstatApp::FindAuxiliaryFileByLangid(LPCTSTR prefix, LPCTSTR suffix, LANGID& langid, bool checkResource) { CString number; number.Format(_T("%04x"), langid); CString exactName; exactName.Format(_T("%s%s%s"), prefix, number, suffix); CString exactPath= GetAppFolder() + _T("\\") + exactName; if (FileExists(exactPath) && (!checkResource || IsCorrectResourceDll(exactPath))) return exactPath; CString search; search.Format(_T("%s*%s"), prefix, suffix); CFileFind finder; BOOL b= finder.FindFile(GetAppFolder() + _T("\\") + search); while (b) { b= finder.FindNextFile(); if (finder.IsDirectory()) continue; LANGID id; if (!ScanAuxiliaryFileName(prefix, suffix, finder.GetFileName(), id)) continue; if (PRIMARYLANGID(id) == PRIMARYLANGID(langid) && (!checkResource || IsCorrectResourceDll(finder.GetFilePath()))) { langid= id; return finder.GetFilePath(); } } return _T(""); }
CString CDirstatApp::FindHelpfilePathByLangid(LANGID langid) { CString s; if (langid == GetBuiltInLanguage()) { // The english help file is named windirstat.chm. s= GetAppFolder() + _T("\\windirstat.chm"); if (FileExists(s)) return s; } // Help files for other languages are named wdshxxxx.chm (xxxx = LANGID). s= FindAuxiliaryFileByLangid(_T("wdsh"), _T(".chm"), langid, false); if (!s.IsEmpty()) return s; // Else, try windirstat.chm again. s= GetAppFolder() + _T("\\windirstat.chm"); if (FileExists(s)) return s; // Not found. return _T(""); }
void CDirstatApp::GetAvailableResourceDllLangids(CArray<LANGID, LANGID>& arr) { arr.RemoveAll(); CFileFind finder; BOOL b= finder.FindFile(GetAppFolder() + _T("\\wdsr*.dll")); while (b) { b= finder.FindNextFile(); if (finder.IsDirectory()) continue; LANGID langid; if (ScanResourceDllName(finder.GetFileName(), langid) && IsCorrectResourceDll(finder.GetFilePath())) arr.Add(langid); } }
CString FileMisc::GetAppResourceFolder(LPCTSTR szResFolder) { return GetAppFolder(szResFolder); }
CString GetNDCRulFile(CString& sNDC,CString& sMobnum,DWORD& dwMaxLen) { dwMaxLen=0; static CFileInfoArray dir; static BOOL bAdded=0; static CMapStringToString aNDCIndex; if(bAdded==0){ bAdded=1; dir.AddDir(GetAppFolder()+"Sms/","*.rul",TRUE,0,FALSE); for(int i=0;i<dir.GetSize();i++){ CString sItemPath=dir[i].GetFilePath(); CString sContent; ReadFile(sItemPath,sContent); sContent.Replace("\r",""); sContent+="\n"; CString sLen=CDataXMLSaver::GetInstringPart("SmsMaxLength=","\n",sContent); CString sNDCs=CDataXMLSaver::GetInstringPart("SmsNdcList=","\n",sContent); CString sName=CDataXMLSaver::GetInstringPart("WndTitle=","\n",sContent); if(sNDCs!=""){ CStringArray aNDCs; ConvertToArray(sNDCs,aNDCs,','); for(int j=0;j<aNDCs.GetSize();j++){ CString sOld=aNDCIndex[aNDCs[j]]; if(sOld!=""){ sOld+="|"; } sOld+=sItemPath+"\t"+sLen+"\t"+sName; aNDCIndex.SetAt(aNDCs[j],sOld); } } } } CString sNDCData=aNDCIndex[sNDC]; if(sNDCData.Find("|")!=-1){ // Выбор :( CStringArray aOperators; ConvertToArray(sNDCData,aOperators,'|'); CStringArray aOperatorsNames; int i=0; for(i=0;i<aOperators.GetSize();i++){ CStringArray aDats; ConvertToArray(aOperators[i],aDats,'\t'); if(aDats.GetSize()>=3){ aOperatorsNames.Add(aDats[2]); } } i=SelectFromMenu(aOperatorsNames,0); if(i>=0){ sNDCData=aOperators[i]; }else{ return "000"; } } if(sNDCData!=""){ CStringArray aDats; ConvertToArray(sNDCData,aDats,'\t'); if(aDats.GetSize()>=2){ dwMaxLen=atol(aDats[1]); return aDats[0]; } } // Доверяем гуглу? CString sRetFile=GetAppFolder()+"Sms/default.rul"; if(isFileExist(sRetFile)){ CString sContent; ReadFile(sRetFile,sContent); CString sCList=CDataXMLSaver::GetInstringPart("SmsCarriersList=","\n",sContent); CStringArray aCarriers; ConvertToArray(sCList,aCarriers,','); int i=SelectFromMenu(aCarriers,0); if(i>0){ dwMaxLen=1000; sMobnum=sNDC+sMobnum; sNDC=Format("%i",i); return sRetFile; } if(i<0){ return "000"; } } return ""; }
BOOL CNetRssProtocol::SendNet_Text(const char* szRecipientIn, CNetMessage_Text* str) { CString sRawAddr=GetCompNameNoProtocol(szRecipientIn); if(str->sProtocol=="sms"){ sRawAddr.Replace("-",""); sRawAddr.Replace(" ",""); sRawAddr.Replace(".",""); CString sApp=GetAppFolder()+"Sms/smssend.exe"; if(isFileExist(sApp)){ sRawAddr.TrimLeft("+"); if(sRawAddr.Left(1)=="7" || sRawAddr.Left(1)=="8"){ sRawAddr=sRawAddr.Mid(1); } if(sRawAddr.GetLength()!=10){ Alert(_l("Incorrect mobile number. Mobile number should be in the form of +7XXXXXXXXXX"),_l("Error")); }else{ CString sNDC=sRawAddr.Left(3); CString sMobnum=sRawAddr.Mid(3); int iLen2=0; int iLen4=0; CString sMessage=EscapeString(str->sMessageBody,1,"\\/:?&\"'\n\r\t%=",&iLen2,&iLen4); int iLenToCompare=(str->sMessageBody.GetLength()-iLen2-iLen4)+2*(iLen2+iLen4); DWORD dwMaxLen=0; CString sNDCFile=GetNDCRulFile(sNDC,sMobnum,dwMaxLen); if(sNDCFile=="" || sNDCFile=="000"){ if(sNDCFile==""){ Alert(_l("Sorry, your provider is not supported this time.\nPlease contact [email protected] for details"),_l("Error")); } }else{ CString sParams=" scriptex=\""+sNDCFile+"\""; sParams+=" NDC="; sParams+=sNDC; sParams+=" MOBNUM="; sParams+=sMobnum; sParams+=" MESSAGE="; sParams+=sMessage; if(sParams.GetLength()>MAX_PATH*2 || iLenToCompare>dwMaxLen){ Alert(_l("Sorry, message is too long"),_l("Error")); }else{ STARTUPINFO su; PROCESS_INFORMATION pi; ZeroMemory(&su, sizeof(su)); ZeroMemory(&pi, sizeof(pi)); GetStartupInfo(&su); su.cb = sizeof(su); su.dwFlags = STARTF_USESHOWWINDOW; su.wShowWindow = SW_SHOWNORMAL; su.lpDesktop = NULL; char szPath[MAX_PATH]={0}; strcpy(szPath,sApp); char szPars[MAX_PATH*2]={0}; strcpy(szPars,sParams); if(::CreateProcess(szPath, szPars, NULL,NULL, false, NULL, NULL, GetAppFolder(), &su, &pi)){ DWORD dwRes=WaitForSingleObject(pi.hProcess,160000); DWORD iExCode=0; GetExitCodeProcess(pi.hProcess,&iExCode); if(pi.hProcess){ CloseHandle(pi.hProcess); } if(dwRes==WAIT_OBJECT_0){ if(iExCode==1){ // Палучилось!!! objSettings.iSMSCount++; if(objSettings.iSMSCount>100) { Alert(Format("Sms #%i: %s\n%s!",_l("You are using SMS feature extensively"),objSettings.iSMSCount,_l("If you don`t want to see this message again\nplease order WireNote Pro")),_l("Registration")); } return TRUE; } } } } } } } return FALSE; } if(sRawAddr.Left(7).CompareNoCase("http://")==0){ CSmartLock SL(&csRssFeeds,TRUE); CString sLnewsLink=aLoadedRss[sRawAddr]; sLnewsLink=sLnewsLink.SpanExcluding("\t"); if(sLnewsLink==""){ sLnewsLink=sRawAddr; } WNSubstMyVariables(sLnewsLink,"web-rss"); ShellExecute(0,"open",sLnewsLink,NULL,NULL,SW_SHOWNORMAL); return 1; } Alert(_l("You can not send messages through this protocol\nUse it for receiving RSS news as messages"),_l(NO_SEND_TITLE)); return 0; }
void GetAppFolders (void) { int i; char szDataRootDir [FILENAME_LEN]; char *psz; #ifdef _WIN32 char c; #endif *gameFolders.szHomeDir = *gameFolders.szGameDir = *gameFolders.szDataDir = *szDataRootDir = '\0'; if ((i = FindArg ("-userdir")) && GetAppFolder ("", gameFolders.szGameDir, pszArgList [i + 1], D2X_APPNAME)) *gameFolders.szGameDir = '\0'; if (!*gameFolders.szGameDir && GetAppFolder ("", gameFolders.szGameDir, getenv ("DESCENT2"), D2X_APPNAME)) *gameFolders.szGameDir = '\0'; #ifdef _WIN32 if (!*gameFolders.szGameDir) { psz = pszArgList [0]; for (int j = (int) strlen (psz); j; ) { c = psz [--j]; if ((c == '\\') || (c == '/')) { memcpy (gameFolders.szGameDir, psz, ++j); gameFolders.szGameDir [j] = '\0'; break; } } } strcpy (szDataRootDir, gameFolders.szGameDir); strcpy (gameFolders.szHomeDir, *gameFolders.szGameDir ? gameFolders.szGameDir : szDataRootDir); #else // Linux, OS X # if defined (__unix__) || defined (__macosx__) if (getenv ("HOME")) strcpy (gameFolders.szHomeDir, getenv ("HOME")); # if 0 if (!*gameFolders.szGameDir && *gameFolders.szHomeDir && GetAppFolder (gameFolders.szHomeDir, gameFolders.szGameDir, "d2x-xl", "d2x-xl")) *gameFolders.szGameDir = '\0'; # endif # endif //__unix__ if (!*gameFolders.szGameDir && GetAppFolder ("", gameFolders.szGameDir, STD_GAMEDIR, "")) *gameFolders.szGameDir = '\0'; if (!*gameFolders.szGameDir && GetAppFolder ("", gameFolders.szGameDir, SHAREPATH, "")) *gameFolders.szGameDir = '\0'; # ifdef __macosx__ GetOSXAppFolder (szDataRootDir, gameFolders.szGameDir); # else strcpy (szDataRootDir, gameFolders.szGameDir); # endif //__macosx__ if (*gameFolders.szGameDir) chdir (gameFolders.szGameDir); #endif //Linux, OS X if ((i = FindArg ("-hogdir")) && !GetAppFolder ("", gameFolders.szDataDir, pszArgList [i + 1], "descent2.hog")) strcpy (szDataRootDir, pszArgList [i + 1]); else { sprintf (gameFolders.szDataDir, "%s%s", gameFolders.szGameDir, DATADIR); if (GetAppFolder ("", gameFolders.szDataDir, gameFolders.szDataDir, "descent2.hog") && GetAppFolder ("", gameFolders.szDataDir, gameFolders.szDataDir, "d2demo.hog") && GetAppFolder (szDataRootDir, gameFolders.szDataDir, DATADIR, "descent2.hog") && GetAppFolder (szDataRootDir, gameFolders.szDataDir, DATADIR, "d2demo.hog")) Error (TXT_NO_HOG2); } psz = strstr (gameFolders.szDataDir, DATADIR); if (psz && !*(psz + 4)) { if (psz == gameFolders.szDataDir) sprintf (gameFolders.szDataDir, "%s%s", gameFolders.szGameDir, DATADIR); else { *(psz - 1) = '\0'; strcpy (szDataRootDir, gameFolders.szDataDir); *(psz - 1) = '/'; } } else strcpy (szDataRootDir, gameFolders.szDataDir); /*---*/PrintLog ("expected game app folder = '%s'\n", gameFolders.szGameDir); /*---*/PrintLog ("expected game data folder = '%s'\n", gameFolders.szDataDir); if (GetAppFolder (szDataRootDir, gameFolders.szModelDir [0], MODELDIR, "*.ase")) GetAppFolder (szDataRootDir, gameFolders.szModelDir [0], MODELDIR, "*.oof"); GetAppFolder (szDataRootDir, gameFolders.szSoundDir [0], SOUNDDIR1, "*.wav"); GetAppFolder (szDataRootDir, gameFolders.szSoundDir [1], SOUNDDIR2, "*.wav"); if (GetAppFolder (szDataRootDir, gameFolders.szSoundDir [2], SOUNDDIR1_D1, "*.wav")) *gameFolders.szSoundDir [2] = '\0'; if (GetAppFolder (szDataRootDir, gameFolders.szSoundDir [3], SOUNDDIR2_D1, "*.wav")) *gameFolders.szSoundDir [3] = '\0'; GetAppFolder (szDataRootDir, gameFolders.szShaderDir, SHADERDIR, ""); GetAppFolder (szDataRootDir, gameFolders.szTextureDir [0], TEXTUREDIR_D2, "*.tga"); GetAppFolder (szDataRootDir, gameFolders.szTextureDir [1], TEXTUREDIR_D1, "*.tga"); GetAppFolder (szDataRootDir, gameFolders.szModDir [0], MODDIR, ""); GetAppFolder (szDataRootDir, gameFolders.szMovieDir, MOVIEDIR, "*.mvl"); #ifdef __unix__ if (*gameFolders.szHomeDir) { char fn [FILENAME_LEN]; sprintf (szDataRootDir, "%s/.d2x-xl", gameFolders.szHomeDir); CFile::MkDir (szDataRootDir); sprintf (fn, "%s/%s", szDataRootDir, PROFDIR); CFile::MkDir (fn); sprintf (fn, "%s/%s", szDataRootDir, SAVEDIR); CFile::MkDir (fn); sprintf (fn, "%s/%s", szDataRootDir, SCRSHOTDIR); CFile::MkDir (fn); sprintf (fn, "%s/%s", szDataRootDir, DEMODIR); CFile::MkDir (fn); sprintf (fn, "%s/%s", szDataRootDir, CONFIGDIR); CFile::MkDir (fn); sprintf (fn, "%s/%s", szDataRootDir, CONFIGDIR); CFile::MkDir (fn); } #endif if (*gameFolders.szHomeDir) { #ifdef __macosx__ char *pszOSXCacheDir = GetMacOSXCacheFolder (); sprintf (gameFolders.szTextureCacheDir [0], "%s/%s",pszOSXCacheDir, TEXTUREDIR_D2); CFile::MkDir (gameFolders.szTextureCacheDir [0]); sprintf (gameFolders.szTextureCacheDir [1], "%s/%s", pszOSXCacheDir, TEXTUREDIR_D1); CFile::MkDir (gameFolders.szTextureCacheDir [1]); sprintf (gameFolders.szModelCacheDir [0], "%s/%s", pszOSXCacheDir, MODELDIR); CFile::MkDir (gameFolders.szModelCacheDir [0]); sprintf (gameFolders.szCacheDir, "%s/%s", pszOSXCacheDir, CACHEDIR); CFile::MkDir (gameFolders.szCacheDir); sprintf (gameFolders.szCacheDir, "%s/%s/256", pszOSXCacheDir, CACHEDIR); CFile::MkDir (gameFolders.szCacheDir); sprintf (gameFolders.szCacheDir, "%s/%s/128", pszOSXCacheDir, CACHEDIR); CFile::MkDir (gameFolders.szCacheDir); sprintf (gameFolders.szCacheDir, "%s/%s/64", pszOSXCacheDir, CACHEDIR); CFile::MkDir (gameFolders.szCacheDir); sprintf (gameFolders.szCacheDir, "%s/%s", pszOSXCacheDir, CACHEDIR); CFile::MkDir (gameFolders.szCacheDir); #else # ifdef __unix__ sprintf (szDataRootDir, "%s/.d2x-xl", gameFolders.szHomeDir); # else strcpy (szDataRootDir, gameFolders.szHomeDir); if (szDataRootDir [i = (int) strlen (szDataRootDir) - 1] == '\\') szDataRootDir [i] = '\0'; # endif // __unix__ CFile::MkDir (szDataRootDir); sprintf (gameFolders.szTextureCacheDir [0], "%s/%s", szDataRootDir, TEXTUREDIR_D2); CFile::MkDir (gameFolders.szTextureCacheDir [0]); sprintf (gameFolders.szTextureCacheDir [1], "%s/%s", szDataRootDir, TEXTUREDIR_D1); CFile::MkDir (gameFolders.szTextureCacheDir [1]); sprintf (gameFolders.szModelCacheDir [0], "%s/%s", szDataRootDir, MODELDIR); CFile::MkDir (gameFolders.szModelCacheDir [0]); sprintf (gameFolders.szCacheDir, "%s/%s", szDataRootDir, CACHEDIR); CFile::MkDir (gameFolders.szCacheDir); #endif // __macosx__ } GetAppFolder (szDataRootDir, gameFolders.szProfDir, PROFDIR, ""); GetAppFolder (szDataRootDir, gameFolders.szSaveDir, SAVEDIR, ""); GetAppFolder (szDataRootDir, gameFolders.szScrShotDir, SCRSHOTDIR, ""); GetAppFolder (szDataRootDir, gameFolders.szDemoDir, DEMODIR, ""); if (GetAppFolder (szDataRootDir, gameFolders.szConfigDir, CONFIGDIR, "*.ini")) strcpy (gameFolders.szConfigDir, gameFolders.szGameDir); #ifdef WIN32 sprintf (gameFolders.szMissionDir, "%s%s", gameFolders.szGameDir, BASE_MISSION_DIR); #else sprintf (gameFolders.szMissionDir, "%s/%s", gameFolders.szGameDir, BASE_MISSION_DIR); #endif //if (i = FindArg ("-hogdir")) // CFUseAltHogDir (pszArgList [i + 1]); for (i = 0; i < 2; i++) MakeTexSubFolders (gameFolders.szTextureCacheDir [i]); MakeTexSubFolders (gameFolders.szModelCacheDir [0]); sprintf (gameFolders.szMissionDownloadDir, "%s/%s", gameFolders.szMissionDir, DOWNLOADDIR); CFile::MkDir (gameFolders.szMissionDownloadDir); }
void CFUseAltHogDir (char * path) { gameFolders.bAltHogDirInited = (strcmp (path, gameFolders.szDataDir) != 0) && (GetAppFolder ("", gameFolders.szAltHogDir, path, "descent2.hog") == 0); }
BOOL CChordEaseApp::InitInstance() { AfxEnableControlContainer(); #ifdef _DEBUG Win32Console::Create(); #endif CSplashDlg splash; splash.Create(IDD_SPLASH); // create splash screen // initialize COM for apartment threading if (FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { AfxMessageBox(IDS_APP_CANT_INIT_COM); return FALSE; } // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #if _MFC_VER < 0x0700 #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif #endif #ifdef PORTABLE_APP // if building portable application // Set profile name to INI file in application folder free((void*)m_pszProfileName); CPathStr IniPath(GetAppFolder()); IniPath.Append(CString(m_pszAppName) + _T(".ini")); m_pszProfileName = _tcsdup(IniPath); #else // Change the registry key under which our settings are stored. SetRegistryKey(_T("Anal Software")); #endif LoadStdProfileSettings(8); // Load standard INI file options (including MRU) // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views. CSingleDocTemplate* pDocTemplate; pDocTemplate = new CSingleDocTemplate( IDR_MAINFRAME, RUNTIME_CLASS(CChordEaseDoc), RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CChordEaseView)); ASSERT(m_pDocManager == NULL); m_pDocManager = new CDocManagerEx; AddDocTemplate(pDocTemplate); // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (IsPatchPath(cmdInfo.m_strFileName)) { m_PatchPath = cmdInfo.m_strFileName; cmdInfo.m_nShellCommand = CCommandLineInfo::FileNew; } // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; splash.DestroyWindow(); // destroy splash screen // The one and only window has been initialized, so show and update it. m_pMainWnd->ShowWindow(SW_SHOW); m_pMainWnd->UpdateWindow(); return TRUE; }