Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow optional conversion & eol for OSREPORT #12581

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Source/Core/Common/Logging/LogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const Config::Info<bool> LOGGER_WRITE_TO_WINDOW{
{Config::System::Logger, "Options", "WriteToWindow"}, true};
const Config::Info<LogLevel> LOGGER_VERBOSITY{{Config::System::Logger, "Options", "Verbosity"},
LogLevel::LNOTICE};
const Config::Info<bool> LOGGER_CONVERT_FROM_SJIS{
{Config::System::Logger, "Options", "ConvertFromSJIS"}, true};

class FileLogListener : public LogListener
{
Expand Down Expand Up @@ -167,7 +169,8 @@ LogManager::LogManager()
container.m_enable = Config::Get(
Config::Info<bool>{{Config::System::Logger, "Logs", container.m_short_name}, false});
}

m_convert_sjis =
Config::Get(Config::Info<bool>{{Config::System::Logger, "Options", "ConvertFromSJIS"}, true});
m_path_cutoff_point = DeterminePathCutOffPoint();
}

Expand Down Expand Up @@ -195,6 +198,8 @@ void LogManager::SaveSettings()
Config::SetBaseOrCurrent(info, container.m_enable);
}

Config::SetBaseOrCurrent(LOGGER_CONVERT_FROM_SJIS, IsEnabledConvertSJIS());

Config::Save();
}

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Common/Logging/LogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class LogManager
void SetEnable(LogType type, bool enable);
bool IsEnabled(LogType type, LogLevel level = LogLevel::LNOTICE) const;

void SetEnableConvertSJIS(bool enable) { m_convert_sjis = enable; }
bool IsEnabledConvertSJIS() const { return m_convert_sjis; }

std::map<std::string, std::string> GetLogTypes();

const char* GetShortName(LogType type) const;
Expand All @@ -67,6 +70,8 @@ class LogManager
bool m_enable = false;
};

bool m_convert_sjis = true;

LogManager();
~LogManager();

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/EXI/EXI_DeviceIPL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ void CEXIIPL::TransferByte(u8& data)

if (data == '\r')
{
NOTICE_LOG_FMT(OSREPORT, "{}", SHIFTJISToUTF8(m_buffer));
NOTICE_LOG_FMT(OSREPORT, "{}", m_osreport_sjis ? SHIFTJISToUTF8(m_buffer) : m_buffer);
m_buffer.clear();
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/Core/HW/EXI/EXI_DeviceIPL.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class CEXIIPL : public IEXIDevice
private:
std::unique_ptr<u8[]> m_rom;

bool m_osreport_sjis = false;

// TODO these ranges are highly suspect
enum
{
Expand Down
9 changes: 9 additions & 0 deletions Source/Core/DolphinQt/Config/LogConfigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ void LogConfigWidget::CreateWidgets()
m_out_file = new QCheckBox(tr("Write to File"));
m_out_console = new QCheckBox(tr("Write to Console"));
m_out_window = new QCheckBox(tr("Write to Window"));
m_convert_sjis = new QCheckBox(tr("Convert from Shift JIS"));

auto* types = new QGroupBox(tr("Log Types"));
auto* types_layout = new QVBoxLayout;
Expand Down Expand Up @@ -84,6 +85,7 @@ void LogConfigWidget::CreateWidgets()
outputs_layout->addWidget(m_out_file);
outputs_layout->addWidget(m_out_console);
outputs_layout->addWidget(m_out_window);
outputs_layout->addWidget(m_convert_sjis);

layout->addWidget(types);
types_layout->addWidget(m_types_toggle);
Expand All @@ -107,6 +109,7 @@ void LogConfigWidget::ConnectWidgets()
connect(m_out_file, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_out_console, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_out_window, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);
connect(m_convert_sjis, &QCheckBox::toggled, this, &LogConfigWidget::SaveSettings);

connect(m_types_toggle, &QPushButton::clicked, [this] {
m_all_enabled = !m_all_enabled;
Expand Down Expand Up @@ -162,6 +165,7 @@ void LogConfigWidget::LoadSettings()

m_types_list->item(i)->setCheckState(log_enabled ? Qt::Checked : Qt::Unchecked);
}
m_convert_sjis->setCheckState(m_convert_sjis ? Qt::Checked : Qt::Unchecked);
}

void LogConfigWidget::SaveSettings()
Expand Down Expand Up @@ -213,6 +217,11 @@ void LogConfigWidget::SaveSettings()
if (enabled != was_enabled)
log_manager->SetEnable(type, enabled);
}
const bool enabled = m_convert_sjis->checkState() == Qt::Checked;
bool was_enabled = log_manager->IsEnabledConvertSJIS();

if (enabled != was_enabled)
log_manager->SetEnableConvertSJIS(enabled);
}

void LogConfigWidget::closeEvent(QCloseEvent*)
Expand Down
2 changes: 2 additions & 0 deletions Source/Core/DolphinQt/Config/LogConfigWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class LogConfigWidget final : public QDockWidget
QCheckBox* m_out_file;
QCheckBox* m_out_console;
QCheckBox* m_out_window;
QCheckBox* m_convert_sjis;

QPushButton* m_types_toggle;
QListWidget* m_types_list;

Expand Down