From 3a3ec457c3fb76df6783b071c4784b8d461ce32d Mon Sep 17 00:00:00 2001 From: xue <2144439972@qq.com> Date: Mon, 1 Dec 2025 15:34:32 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E8=A1=A8=E6=83=85=E5=88=87?= =?utf8?q?=E6=8D=A2=E4=B8=8D=E6=88=90=E5=8A=9F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../thunderbird/src/ThunderBirdModel.cpp | 71 +++++++++++++------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp index 40db336cc..95a16b17a 100644 --- a/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp +++ b/code/sdk/application/wearable/ln/nativeapp/nativeui/thunderbird/src/ThunderBirdModel.cpp @@ -2390,12 +2390,6 @@ extern "C" { const char* eyesColor, const char* hairStyle, int screenImageAsEmoji) { - //修复后 - std::string hairColorStr = hairColor; - if (hairColorStr == "warm-orange") - { - hairColor = "orange"; - } WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange"); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " characterId: %s", characterId ? characterId : "null"); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " characterName: %s", characterName ? characterName : "null"); @@ -2404,27 +2398,49 @@ extern "C" { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " eyesColor: %s", eyesColor ? eyesColor : "null"); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " hairStyle: %s", hairStyle ? hairStyle : "null"); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " screenImageAsEmoji: %d", screenImageAsEmoji); - if(eyesShape == last_eyesShape_ && hairColor == last_hairColor_ && eyesColor == last_eyesColor_ && hairStyle == last_hairStyle_ && screenImageAsEmoji == last_screenImageAsEmoji_) + + // 将传入的参数转换为std::string(处理nullptr和字符串比较) + std::string newEyesShape = eyesShape ? eyesShape : ""; + std::string newEyesColor = eyesColor ? eyesColor : ""; + std::string newHairStyle = hairStyle ? hairStyle : ""; + std::string newHairColor = hairColor ? hairColor : ""; + + // 处理warm-orange到orange的映射 + if (newHairColor == "warm-orange") + { + newHairColor = "orange"; + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " hairColor mapped from warm-orange to orange"); + } + + // 比较传入的新值和上次保存的值(last_xxx_) + if(newEyesShape == last_eyesShape_ && newHairColor == last_hairColor_ && + newEyesColor == last_eyesColor_ && newHairStyle == last_hairStyle_ && + screenImageAsEmoji == last_screenImageAsEmoji_) { WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange: 角色配置没有变化,不进行处理"); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 上次配置: eyesShape=%s, hairColor=%s, eyesColor=%s, hairStyle=%s, screenImageAsEmoji=%d", + last_eyesShape_.c_str(), last_hairColor_.c_str(), last_eyesColor_.c_str(), + last_hairStyle_.c_str(), last_screenImageAsEmoji_); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " 新配置: eyesShape=%s, hairColor=%s, eyesColor=%s, hairStyle=%s, screenImageAsEmoji=%d", + newEyesShape.c_str(), newHairColor.c_str(), newEyesColor.c_str(), + newHairStyle.c_str(), screenImageAsEmoji); return; } - if(eyesShape == "calm-eyes" && eyesColor == "amber" && hairColor == "warm-orange" && hairStyle == "curly-hair" && screenImageAsEmoji == false) + + // 检查是否是默认/空配置(calm-eyes, amber, warm-orange, curly-hair) + if(newEyesShape == "calm-eyes" && newEyesColor == "amber" && + newHairColor == "orange" && newHairStyle == "curly-hair" && screenImageAsEmoji == false && + last_eyesShape_.empty() && last_hairColor_.empty() && last_eyesColor_.empty() && last_hairStyle_.empty() && last_screenImageAsEmoji_ == false) { + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange: 角色配置为默认配置,不进行处理"); + // 更新last_xxx_为当前值,避免下次误判 last_eyesShape_ = eyesShape_; last_hairColor_ = hairColor_; last_eyesColor_ = eyesColor_; last_hairStyle_ = hairStyle_; last_screenImageAsEmoji_ = screenImageAsEmoji_; - WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange: 角色配置为空,不进行处理"); return; } - //更新上次角色配置信息 - last_eyesShape_ = eyesShape_; - last_hairColor_ = hairColor_; - last_eyesColor_ = eyesColor_; - last_hairStyle_ = hairStyle_; - last_screenImageAsEmoji_ = screenImageAsEmoji_; @@ -2436,19 +2452,19 @@ extern "C" { // 4. 如果screenImageAsEmoji为true,可能需要更新表情显示 // 示例:调用表情切换功能 - if (eyesShape && eyesColor) { + if (!newEyesShape.empty() && !newEyesColor.empty()) { if(ThunderBirdMainView::GetInstance()) { - SwitchExpression(eyesShape, eyesColor); + SwitchExpression(newEyesShape.c_str(), newEyesColor.c_str()); } } // 切换发型功能 - if (hairStyle && hairColor) { + if (!newHairStyle.empty() && !newHairColor.empty()) { if(ThunderBirdMainView::GetInstance()) { - SwitchHair(hairStyle, hairColor); + SwitchHair(newHairStyle.c_str(), newHairColor.c_str()); } } @@ -2470,11 +2486,20 @@ extern "C" { } } //更新角色配置信息 - eyesShape_ = eyesShape; - hairColor_ = hairColor; - eyesColor_ = eyesColor; - hairStyle_ = hairStyle; + eyesShape_ = newEyesShape; + hairColor_ = newHairColor; + eyesColor_ = newEyesColor; + hairStyle_ = newHairStyle; screenImageAsEmoji_ = screenImageAsEmoji; + + //更新上次角色配置信息(在处理完成后更新,用于下次比较) + last_eyesShape_ = newEyesShape; + last_hairColor_ = newHairColor; + last_eyesColor_ = newEyesColor; + last_hairStyle_ = newHairStyle; + last_screenImageAsEmoji_ = screenImageAsEmoji; + + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "ThunderBirdModel::HandleCharacterConfigChange: 角色配置已更新"); // SaveCharacterConfig(characterId, characterName, eyesShape, hairColor, eyesColor, hairStyle, screenImageAsEmoji); } -- 2.17.1