diff --git a/RenderEclipseTools-src/src/ARC.cpp b/RenderEclipseTools-src/src/ARC.cpp index c7f5d73..b806d8d 100644 --- a/RenderEclipseTools-src/src/ARC.cpp +++ b/RenderEclipseTools-src/src/ARC.cpp @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include "ARC.h" @@ -13,71 +15,92 @@ using namespace std; using namespace std::filesystem; -unsigned int ARCType; +unsigned int ARC::ARCType; +bool ARC::compressImport; +classValuesARC valuesARC; -string endianChangeString(unsigned long ELittleToEBig) { +string ARC::endianChangeString(unsigned long ELittleToEBig) { ostringstream tempString0; - tempString0 << hex << (((ELittleToEBig << 24) & 0xff000000) | ((ELittleToEBig << 8) & 0xff0000) | ((ELittleToEBig >> 8) & 0xff00) | ((ELittleToEBig >> 24) & 0xff)); + tempString0 << hex << (((ELittleToEBig << 24) & 0xff000000) + | ((ELittleToEBig << 8) & 0xff0000) | ((ELittleToEBig >> 8) & 0xff00) + | ((ELittleToEBig >> 24) & 0xff)); string tempString = tempString0.str(); transform(tempString.begin(), tempString.end(), tempString.begin(), ::toupper); return tempString; } -unsigned long endianChangeULong(string EBigToELittle) { +unsigned long ARC::endianChangeULong(string EBigToELittle) { transform(EBigToELittle.begin(), EBigToELittle.end(), EBigToELittle.begin(), ::tolower); unsigned long tempLong = 0; stringstream tempString; tempString << hex << EBigToELittle; tempString >> tempLong; - return (((tempLong << 24) & 0xff000000) | ((tempLong << 8) & 0xff0000) | ((tempLong >> 8) & 0xff00) | ((tempLong >> 24) & 0xff)); + return (((tempLong << 24) & 0xff000000) | ((tempLong << 8) & 0xff0000) + | ((tempLong >> 8) & 0xff00) | ((tempLong >> 24) & 0xff)); } -void importFunc(classValuesARC valuesARC, string fileImportPath) { +void ARC::importFunc(string fileImportPath) { + string oldARCPath = valuesARC.pathFileLoaded + ".bk"; + std::remove(oldARCPath.c_str()); + std::rename(valuesARC.pathFileLoaded.c_str(), oldARCPath.c_str()); ifstream fileImport(fileImportPath, ios_base::binary | ios::ate| ios::in); - ifstream ARC(valuesARC.pathFileLoaded, ios_base::binary | ios::in); + ifstream oldARC(oldARCPath, ios_base::binary | ios::in); + + /* + Step One: it will regenerate the file until the end of the table file + Step Two: replace the file size values and the data position of the next data table values in case of need it + Step Three: regenerate the file until the part where the new data is inserted + Step Four: add new data + Step Five: lastly, add the rest of the untouched info + */ - // First: it will regenerate the file until the end of the table file - // Second: replace the file size values and the data position of the next data table values in case of need it - // Third: regenerate the file until the part where the new data is inserted - // Fourth: add new data - // Fifth: lastly, add the rest of the untouched info // I have to make it practical so the user could import multiple files at // the same time without having to regenerate the whole file everytime just // one file is being imported - // Also add support for other of the Climax's Silent Hills - // read the arc | first look for the size, the buffer will be of 8 mb/8192 bytes - + /* + Step zero: + Get some of the headers values + */ + string fileName = valuesARC.fileItemSelected.ToStdString(); - unsigned long unHashedStringFileName2Int = endianChangeULong(fileName); - unsigned long hashedStringFileName2Int = SHSMWord2Hash(fileName); - unsigned long fileCount, dataStartPos, fileImportIndex; + unsigned long unHashedStringFileName2Int = ARC::endianChangeULong(fileName); + unsigned long hashedStringFileName2Int = RETH::SHSMWord2Hash(fileName); + unsigned long fileCount, dataStartPos, fileImportIndex, fileNamesPos; - switch (ARCType) { + switch (ARC::ARCType) { case 1: - case 2: //Shattered Memories - 10FA0000 + oldARC.seekg(4, ios::beg); + oldARC.read((char*)&fileCount, 4); + oldARC.seekg(8, ios::beg); + oldARC.read((char*)&dataStartPos, 4); + case 2: //Origins UK - 41322E30 (A2.0) - ARC.seekg(4, ios::beg); - ARC.read((char*)&fileCount, 4); - ARC.seekg(8, ios::beg); - ARC.read((char*)&dataStartPos, 4); + oldARC.seekg(4, ios::beg); + oldARC.read((char*)&fileCount, 4); + oldARC.seekg(8, ios::beg); + oldARC.read((char*)&dataStartPos, 4); + oldARC.seekg(12, ios::beg); + oldARC.read((char*)&fileNamesPos, 4); break; default: //Origins LA - ARC.read((char*)&fileCount, 4); - ARC.seekg(4, ios::beg); - ARC.read((char*)&dataStartPos, 4); + oldARC.read((char*)&fileCount, 4); + oldARC.seekg(4, ios::beg); + oldARC.read((char*)&dataStartPos, 4); + oldARC.seekg(8, ios::beg); + oldARC.read((char*)&fileNamesPos, 4); break; } - //Find the index of the file + // Find the index of the selected file to import for (unsigned long i = 0; i < valuesARC.ARCdata.size(); i++) { - if (ARCType == 1) { + if (ARC::ARCType == 1) { if (unHashedStringFileName2Int == valuesARC.ARCdata[i][0] || hashedStringFileName2Int == valuesARC.ARCdata[i][0]) { fileImportIndex = i; @@ -89,14 +112,35 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { } } - //Step one: regenerate the ARC until the data start - string skibidi = valuesARC.pathFileLoaded += "1"; - fstream newARC(skibidi, ios::binary | ios::in | ios::out | ios::trunc); - - int readableData = dataStartPos; - char *rawData; - int dataReadPos = 0; - int bufferSize = 8192; + + // This asks if the file will be compressed or not. If the file comes + // from CLA's Origins or the user clicks no then it's doesn't compress it + // CLA's Origins doesn't seems to support ZLib as the debug symbols of the + // May 2006 proto doesn't mention ZLib anywhere + wxMessageDialog* compressBox; + if (ARC::ARCType != 3) { + signed long checkCompressImport = wxID_NO; + if (valuesARC.ARCdata[fileImportIndex][3] == 0) { + compressBox = new wxMessageDialog(NULL, _("Do you really want to compress this file?\nThis file was not compressed"), _("Compress file"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION); + } else { + compressBox = new wxMessageDialog(NULL, _("Do you really want to compress this file?\nThis file was compressed"), _("Compress file"), wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION); + } + checkCompressImport = compressBox->ShowModal(); + switch (checkCompressImport) { + case wxID_YES: + ARC::compressImport = true; + break; + default: + ARC::compressImport = false; + break; + }; + } + + + // Step one: regenerate the ARC until the data start + fstream newARC(valuesARC.pathFileLoaded, ios::binary | ios::in | ios::out | ios::trunc); + signed long readableData = dataStartPos, dataReadPos = 0, bufferSize = 8192; + char *rawData, *compressedData; bool endfile = false; @@ -106,10 +150,9 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { bufferSize = readableData + 8192; endfile = true; } - // dont forget to make 0 == condition - ARC.seekg(dataReadPos, ios::beg); + oldARC.seekg(dataReadPos, ios::beg); rawData = new char[bufferSize]; - ARC.read(rawData, bufferSize); + oldARC.read(rawData, bufferSize); newARC.write((char*)&rawData[0], bufferSize); delete[] rawData; @@ -118,63 +161,120 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { } dataReadPos += 8192; } + + + // Second Step: replace the file data values and the header values + oldARC.seekg(0, ios::end); + unsigned long headerSkip = 16, compressedSize = 0, importRealFileSize = fileImport.tellg(), + importFileSpace = 0, oldARCSize = oldARC.tellg(); // originalAddress is for step four + if (ARC::ARCType == 2) {headerSkip = 20;} - // Second Step: replace the file size values and the data position of the next data table values in case of need it - int headerSkip = 16, importRealFileSize = fileImport.tellg(); - unsigned long importFileSpace = 0, importHeader, originalAdress = valuesARC.ARCdata[fileImportIndex+1][1]; // originalAdress is for step four - if (ARCType == 2) {headerSkip = 20;} fileImport.seekg(0, ios::beg); - fileImport.read((char*)&importHeader, 4); newARC.seekg(headerSkip + (fileImportIndex * 16) + 8, ios::beg); - //Last files will bug out - if (importHeader == 0xE0FFD8FF || ARCType == 3) { - //Not compress - + + + // This calculate space to reserved for each file in the ARC + // TODO: research the CLA's Origins betas as some of this seems + // To be using a space minimun of 16 bytes while other 32 + if (ARC::ARCType == 3 || ARC::compressImport == false) { + //Don't compress //Calculate space to grab - if (ARCType == 1) { - while (importRealFileSize > importFileSpace) { - importFileSpace += 2048; // divide by 4 - } + switch (ARC::ARCType) { + case 1: + while (importRealFileSize > importFileSpace) { + importFileSpace += 2048; + } + break; + case 2: + while (importRealFileSize > importFileSpace) { + importFileSpace += 32; + } + break; + case 3: + while (importRealFileSize > importFileSpace) { + importFileSpace += 32; + } + break; } valuesARC.ARCdata[fileImportIndex][2] = importRealFileSize; valuesARC.ARCdata[fileImportIndex][3] = 0; } else { //Compress - - - //Calculate space to grab - if (ARCType == 1) { - while (importRealFileSize > importFileSpace) { - importFileSpace += 2048; // divide by 4 - } + rawData = new char[importRealFileSize]; + fileImport.seekg(0, ios::beg); + fileImport.read(rawData, importRealFileSize); + + compressedSize = compressBound(importRealFileSize); + compressedData = new char[compressedSize]; + + compress2((Bytef*)compressedData, &compressedSize, (Bytef*)rawData, importRealFileSize, 9); + delete[] rawData; + switch (ARC::ARCType) { + case 1: + while (compressedSize > importFileSpace) { + importFileSpace += 2048; + } + break; + case 2: + while (compressedSize > importFileSpace) { + importFileSpace += 32; + } + break; } - valuesARC.ARCdata[fileImportIndex][2] = importRealFileSize; - valuesARC.ARCdata[fileImportIndex][3] = 0; + valuesARC.ARCdata[fileImportIndex][2] = compressedSize; + valuesARC.ARCdata[fileImportIndex][3] = importRealFileSize; } newARC.write((char*)&valuesARC.ARCdata[fileImportIndex][2], 4); newARC.write((char*)&valuesARC.ARCdata[fileImportIndex][3], 4); - // Relocate new file addresses - signed long temp = 0; - if (importFileSpace < (valuesARC.ARCdata[fileImportIndex+1][1] - valuesARC.ARCdata[fileImportIndex][1])) { - temp = -((valuesARC.ARCdata[fileImportIndex+1][1] - valuesARC.ARCdata[fileImportIndex][1]) - importFileSpace); - wxLogMessage("temp - %i", temp); + + + // temp = get the amount of space changed by the new file + // temp1 = save the value of the position of whatever follows the file that is + // being imported + signed long temp = 0, temp1, temp2; + + if (fileImportIndex != valuesARC.ARCdata.size() - 1) { + temp1 = valuesARC.ARCdata[fileImportIndex+1][1]; + } else if (ARC::ARCType == 1) { + temp1 = oldARCSize; } else { - temp = importFileSpace - (valuesARC.ARCdata[fileImportIndex+1][1] - valuesARC.ARCdata[fileImportIndex][1]); + temp1 = fileNamesPos; } - wxLogMessage("\nfileImportIndex + %i\nfileImportIndex+1 + %i\nimportFileSpace %i",valuesARC.ARCdata[fileImportIndex][1], valuesARC.ARCdata[fileImportIndex+1][1], importFileSpace); - for (unsigned int i = fileImportIndex+1; fileCount > i; i++) { + + + + if (importFileSpace < (temp1 - valuesARC.ARCdata[fileImportIndex][1])) { + temp = -((temp1 - valuesARC.ARCdata[fileImportIndex][1]) - importFileSpace); + } else { + temp = importFileSpace - (temp1 - valuesARC.ARCdata[fileImportIndex][1]); + } + + for (unsigned long i = fileImportIndex+1; fileCount > i; i++) { newARC.seekg(headerSkip + (i * 16) + 4, ios::beg); - valuesARC.ARCdata[i][1] = valuesARC.ARCdata[i][1] + temp; - newARC.write((char*)&valuesARC.ARCdata[i][1], 4); + valuesARC.ARCdata[i][1] += temp; + if (ARC::ARCType != 3) { + temp2 = valuesARC.ARCdata[i][1]; + } else { + temp2 = valuesARC.ARCdata[i][1] - dataStartPos; + } + newARC.write((char*)&temp2, 4); } + + if (ARC::ARCType != 1) { + fileNamesPos += temp; + newARC.seekg(headerSkip - 8, ios::beg); + newARC.write((char*)&fileNamesPos, 4); + } + + + // Third Step: regenerate the file until the part where the new data is inserted - readableData = valuesARC.ARCdata[fileImportIndex][1] - dataStartPos; dataReadPos = dataStartPos; endfile = false; @@ -186,10 +286,9 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { bufferSize = readableData + 8192; endfile = true; } - // dont forget to make 0 == condition - ARC.seekg(dataReadPos, ios::beg); + oldARC.seekg(dataReadPos, ios::beg); rawData = new char[bufferSize]; - ARC.read(rawData, bufferSize); + oldARC.read(rawData, bufferSize); newARC.write((char*)&rawData[0], bufferSize); delete[] rawData; @@ -201,42 +300,50 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { // Fourth step: add new data - readableData = importRealFileSize; - dataReadPos = 0; - endfile = false; newARC.seekg(valuesARC.ARCdata[fileImportIndex][1], ios::beg); - fileImport.seekg(0, ios::beg); - bufferSize = 8192; - while (true) { - readableData -= 8192; - if (0 > readableData) { - bufferSize = readableData + 8192; - endfile = true; + if (ARC::ARCType == 3 || ARC::compressImport == false) { + // The file is NOT being compressed + readableData = importRealFileSize; + dataReadPos = 0; + endfile = false; + bufferSize = 8192; + while (true) { + readableData -= 8192; + if (0 > readableData) { + bufferSize = readableData + 8192; + endfile = true; + } + fileImport.seekg(dataReadPos, ios::beg); + rawData = new char[bufferSize]; + fileImport.read(rawData, bufferSize); + newARC.write((char*)&rawData[0], bufferSize); + + delete[] rawData; + if (endfile) { + bufferSize = importFileSpace - importRealFileSize; + while (bufferSize > 0) { + newARC.write((char*)"", 1); + bufferSize--; + } + break; + } + dataReadPos += 8192; } - // dont forget to make 0 == condition - fileImport.seekg(dataReadPos, ios::beg); - rawData = new char[bufferSize]; - fileImport.read(rawData, bufferSize); - newARC.write((char*)&rawData[0], bufferSize); - - delete[] rawData; - if (endfile) { - break; + } else { + // The file is NOT being compressed + newARC.write((char*)&compressedData[0], compressedSize); + delete[] compressedData; + bufferSize = importFileSpace - compressedSize; + while (bufferSize > 0) { + newARC.write((char*)"", 1); + bufferSize--; } - dataReadPos += 8192; - } - bufferSize = importFileSpace - importRealFileSize; - while (bufferSize > 0) { - newARC.write((char*)"", 1); - bufferSize--; } fileImport.close(); - // // Fifth: lastly, add the rest of the untouched info - ARC.seekg(0, ios::end); - unsigned long originalAdress1 = ARC.tellg(); - readableData = originalAdress1 - originalAdress; - dataReadPos = originalAdress; + // Fifth step: lastly, add the rest of the untouched info + readableData = oldARCSize - temp1; + dataReadPos = temp1; bufferSize = 8192; endfile = false; while (true) { @@ -245,9 +352,9 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { bufferSize = readableData + 8192; endfile = true; } - ARC.seekg(dataReadPos, ios::beg); + oldARC.seekg(dataReadPos, ios::beg); rawData = new char[bufferSize]; - ARC.read(rawData, bufferSize); + oldARC.read(rawData, bufferSize); newARC.write((char*)&rawData[0], bufferSize); delete[] rawData; @@ -259,11 +366,13 @@ void importFunc(classValuesARC valuesARC, string fileImportPath) { - ARC.close(); + oldARC.close(); newARC.close(); + std::remove(oldARCPath.c_str()); }; -void extractFunc(classValuesARC valuesARC, bool All) { + +void ARC::extractFunc(bool All) { char *rawData, *unCompData; bool nameFinded, rethEmpty = false; unsigned long hashedStringFileName2Int, unHashedStringFileName2Int; @@ -273,8 +382,8 @@ void extractFunc(classValuesARC valuesARC, bool All) { extractPath = "./" + path(valuesARC.pathFileLoaded).stem().string(); if (!is_directory(extractPath) || !exists(extractPath)) { create_directory(extractPath); } } else { - unHashedStringFileName2Int = endianChangeULong(fileName); - hashedStringFileName2Int = SHSMWord2Hash(valuesARC.fileItemSelected.ToStdString()); + unHashedStringFileName2Int = ARC::endianChangeULong(fileName); + hashedStringFileName2Int = RETH::SHSMWord2Hash(valuesARC.fileItemSelected.ToStdString()); } if (valuesARC.RETH.size() == 0) { rethEmpty = true; } ifstream ARC(valuesARC.pathFileLoaded, ios::in | ios_base::binary); @@ -283,7 +392,7 @@ void extractFunc(classValuesARC valuesARC, bool All) { nameFinded = false; if (All == false) { ofstream fileExt("./" + fileName, ios::out | ios::binary | ios::trunc); - if (ARCType == 1) { + if (ARC::ARCType == 1) { if (unHashedStringFileName2Int == valuesARC.ARCdata[i][0]) { fileName += ".dat"; nameFinded = true; @@ -311,7 +420,7 @@ void extractFunc(classValuesARC valuesARC, bool All) { break; } } else { - if (ARCType > 1) { + if (ARC::ARCType != 1) { fileName = "/" + valuesARC.RETH[i].second; nameFinded = true; } else if (!rethEmpty) { @@ -325,7 +434,7 @@ void extractFunc(classValuesARC valuesARC, bool All) { } if (!nameFinded) { - fileName = "/Unknown Names/" + endianChangeString(valuesARC.ARCdata[i][0]) + ".dat"; + fileName = "/Unknown Names/" + ARC::endianChangeString(valuesARC.ARCdata[i][0]) + ".dat"; if (!is_directory(extractPath + "/Unknown Names") || !exists(extractPath + "/Unknown Names")) { create_directory(extractPath + "/Unknown Names"); } @@ -348,7 +457,10 @@ void extractFunc(classValuesARC valuesARC, bool All) { } }; -vector> readARC(string filePath) { + +//TODO: make a verifier for the third case so users doesn't try to load +//ARC files from other games like PC Silent Hill 3 +vector> ARC::readARC(string filePath) { ifstream ARC(filePath.c_str(), ios::in | ios_base::binary); if (!ARC.is_open()) { printf("Missing file ARC!\n"); @@ -368,19 +480,19 @@ vector> readARC(string filePath) { switch (fileSignature) { case 64016: //Shattered Memories - 10FA0000 - ARCType = 1; + ARC::ARCType = 1; ARC.read((char*)&fileCount, 4); ARC.seekg(16, ios::beg); break; case 808333889: //Origins UK - 41322E30 (A2.0) - ARCType = 2; + ARC::ARCType = 2; ARC.read((char*)&fileCount, 4); ARC.seekg(20, ios::beg); break; default: //Origins LA - ARCType = 3; + ARC::ARCType = 3; fileCount = fileSignature; ARC.seekg(4, ios::beg); ARC.read((char*)&fileSignature, 4); @@ -392,7 +504,7 @@ vector> readARC(string filePath) { ARC.read((char*)&ARCFilesRead, 16); vecFiles.push_back(vector()); vecFiles[i].push_back(ARCFilesRead.fileName); - if (ARCType == 3) { + if (ARC::ARCType == 3) { vecFiles[i].push_back(ARCFilesRead.dataPos + fileSignature); } else { vecFiles[i].push_back(ARCFilesRead.dataPos); diff --git a/RenderEclipseTools-src/src/ARC.h b/RenderEclipseTools-src/src/ARC.h index c8bf16c..63355e4 100644 --- a/RenderEclipseTools-src/src/ARC.h +++ b/RenderEclipseTools-src/src/ARC.h @@ -13,9 +13,16 @@ class classValuesARC { unsigned long rethSize; }; -unsigned long endianChangeULong(std::string EBigToELittle); -std::string endianChangeString(unsigned long ELittleToEBig); -std::vector> readARC(std::string filePath); -extern unsigned int ARCType; -void extractFunc(classValuesARC valuesARC, bool All = true); -void importFunc(classValuesARC valuesARC, std::string fileImportPath); \ No newline at end of file +extern classValuesARC valuesARC; + +namespace ARC { + extern unsigned int ARCType; + extern bool compressImport; + + + std::vector> readARC(std::string filePath); + void extractFunc(bool All = true); + void importFunc(std::string fileImportPath); + unsigned long endianChangeULong(std::string EBigToELittle); + std::string endianChangeString(unsigned long ELittleToEBig); +} \ No newline at end of file diff --git a/RenderEclipseTools-src/src/reth.cpp b/RenderEclipseTools-src/src/reth.cpp index 0aa159e..f8c9cfe 100644 --- a/RenderEclipseTools-src/src/reth.cpp +++ b/RenderEclipseTools-src/src/reth.cpp @@ -1,6 +1,4 @@ #include -#include -#include #include #include @@ -8,7 +6,6 @@ #include "arc.h" #include -#include using namespace std; using namespace filesystem; @@ -23,7 +20,7 @@ Credits to: - SPECIAL THANKS to TPU (XeNTaX page [R.I.P]) as they discovered the hashing method that without it I wouldn't have even tried to make this tool. */ -unsigned long SHSMWord2Hash(string text) { +unsigned long RETH::SHSMWord2Hash(string text) { unsigned long hash = 0; text += ""; for (int i = 0; text[i] != '\0'; i++) { hash = (hash * 33) ^ tolower(text[i]); @@ -31,7 +28,7 @@ unsigned long SHSMWord2Hash(string text) { return hash; } -vector> readNames(string filePath, vector> ARCdata) { +vector> RETH::readNames(string filePath, vector> ARCdata) { ifstream fileNames(filePath.c_str(), ios::in | ios_base::binary); string fileName; unsigned long stringSize; @@ -42,7 +39,7 @@ vector> readNames(string filePath, vector -unsigned long SHSMWord2Hash(std::string text); -std::vector> readNames(std::string filePath, std::vector> ARCdata); \ No newline at end of file + +namespace RETH { + unsigned long SHSMWord2Hash(std::string text); + std::vector> readNames(std::string filePath, std::vector> ARCdata); +} \ No newline at end of file diff --git a/RenderEclipseTools-src/src/wxwindow.cpp b/RenderEclipseTools-src/src/wxwindow.cpp index 02e28bf..e7ecc48 100644 --- a/RenderEclipseTools-src/src/wxwindow.cpp +++ b/RenderEclipseTools-src/src/wxwindow.cpp @@ -14,11 +14,10 @@ using namespace std; using namespace std::filesystem; -classValuesARC valuesARC; MainFrame::MainFrame(const wxString& titleBar): wxFrame(nullptr, wxID_ANY, titleBar) { - wxLog* logger = new wxLogWindow(this, "Test", true, false); - wxLog::SetActiveTarget(logger); + // wxLog* logger = new wxLogWindow(this, "Test", true, false); + // wxLog::SetActiveTarget(logger); wxMenuBar* cMenuBarMain = new wxMenuBar(); wxMenu* cMenuBar0 = new wxMenu(); wxMenu* cMenuBar1 = new wxMenu(); @@ -27,12 +26,11 @@ MainFrame::MainFrame(const wxString& titleBar): wxFrame(nullptr, wxID_ANY, title cMenuBar0->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::menuBarOpenARC, this, cMenuBar0->Append(wxID_ANY, _("&Load file"))->GetId()); cMenuBar0->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::menuBarClose, this, cMenuBar0->Append(wxID_ANY, _("&Close"))->GetId()); cMenuBar1->Bind(wxEVT_COMMAND_MENU_SELECTED, &MainFrame::menuBarCredits, this, cMenuBar1->Append(wxID_ANY, _("&Credits"))->GetId()); - - mainSizer->Add(panel0, 3, wxEXPAND | wxALL, 10); - mainSizer->Add(panel1, 5, wxEXPAND | wxALL, 10); + mainSizer->Add(panel0, 1, wxEXPAND | wxALL, 10); + // mainSizer->Add(panel1, 5, wxEXPAND | wxALL, 10); this->SetSizerAndFit(mainSizer); panel0->SetSizerAndFit(treeListSizer); - panel1->SetSizerAndFit(infoFileSizer); + // panel1->SetSizerAndFit(infoFileSizer); treeListSizer->Add(fileListTree, 1, wxEXPAND | wxALL); SetMenuBar(cMenuBarMain); @@ -47,11 +45,11 @@ void MainFrame::menuBarOpenARC(wxCommandEvent& evt) { if (!fileListTree->IsEmpty()) { fileListTree->Delete(fileListTree->GetRootItem()); } valuesARC.pathFileLoaded = fileARC.GetPath(); wxTreeItemId rootListTree = fileListTree->AddRoot(path(fileARC.GetPath().ToStdString()).filename().string()); - valuesARC.ARCdata = readARC(fileARC.GetPath().ToStdString()); - switch (ARCType) { + valuesARC.ARCdata = ARC::readARC(fileARC.GetPath().ToStdString()); + switch (ARC::ARCType) { case 1: wxLogStatus("Open file is from Shattered Memories"); - valuesARC.RETH = readNames("./hashes.reth", {}); + valuesARC.RETH = RETH::readNames("./hashes.reth", {}); valuesARC.rethSize = valuesARC.RETH.size(); /* 0 = reth empty/dont exist @@ -90,7 +88,7 @@ void MainFrame::menuBarOpenARC(wxCommandEvent& evt) { for (long i = 0; i < valuesARC.ARCdata.size(); i++) { if (valuesARC.fileNameTest == 0) { - fileListTree->AppendItem(rootListTree, endianChangeString(valuesARC.ARCdata[i][0])); + fileListTree->AppendItem(rootListTree, ARC::endianChangeString(valuesARC.ARCdata[i][0])); } else { for (unsigned long j = 0; j < valuesARC.rethSize; j++) { @@ -99,7 +97,7 @@ void MainFrame::menuBarOpenARC(wxCommandEvent& evt) { break; } else if (j == valuesARC.rethSize - 1) { - fileListTree->AppendItem(rootListTree, endianChangeString(valuesARC.ARCdata[i][0])); + fileListTree->AppendItem(rootListTree, ARC::endianChangeString(valuesARC.ARCdata[i][0])); } } } @@ -116,12 +114,12 @@ void MainFrame::menuBarOpenARC(wxCommandEvent& evt) { } break; default: - if (ARCType == 2) { + if (ARC::ARCType == 2) { wxLogStatus("Open file is from Origins (Climax UK)"); } else { wxLogStatus("Open file is from Origins (Climax LA)"); } - valuesARC.RETH = readNames(valuesARC.pathFileLoaded, valuesARC.ARCdata); + valuesARC.RETH = RETH::readNames(valuesARC.pathFileLoaded, valuesARC.ARCdata); valuesARC.rethSize = valuesARC.RETH.size(); for (unsigned long i = 0; i < valuesARC.rethSize; i++) { fileListTree->AppendItem(rootListTree, valuesARC.RETH[i].second); @@ -138,7 +136,6 @@ void MainFrame::ShowContextMenu(wxTreeEvent& evt) { contextMenu->Remove(Call_ExportAll); contextMenu->Remove(Call_Import); - wxString selectedParent = fileListTree->GetItemText((fileListTree->GetRootItem())); if (valuesARC.fileItemSelected != selectedParent) { Call_Export = contextMenu->Append(wxID_ANY, "&Export"); @@ -155,19 +152,18 @@ void MainFrame::ShowContextMenu(wxTreeEvent& evt) { } void MainFrame::ContextMenu_Export(wxCommandEvent& evt) { - extractFunc(valuesARC, false); + ARC::extractFunc(false); } void MainFrame::ContextMenu_ExportAll(wxCommandEvent& evt) { - extractFunc(valuesARC, true); + ARC::extractFunc(true); } void MainFrame::ContextMenu_Import(wxCommandEvent& evt) { - if (ARCType != 1) {return;} - wxFileDialog fileImport(this, "Select import file", "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST); + wxFileDialog fileImport(this, "Select file to import", "", "", "", wxFD_OPEN | wxFD_FILE_MUST_EXIST); if (fileImport.ShowModal() == wxID_CANCEL) { wxLogStatus("No file has been open"); return; } - importFunc(valuesARC, fileImport.GetPath().ToStdString()); + ARC::importFunc(fileImport.GetPath().ToStdString()); } void MainFrame::menuBarClose(wxCommandEvent& evt) { @@ -179,7 +175,7 @@ void MainFrame::menuBarCredits(wxCommandEvent& evt) { wxAboutDialogInfo aboutInfo; aboutInfo.SetName("RenderEclipse Tools"); aboutInfo.SetVersion("V2"); - aboutInfo.SetDescription(_("A extration tool for Climax's Silent Hill games")); + aboutInfo.SetDescription(_("A modding tool for Climax's Silent Hill games")); aboutInfo.SetWebSite("https://github.com/IWILLCRAFT-M0d/RenderEclipse-Tools"); aboutInfo.AddDeveloper("IWILLCRAFT (Creator)"); aboutInfo.AddDeveloper("Ikskoks (SHSM Hashing Help)"); diff --git a/RenderEclipseTools-src/src/wxwindow.h b/RenderEclipseTools-src/src/wxwindow.h index 5a4ec2d..7775cb2 100644 --- a/RenderEclipseTools-src/src/wxwindow.h +++ b/RenderEclipseTools-src/src/wxwindow.h @@ -6,7 +6,7 @@ class MainFrame : public wxFrame { public: wxBoxSizer* m_mainsizerHor; wxPanel* panel0 = new wxPanel(this); - wxPanel* panel1 = new wxPanel(this); + // wxPanel* panel1 = new wxPanel(this); wxMenu* contextMenu = new wxMenu(); wxTreeCtrl* fileListTree = new wxTreeCtrl(panel0); wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL); @@ -16,10 +16,10 @@ class MainFrame : public wxFrame { wxMenuItem* Call_ExportAll; wxMenuItem* Call_Import; MainFrame(const wxString& titleBar); - ~MainFrame() { - wxLog::SetActiveTarget(nullptr); - delete logger; - } + // ~MainFrame() { + // wxLog::SetActiveTarget(nullptr); + // delete logger; + // } //Events void menuBarOpenARC(wxCommandEvent& evt); void menuBarClose(wxCommandEvent& evt); @@ -28,8 +28,8 @@ class MainFrame : public wxFrame { void ContextMenu_Export(wxCommandEvent& evt); void ContextMenu_ExportAll(wxCommandEvent& evt); void ContextMenu_Import(wxCommandEvent& evt); -private: - wxLog *logger; +// private: + // wxLog *logger; }; class App : public wxApp {