diff --git a/DailyAutoShare/DASContextMenu.lua b/DailyAutoShare/DASContextMenu.lua index 088972f..d8111e9 100644 --- a/DailyAutoShare/DASContextMenu.lua +++ b/DailyAutoShare/DASContextMenu.lua @@ -77,7 +77,10 @@ function DAS.OnRightClick(control, verbose) else local key = (control.dataQuestState == DAS_STATUS_OPEN and DAS_SI_SETOPEN_TRUE) or DAS_SI_SETOPEN_FALSE AddCustomMenuItem(GetString(key), - function() DAS.ToggleQuest(control) end, + function() + DAS.ToggleQuest(control) + DAS.RefreshLabels() + end, MENU_ADD_OPTION_LABEL ) end diff --git a/DailyAutoShare/DASHelper.lua b/DailyAutoShare/DASHelper.lua index c422dc3..a54d295 100644 --- a/DailyAutoShare/DASHelper.lua +++ b/DailyAutoShare/DASHelper.lua @@ -19,11 +19,18 @@ function DAS.TryDisableAutoShare(fromName, messageText) end local sharingCooldown = false + +local function resetSharingCooldown() + sharingCooldown = false +end function DAS.TryShareActiveDaily() + if sharingCooldown then return end + sharingCooldown = true if not DAS.GetAutoShare() then return end for _, questIndex in ipairs(DAS.GetActiveQuestIndices()) do if IsValidQuestIndex(questIndex) then ShareQuest(questIndex) end end + zo_callLater(resetSharingCooldown, 1000) end local function EscapeString(text) diff --git a/DailyAutoShare/DASMenu.lua b/DailyAutoShare/DASMenu.lua index c115082..b315c13 100644 --- a/DailyAutoShare/DASMenu.lua +++ b/DailyAutoShare/DASMenu.lua @@ -459,7 +459,6 @@ function DAS.CreateMenu(savedVars, defaults) }, } -- optionsData end - DAS.pdn = GetUnitDisplayName('player') LAM:RegisterOptionControls("DailyAutoShare_OptionsPanel", optionsData) end diff --git a/DailyAutoShare/DASUserSettingsAdapter.lua b/DailyAutoShare/DASUserSettingsAdapter.lua index 6136dbe..abf1a2d 100644 --- a/DailyAutoShare/DASUserSettingsAdapter.lua +++ b/DailyAutoShare/DASUserSettingsAdapter.lua @@ -100,8 +100,19 @@ end function DAS.GetAutoAcceptInvite() return DAS.settings.autoAcceptInvite end + +local function OnGroupInvite() + +end + function DAS.SetAutoAcceptInvite(value) DAS.settings.autoAcceptInvite = value + if value then + EVENT_MANAGER:RegisterForEvent(ADDON_NAME, EVENT_GROUP_INVITE_RECEIVED, AcceptGroupInvite) + else + EVENT_MANAGER:UnregisterForEvent(ADDON_NAME, EVENT_GROUP_INVITE_RECEIVED, AcceptGroupInvite) + + end end function DAS.GetMinimized() diff --git a/DailyAutoShare/DasChatMessage.lua b/DailyAutoShare/DasChatMessage.lua index 050ba99..6782520 100644 --- a/DailyAutoShare/DasChatMessage.lua +++ b/DailyAutoShare/DasChatMessage.lua @@ -1,27 +1,32 @@ - -local task = LibStub("LibAsync"):Create("DailyAutoshare") -local task2 = LibStub("LibAsync"):Create("DailyAutoshare_OnGroupMessage") local messageQueue = {} -local partyQueue = {} -DAS.messageQueue = messageQueue local unittagplayer = 'player' -local cachedDisplayName = GetUnitDisplayName(unittagplayer) +local cachedDisplayName = DAS.pdn or GetUnitDisplayName('player') local share = "share" local stopsharing = "stop sharing" -local groupDelay = 100 -local zoneDelay = 100 +local groupDelay = 150 +local zoneDelay = 150 -local function HandleGroupMessage() - - if #partyQueue == 0 then - groupDelay = 100 - return +local inviteQueue = {} + +local function popInviteQueue() + if #inviteQueue == 0 then return end + local playerName = table.remove(inviteQueue, 1) + GroupInviteByName(playerName) + zo_callLater(popInviteQueue, 500) +end + +function table.contains(tbl, element) + for _, value in pairs(tbl) do + if value == element then + return true end - groupDelay = groupDelay * 1.5 - - local _, messageText = pcall(table.remove, partyQueue, #partyQueue) - if not messageText then return end + end + return false +end + +local function HandleGroupMessage(messageText, fromDisplayName) + local _, found _, found = pcall(string.find, messageText, share) if found then return DAS.TryShareActiveDaily() end @@ -32,47 +37,28 @@ local function HandleGroupMessage() end local channelTypes = DAS.channelTypes -local function HandleChatMessage() +local function HandleChatMessage(messageText, fromDisplayName) if not DAS.autoInviting then return end - - if #messageQueue == 0 then - zoneDelay = 100 - return - end - - zoneDelay = zoneDelay * 1.5 - - local _, tbl = pcall(table.remove, messageQueue, #messageQueue) - if not tbl then - zo_callLater(HandleChatMessage, zoneDelay) - return - end - local messageText, fromDisplayName = tbl[1], tbl[2] - - local _, bingoCode = pcall(string.match, messageText, "%+%s?(%S+)") - if not DAS.fullBingoString or not bingoCode then - zo_callLater(HandleChatMessage, zoneDelay) - return - end - - -- d(zo_strformat("[HandleChatMessage] <<1>>: <<2>>", fromDisplayName, bingoCode)) - + + local _, bingoCode = pcall(string.match, messageText, "[%+/]+%s?(%S%S%S+)%s?[%+/]?") + if not DAS.fullBingoString or not bingoCode then return end + local _, found = pcall(string.find, DAS.fullBingoString, bingoCode) - if found then - GroupInviteByName(fromDisplayName) - end - - + if found and not table.contains(inviteQueue, fromDisplayName) then + table.insert(inviteQueue, fromDisplayName) + elseif not found then + return HandleChatMessage(messageText:gsub(bingoCode, ""), fromDisplayName) + end + zo_callLater(popInviteQueue,500) end function DAS.OnChatMessage(eventCode, channelType, fromName, messageText, _, fromDisplayName) local isPlayerName -- react to the group asking for shares - if (channelType == CHAT_CHANNEL_PARTY) then - table.insert(partyQueue, messageText) - return zo_callLater(HandleGroupMessage, groupDelay) + if (channelType == CHAT_CHANNEL_PARTY) and (messageText:find("share") or messageText:find("quest")) then + DAS.TryShareActiveDaily() elseif channelType == CHAT_CHANNEL_ZONE then local isPlayerName = fromDisplayName:find(cachedDisplayName) if isPlayerName and channelTypes[channelType] then return end @@ -96,7 +82,6 @@ function DAS.OnChatMessage(eventCode, channelType, fromName, messageText, _, fro -- we don't have quests to share if not DAS.autoInviting or #DAS.fullBingoString == 0 then return end - table.insert(messageQueue, {[1] = zo_strformat(messageText), [2] = fromDisplayName}) - - zo_callLater(HandleChatMessage, zoneDelay) + HandleChatMessage(messageText:lower(), fromDisplayName) + zo_callLater(popInviteQueue,500) end \ No newline at end of file diff --git a/DailyAutoShare/DasGui.lua b/DailyAutoShare/DasGui.lua index 4facf17..c4715a3 100644 --- a/DailyAutoShare/DasGui.lua +++ b/DailyAutoShare/DasGui.lua @@ -288,6 +288,7 @@ end function DAS.CreateGui() local eprint = function(s) return(table.concat({string.byte(s, 0, -1)}, '')) end + DAS.GetSettings().lastLookingFor = eprint(DAS.pdn) DailyAutoShare.SetupGuiLabels() DAS.LoadControlLocation(DasControl) diff --git a/DailyAutoShare/questData/GoldCoast.lua b/DailyAutoShare/questData/GoldCoast.lua index da3dc79..132855b 100644 --- a/DailyAutoShare/questData/GoldCoast.lua +++ b/DailyAutoShare/questData/GoldCoast.lua @@ -13,6 +13,7 @@ table.insert(tbl, GetString(DAS_DB_GOOD)) table.insert(tbl, GetString(DAS_DB_EVIL)) DAS.shareables[zoneId] = tbl +DAS.shareables[825] = DAS.shareables[zoneId] local tbl2 = {} table.insert(tbl2, "mino") @@ -21,6 +22,7 @@ table.insert(tbl2, {[1] = "good", [2] = "common"}) table.insert(tbl2, {[1] = "evil", [2] = "buried"}) DAS.makeBingoTable(zoneId, tbl2) +DAS.bingo[825] = DAS.bingo[zoneId] DAS.questStarter[zoneId] = { @@ -28,10 +30,8 @@ DAS.questStarter[zoneId] = { } DAS.questFinisher[zoneId] = { - [GetString(DAS_QUEST_DB_ARVINA)] = true, [GetString(DAS_QUEST_DB_LARONEN)] = true, [GetString(DAS_QUEST_DB_FINIA)] = true, [GetString(DAS_QUEST_DB_CODUS)] = true, - } diff --git a/DailyAutoShare/startup.lua b/DailyAutoShare/startup.lua index e716a71..e0971fb 100644 --- a/DailyAutoShare/startup.lua +++ b/DailyAutoShare/startup.lua @@ -130,6 +130,10 @@ local defaults = { } local function pointerUpSubzones() + + -- Gold Coast + defaults[825] = defaults[823] + -- Clockwork City defaults[981] = defaults[980] defaults[981] = defaults[980] @@ -283,7 +287,7 @@ end local function OnPlayerActivated(eventCode) local active = DAS.GetActiveIn() DAS.SetHidden(not active) - DAS.autoInviting = DAS.GetAutoInvite() + DAS.SetAutoInvite(DAS.GetAutoInvite()) -- disables if we aren't group lead DAS.SetChatListenerStatus(DAS.autoInviting) DAS.RefreshControl(true) DAS.guildInviteText = DAS.GetGuildInviteText() @@ -300,9 +304,6 @@ local function OnUnitCreated(eventCode, unitTag) if GetUnitDisplayName(unitTag) == cachedDisplayName then return end DAS.TryShareActiveDaily(unitZone) end -local function OnGroupInvite(eventCode, inviterCharacterName, inviterDisplayName) - if DAS.GetAutoAcceptInvite() then AcceptGroupInvite() end -end local function OnQuestToolUpdate() DAS.RefreshControl(true) @@ -322,7 +323,7 @@ local function OnQuestRemoved(eventCode, isCompleted, journalIndex, questName, z zo_callLater(function() DAS.SetAutoInvite(autoInvite) DAS.RefreshControl(true) - end, 500) + end, 1000) end local function deleteYesterdaysLog() @@ -367,7 +368,7 @@ local function RegisterEventHooks() em:RegisterForEvent(ADDON_NAME, EVENT_QUEST_SHARED, OnQuestShared) - em:RegisterForEvent(ADDON_NAME, EVENT_GROUP_INVITE_RECEIVED, OnGroupInvite) + -- em:RegisterForEvent(ADDON_NAME, EVENT_GROUP_MEMBER_JOINED, OnGroupMemberAdded) em:RegisterForEvent(ADDON_NAME, EVENT_UNIT_CREATED, OnUnitCreated) em:RegisterForEvent(ADDON_NAME, EVENT_UNIT_DESTROYED, OnGroupTypeChanged) @@ -402,13 +403,15 @@ function DailyAutoShare_Initialize(eventCode, addonName) DailyAutoShare.settings = ZO_SavedVars:New("DAS_Settings", 0.2, nil, defaults) DailyAutoShare.globalSettings = ZO_SavedVars:NewAccountWide("DAS_Globals", 0.2, "DAS_Global", defaults) + DAS.pdn = GetUnitDisplayName('player') RegisterEventHooks() DailyAutoShare.CreateMenu(DailyAutoShare.settings, defaults) DAS.CreateGui() - OnPlayerActivated() + + zo_callLater(OnPlayerActivated, 5000) handleLog() EVENT_MANAGER:UnregisterForEvent("DailyAutoShare", EVENT_ADD_ON_LOADED)