standardFont = "fonts/bookantiqua.mvec";
headerFontName = "fonts/episode1r.mvec";

BlackColor = Color(0,0,0,255);
BlueColor = Color(77,115,178,255);
DarkBlueColor = Color(40,60,120,255);
WhiteColor = Color(255,255,255,255);
MenuButtonFontColor = Color(255,255,255,255);
MenuOverButtonFontColor = Color(248,177,73,255);
MenuDisabledButtonFontColor = Color(10,10,10,255);
CreditsFontColor1 = Color(7,33,65,255);
CreditsFontColor2 = Color(1,88,134,255);
HeaderColor = Color(11,41,77,255);

ScreenWight = 1024;
ScreenHeight = 768;

HeaderFontSize = 55;
HeaderFontSizeSmall = 45;

mainMenuButtonSound="assets/audio/sfx/menu_click1.ogg";
defaultButtonSound="assets/audio/sfx/menu_click2.ogg";
mainMenuOpenSound="assets/audio/sfx/menu_open.ogg";
mainMenuOverSound="assets/audio/sfx/menu_over.ogg";

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

LongButtonStyle = {
    parent = ButtonStyle,
    graphics = LongButtonGraphics
};

SetDefaultStyle(DefaultStyle);


DefaultStyle = {
    font=DialogBodyFont,
    sound = defaultButtonSound,    
    rolloversound = mainMenuOverSound,    
};

HeaderFont = {
  headerFontName,
  70,
  HeaderColor
};

HeaderFontSmall = {
  headerFontName,
  60,
  HeaderColor
};

MenuButtonFont = {
  standardFont,
  22,
  MenuOverButtonFontColor
};

MenuOptionsFont = {
  standardFont,
  20,
  BlackColor
};

MenuProfileFont = {
  standardFont,
  19,
  BlackColor
};

MenuOkFont = {
  standardFont,
  20,
  BlackColor
};

-- ÃËÀÂÍÎÅ ÌÅÍÞ ------------------------------------------------

MainMenuGraphics1 = {
	"Menu/button_menu1_1.png",
	"Menu/button_menu1_2.png",
	"Menu/button_menu1_1.png"
};

MenuButtonStyle1 = {
    parent = DefaultStyle,
    flags = kHAlignCenter + kVAlignTop,
    font = MenuButtonFont,
    sound = mainMenuButtonSound,
    graphics = MainMenuGraphics1
};

MainMenuGraphics2 = {
	"Menu/button_menu2_1.png",
	"Menu/button_menu2_2.png",
	"Menu/button_menu2_1.png"
};

MenuButtonStyle2 = {
    parent = DefaultStyle,
    flags = kHAlignCenter + kVAlignTop,
    font = MenuButtonFont,
    sound = mainMenuButtonSound,
    graphics = MainMenuGraphics2,
};

-- ÊÍÎÏÊÀ BACK -------------------------------

BackButtonGraphics =
{
	"Menu/button_back_up.png",
	"Menu/button_back_down.png",
	"Menu/button_back_rollover.png",
	"Menu/button_back_noactive.png"
};
BackButtonStyle = {
    parent = DefaultStyle,
    graphics = BackButtonGraphics,
    font = MenuOkFont,
    label="back",
    flags = kHAlignLeft + kVAlignCenter,
    tx=24,
};

-- ÊÍÎÏÊÀ OK È ÎÒÌÅÍÀ -------------------------------
MenuButtonOk = {
    parent = DefaultStyle,
    font = MenuOkFont,
    label="ok",
    flags = kHAlignLeft + kVAlignCenter,
    graphics = {
	"Menu/button_ok_up.png",
	"Menu/button_ok_down.png",
	"Menu/button_ok_rollover.png",
	"Menu/button_ok_noactive.png" },
    tx=70,
};

