<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<Script file="MainMenuBarMicroButtons.lua"/>
	<Button name="MainMenuBarMicroButton" virtual="true">
		<Size>
			<AbsDimension x="28" y="58"/>
		</Size>
		<HitRectInsets>
			<AbsInset left="0" right="0" top="18" bottom="0"/>
		</HitRectInsets>
		<Scripts>
			<OnEnter>
				GameTooltip_AddNewbieTip(self, self.tooltipText, 1.0, 1.0, 1.0, self.newbieText);
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide();
			</OnLeave>
		</Scripts>
	</Button>
	<Button name="CharacterMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT">
				<Offset>
					<AbsDimension x="552" y="2"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
                <Texture name="MicroButtonPortrait">
                    <Size>
                        <AbsDimension x="18" y="25"/>
                    </Size>
                    <Anchors>
                        <Anchor point="TOP">
                            <Offset>
                                <AbsDimension x="0" y="-28"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
					<TexCoords left="0.2" right="0.8" top="0.0666" bottom="0.9"/>
                </Texture>
            </Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				CharacterMicroButton_OnLoad(self);
			</OnLoad>
			<OnMouseDown>
				if self.down then
					self.down = nil;
					ToggleCharacter("PaperDollFrame");
					return;
				end
				CharacterMicroButton_SetPushed();
				self.down = 1;
			</OnMouseDown>
			<OnMouseUp>
				if self.down then
					self.down = nil;
					if MouseIsOver(self) then
						ToggleCharacter("PaperDollFrame");
					else
						UpdateMicroButtons();
					end
					return;
				end
				if self:GetButtonState() == "NORMAL" then
					CharacterMicroButton_SetPushed();
					self.down = 1;
				else
					CharacterMicroButton_SetNormal();
					self.down = 1;
				end
			</OnMouseUp>
			<OnEvent>
				CharacterMicroButton_OnEvent(self, event, ...);
			</OnEvent>
		</Scripts>
	</Button>
	<Button name="SpellbookMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="CharacterMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "Spellbook");
			</OnLoad>
			<OnClick>
				ToggleSpellBook(BOOKTYPE_SPELL);
			</OnClick>
			<OnEnter>
				if PlayerHasSpells() then
					self.tooltipText = MicroButtonTooltipText(SPELLBOOK_ABILITIES_BUTTON, "TOGGLESPELLBOOK");
				else
					self.tooltipText = MicroButtonTooltipText(ABILITYBOOK_BUTTON, "TOGGLEABILITYBOOK");
				end
				GameTooltip_AddNewbieTip(self, self.tooltipText, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_SPELLBOOK);
			</OnEnter>
		</Scripts>
	</Button>
	<Button name="TalentMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="SpellbookMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "Talents");
				self.tooltipText = MicroButtonTooltipText(TALENTS_BUTTON, "TOGGLETALENTS");
				self.newbieText = NEWBIE_TOOLTIP_TALENTS;
				self:RegisterEvent("PLAYER_LEVEL_UP");
				self:RegisterEvent("UPDATE_BINDINGS");
				self:RegisterEvent("UNIT_LEVEL");
				self:RegisterEvent("PLAYER_ENTERING_WORLD");
			</OnLoad>
			<OnClick>
				ToggleTalentFrame();
			</OnClick>
			<OnEvent>
				TalentMicroButton_OnEvent(self, event, ...);
			</OnEvent>
		</Scripts>
	</Button>
	<Button name="AchievementMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="TalentMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "Achievement");
				self:RegisterEvent("PLAYER_ENTERING_WORLD");
			</OnLoad>
			<OnEvent>
				-- Put here to show/hide the achievement button
				AchievementMicroButton_Update();
			</OnEvent>
			<OnClick>
				ToggleAchievementFrame();
			</OnClick>
			<OnEnter>
				self.tooltipText = MicroButtonTooltipText(ACHIEVEMENT_BUTTON, "TOGGLEACHIEVEMENT");
				GameTooltip_AddNewbieTip(self, self.tooltipText, 1.0, 1.0, 1.0, NEWBIE_TOOLTIP_ACHIEVEMENT);
			</OnEnter>
		</Scripts>
	</Button>
	<Button name="QuestLogMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="AchievementMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "Quest");
				self.tooltipText = MicroButtonTooltipText(QUESTLOG_BUTTON, "TOGGLEQUESTLOG");
				self.newbieText = NEWBIE_TOOLTIP_QUESTLOG;
			</OnLoad>
			<OnEvent>
				self.tooltipText = MicroButtonTooltipText(QUESTLOG_BUTTON, "TOGGLEQUESTLOG");
			</OnEvent>
			<OnClick>
				ToggleFrame(QuestLogFrame);
			</OnClick>
		</Scripts>
	</Button>
	<Button name="SocialsMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="QuestLogMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "Socials");
				self.tooltipText = MicroButtonTooltipText(SOCIAL_BUTTON, "TOGGLESOCIAL");
				self.newbieText = NEWBIE_TOOLTIP_SOCIAL;
			</OnLoad>
			<OnEvent>
				self.tooltipText = MicroButtonTooltipText(SOCIAL_BUTTON, "TOGGLESOCIAL");
			</OnEvent>
			<OnClick>
				ToggleFriendsFrame();
			</OnClick>
		</Scripts>
	</Button>
	<Button name="PVPMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="SocialsMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
                <Texture name="$parentTexture">
                    <Size>
                        <AbsDimension x="36" y="36"/>
                    </Size>
                    <Anchors>
                        <Anchor point="TOP">
                            <Offset>
                                <AbsDimension x="6" y="-30"/>
                            </Offset>
                        </Anchor>
                    </Anchors>
                </Texture>
            </Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				self:RegisterEvent("UPDATE_BINDINGS");
				
				self:SetNormalTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Up");
				self:SetPushedTexture("Interface\\Buttons\\UI-MicroButtonCharacter-Down");
				self:SetHighlightTexture("Interface\\Buttons\\UI-MicroButton-Hilight");
				local factionGroup = UnitFactionGroup("player");
				if factionGroup then
					getglobal(self:GetName().."Texture"):SetTexture("Interface\\TargetingFrame\\UI-PVP-"..factionGroup);
				end
				self.tooltipText = MicroButtonTooltipText(PLAYER_V_PLAYER, "TOGGLEPVP");
				self.newbieText = NEWBIE_TOOLTIP_PVP;
			</OnLoad>
			<OnEvent>
				self.tooltipText = MicroButtonTooltipText(PLAYER_V_PLAYER, "TOGGLEPVP");
				self.newbieText = NEWBIE_TOOLTIP_PVP;
			</OnEvent>
			<OnMouseDown>
				if self.down then
					self.down = nil;
					ToggleFrame(PVPFrame);
					return;
				end
				PVPMicroButton_SetPushed();
				self.down = 1;
			</OnMouseDown>
			<OnMouseUp>
				if self.down then
					self.down = nil;
					if MouseIsOver(self) then
						ToggleFrame(PVPFrame);
					else
						UpdateMicroButtons();
					end
					return;
				end
				if self:GetButtonState() == "NORMAL" then
					PVPMicroButton_SetPushed();
					self.down = 1;
				else
					PVPMicroButton_SetNormal();
					self.down = 1;
				end
			</OnMouseUp>
		</Scripts>
	</Button>
	<Button name="LFGMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="PVPMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "LFG");
				self.tooltipText = MicroButtonTooltipText(LFG_BUTTON, "TOGGLELFGPARENT");
				self.newbieText = NEWBIE_TOOLTIP_LFGPARENT;
			</OnLoad>
			<OnEvent>
				self.tooltipText = MicroButtonTooltipText(LFG_BUTTON, "TOGGLELFGPARENT");
				self.newbieText = NEWBIE_TOOLTIP_LFGPARENT;
			</OnEvent>
			<OnClick>
				ToggleLFGParentFrame();
			</OnClick>
		</Scripts>
	</Button>
	<Button name="MainMenuMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="LFGMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
				<Texture name="MainMenuBarPerformanceBar" file="Interface\MainMenuBar\UI-MainMenuBar-PerformanceBar">
					<Size>
						<AbsDimension x="14" y="7"/>
					</Size>
					<Anchors>
						<Anchor point="TOPLEFT" relativeTo="MainMenuMicroButton" relativePoint="TOPLEFT">
							<Offset x="10" y="-34"/>
						</Anchor>
					</Anchors>
				</Texture>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "MainMenu");
				self.tooltipText = MicroButtonTooltipText(MAINMENU_BUTTON, "TOGGLEGAMEMENU");
				self.newbieText = NEWBIE_TOOLTIP_MAINMENU;

				PERFORMANCEBAR_LOW_LATENCY = 300;
				PERFORMANCEBAR_MEDIUM_LATENCY = 600;
				PERFORMANCEBAR_UPDATE_INTERVAL = 10;
				self.hover = nil;
				self.updateInterval = 0;
				self:RegisterForClicks("LeftButtonDown", "RightButtonDown", "LeftButtonUp", "RightButtonUp");
			</OnLoad>
			<OnUpdate>
				if self.updateInterval > 0 then
					self.updateInterval = self.updateInterval - elapsed;
				else
					self.updateInterval = PERFORMANCEBAR_UPDATE_INTERVAL;
					local bandwidthIn, bandwidthOut, latency = GetNetStats();
					if latency > PERFORMANCEBAR_MEDIUM_LATENCY then
						MainMenuBarPerformanceBar:SetVertexColor(1, 0, 0);									
					elseif latency > PERFORMANCEBAR_LOW_LATENCY then
						MainMenuBarPerformanceBar:SetVertexColor(1, 1, 0);
					else
						MainMenuBarPerformanceBar:SetVertexColor(0, 1, 0);
					end
					if self.hover then
						MainMenuBarPerformanceBarFrame_OnEnter(self);
					end
				end
			</OnUpdate>
			<OnEvent>
				self.tooltipText = MicroButtonTooltipText(MAINMENU_BUTTON, "TOGGLEGAMEMENU");
			</OnEvent>
			<OnMouseDown>
				if self.down then
					self.down = nil;
					if not GameMenuFrame:IsShown() then
						CloseMenus();
						CloseAllWindows()
						PlaySound("igMainMenuOpen");
						ShowUIPanel(GameMenuFrame);
					else
						PlaySound("igMainMenuQuit");
						HideUIPanel(GameMenuFrame);
						MainMenuMicroButton_SetNormal();
					end
					if InterfaceOptionsFrame:IsShown() then
						InterfaceOptionsFrameCancel:Click();
					end
					return;
				end
				MainMenuMicroButton_SetPushed();
				self.down = 1;
			</OnMouseDown>
			<OnMouseUp>
				if self.down then
					self.down = nil;
					if MouseIsOver(self) then
						if not GameMenuFrame:IsShown() then
							CloseMenus();
							CloseAllWindows()
							PlaySound("igMainMenuOpen");
							ShowUIPanel(GameMenuFrame);
						else
							PlaySound("igMainMenuQuit");
							HideUIPanel(GameMenuFrame);
							MainMenuMicroButton_SetNormal();
						end
						if InterfaceOptionsFrame:IsShown() then
							InterfaceOptionsFrameCancel:Click();
						end
					else
						UpdateMicroButtons();
					end
					return;
				end
				if self:GetButtonState() == "NORMAL" then
					MainMenuMicroButton_SetPushed();
					self.down = 1;
				else
					MainMenuMicroButton_SetNormal();
					self.down = 1;
				end
			</OnMouseUp>
			
			<OnEnter>
				self.hover = 1;
				self.updateInterval = 0;
			</OnEnter>
			<OnLeave>
				self.hover = nil;
				GameTooltip:Hide();
			</OnLeave>
		</Scripts>
	</Button>
	<Button name="HelpMicroButton" inherits="MainMenuBarMicroButton" parent="MainMenuBarArtFrame" hidden="false">
		<Anchors>
			<Anchor point="BOTTOMLEFT" relativeTo="MainMenuMicroButton" relativePoint="BOTTOMRIGHT">
				<Offset>
					<AbsDimension x="-3" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Scripts>
			<OnLoad>
				LoadMicroButtonTextures(self, "Help");
				self.tooltipText = HELP_BUTTON;
				self.newbieText = NEWBIE_TOOLTIP_HELP;
			</OnLoad>
			<OnClick>
				ToggleHelpFrame();
			</OnClick>
		</Scripts>
	</Button>
</Ui>
