Skip to content

Commit

Permalink
Players will now receive a whisper when you were unable to open a tra…
Browse files Browse the repository at this point in the history
…de with them
  • Loading branch information
Gargul committed Jun 25, 2024
1 parent 769aa8b commit f367855
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
22 changes: 20 additions & 2 deletions Classes/AwardedLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,11 @@ end
function AwardedLoot:initiateTrade(AwardDetails)
local tradingPartner = AwardDetails.awardedTo;

-- No need to trade with yourself
if (GL:iEquals(tradingPartner, GL.User.fqn)) then
return;
end

-- Check whether we have the item in our inventory, no point opening a trade window if not
local itemPositionInBag = GL:findBagIdAndSlotForItem(AwardDetails.itemLink or AwardDetails.itemID);
if (GL:empty(itemPositionInBag)) then
Expand All @@ -843,9 +848,22 @@ function AwardedLoot:initiateTrade(AwardDetails)

if (not TradeFrame:IsShown()) then
-- Open a trade window with the winner
GL.TradeWindow:open(tradingPartner, function ()
GL.TradeWindow:open(tradingPartner, function (success)
if (not success) then
if (Settings:get("AwardingLoot.notifyOfFailedTradeStart")) then
GL:sendChatMessage(
GL:printfn(L.CHAT.TRADE_START_FAILED, {
item = AwardDetails.itemLink or "?",
}),
"WHISPER", nil, tradingPartner
);
end

return;
end

self:tradeInitiated();
end);
end, true);

-- We're already trading with the winner
elseif (GL:tableGet(GL.TradeWindow, "State.partner") == tradingPartner) then
Expand Down
8 changes: 4 additions & 4 deletions Classes/TradeWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function TradeWindow:open(playerName, callback, allwaysExecuteCallback)
if (type(callback) == "function"
and (allwaysExecuteCallback or self.Sate.partner == playerName)
) then
callback();
callback(GL:iEquals(self.Sate.partner, playerName));
end

return;
Expand All @@ -85,7 +85,7 @@ function TradeWindow:open(playerName, callback, allwaysExecuteCallback)
GL.Events:unregister("TradeWindowTradeShowCallbackListener");

if (allwaysExecuteCallback) then
callback();
callback(false);
end
end, 1);

Expand All @@ -100,10 +100,10 @@ function TradeWindow:open(playerName, callback, allwaysExecuteCallback)
if (allwaysExecuteCallback
or (
TradeFrame:IsShown()
and self.Sate.partner == playerName
and GL:iEquals(self.Sate.partner, playerName)
)
) then
callback();
callback(true);
end
end);
end
Expand Down
1 change: 1 addition & 0 deletions Data/DefaultSettings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ GL.Data.DefaultSettings = {
awardMessagesEnabled = true,
awardOnReceive = false,
awardOnReceiveMinimumQuality = 4,
notifyOfFailedTradeStart = true,
skipAwardConfirmationDialog = false,
},
ExportingLoot = {
Expand Down
10 changes: 10 additions & 0 deletions Data/Localizations/chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "These players have the highest %s prio: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s to %s",
TRADE_TO_PART = "to %s",
TRADE_GAVE = "I gave %s",
Expand Down Expand Up @@ -204,6 +205,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "Die folgenden Spieler haben die höchste %s-Prio: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s an %s",
TRADE_TO_PART = "an %s",
TRADE_GAVE = "Ich habe %s gegeben",
Expand Down Expand Up @@ -319,6 +321,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "以下玩家的 %s 优先级最高:%s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s 给 %s",
TRADE_TO_PART = "给 %s",
TRADE_GAVE = "我给了%s",
Expand Down Expand Up @@ -434,6 +437,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "Los siguientes jugadores tienen el %s prio más alto: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s a %s",
TRADE_TO_PART = "a %s",
TRADE_GAVE = "Le di %s",
Expand Down Expand Up @@ -549,6 +553,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "Les joueurs suivants ont la plus haute prio %s : %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s à %s",
TRADE_TO_PART = "à %s",
TRADE_GAVE = "J'ai donné %s",
Expand Down Expand Up @@ -664,6 +669,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "I seguenti giocatori hanno il vantaggio di %s più alto: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "Da %s a %s",
TRADE_TO_PART = "a %s",
TRADE_GAVE = "Ho dato %s",
Expand Down Expand Up @@ -779,6 +785,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "다음 플레이어의 %s 우선 순위가 가장 높습니다: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s ~ %s",
TRADE_TO_PART = "%s에게",
TRADE_GAVE = "%s을(를) 줬습니다",
Expand Down Expand Up @@ -894,6 +901,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "Os seguintes jogadores têm o maior %s prio: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s para %s",
TRADE_TO_PART = "para% s",
TRADE_GAVE = "Eu dei %s",
Expand Down Expand Up @@ -1009,6 +1017,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "Следующие игроки имеют самый высокий процент %s: %s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "от %s до %s",
TRADE_TO_PART = "до %s",
TRADE_GAVE = "я дал %s",
Expand Down Expand Up @@ -1124,6 +1133,7 @@ L.CHAT = {
ROLLING_TMB_INFO = "以下玩家的 %s 優先順序最高:%s", -- First %s can be TMB/DFT/CPR

--[[ TradeWindow / Trade ]]
TRADE_START_FAILED = "I tried to trade you, but was unsuccessful - trade me for ${item} asap!",
TRADE_TO = "%s 至 %s",
TRADE_TO_PART = "至 %s",
TRADE_GAVE = "我給了%s",
Expand Down
5 changes: 5 additions & 0 deletions Interface/Settings/AwardingLoot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function AwardingLoot:draw(Parent)
description = "If you award an item from your inventory then automatically trade the winner if he's within reach",
setting = "AwardingLoot.autoTradeAfterAwardingAnItem",
},
{
label = "Notify in case trade fails",
description = "Send a whisper to the winner if you couldn't open a trade window with them",
setting = "AwardingLoot.notifyOfFailedTradeStart",
},
{
label = "Skip award confirmation dialog",
setting = "AwardingLoot.skipAwardConfirmationDialog",
Expand Down

0 comments on commit f367855

Please sign in to comment.