Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Your life becomes more and more of an adventure!
  • Loading branch information
opussf committed Aug 13, 2024
2 parents 76d56a7 + db205f3 commit d907017
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
INTERFACE=110000
INTERFACE=110002
ADDONLOC=/Applications/World of Warcraft/_retail_/Interface/Addons
53 changes: 27 additions & 26 deletions src/INEED.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
INEED_SLUG, INEED = ...
INEED_MSG_ADDONNAME = GetAddOnMetadata( INEED_SLUG, "Title" )
INEED_MSG_VERSION = GetAddOnMetadata( INEED_SLUG, "Version" )
INEED_MSG_AUTHOR = GetAddOnMetadata( INEED_SLUG, "Author" )
INEED_SLUG, INEED = ...
INEED_MSG_ADDONNAME = C_AddOns.GetAddOnMetadata( INEED_SLUG, "Title" )
INEED_MSG_VERSION = C_AddOns.GetAddOnMetadata( INEED_SLUG, "Version" )
INEED_MSG_AUTHOR = C_AddOns.GetAddOnMetadata( INEED_SLUG, "Author" )

-- Colours
COLOR_RED = "|cffff0000";
COLOR_GREEN = "|cff00ff00";
COLOR_BLUE = "|cff0000ff";
COLOR_PURPLE = "|cff700090";
COLOR_YELLOW = "|cffffff00";
COLOR_ORANGE = "|cffff6d00";
COLOR_GREY = "|cff808080";
COLOR_GOLD = "|cffcfb52b";
COLOR_NEON_BLUE = "|cff4d4dff";
COLOR_END = "|r";
COLOR_RED = "|cffff0000"
COLOR_GREEN = "|cff00ff00"
COLOR_BLUE = "|cff0000ff"
COLOR_PURPLE = "|cff700090"
COLOR_YELLOW = "|cffffff00"
COLOR_ORANGE = "|cffff6d00"
COLOR_GREY = "|cff808080"
COLOR_GOLD = "|cffcfb52b"
COLOR_NEON_BLUE = "|cff4d4dff"
COLOR_END = "|r"

INEED_data = {}
INEED_currency = {}
Expand Down Expand Up @@ -238,7 +238,6 @@ end
function INEED.PLAYER_ENTERING_WORLD() -- Variables should be loaded here
--INEED_Frame:RegisterEvent("UNIT_INVENTORY_CHANGED")
INEED_Frame:UnregisterEvent("PLAYER_ENTERING_WORLD")
INEED_options.autoRepair = false
-- Build data structure to track what other players need.
INEED.makeOthersNeed()

Expand All @@ -247,7 +246,7 @@ end
function INEED.BAG_UPDATE()
local itemFulfilled = false -- has an item been fulfilled yet?
for itemID, _ in pairs(INEED_data) do -- loop over the stored data structure
local iHaveNum = GetItemCount( itemID, true ) -- include bank
local iHaveNum = GetItemCount( itemID, true, nil, true ) -- include bank
local _, itemLink = GetItemInfo( itemID )
if itemLink and INEED_data[itemID][INEED.realm] and INEED_data[itemID][INEED.realm][INEED.name] then
INEED_data[itemID][INEED.realm][INEED.name].faction = INEED.faction -- force update incase faction is changed
Expand Down Expand Up @@ -439,6 +438,7 @@ function INEED.MERCHANT_SHOW()
repairAllCost, canRepair = GetRepairAllCost()
if( repairAllCost > 0 ) then -- need to repair
RepairAllItems( true ) -- True to use guild repairAllCost
INEED.Print( "Guild Repair Items: "..C_CurrencyInfo.GetCoinTextureString( repairAllCost ) )
end
repairAllCost, canRepair = GetRepairAllCost()
if( INEED_account.balance and repairAllCost > 0 and repairAllCost <= INEED_account.balance ) then
Expand Down Expand Up @@ -546,7 +546,7 @@ function INEED.makeOthersNeed()
--INEED.Print("-=-=-=-=- makeOthersNeed -=-=-=-=-=-")
INEED.othersNeed = { }
for itemID, _ in pairs(INEED_data) do -- loop over the stored data structure
local iHaveNum = GetItemCount( itemID, true ) or 0 -- include bank
local iHaveNum = GetItemCount( itemID, true, nil, true ) or 0 -- include bank
INEED.othersNeed[itemID] = {}
for realm, _ in pairs( INEED_data[itemID] ) do
INEED.othersNeed[itemID][realm] = {}
Expand Down Expand Up @@ -703,22 +703,23 @@ function INEED.addItem( itemLink, quantity )
quantity = quantity or 1
local itemID = INEED.getItemIdFromLink( itemLink )
if itemID and string.len( itemID ) > 0 then
local youHave = GetItemCount( itemID, true ) -- include bank
local youHave = GetItemCount( itemID, true, nil, true ) -- include bank
local inBags = GetItemCount( itemID, false ) -- only in bags
local inAccount = C_Item.GetItemCount( itemID, false, false, false, true ) - inBags
if quantity > 0 then
local linkString = select( 2, GetItemInfo( itemID ) ) or "item:"..itemID
if quantity > youHave then
INEED.Print( string.format( "Needing: %i/%i %s (item:%s Bags: %i Bank: %i)",
youHave, quantity, linkString, itemID, inBags, youHave-inBags ) )
INEED.Print( string.format( "Needing: %i/%i %s (item:%s Bags: %i Bank: %i WB: %i)",
youHave, quantity, linkString, itemID, inBags, youHave-inBags, inAccount ), false )
INEED_data[itemID] = INEED_data[itemID] or {}
INEED_data[itemID][INEED.realm] = INEED_data[itemID][INEED.realm] or {}
INEED_data[itemID][INEED.realm][INEED.name] = INEED_data[itemID][INEED.realm][INEED.name] or {}

