Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download Tab not working #68

Merged
merged 5 commits into from
Mar 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions .github/workflows/manual_release_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ jobs:
run: |
REGEX_FIND_VERSION_TO_CHANGE_CONTENT_MD_FILE='(?<=version=")[^"]+'

perl -pi -e "s/$REGEX_FIND_VERSION_TO_CHANGE_CONTENT_MD_FILE/${{ steps.version.outputs.version }}/g" addons/admob/plugin.cfg
perl -pi -e "s/$REGEX_FIND_VERSION_TO_CHANGE_CONTENT_MD_FILE/${{env.TAG_PREFIX}}${{ steps.version.outputs.version }}/g" addons/admob/plugin.cfg

cat addons/admob/plugin.cfg

- name: Git Auto Commit
uses: stefanzweifel/[email protected]
id: auto-commit-action
with:
commit_message: Auto changed version with CI/CD

run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add .
git commit -m "Auto changed version with CI/CD"
git push

- name: Create Release
uses: ncipollo/[email protected]
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
fi

echo "GODOT_VERSION=${GODOT_VERSION}" >> $GITHUB_ENV
echo "TAG_PREFIX=godot${GODOT_VERSION}-v" >> $GITHUB_ENV
echo "TAG_PREFIX=godot${GODOT_VERSION}-" >> $GITHUB_ENV

- name: Get plugin version
uses: paulhatch/[email protected]
id: version
with:
tag_prefix: "${{env.TAG_PREFIX}}"
tag_prefix: "${{env.TAG_PREFIX}}v"
major_pattern: "BREAKING CHANGE:"
minor_pattern: "feat:"
version_format: "v${major}.${minor}.${patch}-alpha.${increment}"
Expand All @@ -40,7 +40,7 @@ jobs:
run: |
REGEX_FIND_VERSION_TO_CHANGE_CONTENT_MD_FILE='(?<=version=")[^"]+'

perl -pi -e "s/$REGEX_FIND_VERSION_TO_CHANGE_CONTENT_MD_FILE/${{ steps.version.outputs.version }}/g" addons/admob/plugin.cfg
perl -pi -e "s/$REGEX_FIND_VERSION_TO_CHANGE_CONTENT_MD_FILE/${{env.TAG_PREFIX}}${{ steps.version.outputs.version }}/g" addons/admob/plugin.cfg

- name: Compress .zip
run: |
Expand Down
68 changes: 3 additions & 65 deletions addons/admob/src/core/components/Downloads.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ var downloaded_plugin_version : String = ""
var version_support : Dictionary

var android_dictionary : Dictionary = {
"version" : ["CURRENT"],
"download_directory" : "res://addons/admob/downloads/android"
} :
set(value):
android_dictionary = value
$TabContainer/Android/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % android_dictionary.download_directory

var ios_dictionary : Dictionary = {
"version" : ["CURRENT"],
"download_directory" : "res://addons/admob/downloads/ios"
} :
set(value):
Expand All @@ -35,22 +33,9 @@ func _ready():
godot_version = godot_version.substr(0, godot_version.length()-2)

set_process(false)
set_version_platform_supported("ios")
set_version_platform_supported("android")
$TabContainer/Android/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % android_dictionary.download_directory
$TabContainer/iOS/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % ios_dictionary.download_directory

func set_version_platform_supported(platform):
if platform == "android":
$TabContainer/Android/VersionHBoxContainer/AndroidVersion.clear()
for i in android_dictionary.version:
$TabContainer/Android/VersionHBoxContainer/AndroidVersion.add_item(i)
elif platform == "ios":
$TabContainer/iOS/VersionHBoxContainer/iOSVersion.clear()
for i in ios_dictionary.version:
$TabContainer/iOS/VersionHBoxContainer/iOSVersion.add_item(i)


