Return a string from dumpinformation and let the caller decide how to output the info
This commit is contained in:
parent
4a3965d644
commit
641ec8fdfa
|
@ -40,8 +40,6 @@
|
|||
#include <cstdlib>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
|
@ -550,30 +548,13 @@ static char *BetterTime(uint32 x_timeDate)
|
|||
return x_ctime;
|
||||
}
|
||||
|
||||
bool Xbe::DumpInformationToFile(std::string out_filename)
|
||||
std::string Xbe::DumpInformation()
|
||||
{
|
||||
if(HasError()) {
|
||||
return false;
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
bool success = false;
|
||||
XbePrinter printer(this);
|
||||
std::ofstream out_file(out_filename);
|
||||
if(out_file.is_open()) {
|
||||
out_file << printer.GenXbeInfo();
|
||||
out_file.close();
|
||||
success = true;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
void Xbe::DumpInformationToConsole()
|
||||
{
|
||||
if(HasError())
|
||||
return;
|
||||
|
||||
XbePrinter printer(this);
|
||||
std::cout << printer.GenXbeInfo();
|
||||
return printer.GenXbeInfo();
|
||||
}
|
||||
|
||||
// import logo bitmap from raw monochrome data
|
||||
|
|
|
@ -62,8 +62,7 @@ class Xbe : public Error
|
|||
// export to Xbe file
|
||||
void Export(const char *x_szXbeFilename);
|
||||
|
||||
bool DumpInformationToFile(std::string);
|
||||
void DumpInformationToConsole();
|
||||
std::string DumpInformation();
|
||||
|
||||
// import logo bitmap from raw monochrome data
|
||||
void ImportLogoBitmap(const uint08 x_Gray[100*17]);
|
||||
|
|
|
@ -47,6 +47,8 @@
|
|||
#include <io.h>
|
||||
|
||||
#include <sstream> // for std::stringstream
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include "CxbxKrnl/xxhash32.h" // for XXHash32::hash
|
||||
|
||||
#define XBOX_LED_FLASH_PERIOD 176 // if you know a more accurate value, put it here
|
||||
|
@ -1006,12 +1008,15 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
|
||||
// dump xbe information to file
|
||||
{
|
||||
bool success = m_Xbe->DumpInformationToFile(ofn.lpstrFile);
|
||||
std::string Xbe_info = m_Xbe->DumpInformation();
|
||||
if (m_Xbe->HasError()) {
|
||||
MessageBox(m_hwnd, m_Xbe->GetError().c_str(), "Cxbx-Reloaded", MB_ICONSTOP | MB_OK);
|
||||
}
|
||||
else {
|
||||
if(success) {
|
||||
std::ofstream Xbe_dump_file(ofn.lpstrFile);
|
||||
if(Xbe_dump_file.is_open()) {
|
||||
Xbe_dump_file << Xbe_info;
|
||||
Xbe_dump_file.close();
|
||||
char buffer[255];
|
||||
sprintf(buffer, "%s's .xbe info was successfully dumped.", m_Xbe->m_szAsciiTitle);
|
||||
printf("WndMain: %s\n", buffer);
|
||||
|
@ -1026,24 +1031,20 @@ LRESULT CALLBACK WndMain::WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
}
|
||||
break;
|
||||
|
||||
case ID_EDIT_DUMPXBEINFOTO_DEBUGCONSOLE:
|
||||
{
|
||||
m_Xbe->DumpInformationToConsole();
|
||||
|
||||
if (m_Xbe->HasError())
|
||||
{
|
||||
MessageBox(m_hwnd, m_Xbe->GetError().c_str(), "Cxbx-Reloaded", MB_ICONSTOP | MB_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
char buffer[255];
|
||||
|
||||
sprintf(buffer, "%s's .xbe info was successfully dumped to console.", m_Xbe->m_szAsciiTitle);
|
||||
|
||||
printf("WndMain: %s\n", buffer);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ID_EDIT_DUMPXBEINFOTO_DEBUGCONSOLE:
|
||||
{
|
||||
std::string Xbe_info = m_Xbe->DumpInformation();
|
||||
if (m_Xbe->HasError()) {
|
||||
MessageBox(m_hwnd, m_Xbe->GetError().c_str(), "Cxbx-Reloaded", MB_ICONSTOP | MB_OK);
|
||||
}
|
||||
else {
|
||||
std::cout << Xbe_info;
|
||||
char buffer[255];
|
||||
sprintf(buffer, "%s's .xbe info was successfully dumped to console.", m_Xbe->m_szAsciiTitle);
|
||||
printf("WndMain: %s\n", buffer);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_SETTINGS_CONFIG_CONTROLLER:
|
||||
ShowControllerConfig(hwnd);
|
||||
|
|
Loading…
Reference in New Issue