local L_EXCLUDE = GetLocale() == "deDE" and "%s ausschlieÃen" |
or GetLocale():find("^es") and "Excluir %s" |
or GetLocale() == "frFR" and "Exclure %s" |
or GetLocale() == "itIT" and "Escludere %s" |
or GetLocale():find("^pt") and "Excluir %s" |
or "Exclude %s" |
|
local exclude = { |
TradingPost = true, |
} |
|
local BuildingFromPlotID = { |
[ 24] = "Barn", |
[ 25] = "Barn", |
[133] = "Barn", |
[159] = "GladiatorsSanctum", |
[160] = "GladiatorsSanctum", |
[161] = "GladiatorsSanctum", |
[162] = "GoblinWorkshop", -- Gnomish Workshop for Alliance |
[163] = "GoblinWorkshop", |
[164] = "GoblinWorkshop", |
[ 40] = "LumberMill", |
[ 41] = "LumberMill", |
[138] = "LumberMill", |
[205] = "Shipyard", |
[206] = "Shipyard", |
[207] = "Shipyard", |
[ 37] = "SpiritLodge", -- Mage Tower for Alliance |
[ 38] = "SpiritLodge", |
[ 39] = "SpiritLodge", |
[111] = "TradingPost", |
[144] = "TradingPost", |
[145] = "TradingPost", |
[ 8] = "WarMill", -- Dwarven Bunker for Alliance |
[ 9] = "WarMill", |
[ 10] = "WarMill", |
} |
|
local t = 0 |
local f = CreateFrame("Frame", "PhanxMod_Garrison", InterfaceOptionsFramePanelContainer) |
|
f:RegisterEvent("PLAYER_LOGIN") |
f:RegisterEvent("SHIPMENT_CRAFTER_OPENED") |
f:RegisterEvent("SHIPMENT_CRAFTER_INFO") |
f:RegisterEvent("SHIPMENT_CRAFTER_CLOSED") |
f:SetScript("OnEvent", function(f, event, success, _, maxShipments, plotID) |
if event == "PLAYER_LOGIN" then |
PhanxModDB = PhanxModDB or {} |
PhanxModDB.Garrisons = PhanxModDB.Garrisons or exclude |
exclude = PhanxModDB.Garrisons |
elseif event == "SHIPMENT_CRAFTER_OPENED" then |
f.active = not IsShiftKeyDown() |
elseif event == "SHIPMENT_CRAFTER_CLOSED" then |
f.active = false |
elseif f.active then |
local available = GarrisonCapacitiveDisplayFrame.available |
local building = BuildingFromPlotID[ C_Garrison.GetOwnedBuildingInfo(plotID) ] |
if available and not exclude[building] and (GetTime() - t > 2) then |
t = GetTime() |
C_Garrison.RequestShipmentCreation(available) |
end |
end |
end) |
|
f:Hide() |
f.name = "Phanx:Garrison" |
f:SetScript("OnShow", function(self) |
f:SetScript("OnShow", nil) |
|
f.titleText = f:CreateFontString("$parentTitle", "ARTWORK", "GameFontNormalLarge") |
f.titleText:SetPoint("TOPLEFT", 16, -16) |
f.titleText:SetText("PhanxMod - Garrison) |
|
f.notesText = f:CreateFontString("$parentSubText", "ARTWORK", "GameFontHighlightSmall") |
f.notesText:SetPoint("TOPLEFT", f.titleText, "BOTTOMLEFT", 0, -8) |
f.notesText:SetPoint("RIGHT", -32, 0) |
f.notesText:SetHeight(32) |
f.notesText:SetJustifyH("LEFT") |
f.notesText:SetJustifyV("TOP") |
f.notesText:SetText("Automatically start work orders.") |
|
local chex = {} |
local function boxOnClick(box) |
exclude[box.key] = box:GetChecked() |
end |
for _, data in next, C_Garrison.GetBuildings() do |
local key = BuildingFromPlotID[data.plotID] |
if key and not chex[key] then |
local _, name = C_Garrison.GetBuildingInfo(data.buildingID) |
local box = CreateFrame("CheckButton", "$parentToggle"..key, f, "InterfaceOptionsCheckButtonTemplate") |
box:SetHitRectInsets(0, -200, 0, 0) |
box:SetScript("OnClick", boxOnClick) |
box.Text:SetFormattedText(L_EXCLUDE, name) |
box.name = name |
box.key = key |
tinsert(chex, box) |
chex[key] = true |
end |
end |
table.sort(chex, function(a, b) |
return a.name < b.name |
end) |
for i = 1, #chex do |
chex[i]:SetPoint("TOPLEFT", i > 1 and chex[i-1] or f.notes, "BOTTOMLEFT", i > 1 and 0 or -2, -8) |
end |
|
f.refresh = function() |
for i = 1, #chex do |
chex[i]:SetChecked(exclude[chex[i].key]) |
end |
end |
f.refresh() |
end) |