Quantcast

So now we don't need that max order button and all assosiated stuff. Only auto order script is now in place.

Darthpred [02-23-15 - 21:55]
So now we don't need that max order button and all assosiated stuff. Only auto order script is now in place.
Filename
ElvUI_SLE/defaults/profile.lua
ElvUI_SLE/locales/russian.lua
ElvUI_SLE/modules/garrison.lua
ElvUI_SLE/options/garrison_c.lua
diff --git a/ElvUI_SLE/defaults/profile.lua b/ElvUI_SLE/defaults/profile.lua
index ba97da1..9cfafd7 100644
--- a/ElvUI_SLE/defaults/profile.lua
+++ b/ElvUI_SLE/defaults/profile.lua
@@ -457,7 +457,6 @@ P['sle'] = {
 		['autoOrder'] = false,
 		['autoWar'] = false,
 		['autoTrade'] = false,
-		['showOrderButton'] = true,
 	},

 	['errorframe'] = {
diff --git a/ElvUI_SLE/locales/russian.lua b/ElvUI_SLE/locales/russian.lua
index d22c7b3..fc1ee65 100644
--- a/ElvUI_SLE/locales/russian.lua
+++ b/ElvUI_SLE/locales/russian.lua
@@ -494,9 +494,6 @@ L["Auto Work Orders for Warmill"] = "Авто. заказы на фабрике"
 L["Automatically queue maximum number of work orders available for Warmill/Dwarven Bunker."] = "Автоматически делать максимальное количество заказов для военной фабрики/дворфийского бункера."
 L["Auto Work Orders for Trading Post"] = "Авто. заказы в торговой лавке"
 L["Automatically queue maximum number of work orders available for Trading Post."] = "Автоматически делать максимальное количество заказов для торговой лавки."
-L["Show Max Order Button"] = "Кнопка максимума"
-L["Show the button to queue maximum number of work orders in building's UI."] = "Отображать кнопку для выполнения максимума заказов в интерфейсе зданий."
-L["Max"] = "Макс."

 --Error Frame--
 L["Error Frame"] = "Фрейм ошибок"
diff --git a/ElvUI_SLE/modules/garrison.lua b/ElvUI_SLE/modules/garrison.lua
index ff625b5..e0c57a6 100644
--- a/ElvUI_SLE/modules/garrison.lua
+++ b/ElvUI_SLE/modules/garrison.lua
@@ -2,7 +2,6 @@ local E, L, V, P, G = unpack(ElvUI);
 local S = E:GetModule("Skins")
 local G = E:GetModule("SLE_Garrison")

-local n = 0
 local buildID = {
     [8] = "War",
     [9] = "War",
@@ -12,97 +11,11 @@ local buildID = {
     [145] = "Trade",
 }

-function G:WorkOrderButtonCreate()
-	local button = CreateFrame("Button", 'SLE_MaxWorkOrderButton', GarrisonCapacitiveDisplayFrame, "OptionsButtonTemplate");
-	button:Point("RIGHT", GarrisonCapacitiveDisplayFrame.StartWorkOrderButton, "LEFT", -4, 0);
-	button:Width(50);
-	button:Height(22);
-	S:HandleButton(button)
-
-	button.text = button:CreateFontString(nil, "OVERLAY", button)
-	button.text:SetPoint("CENTER", button, "CENTER", -2, 0)
-	button.text:FontTemplate()
-
-	button:SetScript('OnClick', G.AutoOrderScript)
-end
-
-function G:GetNumOrders(maxShipments)
-	if not maxShipments then return end
-	local number = (maxShipments or 0) - (C_Garrison.GetNumPendingShipments() or 0)
-	for i = 1, C_Garrison.GetNumShipmentReagents() do
-		local name, texture, quality, needed, quantity, itemID = C_Garrison.GetShipmentReagentInfo(i);
-		if (not name) then
-	   		break;
-	   	end
-		local canDo = quantity/needed
-		if canDo < number then number = floor(canDo) end
-	end
-
-	local currencyID, currencyNeeded = C_Garrison.GetShipmentReagentCurrencyInfo();
-
-	if (currencyID and currencyNeeded) then
-		local name, quantity = GetCurrencyInfo(currencyID);
-
-		if (name) then
-			local canDo = quantity/currencyNeeded;
-			if canDo < number then number = floor(canDo) end
-		end
-	end
-
-	return number
-end
-
-function G:AutoOrderScript()
-	local self = SLE_AutoOrderFrame
-
-	if n <= 0 then self:SetScript("OnUpdate", nil); return end
-	self.elapsed = 0
-	self:SetScript("OnUpdate", function (self, elapsed)
-		self.elapsed = self.elapsed + elapsed
-		if self.elapsed > 0.2 then
-			self.elapsed = 0;
-			if n > 0 then
-				C_Garrison.RequestShipmentCreation()
-			else
-				self:SetScript("OnUpdate", nil);
-			end
-		end
-	end)
-end
-
-function G:SHIPMENT_CRAFTER_OPENED(containerID)
-	if E.db.sle.garrison.showOrderButton then
-		if SLE_MaxWorkOrderButton then SLE_MaxWorkOrderButton:Show() end
-	else
-		if SLE_MaxWorkOrderButton then SLE_MaxWorkOrderButton:Hide() end
-	end
-	SLE_AutoOrderFrame:SetScript("OnUpdate", nil);
-end
-
-function G:SHIPMENT_CRAFTER_CLOSED()
-	SLE_AutoOrderFrame:SetScript("OnUpdate", nil);
-end
-
 function G:SHIPMENT_CRAFTER_INFO(event, success, _, maxShipments, plotID)
 	if not GarrisonCapacitiveDisplayFrame then return end
-	n = G:GetNumOrders(maxShipments)
-	local button = SLE_MaxWorkOrderButton
+	local n = GarrisonCapacitiveDisplayFrame.available or 0

 	local enabled = GarrisonCapacitiveDisplayFrame.StartWorkOrderButton:IsEnabled()
-	if button then button:SetEnabled(enabled) end
-    if not enabled then
-		SLE_AutoOrderFrame:SetScript ("OnUpdate", nil)
-		if button then
-			button.text:SetText(L["Max"])
-			button.text:SetTextColor(0.6, 0.6, 0.6)
-		end
-        return
-	else
-		if button then
-			button.text:SetText("x"..n)
-			button.text:SetTextColor(1,0.9,0)
-		end
-    end

 	if not E.db.sle.garrison.autoOrder then return end
 	if not enabled then return end
@@ -110,36 +23,13 @@ function G:SHIPMENT_CRAFTER_INFO(event, success, _, maxShipments, plotID)
 	local nope = buildID[ID]
 	if nope then
 		if E.db.sle.garrison['auto'..nope] then
-			G:AutoOrderScript()
-		end
-	else
-		G:AutoOrderScript()
-	end
-end
-
-function G:ADDON_LOADED(event, name)
-	if name == 'Blizzard_GarrisonUI' then
-		G:WorkOrderButtonCreate()
-		G:UnregisterEvent('ADDON_LOADED')
-	end
-end
-
-function G:ShowButton()
-	if E.db.sle.garrison.showOrderButton then
-		if IsAddOnLoaded('Blizzard_GarrisonUI') and not SLE_MaxWorkOrderButton then
-			G:WorkOrderButtonCreate()
-		else
-			G:RegisterEvent('ADDON_LOADED')
+			C_Garrison.RequestShipmentCreation(n)
 		end
 	else
-		G:UnregisterEvent('ADDON_LOADED')
+		C_Garrison.RequestShipmentCreation(n)
 	end
 end

 function G:Initialize()
-	local f = CreateFrame("Frame", "SLE_AutoOrderFrame", GarrisonCapacitiveDisplayFrame)
-	G:ShowButton()
 	self:RegisterEvent("SHIPMENT_CRAFTER_INFO");
-	self:RegisterEvent("SHIPMENT_CRAFTER_OPENED");
-	self:RegisterEvent("SHIPMENT_CRAFTER_CLOSED");
 end
\ No newline at end of file
diff --git a/ElvUI_SLE/options/garrison_c.lua b/ElvUI_SLE/options/garrison_c.lua
index 43c6ce4..6e96126 100644
--- a/ElvUI_SLE/options/garrison_c.lua
+++ b/ElvUI_SLE/options/garrison_c.lua
@@ -11,11 +11,6 @@ local function configTable()
 				type = "header",
 				name = GARRISON_LOCATION_TOOLTIP,
 			},
-			-- intro = {
-				-- order = 2,
-				-- type = "description",
-				-- name = L["UB_DESC"],
-			-- },
 			autoOrder = {
 				order = 3,
 				type = "toggle",
@@ -42,14 +37,6 @@ local function configTable()
 				get = function(info) return E.db.sle.garrison.autoTrade end,
 				set = function(info, value) E.db.sle.garrison.autoTrade = value end
 			},
-			showButton = {
-				order = 6,
-				type = "toggle",
-				name = L["Show Max Order Button"],
-				desc = L["Show the button to queue maximum number of work orders in building's UI."],
-				get = function(info) return E.db.sle.garrison.showOrderButton end,
-				set = function(info, value) E.db.sle.garrison.showOrderButton = value; E:GetModule('SLE_Garrison'):ShowButton() end
-			},
 		},
 	}
 end