void AutoUpdater::RunInstaller( void ) { // Create predefined copy paths to easily change later string szDashPath = "game:\\"; string szSkinPath = "game:\\skins\\"; string szPluginPath = "game:\\plugins\\"; // Create directories in case they don't exist CreateDirectory(szDashPath.c_str(), NULL); CreateDirectory(szSkinPath.c_str(), NULL); CreateDirectory(szPluginPath.c_str(), NULL); // Release current Direct 3D Device and initialize console view CFreestyleApp::getInstance().m_pd3dDevice->Release(); ATG::Console console; DebugMsg("AutoUpdater", "Installer Running"); // Locate the embedded font file in memory DWORD dwStoredDigest; VOID * pSectionData; BOOL retVal = XGetModuleSection( GetModuleHandle(NULL), "FSDFont", &pSectionData, &dwStoredDigest); if(retVal == FALSE) { // Font Section could not be found within Xex file- compiled wrong? DebugMsg("AutoUpdater", "Font File Could Not Be Extracted."); XNotifyQueueUICustom(L"Font Not Found - Update Manually"); RestartDashboard(&console, true); return; } // Dump the file to a temporary file for use in this updater string szFontPath = "game:\\ConsoleFont.xpr"; FILE * fHandle; fopen_s(&fHandle, szFontPath.c_str(), "wb"); fwrite(pSectionData, dwStoredDigest, 1, fHandle); fclose(fHandle); // Verify that the font file was dumped and the file exists if(!FileExistsA(szFontPath)) { XNotifyQueueUICustom(L"Font Not Found - Update Manually"); RestartDashboard(&console, true); return; } // Font Extracted Fine- continue with updater. console.Create(szFontPath.c_str(), 0xFF000000, 0xFFFFFFFF ); console.Clear(); // Create and Display Intro along with all the version information... console.Format("Welcome to the Freestyle Dash Update Installer. (v.01a)\n\n"); // Scan tempfolder for updates console.Format("** Checking system for downloaded updates...."); bool hasDashFile = false, hasSkinFile = false, hasPluginFile = false; if(FileExistsA(getAutoupdaterTempXexPath(false))) hasDashFile = true; if(FileExistsA(getAutoupdaterTempSkinPath(false))) hasSkinFile = true; if(FileExistsA(getAutoupdaterTempPluginPath(false))) hasPluginFile = true; // Scan tempfolder for version files for updates that were found if(hasDashFile) { // Check Version File for display information string szVerFile = getAutoupdaterTempXexVerPath(false); string szUpdateDisplay = sprintfaA("\n\tFreestyle Dash Update Found ( Version: Unknown )"); if(FileExistsA(szVerFile)) { // File exists, so extract version information VERSION_DATA verInfo; FILE * fHandle; fopen_s(&fHandle, szVerFile.c_str(), "rb"); fread(&verInfo, sizeof(VERSION_DATA), 1, fHandle); fclose(fHandle); szUpdateDisplay = sprintfaA("\n\tFreestyle Dash Update Found ( Version: %d.%d r%d %s )", verInfo.dwMajor, verInfo.dwMinor, verInfo.dwRevision, ConvertTypeToString(verInfo.dwVersionType).c_str()); } // Output results to screen console.Format(szUpdateDisplay.c_str()); } if(hasSkinFile) { // Check Version File for display information string szVerFile = getAutoupdaterTempSkinVerPath(false); string szUpdateDisplay = sprintfaA("\n\tFreestyle Skin Update Found ( Version: Unknown )"); if(FileExistsA(szVerFile)) { // File exists, so extract version information VERSION_DATA verInfo; FILE * fHandle; fopen_s(&fHandle, szVerFile.c_str(), "rb"); fread(&verInfo, sizeof(VERSION_DATA), 1, fHandle); fclose(fHandle); szUpdateDisplay = sprintfaA("\n\tFreestyle Skin Update Found ( Version: %d.%d r%d %s )", verInfo.dwMajor, verInfo.dwMinor, verInfo.dwRevision, ConvertTypeToString(verInfo.dwVersionType).c_str()); } // Output results to screen console.Format(szUpdateDisplay.c_str()); } if(hasPluginFile) { // Check Version File for display information string szVerFile = getAutoupdaterTempPluginVerPath(false); string szUpdateDisplay = sprintfaA("\n\tFreestyle Plugin Update Found ( Version: Unknown )"); if(FileExistsA(szVerFile)) { // File exists, so extract version information VERSION_DATA verInfo; FILE * fHandle; fopen_s(&fHandle, szVerFile.c_str(), "rb"); fread(&verInfo, sizeof(VERSION_DATA), 1, fHandle); fclose(fHandle); szUpdateDisplay = sprintfaA("\n\tFreestyle Plugin Update Found ( Version: %d.%d r%d %s )", verInfo.dwMajor, verInfo.dwMinor, verInfo.dwRevision, ConvertTypeToString(verInfo.dwVersionType).c_str()); } // Output results to screen console.Format(szUpdateDisplay.c_str()); } console.Format("\n\nTo Begin Installation - Press the 'Y' Button."); console.Format("\nTo Exit Installation - Press the 'Back' Button."); // Wait for Button Input to continue for( ; ; ) { ATG::Input::GetMergedInput(); if(ATG::Input::m_DefaultGamepad.wPressedButtons & XINPUT_GAMEPAD_Y ) break; if(ATG::Input::m_DefaultGamepad.wPressedButtons & XINPUT_GAMEPAD_BACK ) RestartDashboard(&console, true); } // ExtractZip Files To Correct Location bool dashResult = false, skinResult = false, pluginResult = false; bool bError = false; if(hasDashFile) { dashResult = InstallDashUpdate(&console, szDashPath); if(!dashResult){ bError = true; console.Format("\n An Error Occurred installing Dash Updates"); } } if(hasSkinFile) { skinResult = InstallSkinUpdate(&console, szSkinPath); if(!skinResult){ bError = true; console.Format("\n An Error Occurred installing Skin Updates"); } } if(hasPluginFile) { pluginResult = InstallPluginUpdate(&console, szPluginPath); if(!pluginResult){ bError = true; console.Format("\n An Error Occurred installing Plugin Updates"); } } // Show Completion Message if(!bError) { console.Format("\n\nUpdate has completed successfully."); } else { console.Format("\n\nUpdate has not completed successfully- please update manually"); } console.Format("\nPress Any Key to Reboot Dashboard."); // Reboot with changed files for( ; ; ) { ATG::Input::GetMergedInput(); if(ATG::Input::m_DefaultGamepad.wPressedButtons ) RestartDashboard(&console, true); } // Serious Error- should never get to this code - if we do, just restart. }
void ClearConsole() { g_console.Clear(); }