standardFont = "fonts/arial.mvec";
bookantiquaFont = "fonts/book_antiqua.mvec";
deloiseFont = "fonts/Deloise.mvec";
corsivaFont = "fonts/monotype_corsiva.mvec";
papyrusFont = "fonts/papyrus.mvec";

BlackColor = Color(0,0,0,255);
BlackColorAlpha = Color(0,0,0,190);
BlueColor = Color(77,115,178,255);
DarkBlueColor = Color(40,60,120,255);
DarkGreenColor = Color( 21, 111, 48,255);
DarkRedColor = Color ( 173, 49 , 16);
MordoreColor = Color (69, 65, 56);
FXColor = Color( 165, 165, 0);
WhiteColor = Color(255,255,255,255);
MenuButtonFontColor = Color(255,255,255,255);

FaerieColor = Color(255,243,179,255);


OptionsButtonGraphics = {
	"buttons/menubuttonup",
	"buttons/menubuttondown",
	"buttons/menubuttonrollover"
};


 OptionsButtonGraphicsCinematic = {
	"buttons/bouton_animatic_long_up",
	"buttons/bouton_animatic_long_down",
	"buttons/bouton_animatic_long_over"
};

TabButtonGraphics = {
	"buttons/tab_right",
	"buttons/tab_right",
	"buttons/tab_right_over"
};

LeftCornerButtonGraphics = {
	"buttons/corner_left_knowledge_tome_00",
	"buttons/corner_left_knowledge_tome_00",
	"buttons/corner_left_knowledge_tome_00"
};

RightCornerButtonGraphics = {
	"buttons/corner_right_knowledge_tome_00",
	"buttons/corner_right_knowledge_tome_00",
	"buttons/corner_right_knowledge_tome_00"
};

HUDButtonGraphicsQuitOption = {
	"buttons/button_hud_option_up",
	"buttons/button_hud_option_down",
	"buttons/button_hud_option_rollover"
};

HUDButtonGraphics = {
	"buttons/button_hud_up",
	"buttons/button_hud_down",
	"buttons/button_hud_rollover"
};

HUDButtonGraphicsDesactivated = {
	"buttons/button_hud_up",
	"buttons/button_hud_up",
	"buttons/button_hud_up"
};

InformationWindowButtonGraphics = {
	"buttons/buton_tooltips_up",
	"buttons/buton_tooltips_up_down",
	"buttons/buton_tooltips_up_over"
}

RuneButtonGraphics = {
	"buttons/buttonruneup",
	"buttons/buttonrunedown",
	"buttons/buttonruneupover",
  "buttons/buttonrunedownover"
};

HelpToLButtonGraphics = {
    "buttons/help_off", 
    "buttons/help_on", 
    "buttons/help_on"
};

TimeButtonGraphics = {
	"buttons/buttoninvisiblerune",
	"buttons/buttoninvisiblerune",
	"buttons/buttoninvisiblerune",
	"buttons/buttoninvisiblerune"
};

StandardButtonGraphics = {
	"buttons/buttonup",
	"buttons/buttondown",
	"buttons/buttonrollover"
};

MainMenuButtonGraphics = {
	"buttons/main_menu_bouton_up.png",
	"buttons/main_menu_bouton_down.png",
	"buttons/main_menu_bouton_over.png",
	};
  
  MainMenuSwitchPlayerGraphics = {
	"buttons/bouton_switch_player_left_up.png",
	"buttons/bouton_switch_player_left_over.png",
	};

	AnimaticButtonGraphics = {
	"buttons/bouton_animatic_up.png",
	"buttons/bouton_animatic_over.png",
	};
	
	AnimactiButtonGraphicsLeft= {
	"buttons/bouton_animatic_up_left.png",
	"buttons/bouton_animatic_over_left.png",
	};
  
  AnimaticButtonGraphicsHud = {
	"buttons/bouton_hud.png",
	"buttons/bouton_hud_over.png",
	};
	
	AnimactiButtonGraphicsHudLeft= {
	"buttons/bouton_hud_left.png",
	"buttons/bouton_hud_over_left.png",
	};

	
StandardButtonFont = {
  standardFont,
  18,
  BlackColor
};

BookAntiquaStandardButtonFont = {
  bookantiquaFont,
  16,
  BlackColor
};

UpHUDFont = 
{
  bookantiquaFont,
  20,
  BlackColor
};