func _process(delta):
var bodySize = $TabContainer/HTTPRequest.get_body_size()
var downloadedBytes = $TabContainer/HTTPRequest.get_downloaded_bytes()
Expand Down Expand Up @@ -80,11 +65,7 @@ func _on_DownloadGoogleMobileAdsSdkiOS_pressed():
set_process(true)

func _on_DownloadiOSTemplate_pressed():
var ios_version = $TabContainer/iOS/VersionHBoxContainer/iOSVersion.text
if ios_version == "CURRENT":
ios_version = godot_version

var file_name = "ios-template-" + ios_version + ".zip"
var file_name = "ios-template-" + godot_version + ".zip"
var plugin_version = version_support.ios
$TabContainer/HTTPRequest.download_file = ios_dictionary.download_directory + "/" + file_name
$TabContainer/HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-ios/releases/download/" + plugin_version + "/" + file_name)
Expand All @@ -94,17 +75,7 @@ func _on_DownloadiOSTemplate_pressed():
set_process(true)

func _on_DownloadAndroidTemplate_pressed():
var android_version = $TabContainer/Android/VersionHBoxContainer/AndroidVersion.text.to_lower()
if android_version == "current":
android_version = godot_version

var android_target = $TabContainer/Android/TargetHBoxContainer/MenuButton.text.to_lower()

if android_target == "current":
android_target = "mono" if Engine.has_singleton("GodotSharp") else "standard"


var file_name = "android-"+ android_target + "-template-" + android_version + ".zip"
var file_name = "android-template-" + godot_version + ".zip"
var plugin_version = version_support.android
$TabContainer/HTTPRequest.download_file = android_dictionary.download_directory + "/" + file_name
$TabContainer/HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-android/releases/download/" + plugin_version + "/" + file_name)
Expand Down Expand Up @@ -139,7 +110,7 @@ func _on_iOSOpenDirectoryButton_pressed():
OS.shell_open(str("file://", path_directory))


func _on_VerifyNetworkGithub_network_status_changed(value : int):
func _on_verify_network_github_network_status_changed(value):
if value == $VerifyNetworkGithub.CONNECTED:
$TabContainer.visible = true
$DontHaveConnectionPanelContainer.visible = false
Expand All @@ -150,36 +121,3 @@ func _on_VerifyNetworkGithub_network_status_changed(value : int):

func _on_VersionSupportedHTTPRequest_supported_version_changed(value_dictionary : Dictionary):
version_support = value_dictionary
$VersionsAndroidSupportedHTTPRequest.request("https://api.github.com/repos/Poing-Studios/godot-admob-android/releases/tags/"+version_support["android"])
$VersionsiOSSupportedHTTPRequest.request("https://api.github.com/repos/Poing-Studios/godot-admob-ios/releases/tags/"+version_support["ios"])


func get_versions_platform_supported(body):
var test_json_conv = JSON.new()
test_json_conv.parse(body.get_string_from_utf8())
var json = test_json_conv.get_data()

var regex = RegEx.new()
regex.compile("[v](([0-9])+(\\.{0,1}([0-9]))*)+")

var versions_supported : Array

for asset in json["assets"]:
var godot_version = asset["name"]

var regex_result = regex.search(godot_version)
if regex_result:
if not versions_supported.has(regex_result.get_string()):
versions_supported.append(regex_result.get_string())

return versions_supported



func _on_VersionsiOSSupportedHTTPRequest_request_completed(result, response_code, headers, body):
ios_dictionary.version.append_array(get_versions_platform_supported(body))
set_version_platform_supported("ios")

func _on_VersionsAndroidSupportedHTTPRequest_request_completed(result, response_code, headers, body):
android_dictionary.version.append_array(get_versions_platform_supported(body))
set_version_platform_supported("android")
77 changes: 1 addition & 76 deletions addons/admob/src/core/components/Downloads.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,6 @@ text = "OPEN DIRECTORY"
[node name="AndroidChangeDirectoryFileDialog" type="FileDialog" parent="TabContainer/Android/ChangeDirectoryHBoxContainer"]
mode = 2

