--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--
--|	GypsyMod HotBar - Gypsy_HotBar.lua
--|	Setting initialization
--|	Component initialization
--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--

--= Libraries =--

local color = Gypsy_Color:New();
local utility = Gypsy_Utility:New();
local hotlib = Gypsy_HotLib:New();
local command = Gypsy_Command:New("GYPSY_HOTBAR", "/gypsy_hotbar", "/g_hb", "help");

--= Variables =--

-- Declare the HotBar add-on
GYPSY_HOTBAR = 1;

GYPSY_HOTBAR_VERSION = "1.00";

-- Setup saves table, shortcut table, and player name holder
GYPSY_SAVED_HOTBAR = {};
local saved = nil;
local player = nil;

-- Time between Quick Page mod key checks
local updateTime = 0.2;

-- OmniFrame radio button properties
Gypsy_HotBar_BindingLabelModes = {};
Gypsy_HotBar_BindingLabelModes[1] = {
	["setting"] = "full";
	["label"] = HOTBAR_TEXT:Get("fullLabelModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("fullLabelModeTooltip");
};
Gypsy_HotBar_BindingLabelModes[2] = {
	["setting"] = "stripped";
	["label"] = HOTBAR_TEXT:Get("strippedLabelModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("strippedLabelModeTooltip");
};
Gypsy_HotBar_BindingLabelModes[3] = {
	["setting"] = "hidden";
	["label"] = HOTBAR_TEXT:Get("hiddenLabelModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("hiddenLabelModeTooltip");
};
Gypsy_HotBar_BindingLabelModes[4] = {
	["setting"] = "id";
	["label"] = HOTBAR_TEXT:Get("idLabelModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("idLabelModeTooltip");
};

Gypsy_HotBar_RangeDetectionModes = {};
Gypsy_HotBar_RangeDetectionModes[1] = {
	["setting"] = "full";
	["label"] = HOTBAR_TEXT:Get("fullRangeModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("fullRangeModeTooltip");
};
Gypsy_HotBar_RangeDetectionModes[2] = {
	["setting"] = "label";
	["label"] = HOTBAR_TEXT:Get("labelRangeModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("labelRangeModeTooltip");
};
Gypsy_HotBar_RangeDetectionModes[3] = {
	["setting"] = "button";
	["label"] = HOTBAR_TEXT:Get("buttonRangeModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("buttonRangeModeTooltip");
};
Gypsy_HotBar_RangeDetectionModes[4] = {
	["setting"] = "none";
	["label"] = HOTBAR_TEXT:Get("noneRangeModeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("noneRangeModeTooltip");
};

Gypsy_HotBar_PagingModes = {};
Gypsy_HotBar_PagingModes[1] = {
	["setting"] = "disallow";
	["label"] = HOTBAR_TEXT:Get("zeroLabel");
	["tooltip"] = HOTBAR_TEXT:Get("zeroTooltip");
};
Gypsy_HotBar_PagingModes[2] = {
	["setting"] = "1";
	["label"] = HOTBAR_TEXT:Get("oneLabel");
	["tooltip"] = HOTBAR_TEXT:Get("oneTooltip");
};
Gypsy_HotBar_PagingModes[3] = {
	["setting"] = "2";
	["label"] = HOTBAR_TEXT:Get("twoLabel");
	["tooltip"] = HOTBAR_TEXT:Get("twoTooltip");
};
Gypsy_HotBar_PagingModes[4] = {
	["setting"] = "3";
	["label"] = HOTBAR_TEXT:Get("threeLabel");
	["tooltip"] = HOTBAR_TEXT:Get("threeTooltip");
};

Gypsy_HotBar_QuickPageModKeys = {};
Gypsy_HotBar_QuickPageModKeys[1] = {
	["setting"] = "Shift";
	["label"] = HOTBAR_TEXT:Get("shift");
	["tooltip"] = HOTBAR_TEXT:Get("shiftTooltip");
};
Gypsy_HotBar_QuickPageModKeys[2] = {
	["setting"] = "Control";
	["label"] = HOTBAR_TEXT:Get("control");
	["tooltip"] = HOTBAR_TEXT:Get("controlTooltip");
};
Gypsy_HotBar_QuickPageModKeys[3] = {
	["setting"] = "Alt";
	["label"] = HOTBAR_TEXT:Get("alt");
	["tooltip"] = HOTBAR_TEXT:Get("altTooltip");
};

--= HotBar Functions =--

function Gypsy_HotBar_OnLoad ()
	this:RegisterEvent("CVAR_UPDATE");
	this:RegisterEvent("PLAYER_ENTERING_WORLD");
end

function Gypsy_HotBar_OnEvent (event)
	if (event == "PLAYER_ENTERING_WORLD") then
		this:UnregisterEvent(event);
		
		player = UnitName("player").." - "..GetRealmName();

		-- Default settings
		if (not GYPSY_SAVED_HOTBAR[player]) then
			GYPSY_SAVED_HOTBAR[player] = {
				-- General
				["enabled"] = 1;
				["locked"] = 0;
				["gap"] = 2;
				["setScale"] = 0;
				["size"] = 34;
				["bindingLabelMode"] = "button";
				["showMacroText"] = 1;
				["showCountText"] = 1;
				["showPlaceholders"] = 1;
				-- Paging
				["pagingMode"] = "1";
				["useQuickPage"] = 0;
				["quickPageSnapBack"] = 1;
				["useQuickPageModKey"] = 0;
				["quickPageModKey"] = "Shift";
				-- Action buttons
				["showEquippedBorder"] = 1;
				["useIndicator"] = 0;
				["useUpdateTimer"] = 0;
				["updateTime"] = TOOLTIP_UPDATE_TIME;
				["rangeDetectionMode"] = "full";
				-- Bag buttons
				["showAmmoCount"] = 1;
				-- Pet action buttons
				["showPetActionLabels"] = 1;
				-- Special action buttons
				["showSpecialActionLabels"] = 1;
				-- Components
				["actionbar1_shown"] = 1;
				["actionbar1_locked"] = 0;
				["actionbar1_orient"] = "HORI";
				["actionbar1_numButtons"] = 12;
				["actionbar1_buttonSize"] = 34;
				["actionbar1_allowPaging"] = 1;
				["actionbar2_shown"] = 1;
				["actionbar2_locked"] = 0;
				["actionbar2_docked"] = 1;
				["actionbar2_orient"] = "HORI";
				["actionbar2_numButtons"] = 12;
				["actionbar2_buttonSize"] = 34;
				["actionbar2_allowPaging"] = 1;
				["actionbar3_shown"] = 1;
				["actionbar3_locked"] = 0;
				["actionbar3_docked"] = 1;
				["actionbar3_orient"] = "HORI";
				["actionbar3_numButtons"] = 12;
				["actionbar3_buttonSize"] = 34;
				["actionbar3_allowPaging"] = 1;
				["actionbar4_shown"] = 1;
				["actionbar4_locked"] = 0;
				["actionbar4_docked"] = 1;
				["actionbar4_orient"] = "HORI";
				["actionbar4_numButtons"] = 12;
				["actionbar4_buttonSize"] = 34;
				["actionbar4_allowPaging"] = 1;
				["actionbar5_shown"] = 0;
				["actionbar5_locked"] = 0;
				["actionbar5_docked"] = 1;
				["actionbar5_orient"] = "HORI";
				["actionbar5_numButtons"] = 12;
				["actionbar5_buttonSize"] = 34;
				["actionbar5_allowPaging"] = 1;
				["actionbar6_shown"] = 0;
				["actionbar6_locked"] = 0;
				["actionbar6_docked"] = 1;
				["actionbar6_orient"] = "HORI";
				["actionbar6_numButtons"] = 12;
				["actionbar6_buttonSize"] = 34;
				["actionbar6_allowPaging"] = 1;
				["bagbar_shown"] = 0;
				["bagbar_locked"] = 0;
				["bagbar_docked"] = 1;
				["bagbar_orient"] = "HORI";
				["bagbar_backpackOnly"] = 0;
				["bagbar_buttonSize"] = 34;
				["menubar_shown"] = 0;
				["menubar_locked"] = 0;
				["menubar_orient"] = "HORI";
				["menubar_buttonSize"] = 34;
				["performancebar_shown"] = 0;
				["performancebar_locked"] = 0;
				["performancebar_docked"] = 1;
				["performancebar_orient"] = "VERT";
				["petactionbar_shown"] = 1;
				["petactionbar_locked"] = 0;
				["petactionbar_docked"] = 1;
				["petactionbar_orient"] = "HORI";
				["petactionbar_buttonSize"] = 30;
				["specialactionbar_shown"] = 1;
				["specialactionbar_locked"] = 0;
				["specialactionbar_docked"] = 1;
				["specialactionbar_orient"] = "HORI";
				["specialactionbar_buttonSize"] = 30;
			};
		end

		-- Component initializations, responsible for getting settings and applying them
		Gypsy_HotBar_Initialize(player);
		Gypsy_ActionBar_Initialize(player);
		Gypsy_BagBar_Initialize(player);
		Gypsy_MenuBar_Initialize(player);
		Gypsy_PerformanceBar_Initialize(player);
		Gypsy_PetActionBar_Initialize(player);
		Gypsy_SpecialActionBar_Initialize(player);

		-- OmniFrame setup
		if (GYPSY_SHELL and GYPSY_SHELL == 1) then
			Gypsy_HotBar_Setup();
		end
		return;
	end
	if (event == "CVAR_UPDATE" and (arg1 == "gxColorBits" or arg1 == "gxDepthBits" or arg1 == "gxRefresh" or arg1 == "gxResolution")) then
		Gypsy_HotBar_ScaleAll();
		return;
	end
end

-- Quick Page mod key watching, does not run when Quick Page is disabled
function Gypsy_HotBar_OnUpdate (elapsed)
	this.updateTime = this.updateTime - elapsed;
	
	if (this.updateTime < 0) then
		this.updateTime = updateTime;
		
		if (not this.keyDown and
			((saved.quickPageModKey == "Shift" and IsShiftKeyDown()) or
			(saved.quickPageModKey == "Control" and IsControlKeyDown()) or
			(saved.quickPageModKey == "Alt" and IsAltKeyDown()))) then
			Gypsy_ActionBar_QuickPage("down", 1);
			this.keyDown = 1;
		elseif (this.keyDown and
				((saved.quickPageModKey == "Shift" and not IsShiftKeyDown()) or
				(saved.quickPageModKey == "Control" and not IsControlKeyDown()) or
				(saved.quickPageModKey == "Alt" and not IsAltKeyDown()))) then
			this.keyDown = nil;
			Gypsy_ActionBar_QuickPage("up", 1);
		end
	end		
end

-- Copy saves table and run an update
function Gypsy_HotBar_Initialize (player)
	saved = GYPSY_SAVED_HOTBAR[player];
	
	-- Initialize lock button properties
	Gypsy_HotBar_LockButton.locked = saved.locked;
	Gypsy_HotBar_LockButton.menuHead = HOTBAR_TEXT:Get("individualLocking");
	Gypsy_HotBar_LockButton.tooltip = {};
	Gypsy_HotBar_LockButton.tooltip.func = function ()
		local body = HOTBAR_TEXT:Get("lockBody1");
		
		if (this:GetChecked()) then
			body = body..HOTBAR_TEXT:Get("unlock");
		else
			body = body..HOTBAR_TEXT:Get("lock");
		end
		
		body = body..HOTBAR_TEXT:Get("lockBody2");
		
		return HOTBAR_TEXT:Get("lockTitle"), body;
	end;

	Gypsy_HotBar_Update();
end

-- Hook to throw onto the end of the multi actionbar update
local function multiActionBar_Update_Hook ()
	MultiBarBottomLeft:Hide();
	MultiBarBottomRight:Hide();
	MultiBarRight:Hide();
	MultiBarLeft:Hide();	
end
	
-- Updating anything that changes per-settings involving the entire add-on
function Gypsy_HotBar_Update ()
	if (saved.enabled == 1) then
		if (saved.useQuickPage == 1 and saved.useQuickPageModKey == 1) then
			Gypsy_HotBar:Show();
			Gypsy_HotBar.updateTime = updateTime;
		else
			Gypsy_HotBar:Hide();
		end
		MainMenuBar:Hide();
		utility:Hook("after", "MultiActionBar_Update", multiActionBar_Update_Hook);
	else
		Gypsy_HotBar:Hide();
		MainMenuBar:Show();
		utility:UnHook("MultiActionBar_Update");
	end
	
	MultiActionBar_Update();
	
	if (saved.enabled == 0) then
		ShapeshiftBar_UpdatePosition();
		PetActionBar_UpdatePosition();
	end
end

-- Update each component
function Gypsy_HotBar_UpdateAll ()
	Gypsy_HotBar_Update();
	Gypsy_ActionBar_Update();
	Gypsy_BagBar_Update();
	Gypsy_MenuBar_Update();
	Gypsy_PerformanceBar_Update();
	Gypsy_PetActionBar_Update();
	Gypsy_SpecialActionBar_Update();
end

-- Dirty scaling workaround for now
function Gypsy_HotBar_ScaleAll ()
	Gypsy_ActionBar_Scale();
	Gypsy_BagBar_Scale();
	Gypsy_MenuBar_Scale();
	Gypsy_PetActionBar_Scale();
	Gypsy_SpecialActionBar_Scale();
end

-- Whole-add-on specific reset
function Gypsy_HotBar_Reset ()
	
end

-- Reset each component
function Gypsy_HotBar_ResetAll ()
	Gypsy_HotBar_Reset();
	Gypsy_ActionBar_Reset();
	Gypsy_BagBar_Reset();
	Gypsy_MenuBar_Reset();
	Gypsy_PerformanceBar_Reset();
	Gypsy_PetActionBar_Reset();
	Gypsy_SpecialActionBar_Reset();
end

-- OmniFrame options and help registrations
function Gypsy_HotBar_Setup ()
	-- HotBar category
	local args = {};
	args.name = "hotbar_category";
	args.save = "GYPSY_SAVED_HOTBAR";
	args.usechar = "1";
	args.char = player;
	args.resetfunc = "Gypsy_HotBar_ResetAll";
	args.label = HOTBAR_TEXT:Get("hotbar");
	args.tooltip = HOTBAR_TEXT:Get("tabTooltip");
	Gypsy_OmniAddCategory(args);
	
	--= Options =--
	
	-- General
	args = {};
	args.name = "hotbar_title";
	args.regtype = "headline";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("title");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_enabled";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.var = "enabled";
	args.func = "Gypsy_HotBar_UpdateAll";
	args.label = HOTBAR_TEXT:Get("enable");
	args.tooltip = HOTBAR_TEXT:Get("enableTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_buttonheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("buttonHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("buttonHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_showplaceholders";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.var = "showPlaceholders";
	args.func = "Gypsy_HotBar_UpdateButtonGrids";
	args.depend = "hotbar_enabled";
	args.label = HOTBAR_TEXT:Get("showPlaceholdersLabel");
	args.tooltip = HOTBAR_TEXT:Get("showPlaceholdersTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_bindinglabelmode_headline";
	args.regtype = "headline";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.color = color.white.rgb;
	args.label = HOTBAR_TEXT:Get("bindingLabelHeadline");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_bindinglabelmode";
	args.regtype = "radiobutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "bindingLabelMode";
	args.settings = "Gypsy_HotBar_BindingLabelModes";
	args.func = "Gypsy_HotBar_UpdateBindingLabels";
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_buttongap";
	args.regtype = "slider";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "gap";
	args.func = "Gypsy_HotBar_UpdateAll";
	args.slidermin = 2;
	args.slidermax = 8;
	args.sliderstep = 2;
	args.sliderunit = HOTBAR_TEXT:Get("px");
	args.label = HOTBAR_TEXT:Get("gapLabel");
	args.tooltip = HOTBAR_TEXT:Get("gapTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_setscale";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "setScale";
	args.func = "Gypsy_HotBar_UpdateAll";
	args.label = HOTBAR_TEXT:Get("setScaleLabel");
	args.tooltip = HOTBAR_TEXT:Get("setScaleTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_scalesize";
	args.regtype = "slider";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_setscale";
	args.var = "size";
	args.func = "Gypsy_HotBar_UpdateAll";
	args.slidermin = 18;
	args.slidermax = 48;
	args.sliderstep = 6;
	args.sliderunit = HOTBAR_TEXT:Get("px");
	args.label = HOTBAR_TEXT:Get("scaleSizeLabel");
	args.tooltip = HOTBAR_TEXT:Get("scaleSizeTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_actionbuttonheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("actionButtonHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("actionButtonHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_showmacrotext";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "showMacroText";
	args.func = "Gypsy_ActionBar_UpdateButtons";
	args.label = HOTBAR_TEXT:Get("showMacroTextLabel");
	args.tooltip = HOTBAR_TEXT:Get("showMacroTextTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_showcounttext";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "showCountText";
	args.func = "Gypsy_ActionBar_UpdateButtonCounts";
	args.label = HOTBAR_TEXT:Get("countTextLabel");
	args.tooltip = HOTBAR_TEXT:Get("countTextTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_showequippedborder";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "showEquippedBorder";
	args.func = "Gypsy_ActionBar_UpdateButtons";
	args.label = HOTBAR_TEXT:Get("equippedBorderLabel");
	args.tooltip = HOTBAR_TEXT:Get("equippedBorderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_enableindicator";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "useIndicator";
	args.func = "Gypsy_ActionBar_UpdateButtons";
	args.label = HOTBAR_TEXT:Get("indicatorLabel");
	args.tooltip = HOTBAR_TEXT:Get("indicatorTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_useupdatetimer";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "useUpdateTimer";
	args.func = "Gypsy_ActionBar_UpdateButtons";
	args.label = HOTBAR_TEXT:Get("useUpdateTimerLabel");
	args.tooltip = HOTBAR_TEXT:Get("useUpdateTimerTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_updatetimer";
	args.regtype = "slider";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_useupdatetimer";
	args.var = "updateTime";
	args.func = "Gypsy_ActionBar_UpdateButtons";
	args.slidermin = TOOLTIP_UPDATE_TIME;
	args.slidermax = 2;
	args.sliderstep = 0.2;
	args.sliderunit = "";
	args.label = HOTBAR_TEXT:Get("updateTimerLabel");
	args.tooltip = HOTBAR_TEXT:Get("updateTimerTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_rangedetectionmode_headline";
	args.regtype = "headline";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.color = color.white.rgb;
	args.label = HOTBAR_TEXT:Get("rangeDetectionHeadline");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_rangedetectionmode";
	args.regtype = "radiobutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "rangeDetectionMode";
	args.settings = "Gypsy_HotBar_RangeDetectionModes";
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_bagbuttonheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.label = HOTBAR_TEXT:Get("bagButtonHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("bagButtonHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_showammocount";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "showAmmoCount";
	args.func = "Gypsy_BagBar_UpdateButtonCounts";
	args.label = HOTBAR_TEXT:Get("ammoCountLabel");
	args.tooltip = HOTBAR_TEXT:Get("ammoCountTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_petactionbuttonheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("petActionButtonHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("petActionButtonHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_petactionbuttonshowlabels";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "showPetActionLabels";
	args.func = "Gypsy_PetActionBar_UpdateBindings";
	args.label = HOTBAR_TEXT:Get("petActionLabelLabel");
	args.tooltip = HOTBAR_TEXT:Get("petActionLabelTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_specialactionbuttonheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("specialActionButtonHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("specialActionButtonHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_specialactionbuttonshowlabels";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "showSpecialActionLabels";
	args.func = "Gypsy_SpecialActionBar_UpdateBindings";
	args.label = HOTBAR_TEXT:Get("specialActionLabelLabel");
	args.tooltip = HOTBAR_TEXT:Get("specialActionLabelTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_performancebarheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("performanceBarHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("performanceBarHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_performancebarshow";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "performancebar_shown";
	args.func = "Gypsy_PerformanceBar_Update";
	args.label = HOTBAR_TEXT:Get("performanceBarShowLabel");
	args.tooltip = HOTBAR_TEXT:Get("performanceBarShowTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_actionbarheader";
	args.regtype = "header";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.label = HOTBAR_TEXT:Get("actionBarHeaderLabel");
	args.tooltip = HOTBAR_TEXT:Get("actionBarHeaderTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_restoreactionbar1";
	args.regtype = "pushbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.func = "Gypsy_ActionBar1_Show";
	args.label = HOTBAR_TEXT:Get("showActionBar1Label");
	args.tooltip = HOTBAR_TEXT:Get("showActionBar1Tooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_pagingmodeheadline";
	args.regtype = "headline";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.color = color.white.rgb;
	args.label = HOTBAR_TEXT:Get("pagingModeHeadline");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_pagingmode";
	args.regtype = "radiobutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "pagingMode";
	args.func = "Gypsy_ActionBar_UpdatePagingMode";
	args.settings = "Gypsy_HotBar_PagingModes";
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_quickpageheadline";
	args.regtype = "headline";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.color = color.white.rgb;
	args.label = HOTBAR_TEXT:Get("quickPageHeadline");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_enablequickpage";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enabled";
	args.var = "useQuickPage";
	args.label = HOTBAR_TEXT:Get("enableQuickPageLabel");
	args.tooltip = HOTBAR_TEXT:Get("enableQuickPageTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_enablequickpagesnapback";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enablequickpage";
	args.var = "quickPageSnapBack";
	args.label = HOTBAR_TEXT:Get("quickPageSnapBackLabel");
	args.tooltip = HOTBAR_TEXT:Get("quickPageSnapBackTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_enablequickpagemodkey";
	args.regtype = "checkbutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enablequickpage";
	args.var = "useQuickPageModKey";
	args.func = "Gypsy_HotBar_Update";
	args.label = HOTBAR_TEXT:Get("quickPageModKeyLabel");
	args.tooltip = HOTBAR_TEXT:Get("quickPageModKeyTooltip");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_quickpagemodkeyheadline";
	args.regtype = "headline";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enablequickpagemodkey";
	args.color = color.white.rgb;
	args.label = HOTBAR_TEXT:Get("modKeyHeadline");
	Gypsy_OmniRegister(args);
	args = {};
	args.name = "hotbar_quickpagemodkeymode";
	args.regtype = "radiobutton";
	args.disptype = "options";
	args.parent = "hotbar_category";
	args.depend = "hotbar_enablequickpagemodkey";
	args.var = "quickPageModKey";
	args.settings = "Gypsy_HotBar_QuickPageModKeys";
	args.func = "Gypsy_HotBar_Update";
	Gypsy_OmniRegister(args);
end

function Gypsy_HotBar_UpdateButtonGrids ()
	Gypsy_ActionBar_UpdateButtonGrids();
	Gypsy_PetActionBar.showgrid = saved.showPlaceholders;
	Gypsy_PetActionBar_UpdateState();
end

function Gypsy_HotBar_UpdateBindingLabels ()
	hotlib:UpdateGroupHotkey("Gypsy_ActionButton", 1, 72);
	Gypsy_SpecialActionBar_UpdateBindings();
	Gypsy_PetActionBar_UpdateBindings();
end

--= Scale Watch Functions =--

function Gypsy_HotBar_ScaleWatchFrame_OnLoad ()
	this.updateTime = 5;
	this.updateTimer = 5;
end

function Gypsy_HotBar_ScaleWatchFrame_OnUpdate (elapsed)
	this.updateTime = this.updateTime - elapsed;
	
	if (this.updateTime < 0) then
		this.updateTime = this.updateTimer;
		
		Gypsy_HotBar_CheckScaling();
	end		
end

function Gypsy_HotBar_CheckScaling ()
	if (saved.setScale == 1) then
		if (Gypsy_ActionButton1:GetScale() ~= Gypsy_ActionButton1.scale) then
			Gypsy_HotBar_ScaleAll();
		end
	else
		local doScale = nil;
		
		if (Gypsy_ActionButton1:GetScale() ~= Gypsy_ActionButton1.scale) then
			doScale = 1;
		end
		
		if (Gypsy_ActionButton13:GetScale() ~= Gypsy_ActionButton13.scale) then
			doScale = 1;
		end
		
		if (Gypsy_ActionButton25:GetScale() ~= Gypsy_ActionButton13.scale) then
			doScale = 1;
		end
		
		if (Gypsy_ActionButton37:GetScale() ~= Gypsy_ActionButton13.scale) then
			doScale = 1;
		end
		
		if (Gypsy_ActionButton49:GetScale() ~= Gypsy_ActionButton13.scale) then
			doScale = 1;
		end
		
		if (Gypsy_ActionButton61:GetScale() ~= Gypsy_ActionButton13.scale) then
			doScale = 1;
		end
		
		if (Gypsy_PetActionButton1:GetScale() ~= Gypsy_PetActionButton1.scale) then
			doScale = 1;
		end
		
		if (Gypsy_SpecialActionButton1:GetScale() ~= Gypsy_SpecialActionButton1.scale) then
			doScale = 1;
		end
		
		if (Gypsy_CharacterMenuButton:GetScale() ~= Gypsy_CharacterMenuButton.scale) then
			doScale = 1;
		end
		
		if (Gypsy_BackpackButton:GetScale() ~= Gypsy_BackpackButton.scale) then
			doScale = 1;
		end
		
		if (doScale) then
			Gypsy_HotBar_ScaleAll();
		end
	end
end

--= Slash Command Functions =--

command:Add("help", function (msg)
	utility:Print(color.orange.code..HOTBAR_TEXT:Get("validCommands")..color.close..SLASH_GYPSY_HOTBAR1..color.orange.code.." - "..color.close..SLASH_GYPSY_HOTBAR2);
	utility:Print(color.orange.code..HOTBAR_TEXT:Get("specificParameters")..color.close..SLASH_GYPSY_HOTBAR1..color.yellow.code..HOTBAR_TEXT:Get("command")..color.close);
	local text = "   "..color.yellow.code;
	for i,v in command.handlers do
		text = text..i.. "  ";
	end
	text = text..color.close;
	utility:Print(text);
end);

command:Add("enable", function (msg)
	if (not msg or (msg and msg ~= "help")) then
		if (saved.enabled == 0) then
			saved.enabled = 1;
			Gypsy_HotBar_UpdateAll();
			utility:Print(HOTBAR_TEXT:Get("enabledConfirmation"));
		else
			utility:Print(HOTBAR_TEXT:Get("alreadyEnabled"));
		end
	else
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("enableHelpHead").."\nenable"..color.close..HOTBAR_TEXT:Get("enableHelp"));
	end
end);

command:Add("disable", function (msg)
	if (not msg or (msg and msg ~= "help")) then
		if (saved.enabled == 1) then
			saved.enabled = 0;
			Gypsy_HotBar_UpdateAll();
			utility:Print(HOTBAR_TEXT:Get("disabledConfirmation"));
		else
			utility:Print(HOTBAR_TEXT:Get("alreadyDisabled"));
		end
	else
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("disableHelpHead").."\ndisable"..color.close..HOTBAR_TEXT:Get("disableHelp"));
	end
end);

command:Add("placeholders", function (msg)
	local toggle;
	
	if (not msg) then
		if (saved.showPlaceholders == 1) then
			toggle = 0;
			utility:Print(HOTBAR_TEXT:Get("placeholderHideConfirm"));
		else
			toggle = 1;
			utility:Print(HOTBAR_TEXT:Get("placeholderShowConfirm"));
		end
	else
		if (msg == "help") then
			utility:Print(color.yellow.code..HOTBAR_TEXT:Get("placeholderHelpHead").."\nplaceholder"..color.close..HOTBAR_TEXT:Get("placeholderHelp"));
			return;
		end
		
		if (msg == "1" or msg == "on" or msg == "show") then
			toggle = 1;
			utility:Print(HOTBAR_TEXT:Get("placeholderShowConfirm"));
		elseif (msg == "0" or msg == "off" or msg == "hide") then
			toggle = 0;
			utility:Print(HOTBAR_TEXT:Get("placeholderHideConfirm"));
		else
			utility:Print(color.yellow.code..HOTBAR_TEXT:Get("placeholderHelpHead").."\nplaceholder"..color.close..HOTBAR_TEXT:Get("placeholderHelp"));	
			return;
		end
	end
	
	if (toggle) then
		saved.showPlaceholders = toggle;
		Gypsy_HotBar_UpdateButtonGrids();
	end
end);
		
command:Add("bindinglabelmode", function (msg)
	if (not msg or (msg ~= "full" and msg ~= "stripped" and msg ~= "id" and msg ~= "hidden")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("bindinglabelmodeHelpHead").."\nbindinglabelmode"..color.close..HOTBAR_TEXT:Get("bindinglabelmodeHelp"));
	else
		saved.bindingLabelMode = msg;
		Gypsy_HotBar_UpdateBindingLabels();
		utility:Print(HOTBAR_TEXT:Get("bindinglabelmodeConfirm")..msg);
	end
end);

command:Add("buttonpadding", function (msg)
	if (not msg or (msg ~= "2" and msg ~= "4" and msg ~= "6" and msg ~= "8")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("buttonpaddingHelpHead").."\nbuttonpadding"..color.close..HOTBAR_TEXT:Get("buttonpaddingHelp"));
	else
		saved.gap = tonumber(msg);
		Gypsy_HotBar_UpdateAll();
		utility:Print(HOTBAR_TEXT:Get("buttonpaddingConfirm")..msg);
	end
end);

command:Add("setbuttonsize", function (msg)
	if (not msg or (msg ~= "1" and msg ~= "0" and msg ~= "18" and msg ~= "24" and msg ~= "30" and msg ~= "36" and msg ~= "42" and msg ~= "48")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("setbuttonsizeHelpHead").."\nsetbuttonsize"..color.close..HOTBAR_TEXT:Get("setbuttonsizeHelp"));
	else
		if (msg == "1") then
			saved.setScale = 1;
			Gypsy_HotBar_UpdateAll();
			utility:Print(HOTBAR_TEXT:Get("setbuttonsizeConfirmOn")..saved.size);
		elseif (msg == "0") then
			saved.setScale = 0;
			Gypsy_HotBar_UpdateAll();
			utility:Print(HOTBAR_TEXT:Get("setbuttonsizeConfirmOff"));
		elseif (saved.setScale == 1) then
			saved.size = msg;
			Gypsy_HotBar_UpdateAll();
			utility:Print(HOTBAR_TEXT:Get("setbuttonsizeConfirmSize")..msg);
		else
			utility:Print(HOTBAR_TEXT:Get("setbuttonsizeConfirmError"));
		end
	end	
end);

command:Add("showmacrotext", function (msg)
	if (not msg or (msg ~= "1" and msg ~= "0" and msg ~= "show" and msg ~= "hide")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("showmacrotextHelpHead").."\nshowmacrotext"..color.close..HOTBAR_TEXT:Get("showmacrotextHelp"));
	else
		if (msg == "1" or msg == "show") then
			saved.showMacroText = 1;
			Gypsy_ActionBar_UpdateButtons();
			utility:Print(HOTBAR_TEXT:Get("showmacrotextConfirmOn"));
		elseif (msg == "0" or msg == "hide") then
			saved.showMacroText = 0;
			Gypsy_ActionBar_UpdateButtons();
			utility:Print(HOTBAR_TEXT:Get("showmacrotextConfirmOff"));
		end
	end
end);

command:Add("showcounttext", function (msg)
	if (not msg or (msg ~= "1" and msg ~= "0" and msg ~= "show" and msg ~= "hide")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("showcounttextHelpHead").."\nshowcounttext"..color.close..HOTBAR_TEXT:Get("showcounttextHelp"));
	else
		if (msg == "1" or msg == "show") then
			saved.showCountText = 1;
			Gypsy_ActionBar_UpdateButtonCounts();
			utility:Print(HOTBAR_TEXT:Get("showcounttextConfirmOn"));
		elseif (msg == "0" or msg == "hide") then
			saved.showCountText = 0;
			Gypsy_ActionBar_UpdateButtonCounts();
			utility:Print(HOTBAR_TEXT:Get("showcounttextConfirmOff"));
		end
	end
end);

command:Add("usageindicator", function (msg)
	if (not msg or (msg ~= "1" and msg ~= "enable" and msg ~= "0" and msg ~= "disable")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("usageindicatorHelpHead").."\nusageindicator"..color.close..HOTBAR_TEXT:Get("usageindicatorHelp"));
	else
		if (msg == "1" or msg == "enable") then
			saved.useIndicator = 1;
			Gypsy_ActionBar_UpdateButtons();
			utility:Print(HOTBAR_TEXT:Get("usageindicatorConfirmOn"));
		elseif (msg == "0" or msg == "disable") then
			saved.useIndicator = 0;
			Gypsy_ActionBar_UpdateButtons();
			utility:Print(HOTBAR_TEXT:Get("usageindicatorConfirmOff"));
		end
	end
end);

command:Add("rangedetectionmode", function (msg)
	if (not msg or (msg ~= "full" and msg ~= "label" and msg ~= "button" and msg ~= "none")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("rangedetectionmodeHelpHead").."\nrangedetectionmode"..color.close..HOTBAR_TEXT:Get("rangedetectionmodeHelp"));
	else
		saved.rangeDetectionmode = msg;
		utility:Print(HOTBAR_TEXT:Get("rangedetectionmodeConfirm")..msg);
	end
end);

command:Add("showammocount", function (msg)
	if (not msg or (msg ~= "1" and msg ~= "0" and msg ~= "show" and msg ~= "hide")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("showammocountHelpHead").."\nshowammocount"..color.close..HOTBAR_TEXT:Get("showammocountHelp"));
	else
		if (msg == "1" or msg == "show") then
			saved.showAmmoCount = 1;
			utility:Print(HOTBAR_TEXT:Get("showammocountConfirmOn"));
		elseif (msg == "0" or msg == "hide") then
			saved.showAmmoCount = 0;
			utility:Print(HOTBAR_TEXT:Get("showammocountConfirmOff"));
		end
		Gypsy_BagBar_UpdateButtonCounts();
	end
end);

command:Add("togglepetbindings", function (msg)
	if (msg and (msg ~= "1" and msg ~= "show" and msg ~= "0" and msg ~= "hide")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("togglepetbindingsHelpHead").."\ntogglepetbindings"..color.close..HOTBAR_TEXT:Get("togglepetbindingsHelp"));
	else
		local toggle;
		
		if (not msg) then
			if (saved.showPetActionLabels == 1) then
				toggle = 0;
			else
				toggle = 1;
			end
		else
			if (msg == "1" or msg == "show") then
				toggle = 1;
			elseif (msg == "0" or msg == "hide") then
				toggle = 0;
			end
		end
		
		if (toggle == 1) then
			saved.showPetActionLabels = 1;
			utility:Print(HOTBAR_TEXT:Get("togglepetbindingsConfirmOn"));
		else
			saved.showPetActionLabels = 0;
			utility:Print(HOTBAR_TEXT:Get("togglepetbindingsConfirmOff"));
		end
		
		Gypsy_PetActionBar_UpdateBindings();
	end
end);

command:Add("togglespecialactionbindings", function (msg)
	if (msg and (msg ~= "1" and msg ~= "show" and msg ~= "0" and msg ~= "hide")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("togglespecialactionbindingsHelpHead").."\ntogglespecialactionbindings"..color.close..HOTBAR_TEXT:Get("togglespecialactionbindingsHelp"));
	else
		local toggle;
		
		if (not msg) then
			if (saved.showSpecialActionLabels == 1) then
				toggle = 0;
			else
				toggle = 1;
			end
		else
			if (msg == "1" or msg == "show") then
				toggle = 1;
			elseif (msg == "0" or msg == "hide") then
				toggle = 0;
			end
		end
		
		if (toggle == 1) then
			saved.showSpecialActionLabels = 1;
			utility:Print(HOTBAR_TEXT:Get("togglespecialactionbindingsConfirmOn"));
		else
			saved.showSpecialActionLabels = 0;
			utility:Print(HOTBAR_TEXT:Get("togglespecialactionbindingsConfirmOff"));
		end
		
		Gypsy_SpecialActionBar_UpdateBindings();
	end
end);

command:Add("toggleperformancebar", function (msg)
	if (msg and (msg ~= "1" and msg ~= "show" and msg ~= "0" and msg ~= "hide")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("toggleperformancebarHelpHead").."\ntoggleperformancebar"..color.close..HOTBAR_TEXT:Get("toggleperformancebarHelp"));
	else
		local toggle;
		
		if (not msg) then
			if (saved.performancebar_shown == 1) then
				toggle = 0;
			else
				toggle = 1;
			end
		else
			if (msg == "1" or msg == "show") then
				toggle = 1;
			elseif (msg == "0" or msg == "hide") then
				toggle = 0;
			end
		end
		
		if (toggle == 1) then
			saved.performancebar_shown = 1;
			utility:Print(HOTBAR_TEXT:Get("toggleperformancebarConfirmOn"));
		else
			saved.performancebar_shown = 0;
			utility:Print(HOTBAR_TEXT:Get("toggleperformancebarConfirmOff"));
		end
		
		Gypsy_PerformanceBar_Update();
	end
end);

command:Add("showactionbar1", function (msg)
	if (msg and msg == "help") then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("showactionbar1HelpHead").."\nshowactionbar1"..color.close..HOTBAR_TEXT:Get("showactionbar1Help"));
	else
		if (saved.actionbar1_shown == 1) then
			utility:Print(HOTBAR_TEXT:Get("showactionbar1ConfirmError"));
		else
			utility:Print(HOTBAR_TEXT:Get("showactionbar1ConfirmShow"));
		end
		
		Gypsy_ActionBar1_Show();
	end
end);

command:Add("pagingmode", function (msg)
	if (not msg or (msg ~= "0" and msg ~= "1" and msg ~= "2" and msg ~= "3")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("pagingmodeHelpHead").."\npagingmode"..color.close..HOTBAR_TEXT:Get("pagingmodeHelp"));
	else
		saved.pagingMode = tonumber(msg);
		
		utility:Print(HOTBAR_TEXT:Get("pagingmodeConfirm")..msg);
	end
end);

command:Add("togglequickpage", function (msg)
	if (msg and (msg ~= "1" and msg ~= "on" and msg ~= "0" and msg ~= "off")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("togglequickpageHelpHead").."\ntogglequickpage"..color.close..HOTBAR_TEXT:Get("togglequickpageHelp"));
	else
		local toggle;
		
		if (not msg) then
			if (saved.useQuickPage == 1) then
				toggle = 0;
			else
				toggle = 1;
			end
		else
			if (msg == "1" or msg == "on") then
				toggle = 1;
			else
				toggle = 0;
			end
		end
		
		if (toggle == 1) then
			saved.useQuickPage = 1;
			utility:Print(HOTBAR_TEXT:Get("togglequickpageConfirmOn"));
		else
			saved.useQuickPage = 0;
			utility:Print(HOTBAR_TEXT:Get("togglequickpageConfirmOff"));
		end
		
		Gypsy_HotBar_Update();
	end
end);

command:Add("togglesnapback", function (msg)
	if (msg and (msg ~= "1" and msg ~= "on" and msg ~= "0" and msg ~= "off")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("togglesnapbackHelpHead").."\ntogglesnapback"..color.close..HOTBAR_TEXT:Get("togglesnapbackHelp"));
	else
		local toggle;
		
		if (not msg) then	
			if (saved.quickPageSnapBack == 1) then
				toggle = 0;
			else
				toggle = 1;
			end
		else
			if (msg == "1" or msg == "on") then
				toggle = 1;
			else
				toggle = 0;
			end
		end
		
		if (toggle == 1) then
			saved.quickPageSnapBack = 1;
			utility:Print(HOTBAR_TEXT:Get("togglesnapbackConfirmOn"));
		else
			saved.quickPageSnapBack = 0;
			utility:Print(HOTBAR_TEXT:Get("togglesnapbackConfirmOff"));
		end
	end
end);

command:Add("quickpagemodkey", function (msg)
	if (not msg or (msg ~= "1" and msg ~= "0" and msg ~= "shift" and msg ~= "control" and msg ~= "alt")) then
		utility:Print(color.yellow.code..HOTBAR_TEXT:Get("quickpagemodkeyHelpHead").."\nquickpagemodkey"..color.close..HOTBAR_TEXT:Get("quickpagemodkeyHelp"));
	else
		if (msg == "1") then
			saved.useQuickPageModKey = 1;
			utility:Print(HOTBAR_TEXT:Get("quickpagemodkeyConfirmOn"));
		elseif (msg == "0") then
			saved.useQuickpageModKey = 0;
			utility:Print(HOTBAR_TEXT:Get("quickpagemodkeyConfirmOff"));
		elseif (msg == "shift") then
			saved.quickPageModKey = "Shift";
			utility:Print(HOTBAR_TEXT:Get("quickpagemodkeyConfirmKey")..msg);
		elseif (msg == "control") then
			saved.quickPageModKey = "Control";
			utility:Print(HOTBAR_TEXT:Get("quickpagemodkeyConfirmKey")..msg);
		elseif (msg == "alt") then
			saved.quickPageModKey = "Alt";
			utility:Print(HOTBAR_TEXT:Get("quickpagemodkeyConfirmKey")..msg);
		end
		
		Gypsy_HotBar_Update();
	end
end);