MenuButtonCross = {
    parent = DefaultStyle,
    font = MenuOkFont, 
    label="cancel",
    flags = kHAlignLeft + kVAlignCenter,
    graphics = {
	"Menu/button_cross_up.png",
	"Menu/button_cross_down.png",
	"Menu/button_cross_rollover.png" },
   tx=30,
};
-- ÏÐÎÔÈËÈ ------------------------------------------------

ProfilesButtonGraphics1 =
{
	"Menu/button_01_1.png",
	"Menu/button_01_3.png",
	"Menu/button_01_2.png",
	"Menu/button_01_4.png"
};

ProfilesButtonGraphics2 =
{
	"Menu/button_02_1.png",
	"Menu/button_02_3.png",
	"Menu/button_02_2.png",
	"Menu/button_02_4.png"
};

ProfilesButtonGraphics3 =
{
	"Menu/button_03_1.png",
	"Menu/button_03_3.png",
	"Menu/button_03_2.png",
	"Menu/button_03_4.png"
};

ProfilesButtonStyle1 =
{
	parent = DefaultStyle,
	flags = kHAlignCenter + kVAlignCenter,
	font = MenuProfileFont,
	graphics = ProfilesButtonGraphics1,
	h=40
};

ProfilesButtonStyle2 =
{
	parent = DefaultStyle,
	flags = kHAlignCenter + kVAlignCenter,
	font = MenuProfileFont,
	graphics = ProfilesButtonGraphics2,
	h=40
};

ProfilesButtonStyle3 =
{
	parent = DefaultStyle,
	flags = kHAlignCenter + kVAlignCenter,
	font = MenuProfileFont,
	graphics = ProfilesButtonGraphics3,
	h=40
};

ProfilesNamesGraphics =
{
	"Menu/button_05.png",
	"Menu/button_04.png",
	"Menu/button_06.png",
	"Menu/button_04.png"
};

ProfilesNamesStyle =
{
	type = kRadio,
	flags = kHAlignCenter + kVAlignCenter,
	font = MenuProfileFont,
	graphics = ProfilesNamesGraphics
};

-- OPTIONS -------------------------------------------------------

CheckboxButtonGraphics = {
    "Menu/check_btn_up",
    "Menu/check_btn_down",
    "Menu/check_btn_up",
    "Menu/check_btn_down"
};

CheckboxButtonStyle = {
    parent = DefaultStyle,
    font = MenuOptionsFont,
    type = kToggle,
    graphics = CheckboxButtonGraphics,
    tx=28,
};

CheckboxMuteStyle = {
    parent = DefaultStyle,
    font = MenuOptionsFont,
    type = kToggle,
    graphics = {
    "Menu/button_mute_02",
    "Menu/button_mute_01",
    "Menu/button_mute_02_2",
    "Menu/button_mute_01_1"
    },
    tx=40,
};

CheckboxFullStyle = {
    parent = DefaultStyle,
    font = MenuOptionsFont,
    type = kToggle,
    flags = kHAlignLeft + kVAlignCenter,
    graphics = {
    "Menu/button_fullscr_01",
    "Menu/button_fullscr_02",
    "Menu/button_fullscr_01_1",
    "Menu/button_fullscr_02_2"},
    tx=66,
};

CheckboxCursorStyle = {
    parent = DefaultStyle,
    font = MenuOptionsFont,
    type = kToggle,
    flags = kHAlignLeft + kVAlignCenter,
    graphics = {
    "Menu/button_cursor_01",
    "Menu/button_cursor_02",
    "Menu/button_cursor_01_1",
    "Menu/button_cursor_02_2"},
    tx=66,
};

CheckboxTutorialStyle = {
    parent = DefaultStyle,
    font = MenuOptionsFont,
    type = kToggle,
    flags = kHAlignLeft + kVAlignCenter,
    graphics = {
    "Menu/button_tutor_01",
    "Menu/button_tutor_02",
    "Menu/button_tutor_01_1",
    "Menu/button_tutor_02_2"},
    tx=66,
};

