1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

cellOskDialog: implement base_color

This commit is contained in:
Megamouse 2022-04-20 18:16:27 +02:00
parent 71f8280c5e
commit b29f106c51
6 changed files with 23 additions and 24 deletions

View File

@ -75,10 +75,7 @@ struct osk_info
atomic_t<u32> supported_languages = 0; // Used to enable non-default languages in the OSK
atomic_t<bool> dimmer_enabled = true;
atomic_t<f32> base_color_red = 1.0f;
atomic_t<f32> base_color_green = 1.0f;
atomic_t<f32> base_color_blue = 1.0f;
atomic_t<f32> base_color_alpha = 1.0f;
atomic_t<OskDialogBase::color> base_color = OskDialogBase::color{ 0.2f, 0.2f, 0.2f, 1.0f };
atomic_t<bool> pointer_enabled = false;
CellOskDialogPoint pointer_pos{0.0f, 0.0f};
@ -112,10 +109,7 @@ struct osk_info
half_byte_kana_enabled = false;
supported_languages = 0;
dimmer_enabled = true;
base_color_red = 1.0f;
base_color_blue = 1.0f;
base_color_green = 1.0f;
base_color_alpha = 1.0f;
base_color = OskDialogBase::color{ 0.2f, 0.2f, 0.2f, 1.0f };
pointer_enabled = false;
pointer_pos = {0.0f, 0.0f};
initial_scale = 1.0f;
@ -511,9 +505,9 @@ error_code cellOskDialogLoadAsync(u32 container, vm::ptr<CellOskDialogParam> dia
return CELL_OK;
}
Emu.CallFromMainThread([=, &result]()
Emu.CallFromMainThread([=, &result, &info]()
{
osk->Create(get_localized_string(localized_string_id::CELL_OSK_DIALOG_TITLE), message, osk->osk_text, maxLength, prohibitFlgs, allowOskPanelFlg, firstViewPanel);
osk->Create(get_localized_string(localized_string_id::CELL_OSK_DIALOG_TITLE), message, osk->osk_text, maxLength, prohibitFlgs, allowOskPanelFlg, firstViewPanel, info.base_color.load());
result = true;
result.notify_one();
@ -995,12 +989,7 @@ error_code cellOskDialogExtSetBaseColor(f32 red, f32 green, f32 blue, f32 alpha)
}
auto& osk = g_fxo->get<osk_info>();
osk.base_color_red = red;
osk.base_color_green = green;
osk.base_color_blue = blue;
osk.base_color_alpha = alpha;
// TODO: use osk base color
osk.base_color = OskDialogBase::color{ red, green, blue, alpha };
return CELL_OK;
}

View File

@ -253,7 +253,15 @@ enum class OskDialogState
class OskDialogBase
{
public:
virtual void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) = 0;
struct color
{
f32 r = 1.0f;
f32 g = 1.0f;
f32 b = 1.0f;
f32 a = 1.0f;
};
virtual void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel, color base_color) = 0;
// Closes the dialog.
// Set status to CELL_OSKDIALOG_CLOSE_CONFIRM or CELL_OSKDIALOG_CLOSE_CANCEL for user input.

View File

@ -267,10 +267,8 @@ namespace rsx
m_background.set_size(1280, 720);
m_background.back_color.a = 0.8f;
m_frame.back_color = { 0.2f, 0.2f, 0.2f, 1.f };
m_title.set_unicode_text(title);
m_title.back_color.a = 0.f;
m_title.back_color.a = 0.7f; // Uses the dimmed color of the frame background
m_preview.password_mode = m_password_mode;
m_preview.set_placeholder(get_placeholder());
@ -946,11 +944,15 @@ namespace rsx
static constexpr auto thread_name = "OSK Thread"sv;
};
void osk_dialog::Create(const std::string& /*title*/, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel)
void osk_dialog::Create(const std::string& /*title*/, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel, color base_color)
{
state = OskDialogState::Open;
flags = prohibit_flags;
char_limit = charlimit;
m_frame.back_color.r = base_color.r;
m_frame.back_color.g = base_color.g;
m_frame.back_color.b = base_color.b;
m_frame.back_color.a = base_color.a;
const callback_t shift_cb = [this](const std::u32string& text){ on_shift(text); };
const callback_t layer_cb = [this](const std::u32string& text){ on_layer(text); };

View File

@ -82,7 +82,7 @@ namespace rsx
osk_dialog();
~osk_dialog() override = default;
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) override;
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel, color base_color) override;
void Close(s32 status) override;
void initialize_layout(const std::u32string& title, const std::u32string& initial_text);

View File

@ -22,7 +22,7 @@ osk_dialog_frame::~osk_dialog_frame()
}
}
void osk_dialog_frame::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 /*first_view_panel*/)
void osk_dialog_frame::Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 /*first_view_panel*/, color /*base_color*/)
{
state = OskDialogState::Open;

View File

@ -16,7 +16,7 @@ class osk_dialog_frame : public QObject, public OskDialogBase
public:
osk_dialog_frame() = default;
~osk_dialog_frame();
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel) override;
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 prohibit_flags, u32 panel_flag, u32 first_view_panel, color base_color) override;
void Close(s32 status) override;
private: