diff --git a/addons/admob/admob.gd b/addons/admob/admob.gd index 23ea258..5449981 100644 --- a/addons/admob/admob.gd +++ b/addons/admob/admob.gd @@ -19,8 +19,8 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. - @tool +class_name AdMobEditorPlugin extends EditorPlugin var http_request_downloader := HTTPRequest.new() @@ -34,8 +34,8 @@ var godot_version := "v" + str(Engine.get_version_info().major) + "." + str(Engi var plugin_version := get_plugin_version() var version_support := { - "android": "v3.0.0", - "ios": "v3.0.0" + "android": "v3.0.2", + "ios": "v3.0.2" } enum Items { @@ -44,7 +44,21 @@ enum Items { GitHub } + +class PoingAdMobEditorExportPlugin extends EditorExportPlugin: + const CFG_FILE_PATH := "res://addons/admob/plugin.cfg" + + func _export_begin(features: PackedStringArray, is_debug: bool, path: String, flags: int) -> void: + var file = FileAccess.open(CFG_FILE_PATH, FileAccess.READ) + if file: + print("Exporting Poing AdMob '.cfg' file") + add_file(CFG_FILE_PATH, file.get_buffer(file.get_length()), false) + file.close() + +var _exporter := PoingAdMobEditorExportPlugin.new() func _enter_tree(): + add_export_plugin(_exporter) + setup_timer() create_download_directories() _request_version_support() @@ -80,11 +94,12 @@ func _enter_tree(): add_tool_submenu_item("AdMob Download Manager", popup) func _exit_tree(): + remove_export_plugin(_exporter) remove_tool_menu_item("AdMob Download Manager") func _request_version_support(): - var url = "https://raw.githubusercontent.com/Poing-Studios/godot-admob-versions/" + plugin_version + "/versions.json" + var url = "https://raw.githubusercontent.com/Poing-Studios/godot-admob-versions/" + get_plugin_version() + "/versions.json" var http_request = HTTPRequest.new() http_request.request_completed.connect(_on_version_support_request_completed) add_child(http_request) @@ -161,19 +176,7 @@ func _on_popupmenu_id_pressed(id : int): var path_directory = ProjectSettings.globalize_path(default_download_path) OS.shell_open(str("file://", path_directory)) Items.GitHub: - OS.shell_open("https://github.com/Poing-Studios/godot-admob-plugin/tree/" + plugin_version) - - -func get_plugin_version() -> String: - var plugin_config_file := ConfigFile.new() - var version: String = "" - - if plugin_config_file.load("res://addons/admob/plugin.cfg") == OK: - version = plugin_config_file.get_value("plugin", "version") - else: - printerr("Failed to load plugin.cfg") - - return version + OS.shell_open("https://github.com/Poing-Studios/godot-admob-plugin/tree/" + get_plugin_version()) func show_download_percent(url_download: String = ""): if not url_download.is_empty(): diff --git a/addons/admob/plugin.cfg b/addons/admob/plugin.cfg index 453255b..6f67b5a 100644 --- a/addons/admob/plugin.cfg +++ b/addons/admob/plugin.cfg @@ -3,5 +3,5 @@ name="AdMob" description="The AdMob Plugin for Android and iOS." author="Poing Studios" -version="v3.0.0" +version="v3.0.1" script="admob.gd" diff --git a/addons/admob/src/api/core/AdRequest.gd b/addons/admob/src/api/core/AdRequest.gd index 790614f..aa8c8f2 100644 --- a/addons/admob/src/api/core/AdRequest.gd +++ b/addons/admob/src/api/core/AdRequest.gd @@ -29,7 +29,8 @@ var extras : Dictionary func convert_to_dictionary() -> Dictionary: return { "mediation_extras" : _transform_mediation_extras_to_dictionary(), - "extras" : extras + "extras" : extras, + "google_request_agent" : "Godot-PoingStudios-"+PoingAdMobVersionHelper.version_formated } func _transform_mediation_extras_to_dictionary() -> Dictionary: @@ -41,3 +42,4 @@ func _transform_mediation_extras_to_dictionary() -> Dictionary: "extras" : extra.extras } return mediation_extras_dictionary + diff --git a/addons/admob/version_helper.gd b/addons/admob/version_helper.gd new file mode 100644 index 0000000..28d85a2 --- /dev/null +++ b/addons/admob/version_helper.gd @@ -0,0 +1,46 @@ +# MIT License + +# Copyright (c) 2023-present Poing Studios + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + +class_name PoingAdMobVersionHelper +extends Object + +static var version_formated : String = _get_plugin_version_formated() : + set(value): + version_formated = _get_plugin_version_formated() + +static func _get_plugin_version_formated() -> String: + var plugin_config_file := ConfigFile.new() + var version: String = "v3.0.1" #redundancy + + if plugin_config_file.load("res://addons/admob/plugin.cfg") == OK: + version = plugin_config_file.get_value("plugin", "version") + else: + push_error("Failed to load plugin.cfg") + + var pattern = RegEx.new() + pattern.compile("(?:v)?(\\d+\\.\\d+\\.\\d+)") + + var matchs := pattern.search(version) + if matchs != null: + version = matchs.get_string(1) + return version + diff --git a/project.godot b/project.godot index b2392b8..f5e3d71 100644 --- a/project.godot +++ b/project.godot @@ -71,7 +71,7 @@ config={ config/name="AdMobAddon" run/main_scene="res://addons/admob/sample/Main.tscn" -config/features=PackedStringArray("4.1", "GL Compatibility") +config/features=PackedStringArray("4.2", "GL Compatibility") config/icon="res://addons/admob/assets/icon-76.png" [display]