MenuButtonCredits = {
    parent = DefaultStyle,
    font = MenuProfileFont,
    graphics = {
	"Menu/button_credits_up.png",
	"Menu/button_credits_down.png",
	"Menu/button_credits_rollover.png" },
    w=63, h=50
};
---------- PAUSE ----------------------------

MenuButtonPause1 = {
    parent = DefaultStyle,
    font = MenuProfileFont,
    graphics = {
	"Menu/button_menu_up.png",
	"Menu/button_menu_down.png",
	"Menu/button_menu_rollover.png" },
    w=63, h=50
};

MenuButtonPause2 = {
    parent = DefaultStyle,
    font = MenuProfileFont,
    graphics = {
	"Menu/button_option_up.png",
	"Menu/button_option_down.png",
	"Menu/button_option_rollover.png" },
    w=63, h=50
};

MenuButtonPause3 = {
    parent = DefaultStyle,
    font = MenuProfileFont,
    graphics = {
	"Menu/button_quit_up.png",
	"Menu/button_quit_down.png",
	"Menu/button_quit_rollover.png" },
    w=63, h=50
};


--------------------------------------

StandardButtonFont = {
  standardFont,
  22,
  BlackColor,
};


MenuDisabledButtonFont = {
  standardFont,
  22,
  MenuDisabledButtonFontColor
};

WelcomeFont = {
  standardFont,
  26,
  WhiteColor
};


DialogTitleFont = {
  standardFont,
  20,
  BlackColor
};

PanelHeaderFont = {
  headerFontName,
  30,
  BlackColor
};

DialogBodyFont = {
  standardFont,
  20,
  BlackColor
};


DialogTitleText = {
    parent=DefaultStyle,
    font = DialogTitleFont,
    flags = kVAlignCenter + kHAlignCenter,
    x=16,y=12,w=kMax,h=kMax-200
};

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

SliderStyle =
{
    parent=DefaultStyle,
    railtop = "Menu/slider_empty",
    railmid = "Menu/slider_empty",
    railbot = "Menu/slider_empty",
    sliderimage = "Menu/slider_empty",
    sliderrollimage = "Menu/slider_empty",
};

-- 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

-- 4.0.15 -- Begin new hotkey support
            -- Get the label
            local label = GetTag(button,"label");
            local hotkey = GetTag(button,"hotkey");

            label,labelkey = StripKeyFromLabel( GetString(label) );

            -- If no hotkey was specified explicitly, then
            -- use the translated key.
            if not hotkey then
                -- change our local
                hotkey = labelkey
            end;

            RegisterHotkey( hotkey, GetTag(button,"name") );
-- 4.0.15 -- End new hotkey support (more below!)

            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
                {
-- 4.0.15 -- Begin new hotkey support
                    label="#"..TagHotKey( hotkey, label ),
-- 4.0.15 -- End new hotkey support
                    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

function QEMenuButton( 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

-- 4.0.15 -- Begin new hotkey support
            -- Get the label
            local label = GetTag(button,"label");
            local hotkey = GetTag(button,"hotkey");

            label,labelkey = StripKeyFromLabel( GetString(label) );

            -- If no hotkey was specified explicitly, then
            -- use the translated key.
            if not hotkey then
                -- change our local
                hotkey = labelkey
            end;

            RegisterHotkey( hotkey, GetTag(button,"name") );
-- 4.0.15 -- End new hotkey support (more below!)

            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
                {
-- 4.0.15 -- Begin new hotkey support
                    label="#"..TagHotKey( hotkey, label ),
-- 4.0.15 -- End new hotkey support
                    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='QEMenuButton';
        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 },
            AppendStyle{ font = { headerFontName, size, Color(0,0,0,40)} },
            Text{ y=y+4, x=x+1 },
            AppendStyle{ font = { headerFontName, size, Color(0,0,0,220)} },
            Text{ y=y+2 },
            AppendStyle{ font = { headerFontName, size, color } } ,
            Text{},
        }
    )
end

