dim runtime,androidRootFiles,androidProjectSourceMain,androidProjectXML,rootPath,isAmazon,androidProjectFiles,admobAppId
runtime = "2.2.1.291"
if WScript.Arguments.Count = 0 then
WScript.Echo "Missing parameters"
wscript.quit
end if
Const ForReading = 1
Const ForWriting = 2
androidRootFiles = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\android\runner\RootFiles"
androidProjectSourceMain = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\android\runner\ProjectFiles\src\main"
androidProjectFiles = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\android\runner\ProjectFiles"
androidProjectXML = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\android\runner\ProjectFiles\src\main\res\xml"
androidRunner = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\android\runner\ProjectFiles\src\main\java\YYAndroidPackageDomain\YYAndroidPackageCompany\YYAndroidPackageProduct"
iosProjectRoot = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\ios\TemplateProject\${YYXCodeProjName}"
iosProjectFile = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\ios\TemplateProject\${YYXCodeProjName}.xcodeproj"
iosFoldersRoot = "C:\ProgramData\GameMakerStudio2\Cache\runtimes\runtime-" & runtime & "\ios\TemplateProject"
rootPath = WScript.Arguments(0) ' The Path of the GMS projet where the expected files exist
isAmazon = WScript.Arguments(1) ' If True indicates we are building for the Amazon store
admobAppId = WScript.Arguments(2) ' The Admob ID to update the Appodeal manifest
langs = WScript.Arguments(3) ' The iOS languages to support 'ES,FR'
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
dim scriptdir
scriptdir = fso.GetParentFolderName(WScript.ScriptFullName)
' If the network_security_config.xml file is not in place then run the following one time copy instructions
If (not Fso.FileExists(androidProjectXML & "\network_security_config.xml")) Then
' Copy Resources folder for Appodeal
Fso.CopyFolder scriptdir & "\Resources", iosFoldersRoot & "\Resources"
' Copy the network_security_config.xml and AndroidManifest.xml
Fso.CopyFile scriptdir & "\network_security_config.xml", androidProjectXML & "\network_security_config.xml"
Fso.CopyFile scriptdir & "\AndroidManifest.xml", androidProjectSourceMain & "\AndroidManifest.xml"
' Create the French and Spanish languages (even though we may only use one or both)
Fso.CopyFolder iosProjectRoot & "\en.lproj", iosProjectRoot & "\es.lproj"
Fso.CopyFolder iosProjectRoot & "\en.lproj", iosProjectRoot & "\fr.lproj"
' Copy modifications to the Android Runner
Fso.CopyFile scriptdir & "\RunnerActivity.java", androidRunner & "\RunnerActivity.java"
MsgBox("Copied : " + chr(13) + "RunnerActivity.java" + chr(13) + "Appodeal Resources folder" + chr(13) + "network_security_config.xml" + chr(13) + "AndroidManifest.xml" + chr(13) + "fr.lproj (ios)" + chr(13) + "es.lproj" + chr(13) + "Runtime : " & runtime )
end if
' Copy the gradle modified files
Fso.CopyFile scriptdir & "\root-build.gradle", androidRootFiles & "\build.gradle"
Fso.CopyFile scriptdir & "\project-build.gradle", androidProjectFiles & "\build.gradle"
' Modify the Appodeal manifest which includes the ADMOB ApplicationID
dim first,second
Set objFile = Fso.OpenTextFile(rootPath & "\extensions\AppodealAds\AppodealAds.yy", ForReading)
strText = objFile.ReadAll
objFile.Close
first = Left(strText,InStr(strText,"ca-app-pub-XXXXXXX~")-1) ' This is the admob id which is the same for all apps replace XXXXXXX with your actual admob publisher id
second = Mid(strText,InStr(strText,"ca-app-pub-XXXXXX~"))
second = Mid(second, InStr(second,"\"))
strNewText = first & admobAppId & second
Set objFile = Fso.OpenTextFile(rootPath & "\extensions\AppodealAds\AppodealAds.yy", ForWriting)
objFile.WriteLine strNewText
objFile.Close
'''''''''''''''''
' iOS
'''''''''''''''''
' Copy the GoogleService-Info.plist to iOS
Fso.CopyFile rootPath & "\GoogleService-Info.plist", iosProjectRoot & "\GoogleService-Info.plist"
' Copy the project.pbxproj to iOS - Then modify to replace the languages to be used
Fso.CopyFile scriptdir & "\project.pbxproj", iosProjectFile & "\project.pbxproj"
Set objFile = Fso.OpenTextFile(iosProjectFile & "\project.pbxproj", ForReading)
strText = objFile.ReadAll
objFile.Close
strNewText = Replace(strText, "${AdditionalLanguages}", langs)
Set objFile = Fso.OpenTextFile(iosProjectFile & "\project.pbxproj", ForWriting)
objFile.WriteLine strNewText
objFile.Close
' Get Project Folder Name
dim projectName,store
projectName = Fso.getfolder(rootPath).Name
if (isAmazon) then
Fso.CopyFile rootPath & "\google-services-amazon.json", androidProjectFiles & "\google-services.json"
' Copy the Amazon Login api_key
Fso.CopyFile rootPath & "\api_key_amazon.txt", rootPath & "\datafiles\api_key.txt"
store = "AMAZON"
else
Fso.CopyFile rootPath & "\google-services.json", androidProjectFiles & "\google-services.json"
' Copy the Amazon Login api_key
Fso.CopyFile rootPath & "\api_key_googleplay.txt", rootPath & "\datafiles\api_key.txt"
store = "Google Play"
end if
MsgBox("Project : " & projectName & chr(13) & "Runtime : " & runtime & chr(13) & chr(13) & "Android : " & store)