[node name="VersionHBoxContainer" type="HBoxContainer" parent="TabContainer/Android"]
layout_mode = 2

[node name="Label" type="Label" parent="TabContainer/Android/VersionHBoxContainer"]
layout_mode = 2
text = "Version:"

[node name="AndroidVersion" type="OptionButton" parent="TabContainer/Android/VersionHBoxContainer"]
layout_mode = 2
item_count = 3
selected = 0
popup/item_0/text = "CURRENT"
popup/item_0/id = 0
popup/item_1/text = "v3.5.1"
popup/item_1/id = 1
popup/item_2/text = "v3.5"
popup/item_2/id = 2

[node name="TargetHBoxContainer" type="HBoxContainer" parent="TabContainer/Android"]
layout_mode = 2

[node name="Label" type="Label" parent="TabContainer/Android/TargetHBoxContainer"]
layout_mode = 2
text = "Target:"

[node name="MenuButton" type="OptionButton" parent="TabContainer/Android/TargetHBoxContainer"]
layout_mode = 2

[node name="DownloadAndroidTemplate" type="Button" parent="TabContainer/Android"]
layout_mode = 2
text = "Download Android Template"
Expand Down Expand Up @@ -104,46 +76,6 @@ text = "OPEN DIRECTORY"
size = Vector2i(392, 162)
mode = 2

[node name="VersionHBoxContainer" type="HBoxContainer" parent="TabContainer/iOS"]
layout_mode = 2

[node name="Label" type="Label" parent="TabContainer/iOS/VersionHBoxContainer"]
layout_mode = 2
text = "Version:"

[node name="iOSVersion" type="OptionButton" parent="TabContainer/iOS/VersionHBoxContainer"]
layout_mode = 2
item_count = 14
selected = 0
popup/item_0/text = "CURRENT"
popup/item_0/id = 0
popup/item_1/text = "v3.3.1"
popup/item_1/id = 1
popup/item_2/text = "v3.3.2"
popup/item_2/id = 2
popup/item_3/text = "v3.3.3"
popup/item_3/id = 3
popup/item_4/text = "v3.3.4"
popup/item_4/id = 4
popup/item_5/text = "v3.3"
popup/item_5/id = 5
popup/item_6/text = "v3.4.1"
popup/item_6/id = 6
popup/item_7/text = "v3.4.2"
popup/item_7/id = 7
popup/item_8/text = "v3.4.3"
popup/item_8/id = 8
popup/item_9/text = "v3.4.4"
popup/item_9/id = 9
popup/item_10/text = "v3.4.5"
popup/item_10/id = 10
popup/item_11/text = "v3.4"
popup/item_11/id = 11
popup/item_12/text = "v3.5.1"
popup/item_12/id = 12
popup/item_13/text = "v3.5"
popup/item_13/id = 13

[node name="DownloadiOSTemplate" type="Button" parent="TabContainer/iOS"]
layout_mode = 2
text = "Download iOS Template"
Expand All @@ -160,7 +92,6 @@ layout_mode = 2
layout_mode = 2
bbcode_enabled = true
text = "[b]You don't have connection to the Server: https://github.com/, please verify your connection in order to Download[/b]"
fit_content_height = true
scroll_active = false

[node name="VerifyNetworkGithub" type="HTTPRequest" parent="."]
Expand All @@ -172,10 +103,6 @@ autostart = true

[node name="VersionSupportedHTTPRequest" parent="." instance=ExtResource("3")]

[node name="VersionsAndroidSupportedHTTPRequest" type="HTTPRequest" parent="."]

[node name="VersionsiOSSupportedHTTPRequest" type="HTTPRequest" parent="."]