function ColorShadowText1( 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 },
            AppendStyle{ font = { headerFontName, size, Color(0,0,0,40)} },
            Text{ y=y+4-3, x=x+1 },
            AppendStyle{ font = { headerFontName, size, Color(0,0,0,230)} },
            Text{ y=y+2-3 },
            AppendStyle{ font = { headerFontName, size, color },
           --label="#"..GetString("text_outlined", "54431f", 1, GetString(label)) 
           } ,
            Text{y=y-3},
        }
    )
end

function ColorOutlineText( label, color )
	return Group(
		{
			--AppendStyle{ font = { standardFont, 20} },
			Text{w=kMax, h=kMax,
			--	label="#"..GetString("text_outlined", color, GetString(label)),
				label="9987",
				flags = kHAlignCenter+kVAlignCenter},
		}		
	)
	
end

kMenuButtonFontSize = 24;

function MenuButtonLabel( label, color, colorHighlight )

    if not color then
        color = Color(248,177,73,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

function WelcomeTextLabel( label )
return Group{
            AppendStyle{ x=0, y=0, w=kMax, h=kMax, 
                  label="#"..GetString("text_bold", GetString(label))
                   },
            AppendStyle{ font = { headerFontName, 26, Color(139,161,132,200)} },
            Text{ x=1, y=1 },
            AppendStyle{ font = { headerFontName, 26, Color(157,166,121,255)},
            label="#"..GetString("text_outlined", "2c3a2b", "1", GetString(label)) },
            Text{ x=0,y=0 },
      }
end

function PlayerNameLabel( label )
return Group{
            AppendStyle{ x=0, y=0, w=kMax, h=kMax, 
                  label="#"..GetString("text_bold", GetString(label))
                   --label=label
                   },
            AppendStyle{ font = { headerFontName, 26, Color(0,0,0,60)} },
            Text{ x=4, y=3, name="layer0" },
            AppendStyle{ font = { headerFontName, 26, Color(0,0,0,100)} },
            Text{ x=1,y=2, name="layer1" },
            AppendStyle{ font = { headerFontName, 26, Color(248,177,73,255)}, 
            --label="#"..GetString("text_outlined", "725d36", "1", GetString(label))
            label=label},
            Text{ x=0,y=0, name="layer2" },
      }
end

function StartGameLabel( label )
    if not color then
        color = Color(248,177,73,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),
        ColorShadowText1(5,8,kMenuButtonFontSize, label, color ),
        SelectLayer(1),
        ColorShadowText1(5,8,kMenuButtonFontSize, label, colorHighlight ),
        SelectLayer(2),
        ColorShadowText1(5,8,kMenuButtonFontSize, label, colorHighlight )
    }
end

function ProfileButtonLabel( label, size, flags, color )
  if not color then
        color = Color(225,219,165,255);
    end
  if not flags then
        flags = kHAlignCenter + kVAlignTop;
    end
return Group{
            AppendStyle{ x=0, y=0, w=kMax, h=kMax, 
            			flags = flags,
                  label="#"..GetString("text_bold", GetString(label)) },
            AppendStyle{ font = { headerFontName, size, Color(0,0,0,50)} },
            Text{ x=4, y=4, name="layer0" },
            AppendStyle{ font = { headerFontName, size, Color(0,0,0,200)} },
            Text{ x=2,y=2 , name="layer1" },
            AppendStyle{ font = { headerFontName, size,  Color(62,49,42,255) } } ,
            Text{ name="layer2" },
            AppendStyle{ font = { headerFontName, size,  color },label=label } ,
            Text{ name="layer3" },
      }
end


function QuitLabel(label)
    labelnew = "";
    if IsMinigame() then
    labelnew = "#"..GetString(label).."<br><br>"..GetString("quitminigame");
    else
    labelnew = "#"..GetString(label);
    end;

   return labelnew;
 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 = "!@#$%^&*()><\\\"\'[]{}|?/+=~`.,;:-_";