Skin Installer: Fixed custom header bitmap with new format .rmskin

This commit is contained in:
Birunthan Mohanathas 2012-06-19 14:52:29 +03:00
parent 4647c44d92
commit 54fcd21e03
2 changed files with 25 additions and 18 deletions

View File

@ -373,13 +373,14 @@ bool CDialogInstall::ReadPackage()
return false;
}
// Temporary file to extract the options file and header bitmap
WCHAR tempFile[MAX_PATH];
GetTempPath(MAX_PATH, tempFile);
GetTempFileName(tempFile, L"dat", 0, tempFile);
WCHAR buffer[MAX_PATH];
// Get temporary file to extract the options file and header bitmap
GetTempPath(MAX_PATH, buffer);
GetTempFileName(buffer, L"dat", 0, buffer);
std::wstring tempFile = buffer;
const WCHAR* tempFileSz = tempFile.c_str();
// Helper to sets buffer with current file name
auto getFileInfo = [&]()->bool
{
@ -421,26 +422,19 @@ bool CDialogInstall::ReadPackage()
++path; // Skip slash
}
if (_wcsicmp(path, m_PackageFormat == PackageFormat::New ? L"RMSKIN.bmp" : L"Rainstaller.bmp") == 0)
if (_wcsicmp(path, m_PackageFormat == PackageFormat::New ? L"RMSKIN.ini" : L"Rainstaller.cfg") == 0)
{
if (!ExtractCurrentFile(tempFile))
if (ExtractCurrentFile(tempFile))
{
break;
optionsFound = ReadOptions(tempFileSz);
DeleteFile(tempFileSz);
}
HBITMAP header = (HBITMAP)LoadImage(NULL, tempFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
SendMessage(GetDlgItem(m_Window, IDC_INSTALL_HEADER_BITMAP), STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)header);
}
else if (_wcsicmp(path, m_PackageFormat == PackageFormat::New ? L"RMSKIN.ini" : L"Rainstaller.cfg") == 0)
{
optionsFound = ExtractCurrentFile(tempFile) && ReadOptions(tempFile);
break;
}
}
while (unzGoToNextFile(m_PackageUnzFile) == UNZ_OK);
DeleteFile(tempFile);
if (!optionsFound)
{
return false;
@ -473,6 +467,19 @@ bool CDialogInstall::ReadPackage()
}
else
{
if (_wcsicmp(component, m_PackageFormat == PackageFormat::New ? L"RMSKIN.bmp" : L"Rainstaller.bmp") == 0)
{
if (!ExtractCurrentFile(tempFile))
{
return false;
}
HBITMAP bitmap = (HBITMAP)LoadImage(NULL, tempFileSz, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
HWND header = GetDlgItem(m_Window, IDC_INSTALL_HEADER_BITMAP);
SendMessage(header, STM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)bitmap);
DeleteFile(tempFileSz);
}
continue;
}

View File

@ -258,8 +258,8 @@ bool CDialogPackage::CreatePackage()
};
if (!m_ZipFile ||
!AddFileToPackage(tempFile, L"RMSKIN.ini") ||
(!c_Dialog->m_HeaderFile.empty() && !AddFileToPackage(c_Dialog->m_HeaderFile.c_str(), L"RMSKIN.bmp")))
(!c_Dialog->m_HeaderFile.empty() && !AddFileToPackage(c_Dialog->m_HeaderFile.c_str(), L"RMSKIN.bmp")) ||
!AddFileToPackage(tempFile, L"RMSKIN.ini"))
{
std::wstring error = L"Unable to create package.";
error += L"\n\nClick OK to close Packager.";