--
-- Created by IntelliJ IDEA.
-- User: Eucalyptisch
-- Date: 26-1-2016
-- Time: 18:58
--

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.13|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);