INEED_data[itemID][INEED.realm][INEED.name] = INEED.addItemToTable( INEED_data[itemID][INEED.realm][INEED.name],
quantity, youHave, true, linkString )
else
INEED.Print( string.format( COLOR_RED.."-------"..COLOR_END..": %i/%i %s (item:%s Bags: %i Bank: %i)",
youHave, quantity, linkString, itemID, inBags, youHave-inBags ) )
INEED.Print( string.format( COLOR_RED.."-------"..COLOR_END..": %i/%i %s (item:%s Bags: %i Bank: %i WB: %i)",
youHave, quantity, linkString, itemID, inBags, youHave-inBags, inAccount ), false )
end
elseif quantity == 0 then
if INEED_data[itemID] and
Expand Down Expand Up @@ -775,7 +776,7 @@ function INEED.addItem( itemLink, quantity )
if quantity > 0 then
if quantity > iHaveNum then
INEED.Print( string.format( "Needing: %i/%i %s (currency:%s)",
iHaveNum, quantity, currencyLink, currencyID ) )
iHaveNum, quantity, currencyLink, currencyID ), false )
INEED_currency[currencyID] = INEED_currency[currencyID] or {}

INEED_currency[currencyID] = INEED.addItemToTable( INEED_currency[currencyID], quantity, iHaveNum, false)
Expand All @@ -784,7 +785,7 @@ function INEED.addItem( itemLink, quantity )
else
--local currencyLink = GetCurrencyLink( currencyID )
INEED.Print( string.format( COLOR_RED.."-------"..COLOR_END..": %s %i / %i",
currencyLink, iHaveNum, quantity ) )
currencyLink, iHaveNum, quantity ), false )

end
elseif quantity == 0 then
Expand All @@ -804,7 +805,7 @@ function INEED.addItem( itemLink, quantity )
--print("Need gold amount: "..(needGoldAmount or "nil") )
if curAmount < needGoldAmount then
INEED.Print( string.format( "Needing: %s/%s",
C_CurrencyInfo.GetCoinTextureString(curAmount), C_CurrencyInfo.GetCoinTextureString(needGoldAmount) ) )
C_CurrencyInfo.GetCoinTextureString(curAmount), C_CurrencyInfo.GetCoinTextureString(needGoldAmount) ), false )
INEED_gold[INEED.realm] = INEED_gold[INEED.realm] or {}
INEED_gold[INEED.realm][INEED.name] = INEED_gold[INEED.realm][INEED.name] or {}
INEED_gold[INEED.realm][INEED.name] = INEED.addItemToTable( INEED_gold[INEED.realm][INEED.name], needGoldAmount, curAmount )
Expand Down Expand Up @@ -983,7 +984,7 @@ function INEED.showFulfillList()
isSoulBound = INEED.itemIsSoulbound( itemLink )
--INEED.Print( "Looking at "..itemLink..". Which is "..( INEED.itemIsSoulbound( itemLink ) and "soulbound" or "not soulbound" ) )
if not isSoulBound then
local youHaveNum = GetItemCount( itemID, true )
local youHaveNum = GetItemCount( itemID, true, nil, true )
local neededValue = data.needed - data.total - ( data.inMail or 0 )
if (youHaveNum > 0) and (neededValue > 0) then
youHaveTotal = youHaveTotal and youHaveTotal + youHaveNum or youHaveNum
Expand Down
2 changes: 1 addition & 1 deletion src/INEEDOptions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function INEED.OptionsPanel_Refresh()
INEEDOptionsFrame_CombatHide:SetChecked(INEED_options["combatHide"])
INEED.OptionsPanel_EditBox_OnLoad( INEEDOptionsFrame_DisplayBarCount, "barCount" )
INEEDOptionsFrame_FillOldest:SetChecked(INEED_options["fillBars"])
-- INEEDOptionsFrame_AutoRepair:SetChecked(INEED_options["autoRepair"])
INEEDOptionsFrame_AutoRepair:SetChecked(INEED_options["autoRepair"])

