99 lines
No EOL
3.5 KiB
Lua
99 lines
No EOL
3.5 KiB
Lua
---
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
--- Created by admin.
|
|
--- DateTime: 2020/10/15 18:05
|
|
---
|
|
|
|
XAgreementManager = XAgreementManager or {}
|
|
|
|
XAgreementManager.UserAgreeLicence = nil
|
|
|
|
XAgreementManager.CurAgree = ""
|
|
XAgreementManager.CurPriva = ""
|
|
|
|
local USER_AGREEMENT_URL = "https://kurogame.net/download/termsofservice.txt"
|
|
local USER_PRIVACY_URL = "https://kurogame.net/download/privacypolicy.txt"
|
|
|
|
local LOCAL_SAVE_AGREE = "LOCAL_SAVE_AGREE"
|
|
local LOCAL_SAVE_PRIVE = "LOCAL_SAVE_PRIVE"
|
|
|
|
function XAgreementManager.SetUserAgreeLicence(agree)
|
|
XAgreementManager.UserAgreeLicence = agree
|
|
end
|
|
|
|
function XAgreementManager.GetUserAgreeLicence()
|
|
return XAgreementManager.UserAgreeLicence
|
|
end
|
|
|
|
function XAgreementManager.SetDelegate(delegate)
|
|
XAgreementManager.CheckDelegate = delegate
|
|
end
|
|
|
|
function XAgreementManager.CheckNeedShow()
|
|
local saveAgree = XSaveTool.GetData(LOCAL_SAVE_AGREE)
|
|
local savePrive = XSaveTool.GetData(LOCAL_SAVE_PRIVE)
|
|
|
|
if saveAgree == nil or savePrive == nil then
|
|
XAgreementManager.SetUserAgreeLicence(false)
|
|
return true
|
|
end
|
|
|
|
if XAgreementManager.CurAgree == "" or XAgreementManager.CurPriva == "" then
|
|
XAgreementManager.CurAgree = saveAgree
|
|
XAgreementManager.CurPriva = savePrive
|
|
XAgreementManager.SetUserAgreeLicence(true)
|
|
return false
|
|
end
|
|
|
|
if XAgreementManager.CurAgree ~= saveAgree or XAgreementManager.CurPriva ~= savePrive then
|
|
XAgreementManager.SetUserAgreeLicence(false)
|
|
return true
|
|
end
|
|
|
|
XAgreementManager.SetUserAgreeLicence(true)
|
|
return false
|
|
end
|
|
|
|
function XAgreementManager.LoadAgreeInfo()
|
|
XLuaUiManager.SetAnimationMask("LoadAgree", true)
|
|
XAgreementManager.NeedLoadCount = 2
|
|
local agreementRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(USER_AGREEMENT_URL)
|
|
CS.XTool.WaitNativeCoroutine(agreementRequest:SendWebRequest(), function()
|
|
if agreementRequest.isNetworkError or agreementRequest.isHttpError or agreementRequest.isError then
|
|
XLuaUiManager.SetAnimationMask("LoadAgree", false)
|
|
return
|
|
end
|
|
XAgreementManager.CurAgree = agreementRequest.downloadHandler.text or ""
|
|
agreementRequest:Dispose()
|
|
XAgreementManager.NeedLoadCount = XAgreementManager.NeedLoadCount - 1
|
|
if XAgreementManager.NeedLoadCount == 0 then
|
|
XLuaUiManager.SetAnimationMask("LoadAgree",false)
|
|
XEventManager.DispatchEvent(XEventId.EVENT_AGREEMENT_LOAD_FINISH)
|
|
end
|
|
end)
|
|
local privacyRequest = CS.UnityEngine.Networking.UnityWebRequest.Get(USER_PRIVACY_URL)
|
|
CS.XTool.WaitNativeCoroutine(privacyRequest:SendWebRequest(), function()
|
|
if privacyRequest.isNetworkError or privacyRequest.isHttpError or privacyRequest.isError then
|
|
XLuaUiManager.SetAnimationMask("LoadAgree",false)
|
|
return
|
|
end
|
|
XAgreementManager.CurPriva = privacyRequest.downloadHandler.text or ""
|
|
privacyRequest:Dispose()
|
|
XAgreementManager.NeedLoadCount = XAgreementManager.NeedLoadCount - 1
|
|
if XAgreementManager.NeedLoadCount == 0 then
|
|
XLuaUiManager.SetAnimationMask("LoadAgree",false)
|
|
XEventManager.DispatchEvent(XEventId.EVENT_AGREEMENT_LOAD_FINISH)
|
|
end
|
|
end)
|
|
end
|
|
|
|
function XAgreementManager.SplitLongText(str)
|
|
local len = #str
|
|
local half = math.floor(len / 2)
|
|
local _, e = string.find(str, '\r\n', half, true)
|
|
if e ~= nil then
|
|
return string.sub(str, 1, e), string.sub(str, e + 1, len)
|
|
else
|
|
return str, ""
|
|
end
|
|
end |