GlobalFunctions = GlobalFunctions or {}

function ShowNotice(info)
    local uiControllerPath = "UI/Public/SUINoticeText.lua"
	require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
	require(uiControllerPath).NoticeInfo(info)
end

function ShowDialogOK(tips)
	local uiControllerPath = "UI/Public/SUIDialogOKPanel.lua"
	require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
	require(uiControllerPath).SetInfo(tips)
end

function ShowDialogConfirm(tips, confirmFunction, cancelFunction)
    local uiControllerPath = "UI/Public/SUIDialogConfirmPanel.lua"
	require("Base/UIHelper.lua"):OpenUI(uiControllerPath)
	require(uiControllerPath).SetInfo(tips, confirmFunction, cancelFunction)
end

local function __TRACKBACK__(szErrorMsg)
    local szTrackText = debug.traceback(tostring(szErrorMsg), 6);
    print("---------------------------------------- TRACKBACK ----------------------------------------");
    print(szTrackText, "LUA ERROR");
    print("---------------------------------------- TRACKBACK ----------------------------------------");
    local szExceptionText = "LUA EXCEPTION\n" .. szTrackText;

    --[[Error("---------------------------------------- TRACKBACK ----------------------------------------");
    Error(szTrackText ..  " LUA ERROR");
    Error("---------------------------------------- TRACKBACK ----------------------------------------");
    Error(szExceptionText)]]
    CS.UnityEngine.Debug.LogWarning(szExceptionText)

    return false;
end

function SafeCall(fnFunc, ...)
    local tArgs = { ... };
    return xpcall(function() return fnFunc(table.unpack(tArgs)) end, __TRACKBACK__);
end