-- Slush
INEED.OptionsPanel_Account_EditBox_OnShow( INEEDOptionsFrame_AccountPercent, "percent" )
Expand Down
4 changes: 0 additions & 4 deletions src/INEEDOptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,6 @@
</Layer>
</Layers>
</EditBox>

<!-- Remove for now
<CheckButton name="$parent_AutoRepair" inherits="INEEDOptionsCheckButtonTemplate">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parent_UseAccountForHeader" relativePoint="BOTTOMLEFT"/>
Expand All @@ -486,8 +484,6 @@
<OnClick>INEED.OptionsPanel_CheckButton_OnClick(self,"autoRepair")</OnClick>
</Scripts>
</CheckButton>
-->

<EditBox name="$parent_AccountPercent" inherits="InputBoxTemplate" letters="5" autoFocus="false">
<Size x="44" y="16"/>
<Anchors>
Expand Down
2 changes: 2 additions & 0 deletions test/test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ SendMailNameEditBox = CreateFontString("SendMailNameEditBox")
INEED_SplashFrame = { ["Show"] = function() end,
["AddMessage"] = function(msg) print( "SPLASHFRAME:", (msg or "")) end,
}
MerchantGuildBankRepairButton = CreateButton()
MerchantRepairAllButton = CreateButton()

-- addon setup
INEED.name = "testName"
Expand Down
94 changes: 78 additions & 16 deletions test/wowStubs.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-----------------------------------------
-- Author : Opussf
-- Date : August 5 2024
-- Revision: 9.4.3-10-gb1ddb7e
-- Date : August 13 2024
-- Revision: 9.4.3-16-g4300a9c
-----------------------------------------
-- These are functions from wow that have been needed by addons so far
-- Not a complete list of the functions.
Expand Down Expand Up @@ -283,6 +283,19 @@ FactionInfo = {
["isChild"] = false, ["isHeader"] = true, ["isHeaderWithRep"] = true, ["isCollapsed"] = false, ["isWatched"] = false,
["hasBonusRepGain"] = false, ["canSetInactive"] = false, ["isAccountWide"] = true,
},
{
["factionID"] = 1282, ["name"] = "Fish Fellrend", ["description"] = "", ["reaction"] = 5, ["currentReactionThreshold"] = 0,
["nextReactionThreshold"] = 4000, ["currentStanding"] = 0, ["atWarWith"] = false, ["canToggleAtWar"] = true,
["isChild"] = false, ["isHeader"] = true, ["isHeaderWithRep"] = true, ["isCollapsed"] = false, ["isWatched"] = false,
["hasBonusRepGain"] = false, ["canSetInactive"] = false, ["isAccountWide"] = true,
},
{
["factionID"] = 2010, ["name"] = "Max", ["description"] = "", ["reaction"] = 8, ["currentReactionThreshold"] = 42000,
["nextReactionThreshold"] = 42000, ["currentStanding"] = 42000, ["atWarWith"] = false, ["canToggleAtWar"] = true,
["isChild"] = false, ["isHeader"] = true, ["isHeaderWithRep"] = true, ["isCollapsed"] = false, ["isWatched"] = false,
["hasBonusRepGain"] = false, ["canSetInactive"] = false, ["isAccountWide"] = true,
},

}
--Auras
-- IIRC (Look this up) Auras are index based, use an index based system
Expand Down Expand Up @@ -605,7 +618,6 @@ end
EditBox = {
["SetText"] = function(self,text) self.text=text; end,
["SetCursorPosition"] = function(self,pos) self.cursorPosition=pos; end,

}
function CreateEditBox( name, ... )
me = {}
Expand All @@ -615,6 +627,19 @@ function CreateEditBox( name, ... )
me.name = name
return me
end
Button = {
["enabled"] = true,
["SetEnabled"] = function(self,enabled) self.enabled = enabled; end,
["IsEnabled"] = function(self) return self.enabled; end,
}
function CreateButton( name, ... )
me = {}
for k,v in pairs(Button) do
me[k] = v
end
me.name = name
return me
end

