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");
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_;
// 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());
}
}
}
}
//更新角色配置信息
- 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);
}