ActionDescriptionFont = 
{
  bookantiquaFont,
  17,
  MordoreColor
};

ActionDescriptionHighlightFont = 
{
  bookantiquaFont,
  17,
  Color ( 255, 0 , 0);
};

Desc_Font = 
{
  bookantiquaFont,
  16,
  MordoreColor
};


InformationDialogFont =
{
  bookantiquaFont,
  20,
  BlackColor
};

BanquetAndEndQuestDialogFont =
{
  bookantiquaFont,
  45,
  FaerieColor
};

UpHUDFontGreen = 
{
  bookantiquaFont,
  20,
  DarkGreenColor
};

TooltipFont = 
{
  bookantiquaFont,
  20,
  BlackColor
};

BookAntiquaLegend24vitesseFont = {
  bookantiquaFont,
  36,
  BlackColor
};

BookAntiquaLegend24Font = {
  bookantiquaFont,
  24,
  BlackColor
};

BookAntiquaLegend25Font = {
  bookantiquaFont,
  25,
  BlackColor
};

BookAntiquaTitle36Font = {
  bookantiquaFont,
  36,
  BlackColor
};

BookAntiquaTitle28Font = {
  bookantiquaFont,
  28,
  BlackColor
};

BookAntiquaTitle20Font = {
  bookantiquaFont,
  20,
  BlackColor
};

BookAntiquaTitle20FontHappy = {
  bookantiquaFont,
  16,
  BlackColor
};

BookAntiquaTitle20FontSad = {
  bookantiquaFont,
  16,
  DarkRedColor
};

BookAntiquaTitle20FontVerryHappy = {
  bookantiquaFont,
  16,
  DarkGreenColor
};

PapyrusLegendFont = {
  papyrusFont,
  30,
  BlackColor
};

PapyrusTitleFont = {
  papyrusFont,
  42,
  BlackColor
};

CorsivaFont = 
{
  corsivaFont,
  24,
  BlackColor
};

Corsiva30FontBlack = 
{
  corsivaFont,
  30,
  BlackColor
};

Corsiva40FontBlack = 
{
  corsivaFont,
  40,
  BlackColor
};

Papyrus25FontBlack = {
  papyrusFont,
  25,
  BlackColor
};

Papyrus35FontBlack = {
  papyrusFont,
  35,
  BlackColor
};

Papyrus40FontBlack = {
  papyrusFont,
  40,
  BlackColor
};

Deloise30FontBlack = {
  deloiseFont,
  30,
  BlackColor
};

CorsivaFontGreen = 
{
  cosivaFont,
  24,
  DarkGreenColor
};

MenuButtonFont = {
  standardFont,
  22,
  MenuButtonFontColor
};

DialogTitleFont = {
  standardFont,
  20,
  BlackColor
};

DialogCinematicFont = {
 
 deloiseFont,
 39,
 WhiteColor
}

ButtonKnowledgeTreeCostFont = {
    papyrusFont,
    19,
    WhiteColor
}

DialogBodyFont = {
  standardFont,
  18,
  BlackColor
};

HudMoraleFont = {
  standardFont,
  14,
  BlackColor
};

TomeOfLoreTitleFont = {
  papyrusFont,
  20,
  BlackColor
};

DefaultStyle = {
	font=DialogBodyFont
};


QuittStyle = {
	font=BookAntiquaStandardButtonFont
};

QuittStyletitle = {
	font=BookAntiquaTitle36Font
};

DialogTitleText = {
	parent=DefaultStyle,
	font = BookAntiquaTitle28Font,
	flags = kVAlignCenter + kHAlignCenter,
	x=50,y=12,w=kMax - 50,h=60
};

DialogTitleTextQuit = {
	parent=QuittStyle,
	font = BookAntiquaTitle36Font,
	x=0,y=18,w=kMax,h=kMax,
	flags = kHAlignCenter + kVAlignTop
};

DialogBodyText = {
	parent=DefaultStyle,
	font = DialogBodyFont,
	flags = kVAlignCenter + kHAlignCenter,
	x=50,y=46,w=kMax - 50,h=kMax-60
};

DialogBodyTextQuit = {
	parent=QuittStyle,
	font = BookAntiquaTitle20Font,
	flags = kVAlignCenter + kHAlignCenter,
	x=30,y=46,w=kMax-60,h=kMax-60
};

SliderStyle =
{
	parent=DefaultStyle,
	railtop = "slider/sliderrailtop",
	railmid = "slider/sliderrailmid",
	railbot = "slider/sliderrailbot",
	sliderimage = "slider/sliderknob",
	sliderrollimage = "slider/sliderknobover",

	yoffset = -1, -- scoot the slider down by one pixel to center it.
};

OptionsSliderStyle =
{
	parent=DefaultStyle,
	railtop = "slider/sliderrailtop",
	railmid = "slider/sliderrailmid",
	railbot = "slider/sliderrailbot",
	sliderimage = "slider/sliderknob",
	sliderrollimage = "slider/sliderknobover",

	railfilledbot = "slider/sliderrailfilledbot",
	railfilledmid = "slider/sliderrailfilledmid",
	railfilledtop = "slider/sliderrailfilledtop",
  
	yoffset = -1, -- scoot the slider down by one pixel to center it.
};

LoadingSliderStyle =
{
	parent=DefaultStyle,
	railtop = "slider/sliderrailtop",
	railmid = "slider/sliderrailmid",
	railbot = "slider/sliderrailbot",
	sliderimage = "slider/sliderknob_transparent",
	sliderrollimage = "slider/sliderknob_transparent",

	railfilledbot = "slider/sliderrailfilledbot",
	railfilledmid = "slider/sliderrailfilledmid",
	railfilledtop = "slider/sliderrailfilledtop",
  
	yoffset = -1, -- scoot the slider down by one pixel to center it.
};

kDefaultButtonSound= "sounds/gui/validation/gui_validation_short.ogg";
kValidationButtonSound = "sounds/gui/validation/gui_validation_short.ogg";
kCancelButtonSound = "sounds/gui/retour/gui_retour.ogg";
kAnimaticButtonSound = "sounds/gui/validation/menu_page.ogg";

MenuButtonStyle = {
	parent = BookAntiquaTitle28Font,
	font = BookAntiquaTitle28Font,
	sound = kDefaultButtonSound,
	color =Color(40,30,15,255),
	graphics = MainMenuButtonGraphics,
	w=195, h=40
};

SwitchPlayerButtonStyle = 
{
  parent = BookAntiquaTitle28Font,
  sound = kDefaultButtonSound,
	color =Color(40,30,15,255),
	graphics = MainMenuSwitchPlayerGraphics,
  type = kPush,
	w=39, h=34
};


ButtonStyle = {
	parent = DefaultStyle,
	font = StandardButtonFont,
	sound = kDefaultButtonSound,
	type= kPush,
	graphics = StandardButtonGraphics,
};

UpHUDStyle = {
    parent = DefaultStyle,
    font = UpHUDFont,
};

RuneButtonStyle = {
	parent = DefaultStyle,
	font = StandardButtonFont,
	type = kToggle,
	sound = kDefaultButtonSound,
	graphics = RuneButtonGraphics,
};

OptionsButtonStyle = {
	parent = QuittStyle,
	font = BookAntiquaStandardButtonFont,
	sound = kDefaultButtonSound,
	type= kPush,
	graphics = OptionsButtonGraphics,
};

OptionsButtonStyleCinematic = {
	parent = QuittStyle,
	font = BookAntiquaStandardButtonFont,
	sound = kDefaultButtonSound,
	type= kPush,
	graphics = OptionsButtonGraphicsCinematic,
};

TabButtonStyle = {
	parent = DefaultStyle,
	font = BookAntiquaStandardButtonFont,
	sound = kDefaultButtonSound,
	type= kPush,
	--graphics = TabButtonGraphics,
};

OptionsValidationButtonStyle = {
	parent = QuittStyle,
	font = BookAntiquaStandardButtonFont,
	sound = kValidationButtonSound,
	type= kPush,
	graphics = OptionsButtonGraphics,
};

OptionsCancelButtonStyle = {
	parent = QuittStyle,
	font = BookAntiquaStandardButtonFont,
	sound = kCancelButtonSound,
	type= kPush,
	graphics = OptionsButtonGraphics,
};

TimeButtonStyle = {
	parent = DefaultStyle,
	font = StandardButtonFont,
  flags = kHAlignCenter + kVAlignCenter,
	--sound = kDefaultButtonSound,
	type= kRadio,
	graphics = TimeButtonGraphics,
};