function ChatFrame_AddMessageEventFilter()
end
Expand Down Expand Up @@ -849,11 +874,6 @@ function GetComparisonStatistic( achievementID )
-- returns: string - the value of the requested statistic
return Achievements[achievementID].value
end
function GetAddOnMetadata( addon, field )
-- returns addonData[field] for 'addon'
-- local addonData = { ["version"] = "1.0", }
return addonData[field]
end
function GetCategoryList()
-- http://www.wowwiki.com/API_GetCategoryList
-- Returns a table of achievement categories
Expand All @@ -872,6 +892,18 @@ function GetCategoryNumAchievements( catID )
return 5,0,5
end

C_AddOns = {}
function C_AddOns.GetAddOnMetadata( addon, field )
-- returns addonData[field] for 'addon'
-- local addonData = { ["version"] = "1.0", }
return addonData[field]
end
function C_AddOns.GetNumAddOns()
return 1
end
function C_AddOns.LoadAddOn( addonName )
end

C_Container = {}
C_Container.SortBagsRightToLeft = false -- this is normal
function C_Container.GetContainerItemInfo( bagId, slotId )
Expand Down Expand Up @@ -978,7 +1010,7 @@ function GetInventorySlotInfo( slotName )
end
end
end
function GetItemCount( itemID, includeBank )
function GetItemCount( itemID, includeBank, includeUses, includeReagentBank, includeAccountBank )
-- print( itemID, myInventory[itemID] )
return myInventory[itemID] or 0
end
Expand Down Expand Up @@ -1317,8 +1349,6 @@ end
function IsResting()
return true
end
function LoadAddOn()
end
function NumTaxiNodes()
-- http://www.wowwiki.com/API_NumTaxiNodes
local count = 0
Expand Down Expand Up @@ -1523,13 +1553,12 @@ end
function UnitAffectingCombat( unit )
return false
end
function UnitAura( unit, index, filter )
C_UnitAuras = {}
function C_UnitAuras.GetAuraDataByIndex( unit, index )
-- @TODO: Look this up to get a better idea of what this function does.
-- Returns the aura name
-- unit, [index] [,filter]
-- Returns True or nil
-- Returns an auraData table
if( UnitAuras[unit] and UnitAuras[unit][index] ) then
return UnitAuras[unit][index].name
return UnitAuras[unit][index]
end
end
function UnitClass( who )
Expand Down Expand Up @@ -1668,6 +1697,12 @@ function GetEquipmentSetInfoByName( nameIn )
end
end
end
function CanMerchantRepair()
return true
end
function CanGuildBankRepair()
return true
end

--http://wow.gamepedia.com/Patch_7.0.3/API_changes

Expand Down Expand Up @@ -1840,6 +1875,19 @@ function C_ToyBox.IsToyUsable( id )
return toyList[id] and toyList[id][1]
end

----------
-- Settings
----------
Settings = {}
function Settings.OpenToCategory( id )
end
function Settings.RegisterCanvasLayoutCategory( frame, name )
-- return a category structure
return ( {["GetID"] = function() return 234; end} )
end
function Settings.RegisterAddOnCategory(category)
end

----------
-- C_Reputation
----------
Expand All @@ -1854,6 +1902,20 @@ end
function C_Reputation.GetFactionParagonInfo()
end

----------
-- C_GossipInfo
----------
C_GossipInfo = {}
function C_GossipInfo.GetFriendshipReputation( idIn )
return {["maxRep"]=0, ["text"]="", ["reversedColor"]=false, ["reaction"]="", ["standing"]=0, ["reactionThreshold"]=0, ["friendshipFactionID"]=0, ["textrue"]=0}
end

----------
-- C_Item
----------
C_Item = {}
C_Item.GetItemCount = GetItemCount

----------
-- Menu
----------
Expand Down
4 changes: 2 additions & 2 deletions test/wowTest.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
-----------------------------------------
-- Author : Opussf
-- Date : August 5 2024
-- Revision: 9.4.3-10-gb1ddb7e
-- Date : August 13 2024
-- Revision: 9.4.3-16-g4300a9c
-----------------------------------------
-- This is an uber simple unit test implementation
-- It creates a dictionary called test.
Expand Down

0 comments on commit d907017

Please sign in to comment.