--
-- Created by IntelliJ IDEA.
-- User: Gebruiker
-- Date: 26-1-2016
-- Time: 18:58
-- To change this template use File | Settings | File Templates.
--

local startUp = CreateFrame("Frame")
startUp:RegisterEvent("PLAYER_LOGIN");

--function that gets called when an event within startUp triggers.
startUp:SetScript("OnEvent", function(self, event, ...)
    --print startup message for addon
    print("|cffffff00Killing Blow Announcer|cff3498db v1.10|cffecf0f1 - type in '/kba' to open the options panel");

    --hide or show minimap icon
    KillingBlowAnnouncer:GetEnableMinimapIcon(info)

    --create message and image frames
    createFrames();

    --snap edit killing blow message to screen if enabled
    snapMessage();

    --display or hide the kbtracker
    hideKbtracker();

    --enable or disable drag on startup
    lockKbtracker();

    --set tracker backdrop
    setBackdrop();


    if(KillingBlowAnnouncer:GetPrevSession(info) == 0) then
        new = kbs_session + 1;
        old = KillingBlowAnnouncer:GetPrevSession(info) + 1;
        p = format("%.2f",(new- old)/ old  * 100)
    else
        p = format("%.2f",(kbs_session- KillingBlowAnnouncer:GetPrevSession(info))/ KillingBlowAnnouncer:GetPrevSession(info)  * 100)
    end

    p = tonumber(p)

    if(p < 0) then
        zone = "|cffE2252D" .. p;
    elseif(p > 0)then
        zone = "|cff2ed689" .. p;
    else
        zone = "|cFFFFFFFF" .. p;
    end

    kbtrackerText:SetText("|cFFFFFFFF          Killing blow tracker\n"
            .. "|cffffcc00Current zone:\n"
            .. "Previous zone:\n\n"
            .. "Current session:\n"
            .. "Previous session:" )
    kbtrackerTextVars:SetText("|cFFFFFFFF"..kbs_cZone .."\n"
            .. kbs_pZone .."\n\n"
            .. kbs_session.."\n"
            .. KillingBlowAnnouncer:GetPrevSession(info))
    kbtrackerTextProc:SetText("|cFFFFFFFF0%\n\n\n"..zone.."%\n")


    setTrackerFont();
end);
