#****************************************************************************
#**
#**  File     :  /lua/ui/game/CBFP_UI.lua
#**  Author(s):  Brute51
#**
#**  Summary  :  This displays a message when not using the correct FA version.
#**
#****************************************************************************

local CreateAnnouncement = import('/lua/ui/game/announcement.lua').CreateAnnouncement
local Game = import('/lua/game.lua')

function GetRequiredFaVersion()
    for k, mod in __active_mods do
        if Game.CBFP_ModUID == mod.uid then
            return mod.FAversion or nil
        end
    end
end

function VerifyFaVersion()
    local reqVersion = GetRequiredFaVersion() or nil
    return GetVersion(), reqVersion
end

function DisplayVersionConflictWarning( reqVersion, curVersion)
    local parent = import('/lua/ui/game/borders.lua').GetMapGroup()
    local text1 = "CBFP version conflict - please update the CBFP"
    local text2 = "Forged Alliance version: "..curVersion.." but CBFP wants version: "..reqVersion..". Please update."
    CreateAnnouncement(text1, parent, text2)
end

function InitUI( SessionIsReplay)
    if not SessionIsReplay then
        local curVersion, reqVersion = VerifyFaVersion()
        if curVersion != reqVersion then
            DisplayVersionConflictWarning( reqVersion, curVersion)
        end
    end
end