[connection signal="request_completed" from="TabContainer/HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
[connection signal="pressed" from="TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidChangeDirectoryButton" to="." method="_on_AndroidChangeDirectoryButton_pressed"]
[connection signal="pressed" from="TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidOpenDirectoryButton" to="." method="_on_AndroidOpenDirectoryButton_pressed"]
Expand All @@ -186,9 +113,7 @@ autostart = true
[connection signal="dir_selected" from="TabContainer/iOS/ChangeDirectoryHBoxContainer/iOSChangeDirectoryFileDialog" to="." method="_on_iOSChangeDirectoryFileDialog_dir_selected"]
[connection signal="pressed" from="TabContainer/iOS/DownloadiOSTemplate" to="." method="_on_DownloadiOSTemplate_pressed"]
[connection signal="pressed" from="TabContainer/iOS/DownloadGoogleMobileAdsSdkiOS" to="." method="_on_DownloadGoogleMobileAdsSdkiOS_pressed"]
[connection signal="network_status_changed" from="VerifyNetworkGithub" to="." method="_on_VerifyNetworkGithub_network_status_changed"]
[connection signal="network_status_changed" from="VerifyNetworkGithub" to="." method="_on_verify_network_github_network_status_changed"]
[connection signal="request_completed" from="VerifyNetworkGithub" to="VerifyNetworkGithub" method="_on_VerifyNetworkGithub_request_completed"]
[connection signal="timeout" from="VerifyNetworkGithub/VerifyAgainTimer" to="VerifyNetworkGithub" method="_on_VerifyAgainTimer_timeout"]
[connection signal="supported_version_changed" from="VersionSupportedHTTPRequest" to="." method="_on_VersionSupportedHTTPRequest_supported_version_changed"]
[connection signal="request_completed" from="VersionsAndroidSupportedHTTPRequest" to="." method="_on_VersionsAndroidSupportedHTTPRequest_request_completed"]
[connection signal="request_completed" from="VersionsiOSSupportedHTTPRequest" to="." method="_on_VersionsiOSSupportedHTTPRequest_request_completed"]
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ layout_mode = 2

[node name="RespectSafeArea" type="CheckBox" parent="." index="1"]
layout_mode = 2
text = "Respect Safe Area3D (RECOMMEND TRUE)"
text = "Respect Safe Area (RECOMMEND TRUE)"
script = ExtResource("3")

[node name="ConfirmationDialog" type="ConfirmationDialog" parent="RespectSafeArea" index="0"]
dialog_text = "IT'S NOT RECOMMENDED LEAVE THIS AS FALSE

According to Google AdMob documentation for iOS: Banner ads must be placed in the \"Safe Area3D\" to avoid being obscured by rounded corners, sensor housing, and the Home indicator.
According to Google AdMob documentation for iOS: Banner ads must be placed in the \"Safe Area\" to avoid being obscured by rounded corners, sensor housing, and the Home indicator.

Read here: https://developers.google.com/admob/ios/x-ad-rendering"
dialog_autowrap = true
Expand Down
8 changes: 7 additions & 1 deletion addons/admob/src/utils/AdMobGlobals.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ static func get_plugin_version() -> String:
var plugin_config_file := ConfigFile.new()
plugin_config_file.load("res://addons/admob/plugin.cfg")
var version : String = plugin_config_file.get_value("plugin", "version")
return version

var regex = RegEx.new()
regex.compile("^.*?v1\\.0\\.1")
var result = regex.search(version)
if result:
return result.get_string()
return ""
2 changes: 1 addition & 1 deletion addons/admob/test/Example.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ text = "Position checked TOP"

[node name="RespectSafeArea" type="CheckBox" parent="Background/TabContainer/Banner"]
layout_mode = 2
text = "Respect Safe Area3D (RECOMMENDED TRUE)"
text = "Respect Safe Area (RECOMMENDED TRUE)"

[node name="BannerSizes" type="ItemList" parent="Background/TabContainer/Banner"]
layout_mode = 2
Expand Down