--============================================================================
--  style.lua
--  Copyright (c) 2010, Bamtang Games. All Rights Reserved.
------------------------------------------------------------------------------
-- Illegal Characters
kIllegalNameChars = "!@#$%^&*()><\\\"\'[]{}|?/+=~`.,;:-";
-- Font definition
TextFont = gsw_LocalizedPath.. "font/helsinki.mvec";

FontColor = Color(64, 3, 60, 255);
ChangePlayerColor = Color(97, 56, 148, 255);
ColorWhite = Color(255, 255, 255, 255);
coloryellow = Color(244, 245, 155, 255);

DefaultButtonSound="audio/sfx/menu_click.ogg";
DefaultButtonRollOverSound = "audio/sfx/menu_rollover";
MetamapButtonSound="audio/sfx/pause_unpause_node.ogg";

StandardButtonGraphics = {
    "gpx/buttons/button_n",
    "gpx/buttons/button_d",
    "gpx/buttons/button_h"
};

MainButtonGpx = {
    "gpx/buttons/mainmenu_n",
    "gpx/buttons/mainmenu_d",
    "gpx/buttons/mainmenu_h"
};

PlayButtonGraphics = {
    "gpx/buttons/play_n",
    "gpx/buttons/play_d",
    "gpx/buttons/play_h"
};

QuickPlayButtonGpx = {
    "gpx/buttons/quickplay_n",
    "gpx/buttons/quickplay_d",
    "gpx/buttons/quickplay_h",
    "gpx/buttons/quickplay_i"
};

NewRowButtonGraphics = {
    "gpx/buttons/newrow_n",
    "gpx/buttons/newrow_d",
    "gpx/buttons/newrow_h",
    "gpx/buttons/newrow_i"
};

ArrowDownGraphics = {
    "gpx/buttons/down_n";
    "gpx/buttons/down_d";
    "gpx/buttons/down_h";
};

ArrowUpGraphics = {
    "gpx/buttons/up_n";
    "gpx/buttons/up_d";
    "gpx/buttons/up_h";
};

SmallButtonGpx = {
    "gpx/buttons/buttonsmall_n";
    "gpx/buttons/buttonsmall_d";
    "gpx/buttons/buttonsmall_h";
    "gpx/buttons/buttonsmall_i";
};

CheckboxButtonGpx = {
    "gpx/buttons/button_off";
    "gpx/buttons/button_on";
    "gpx/buttons/button_on";
    "gpx/buttons/button_off";
}

OptionsButtonGpx = {
    "gpx/buttons/newrow_n";
    "gpx/buttons/newrow_d";
    "gpx/buttons/newrow_h";
};

ChangePlayerButtonGpx = {
    "gpx/buttons/changeplayer_n";
    "gpx/buttons/changeplayer_d";
    "gpx/buttons/changeplayer_h";
};

PauseButtonGpx = {
    "gpx/buttons/options_n";
    "gpx/buttons/options_d";
    "gpx/buttons/options_h";
    "gpx/buttons/options_i";
};

PausedButtonGpx = {
    "gpx/buttons/paused_n";
    "gpx/buttons/paused_d";
    "gpx/buttons/paused_h";
};

ClassicButtonGpx = {
    "gpx/screens/icon_metamap_classic_n";
    "gpx/screens/icon_metamap_classic_on";
    "gpx/screens/icon_metamap_classic_over";
};
ClassicButtonGpxF = {
    "gpx/screens/icon_metamap_classic_check_n";
    "gpx/screens/icon_metamap_classic_check_on";
    "gpx/screens/icon_metamap_classic_check_over";
};

BlitzButtonGpx = {
    "gpx/screens/icon_metamap_blitz_n";
    "gpx/screens/icon_metamap_blitz_on";
    "gpx/screens/icon_metamap_blitz_over";
};
BlitzButtonGpxF = {
    "gpx/screens/icon_metamap_blitz_check_n";
    "gpx/screens/icon_metamap_blitz_check_on";
    "gpx/screens/icon_metamap_blitz_check_over";
};

