diff --git a/src/gui/assets/localization/localization.h b/src/gui/assets/localization/localization.h index b741429..e90206e 100644 --- a/src/gui/assets/localization/localization.h +++ b/src/gui/assets/localization/localization.h @@ -146,6 +146,8 @@ static std::vector p2p_disconnected = { static std::vector p2p_connecting = { reinterpret_cast(u8"正在建立对等连接..."), "P2P Connecting ..."}; +static std::vector receiving_screen = { + reinterpret_cast(u8"画面接收中..."), "Receiving screen..."}; static std::vector p2p_failed = { reinterpret_cast(u8"对等连接失败"), "P2P Failed"}; static std::vector p2p_closed = { diff --git a/src/gui/render.h b/src/gui/render.h index d9f2af9..f353f8c 100644 --- a/src/gui/render.h +++ b/src/gui/render.h @@ -261,6 +261,8 @@ class Render { int NetTrafficStats(std::shared_ptr& props); void DrawConnectionStatusText( std::shared_ptr& props); + void DrawReceivingScreenText( + std::shared_ptr& props); #ifdef __APPLE__ int RequestPermissionWindow(); bool CheckScreenRecordingPermission(); diff --git a/src/gui/windows/stream_window.cpp b/src/gui/windows/stream_window.cpp index 99e5d6a..06e13d7 100644 --- a/src/gui/windows/stream_window.cpp +++ b/src/gui/windows/stream_window.cpp @@ -31,6 +31,34 @@ void Render::DrawConnectionStatusText( } } +void Render::DrawReceivingScreenText( + std::shared_ptr& props) { + if (!props->connection_established_ || + props->connection_status_ != ConnectionStatus::Connected) { + return; + } + + bool has_valid_frame = false; + { + std::lock_guard lock(props->video_frame_mutex_); + has_valid_frame = props->stream_texture_ != nullptr && + props->video_width_ > 0 && props->video_height_ > 0 && + props->front_frame_ && !props->front_frame_->empty(); + } + + if (has_valid_frame) { + return; + } + + const std::string& text = + localization::receiving_screen[localization_language_index_]; + ImVec2 size = ImGui::GetWindowSize(); + ImVec2 text_size = ImGui::CalcTextSize(text.c_str()); + ImGui::SetCursorPos( + ImVec2((size.x - text_size.x) * 0.5f, (size.y - text_size.y) * 0.5f)); + ImGui::TextColored(ImVec4(1.0f, 1.0f, 1.0f, 0.92f), "%s", text.c_str()); +} + void Render::CloseTab(decltype(client_properties_)::iterator& it) { // std::unique_lock lock(client_properties_mutex_); if (it != client_properties_.end()) { @@ -144,6 +172,8 @@ int Render::StreamWindow() { // Show file transfer window if needed FileTransferWindow(props); + DrawReceivingScreenText(props); + focused_remote_id_ = props->remote_id_; if (!props->peer_) { @@ -244,6 +274,8 @@ int Render::StreamWindow() { // Show file transfer window if needed FileTransferWindow(props); + DrawReceivingScreenText(props); + ImGui::End(); if (!props->peer_) {