Add support for SFML utf8 strings
Some checks failed
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux32 flags:32 name:Linux GCC 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linux64 flags:64 name:Linux GCC x64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm32 flags:arm32 name:Linux GCC ARM 32 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:linuxarm64 flags:arm64 name:Linux GCC ARM 64 os:ubuntu-latest]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:macos name:macOS Apple Silicon os:macos-14]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win32 flags:-A Win32 name:Windows VS2022 Win32 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:win64 flags:-A x64 name:Windows VS2022 x64 os:windows-2022]) (push) Has been cancelled
CD / ${{ matrix.platform.name }} ${{ matrix.config.name }} (map[flags:-DBUILD_SHARED_LIBS=FALSE name:Static], map[artifact_name:winarm64 flags:-A ARM64 name:Windows VS2022 ARM os:windows-2022]) (push) Has been cancelled
CD / Create Pi Mono Setup (push) Has been cancelled
CD / Publishing (push) Has been cancelled

This commit is contained in:
Lorenzooone
2025-04-17 21:40:35 +02:00
parent 403355ce13
commit 33660b3ef7
4 changed files with 18 additions and 8 deletions

View File

@@ -321,7 +321,8 @@ private:
int get_fullscreen_offset_y(int top_width, int top_height, int bot_width, int bot_height, int separator_contribute);
void resize_window_and_out_rects(bool do_work = true);
void create_window(bool re_prepare_size, bool reset_text = true);
std::string title_factory();
std::string _title_factory();
sf::String title_factory();
void update_view_size();
void open();
void update_screen_settings();

View File

@@ -153,9 +153,13 @@ void TextRectangle::reset_data(TextData &data) {
data.pos_y = 0;
}
static sf::String convert_to_utf8(const std::string &str) {
return sf::String::fromUtf8(str.begin(), str.end());
}
void TextRectangle::setTextWithLineWrapping(int x_limit) {
if(x_limit == 0) {
this->actual_text.setString(this->loaded_data.printed_text);
this->actual_text.setString(convert_to_utf8(this->loaded_data.printed_text));
return;
}
bool is_done = false;
@@ -173,7 +177,7 @@ void TextRectangle::setTextWithLineWrapping(int x_limit) {
}
for(size_t i = pos; i < space_pos; i++)
curr_text += this->loaded_data.printed_text[i];
this->actual_text.setString(curr_text);
this->actual_text.setString(convert_to_utf8(curr_text));
sf::FloatRect globalBounds = this->actual_text.getGlobalBounds();
int bounds_width = (int)(globalBounds.size.x + (globalBounds.position.x * 2));
if(line_started && (bounds_width > x_limit)) {
@@ -185,7 +189,7 @@ void TextRectangle::setTextWithLineWrapping(int x_limit) {
line_started = true;
new_text = curr_text;
}
this->actual_text.setString(new_text);
this->actual_text.setString(convert_to_utf8(new_text));
}
void TextRectangle::setRealSize(int width, int height, bool check_previous) {

View File

@@ -481,13 +481,18 @@ void WindowScreen::window_factory(bool is_main_thread) {
this->update_connection();
}
std::string WindowScreen::title_factory() {
std::string WindowScreen::_title_factory() {
std::string title = this->win_title;
if(this->capture_status->connected)
title += " - " + get_name_of_device(this->capture_status);
return title;
}
sf::String WindowScreen::title_factory() {
std::string title = this->_title_factory();
return sf::String::fromUtf8(title.begin(), title.end());
}
// These values may be undefined under Windows...
#ifndef GL_BGR
#define GL_BGR 0x80e0

View File

@@ -109,7 +109,7 @@ const CropData scaled_ds_pokemon_crop = {
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = false,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Scaled Pokemon DS"};
.name = "Scaled Pokémon DS"};
const CropData scaled_ds_pmd_brt_crop = {
.top_width = TOP_SCALED_DS_WIDTH_3DS, .top_height = HEIGHT_3DS,
@@ -127,7 +127,7 @@ const CropData native_ds_pokemon_crop = {
.bot_x = (BOT_WIDTH_3DS - WIDTH_DS) / 2, .bot_y = HEIGHT_3DS - HEIGHT_DS,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = true, .allowed_ds = false, .is_game_specific = true,
.name = "Native Pokemon DS"};
.name = "Native Pokémon DS"};
const CropData native_ds_pmd_brt_crop = {
.top_width = WIDTH_DS, .top_height = HEIGHT_DS,
@@ -190,7 +190,7 @@ const CropData ds_pokemon_crop = {
.bot_x = 0, .bot_y = 0,
.allowed_joint = true, .allowed_top = true, .allowed_bottom = true,
.allowed_3ds = false, .allowed_ds = true, .is_game_specific = true,
.name = "Pokemon DS"};
.name = "Pokémon DS"};
const CropData ds_pmd_brt_crop = {
.top_width = WIDTH_DS, .top_height = HEIGHT_DS,