mirror of https://github.com/RPCS3/rpcs3.git
overlays: Ditch wstring for u32string
- Turns out wstring is not the same as u32string on windows.
This commit is contained in:
parent
13ef0cc8c4
commit
f6ebd88687
|
@ -331,7 +331,7 @@ namespace rsx
|
||||||
u16 w = 0;
|
u16 w = 0;
|
||||||
u16 h = 0;
|
u16 h = 0;
|
||||||
|
|
||||||
std::wstring text;
|
std::u32string text;
|
||||||
font* font_ref = nullptr;
|
font* font_ref = nullptr;
|
||||||
text_align alignment = left;
|
text_align alignment = left;
|
||||||
bool wrap_text = false;
|
bool wrap_text = false;
|
||||||
|
@ -433,11 +433,11 @@ namespace rsx
|
||||||
|
|
||||||
virtual void set_text(const std::string& text)
|
virtual void set_text(const std::string& text)
|
||||||
{
|
{
|
||||||
this->text = utf8_to_wstring(text);
|
this->text = utf8_to_u32string(text);
|
||||||
is_compiled = false;
|
is_compiled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void set_text(const std::wstring& text)
|
virtual void set_text(const std::u32string& text)
|
||||||
{
|
{
|
||||||
this->text = text;
|
this->text = text;
|
||||||
is_compiled = false;
|
is_compiled = false;
|
||||||
|
@ -466,7 +466,7 @@ namespace rsx
|
||||||
return font_ref ? font_ref : fontmgr::get("Arial", 12);
|
return font_ref ? font_ref : fontmgr::get("Arial", 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual std::vector<vertex> render_text(const wchar_t *string, f32 x, f32 y)
|
virtual std::vector<vertex> render_text(const char32_t *string, f32 x, f32 y)
|
||||||
{
|
{
|
||||||
auto renderer = get_font();
|
auto renderer = get_font();
|
||||||
|
|
||||||
|
@ -1036,7 +1036,7 @@ namespace rsx
|
||||||
|
|
||||||
int get_selected_index();
|
int get_selected_index();
|
||||||
|
|
||||||
std::wstring get_selected_item();
|
std::u32string get_selected_item();
|
||||||
|
|
||||||
void set_cancel_only(bool cancel_only);
|
void set_cancel_only(bool cancel_only);
|
||||||
void translate(s16 _x, s16 _y) override;
|
void translate(s16 _x, s16 _y) override;
|
||||||
|
@ -1060,7 +1060,7 @@ namespace rsx
|
||||||
using label::label;
|
using label::label;
|
||||||
|
|
||||||
void move_caret(direction dir);
|
void move_caret(direction dir);
|
||||||
void insert_text(const std::wstring& str);
|
void insert_text(const std::u32string& str);
|
||||||
void erase();
|
void erase();
|
||||||
|
|
||||||
compiled_resource& get_compiled() override;
|
compiled_resource& get_compiled() override;
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void edit_text::insert_text(const std::wstring& str)
|
void edit_text::insert_text(const std::u32string& str)
|
||||||
{
|
{
|
||||||
if (caret_position == 0)
|
if (caret_position == 0)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ namespace rsx
|
||||||
|
|
||||||
if (caret_position == 1)
|
if (caret_position == 1)
|
||||||
{
|
{
|
||||||
text = text.length() > 1 ? text.substr(1) : L"";
|
text = text.length() > 1 ? text.substr(1) : U"";
|
||||||
}
|
}
|
||||||
else if (caret_position == text.length())
|
else if (caret_position == text.length())
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace rsx
|
||||||
{
|
{
|
||||||
namespace overlays
|
namespace overlays
|
||||||
{
|
{
|
||||||
void codepage::initialize_glyphs(u16 codepage_id, f32 font_size, const std::vector<u8>& ttf_data)
|
void codepage::initialize_glyphs(char32_t codepage_id, f32 font_size, const std::vector<u8>& ttf_data)
|
||||||
{
|
{
|
||||||
glyph_base = (codepage_id * 256);
|
glyph_base = (codepage_id * 256);
|
||||||
glyph_data.resize(bitmap_width * bitmap_height);
|
glyph_data.resize(bitmap_width * bitmap_height);
|
||||||
|
@ -31,7 +31,7 @@ namespace rsx
|
||||||
stbtt_PackEnd(&context);
|
stbtt_PackEnd(&context);
|
||||||
}
|
}
|
||||||
|
|
||||||
stbtt_aligned_quad codepage::get_char(wchar_t c, f32& x_advance, f32& y_advance)
|
stbtt_aligned_quad codepage::get_char(char32_t c, f32& x_advance, f32& y_advance)
|
||||||
{
|
{
|
||||||
stbtt_aligned_quad quad;
|
stbtt_aligned_quad quad;
|
||||||
stbtt_GetPackedQuad(pack_info.data(), bitmap_width, bitmap_height, (c - glyph_base), &x_advance, &y_advance, &quad, false);
|
stbtt_GetPackedQuad(pack_info.data(), bitmap_width, bitmap_height, (c - glyph_base), &x_advance, &y_advance, &quad, false);
|
||||||
|
@ -51,7 +51,7 @@ namespace rsx
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
language_class font::classify(u16 codepage_id)
|
language_class font::classify(char32_t codepage_id)
|
||||||
{
|
{
|
||||||
switch (codepage_id)
|
switch (codepage_id)
|
||||||
{
|
{
|
||||||
|
@ -151,7 +151,7 @@ namespace rsx
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
codepage* font::initialize_codepage(u16 codepage_id)
|
codepage* font::initialize_codepage(char32_t codepage_id)
|
||||||
{
|
{
|
||||||
// Init glyph
|
// Init glyph
|
||||||
const auto class_ = classify(codepage_id);
|
const auto class_ = classify(codepage_id);
|
||||||
|
@ -210,7 +210,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rsx_log.error("Failed to initialize font '%s.ttf' on codepage %d", font_name, codepage_id);
|
rsx_log.error("Failed to initialize font '%s.ttf' on codepage %d", font_name, static_cast<u32>(codepage_id));
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ namespace rsx
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
stbtt_aligned_quad font::get_char(wchar_t c, f32& x_advance, f32& y_advance)
|
stbtt_aligned_quad font::get_char(char32_t c, f32& x_advance, f32& y_advance)
|
||||||
{
|
{
|
||||||
if (!initialized)
|
if (!initialized)
|
||||||
return {};
|
return {};
|
||||||
|
@ -265,7 +265,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void font::render_text_ex(std::vector<vertex>& result, f32& x_advance, f32& y_advance, const wchar_t* text, u32 char_limit, u16 max_width, bool wrap)
|
void font::render_text_ex(std::vector<vertex>& result, f32& x_advance, f32& y_advance, const char32_t* text, u32 char_limit, u16 max_width, bool wrap)
|
||||||
{
|
{
|
||||||
x_advance = 0.f;
|
x_advance = 0.f;
|
||||||
y_advance = 0.f;
|
y_advance = 0.f;
|
||||||
|
@ -401,7 +401,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<vertex> font::render_text(const wchar_t* text, u16 max_width, bool wrap)
|
std::vector<vertex> font::render_text(const char32_t* text, u16 max_width, bool wrap)
|
||||||
{
|
{
|
||||||
std::vector<vertex> result;
|
std::vector<vertex> result;
|
||||||
f32 unused_x, unused_y;
|
f32 unused_x, unused_y;
|
||||||
|
@ -410,7 +410,7 @@ namespace rsx
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<f32, f32> font::get_char_offset(const wchar_t* text, u16 max_length, u16 max_width, bool wrap)
|
std::pair<f32, f32> font::get_char_offset(const char32_t* text, u16 max_length, u16 max_width, bool wrap)
|
||||||
{
|
{
|
||||||
std::vector<vertex> unused;
|
std::vector<vertex> unused;
|
||||||
f32 loc_x, loc_y;
|
f32 loc_x, loc_y;
|
||||||
|
|
|
@ -37,11 +37,11 @@ namespace rsx
|
||||||
|
|
||||||
std::vector<stbtt_packedchar> pack_info;
|
std::vector<stbtt_packedchar> pack_info;
|
||||||
std::vector<u8> glyph_data;
|
std::vector<u8> glyph_data;
|
||||||
u16 glyph_base = 0;
|
char32_t glyph_base = 0;
|
||||||
f32 sampler_z = 0.f;
|
f32 sampler_z = 0.f;
|
||||||
|
|
||||||
void initialize_glyphs(u16 codepage_id, f32 font_size, const std::vector<u8>& ttf_data);
|
void initialize_glyphs(char32_t codepage_id, f32 font_size, const std::vector<u8>& ttf_data);
|
||||||
stbtt_aligned_quad get_char(wchar_t c, f32& x_advance, f32& y_advance);
|
stbtt_aligned_quad get_char(char32_t c, f32& x_advance, f32& y_advance);
|
||||||
};
|
};
|
||||||
|
|
||||||
class font
|
class font
|
||||||
|
@ -52,30 +52,30 @@ namespace rsx
|
||||||
f32 em_size = 0.f;
|
f32 em_size = 0.f;
|
||||||
std::string font_name;
|
std::string font_name;
|
||||||
|
|
||||||
std::vector<std::pair<u32, std::unique_ptr<codepage>>> m_glyph_map;
|
std::vector<std::pair<char32_t, std::unique_ptr<codepage>>> m_glyph_map;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
u16 codepage_id = 0;
|
char32_t codepage_id = 0;
|
||||||
codepage* page = nullptr;
|
codepage* page = nullptr;
|
||||||
}
|
}
|
||||||
codepage_cache;
|
codepage_cache;
|
||||||
|
|
||||||
language_class classify(u16 page);
|
language_class classify(char32_t page);
|
||||||
glyph_load_setup get_glyph_files(language_class class_);
|
glyph_load_setup get_glyph_files(language_class class_);
|
||||||
codepage* initialize_codepage(u16 page);
|
codepage* initialize_codepage(char32_t page);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
font(const char* ttf_name, f32 size);
|
font(const char* ttf_name, f32 size);
|
||||||
|
|
||||||
stbtt_aligned_quad get_char(wchar_t c, f32& x_advance, f32& y_advance);
|
stbtt_aligned_quad get_char(char32_t c, f32& x_advance, f32& y_advance);
|
||||||
|
|
||||||
void render_text_ex(std::vector<vertex>& result, f32& x_advance, f32& y_advance, const wchar_t* text, u32 char_limit, u16 max_width, bool wrap);
|
void render_text_ex(std::vector<vertex>& result, f32& x_advance, f32& y_advance, const char32_t* text, u32 char_limit, u16 max_width, bool wrap);
|
||||||
|
|
||||||
std::vector<vertex> render_text(const wchar_t* text, u16 max_width = UINT16_MAX, bool wrap = false);
|
std::vector<vertex> render_text(const char32_t* text, u16 max_width = UINT16_MAX, bool wrap = false);
|
||||||
|
|
||||||
std::pair<f32, f32> get_char_offset(const wchar_t* text, u16 max_length, u16 max_width = UINT16_MAX, bool wrap = false);
|
std::pair<f32, f32> get_char_offset(const char32_t* text, u16 max_length, u16 max_width = UINT16_MAX, bool wrap = false);
|
||||||
|
|
||||||
bool matches(const char* name, int size) const { return font_name == name && static_cast<int>(size_pt) == size; }
|
bool matches(const char* name, int size) const { return font_name == name && static_cast<int>(size_pt) == size; }
|
||||||
std::string_view get_name() const { return font_name; };
|
std::string_view get_name() const { return font_name; };
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace rsx
|
||||||
return m_selected_entry;
|
return m_selected_entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring list_view::get_selected_item()
|
std::u32string list_view::get_selected_item()
|
||||||
{
|
{
|
||||||
if (m_selected_entry < 0)
|
if (m_selected_entry < 0)
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace rsx
|
||||||
fade_animation.active = true;
|
fade_animation.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osk_dialog::initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::wstring& title, const std::wstring& initial_text)
|
void osk_dialog::initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::u32string& title, const std::u32string& initial_text)
|
||||||
{
|
{
|
||||||
const u32 cell_count = num_rows * num_columns;
|
const u32 cell_count = num_rows * num_columns;
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
case pad_button::select:
|
case pad_button::select:
|
||||||
{
|
{
|
||||||
on_shift(L"");
|
on_shift(U"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case pad_button::start:
|
case pad_button::start:
|
||||||
|
@ -380,12 +380,12 @@ namespace rsx
|
||||||
}
|
}
|
||||||
case pad_button::triangle:
|
case pad_button::triangle:
|
||||||
{
|
{
|
||||||
on_space(L"");
|
on_space(U"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case pad_button::square:
|
case pad_button::square:
|
||||||
{
|
{
|
||||||
on_backspace(L"");
|
on_backspace(U"");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case pad_button::cross:
|
case pad_button::cross:
|
||||||
|
@ -405,7 +405,7 @@ namespace rsx
|
||||||
|
|
||||||
void osk_dialog::on_text_changed()
|
void osk_dialog::on_text_changed()
|
||||||
{
|
{
|
||||||
const auto ws = wstring_to_utf16(m_preview.text);
|
const auto ws = u32string_to_utf16(m_preview.text);
|
||||||
const auto length = (ws.length() + 1) * sizeof(char16_t);
|
const auto length = (ws.length() + 1) * sizeof(char16_t);
|
||||||
memcpy(osk_text, ws.c_str(), length);
|
memcpy(osk_text, ws.c_str(), length);
|
||||||
|
|
||||||
|
@ -417,10 +417,10 @@ namespace rsx
|
||||||
m_update = true;
|
m_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osk_dialog::on_default_callback(const std::wstring& str)
|
void osk_dialog::on_default_callback(const std::u32string& str)
|
||||||
{
|
{
|
||||||
// Append to output text
|
// Append to output text
|
||||||
if (m_preview.text == L"[Enter Text]")
|
if (m_preview.text == U"[Enter Text]")
|
||||||
{
|
{
|
||||||
m_preview.caret_position = ::narrow<u16>(str.length());
|
m_preview.caret_position = ::narrow<u16>(str.length());
|
||||||
m_preview.set_text(str);
|
m_preview.set_text(str);
|
||||||
|
@ -443,17 +443,17 @@ namespace rsx
|
||||||
on_text_changed();
|
on_text_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void osk_dialog::on_shift(const std::wstring&)
|
void osk_dialog::on_shift(const std::u32string&)
|
||||||
{
|
{
|
||||||
selected_z = (selected_z + 1) % num_layers;
|
selected_z = (selected_z + 1) % num_layers;
|
||||||
m_update = true;
|
m_update = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void osk_dialog::on_space(const std::wstring&)
|
void osk_dialog::on_space(const std::u32string&)
|
||||||
{
|
{
|
||||||
if (!(flags & CELL_OSKDIALOG_NO_SPACE))
|
if (!(flags & CELL_OSKDIALOG_NO_SPACE))
|
||||||
{
|
{
|
||||||
on_default_callback(L" ");
|
on_default_callback(U" ");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -461,7 +461,7 @@ namespace rsx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void osk_dialog::on_backspace(const std::wstring&)
|
void osk_dialog::on_backspace(const std::u32string&)
|
||||||
{
|
{
|
||||||
if (m_preview.text.empty())
|
if (m_preview.text.empty())
|
||||||
{
|
{
|
||||||
|
@ -472,11 +472,11 @@ namespace rsx
|
||||||
on_text_changed();
|
on_text_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void osk_dialog::on_enter(const std::wstring&)
|
void osk_dialog::on_enter(const std::u32string&)
|
||||||
{
|
{
|
||||||
if (!(flags & CELL_OSKDIALOG_NO_RETURN))
|
if (!(flags & CELL_OSKDIALOG_NO_RETURN))
|
||||||
{
|
{
|
||||||
on_default_callback(L"\n");
|
on_default_callback(U"\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -617,57 +617,57 @@ namespace rsx
|
||||||
std::vector<osk_dialog::grid_entry_ctor> layout =
|
std::vector<osk_dialog::grid_entry_ctor> layout =
|
||||||
{
|
{
|
||||||
// Alphanumeric
|
// Alphanumeric
|
||||||
{{L"1", L"!"}, default_bg, 1},
|
{{U"1", U"!"}, default_bg, 1},
|
||||||
{{L"2", L"@"}, default_bg, 1},
|
{{U"2", U"@"}, default_bg, 1},
|
||||||
{{L"3", L"#"}, default_bg, 1},
|
{{U"3", U"#"}, default_bg, 1},
|
||||||
{{L"4", L"$"}, default_bg, 1},
|
{{U"4", U"$"}, default_bg, 1},
|
||||||
{{L"5", L"%"}, default_bg, 1},
|
{{U"5", U"%"}, default_bg, 1},
|
||||||
{{L"6", L"^"}, default_bg, 1},
|
{{U"6", U"^"}, default_bg, 1},
|
||||||
{{L"7", L"&"}, default_bg, 1},
|
{{U"7", U"&"}, default_bg, 1},
|
||||||
{{L"8", L"*"}, default_bg, 1},
|
{{U"8", U"*"}, default_bg, 1},
|
||||||
{{L"9", L"("}, default_bg, 1},
|
{{U"9", U"("}, default_bg, 1},
|
||||||
{{L"0", L")"}, default_bg, 1},
|
{{U"0", U")"}, default_bg, 1},
|
||||||
|
|
||||||
// Alpha
|
// Alpha
|
||||||
{{L"q", L"Q"}, default_bg, 1},
|
{{U"q", U"Q"}, default_bg, 1},
|
||||||
{{L"w", L"W"}, default_bg, 1},
|
{{U"w", U"W"}, default_bg, 1},
|
||||||
{{L"e", L"E"}, default_bg, 1},
|
{{U"e", U"E"}, default_bg, 1},
|
||||||
{{L"r", L"R"}, default_bg, 1},
|
{{U"r", U"R"}, default_bg, 1},
|
||||||
{{L"t", L"T"}, default_bg, 1},
|
{{U"t", U"T"}, default_bg, 1},
|
||||||
{{L"y", L"Y"}, default_bg, 1},
|
{{U"y", U"Y"}, default_bg, 1},
|
||||||
{{L"u", L"U"}, default_bg, 1},
|
{{U"u", U"U"}, default_bg, 1},
|
||||||
{{L"i", L"I"}, default_bg, 1},
|
{{U"i", U"I"}, default_bg, 1},
|
||||||
{{L"o", L"O"}, default_bg, 1},
|
{{U"o", U"O"}, default_bg, 1},
|
||||||
{{L"p", L"P"}, default_bg, 1},
|
{{U"p", U"P"}, default_bg, 1},
|
||||||
{{L"a", L"A"}, default_bg, 1},
|
{{U"a", U"A"}, default_bg, 1},
|
||||||
{{L"s", L"S"}, default_bg, 1},
|
{{U"s", U"S"}, default_bg, 1},
|
||||||
{{L"d", L"D"}, default_bg, 1},
|
{{U"d", U"D"}, default_bg, 1},
|
||||||
{{L"f", L"F"}, default_bg, 1},
|
{{U"f", U"F"}, default_bg, 1},
|
||||||
{{L"g", L"G"}, default_bg, 1},
|
{{U"g", U"G"}, default_bg, 1},
|
||||||
{{L"h", L"H"}, default_bg, 1},
|
{{U"h", U"H"}, default_bg, 1},
|
||||||
{{L"j", L"J"}, default_bg, 1},
|
{{U"j", U"J"}, default_bg, 1},
|
||||||
{{L"k", L"K"}, default_bg, 1},
|
{{U"k", U"K"}, default_bg, 1},
|
||||||
{{L"l", L"L"}, default_bg, 1},
|
{{U"U", U"U"}, default_bg, 1},
|
||||||
{{L"'", L"\""}, default_bg, 1},
|
{{U"'", U"\""}, default_bg, 1},
|
||||||
{{L"z", L"Z"}, default_bg, 1},
|
{{U"z", U"Z"}, default_bg, 1},
|
||||||
{{L"x", L"X"}, default_bg, 1},
|
{{U"x", U"X"}, default_bg, 1},
|
||||||
{{L"c", L"C"}, default_bg, 1},
|
{{U"c", U"C"}, default_bg, 1},
|
||||||
{{L"v", L"V"}, default_bg, 1},
|
{{U"v", U"V"}, default_bg, 1},
|
||||||
{{L"b", L"B"}, default_bg, 1},
|
{{U"b", U"B"}, default_bg, 1},
|
||||||
{{L"n", L"N"}, default_bg, 1},
|
{{U"n", U"N"}, default_bg, 1},
|
||||||
{{L"m", L"M"}, default_bg, 1},
|
{{U"m", U"M"}, default_bg, 1},
|
||||||
{{L"-", L"_"}, default_bg, 1},
|
{{U"-", U"_"}, default_bg, 1},
|
||||||
{{L"+", L"="}, default_bg, 1},
|
{{U"+", U"="}, default_bg, 1},
|
||||||
{{L",", L"?"}, default_bg, 1},
|
{{U",", U"?"}, default_bg, 1},
|
||||||
|
|
||||||
// Special
|
// Special
|
||||||
{{L"Shift"}, special2_bg, 2, button_flags::_default, shift_callback },
|
{{U"Shift"}, special2_bg, 2, button_flags::_default, shift_callback },
|
||||||
{{L"Space"}, special_bg, 4, button_flags::_space, space_callback },
|
{{U"Space"}, special_bg, 4, button_flags::_space, space_callback },
|
||||||
{{L"Backspace"}, special_bg, 2, button_flags::_default, delete_callback },
|
{{U"Backspace"}, special_bg, 2, button_flags::_default, delete_callback },
|
||||||
{{L"Enter"}, special2_bg, 2, button_flags::_return, enter_callback },
|
{{U"Enter"}, special2_bg, 2, button_flags::_return, enter_callback },
|
||||||
};
|
};
|
||||||
|
|
||||||
initialize_layout(layout, utf16_to_wstring(message), utf16_to_wstring(init_text));
|
initialize_layout(layout, utf16_to_u32string(message), utf16_to_u32string(init_text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,6 @@ using vector3f = vector3_base<float>;
|
||||||
std::string utf8_to_ascii8(const std::string& utf8_string);
|
std::string utf8_to_ascii8(const std::string& utf8_string);
|
||||||
std::string utf16_to_ascii8(const std::u16string& utf16_string);
|
std::string utf16_to_ascii8(const std::u16string& utf16_string);
|
||||||
std::u16string ascii8_to_utf16(const std::string& ascii_string);
|
std::u16string ascii8_to_utf16(const std::string& ascii_string);
|
||||||
std::wstring utf8_to_wstring(const std::string& utf8_string);
|
std::u32string utf8_to_u32string(const std::string& utf8_string);
|
||||||
std::u16string wstring_to_utf16(const std::wstring& w_string);
|
std::u16string u32string_to_utf16(const std::u32string& utf32_string);
|
||||||
std::wstring utf16_to_wstring(const std::u16string& utf16_string);
|
std::u32string utf16_to_u32string(const std::u16string& utf16_string);
|
||||||
|
|
|
@ -168,57 +168,43 @@ std::u16string ascii8_to_utf16(const std::string& ascii_string)
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring utf8_to_wstring(const std::string& utf8_string)
|
std::u32string utf8_to_u32string(const std::string& utf8_string)
|
||||||
{
|
{
|
||||||
std::wstring result;
|
std::u32string result;
|
||||||
result.reserve(utf8_string.size());
|
result.reserve(utf8_string.size());
|
||||||
|
|
||||||
process_multibyte(utf8_string, [&result](u32 code)
|
process_multibyte(utf8_string, [&result](u32 code)
|
||||||
{
|
{
|
||||||
result.push_back(static_cast<wchar_t>(code));
|
result.push_back(static_cast<char32_t>(code));
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::u16string wstring_to_utf16(const std::wstring& w_string)
|
std::u16string u32string_to_utf16(const std::u32string& utf32_string)
|
||||||
{
|
{
|
||||||
if constexpr (sizeof(wchar_t) == sizeof(char16_t))
|
std::u16string result;
|
||||||
{
|
result.reserve(utf32_string.size());
|
||||||
return reinterpret_cast<const char16_t*>(w_string.data());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::u16string result;
|
|
||||||
result.reserve(w_string.size());
|
|
||||||
|
|
||||||
for (const auto& code : w_string)
|
for (const auto& code : utf32_string)
|
||||||
{
|
{
|
||||||
result.push_back(code);
|
result.push_back(static_cast<char16_t>(code));
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring utf16_to_wstring(const std::u16string& utf16_string)
|
std::u32string utf16_to_u32string(const std::u16string& utf16_string)
|
||||||
{
|
{
|
||||||
if constexpr (sizeof(wchar_t) == sizeof(char16_t))
|
std::u32string result;
|
||||||
{
|
result.reserve(utf16_string.size());
|
||||||
return reinterpret_cast<const wchar_t*>(utf16_string.data());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::wstring result;
|
|
||||||
result.reserve(utf16_string.size());
|
|
||||||
|
|
||||||
for (const auto& code : utf16_string)
|
for (const auto& code : utf16_string)
|
||||||
{
|
{
|
||||||
result.push_back(code);
|
result.push_back(code);
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace rsx
|
namespace rsx
|
||||||
|
|
|
@ -330,7 +330,7 @@ namespace rsx
|
||||||
|
|
||||||
struct osk_dialog : public user_interface, public OskDialogBase
|
struct osk_dialog : public user_interface, public OskDialogBase
|
||||||
{
|
{
|
||||||
using callback_t = std::function<void(const std::wstring&)>;
|
using callback_t = std::function<void(const std::u32string&)>;
|
||||||
|
|
||||||
enum border_flags
|
enum border_flags
|
||||||
{
|
{
|
||||||
|
@ -360,13 +360,13 @@ namespace rsx
|
||||||
bool selected = false;
|
bool selected = false;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
|
||||||
std::vector<std::wstring> outputs;
|
std::vector<std::u32string> outputs;
|
||||||
callback_t callback;
|
callback_t callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct grid_entry_ctor
|
struct grid_entry_ctor
|
||||||
{
|
{
|
||||||
std::vector<std::wstring> outputs;
|
std::vector<std::u32string> outputs;
|
||||||
color4f color;
|
color4f color;
|
||||||
u32 num_cell_hz;
|
u32 num_cell_hz;
|
||||||
button_flags type_flags;
|
button_flags type_flags;
|
||||||
|
@ -412,17 +412,17 @@ namespace rsx
|
||||||
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options) override = 0;
|
void Create(const std::string& title, const std::u16string& message, char16_t* init_text, u32 charlimit, u32 options) override = 0;
|
||||||
void Close(bool ok) override;
|
void Close(bool ok) override;
|
||||||
|
|
||||||
void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::wstring& title, const std::wstring& initial_text);
|
void initialize_layout(const std::vector<grid_entry_ctor>& layout, const std::u32string& title, const std::u32string& initial_text);
|
||||||
void update() override;
|
void update() override;
|
||||||
|
|
||||||
void on_button_pressed(pad_button button_press) override;
|
void on_button_pressed(pad_button button_press) override;
|
||||||
void on_text_changed();
|
void on_text_changed();
|
||||||
|
|
||||||
void on_default_callback(const std::wstring&);
|
void on_default_callback(const std::u32string&);
|
||||||
void on_shift(const std::wstring&);
|
void on_shift(const std::u32string&);
|
||||||
void on_space(const std::wstring&);
|
void on_space(const std::u32string&);
|
||||||
void on_backspace(const std::wstring&);
|
void on_backspace(const std::u32string&);
|
||||||
void on_enter(const std::wstring&);
|
void on_enter(const std::u32string&);
|
||||||
|
|
||||||
compiled_resource get_compiled() override;
|
compiled_resource get_compiled() override;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue