Quantcast

new fun stuff

Munglunch [04-06-15 - 21:11]
new fun stuff
Filename
SVUI_CraftOMatic/components/cooking.lua
SVUI_CraftOMatic/components/fishing.lua
SVUI_Inventory/SVUI_Inventory.lua
diff --git a/SVUI_CraftOMatic/components/cooking.lua b/SVUI_CraftOMatic/components/cooking.lua
index b1ad174..52b1d7f 100644
--- a/SVUI_CraftOMatic/components/cooking.lua
+++ b/SVUI_CraftOMatic/components/cooking.lua
@@ -1,7 +1,7 @@
 --[[
 ##########################################################
 S V U I   By: S.Jackson
-##########################################################
+##########################################################
 LOCALIZED LUA FUNCTIONS
 ##########################################################
 ]]--
@@ -13,7 +13,7 @@ local type 		= _G.type;
 local string    = _G.string;
 local math 		= _G.math;
 local table 	= _G.table;
-local rept      = string.rep;
+local rept      = string.rep;
 local tsort,twipe = table.sort,table.wipe;
 local floor,ceil  = math.floor, math.ceil;
 local band 		= _G.bit.band;
@@ -33,8 +33,8 @@ local GetItemInfo           = _G.GetItemInfo;
 local GetItemCount          = _G.GetItemCount;
 local GetItemQualityColor   = _G.GetItemQualityColor;
 local GetItemFamily         = _G.GetItemFamily;
---[[
-##########################################################
+--[[
+##########################################################
 GET ADDON DATA
 ##########################################################
 ]]--
@@ -42,14 +42,14 @@ local SV = _G.SVUI;
 local L = SV.L;
 local PLUGIN = select(2, ...);
 local CONFIGS = SV.defaults[PLUGIN.Schema];
---[[
-##########################################################
+--[[
+##########################################################
 LOCAL VARS
 ##########################################################
 ]]--
 local cookingSpell, campFire, skillRank, skillModifier, DockButton, usePierre;
---[[
-##########################################################
+--[[
+##########################################################
 LOCAL FUNCTIONS
 ##########################################################
 ]]--
@@ -74,7 +74,7 @@ local function UpdateChefWear()
 		EquipItemByName(86558)
 		PLUGIN.InModeGear = true
 	end
-end
+end

 local function GetTitleAndSkill()
 	local msg = "|cff22ff11Cooking Mode|r"
@@ -83,7 +83,7 @@ local function GetTitleAndSkill()
 			skillRank = skillRank + skillModifier;
 		end
 		msg = msg .. " (|cff00ddff" .. skillRank .. "|r)";
-	end
+	end
 	return msg
 end

@@ -107,16 +107,16 @@ local function FindPierre()
 		end
 	end
 end
---[[
-##########################################################
+--[[
+##########################################################
 CORE NAMESPACE
 ##########################################################
 ]]--
 PLUGIN.Cooking = {};
 PLUGIN.Cooking.Log = {};
 PLUGIN.Cooking.Loaded = false;
---[[
-##########################################################
+--[[
+##########################################################
 EVENT HANDLER
 ##########################################################
 ]]--
@@ -133,7 +133,7 @@ do
 				proxyTest = true;
 			end
 		end
-	end
+	end

 	local Cook_OnEvent = function(self, event, ...)
 		if(InCombatLockdown()) then return end
@@ -145,18 +145,18 @@ do
 			local item, amt = PLUGIN:CheckForModeLoot(...);
 			if item then
 				local name, lnk, rarity, lvl, mlvl, itype, stype, cnt, ieq, tex, price = GetItemInfo(item);
-				if proxyTest == false then
+				if proxyTest == false then
 					LootProxy(lnk, name)
-				end
-				if proxyTest == false then return end
-				if not PLUGIN.Cooking.Log[name] then
-					PLUGIN.Cooking.Log[name] = {amount = 0, texture = ""};
-				end
+				end
+				if proxyTest == false then return end
+				if not PLUGIN.Cooking.Log[name] then
+					PLUGIN.Cooking.Log[name] = {amount = 0, texture = ""};
+				end
 				local r, g, b, hex = GetItemQualityColor(rarity);
 				local stored = PLUGIN.Cooking.Log
 				local mod = stored[name];
 				local newAmt = mod.amount + 1;
-				if amt >= 2 then newAmt = mod.amount + amt end
+				if amt >= 2 then newAmt = mod.amount + amt end
 				PLUGIN.Cooking.Log[name].amount = newAmt;
 				PLUGIN.Cooking.Log[name].texture = tex;
 				PLUGIN.LogWindow:Clear();
@@ -164,14 +164,14 @@ do
 					if type(data) == "table" and data.amount and data.texture then
 						PLUGIN.LogWindow:AddMessage("|cff55FF55"..data.amount.." x|r |T".. data.texture ..":16:16:0:0:64:64:4:60:4:60|t".." "..name, r, g, b);
 					end
-				end
+				end
 				PLUGIN.LogWindow:AddMessage("----------------", 0, 0, 0);
 				PLUGIN.LogWindow:AddMessage("Cooked So Far...", 0, 1, 1);
 				PLUGIN.LogWindow:AddMessage(" ", 0, 0, 0);
 				proxyTest = false;
 			end
 		end
-	end
+	end

 	function EnableListener()
 		CookEventHandler:RegisterEvent("ZONE_CHANGED")
@@ -185,8 +185,8 @@ do
 		CookEventHandler:SetScript("OnEvent", nil)
 	end
 end
---[[
-##########################################################
+--[[
+##########################################################
 CORE METHODS
 ##########################################################
 ]]--
@@ -203,6 +203,11 @@ function PLUGIN.Cooking:Enable()

 	if(not IsSpellKnown(818)) then
 		PLUGIN:ModeLootLoader("Cooking", "WTF is Cooking?", "You have no clue how to cook! \nEven toast is a mystery to you. \nGo find a trainer and learn \nhow to do this simple job.");
+		PLUGIN.TitleWindow:Clear();
+		PLUGIN.TitleWindow:AddMessage("WTF is Cooking?");
+		PLUGIN.LogWindow:Clear();
+		PLUGIN.LogWindow:AddMessage("You have no clue how to cook! \nEven toast is a mystery to you. \nGo find a trainer and learn \nhow to do this simple job.", 1, 1, 1);
+		PLUGIN.LogWindow:AddMessage(" ", 1, 1, 1);
 	else
 		local msg = GetTitleAndSkill();
 		--70082
@@ -243,10 +248,10 @@ function PLUGIN.Cooking:Update()
 	local _,_,_,_,cook,_ = GetProfessions();
 	if cook ~= nil then
 		cookingSpell, _, skillRank, _, _, _, _, skillModifier = GetProfessionInfo(cook)
-	end
+	end
 end
---[[
-##########################################################
+--[[
+##########################################################
 LOADER
 ##########################################################
 ]]--
@@ -254,4 +259,4 @@ function PLUGIN:LoadCookingMode()
 	CONFIGS = SV.db[self.Schema];
 	usePierre = FindPierre()
 	self.Cooking:Update()
-end
\ No newline at end of file
+end
diff --git a/SVUI_CraftOMatic/components/fishing.lua b/SVUI_CraftOMatic/components/fishing.lua
index b73dd30..e7bf203 100644
--- a/SVUI_CraftOMatic/components/fishing.lua
+++ b/SVUI_CraftOMatic/components/fishing.lua
@@ -69,17 +69,18 @@ LOCAL VARS
 local fishingIsKnown, fishingSpell, fishingLure;
 local proxyTest = false;
 local refLures = {
-	{ ["id"] = 6529,  ["bonus"] = 25,  ["skillReq"] = 1,   ["order"] = 10, },  --Shiny Bauble
-	{ ["id"] = 6811,  ["bonus"] = 50,  ["skillReq"] = 50,  ["order"] = 10, },  --Aquadynamic Fish Lens
-	{ ["id"] = 6530,  ["bonus"] = 50,  ["skillReq"] = 50,  ["order"] = 10, },  --Nightcrawlers
-	{ ["id"] = 7307,  ["bonus"] = 75,  ["skillReq"] = 100, ["order"] = 10, },  --Flesh Eating Worm
-	{ ["id"] = 6532,  ["bonus"] = 75,  ["skillReq"] = 100, ["order"] = 10, },  --Bright Baubles
-	{ ["id"] = 34861, ["bonus"] = 100, ["skillReq"] = 100, ["order"] = 10, },  --Sharpened Fish Hook
-	{ ["id"] = 6533,  ["bonus"] = 100, ["skillReq"] = 100, ["order"] = 10, },  --Aquadynamic Fish Attractor
-	{ ["id"] = 62673, ["bonus"] = 100, ["skillReq"] = 100, ["order"] = 10, },  --Feathered Lure
-	{ ["id"] = 46006, ["bonus"] = 100, ["skillReq"] = 100, ["order"] = 60, },  --Glow Worm
-	{ ["id"] = 68049, ["bonus"] = 150, ["skillReq"] = 250, ["order"] = 5,  },  --Heat-Treated Spinning Lure
-	{ ["id"] = 67404, ["bonus"] = 15,  ["skillReq"] = 1,   ["order"] = 10, },  --Glass Fishing Bobber
+	{ ["id"] = 6529, 		["bonus"] = 25, 	["skillReq"] = 1, 	["order"] = 10, }, --Shiny Bauble
+	{ ["id"] = 6811, 		["bonus"] = 50, 	["skillReq"] = 50, 	["order"] = 10, }, --Aquadynamic Fish Lens
+	{ ["id"] = 6530, 		["bonus"] = 50, 	["skillReq"] = 50, 	["order"] = 10, }, --Nightcrawlers
+	{ ["id"] = 7307, 		["bonus"] = 75, 	["skillReq"] = 100, ["order"] = 10, }, --Flesh Eating Worm
+	{ ["id"] = 6532, 		["bonus"] = 75, 	["skillReq"] = 100, ["order"] = 10, }, --Bright Baubles
+	{ ["id"] = 34861, 	["bonus"] = 100, 	["skillReq"] = 100, ["order"] = 10, }, --Sharpened Fish Hook
+	{ ["id"] = 6533, 		["bonus"] = 100, 	["skillReq"] = 100, ["order"] = 10, }, --Aquadynamic Fish Attractor
+	{ ["id"] = 62673, 	["bonus"] = 100, 	["skillReq"] = 100, ["order"] = 10, }, --Feathered Lure
+	{ ["id"] = 46006, 	["bonus"] = 100, 	["skillReq"] = 100, ["order"] = 60, }, --Glow Worm
+	{ ["id"] = 68049, 	["bonus"] = 150, 	["skillReq"] = 250, ["order"] = 5,  }, --Heat-Treated Spinning Lure
+	{ ["id"] = 118391, 	["bonus"] = 200, 	["skillReq"] = 100, ["order"] = 70, }, --Worm Supreme WOD
+	{ ["id"] = 67404, 	["bonus"] = 15, 	["skillReq"] = 1, 	["order"] = 10, }, --Glass Fishing Bobber
 }
 tsort(refLures, function(a,b)
 	if ( a.bonus == b.bonus ) then
@@ -89,27 +90,30 @@ tsort(refLures, function(a,b)
 	end
 end);
 local refHats = {
-	{ ["id"] = 93732, ["weight"] = 10, ["nocast"] = true },  --Darkmoon Fishing Hat
-	{ ["id"] = 33820, ["weight"] = 50  },  --Weather Beaten Fishing Hat
-	{ ["id"] = 19972, ["weight"] = 75  },  --Lucky Fishing Hat
-	{ ["id"] = 88710, ["weight"] = 100 },  --Nats Hat
+	{ ["id"] = 93732, 	["weight"] = 10, 	["nocast"] = true 	},  --Darkmoon Fishing Hat
+	{ ["id"] = 33820, 	["weight"] = 50, 	["nocast"] = false 	},  --Weather Beaten Fishing Hat
+	{ ["id"] = 19972, 	["weight"] = 75, 	["nocast"] = false 	},  --Lucky Fishing Hat
+	{ ["id"] = 118380, 	["weight"] = 100, ["nocast"] = false 	},  --Hightfish Cap 7Days WOD
+	{ ["id"] = 118393, 	["weight"] = 100, ["nocast"] = false 	},  --Tentacled Hat 7Days WOD
+	{ ["id"] = 88710, 	["weight"] = 100, ["nocast"] = false 	},  --Nats Hat
 }
 local refPoles = {
-	{ ["id"] = 44050, ["weight"] = 33 },  --Kaluak
-	{ ["id"] = 25978, ["weight"] = 22 },  --Seths Graphite
-	{ ["id"] = 19022, ["weight"] = 21 },  --Nat Pagles Extreme Angler
-	{ ["id"] = 6367,  ["weight"] = 20 },  --Big Iron
-	{ ["id"] = 6366,  ["weight"] = 15 },  --Darkwood
-	{ ["id"] = 84661, ["weight"] = 32 },  --Dragon
-	{ ["id"] = 19970, ["weight"] = 40 },  --Arcanite
-	{ ["id"] = 45858, ["weight"] = 25 },  --Nats Lucky
-	{ ["id"] = 45992, ["weight"] = 31 },  --Jeweled
-	{ ["id"] = 45991, ["weight"] = 30 },  --Bone
-	{ ["id"] = 6365,  ["weight"] = 5 },   --Strong
-	{ ["id"] = 12225, ["weight"] = 4 },   --Blump Family
-	{ ["id"] = 46337, ["weight"] = 3 },   --Staats
-	{ ["id"] = 84660, ["weight"] = 10 },  --Pandaren
-	{ ["id"] = 6256,  ["weight"] = 1 }    --Standard
+	{ ["id"] = 118381, 	["weight"] = 50 }, --Ephemeral Fishing Pole 24hours WOD
+	{ ["id"] = 44050, 	["weight"] = 33 }, --Kaluak
+	{ ["id"] = 25978, 	["weight"] = 22 }, --Seths Graphite
+	{ ["id"] = 19022, 	["weight"] = 21 }, --Nat Pagles Extreme Angler
+	{ ["id"] = 6367, 		["weight"] = 20 }, --Big Iron
+	{ ["id"] = 6366, 		["weight"] = 15 }, --Darkwood
+	{ ["id"] = 84661, 	["weight"] = 32 }, --Dragon
+	{ ["id"] = 19970, 	["weight"] = 40 }, --Arcanite
+	{ ["id"] = 45858, 	["weight"] = 25 }, --Nats Lucky
+	{ ["id"] = 45992, 	["weight"] = 31 }, --Jeweled
+	{ ["id"] = 45991, 	["weight"] = 30 }, --Bone
+	{ ["id"] = 6365, 		["weight"] = 5 	}, --Strong
+	{ ["id"] = 12225, 	["weight"] = 4 	}, --Blump Family
+	{ ["id"] = 46337, 	["weight"] = 3 	}, --Staats
+	{ ["id"] = 84660, 	["weight"] = 10 }, --Pandaren
+	{ ["id"] = 6256, 		["weight"] = 1 	}  --Standard
 }
 --[[
 ##########################################################
@@ -210,7 +214,7 @@ local function UpdateFishingGear(autoequip)
 		if(OffHandID) then
 			PLUGIN.WornItems["OFF"] = OffHandID;
 		end
-
+
 		if(fishingPole) then
 			EquipItemByName(fishingPole)
 			PLUGIN.InModeGear = true
diff --git a/SVUI_Inventory/SVUI_Inventory.lua b/SVUI_Inventory/SVUI_Inventory.lua
index eff0305..4079232 100644
--- a/SVUI_Inventory/SVUI_Inventory.lua
+++ b/SVUI_Inventory/SVUI_Inventory.lua
@@ -265,9 +265,7 @@ function MOD:BuildEquipmentMap()
 	for key, gearData in pairs(GEARSET_LISTING) do
 		twipe(gearData);
 	end
-
 	local set, player, bank, bags, slotIndex, bagIndex, loc, _;
-
 	for i = 1, GetNumEquipmentSets() do
 		set = GetEquipmentSetInfo(i);
 		GEAR_CACHE = GetEquipmentSetLocations(set);
@@ -290,29 +288,14 @@ end
 CORE FUNCTIONS
 ##########################################################
 ]]--
-function MOD:INVENTORY_SEARCH_UPDATE()
-	if(self.BagFrame) then
-		for id, bag in ipairs(self.BagFrame.Bags) do
-			for i = 1, GetContainerNumSlots(id) do
-				local _, _, _, _, _, _, _, isFiltered = GetContainerItemInfo(id, i)
-				local item = bag[i]
-				if(item and item:IsShown()) then
-					if isFiltered then
-						SetItemButtonDesaturated(item, 1)
-						item:SetAlpha(0.4)
-					else
-						SetItemButtonDesaturated(item)
-						item:SetAlpha(1)
-					end
-				end
-			end
-		end
-	end
-	if(self.BankFrame and self.BankFrame:IsShown()) then
-		for id, bag in ipairs(self.BankFrame.Bags) do
-			for i = 1, GetContainerNumSlots(id) do
-				local _, _, _, _, _, _, _, isFiltered = GetContainerItemInfo(id, i)
-				local item = bag[i]
+local function SearchInBags(frame)
+	if((not frame) or (not frame.BagIDs) or (not frame:IsShown())) then return end
+	for _, bagID in ipairs(frame.BagIDs) do
+		local container = frame.Bags[bagID];
+		if(container) then
+			for i = 1, GetContainerNumSlots(bagID) do
+				local _, _, _, _, _, _, _, isFiltered = GetContainerItemInfo(bagID, i)
+				local item = container[i]
 				if(item and item:IsShown()) then
 					if isFiltered then
 						SetItemButtonDesaturated(item, 1)
@@ -325,21 +308,27 @@ function MOD:INVENTORY_SEARCH_UPDATE()
 			end
 		end
 	end
-	if(self.ReagentFrame and self.ReagentFrame:IsShown()) then
-		for i = 1, self.ReagentFrame.numSlots do
-			local _, _, _, _, _, _, _, isFiltered = GetContainerItemInfo(REAGENTBANK_CONTAINER, i)
-			local item = self.ReagentFrame.Bags[REAGENTBANK_CONTAINER][i]
-			if(item and item:IsShown()) then
-				if isFiltered then
-					SetItemButtonDesaturated(item, 1)
-					item:SetAlpha(0.4)
-				else
-					SetItemButtonDesaturated(item)
-					item:SetAlpha(1)
-				end
-			end
-		end
-	end
+end
+
+function MOD:INVENTORY_SEARCH_UPDATE()
+	SearchInBags(self.BagFrame)
+	SearchInBags(self.BankFrame)
+	SearchInBags(self.ReagentFrame)
+	-- if(self.ReagentFrame and self.ReagentFrame:IsShown()) then
+	-- 	for i = 1, self.ReagentFrame.numSlots do
+	-- 		local _, _, _, _, _, _, _, isFiltered = GetContainerItemInfo(REAGENTBANK_CONTAINER, i)
+	-- 		local item = self.ReagentFrame.Bags[REAGENTBANK_CONTAINER][i]
+	-- 		if(item and item:IsShown()) then
+	-- 			if isFiltered then
+	-- 				SetItemButtonDesaturated(item, 1)
+	-- 				item:SetAlpha(0.4)
+	-- 			else
+	-- 				SetItemButtonDesaturated(item)
+	-- 				item:SetAlpha(1)
+	-- 			end
+	-- 		end
+	-- 	end
+	-- end
 end

 local SlotUpdate = function(self, slotID)
@@ -1051,29 +1040,45 @@ local NEXT_ACTION_ALLOWED, NEXT_ACTION_TOGGLED = false, false;
 local NEXT_ACTION_FORCED, FORCED_CLOSED, FORCED_OPEN = false, false, false;

 do
-	local Search_OnKeyPressed = function(self)
+	local InventorySearch_OnReset = function(self)
 		self:GetParent().detail:Show()
 		self:ClearFocus()
 		SetItemSearch('')
 	end

-	local Search_OnInput = function(self)
-		local i = 3;
-		local j = self:GetText()
-		if len(j) > i then
-			local k=true;
-			for h=1,i,1 do
-				if sub(j,0-h,0-h) ~= sub(j,-1-h,-1-h) then
-					k=false;
-					break
+	local InventorySearch_OnChar = function(self)
+		local MIN_REPEAT_CHARACTERS = 4;
+		local searchString = self:GetText();
+		if (len(searchString) >= MIN_REPEAT_CHARACTERS) then
+			local repeatChar = true;
+			for i=1, MIN_REPEAT_CHARACTERS - 1, 1 do
+				if ( searchString:sub((0-i), (0-i)) ~= searchString:sub((-1-i),(-1-i)) ) then
+					repeatChar = false;
+					break;
+				end
+			end
+			if ( repeatChar ) then
+				InventorySearch_OnReset(self)
+			end
+		end
+	end
+
+	local InventorySearch_OnTextChanged = function(self)
+		local MIN_REPEAT_CHARACTERS = 4;
+		local searchString = self:GetText();
+		if (len(searchString) >= MIN_REPEAT_CHARACTERS) then
+			local repeatChar = true;
+			for i=1, MIN_REPEAT_CHARACTERS - 1, 1 do
+				if ( searchString:sub((0-i), (0-i)) ~= searchString:sub((-1-i),(-1-i)) ) then
+					repeatChar = false;
+					break;
 				end
 			end
-			if k then
-				Search_OnKeyPressed(self)
-				return
+			if ( repeatChar ) then
+				InventorySearch_OnReset(self)
 			end
 		end
-		SetItemSearch(j)
+		SetItemSearch(searchString)
 	end

 	local Search_OnClick = function(self, button)
@@ -1250,13 +1255,13 @@ do
 		frame.editBox:ModPoint("BOTTOMLEFT", frame.holderFrame, "TOPLEFT", 2, 4)
 		frame.editBox:ModPoint("RIGHT", frame.goldText, "LEFT", -5, 0)
 		frame.editBox:SetAutoFocus(true)
-		frame.editBox:SetScript("OnEscapePressed", Search_OnKeyPressed)
-		frame.editBox:SetScript("OnEnterPressed", Search_OnKeyPressed)
+		frame.editBox:SetScript("OnEscapePressed", InventorySearch_OnReset)
+		frame.editBox:SetScript("OnEnterPressed", InventorySearch_OnReset)
 		frame.editBox:SetScript("OnEditFocusLost", frame.editBox.Hide)
 		frame.editBox:SetScript("OnEditFocusGained", frame.editBox.HighlightText)
-		frame.editBox:SetScript("OnTextChanged", Search_OnInput)
-		frame.editBox:SetScript("OnChar", Search_OnInput)
-		frame.editBox.SearchReset = Search_OnKeyPressed
+		frame.editBox:SetScript("OnTextChanged", InventorySearch_OnTextChanged)
+		frame.editBox:SetScript("OnChar", InventorySearch_OnChar)
+		frame.editBox.SearchReset = InventorySearch_OnReset
 		frame.editBox:SetText(SEARCH)
 		frame.editBox:SetFontObject(SVUI_Font_Bag)