<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>tekKonfig/tekKonfigButton.lua</filename>
    </added>
    <added>
      <filename>tekKonfig/tekKonfigTopTab.lua</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -6,7 +6,10 @@ KENNELFRAME = nil
 
 local frame = CreateFrame(&quot;Frame&quot;, nil, InterfaceOptionsFramePanelContainer)
 frame.name = &quot;Kennel&quot;
+frame:Hide()
 frame:SetScript(&quot;OnShow&quot;, function(frame)
+	local tektab = LibStub(&quot;tekKonfig-TopTab&quot;)
+
 	local title, subtitle = LibStub(&quot;tekKonfig-Heading&quot;).new(frame, &quot;Kennel&quot;, &quot;This panel allows you to select which pets Kennel will put out.&quot;)
 
 
@@ -20,25 +23,49 @@ frame:SetScript(&quot;OnShow&quot;, function(frame)
 	mountdismiss:SetChecked(KennelDBPC.dismissonmount)
 
 
-	local group = LibStub(&quot;tekKonfig-Group&quot;).new(frame, &quot;Furry bastards&quot;, &quot;TOP&quot;, mountdismiss, &quot;BOTTOM&quot;, 0, -GAP-14)
+	local group = LibStub(&quot;tekKonfig-Group&quot;).new(frame, nil, &quot;TOP&quot;, mountdismiss, &quot;BOTTOM&quot;, 0, -GAP-14)
 	group:SetPoint(&quot;LEFT&quot;, EDGEGAP, 0)
 	group:SetPoint(&quot;BOTTOMRIGHT&quot;, -EDGEGAP, EDGEGAP)
 
-	local scrollbar = LibStub(&quot;tekKonfig-Scroll&quot;).new(group, 6, 1)
 
-	group:EnableMouseWheel()
-	group:SetScript(&quot;OnMouseWheel&quot;, function(self, val) scrollbar:SetValue(scrollbar:GetValue() - val) end)
+	local randoms, zones
+	local tab1 = tektab.new(frame, &quot;Random&quot;, &quot;BOTTOMLEFT&quot;, group, &quot;TOPLEFT&quot;, 0, -4)
+	local tab2 = tektab.new(frame, &quot;Zone&quot;, &quot;LEFT&quot;, tab1, &quot;RIGHT&quot;, -15, 0)
+	tab2:Deactivate()
+	tab1:SetScript(&quot;OnClick&quot;, function(self)
+		self:Activate()
+		tab2:Deactivate()
+		randoms:Show()
+		zones:Hide()
+	end)
+	tab2:SetScript(&quot;OnClick&quot;, function(self)
+		self:Activate()
+		tab1:Deactivate()
+		randoms:Hide()
+		zones:Show()
+	end)
+
+
+	----------------------------
+	--      Random panel      --
+	----------------------------
+
+	randoms = CreateFrame(&quot;Frame&quot;, nil, group)
+	randoms:SetAllPoints()
 
+	local scrollbar = LibStub(&quot;tekKonfig-Scroll&quot;).new(randoms, 6, 1)
 
-	local grouptext = group:CreateFontString(nil, &quot;ARTWORK&quot;, &quot;GameFontHighlightSmall&quot;)
-	grouptext:SetHeight(32)
-	grouptext:SetPoint(&quot;TOPLEFT&quot;, group, &quot;TOPLEFT&quot;, EDGEGAP, -EDGEGAP)
-	grouptext:SetPoint(&quot;RIGHT&quot;, group, -EDGEGAP-16, 0)
-	grouptext:SetNonSpaceWrap(true)
-	grouptext:SetJustifyH(&quot;LEFT&quot;)
-	grouptext:SetJustifyV(&quot;TOP&quot;)
-	grouptext:SetText(&quot;These pets will be used at random.  Solid blue highlighted pets will be used more often.&quot;)
+	randoms:EnableMouseWheel()
+	randoms:SetScript(&quot;OnMouseWheel&quot;, function(self, val) scrollbar:SetValue(scrollbar:GetValue() - val) end)
 
+	local randomstext = randoms:CreateFontString(nil, &quot;ARTWORK&quot;, &quot;GameFontHighlightSmall&quot;)
+	randomstext:SetHeight(32)
+	randomstext:SetPoint(&quot;TOPLEFT&quot;, randoms, &quot;TOPLEFT&quot;, EDGEGAP, -EDGEGAP)
+	randomstext:SetPoint(&quot;RIGHT&quot;, randoms, -EDGEGAP-16, 0)
+	randomstext:SetNonSpaceWrap(true)
+	randomstext:SetJustifyH(&quot;LEFT&quot;)
+	randomstext:SetJustifyV(&quot;TOP&quot;)
+	randomstext:SetText(&quot;These pets will be used at random.  Solid blue highlighted pets will be used more often.&quot;)
 
 	local function OnClick(self)
 		local v = kennel.randomdb[self.id] + 1
@@ -64,9 +91,9 @@ frame:SetScript(&quot;OnShow&quot;, function(frame)
 	local function HideTooltip() GameTooltip:Hide() end
 
 	for i=1,NUMROWS do
-		local row = CreateFrame(&quot;Frame&quot;, nil, group)
+		local row = CreateFrame(&quot;Frame&quot;, nil, randoms)
 		row:SetHeight(ICONSIZE)
-		if i == 1 then row:SetPoint(&quot;TOPLEFT&quot;, group, EDGEGAP, -EDGEGAP-ICONSIZE-6)
+		if i == 1 then row:SetPoint(&quot;TOPLEFT&quot;, randoms, EDGEGAP, -EDGEGAP-ICONSIZE-6)
 		else row:SetPoint(&quot;TOPLEFT&quot;, rows[i-1], &quot;BOTTOMLEFT&quot;, 0, -6) end
 		row:SetPoint(&quot;RIGHT&quot;, -EDGEGAP, 0)
 		row.buttons = {}
@@ -125,7 +152,146 @@ frame:SetScript(&quot;OnShow&quot;, function(frame)
 
 	Update()
 	scrollbar:SetValue(0)
-	frame:SetScript(&quot;OnShow&quot;, Update)
+	randoms:SetScript(&quot;OnShow&quot;, Update)
+
+
+	--------------------------
+	--      Zone panel      --
+	--------------------------
+
+	zones = CreateFrame(&quot;Frame&quot;, nil, group)
+	zones:SetAllPoints()
+	zones:Hide()
+
+	local scrollbar = LibStub(&quot;tekKonfig-Scroll&quot;).new(zones, 6, 1)
+
+	zones:EnableMouseWheel()
+	zones:SetScript(&quot;OnMouseWheel&quot;, function(self, val) scrollbar:SetValue(scrollbar:GetValue() - val) end)
+
+	local zonestext = zones:CreateFontString(nil, &quot;ARTWORK&quot;, &quot;GameFontHighlightSmall&quot;)
+	zonestext:SetHeight(34)
+	zonestext:SetPoint(&quot;TOPLEFT&quot;, zones, &quot;TOPLEFT&quot;, EDGEGAP, -EDGEGAP)
+	zonestext:SetPoint(&quot;RIGHT&quot;, zones, -EDGEGAP-16, 0)
+	zonestext:SetNonSpaceWrap(true)
+	zonestext:SetJustifyH(&quot;LEFT&quot;)
+	zonestext:SetJustifyV(&quot;TOP&quot;)
+	zonestext:SetText(&quot;These pets will be used when you are in the corresponding zone or subzone.  Summon the desired pet and click an 'add' button to set that pet for the current zone or subzone.&quot;)
+
+
+	local NUMROWS = 10
+	local ROWHEIGHT = 15
+	local rows, Update, selectedzone = {}
+	local function OnClick(self)
+		selectedzone = self.zone:GetText()
+		Update()
+	end
+	for i=1,NUMROWS do
+		local row = CreateFrame(&quot;CheckButton&quot;, nil, zones)
+		row:SetHeight(ROWHEIGHT)
+		if i == 1 then row:SetPoint(&quot;TOP&quot;, zonestext, &quot;BOTTOM&quot;, 0, -8)
+		else row:SetPoint(&quot;TOP&quot;, rows[i-1], &quot;BOTTOM&quot;) end
+		row:SetPoint(&quot;LEFT&quot;, 4, 0)
+		row:SetPoint(&quot;RIGHT&quot;, scrollbar, &quot;LEFT&quot;, -4, 0)
+
+		local highlight = row:CreateTexture()
+		highlight:SetTexture(&quot;Interface\\HelpFrame\\HelpFrameButton-Highlight&quot;)
+		highlight:SetTexCoord(0, 1, 0, 0.578125)
+		highlight:SetAllPoints()
+		row:SetHighlightTexture(highlight)
+		row:SetCheckedTexture(highlight)
+
+		local textzone = row:CreateFontString(nil, nil, &quot;GameFontNormalSmall&quot;)
+		textzone:SetPoint(&quot;LEFT&quot;, EDGEGAP + GAP, 0)
+		local textpet = row:CreateFontString(nil, nil, &quot;GameFontHighlightSmall&quot;)
+		textpet:SetPoint(&quot;LEFT&quot;, textzone, &quot;RIGHT&quot;, GAP, 0)
+		textpet:SetPoint(&quot;RIGHT&quot;, -GAP, 0)
+		textpet:SetJustifyH(&quot;RIGHT&quot;)
+
+		row:SetScript(&quot;OnClick&quot;, OnClick)
+
+		row.zone = textzone
+		row.pet = textpet
+		textzone:SetText(&quot;Testing zone&quot;)
+		textpet:SetText(&quot;Test pet&quot;)
+		rows[i] = row
+	end
+
+	local offset, deletebutt, sortedzones = 0
+	function Update()
+		if not sortedzones then
+			sortedzones = {}
+			for i in pairs(KennelDBPC.zone) do table.insert(sortedzones, i) end
+			table.sort(sortedzones)
+		end
+
+		scrollbar:SetMinMaxValues(0, math.max(0, #sortedzones - NUMROWS))
+
+		local selectedvisible
+		for i,row in pairs(rows) do
+			local zone = sortedzones[i + offset]
+			local pet = zone and KennelDBPC.zone[zone]
+			if pet then
+				row.zone:SetText(zone)
+				row.pet:SetText(pet)
+				row:SetChecked(zone == selectedzone)
+				selectedvisible = selectedvisible or zone == selectedzone
+				row:Show()
+			else
+				row:Hide()
+			end
+		end
+
+		if selectedvisible then deletebutt:Enable() else deletebutt:Disable() end
+	end
+
+	local function GetCurrentPet()
+		for i=1,GetNumCompanions(&quot;CRITTER&quot;) do
+			local _, name, _, _, summoned = GetCompanionInfo(&quot;CRITTER&quot;, i)
+			if summoned then return name end
+		end
+	end
+
+	local addzone = LibStub(&quot;tekKonfig-Button&quot;).new(zones, &quot;BOTTOMLEFT&quot;, zones, &quot;BOTTOMLEFT&quot;, EDGEGAP, EDGEGAP):MakeSmall()
+	addzone.tiptext = &quot;Click to set the currently summoned pet to be used in the current zone.&quot;
+	addzone:SetText(&quot;Add zone&quot;)
+	addzone:SetScript(&quot;OnClick&quot;, function()
+		KennelDBPC.zone[GetZoneText()] = GetCurrentPet()
+		sortedzones, selectedzone = nil
+		Update()
+	end)
+
+	local addsubzone = LibStub(&quot;tekKonfig-Button&quot;).new(zones, &quot;LEFT&quot;, addzone, &quot;RIGHT&quot;, GAP/2, 0):MakeSmall()
+	addsubzone.tiptext = &quot;Click to set the currently summoned pet to be used in the current subzone.&quot;
+	addsubzone:SetText(&quot;Add subzone&quot;)
+	addsubzone:SetScript(&quot;OnShow&quot;, function(self) if GetSubZoneText() == &quot;&quot; then self:Disable() else self:Enable() end end)
+	addsubzone:SetScript(&quot;OnClick&quot;, function()
+		KennelDBPC.zone[GetZoneText() ..&quot; - &quot;..GetSubZoneText()] = GetCurrentPet()
+		sortedzones, selectedzone = nil
+		Update()
+	end)
+
+	deletebutt = LibStub(&quot;tekKonfig-Button&quot;).new(zones, &quot;BOTTOM&quot;, zones, &quot;BOTTOM&quot;, 0, EDGEGAP):MakeSmall():MakeGrey()
+	deletebutt:SetPoint(&quot;RIGHT&quot;, scrollbar, &quot;LEFT&quot;, -EDGEGAP, 0)
+	deletebutt.tiptext = &quot;Remove the currently selected zone-pet setting.&quot;
+	deletebutt:SetText(&quot;Delete&quot;)
+	deletebutt:SetScript(&quot;OnClick&quot;, function()
+		KennelDBPC.zone[selectedzone], sortedzones, selectedzone = nil
+		Update()
+	end)
+
+	local f = scrollbar:GetScript(&quot;OnValueChanged&quot;)
+	scrollbar:SetScript(&quot;OnValueChanged&quot;, function(self, value, ...)
+		offset = math.floor(value)
+		Update()
+		return f(self, value, ...)
+	end)
+
+	Update()
+	scrollbar:SetValue(0)
+	zones:SetScript(&quot;OnShow&quot;, Update)
+
+
+	frame:SetScript(&quot;OnShow&quot;, nil)
 end)
 
 </diff>
      <filename>Config.lua</filename>
    </modified>
    <modified>
      <diff>@@ -15,18 +15,14 @@ f:SetScript(&quot;OnEvent&quot;, function(self, event, ...) if self[event] then return sel
 f:Hide()
 
 
-local numpets = 0
-local function PutTheCatOut(self, event)
-	Debug(event or &quot;nil&quot;, HasFullControl() and &quot;In control&quot; or &quot;Not in control&quot;, InCombatLockdown() and &quot;In combat&quot; or &quot;Not in combat&quot;)
-
-	if InCombatLockdown() then return self:RegisterEvent(&quot;PLAYER_REGEN_ENABLED&quot;) end
-	if not HasFullControl() then return self:RegisterEvent(&quot;PLAYER_CONTROL_GAINED&quot;) end
-	self:UnregisterEvent(&quot;PLAYER_REGEN_ENABLED&quot;)
-
-	for i=1,GetNumCompanions(&quot;CRITTER&quot;) do if select(5, GetCompanionInfo(&quot;CRITTER&quot;, i)) then return end end
-
-	Debug(&quot;Queueing pet to be put out&quot;)
-	self:Show()
+local function GetZonePet()
+	local z, sz = GetZoneText(), GetSubZoneText()
+	local name = sz and sz ~= &quot;&quot; and KennelDBPC.zone[z ..&quot; - &quot;..sz] or KennelDBPC.zone[z]
+	if not name then return end
+	for i=1,GetNumCompanions(&quot;CRITTER&quot;) do
+		local _, pname, id = GetCompanionInfo(&quot;CRITTER&quot;, i)
+		if pname == name then return i, pname end
+	end
 end
 
 
@@ -47,6 +43,30 @@ local function GetRandomPet()
 end
 
 
+local function SummonedPet()
+	for i=1,GetNumCompanions(&quot;CRITTER&quot;) do
+		local _, name, _, _, summoned = GetCompanionInfo(&quot;CRITTER&quot;, i)
+		if summoned then return name end
+	end
+end
+
+
+local numpets = 0
+local function PutTheCatOut(self, event)
+	Debug(event or &quot;nil&quot;, HasFullControl() and &quot;In control&quot; or &quot;Not in control&quot;, InCombatLockdown() and &quot;In combat&quot; or &quot;Not in combat&quot;)
+
+	if InCombatLockdown() then return self:RegisterEvent(&quot;PLAYER_REGEN_ENABLED&quot;) end
+	if not HasFullControl() then return self:RegisterEvent(&quot;PLAYER_CONTROL_GAINED&quot;) end
+	self:UnregisterEvent(&quot;PLAYER_REGEN_ENABLED&quot;)
+
+	local summ, _, zonepet = SummonedPet(), GetZonePet()
+	if (not zonepet and summ) or (zonepet and zonepet == summ) then return end
+
+	Debug(&quot;Queueing pet to be put out&quot;)
+	self:Show()
+end
+
+
 local elapsed
 f:SetScript(&quot;OnShow&quot;, function() elapsed = 0 end)
 f:SetScript(&quot;OnUpdate&quot;, function(self, elap)
@@ -64,7 +84,8 @@ f:SetScript(&quot;OnUpdate&quot;, function(self, elap)
 		return
 	end
 
-	local peti, name = GetRandomPet()
+	local peti, name = GetZonePet()
+	if not peti then peti, name = GetRandomPet() end
 	if peti then
 	local numpets = GetNumCompanions(&quot;CRITTER&quot;)
 		Debug(&quot;Putting out pet&quot;, name)
@@ -80,12 +101,13 @@ f:RegisterEvent(&quot;ADDON_LOADED&quot;)
 function f:ADDON_LOADED(event, addon)
 	if addon:lower() ~= &quot;kennel&quot; then return end
 
-	KennelDBPC = KennelDBPC or {random = {}}
+	KennelDBPC = KennelDBPC or {random = {}, zone = {}}
 	if not KennelDBPC.random then
 		for i,v in pairs(KennelDBPC) do KennelDBPC[i] = 0 end
 		KennelDBPC = {random = KennelDBPC}
 		KennelDBPC.disabled, KennelDBPC.random.disabled = KennelDBPC.random.disabled
 	end
+	if not KennelDBPC.zone then KennelDBPC.zone = {} end
 
 	db = setmetatable(KennelDBPC.random, {__index = function() return 2 end})
 	self.randomdb = db
@@ -107,12 +129,9 @@ f.PLAYER_REGEN_ENABLED = PutTheCatOut
 f.PLAYER_CONTROL_GAINED = PutTheCatOut
 f.PLAYER_LOGIN = PutTheCatOut
 f.PLAYER_UNGHOST = PutTheCatOut
-
-
-function f:ZONE_CHANGED_NEW_AREA()
-	SetMapToCurrentZone()
-	PutTheCatOut(self, &quot;ZONE_CHANGED_NEW_AREA&quot;)
-end
+f.ZONE_CHANGED = PutTheCatOut
+f.ZONE_CHANGED_INDOORS = PutTheCatOut
+f.ZONE_CHANGED_NEW_AREA = PutTheCatOut
 
 
 function f:COMPANION_UPDATE(event, comptype)
@@ -129,6 +148,8 @@ end
 
 f:RegisterEvent(&quot;COMPANION_UPDATE&quot;)
 f:RegisterEvent(&quot;PLAYER_UNGHOST&quot;)
+f:RegisterEvent(&quot;ZONE_CHANGED&quot;)
+f:RegisterEvent(&quot;ZONE_CHANGED_INDOORS&quot;)
 f:RegisterEvent(&quot;ZONE_CHANGED_NEW_AREA&quot;)
 
 </diff>
      <filename>Kennel.lua</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,10 @@
 &lt;Ui xmlns=&quot;http://www.blizzard.com/wow/ui/&quot;&gt;
 	&lt;Script file=&quot;LibStub.lua&quot;/&gt;
+	&lt;Script file=&quot;tekKonfigButton.lua&quot;/&gt;
 	&lt;Script file=&quot;tekKonfigCheckbox.lua&quot;/&gt;
 	&lt;Script file=&quot;tekKonfigHeading.lua&quot;/&gt;
 	&lt;Script file=&quot;tekKonfigScroll.lua&quot;/&gt;
 	&lt;Script file=&quot;tekKonfigAboutPanel.lua&quot;/&gt;
 	&lt;Script file=&quot;tekKonfigGroup.lua&quot;/&gt;
+	&lt;Script file=&quot;tekKonfigTopTab.lua&quot;/&gt;
 &lt;/Ui&gt;</diff>
      <filename>tekKonfig/tekKonfig.xml</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>a32467cc35c2be2fd6a9e5fd73f6de855f53b4dd</id>
    </parent>
  </parents>
  <author>
    <name>Tekkub</name>
    <email>tekkub@gmail.com</email>
  </author>
  <url>http://github.com/tekkub/kennel/commit/3e73da9b8ae9d78cbee78685cf5286df1922e53b</url>
  <id>3e73da9b8ae9d78cbee78685cf5286df1922e53b</id>
  <committed-date>2009-06-20T15:43:10-07:00</committed-date>
  <authored-date>2009-06-20T15:43:10-07:00</authored-date>
  <message>Add per-zone pet options</message>
  <tree>4210c473b1b6678715a44861d59c917825ba481e</tree>
  <committer>
    <name>Tekkub</name>
    <email>tekkub@gmail.com</email>
  </committer>
</commit>