StrategyButtonGpx = {
    "gpx/screens/icon_metamap_strategy_n";
    "gpx/screens/icon_metamap_strategy_on";
    "gpx/screens/icon_metamap_strategy_over";
};
StrategyButtonGpxF = {
    "gpx/screens/icon_metamap_strategy_check_n";
    "gpx/screens/icon_metamap_strategy_check_on";
    "gpx/screens/icon_metamap_strategy_check_over";
};

CradleButtonGpx = {
    "gpx/screens/icon_metamap_cradle_n";
    "gpx/screens/icon_metamap_cradle_on";
    "gpx/screens/icon_metamap_cradle_over";
};
CradleButtonGpxF = {
    "gpx/screens/icon_metamap_cradle_check_n";
    "gpx/screens/icon_metamap_cradle_check_on";
    "gpx/screens/icon_metamap_cradle_check_over";
};

JockerButtonGpx = {
    "gpx/screens/icon_metamap_joker_n";
    "gpx/screens/icon_metamap_joker_on";
    "gpx/screens/icon_metamap_joker_over";
};
JockerButtonGpxF = {
    "gpx/screens/icon_metamap_joker_check_n";
    "gpx/screens/icon_metamap_joker_check_on";
    "gpx/screens/icon_metamap_joker_check_over";
};


Font34Yellow = {
    TextFont,
    34,
    coloryellow,
};

Font11 = {
    TextFont,
    11,
    FontColor
};

Font13 = {
    TextFont,
    13,
    FontColor
};

Font14 = {
    TextFont,
    14,
    FontColor
};

Font16 = {
    TextFont,
    16,
    FontColor
};

Font17 = {
    TextFont,
    17,
    FontColor
};

Font18 = {
    TextFont,
    18,
    FontColor
};

Font19 = {
    TextFont,
    19,
    FontColor
};

Font20 = {
    TextFont,
    20,
    FontColor
};

Font18White = {
    TextFont,
    18,
    ColorWhite
};

Font20White = {
    TextFont,
    20,
    ColorWhite
};

Font20ChangePlayer = {
    TextFont,
    20,
    ChangePlayerColor
};

Font21 = {
    TextFont,
    21,
    FontColor
};

Font22 = {
    TextFont,
    22,
    FontColor
};

Font22White = {
    TextFont,
    22,
    ColorWhite
}

Font23 = {
    TextFont,
    23,
    FontColor
};

Font24 = {
    TextFont,
    24,
    FontColor
};

Font26 = {
    TextFont,
    26,
    FontColor
};

Font28 = {
    TextFont,
    28,
    FontColor
};

Font30 = {
    TextFont,
    30,
    FontColor
};

Font32 = {
    TextFont,
    32,
    FontColor
};

Font34 = {
    TextFont,
    34,
    FontColor
};

Font34White = {
    TextFont,
    34,
    ColorWhite
};

Font35 = {
    TextFont,
    35,
    FontColor
};

Font36 = {
    TextFont,
    36,
    FontColor
};

Font36White = {
    TextFont,
    36,
    ColorWhite
}

Font40 = {
    TextFont,
    40,
    FontColor
};

Font40White = {
    TextFont,
    40,
    ColorWhite,
};

Font41 = {
    TextFont,
    41,
    FontColor
};

Font42 = {
    TextFont,
    42,
    FontColor
};

Font42White = {
    TextFont,
    42,
    ColorWhite
};

Font44 = {
    TextFont,
    44,
    FontColor
};

Font44White = {
    TextFont,
    44,
    ColorWhite
};

Font46 = {
    TextFont,
    46,
    FontColor
};

Font48 = {
    TextFont,
    48,
    FontColor
};

Font48White = {
    TextFont,
    48,
    ColorWhite
}

Font50 = {
    TextFont,
    50,
    FontColor
};

