diff --git a/.gitignore b/.gitignore index 32ceb62..7f8620d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,8 @@ !.gitkeep +/mod-Collection/src + # default build directory if not specified by CMAKE configuration /out/* @@ -84,7 +86,8 @@ local.properties .loadpath .project .cproject - +*.cpp +*.h # ================== # diff --git a/Data/Camera.lua b/Data/Camera.lua index 54053e3..ee21610 100644 --- a/Data/Camera.lua +++ b/Data/Camera.lua @@ -308,7 +308,7 @@ SM_CollectionData.Cameras = [Wpn(I.INVTYPE_WEAPONOFFHAND, LE_ITEM_WEAPON_SWORD1H)] = { 1.35, 0.00, -0.83, OHAND }, -- 副手单手剑:Z偏移调整(-0.83)以适应剑的长度 [Wpn(I.INVTYPE_WEAPONOFFHAND, LE_ITEM_WEAPON_FIST)] = { 1.70, 0.00, -0.45, OHAND }, -- 副手拳套:距离更远(1.70),Z偏移较高(-0.45)以展示拳套 - [Wpn(I.INVTYPE_WEAPONOFFHAND)] = { 1.5, 0, 0.00, -1.5, 0 }, -- 副手单手斧 + [Wpn(I.INVTYPE_WEAPONOFFHAND)] = { 1.5, 0.00, -1.30, OHAND }, -- 副手单手斧 -- 盾牌摄像机设置 [Wpn(I.INVTYPE_SHIELD)] = { 2.00, 0.10, -0.30, -0.50, 110 }, -- 盾牌:距离2.0,Y偏移0.10,Z偏移-0.30,自定义角度-0.50,额外角度110度 @@ -536,38 +536,38 @@ SM_CollectionData.Cameras = [Chr(O.Classic, R.Tauren, S.Female, I.INVTYPE_RANGED)] = { 1.25, 0.00, -0.25, 0.00 }, -- 远程武器 -- 侏儒男性 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_HEAD)] = { 2, 0, -1, -0.50 }, -- 头部 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_SHOULDER)] = { 2.5, -0.5, -1, -0.25 }, -- 肩膀 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_CLOAK)] = { 1.00, 0.00, 0.20, BACK }, -- 斗篷 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_CHEST)] = { 1.10, -0.02, 0.05, -0.25 }, -- 胸甲 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_ROBE)] = { 1.00, -0.02, 0.15, -0.25 }, -- 长袍 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_BODY)] = { 1.10, -0.02, 0.05, -0.25 }, -- 衬衣 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_TABARD)] = { 1.25, 0.00, 0.15, -0.25 }, -- 战袍 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_WRIST)] = { 1.50, -0.15, 0.15, -1.10 }, -- 护腕 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_HAND)] = { 1.50, -0.22, 0.17, -0.50 }, -- 手套 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_WAIST)] = { 1.30, 0.00, 0.20, -0.25 }, -- 腰带 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_LEGS)] = { 1.25, 0.00, 0.32, -0.25 }, -- 腿甲 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_FEET)] = { 1.35, -0.02, 0.40, -1.00 }, -- 靴子 - [Chr(O.Classic, R.Gnome, S.Male, I.SetsDetails)] = { 0.00, 0.00, -0.15, 0.00 }, -- 套装详情 - [Chr(O.Classic, R.Gnome, S.Male, I.SetsVendor)] = { 0.50, 0.00, 0.00, 0.00 }, -- 套装商人 - [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_RANGED)] = { 1.25, 0.00, -0.25, 0.00 }, -- 远程武器 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_HEAD)] = { 2, 0, -1, -0.50 }, -- 头部 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_SHOULDER)] = { 2.5, -0.5, -1, -0.25 }, -- 肩膀 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_CLOAK)] = { 1.60, 0.00, 0, BACK }, -- 斗篷 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_CHEST)] = { 2.0, -0.02, -0.3, 0}, -- 胸甲 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_ROBE)] = { 2.0, -0.02, -0.3, 0 }, -- 长袍 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_BODY)] = { 2.0, -0.02, -0.3, 0 }, -- 衬衣 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_TABARD)] = { 2.0, -0.02, -0.3, 0 }, -- 战袍 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_WRIST)] = { 2.3, -0.15, -0.3, -1.30 }, -- 护腕 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_HAND)] = { 2.3, -0.15, -0.3, -1.30 }, -- 手套 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_WAIST)] = { 2.3, 0.00, -0.2, 0 }, -- 腰带 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_LEGS)] = { 2.3, 0.00, 0.15, 0 }, -- 腿甲 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_FEET)] = { 2.3, 0.00, 0.15, 0 }, -- 靴子 + [Chr(O.Classic, R.Gnome, S.Male, I.SetsDetails)] = { 0.00, 0.00, -0.15, 0.00 }, -- 套装详情 + [Chr(O.Classic, R.Gnome, S.Male, I.SetsVendor)] = { 0.50, 0.00, 0.00, 0.00 }, -- 套装商人 + [Chr(O.Classic, R.Gnome, S.Male, I.INVTYPE_RANGED)] = { 1.25, 0.00, -0.25, 0.00 }, -- 远程武器 -- 侏儒女性 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_HEAD)] = { 0.90, -0.03, -0.20, -0.50 }, -- 头部 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_SHOULDER)] = { 1.00, -0.20, -0.05, -0.25 }, -- 肩膀 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_CLOAK)] = { 0.90, 0.00, 0.20, BACK }, -- 斗篷 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_CHEST)] = { 1.10, -0.02, 0.10, -0.25 }, -- 胸甲 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_ROBE)] = { 1.05, -0.02, 0.20, -0.25 }, -- 长袍 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_BODY)] = { 1.10, -0.02, 0.10, -0.25 }, -- 衬衣 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_TABARD)] = { 1.15, -0.02, 0.18, -0.25 }, -- 战袍 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_WRIST)] = { 1.35, -0.17, 0.17, -0.90 }, -- 护腕 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_HAND)] = { 1.35, -0.19, 0.20, -0.50 }, -- 手套 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_WAIST)] = { 1.25, -0.02, 0.20, -0.25 }, -- 腰带 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_LEGS)] = { 1.25, -0.02, 0.32, -0.25 }, -- 腿甲 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_FEET)] = { 1.25, -0.05, 0.40, -1.00 }, -- 靴子 - [Chr(O.Classic, R.Gnome, S.Female, I.SetsDetails)] = { 0.00, 0.00, -0.15, 0.00 }, -- 套装详情 - [Chr(O.Classic, R.Gnome, S.Female, I.SetsVendor)] = { 0.50, 0.00, 0.00, 0.00 }, -- 套装商人 - [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_RANGED)] = { 1.25, 0.00, -0.25, 0.00 }, -- 远程武器 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_HEAD)] = { 2, 0, -1, -0.50 }, -- 头部 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_SHOULDER)] = { 2.5, -0.5, -1, -0.25 }, -- 肩膀 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_CLOAK)] = { 1.60, 0.00, 0, BACK }, -- 斗篷 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_CHEST)] = { 2.0, -0.02, -0.3, 0 }, -- 胸甲 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_ROBE)] = { 2.0, -0.02, -0.3, 0 }, -- 长袍 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_BODY)] = { 2.0, -0.02, -0.3, 0 }, -- 衬衣 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_TABARD)] = { 2.0, -0.02, -0.3, 0 }, -- 战袍 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_WRIST)] = { 2.3, -0.15, -0.3, -1.30 }, -- 护腕 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_HAND)] = { 2.3, -0.15, -0.3, -1.30 }, -- 手套 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_WAIST)] = { 2.3, 0.00, -0.2, 0 }, -- 腰带 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_LEGS)] = { 2.3, 0.00, 0.15, 0 }, -- 腿甲 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_FEET)] = { 2.3, 0.00, 0.15, 0 }, -- 靴子 + [Chr(O.Classic, R.Gnome, S.Female, I.SetsDetails)] = { 0.00, 0.00, -0.15, 0.00 }, -- 套装详情 + [Chr(O.Classic, R.Gnome, S.Female, I.SetsVendor)] = { 0.50, 0.00, 0.00, 0.00 }, -- 套装商人 + [Chr(O.Classic, R.Gnome, S.Female, I.INVTYPE_RANGED)] = { 1.25, 0.00, -0.25, 0.00 }, -- 远程武器 -- 巨魔男性 [Chr(O.Classic, R.Troll, S.Male, I.INVTYPE_HEAD)] = { 2.90, 0.05, -1.00, -0.50 }, -- 头部 diff --git a/SM_UI_SplitPanel.lua b/SM_UI_SplitPanel.lua index c13d104..95a9201 100644 --- a/SM_UI_SplitPanel.lua +++ b/SM_UI_SplitPanel.lua @@ -3,10 +3,9 @@ -- 迁移左右分栏、列表、滚动条、模型、物品网格、CreateSplitPanel、CreateListItems、CreateItemGrid等所有UI细节和逻辑 -- ...(此处插入完整实现,详见原始大文件) --- 在这里添加点击处理逻辑 +-- 点击处理逻辑 function OnItemClick(button, itemData, itemType, panel) - - + print("点击处理逻辑") -- 设置按钮选中状态 if button then -- 取消其他按钮的选中状态 @@ -26,7 +25,6 @@ function OnItemClick(button, itemData, itemType, panel) if button.selectedTexture then button.selectedTexture:Show() end - end -- 更新名称和描述 @@ -58,7 +56,7 @@ function OnItemClick(button, itemData, itemType, panel) -- 更新名称 if SM_Collections.MainFrame.RightSidePanel.MountNama then SM_Collections.MainFrame.RightSidePanel.MountNama:SetText(displayName or "") - + SM_Collections.MainFrame.RightSidePanel.MountNama:Show() end @@ -73,11 +71,12 @@ function OnItemClick(button, itemData, itemType, panel) local creatureDisplayID = nil -- 如果服务端已经提供了displayID,优先使用它 if itemData.displayID and itemData.displayID > 0 then + print("服务端已经提供了displayID= ",itemData.displayID) creatureDisplayID = itemData.displayID - else -- 否则从映射表中获取 creatureDisplayID = SM_Collections:GetCreatureDisplayID(itemData.id, itemType) + print("从映射表中获取") end if panel and panel.model and creatureDisplayID and creatureDisplayID > 0 then @@ -417,9 +416,39 @@ function SM_Collections:CreateListItems(parent, data, itemType, model, nameText, if icon then ButtonIcon:SetNormalTexture(icon) ButtonIcon:SetHighlightTexture(icon) + + -- 为未获得的项目设置灰色图标 + if not item.obtained then + local normalTexture = ButtonIcon:GetNormalTexture() + if normalTexture then + normalTexture:SetDesaturated(true) + normalTexture:SetVertexColor(0.5, 0.5, 0.5) + end + + local highlightTexture = ButtonIcon:GetHighlightTexture() + if highlightTexture then + highlightTexture:SetDesaturated(true) + highlightTexture:SetVertexColor(0.7, 0.7, 0.7) + end + end else ButtonIcon:SetNormalTexture("Interface\\Icons\\INV_Misc_QuestionMark") ButtonIcon:SetHighlightTexture("Interface\\Icons\\INV_Misc_QuestionMark") + + -- 为未获得的项目设置灰色问号图标 + if not item.obtained then + local normalTexture = ButtonIcon:GetNormalTexture() + if normalTexture then + normalTexture:SetDesaturated(true) + normalTexture:SetVertexColor(0.5, 0.5, 0.5) + end + + local highlightTexture = ButtonIcon:GetHighlightTexture() + if highlightTexture then + highlightTexture:SetDesaturated(true) + highlightTexture:SetVertexColor(0.7, 0.7, 0.7) + end + end end ButtonIcon:SetFrameLevel(button:GetFrameLevel() + 1) ButtonIcon:SetScript("OnEnter", function() @@ -914,6 +943,36 @@ function SM_Collections:RefreshCollectionStatus(itemType, itemID, isObtained) end end + -- 更新图标颜色(针对坐骑和小伙伴) + for _, child in ipairs({button:GetChildren()}) do + if child:GetName() and string.find(child:GetName(), "CollectionsButtonIcon") then + local normalTexture = child:GetNormalTexture() + local highlightTexture = child:GetHighlightTexture() + + if normalTexture then + if isObtained then + normalTexture:SetDesaturated(false) + normalTexture:SetVertexColor(1, 1, 1) + else + normalTexture:SetDesaturated(true) + normalTexture:SetVertexColor(0.5, 0.5, 0.5) + end + end + + if highlightTexture then + if isObtained then + highlightTexture:SetDesaturated(false) + highlightTexture:SetVertexColor(1, 1, 1) + else + highlightTexture:SetDesaturated(true) + highlightTexture:SetVertexColor(0.7, 0.7, 0.7) + end + end + + break + end + end + -- 如果是新获得的项目,添加"NEW"标记 if isObtained and self.NewItems and self.NewItems[itemType] and self.NewItems[itemType][itemID] then -- 检查是否已经有NEW标记 diff --git a/mod-Collection/src/CollectionMgr.cpp b/mod-Collection/src/CollectionMgr.cpp index 8df8eb4..fe2c3af 100644 --- a/mod-Collection/src/CollectionMgr.cpp +++ b/mod-Collection/src/CollectionMgr.cpp @@ -297,6 +297,7 @@ bool CollectionMgr::AddToCollection(Player* player, CollectionCategory category, itemType = "unknown"; } + // 这里应该不用更新 OnPlayerCreatureKill 这里更新 std::ostringstream message; message << itemType << "|" << itemId << "|1"; SendAddonMessageToPlayer(player, "SM_S_COLLECTION_UPDATE", message.str(), CHAT_MSG_WHISPER); @@ -761,25 +762,24 @@ void CollectionMgr::SendCardsData(Player* player) // 确保每组数据之间有分隔符 if (count > 0) data << "|"; - + // 格式: ID|名称|描述|获得状态(1/0) data << cardId << "|"; data << cardName << "|"; data << description << "|"; data << (hasCollected ? "1" : "0"); - + + count++; - + // 每10个物品发送一次,避免消息过长 - if (count % 10 == 0) + if (count % 20 == 0) { SendAddonMessageToPlayer(player, "SM_S_COLLECTIONS_CARDS", data.str(), CHAT_MSG_WHISPER); data.str(""); data.clear(); } } - - // 发送剩余数据 if (!data.str().empty()) { SendAddonMessageToPlayer(player, "SM_S_COLLECTIONS_CARDS", data.str(), CHAT_MSG_WHISPER); @@ -816,6 +816,9 @@ void CollectionMgr::SendItemsData(Player* player) if (count % 10 == 0) { SendAddonMessageToPlayer(player, "SM_S_COLLECTIONS_ITEMS", data.str(), CHAT_MSG_WHISPER); + + sLog->outMessage("server", LogLevel::LOG_LEVEL_INFO, "SM_S_COLLECTIONS_ITEMS1:{} ", data.str()); + data.str(""); data.clear(); } @@ -823,6 +826,8 @@ void CollectionMgr::SendItemsData(Player* player) if (!data.str().empty()) { SendAddonMessageToPlayer(player, "SM_S_COLLECTIONS_ITEMS", data.str(), CHAT_MSG_WHISPER); + + sLog->outMessage("server", LogLevel::LOG_LEVEL_INFO, "SM_S_COLLECTIONS_ITEMS2:{} ", data.str()); } } diff --git a/mod-Collection/src/CollectionScript.cpp b/mod-Collection/src/CollectionScript.cpp index b27c0a9..41b8280 100644 --- a/mod-Collection/src/CollectionScript.cpp +++ b/mod-Collection/src/CollectionScript.cpp @@ -6,7 +6,6 @@ #include "Chat.h" #include "ChatCommand.h" #include "Log.h" -#include class CollectionSystem_PlayerScript : public PlayerScript { @@ -53,15 +52,17 @@ public: // 检查是否是坐骑技能 if (sCollectionMgr->IsMountSpell(spellId)) { - // 添加到收藏并通知客户端 + // 发送单个收藏更新通知给客户端 sCollectionMgr->AddToCollection(player, COLLECTION_MOUNT, spellId); + // 发送所有坐骑的完整列表给客户端 sCollectionMgr->SendMountsData(player); } // 检查是否是小伙伴技能 else if (sCollectionMgr->IsCompanionSpell(spellId)) { - // 添加到收藏并通知客户端 + // 发送单个收藏更新通知给客户端 sCollectionMgr->AddToCollection(player, COLLECTION_PET, spellId); + // 发送所有宠物的完整列表给客户端 sCollectionMgr->SendCompanionsData(player); } } @@ -79,25 +80,25 @@ public: { // 检查是否已经收藏 bool alreadyCollected = sCollectionMgr->HasInCollection(killer, COLLECTION_CARD, creatureId); - + // 添加到收藏 bool added = sCollectionMgr->AddToCollection(killer, COLLECTION_CARD, creatureId); - + // 如果成功添加(新收藏) if (added && !alreadyCollected) { // 获取生物名称 std::string creatureName = killed->GetName(); - + // 发送实时更新通知 std::ostringstream updateMsg; updateMsg << "card|" << creatureId << "|1"; sCollectionMgr->SendAddonMessageToPlayer(killer, "SM_S_COLLECTION_UPDATE", updateMsg.str(), CHAT_MSG_WHISPER); - + // 通知玩家 std::string message = "您已收集到新卡牌: " + creatureName; - killer->GetSession()->SendNotification("%s", message.c_str()); - + ChatHandler(killer->GetSession()).SendNotification("竞技场比赛开始!战斗吧!" ,message.c_str()); + // 重新发送完整卡牌数据 sCollectionMgr->SendCardsData(killer); }