mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-11 12:45:05 +01:00
Address remaining review comments
This commit is contained in:
parent
1517d2fef7
commit
e9bd34f7da
@ -9,10 +9,25 @@
|
||||
#include <QVBoxLayout>
|
||||
#include "citra_qt/applets/mii_selector.h"
|
||||
#include "common/file_util.h"
|
||||
#include "common/string_util.h"
|
||||
#include "core/file_sys/archive_extsavedata.h"
|
||||
#include "core/file_sys/file_backend.h"
|
||||
#include "core/hle/service/ptm/ptm.h"
|
||||
|
||||
/**
|
||||
* Converts a UTF-16 text in a container to a UTF-8 std::string.
|
||||
*/
|
||||
template <typename T>
|
||||
std::string TextFromBuffer(const T& text) {
|
||||
const auto text_end = std::find(text.begin(), text.end(), u'\0');
|
||||
const std::size_t text_size = std::distance(text.begin(), text_end);
|
||||
std::u16string buffer(text_size, 0);
|
||||
std::transform(text.begin(), text_end, buffer.begin(), [](u16_le character) {
|
||||
return static_cast<char16_t>(static_cast<u16>(character));
|
||||
});
|
||||
return Common::UTF16ToUTF8(buffer);
|
||||
}
|
||||
|
||||
QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_selector_)
|
||||
: QDialog(parent), mii_selector(mii_selector_) {
|
||||
using namespace Frontend;
|
||||
@ -28,7 +43,7 @@ QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_sel
|
||||
|
||||
setWindowTitle(config.title.empty() || config.title.at(0) == '\x0000'
|
||||
? tr("Mii Selector")
|
||||
: QString::fromStdU16String(config.title));
|
||||
: QString::fromStdString(config.title));
|
||||
|
||||
miis.push_back(HLE::Applets::MiiSelector::GetStandardMiiResult().selected_mii_data);
|
||||
combobox->addItem(tr("Standard Mii"));
|
||||
@ -56,10 +71,9 @@ QtMiiSelectorDialog::QtMiiSelectorDialog(QWidget* parent, QtMiiSelector* mii_sel
|
||||
file->Read(saved_miis_offset, sizeof(mii), mii_raw.data());
|
||||
std::memcpy(&mii, mii_raw.data(), sizeof(mii));
|
||||
if (mii.mii_id != 0) {
|
||||
std::u16string name(sizeof(mii.mii_name), '\0');
|
||||
std::memcpy(name.data(), mii.mii_name.data(), sizeof(mii.mii_name));
|
||||
std::string name = TextFromBuffer(mii.mii_name);
|
||||
miis.push_back(mii);
|
||||
combobox->addItem(QString::fromStdU16String(name));
|
||||
combobox->addItem(QString::fromStdString(name));
|
||||
}
|
||||
saved_miis_offset += sizeof(mii);
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
Path(const char* path) : type(LowPathType::Char), string(path) {}
|
||||
Path(std::vector<u8> binary_data) : type(LowPathType::Binary), binary(std::move(binary_data)) {}
|
||||
template <std::size_t size>
|
||||
Path(std::array<u8, size> binary_data)
|
||||
Path(const std::array<u8, size>& binary_data)
|
||||
: type(LowPathType::Binary), binary(binary_data.begin(), binary_data.end()) {}
|
||||
Path(LowPathType type, const std::vector<u8>& data);
|
||||
|
||||
|
@ -18,7 +18,7 @@ constexpr char MII_BUTTON_CANCEL[] = "Cancel";
|
||||
/// later learn is needed can be added here and filled in by the backend HLE applet
|
||||
struct MiiSelectorConfig {
|
||||
bool enable_cancel_button;
|
||||
std::u16string title;
|
||||
std::string title;
|
||||
u32 initially_selected_mii_index;
|
||||
};
|
||||
|
||||
|
@ -19,6 +19,20 @@
|
||||
|
||||
namespace HLE::Applets {
|
||||
|
||||
/**
|
||||
* Converts a UTF-16 text in a container to a UTF-8 std::string.
|
||||
*/
|
||||
template <typename T>
|
||||
std::string TextFromBuffer(const T& text) {
|
||||
const auto text_end = std::find(text.begin(), text.end(), u'\0');
|
||||
const std::size_t text_size = std::distance(text.begin(), text_end);
|
||||
std::u16string buffer(text_size, 0);
|
||||
std::transform(text.begin(), text_end, buffer.begin(), [](u16_le character) {
|
||||
return static_cast<char16_t>(static_cast<u16>(character));
|
||||
});
|
||||
return Common::UTF16ToUTF8(buffer);
|
||||
}
|
||||
|
||||
ResultCode MiiSelector::ReceiveParameter(const Service::APT::MessageParameter& parameter) {
|
||||
if (parameter.signal != Service::APT::SignalType::Request) {
|
||||
LOG_ERROR(Service_APT, "unsupported signal {}", static_cast<u32>(parameter.signal));
|
||||
@ -142,10 +156,7 @@ MiiResult MiiSelector::GetStandardMiiResult() {
|
||||
Frontend::MiiSelectorConfig MiiSelector::ToFrontendConfig(const MiiConfig& config) const {
|
||||
Frontend::MiiSelectorConfig frontend_config;
|
||||
frontend_config.enable_cancel_button = config.enable_cancel_button == 1;
|
||||
std::transform(config.title.begin(), config.title.end(),
|
||||
std::back_inserter(frontend_config.title), [](u16_le character) -> char16_t {
|
||||
return static_cast<char16_t>(static_cast<u16>(character));
|
||||
});
|
||||
frontend_config.title = TextFromBuffer(config.title);
|
||||
frontend_config.initially_selected_mii_index = config.initially_selected_mii_index;
|
||||
return frontend_config;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user