Font58 = {
    TextFont,
    58,
    FontColor
};

Font58White = {
    TextFont,
    58,
    ColorWhite
};

Font60White = {
	TextFont,
	60,
	ColorWhite,
};

Font82White = {
    TextFont,
    82,
    ColorWhite
};

Font50White = {
    TextFont,
    50,
    ColorWhite
};

ButtonStyle = {
    font = Fon14,
    type = kPush,
    graphics = StandardButtonGraphics,
    sound = DefaultButtonSound;
    rolloversound = DefaultButtonRollOverSound;
};

MetamapButtonStyle = {
    font = Fon14,
    type = kPush,
    graphics = StandardButtonGraphics,
    sound = MetamapButtonSound;
    rolloversound = DefaultButtonRollOverSound;
};

ChangePlayerRadioButtonStyle = {
    type = kRadio;
    sound = kDefaultButtonSound;
    graphics = {
        "";
        "gpx/screens/player_name_scroll";
        "gpx/screens/player_name_scroll_h";
        "gpx/screens/player_name_scroll";
    };
};

DifficultyRadioButtonStyle = {
    parent = ChangePlayerRadioButtonStyle;
    graphics = {
        "";
        "gpx/screens/quickplay_dificultymarc";
        "gpx/screens/quickplay_dificultymarc_h";
        "gpx/screens/quickplay_dificultymarc";
    };
};

CharacterRadioButtonStyle = {
    type = kRadio;
    sound = kDefaultButtonSound;
}

--PauseButtonStyle = {
--    parent = DefaultStyle,
--    font = Font17,
--    type = kPush,
--    graphics = MainButtonGpx,
--    sound = DefaultButtonSound;
--    rolloversound = DefaultButtonRollOverSound;
--};

MainWindowButtonStyle = {
    parent = ButtonStyle,
    font = Font11,
    graphics = MainButtonGpx,
};

PanelButtonStyle = {
    parent = ButtonStyle,
    font = Font22,
    graphics = NewRowButtonGraphics,
};

SmallButtonStyle = {
    parent = ButtonStyle,
    font = Font16,
    graphics = SmallButtonGpx,
};

CheckboxButtonStyle = {
    font = Font22,
    type = kToggle,
    graphics = CheckboxButtonGpx,
    tx = 5,
    sound = DefaultButtonSound;
    rolloversound = DefaultButtonRollOverSound;
};

OptionButtonStyle = {
    parent = ButtonStyle;
    font = Font18;
    graphics = OptionsButtonGpx;
};

PauseButtonStyle = {
    parent = ButtonStyle;
    font = Font18;
    graphics = PauseButtonGpx;
};

PausedButtonStyle = {
    parent = ButtonStyle;
    font = Font18;
    graphics = PausedButtonGpx;
};

ChangePlayerButtonStyle = {
    parent = ButtonStyle;
    font = Font11;
    graphics = ChangePlayerButtonGpx;
};

SliderStyle = {
    --parent = DefaultStyle,
    railtop = "gpx/bar/slider_01",
    railmid = "gpx/bar/slider_02",
    railbot = "gpx/bar/slider_03",
    sliderimage = "gpx/buttons/slider_n",
    sliderrollimage = "gpx/buttons/slider_d",

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

-- 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
        local label = GetTag(button,"label");
        if 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

            -- Begin new hotkey support
            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"));
            -- End new hotkey support

            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 {
                    -- Begin new hotkey support
                    label = "#"..TagHotKey(hotkey, label),
                    -- End new hotkey support
                    x = tx, y = ty, w = tw, h = th,
                    name = 'label',
                    defflags = defflags
                }
            )
        end

        local commandFunction = GetTag(button,"command");
        if commandFunction then
            button.command = function()
                -- Only execute command if flag gAllButtonsDisabled is false
                if not gAllButtonsDisabled then
                    commandFunction();
                end
            end;
        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
