Begin porting common functions to common file
For easier readability and expandability
This commit is contained in:
@@ -27,11 +27,15 @@
|
|||||||
],
|
],
|
||||||
"Scripts": [
|
"Scripts": [
|
||||||
{
|
{
|
||||||
"Path": "pulse.gnut",
|
"Path":"pulse-common-func.gnut",
|
||||||
"RunOn": "UI",
|
"RunOn":"UI"
|
||||||
"UICallback": {
|
},
|
||||||
"After": "pulseInit"
|
{
|
||||||
}
|
"Path": "pulse.gnut",
|
||||||
|
"RunOn": "UI",
|
||||||
|
"UICallback": {
|
||||||
|
"After": "pulseInit"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
globalize_all_functions
|
||||||
|
|
||||||
|
|
||||||
|
void function pulsePrintt (string content)
|
||||||
|
{
|
||||||
|
printt(format("%s " + content, pulsePrefix))
|
||||||
|
}
|
||||||
|
|
||||||
|
table function pulseGetCurrentVersionAsTable
|
||||||
|
{
|
||||||
|
table result = ["MajorVersion" = GetConVarString("MajorVersion"), "MinorVersion" = GetConVarString("MinorVersion"), "PatchVersion" = GetConVarString("PatchVersion")]
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
string function pulseFormatAsVersion(table Version)
|
||||||
|
{
|
||||||
|
return format("v%s.%s.%s", Version["MajorVersion"], Version["MinorVersion"], Version["PatchVersion"])
|
||||||
|
}
|
||||||
|
|
||||||
|
bool function pulseIsUpToDate(string givenURL)
|
||||||
|
{
|
||||||
|
bool result = false
|
||||||
|
HttpRequest versionreq
|
||||||
|
versionreq.method = HttpRequestMethod.GET
|
||||||
|
versionreq.url = givenURL
|
||||||
|
void functionref (HttpRequestResponse) onSuccess = void function(HttpRequestResponse response)
|
||||||
|
{
|
||||||
|
table DecodedJSON = DecodeJSON(response.body)
|
||||||
|
if (pulseFormatAsVersion(DecodedJSON) == pulseFormatAsVersion(pulseGetCurrentVersionAsTable()))
|
||||||
|
{
|
||||||
|
result = true
|
||||||
|
} else {
|
||||||
|
result = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void functionref (HttpRequestFailure) onFailure = void function(HttpRequestFailure failure)
|
||||||
|
{
|
||||||
|
pulsePrintt("Something went wrong while getting latest version.")
|
||||||
|
}
|
||||||
|
NSHttpRequest(versionreq, onSuccess, onFailure)
|
||||||
|
return result
|
||||||
|
}
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"Major": "2",
|
"MajorVersion": "2",
|
||||||
"Minor": "0",
|
"MinorVersion": "0",
|
||||||
"Patch": "0"
|
"PatchVersion": "0"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user