local c;
local player = Var "Player";
local ShowComboAt = THEME:GetMetric("Combo", "ShowComboAt");
local NumberPulse = THEME:GetMetric("Combo", "NumberPulseCommand");
local LabelPulse = THEME:GetMetric("Combo", "LabelPulseCommand");

local NumberMinZoom = THEME:GetMetric("Combo", "NumberMinZoom");
local NumberMaxZoom = THEME:GetMetric("Combo", "NumberMaxZoom");
local NumberMaxZoomAt = THEME:GetMetric("Combo", "NumberMaxZoomAt");

local FullComboCommands = {
		W1 = THEME:GetMetric("Combo","FullComboW1Command");
		W2 = THEME:GetMetric("Combo","FullComboW2Command");
		W3 = THEME:GetMetric("Combo","FullComboW3Command");
	Broken = THEME:GetMetric("Combo","FullComboBrokenCommand");
};

local t = Def.ActorFrame {
	LoadFont( "Combo", "numbers" ) .. {
		Name="Number";
		OnCommand = THEME:GetMetric("Combo", "NumberOnCommand");
	};
	LoadActor("_combo") .. {
		Name="Label";
		OnCommand = THEME:GetMetric("Combo", "LabelOnCommand");
	};

	InitCommand = function(self)
		c = self:GetChildren();
		c.Number:visible(false);
		c.Label:visible(false);
	end;

	ComboCommand=function(self, param)
		local iCombo = param.Combo;
		if not iCombo or iCombo < ShowComboAt then
			c.Number:visible(false);
			c.Label:visible(false);
			return;
		end

		param.Zoom = scale( iCombo, 0, NumberMaxZoomAt, NumberMinZoom, NumberMaxZoom );
		param.Zoom = clamp( param.Zoom, NumberMinZoom, NumberMaxZoom );

		c.Number:settext( string.format("%i", iCombo) );
		c.Number:visible(true);
		c.Label:visible(true);

		local cmdToPlay;
		if param.FullComboW1 then
			cmdToPlay = FullComboCommands["W1"];
		elseif param.FullComboW2 then
			cmdToPlay = FullComboCommands["W2"];
		elseif param.FullComboW3 then
			cmdToPlay = FullComboCommands["W3"];
		else
			cmdToPlay = FullComboCommands["Broken"];
		end;
		(cmdToPlay)(c.Number);
		(cmdToPlay)(c.Label);

		NumberPulse( c.Number, param );
		LabelPulse( c.Label, param );
	end;
};

return t;