tooltip_background1 = "backgrounds/tooltip_background";
tooltip_background2 = "backgrounds/tooltip_plus";
tooltip_font = TooltipFont;

MenuAnimaticStyle = {
	graphics = AnimaticButtonGraphics,
	sound = kAnimaticButtonSound,	
};

MenuAnimaticStyleLeft = {
	graphics = AnimactiButtonGraphicsLeft,
	sound = kAnimaticButtonSound,	
};

MenuAnimaticStyleHud = {
	graphics = AnimaticButtonGraphicsHud,
	sound = kAnimaticButtonSound,	
};

MenuAnimaticStyleHudLeft = {
	graphics = AnimactiButtonGraphicsHudLeft,
	sound = kAnimaticButtonSound,	
};


SetDefaultStyle(DefaultStyle);

-- Create a TButton with a label
--
-- We're overriding the default "Button" here with
-- some custom behavior. Specifically, we're layering
-- a Text{} object on top of every button, and it's placed
-- on all layers (up, down, roll-over).
function Button( button )
	return function()
		-- Grab the label from the button or current style
		if (GetTag(button,"label")) then

			-- Look for text dimensions
			local tx = GetTag(button,"tx");
			local ty = GetTag(button,"ty");
			local tw = GetTag(button,"tw");
			local th = GetTag(button,"th");

			-- Set defaults
			if (not tx) then
				tx = 0;
			end
			if (not ty) then
				ty = 0;
			end
			if (not tw) then
				tw=kMax ;
			end
			if (not th) then
				th=kMax ;
			end

			-- Get the label
			local label = GetTag(button,"label");

			local defflags = kPushButtonAlignment ;
			if (GetTag(button,"type")==kToggle) then
				defflags = kToggleButtonAlignment ;
			elseif (GetTag(button,"type")==kRadio) then
				defflags = kRadioButtonAlignment ;
			end

			local textfactory = GetTag(button,"textfactory");
			if (not textfactory) then
				textfactory = "_text"
			end
			table.insert(button,
				SelectLayer( kAllLayers )
			);
			-- Grow our window to encompass any children we've added
			-- already.
			table.insert(button,
				FitToChildren()
			);

			table.insert(button,
				AppendStyle{ font=button.font; flags=button.flags; }
			);

			table.insert(button,
				Text
				{
					label=label,
					x=tx, y=ty, w=tw, h=th,
					name='label',
					defflags =defflags
				}
			)
		end

		-- Type name of window to create; in our case, "Button".
		-- If you want to create a derived button type, you can do that here.
		button.typename='Button';
		DoWindow( button )
	end
end

-- Create several bits of text that combine to make a blended shadow
function ColorShadowText( x,y,size, label, color )

	return Group(
		{
		-- Add these traits to the current style
			AppendStyle{ x=x, y=y, w=kMax, h=kMax, label=label, flags = kHAlignCenter, },
			AppendStyle{ font = { bookantiquaFont, size, Color(0,0,0,255)} },
			Text{ y=y+4 },
			AppendStyle{ font = { bookantiquaFont, size, Color(255,255,255,255)} },
			Text{ y=y+2 },
			AppendStyle{ font = { bookantiquaFont, size, color } } ,
			Text{},
		}
	)
end

kMenuButtonFontSize = 30;

function MenuButtonLabel( label, color, colorHighlight )

	if not color then
		color =Color(40,30,15,255);	-- the default colors
		colorHighlight=Color(255,255,255,255)
	end

	return Group{
		--[[Bitmap
		{
			image="backgrounds/bar",
			x=0,y=0,scale=1
		}, ]]--
		--SelectLayer(0),
		--ColorShadowText(5,8,kMenuButtonFontSize, label, color ),
		--SelectLayer(1),
		--ColorShadowText(5,8,kMenuButtonFontSize, label, colorHighlight ),
		--SelectLayer(2),
		--ColorShadowText(5,8,kMenuButtonFontSize, label, colorHighlight )
	}

end

-- Create a more limited-use button type here; the label is defined inline
-- with MenuButtonLabel above
function MenuButton( button )
	return function()
		-- Type name of window to create; in our case, "Button".
		-- If you want to create a derived button type, you can do that here.
		button.typename='Button';
		DoWindow( button )
	end
end

kIllegalNameChars = "!@#$%^&*()><\\\"\'[]{}|?/+=~`.,;:-";
