applets: Port current applets to take frontend in constructor

As opposed to using Core::System::GetInstance()
This commit is contained in:
Zach Hilman 2019-03-11 19:35:01 -04:00
parent f7540157e4
commit d273bec68f
6 changed files with 16 additions and 14 deletions

View file

@ -15,7 +15,9 @@ namespace Service::AM::Applets {
constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1}; constexpr ResultCode ERR_USER_CANCELLED_SELECTION{ErrorModule::Account, 1};
ProfileSelect::ProfileSelect() = default; ProfileSelect::ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend)
: frontend(frontend) {}
ProfileSelect::~ProfileSelect() = default; ProfileSelect::~ProfileSelect() = default;
void ProfileSelect::Initialize() { void ProfileSelect::Initialize() {
@ -51,8 +53,6 @@ void ProfileSelect::Execute() {
return; return;
} }
const auto& frontend{Core::System::GetInstance().GetProfileSelector()};
frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); }); frontend.SelectProfile([this](std::optional<Account::UUID> uuid) { SelectionComplete(uuid); });
} }

View file

@ -7,6 +7,7 @@
#include <vector> #include <vector>
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "core/frontend/applets/software_keyboard.h"
#include "core/hle/service/acc/profile_manager.h" #include "core/hle/service/acc/profile_manager.h"
#include "core/hle/service/am/applets/applets.h" #include "core/hle/service/am/applets/applets.h"
@ -28,7 +29,7 @@ static_assert(sizeof(UserSelectionOutput) == 0x18, "UserSelectionOutput has inco
class ProfileSelect final : public Applet { class ProfileSelect final : public Applet {
public: public:
ProfileSelect(); ProfileSelect(const Core::Frontend::ProfileSelectApplet& frontend);
~ProfileSelect() override; ~ProfileSelect() override;
void Initialize() override; void Initialize() override;
@ -41,6 +42,8 @@ public:
void SelectionComplete(std::optional<Account::UUID> uuid); void SelectionComplete(std::optional<Account::UUID> uuid);
private: private:
const Core::Frontend::ProfileSelectApplet& frontend;
UserSelectionConfig config; UserSelectionConfig config;
bool complete = false; bool complete = false;
ResultCode status = RESULT_SUCCESS; ResultCode status = RESULT_SUCCESS;

View file

@ -39,7 +39,8 @@ static Core::Frontend::SoftwareKeyboardParameters ConvertToFrontendParameters(
return params; return params;
} }
SoftwareKeyboard::SoftwareKeyboard() = default; SoftwareKeyboard::SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend)
: frontend(frontend) {}
SoftwareKeyboard::~SoftwareKeyboard() = default; SoftwareKeyboard::~SoftwareKeyboard() = default;
@ -90,8 +91,6 @@ void SoftwareKeyboard::ExecuteInteractive() {
if (status == INTERACTIVE_STATUS_OK) { if (status == INTERACTIVE_STATUS_OK) {
complete = true; complete = true;
} else { } else {
const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()};
std::array<char16_t, SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE / 2 - 2> string; std::array<char16_t, SWKBD_OUTPUT_INTERACTIVE_BUFFER_SIZE / 2 - 2> string;
std::memcpy(string.data(), data.data() + 4, string.size() * 2); std::memcpy(string.data(), data.data() + 4, string.size() * 2);
frontend.SendTextCheckDialog( frontend.SendTextCheckDialog(
@ -106,8 +105,6 @@ void SoftwareKeyboard::Execute() {
return; return;
} }
const auto& frontend{Core::System::GetInstance().GetSoftwareKeyboard()};
const auto parameters = ConvertToFrontendParameters(config, initial_text); const auto parameters = ConvertToFrontendParameters(config, initial_text);
frontend.RequestText([this](std::optional<std::u16string> text) { WriteText(text); }, frontend.RequestText([this](std::optional<std::u16string> text) { WriteText(text); },

View file

@ -55,7 +55,7 @@ static_assert(sizeof(KeyboardConfig) == 0x3E0, "KeyboardConfig has incorrect siz
class SoftwareKeyboard final : public Applet { class SoftwareKeyboard final : public Applet {
public: public:
SoftwareKeyboard(); SoftwareKeyboard(const Core::Frontend::SoftwareKeyboardApplet& frontend);
~SoftwareKeyboard() override; ~SoftwareKeyboard() override;
void Initialize() override; void Initialize() override;
@ -68,6 +68,8 @@ public:
void WriteText(std::optional<std::u16string> text); void WriteText(std::optional<std::u16string> text);
private: private:
const Core::Frontend::SoftwareKeyboardApplet& frontend;
KeyboardConfig config; KeyboardConfig config;
std::u16string initial_text; std::u16string initial_text;
bool complete = false; bool complete = false;

View file

@ -95,7 +95,7 @@ static FileSys::VirtualFile GetManualRomFS() {
return nullptr; return nullptr;
} }
WebBrowser::WebBrowser() = default; WebBrowser::WebBrowser(const Core::Frontend::WebBrowserApplet& frontend) : frontend(frontend) {}
WebBrowser::~WebBrowser() = default; WebBrowser::~WebBrowser() = default;
@ -152,8 +152,6 @@ void WebBrowser::Execute() {
return; return;
} }
auto& frontend{Core::System::GetInstance().GetWebBrowser()};
frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); }); frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); });
} }

View file

@ -12,7 +12,7 @@ namespace Service::AM::Applets {
class WebBrowser final : public Applet { class WebBrowser final : public Applet {
public: public:
WebBrowser(); WebBrowser(const Core::Frontend::WebBrowserApplet& frontend);
~WebBrowser() override; ~WebBrowser() override;
void Initialize() override; void Initialize() override;
@ -32,6 +32,8 @@ public:
void Finalize(); void Finalize();
private: private:
const Core::Frontend::WebBrowserApplet& frontend;
bool complete = false; bool complete = false;
bool unpacked = false; bool unpacked = false;
ResultCode status = RESULT_SUCCESS; ResultCode status = RESULT_SUCCESS;