优化对话模式的表情逻辑
authorxue <2144439972@qq.com>
Thu, 4 Dec 2025 09:23:57 +0000 (17:23 +0800)
committerxue <2144439972@qq.com>
Thu, 4 Dec 2025 09:23:57 +0000 (17:23 +0800)
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp
code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdPresenter.cpp

index 3c006fd..a9f90a1 100644 (file)
@@ -3163,9 +3163,9 @@ extern "C" {
             SetCurrentExpression(emotion);
             SetCurrentExpressionAndStatus(); //更新当前表情和状态文本
             
-            // 标记时间线已获取,允许休眠
-            ThunderBirdMainView::SetTimelineReceived(true);
-            WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleTimelineStatusChange: 时间线已获取,允许休眠");
+            // // 标记时间线已获取,允许休眠
+            // ThunderBirdMainView::SetTimelineReceived(true);
+            // WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleTimelineStatusChange: 时间线已获取,允许休眠");
         }
     }
     
@@ -3174,9 +3174,25 @@ extern "C" {
     {
         // 重置对话模式finished标志
         m_dialogueModeFinished = false;
-        // 记录进入对话模式前的表情,不改变当前表情
+        //如果本来就是眨眼的表情直接返回
+        if (m_currentExpression == "winking") {
+            return;
+        }
+        // 记录进入对话模式前的时间线表情(用于退出时恢复)
         m_dialogueExpression = m_currentExpression;
-        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnEnterDialogueMode: 记录进入对话模式前的表情: %s", m_currentExpression.c_str());
+        WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnEnterDialogueMode: 记录时间线表情: %s", m_currentExpression.c_str());
+        
+        // 切换到眨眼表情(winking)
+        std::string winkingExpressionPath = "/user/res/video/CloseEyes/" + eyesShape_ + "/" + eyesColor_ + ".mp4";
+        
+        // 检查文件是否存在
+        if (access(winkingExpressionPath.c_str(), F_OK) == 0) {
+            // 切换到眨眼表情(但不更新m_currentExpression,因为退出时要恢复时间线表情)
+            SwitchExpressionVideo(winkingExpressionPath.c_str());
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnEnterDialogueMode: 切换到眨眼表情: %s", winkingExpressionPath.c_str());
+        } else {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnEnterDialogueMode: 眨眼表情文件不存在: %s", winkingExpressionPath.c_str());
+        }
     }
     
     // 退出对话模式时恢复表情
@@ -3184,10 +3200,51 @@ extern "C" {
     {
         // 重置对话模式finished标志
         m_dialogueModeFinished = false;
-        // 恢复到进入对话模式前记录的表情
+        
+        // 恢复到进入对话模式前记录的时间线表情
         if (!m_currentExpression.empty()) {
-            SetCurrentExpression(m_currentExpression);
-            //SetCurrentExpressionAndStatus();
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnExitDialogueMode: 恢复时间线表情: %s", m_dialogueExpression.c_str());
+            //如果相同直接返回
+            if(m_dialogueExpression == m_currentExpression)     
+            {
+                return;
+            }
+            m_dialogueExpression = m_currentExpression;
+            // 恢复表情状态
+            // 构建表情文件路径并切换表情
+            std::string expressionPath;
+            if (screenImageAsEmoji_ == false) {
+                // 不为屏保模式,根据角色配置构建表情路径
+                if (eyesColor_.empty() || eyesShape_.empty() || 
+                    (eyesShape_ == "calm-eyes" && eyesColor_ == "amber")) {
+                    // 默认表情
+                    std::string emotionFileName = MapEmotionToFileName(m_dialogueExpression.c_str());
+                    expressionPath = "/user/res/video/Default/" + emotionFileName + ".mp4";
+                } else {
+                    // 非默认表情
+                    if (m_dialogueExpression == "winking") {
+                        // 眨眼表情
+                        expressionPath = "/user/res/video/CloseEyes/" + eyesShape_ + "/" + eyesColor_ + ".mp4";
+                    } else if (m_dialogueExpression == "sleeping") {
+                        // 睡眠表情
+                        expressionPath = "/user/res/video/Default/sleeping.mp4";
+                    } else {
+                        // 其他表情
+                        expressionPath = "/user/userdata/leiniao/emoji/" + eyesShape_ + "/" + eyesColor_ + "/" + m_dialogueExpression + ".mp4";
+                    }
+                }
+                
+                // 检查文件是否存在并切换表情
+                if (access(expressionPath.c_str(), F_OK) == 0) {
+                    SwitchExpressionVideo(expressionPath.c_str());
+                    HandleHairIconChange(m_dialogueExpression);
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnExitDialogueMode: 恢复表情成功: %s", expressionPath.c_str());
+                } else {
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnExitDialogueMode: 表情文件不存在: %s", expressionPath.c_str());
+                }
+            }
+        } else {
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::OnExitDialogueMode: 没有记录的表情,无法恢复");
         }
     }
     
index eacebdd..db62234 100644 (file)
@@ -692,7 +692,7 @@ namespace OHOS
                     ThunderBirdMainView::GetInstance()->ChangeView(THUNDERBIRD_GUIDEVIEW, THUNDERBIRD_DIALOGUEVIEW, ThunderBirdDialogueView::THUNDERBIRD_DIALOGUEVIEW_LISTENING);
                     isDialogueing = true;
                     // 进入对话模式时记录当前表情
-                    //ThunderBirdModel::GetInstance()->OnEnterDialogueMode();
+                    ThunderBirdModel::GetInstance()->OnEnterDialogueMode();
                     // 开始对话
                     do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_AUDIO_INIT, NULL, 0);
                     // ln_ws_start_audio_chat(LN_AUDIO_CHAT_VOICE_CHAT_REQUEST);