diff --git a/.gitignore b/.gitignore index 9cde025..bc41454 100755 --- a/.gitignore +++ b/.gitignore @@ -14,9 +14,11 @@ export_presets.cfg # Mono-specific ignores .mono/ +mono_crash*.json data_*/ AdMobAddon.csproj AdMobAddon.sln + android/ -ios/ \ No newline at end of file +ios/ diff --git a/README.md b/README.md index de656c1..d54c472 100755 --- a/README.md +++ b/README.md @@ -24,3 +24,44 @@ After you installed, the Plugin will automaticly add an AutoLoad called `MobileA A example scene is here: `res://addons/admob/develop/Example.tscn` To your plugin work, you need to download the `AdMob Plugin` here: https://github.com/Poing-Studios/Godot-AdMob-Android-iOS#readme + + +# Signals: +``` +signal initialization_complete(status, adapter_name) + +signal consent_form_dismissed() +signal consent_status_changed(consent_status_message) +signal consent_form_load_failure(error_code, error_message) +signal consent_info_update_success(consent_status_message) +signal consent_info_update_failure(error_code, error_message) + +signal banner_loaded() +signal banner_failed_to_load(error_code) +signal banner_opened() +signal banner_clicked() +signal banner_closed() +signal banner_recorded_impression() +signal banner_destroyed() + +signal interstitial_failed_to_load(error_code) +signal interstitial_loaded() +signal interstitial_failed_to_show(error_code) +signal interstitial_opened() +signal interstitial_closed() + +signal rewarded_ad_failed_to_load(error_code) +signal rewarded_ad_loaded() +signal rewarded_ad_failed_to_show(error_code) +signal rewarded_ad_opened() +signal rewarded_ad_closed() + +signal rewarded_interstitial_ad_failed_to_load(error_code) +signal rewarded_interstitial_ad_loaded() +signal rewarded_interstitial_ad_failed_to_show(error_code) +signal rewarded_interstitial_ad_opened() +signal rewarded_interstitial_ad_closed() + +signal user_earned_rewarded(currency, amount) + +``` diff --git a/addons/admob/.gitignore b/addons/admob/.gitignore new file mode 100644 index 0000000..6f66c74 --- /dev/null +++ b/addons/admob/.gitignore @@ -0,0 +1 @@ +*.zip \ No newline at end of file diff --git a/addons/admob/AdMob.gd b/addons/admob/AdMob.gd deleted file mode 100755 index cb2f6ea..0000000 --- a/addons/admob/AdMob.gd +++ /dev/null @@ -1,27 +0,0 @@ -tool -extends EditorPlugin - -var AdMobConfigScene : Control - -func _enter_tree(): - add_autoload_singleton("MobileAds", "res://addons/admob/scripts/MobileAds.gd") - AdMobConfigScene = load("res://addons/admob/scenes/AdMobConfig.tscn").instance() - get_editor_interface().get_editor_viewport().add_child(AdMobConfigScene) - AdMobConfigScene.hide() - -func _exit_tree(): - remove_autoload_singleton("MobileAds") - get_editor_interface().get_editor_viewport().remove_child(AdMobConfigScene) - AdMobConfigScene.queue_free() - -func has_main_screen(): - return true - -func make_visible(visible): - AdMobConfigScene.visible = visible - -func get_plugin_name(): - return "AdMob" - -func get_plugin_icon(): - return load("res://addons/admob/assets/icon-15.png") diff --git a/addons/admob/assets/android.png b/addons/admob/assets/android.png new file mode 100644 index 0000000..bae5dce Binary files /dev/null and b/addons/admob/assets/android.png differ diff --git a/addons/admob/assets/android.png.import b/addons/admob/assets/android.png.import new file mode 100644 index 0000000..9ea6f99 --- /dev/null +++ b/addons/admob/assets/android.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/android.png-fb2caea48032eea3d74244daf04c3454.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/android.png" +dest_files=[ "res://.import/android.png-fb2caea48032eea3d74244daf04c3454.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/assets/fonts/arial.ttf b/addons/admob/assets/fonts/arial.ttf new file mode 100644 index 0000000..8682d94 Binary files /dev/null and b/addons/admob/assets/fonts/arial.ttf differ diff --git a/addons/admob/assets/ios.png b/addons/admob/assets/ios.png new file mode 100644 index 0000000..7a6dec4 Binary files /dev/null and b/addons/admob/assets/ios.png differ diff --git a/addons/admob/assets/ios.png.import b/addons/admob/assets/ios.png.import new file mode 100644 index 0000000..bfcbce8 --- /dev/null +++ b/addons/admob/assets/ios.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/ios.png" +dest_files=[ "res://.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/config/Settings.gd b/addons/admob/config/Settings.gd deleted file mode 100644 index 272cbb4..0000000 --- a/addons/admob/config/Settings.gd +++ /dev/null @@ -1,34 +0,0 @@ -extends Node - -var config : Dictionary = { - "banner": { - "position": 0, - "show_instantly": true, - "size": 0 - }, - "is_enabled": true, - "is_for_child_directed_treatment": true, - "is_real": false, - "is_test_europe_user_consent": true, - "max_ad_content_rating": 0, - "position": 0, - "size": 4, - "unit_ids": { - "banner": { - "Android": "ca-app-pub-3940256099942544/6300978111", - "iOS": "ca-app-pub-3940256099942544/2934735716" - }, - "interstitial": { - "Android": "ca-app-pub-3940256099942544/1033173712", - "iOS": "ca-app-pub-3940256099942544/4411468910" - }, - "rewarded": { - "Android": "ca-app-pub-3940256099942544/5224354917", - "iOS": "ca-app-pub-3940256099942544/1712485313" - }, - "rewarded_interstitial": { - "Android": "ca-app-pub-3940256099942544/5354046379", - "iOS": "ca-app-pub-3940256099942544/6978759866" - } - } -} \ No newline at end of file diff --git a/addons/admob/downloads/android/.gitkeep b/addons/admob/downloads/android/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/addons/admob/downloads/ios/.gitkeep b/addons/admob/downloads/ios/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/addons/admob/plugin.cfg b/addons/admob/plugin.cfg index d6ced84..75d57f2 100644 --- a/addons/admob/plugin.cfg +++ b/addons/admob/plugin.cfg @@ -3,5 +3,5 @@ name="AdMob" description="The AdMob of Plugin for Android and iOS." author="Poing Studios" -version="0.4.2" -script="AdMob.gd" +version="1.0.0" +script="src/core/AdMob.gd" diff --git a/addons/admob/scenes/AdMobConfig.tscn b/addons/admob/scenes/AdMobConfig.tscn deleted file mode 100644 index c4eb792..0000000 --- a/addons/admob/scenes/AdMobConfig.tscn +++ /dev/null @@ -1,396 +0,0 @@ -[gd_scene load_steps=6 format=2] - -[ext_resource path="res://addons/admob/scripts/AdMobConfig.gd" type="Script" id=1] -[ext_resource path="res://addons/admob/assets/fonts/orange_juice_2_0.ttf" type="DynamicFontData" id=2] - -[sub_resource type="StyleBoxFlat" id=1] -draw_center = false - -[sub_resource type="StyleBoxFlat" id=2] -bg_color = Color( 0.25098, 0.52549, 0.956863, 1 ) - -[sub_resource type="DynamicFont" id=3] -size = 36 -use_filter = true -font_data = ExtResource( 2 ) - -[node name="AdMobConfig" type="Control"] -pause_mode = 2 -anchor_right = 1.144 -anchor_bottom = 1.00111 -margin_bottom = -6.10352e-05 -rect_clip_content = true -mouse_filter = 1 -size_flags_horizontal = 3 -size_flags_vertical = 3 -script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": true -} - -[node name="PanelContainer" type="PanelContainer" parent="."] -margin_right = 14.0 -margin_bottom = 14.0 -custom_styles/panel = SubResource( 1 ) -__meta__ = { -"_edit_lock_": true, -"_edit_use_anchors_": false -} - -[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"] -margin_right = 532.0 -margin_bottom = 469.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="TopPanel" type="Panel" parent="PanelContainer/VBoxContainer"] -margin_right = 532.0 -margin_bottom = 40.0 -rect_min_size = Vector2( 0, 40 ) -custom_styles/panel = SubResource( 2 ) - -[node name="CurrentVersion" type="Label" parent="PanelContainer/VBoxContainer/TopPanel"] -anchor_bottom = 1.0 -margin_right = 88.0 -custom_fonts/font = SubResource( 3 ) -custom_colors/font_color = Color( 0.984314, 0.741176, 0, 1 ) -text = "Version: 0.4.2" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Enabled" type="CheckBox" parent="PanelContainer/VBoxContainer"] -margin_top = 44.0 -margin_right = 532.0 -margin_bottom = 68.0 -pressed = true -text = "Enabled" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="TestEuropeUserConsent" type="CheckBox" parent="PanelContainer/VBoxContainer"] -margin_top = 72.0 -margin_right = 532.0 -margin_bottom = 96.0 -pressed = true -text = "Test Europe User Consent" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="BannerShowInstantly" type="CheckBox" parent="PanelContainer/VBoxContainer"] -margin_top = 100.0 -margin_right = 532.0 -margin_bottom = 124.0 -pressed = true -text = "Show Banner Instantly" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="BannerSizeHBoxContainer" type="HBoxContainer" parent="PanelContainer/VBoxContainer"] -margin_top = 128.0 -margin_right = 532.0 -margin_bottom = 148.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Label" type="Label" parent="PanelContainer/VBoxContainer/BannerSizeHBoxContainer"] -margin_top = 3.0 -margin_right = 75.0 -margin_bottom = 17.0 -text = "Banner Size" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="BannerSize" type="OptionButton" parent="PanelContainer/VBoxContainer/BannerSizeHBoxContainer"] -margin_left = 79.0 -margin_right = 161.0 -margin_bottom = 20.0 -text = "BANNER" -items = [ "BANNER", null, false, 0, null, "MEDIUM_RECTANGLE", null, false, 1, null, "FULL_BANNER", null, false, 2, null, "LEADERBOARD", null, false, 3, null, "ADAPTIVE", null, false, 4, null, "SMART_BANNER", null, false, 5, null ] -selected = 0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="BannerOnTop" type="CheckBox" parent="PanelContainer/VBoxContainer"] -margin_top = 152.0 -margin_right = 532.0 -margin_bottom = 176.0 -text = "Banner On Top" - -[node name="ChildDirectedTreatment" type="CheckBox" parent="PanelContainer/VBoxContainer"] -margin_top = 180.0 -margin_right = 532.0 -margin_bottom = 204.0 -pressed = true -text = "Child Directed Treatment" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="MaxAdContentRating" type="HBoxContainer" parent="PanelContainer/VBoxContainer"] -margin_top = 208.0 -margin_right = 532.0 -margin_bottom = 228.0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Key" type="Label" parent="PanelContainer/VBoxContainer/MaxAdContentRating"] -margin_top = 3.0 -margin_right = 132.0 -margin_bottom = 17.0 -text = "MaxAdContentRating" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Value" type="OptionButton" parent="PanelContainer/VBoxContainer/MaxAdContentRating"] -margin_left = 136.0 -margin_right = 175.0 -margin_bottom = 20.0 -text = "G" -items = [ "G", null, false, 0, null, "PG", null, false, 1, null, "T", null, false, 2, null, "MA", null, false, 3, null ] -selected = 0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="UnitIds" type="HBoxContainer" parent="PanelContainer/VBoxContainer"] -margin_top = 232.0 -margin_right = 532.0 -margin_bottom = 382.0 -rect_min_size = Vector2( 532, 150 ) -size_flags_horizontal = 3 -size_flags_vertical = 3 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Description" type="Label" parent="PanelContainer/VBoxContainer/UnitIds"] -margin_top = 68.0 -margin_right = 58.0 -margin_bottom = 82.0 -text = "UNIT IDS" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="TabContainer" type="TabContainer" parent="PanelContainer/VBoxContainer/UnitIds"] -margin_left = 62.0 -margin_right = 532.0 -margin_bottom = 150.0 -size_flags_horizontal = 3 -tab_align = 0 -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Android" type="GridContainer" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer"] -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 4.0 -margin_top = 32.0 -margin_right = -4.0 -margin_bottom = -4.0 -size_flags_horizontal = 3 -size_flags_vertical = 3 -columns = 2 - -[node name="Key" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_top = 5.0 -margin_right = 129.0 -margin_bottom = 19.0 -text = "Banner" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Banner" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_left = 133.0 -margin_right = 436.0 -margin_bottom = 24.0 -text = "ca-app-pub-3940256099942544/6300978111" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="Key2" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_top = 33.0 -margin_right = 129.0 -margin_bottom = 47.0 -text = "Interstitial" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Interstitial" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_left = 133.0 -margin_top = 28.0 -margin_right = 436.0 -margin_bottom = 52.0 -text = "ca-app-pub-3940256099942544/1033173712" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="Key3" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_top = 61.0 -margin_right = 129.0 -margin_bottom = 75.0 -text = "Rewarded" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Rewarded" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_left = 133.0 -margin_top = 56.0 -margin_right = 436.0 -margin_bottom = 80.0 -text = "ca-app-pub-3940256099942544/5224354917" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="Key4" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_top = 89.0 -margin_right = 129.0 -margin_bottom = 103.0 -text = "RewardedInterstitial" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="RewardedInterstitial" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android"] -margin_left = 133.0 -margin_top = 84.0 -margin_right = 436.0 -margin_bottom = 108.0 -text = "ca-app-pub-3940256099942544/5354046379" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="iOS" type="GridContainer" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer"] -visible = false -anchor_right = 1.0 -anchor_bottom = 1.0 -margin_left = 4.0 -margin_top = 32.0 -margin_right = -4.0 -margin_bottom = -4.0 -columns = 2 - -[node name="Key" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_top = 5.0 -margin_right = 129.0 -margin_bottom = 19.0 -text = "Banner" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Banner" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_left = 133.0 -margin_right = 436.0 -margin_bottom = 24.0 -text = "ca-app-pub-3940256099942544/2934735716" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="Key2" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_top = 33.0 -margin_right = 129.0 -margin_bottom = 47.0 -text = "Interstitial" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Interstitial" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_left = 133.0 -margin_top = 28.0 -margin_right = 436.0 -margin_bottom = 52.0 -text = "ca-app-pub-3940256099942544/4411468910" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="Key3" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_top = 61.0 -margin_right = 129.0 -margin_bottom = 75.0 -text = "Rewarded" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="Rewarded" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_left = 133.0 -margin_top = 56.0 -margin_right = 436.0 -margin_bottom = 80.0 -text = "ca-app-pub-3940256099942544/1712485313" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="Key4" type="Label" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_top = 89.0 -margin_right = 129.0 -margin_bottom = 103.0 -text = "RewardedInterstitial" -__meta__ = { -"_edit_use_anchors_": false -} - -[node name="RewardedInterstitial" type="LineEdit" parent="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS"] -margin_left = 133.0 -margin_top = 84.0 -margin_right = 436.0 -margin_bottom = 108.0 -text = "ca-app-pub-3940256099942544/6978759866" -align = 1 -expand_to_text_length = true -virtual_keyboard_enabled = false - -[node name="SupportVersion" type="Label" parent="PanelContainer/VBoxContainer"] -margin_top = 386.0 -margin_right = 532.0 -margin_bottom = 451.0 -text = "Supported Plugin Versions: - -iOS: 1.1.x -Android: 1.1.x" - -[node name="InstallationTutorial" type="LinkButton" parent="PanelContainer/VBoxContainer"] -margin_top = 455.0 -margin_right = 532.0 -margin_bottom = 469.0 -text = "INSTALLATION TUTORIAL" - -[connection signal="pressed" from="PanelContainer/VBoxContainer/Enabled" to="." method="_on_Enabled_pressed"] -[connection signal="pressed" from="PanelContainer/VBoxContainer/TestEuropeUserConsent" to="." method="_on_TestEuropeUserConsent_pressed"] -[connection signal="pressed" from="PanelContainer/VBoxContainer/BannerShowInstantly" to="." method="_on_BannerShowInstantly_pressed"] -[connection signal="item_selected" from="PanelContainer/VBoxContainer/BannerSizeHBoxContainer/BannerSize" to="." method="_on_BannerSize_item_selected"] -[connection signal="pressed" from="PanelContainer/VBoxContainer/BannerOnTop" to="." method="_on_BannerOnTop_pressed"] -[connection signal="pressed" from="PanelContainer/VBoxContainer/ChildDirectedTreatment" to="." method="_on_ChildDirectedTreatment_pressed"] -[connection signal="item_selected" from="PanelContainer/VBoxContainer/MaxAdContentRating/Value" to="." method="_on_MaxAdContentRating_item_selected"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/Banner" to="." method="_on_AndroidBanner_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/Interstitial" to="." method="_on_AndroidInterstitial_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/Rewarded" to="." method="_on_AndroidRewarded_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/RewardedInterstitial" to="." method="_on_AndroidRewardedInterstitial_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/Banner" to="." method="_on_iOSBanner_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/Interstitial" to="." method="_on_iOSInterstitial_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/Rewarded" to="." method="_on_iOSRewarded_text_changed"] -[connection signal="text_changed" from="PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/RewardedInterstitial" to="." method="_on_iOSRewardedInterstitial_text_changed"] -[connection signal="pressed" from="PanelContainer/VBoxContainer/InstallationTutorial" to="." method="_on_InstallationTutorial_pressed"] diff --git a/addons/admob/scripts/AdMobConfig.gd b/addons/admob/scripts/AdMobConfig.gd deleted file mode 100644 index bb0462c..0000000 --- a/addons/admob/scripts/AdMobConfig.gd +++ /dev/null @@ -1,128 +0,0 @@ -tool -extends "util/Variables.gd" - -onready var CurrentVersion := $PanelContainer/VBoxContainer/TopPanel/CurrentVersion -onready var BannerSize := $PanelContainer/VBoxContainer/BannerSizeHBoxContainer/BannerSize -onready var MaxAdContentRating := $PanelContainer/VBoxContainer/MaxAdContentRating/Value -onready var Enabled := $PanelContainer/VBoxContainer/Enabled -onready var TestEuropeUserConsent := $PanelContainer/VBoxContainer/TestEuropeUserConsent -onready var BannerShowInstantly := $PanelContainer/VBoxContainer/BannerShowInstantly -onready var BannerOnTop := $PanelContainer/VBoxContainer/BannerOnTop -onready var ChildDirectedTreatment := $PanelContainer/VBoxContainer/ChildDirectedTreatment -onready var Android = { - "Banner" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/Banner, - "Interstitial" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/Interstitial, - "Rewarded" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/Rewarded, - "RewardedInterstitial" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/Android/RewardedInterstitial -} -onready var iOS = { - "Banner" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/Banner, - "Interstitial" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/Interstitial, - "Rewarded" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/Rewarded, - "RewardedInterstitial" : $PanelContainer/VBoxContainer/UnitIds/TabContainer/iOS/RewardedInterstitial -} - -func _ready(): - var plugin_config_file := ConfigFile.new() - plugin_config_file.load("res://addons/admob/plugin.cfg") - CurrentVersion.text = "Version: " + plugin_config_file.get_value("plugin", "version") - - BannerSize.clear() - MaxAdContentRating.clear() - for banner_size in BANNER_SIZE: - BannerSize.add_item(banner_size) - for content_rating in MAX_AD_RATING: - MaxAdContentRating.add_item(content_rating) - - Enabled.pressed = config.is_enabled - TestEuropeUserConsent.pressed = config.is_test_europe_user_consent - BannerShowInstantly.pressed = config.banner.show_instantly - BannerSize.selected = config.banner.size - BannerOnTop.pressed = config.banner.position - ChildDirectedTreatment.pressed = config.is_for_child_directed_treatment - MaxAdContentRating.selected = config.max_ad_content_rating - Android.Banner.text = config.unit_ids.banner.Android - Android.Interstitial.text = config.unit_ids.interstitial.Android - Android.Rewarded.text = config.unit_ids.rewarded.Android - Android.RewardedInterstitial.text = config.unit_ids.rewarded_interstitial.Android - - iOS.Banner.text = config.unit_ids.banner.iOS - iOS.Interstitial.text = config.unit_ids.interstitial.iOS - iOS.Rewarded.text = config.unit_ids.rewarded.iOS - iOS.RewardedInterstitial.text = config.unit_ids.rewarded_interstitial.iOS - -func _on_Enabled_pressed(): - config.is_enabled = Enabled.pressed - save_config() - - -func _on_TestEuropeUserConsent_pressed(): - config.is_test_europe_user_consent = TestEuropeUserConsent.pressed - save_config() - - -func _on_BannerSize_item_selected(index): - config.banner.size = index - save_config() - -func _on_BannerOnTop_pressed(): - config.banner.position = int(BannerOnTop.pressed) - save_config() - - -func _on_ChildDirectedTreatment_pressed(): - config.is_for_child_directed_treatment = ChildDirectedTreatment.pressed - save_config() - - -func _on_MaxAdContentRating_item_selected(index): - config.max_ad_content_rating = index - save_config() - - -func _on_AndroidBanner_text_changed(new_text): - config.unit_ids.banner.Android = new_text - save_config() - - -func _on_AndroidInterstitial_text_changed(new_text): - config.unit_ids.interstitial.Android = new_text - save_config() - - -func _on_AndroidRewarded_text_changed(new_text): - config.unit_ids.rewarded.Android = new_text - save_config() - - -func _on_iOSBanner_text_changed(new_text): - config.unit_ids.banner.iOS = new_text - save_config() - - -func _on_iOSInterstitial_text_changed(new_text): - config.unit_ids.interstitial.iOS = new_text - save_config() - - -func _on_iOSRewarded_text_changed(new_text): - config.unit_ids.rewarded.iOS = new_text - save_config() - -func _on_iOSRewardedInterstitial_text_changed(new_text): - config.unit_ids.rewarded_interstitial.iOS = new_text - save_config() - - -func _on_AndroidRewardedInterstitial_text_changed(new_text): - config.unit_ids.rewarded_interstitial.Android = new_text - save_config() - -func _on_InstallationTutorial_pressed(): - OS.shell_open("https://github.com/Poing-Studios/Godot-AdMob-Android-iOS#installation") - - - -func _on_BannerShowInstantly_pressed(): - config.banner.show_instantly = BannerShowInstantly.pressed - save_config() diff --git a/addons/admob/scripts/DownloadiOSPlugin.gd b/addons/admob/scripts/DownloadiOSPlugin.gd deleted file mode 100755 index 44bb3f6..0000000 --- a/addons/admob/scripts/DownloadiOSPlugin.gd +++ /dev/null @@ -1,15 +0,0 @@ -tool -extends Button -# Instance the gdunzip script - -func _on_DownloadiOSPlugin_pressed(): - var godot_version : String = String(Engine.get_version_info().major) + "." + String(Engine.get_version_info().minor) + "." + String(Engine.get_version_info().patch) - print(godot_version) - $HTTPRequest.download_file = "ios-template-v3.3.2.zip" - $HTTPRequest.request("https://github.com/Poing-Studios/Godot-AdMob-Android-iOS/releases/download/iOS_v3.3%2B/ios-template-v3.3.2.zip") - - -func _on_HTTPRequest_request_completed(result, response_code, headers, body): - print("Request completed ", result, ", ", response_code) - # Uncompress a file, getting a PoolByteArray in return - # (or false if it failed uncompressing) diff --git a/addons/admob/scripts/util/Variables.gd b/addons/admob/scripts/util/Variables.gd deleted file mode 100644 index b9fd0a0..0000000 --- a/addons/admob/scripts/util/Variables.gd +++ /dev/null @@ -1,32 +0,0 @@ -extends "../../config/Settings.gd" - -enum INITIALIZATION_STATUS {NOT_READY, READY} - -#private attributes -var _control_node_to_be_replaced : Control -enum _position_options {BOTTOM, TOP} - -const BANNER_SIZE : Array = ["BANNER", "MEDIUM_RECTANGLE", "FULL_BANNER", "LEADERBOARD", "ADAPTIVE", "SMART_BANNER"] -const MAX_AD_RATING : Array = ["G", "PG", "T", "MA"] - -const BEGINNING_SETTINGS_SCRIPT = "extends Node\n\nvar config : Dictionary = " -const FILE_PATH = "res://addons/admob/config/Settings.gd" - - -func _ready() -> void: - load_config() - -func save_config() -> void: - if !(OS.get_name() == "Android" or OS.get_name() == "iOS"): - var file = File.new() - file.open(FILE_PATH, File.WRITE) - file.store_string(BEGINNING_SETTINGS_SCRIPT + JSON.print(config, "\t")) - file.close() - -func load_config() -> void: - var config_file := File.new() - if config_file.file_exists(FILE_PATH): - config_file.open(FILE_PATH, File.READ) - var new_config : Dictionary = parse_json(config_file.get_as_text().replace(BEGINNING_SETTINGS_SCRIPT, "")) - config_file.close() - config = new_config diff --git a/addons/admob/src/core/AdMob.gd b/addons/admob/src/core/AdMob.gd new file mode 100644 index 0000000..9f56c96 --- /dev/null +++ b/addons/admob/src/core/AdMob.gd @@ -0,0 +1,27 @@ +tool +extends EditorPlugin + +var AdMobEditor : Control + +func _enter_tree(): + add_autoload_singleton("MobileAds", "res://addons/admob/src/singletons/MobileAds.gd") + AdMobEditor = load("res://addons/admob/src/core/AdMobEditor.tscn").instance() + get_editor_interface().get_editor_viewport().add_child(AdMobEditor) + AdMobEditor.hide() + +func _exit_tree(): + remove_autoload_singleton("MobileAds") + get_editor_interface().get_editor_viewport().remove_child(AdMobEditor) + AdMobEditor.queue_free() + +func has_main_screen(): + return true + +func make_visible(visible): + AdMobEditor.visible = visible + +func get_plugin_name(): + return "AdMob" + +func get_plugin_icon(): + return load("res://addons/admob/assets/icon-15.png") diff --git a/addons/admob/src/core/AdMobEditor.gd b/addons/admob/src/core/AdMobEditor.gd new file mode 100644 index 0000000..9b5dc15 --- /dev/null +++ b/addons/admob/src/core/AdMobEditor.gd @@ -0,0 +1,27 @@ +tool +extends Control +var AdMobSettings = preload("res://addons/admob/src/utils/AdMobSettings.gd").new() +var support_version_text = "[rainbow sat=10]iOS[/rainbow][color=black]:%s[/color] [rainbow sat=10]Android[/rainbow][color=black]:%s[/color]" + +onready var SupportVersion := $BottomPanel/SupportVersion +onready var CurrentVersion := $BottomPanel/CurrentVersion + +func _ready(): + SupportVersion.bbcode_text = support_version_text % [AdMobSettings.version_support.ios, AdMobSettings.version_support.android] + + var plugin_config_file := ConfigFile.new() + plugin_config_file.load("res://addons/admob/plugin.cfg") + CurrentVersion.text = "Version: " + plugin_config_file.get_value("plugin", "version") + + +func _on_AndroidButton_pressed(): + OS.shell_open("https://github.com/Poing-Studios/godot-admob-android#installation") + +func _on_iOSButton_pressed(): + OS.shell_open("https://github.com/Poing-Studios/godot-admob-ios#installation") + +func _on_AdMobButton_pressed(): + OS.shell_open("https://github.com/Poing-Studios/godot-admob-editor") + +func _on_PoingButton_pressed(): + OS.shell_open("https://github.com/Poing-Studios") diff --git a/addons/admob/src/core/AdMobEditor.tscn b/addons/admob/src/core/AdMobEditor.tscn new file mode 100644 index 0000000..5cabe90 --- /dev/null +++ b/addons/admob/src/core/AdMobEditor.tscn @@ -0,0 +1,242 @@ +[gd_scene load_steps=19 format=2] + +[ext_resource path="res://addons/admob/assets/android.png" type="Texture" id=1] +[ext_resource path="res://addons/admob/assets/poing.jpeg" type="Texture" id=2] +[ext_resource path="res://addons/admob/assets/fonts/arial.ttf" type="DynamicFontData" id=3] +[ext_resource path="res://addons/admob/src/core/AdMobEditor.gd" type="Script" id=4] +[ext_resource path="res://addons/admob/assets/ios.png" type="Texture" id=5] +[ext_resource path="res://addons/admob/assets/icon-76.png" type="Texture" id=6] +[ext_resource path="res://addons/admob/src/core/components/ad_format/BannerAdFormat.tscn" type="PackedScene" id=7] +[ext_resource path="res://addons/admob/src/core/components/General.tscn" type="PackedScene" id=8] +[ext_resource path="res://addons/admob/src/core/components/ad_format/InterstitialAdFormat.tscn" type="PackedScene" id=9] +[ext_resource path="res://addons/admob/src/core/components/ad_format/RewardedAdFormat.tscn" type="PackedScene" id=10] +[ext_resource path="res://addons/admob/src/core/components/ad_format/RewardedInterstitialAdFormat.tscn" type="PackedScene" id=11] +[ext_resource path="res://addons/admob/src/core/components/Downloads.tscn" type="PackedScene" id=12] + +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0.839216, 0.0352941, 0.0352941, 1 ) + +[sub_resource type="DynamicFont" id=2] +size = 30 +use_filter = true +font_data = ExtResource( 3 ) + +[sub_resource type="StyleBoxFlat" id=3] +bg_color = Color( 1, 0.772549, 0, 1 ) + +[sub_resource type="DynamicFont" id=4] +size = 20 +use_filter = true +font_data = ExtResource( 3 ) + +[sub_resource type="StyleBoxFlat" id=5] +bg_color = Color( 0.172549, 0.568627, 0.992157, 1 ) + +[sub_resource type="DynamicFont" id=6] +size = 20 +outline_size = 1 +outline_color = Color( 0, 0, 0, 1 ) +use_filter = true +font_data = ExtResource( 3 ) + +[node name="AdMobEditor" type="Control"] +pause_mode = 2 +anchor_left = -0.002 +anchor_right = 1.502 +anchor_bottom = 0.731444 +margin_left = 1.0 +margin_right = -6.10352e-05 +margin_bottom = -8.30005 +rect_clip_content = true +size_flags_horizontal = 3 +size_flags_vertical = 3 +script = ExtResource( 4 ) +__meta__ = { +"_edit_group_": true, +"_edit_lock_": true, +"_edit_use_anchors_": true +} + +[node name="TopPanel" type="Panel" parent="."] +anchor_right = 1.0 +margin_bottom = 40.0 +rect_min_size = Vector2( 0, 35 ) +custom_styles/panel = SubResource( 1 ) +__meta__ = { +"_edit_lock_": true, +"_edit_use_anchors_": false +} + +[node name="Description" type="Label" parent="TopPanel"] +anchor_right = 1.0 +margin_right = -401.4 +margin_bottom = 40.0 +custom_fonts/font = SubResource( 2 ) +text = "AdMob Editor" +valign = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Icons" type="Control" parent="TopPanel"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -395.4 +margin_right = 0.600037 +margin_bottom = 40.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AndroidButton" type="TextureButton" parent="TopPanel/Icons"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -158.6 +margin_right = -118.6 +margin_bottom = 40.0 +mouse_default_cursor_shape = 2 +texture_normal = ExtResource( 1 ) +expand = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="iOSButton" type="TextureButton" parent="TopPanel/Icons"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -118.145 +margin_right = -78.1449 +margin_bottom = 40.0 +mouse_default_cursor_shape = 2 +texture_normal = ExtResource( 5 ) +expand = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AdMobButton" type="TextureButton" parent="TopPanel/Icons"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -79.9999 +margin_right = -39.9999 +margin_bottom = 40.0 +mouse_default_cursor_shape = 2 +texture_normal = ExtResource( 6 ) +expand = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="PoingButton" type="TextureButton" parent="TopPanel/Icons"] +anchor_left = 1.0 +anchor_right = 1.0 +margin_left = -40.0 +margin_bottom = 40.0 +mouse_default_cursor_shape = 2 +texture_normal = ExtResource( 2 ) +expand = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MiddleScrollContainer" type="ScrollContainer" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 40.0 +margin_right = 6.10352e-05 +margin_bottom = -34.9996 +__meta__ = { +"_edit_lock_": true +} + +[node name="TabContainer" type="TabContainer" parent="MiddleScrollContainer"] +margin_right = 751.0 +margin_bottom = 575.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 +tab_align = 0 + +[node name="General" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 8 )] + +[node name="Banner" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 7 )] +visible = false +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="Interstitial" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 9 )] +visible = false +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="Rewarded" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 10 )] +visible = false +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="RewardedInterstitial" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 11 )] +visible = false +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="Downloads" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 12 )] +visible = false +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="BottomPanel" type="Panel" parent="."] +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = -35.0 +rect_min_size = Vector2( 0, 35 ) +__meta__ = { +"_edit_lock_": true, +"_edit_use_anchors_": false +} + +[node name="SupportVersion" type="RichTextLabel" parent="BottomPanel"] +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = -35.0 +margin_right = -158.0 +custom_styles/normal = SubResource( 3 ) +custom_fonts/normal_font = SubResource( 4 ) +bbcode_enabled = true +bbcode_text = "[rainbow sat=10]iOS[/rainbow][color=black]:v2.0.0[/color] [rainbow sat=10]Android[/rainbow][color=black]:v2.0.0[/color]" +text = "iOS:v2.0.0 Android:v2.0.0" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="CurrentVersion" type="Label" parent="BottomPanel"] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -158.0 +margin_top = -35.0 +rect_min_size = Vector2( 0, 35 ) +custom_styles/normal = SubResource( 5 ) +custom_fonts/font = SubResource( 6 ) +text = "Version: 1.0.0" +align = 2 +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="pressed" from="TopPanel/Icons/AndroidButton" to="." method="_on_AndroidButton_pressed"] +[connection signal="pressed" from="TopPanel/Icons/iOSButton" to="." method="_on_iOSButton_pressed"] +[connection signal="pressed" from="TopPanel/Icons/AdMobButton" to="." method="_on_AdMobButton_pressed"] +[connection signal="pressed" from="TopPanel/Icons/PoingButton" to="." method="_on_PoingButton_pressed"] diff --git a/addons/admob/src/core/components/Downloads.gd b/addons/admob/src/core/components/Downloads.gd new file mode 100644 index 0000000..d63684d --- /dev/null +++ b/addons/admob/src/core/components/Downloads.gd @@ -0,0 +1,114 @@ +tool +extends VBoxContainer + +onready var AdMobEditor : Control = find_parent("AdMobEditor") + +onready var godot_version : String = String(Engine.get_version_info().major) + "." + String(Engine.get_version_info().minor) + "." + String(Engine.get_version_info().patch) +var actual_downloading_file : String = "" + +var android_dictionary : Dictionary = { + "version" : ["CURRENT", "3.3.4", "3.3.3", "3.3.2", "3.3.1", "3.3", "3.2.3", "3.2.2"], + "download_directory" : "res://addons/admob/downloads/android" + } setget set_android_dictionary + +var ios_dictionary : Dictionary = { + "version" : ["CURRENT", "3.3.4", "3.3.3", "3.3.2", "3.3.1", "3.3"], + "download_directory" : "res://addons/admob/downloads/ios" + } setget set_ios_dictionary + +var current_dir_download_label = "Current Download Directory: %s" +var download_complete_message = "Download of %s completed!" + +func set_android_dictionary(value): + android_dictionary = value + $TabContainer/Android/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % android_dictionary.download_directory + +func set_ios_dictionary(value): + ios_dictionary = value + $TabContainer/iOS/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % ios_dictionary.download_directory + +func _ready(): + set_process(false) + $TabContainer/Android/VersionHBoxContainer/AndroidVersion.clear() + $TabContainer/iOS/VersionHBoxContainer/iOSVersion.clear() + for i in android_dictionary.version: + $TabContainer/Android/VersionHBoxContainer/AndroidVersion.add_item(i) + for i in ios_dictionary.version: + $TabContainer/iOS/VersionHBoxContainer/iOSVersion.add_item(i) + + $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 _process(delta): + var bodySize = $HTTPRequest.get_body_size() + var downloadedBytes = $HTTPRequest.get_downloaded_bytes() + var percent = int(downloadedBytes*100/bodySize) + $ProgressBar.value = percent + + +func _on_HTTPRequest_request_completed(result, response_code, headers, body): + if response_code != 200: + $AdviceAcceptDialog.dialog_text = "!!!DOWNLOAD FAILED!!!" + $ProgressBar.value = 0 + else: + $AdviceAcceptDialog.dialog_text = download_complete_message % actual_downloading_file + + set_process(false) + $AdviceAcceptDialog.popup_centered() + + +func _on_DownloadGoogleMobileAdsSdkiOS_pressed(): + var file_name = "googlemobileadssdkios.zip" + var plugin_version = AdMobEditor.AdMobSettings.version_support.ios + $HTTPRequest.download_file = ios_dictionary.download_directory + "/" + file_name + $HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-ios/releases/download/" + plugin_version + "/" + file_name) + actual_downloading_file = file_name + + 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-v" + ios_version + ".zip" + var plugin_version = AdMobEditor.AdMobSettings.version_support.ios + $HTTPRequest.download_file = ios_dictionary.download_directory + "/" + file_name + $HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-ios/releases/download/" + plugin_version + "/" + file_name) + actual_downloading_file = file_name + + 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-v" + android_version + ".zip" + var plugin_version = AdMobEditor.AdMobSettings.version_support.android + $HTTPRequest.download_file = android_dictionary.download_directory + "/" + file_name + $HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-android/releases/download/" + plugin_version + "/" + file_name) + actual_downloading_file = file_name + + set_process(true) + + +func _on_AndroidChangeDirectoryFileDialog_dir_selected(dir): + self.android_dictionary.download_directory = dir + +func _on_AndroidChangeDirectoryButton_pressed(): + $TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidChangeDirectoryFileDialog.popup_centered() + + +func _on_iOSChangeDirectoryFileDialog_dir_selected(dir): + self.ios_dictionary.download_directory = dir + +func _on_iOSChangeDirectoryButton_pressed(): + $TabContainer/iOS/ChangeDirectoryHBoxContainer/iOSChangeDirectoryFileDialog.popup_centered() + diff --git a/addons/admob/src/core/components/Downloads.tscn b/addons/admob/src/core/components/Downloads.tscn new file mode 100644 index 0000000..6c28a40 --- /dev/null +++ b/addons/admob/src/core/components/Downloads.tscn @@ -0,0 +1,216 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://addons/admob/src/core/components/Downloads.gd" type="Script" id=1] + +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0, 1, 0.109804, 1 ) + +[sub_resource type="StyleBoxFlat" id=2] + +[node name="Downloads" type="VBoxContainer"] +anchor_right = 1.0 +margin_bottom = 31.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Advice" type="Label" parent="."] +margin_right = 593.0 +margin_bottom = 82.0 +text = "This screen is just to download the AdMob plugin referring to the current version of your Godot, IT WILL NOT INSTALL. + +To install you need to follow the Android or iOS installation guide clicking on the icons on top screen." +autowrap = true + +[node name="ProgressBar" type="ProgressBar" parent="."] +margin_top = 86.0 +margin_right = 593.0 +margin_bottom = 100.0 +custom_styles/fg = SubResource( 1 ) +custom_styles/bg = SubResource( 2 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) + +[node name="HTTPRequest" type="HTTPRequest" parent="."] + +[node name="AdviceAcceptDialog" type="AcceptDialog" parent="."] +margin_top = 70.0 +margin_right = 888.0 +margin_bottom = 128.0 +popup_exclusive = true +window_title = "Alerta!" +dialog_text = "Download of %s completed!" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TabContainer" type="TabContainer" parent="."] +margin_top = 104.0 +margin_right = 593.0 +margin_bottom = 232.0 + +[node name="Android" type="VBoxContainer" parent="TabContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="ChangeDirectoryHBoxContainer" type="HBoxContainer" parent="TabContainer/Android"] +margin_right = 585.0 +margin_bottom = 20.0 + +[node name="DownloadDirectoryLabel" type="Label" parent="TabContainer/Android/ChangeDirectoryHBoxContainer"] +margin_top = 3.0 +margin_right = 440.0 +margin_bottom = 17.0 +text = "Current Download Directory: res://addons/admob/downloads/android" + +[node name="AndroidChangeDirectoryButton" type="Button" parent="TabContainer/Android/ChangeDirectoryHBoxContainer"] +margin_left = 444.0 +margin_right = 585.0 +margin_bottom = 20.0 +text = "CHANGE DIRECTORY" + +[node name="AndroidChangeDirectoryFileDialog" type="FileDialog" parent="TabContainer/Android/ChangeDirectoryHBoxContainer"] +margin_left = 380.0 +margin_right = 780.0 +margin_bottom = 250.0 +rect_min_size = Vector2( 400, 250 ) +window_title = "Open a Directory" +mode = 2 +current_dir = "res://addons/admob/downloads/android" +current_path = "res://addons/admob/downloads/android/" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VersionHBoxContainer" type="HBoxContainer" parent="TabContainer/Android"] +margin_top = 24.0 +margin_right = 585.0 +margin_bottom = 44.0 + +[node name="Label" type="Label" parent="TabContainer/Android/VersionHBoxContainer"] +margin_top = 3.0 +margin_right = 52.0 +margin_bottom = 17.0 +text = "Version:" + +[node name="AndroidVersion" type="OptionButton" parent="TabContainer/Android/VersionHBoxContainer"] +margin_left = 56.0 +margin_right = 143.0 +margin_bottom = 20.0 +text = "CURRENT" +items = [ "CURRENT", null, false, 0, null, "3.3.3", null, false, 1, null, "3.3.2", null, false, 2, null, "3.3.1", null, false, 3, null, "3.3", null, false, 4, null, "3.2.3", null, false, 5, null, "3.2.2", null, false, 6, null ] +selected = 0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TargetHBoxContainer" type="HBoxContainer" parent="TabContainer/Android"] +margin_top = 48.0 +margin_right = 585.0 +margin_bottom = 68.0 + +[node name="Label" type="Label" parent="TabContainer/Android/TargetHBoxContainer"] +margin_top = 3.0 +margin_right = 43.0 +margin_bottom = 17.0 +text = "Target:" + +[node name="MenuButton" type="OptionButton" parent="TabContainer/Android/TargetHBoxContainer"] +margin_left = 47.0 +margin_right = 134.0 +margin_bottom = 20.0 +text = "CURRENT" +items = [ "CURRENT", null, false, 0, null, "STANDARD", null, false, 1, null, "MONO", null, false, 2, null ] +selected = 0 + +[node name="DownloadAndroidTemplate" type="Button" parent="TabContainer/Android"] +margin_top = 72.0 +margin_right = 585.0 +margin_bottom = 92.0 +text = "Download Android Template" + +[node name="iOS" type="VBoxContainer" parent="TabContainer"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="ChangeDirectoryHBoxContainer" type="HBoxContainer" parent="TabContainer/iOS"] +margin_right = 880.0 +margin_bottom = 250.0 + +[node name="DownloadDirectoryLabel" type="Label" parent="TabContainer/iOS/ChangeDirectoryHBoxContainer"] +margin_top = 118.0 +margin_right = 231.0 +margin_bottom = 132.0 +text = "Current Download Directory: res://addons/admob/downloads/ios" + +[node name="iOSChangeDirectoryButton" type="Button" parent="TabContainer/iOS/ChangeDirectoryHBoxContainer"] +margin_left = 235.0 +margin_right = 376.0 +margin_bottom = 250.0 +text = "CHANGE DIRECTORY" + +[node name="iOSChangeDirectoryFileDialog" type="FileDialog" parent="TabContainer/iOS/ChangeDirectoryHBoxContainer"] +visible = true +margin_left = 380.0 +margin_right = 780.0 +margin_bottom = 250.0 +rect_min_size = Vector2( 400, 250 ) +window_title = "Open a Directory" +mode = 2 +current_dir = "res://addons/admob/downloads/ios" +current_path = "res://addons/admob/downloads/ios/" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="VersionHBoxContainer" type="HBoxContainer" parent="TabContainer/iOS"] +margin_top = 254.0 +margin_right = 880.0 +margin_bottom = 274.0 + +[node name="Label" type="Label" parent="TabContainer/iOS/VersionHBoxContainer"] +margin_top = 3.0 +margin_right = 52.0 +margin_bottom = 17.0 +text = "Version:" + +[node name="iOSVersion" type="OptionButton" parent="TabContainer/iOS/VersionHBoxContainer"] +margin_left = 56.0 +margin_right = 85.0 +margin_bottom = 20.0 +text = "CURRENT" +items = [ "CURRENT", null, false, 0, null, "3.3.3", null, false, 1, null, "3.3.2", null, false, 2, null, "3.3.1", null, false, 3, null, "3.3", null, false, 4, null ] +selected = 0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="DownloadiOSTemplate" type="Button" parent="TabContainer/iOS"] +margin_top = 278.0 +margin_right = 880.0 +margin_bottom = 298.0 +text = "Download iOS Template" + +[node name="DownloadGoogleMobileAdsSdkiOS" type="Button" parent="TabContainer/iOS"] +margin_top = 302.0 +margin_right = 880.0 +margin_bottom = 322.0 +text = "Download GoogleMobileAdsSdkiOS" + +[connection signal="request_completed" from="HTTPRequest" to="." method="_on_HTTPRequest_request_completed"] +[connection signal="pressed" from="TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidChangeDirectoryButton" to="." method="_on_AndroidChangeDirectoryButton_pressed"] +[connection signal="dir_selected" from="TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidChangeDirectoryFileDialog" to="." method="_on_AndroidChangeDirectoryFileDialog_dir_selected"] +[connection signal="pressed" from="TabContainer/Android/DownloadAndroidTemplate" to="." method="_on_DownloadAndroidTemplate_pressed"] +[connection signal="pressed" from="TabContainer/iOS/ChangeDirectoryHBoxContainer/iOSChangeDirectoryButton" to="." method="_on_iOSChangeDirectoryButton_pressed"] +[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"] diff --git a/addons/admob/src/core/components/General.gd b/addons/admob/src/core/components/General.gd new file mode 100644 index 0000000..c4f5fcf --- /dev/null +++ b/addons/admob/src/core/components/General.gd @@ -0,0 +1,24 @@ +tool +extends VBoxContainer + +onready var AdMobEditor : Control = find_parent("AdMobEditor") +onready var config_dictionary : Dictionary = AdMobEditor.AdMobSettings.config.general + + +func _ready(): + $Enabled.pressed = config_dictionary.is_enabled + $TestEuropeUserConsent.pressed = config_dictionary.is_test_europe_user_consent + $ChildDirectedTreatment.pressed = config_dictionary.is_for_child_directed_treatment + $MaxAdContentRating/Value.selected = AdMobEditor.AdMobSettings.MAX_AD_RATING.find(config_dictionary.max_ad_content_rating) + +func _on_Enabled_pressed(): + config_dictionary.is_enabled = $Enabled.pressed + +func _on_TestEuropeUserConsent_pressed(): + config_dictionary.is_test_europe_user_consent = $TestEuropeUserConsent.pressed + +func _on_ChildDirectedTreatment_pressed(): + config_dictionary.is_for_child_directed_treatment = $ChildDirectedTreatment.pressed + +func _on_MaxAdContentRating_item_selected(index): + config_dictionary.max_ad_content_rating = AdMobEditor.AdMobSettings.MAX_AD_RATING[index] diff --git a/addons/admob/src/core/components/General.tscn b/addons/admob/src/core/components/General.tscn new file mode 100644 index 0000000..a427853 --- /dev/null +++ b/addons/admob/src/core/components/General.tscn @@ -0,0 +1,75 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/admob/src/core/components/General.gd" type="Script" id=1] + +[node name="General" type="VBoxContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Enabled" type="CheckBox" parent="."] +margin_right = 592.0 +margin_bottom = 24.0 +pressed = true +text = "Enabled" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="TestEuropeUserConsent" type="CheckBox" parent="."] +margin_top = 28.0 +margin_right = 592.0 +margin_bottom = 52.0 +text = "Test Europe User Consent" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ChildDirectedTreatment" type="CheckBox" parent="."] +margin_top = 56.0 +margin_right = 592.0 +margin_bottom = 80.0 +text = "Child Directed Treatment" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MaxAdContentRating" type="HBoxContainer" parent="."] +margin_top = 84.0 +margin_right = 592.0 +margin_bottom = 104.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Key" type="Label" parent="MaxAdContentRating"] +margin_top = 3.0 +margin_right = 132.0 +margin_bottom = 17.0 +text = "MaxAdContentRating" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Value" type="OptionButton" parent="MaxAdContentRating"] +margin_left = 136.0 +margin_right = 183.0 +margin_bottom = 20.0 +text = "PG" +items = [ "G", null, false, 0, null, "PG", null, false, 1, null, "T", null, false, 2, null, "MA", null, false, 3, null ] +selected = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="pressed" from="Enabled" to="." method="_on_Enabled_pressed"] +[connection signal="pressed" from="TestEuropeUserConsent" to="." method="_on_TestEuropeUserConsent_pressed"] +[connection signal="pressed" from="ChildDirectedTreatment" to="." method="_on_ChildDirectedTreatment_pressed"] +[connection signal="item_selected" from="MaxAdContentRating/Value" to="." method="_on_MaxAdContentRating_item_selected"] diff --git a/addons/admob/src/core/components/ad_format/AdFormat.tscn b/addons/admob/src/core/components/ad_format/AdFormat.tscn new file mode 100644 index 0000000..29c0e80 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/AdFormat.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/unit_ids/UnitIds.tscn" type="PackedScene" id=1] + +[node name="AdFormat" type="VBoxContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="UnitIds" parent="." instance=ExtResource( 1 )] +margin_bottom = 60.0 diff --git a/addons/admob/src/core/components/ad_format/BannerAdFormat.gd b/addons/admob/src/core/components/ad_format/BannerAdFormat.gd new file mode 100644 index 0000000..587b095 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/BannerAdFormat.gd @@ -0,0 +1,19 @@ +tool +extends VBoxContainer +onready var AdMobEditor : Control = find_parent("AdMobEditor") +onready var config_dictionary : Dictionary = AdMobEditor.AdMobSettings.config.banner + +func _ready(): + $BannerSizeHBoxContainer/BannerSize.selected = AdMobEditor.AdMobSettings.BANNER_SIZE.find(config_dictionary.size) + $BannerShowInstantly.pressed = config_dictionary.show_instantly + $BannerOnTop.pressed = config_dictionary.position + + +func _on_BannerSize_item_selected(index): + config_dictionary.size = AdMobEditor.AdMobSettings.BANNER_SIZE[index] + +func _on_BannerShowInstantly_pressed(): + config_dictionary.show_instantly = $BannerShowInstantly.pressed# + +func _on_BannerOnTop_pressed(): + config_dictionary.position = int($BannerOnTop.pressed) diff --git a/addons/admob/src/core/components/ad_format/BannerAdFormat.tscn b/addons/admob/src/core/components/ad_format/BannerAdFormat.tscn new file mode 100644 index 0000000..b06a913 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/BannerAdFormat.tscn @@ -0,0 +1,58 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/AdFormat.tscn" type="PackedScene" id=1] +[ext_resource path="res://addons/admob/src/core/components/ad_format/BannerAdFormat.gd" type="Script" id=2] + +[node name="BannerAdFormat" instance=ExtResource( 1 )] +script = ExtResource( 2 ) + +[node name="BannerSizeHBoxContainer" type="HBoxContainer" parent="." index="0"] +margin_right = 600.0 +margin_bottom = 20.0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Label" type="Label" parent="BannerSizeHBoxContainer" index="0"] +margin_top = 3.0 +margin_right = 75.0 +margin_bottom = 17.0 +text = "Banner Size" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="BannerSize" type="OptionButton" parent="BannerSizeHBoxContainer" index="1"] +margin_left = 79.0 +margin_right = 243.0 +margin_bottom = 20.0 +text = "MEDIUM_RECTANGLE" +items = [ "BANNER", null, false, 0, null, "MEDIUM_RECTANGLE", null, false, 1, null, "FULL_BANNER", null, false, 2, null, "LEADERBOARD", null, false, 3, null, "ADAPTIVE", null, false, 4, null, "SMART_BANNER", null, false, 5, null ] +selected = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="BannerShowInstantly" type="CheckBox" parent="." index="1"] +margin_top = 24.0 +margin_right = 600.0 +margin_bottom = 48.0 +pressed = true +text = "Show Banner Instantly" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="BannerOnTop" type="CheckBox" parent="." index="2"] +margin_top = 52.0 +margin_right = 600.0 +margin_bottom = 76.0 +text = "Banner On Top" + +[node name="UnitIds" parent="." index="3"] +margin_top = 80.0 +margin_bottom = 140.0 + +[connection signal="item_selected" from="BannerSizeHBoxContainer/BannerSize" to="." method="_on_BannerSize_item_selected"] +[connection signal="pressed" from="BannerShowInstantly" to="." method="_on_BannerShowInstantly_pressed"] +[connection signal="pressed" from="BannerOnTop" to="." method="_on_BannerOnTop_pressed"] diff --git a/addons/admob/src/core/components/ad_format/InterstitialAdFormat.tscn b/addons/admob/src/core/components/ad_format/InterstitialAdFormat.tscn new file mode 100644 index 0000000..020f612 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/InterstitialAdFormat.tscn @@ -0,0 +1,5 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/AdFormat.tscn" type="PackedScene" id=1] + +[node name="InterstitialAdFormat" instance=ExtResource( 1 )] diff --git a/addons/admob/src/core/components/ad_format/RewardedAdFormat.tscn b/addons/admob/src/core/components/ad_format/RewardedAdFormat.tscn new file mode 100644 index 0000000..d20fc69 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/RewardedAdFormat.tscn @@ -0,0 +1,5 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/AdFormat.tscn" type="PackedScene" id=1] + +[node name="RewardedAdFormat" instance=ExtResource( 1 )] diff --git a/addons/admob/src/core/components/ad_format/RewardedInterstitialAdFormat.tscn b/addons/admob/src/core/components/ad_format/RewardedInterstitialAdFormat.tscn new file mode 100644 index 0000000..ecfbaf5 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/RewardedInterstitialAdFormat.tscn @@ -0,0 +1,5 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/AdFormat.tscn" type="PackedScene" id=1] + +[node name="RewardedInterstitialAdFormat" instance=ExtResource( 1 )] diff --git a/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.gd b/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.gd new file mode 100644 index 0000000..b948fe9 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.gd @@ -0,0 +1,47 @@ +tool +extends HBoxContainer + +var AdUnit = preload("res://addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.tscn") + +onready var AdMobEditor : Control = find_parent("AdMobEditor") +onready var ad_format_name = AdMobEditor.AdMobSettings.pascal2snake(get_parent().name) + +onready var config_dictionary : Dictionary = AdMobEditor.AdMobSettings.config[ad_format_name].unit_ids + +func _ready(): + for operational_system in $OperationalSystemTabContainer.get_children(): + for unit_name in (config_dictionary[operational_system.name] as Dictionary): + var unit_id = config_dictionary[operational_system.name][unit_name] + instance_ad_unit(operational_system.name, false, unit_name, unit_id) + get_node("OperationalSystemTabContainer/"+operational_system.name+"/AddAdUnitButton").connect("pressed", self, "_on_AddAdUnitButton_pressed", [operational_system.name]) + + +func _on_AdUnitChanged(name_value: String, id_value: String, old_name_value :String, system): + remove_ad_unit(system, name_value) + remove_ad_unit(system, old_name_value) + add_ad_unit(system, name_value, id_value) + +func _on_AdUnitRemoved(name_value : String, system): + remove_ad_unit(system, name_value) + +func _on_AddAdUnitButton_pressed(system): + print("_on_AddAdUnitButton_pressed", system) + instance_ad_unit(system, true) + + +func add_ad_unit(operational_system : String, name_value: String, id_value : String): + print(config_dictionary) + config_dictionary[operational_system][name_value] = id_value + +func remove_ad_unit(operational_system : String, name_value: String): + config_dictionary[operational_system].erase(name_value) + +func instance_ad_unit(system : String, is_editing : bool, unit_name : String = "", unit_id : String = ""): + var tab_container = get_node("OperationalSystemTabContainer/"+system+"/AdUnitVBoxContainer") + var ad_unit = AdUnit.instance() + tab_container.add_child(ad_unit) + ad_unit.connect("AdUnitChanged", self, "_on_AdUnitChanged", [system]) + ad_unit.connect("AdUnitRemoved", self, "_on_AdUnitRemoved", [system]) + ad_unit.Name.text = unit_name + ad_unit.Id.text = unit_id + ad_unit.is_editing = is_editing diff --git a/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.tscn b/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.tscn new file mode 100644 index 0000000..7917efb --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.tscn @@ -0,0 +1,50 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/unit_ids/UnitIds.gd" type="Script" id=1] +[ext_resource path="res://addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/AdUnitOperationalSystem.tscn" type="PackedScene" id=2] + +[node name="UnitIds" type="HBoxContainer"] +margin_right = 600.0 +margin_bottom = 84.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Description" type="Label" parent="."] +margin_top = 54.0 +margin_right = 58.0 +margin_bottom = 68.0 +text = "UNIT IDS" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="OperationalSystemTabContainer" type="TabContainer" parent="."] +margin_left = 62.0 +margin_right = 262.0 +margin_bottom = 122.0 +rect_min_size = Vector2( 200, 0 ) +rect_clip_content = true +mouse_filter = 1 +tab_align = 0 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Android" parent="OperationalSystemTabContainer" instance=ExtResource( 2 )] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 + +[node name="iOS" parent="OperationalSystemTabContainer" instance=ExtResource( 2 )] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = 4.0 +margin_top = 32.0 +margin_right = -4.0 +margin_bottom = -4.0 diff --git a/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/AdUnitOperationalSystem.tscn b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/AdUnitOperationalSystem.tscn new file mode 100644 index 0000000..2834754 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/AdUnitOperationalSystem.tscn @@ -0,0 +1,23 @@ +[gd_scene format=2] + +[node name="AdUnitOperationalSystem" type="VBoxContainer"] +margin_right = 382.0 +margin_bottom = 159.0 +rect_clip_content = true +size_flags_horizontal = 3 +size_flags_vertical = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AdUnitVBoxContainer" type="VBoxContainer" parent="."] +margin_right = 382.0 +margin_bottom = 135.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 + +[node name="AddAdUnitButton" type="Button" parent="."] +margin_top = 139.0 +margin_right = 382.0 +margin_bottom = 159.0 +text = "ADD" diff --git a/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.gd b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.gd new file mode 100644 index 0000000..bfcd8fb --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.gd @@ -0,0 +1,72 @@ +tool +extends GridContainer + +signal AdUnitChanged(name_value, id_value, old_name_value) +signal AdUnitRemoved(name_value) + +onready var Name := $Name +onready var Id := $Id +onready var ChildrenParent := get_parent().get_children() +onready var AddAdUnitButtonParent := get_parent().get_parent().get_node("AddAdUnitButton") + +var old_name_value := "" +var is_editing := true setget set_is_editing + +func change_state(editing : bool) -> void: + if editing: + editing_state() + else: + not_editing_state() + +func editing_state() -> void: + $GridContainer/ConfirmButton.visible = true + $GridContainer/EditButton.visible = false + Name.editable = true + Id.editable = true + + for ad_unit in ChildrenParent: + if ad_unit.get_index() != get_index(): + ad_unit.get_node("GridContainer/RemoveButton").disabled = true + ad_unit.get_node("GridContainer/EditButton").disabled = true + AddAdUnitButtonParent.disabled = true + +func not_editing_state(): + $GridContainer/ConfirmButton.visible = false + $GridContainer/EditButton.visible = true + Name.editable = false + Id.editable = false + for ad_unit in ChildrenParent: + ad_unit.get_node("GridContainer/EditButton").disabled = false + ad_unit.get_node("GridContainer/RemoveButton").disabled = false + AddAdUnitButtonParent.disabled = false + + +func set_is_editing(value : bool): + change_state(value) + +func _on_RemoveButton_pressed(): + if (get_parent().get_child_count() > 1): + self.is_editing = false + emit_signal("AdUnitRemoved", Name.text) + queue_free() + +func _on_ConfirmButton_pressed(): + if Name.text != "" && Id.text != "": + for ad_unit in ChildrenParent: + if ad_unit.get_index() != get_index(): + if ad_unit.Name.text == Name.text: + $Alerts/UniqueNameAcceptDialog.popup_centered() + return + else: + $Alerts/NameIdEmptyAcceptDialog.popup_centered() + return + emit_signal("AdUnitChanged", Name.text, Id.text, old_name_value) + self.is_editing = false + + +func _on_AdUnit_text_entered(new_text): + $GridContainer/ConfirmButton.emit_signal("pressed") + +func _on_EditButton_pressed(): + old_name_value = Name.text + self.is_editing = true diff --git a/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.tscn b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.tscn new file mode 100644 index 0000000..7037ff3 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.tscn @@ -0,0 +1,97 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.gd" type="Script" id=1] + +[node name="AdUnit" type="GridContainer"] +margin_right = 220.0 +margin_bottom = 24.0 +columns = 3 +script = ExtResource( 1 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Name" type="LineEdit" parent="."] +margin_right = 108.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +text = "" +align = 1 +expand_to_text_length = true +virtual_keyboard_enabled = false + +[node name="Id" type="LineEdit" parent="."] +margin_left = 112.0 +margin_right = 196.0 +margin_bottom = 24.0 +size_flags_horizontal = 3 +text = "" +align = 1 +expand_to_text_length = true +virtual_keyboard_enabled = false +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="GridContainer" type="GridContainer" parent="."] +margin_left = 200.0 +margin_right = 255.0 +margin_bottom = 24.0 +columns = 2 + +[node name="ConfirmButton" type="Button" parent="GridContainer"] +margin_right = 31.0 +margin_bottom = 20.0 +text = "OK" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="EditButton" type="Button" parent="GridContainer"] +visible = false +margin_left = 35.0 +margin_right = 76.0 +margin_bottom = 20.0 +text = "EDIT" + +[node name="RemoveButton" type="Button" parent="GridContainer"] +margin_left = 35.0 +margin_right = 55.0 +margin_bottom = 20.0 +text = "X" + +[node name="Alerts" type="Node" parent="."] + +[node name="UniqueNameAcceptDialog" type="AcceptDialog" parent="Alerts"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -95.0 +margin_top = -29.0 +margin_right = 95.0 +margin_bottom = 29.0 +dialog_text = "The Name must be unique!" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="NameIdEmptyAcceptDialog" type="AcceptDialog" parent="Alerts"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -95.0 +margin_top = -29.0 +margin_right = 95.0 +margin_bottom = 29.0 +dialog_text = "The Name and Id must not be empty!" +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="text_entered" from="Name" to="." method="_on_AdUnit_text_entered"] +[connection signal="text_entered" from="Id" to="." method="_on_AdUnit_text_entered"] +[connection signal="pressed" from="GridContainer/ConfirmButton" to="." method="_on_ConfirmButton_pressed"] +[connection signal="pressed" from="GridContainer/EditButton" to="." method="_on_EditButton_pressed"] +[connection signal="pressed" from="GridContainer/RemoveButton" to="." method="_on_RemoveButton_pressed"] diff --git a/addons/admob/scripts/MobileAds.gd b/addons/admob/src/singletons/MobileAds.gd similarity index 69% rename from addons/admob/scripts/MobileAds.gd rename to addons/admob/src/singletons/MobileAds.gd index 5ebc89a..c8ea42a 100644 --- a/addons/admob/scripts/MobileAds.gd +++ b/addons/admob/src/singletons/MobileAds.gd @@ -1,15 +1,18 @@ -extends "util/Variables.gd" +extends Node +var AdMobSettings = preload("res://addons/admob/src/utils/AdMobSettings.gd").new() +onready var config = AdMobSettings.config var plugin : Object func _ready() -> void: - if config.is_enabled: + if config.general.is_enabled: if (Engine.has_singleton("AdMob")): plugin = Engine.get_singleton("AdMob") initialize() # warning-ignore:return_value_discarded get_tree().connect("screen_resized", self, "_on_get_tree_resized") + func get_is_initialized() -> bool: if plugin: return plugin.get_is_initialized() @@ -17,24 +20,24 @@ func get_is_initialized() -> bool: func initialize() -> void: if plugin and not get_is_initialized(): - plugin.initialize(config.is_for_child_directed_treatment, MAX_AD_RATING[config.max_ad_content_rating], OS.has_feature("release"), config.is_test_europe_user_consent) - + plugin.initialize(config.general.is_for_child_directed_treatment, config.general.max_ad_content_rating, OS.has_feature("release"), config.general.is_test_europe_user_consent) -func load_banner() -> void: +func load_banner(ad_unit_name : String = "demo") -> void: if plugin: - plugin.load_banner(config.unit_ids.banner[OS.get_name()], config.banner.position, BANNER_SIZE[config.banner.size], config.banner.show_instantly) + print(config.banner.size) + plugin.load_banner(config.banner.unit_ids[OS.get_name()][ad_unit_name], config.banner.position, config.banner.size, config.banner.show_instantly) -func load_interstitial() -> void: +func load_interstitial(ad_unit_name : String = "demo") -> void: if plugin: - plugin.load_interstitial(config.unit_ids.interstitial[OS.get_name()]) + plugin.load_interstitial(config.interstitial.unit_ids[OS.get_name()][ad_unit_name]) -func load_rewarded() -> void: +func load_rewarded(ad_unit_name : String = "demo") -> void: if plugin: - plugin.load_rewarded(config.unit_ids.rewarded[OS.get_name()]) + plugin.load_rewarded(config.rewarded.unit_ids[OS.get_name()][ad_unit_name]) -func load_rewarded_interstitial() -> void: +func load_rewarded_interstitial(ad_unit_name : String = "demo") -> void: if plugin: - plugin.load_rewarded_interstitial(config.unit_ids.rewarded_interstitial[OS.get_name()]) + plugin.load_rewarded_interstitial(config.rewarded_interstitial.unit_ids[OS.get_name()][ad_unit_name]) func destroy_banner() -> void: if plugin: diff --git a/addons/admob/src/utils/AdMobLoad.gd b/addons/admob/src/utils/AdMobLoad.gd new file mode 100644 index 0000000..d2ad866 --- /dev/null +++ b/addons/admob/src/utils/AdMobLoad.gd @@ -0,0 +1,4 @@ +static func load_config(p_path) -> Dictionary: + if ProjectSettings.has_setting(p_path): + return ProjectSettings.get_setting(p_path) + return {} diff --git a/addons/admob/src/utils/AdMobSave.gd b/addons/admob/src/utils/AdMobSave.gd new file mode 100644 index 0000000..1464d18 --- /dev/null +++ b/addons/admob/src/utils/AdMobSave.gd @@ -0,0 +1,2 @@ +static func save_config(p_path : String, p_config : Dictionary) -> void: + ProjectSettings.set_setting(p_path, p_config) diff --git a/addons/admob/src/utils/AdMobSettings.gd b/addons/admob/src/utils/AdMobSettings.gd new file mode 100644 index 0000000..78b8fab --- /dev/null +++ b/addons/admob/src/utils/AdMobSettings.gd @@ -0,0 +1,101 @@ +var AdMobLoad = preload("res://addons/admob/src/utils/AdMobLoad.gd") +var AdMobSave = preload("res://addons/admob/src/utils/AdMobSave.gd") + +enum INITIALIZATION_STATUS {NOT_READY, READY} +const PATH_ADMOB_PROJECT_SETTINGS = "admob/config" + +const BANNER_SIZE : Array = ["BANNER", "MEDIUM_RECTANGLE", "FULL_BANNER", "LEADERBOARD", "ADAPTIVE", "SMART_BANNER"] +const MAX_AD_RATING : Array = ["G", "PG", "T", "MA"] +enum POSITION {TOP, BOTTOM} + +var version_support : Dictionary = { + "ios" : "v2.0.0", + "android" : "v2.0.0" +} + +var config : Dictionary = { + "general" : { + "is_enabled": true, + "is_for_child_directed_treatment": false, + "is_test_europe_user_consent": false, + "max_ad_content_rating": "PG" + }, + "banner": { + "position": POSITION.TOP, + "show_instantly": true, + "size": "MEDIUM_RECTANGLE", + "unit_ids" : { + "Android": { + "demo" : "ca-app-pub-3940256099942544/6300978111", + }, + "iOS": { + "demo" : "ca-app-pub-3940256099942544/2934735716" + } + } + }, + "interstitial": { + "unit_ids" : { + "Android": { + "demo" : "ca-app-pub-3940256099942544/1033173712" + }, + "iOS": { + "demo" : "ca-app-pub-3940256099942544/4411468910" + } + } + }, + "rewarded": { + "unit_ids" : { + "Android": { + "demo" : "ca-app-pub-3940256099942544/5224354917" + }, + "iOS": { + "demo" : "ca-app-pub-3940256099942544/1712485313" + } + } + }, + "rewarded_interstitial": { + "unit_ids" : { + "Android": { + "demo" : "ca-app-pub-3940256099942544/5354046379" + }, + "iOS": { + "demo" : "ca-app-pub-3940256099942544/6978759866" + } + } + } +} setget set_config + +func _init(): + var config_project_settings : Dictionary = AdMobLoad.load_config(PATH_ADMOB_PROJECT_SETTINGS) + merge_dir(config, config_project_settings) + save_config() + +func save_config(): + AdMobSave.save_config(PATH_ADMOB_PROJECT_SETTINGS, self.config) + +func set_config(value : Dictionary): + config = value + save_config() + +func merge_dir(target : Dictionary, patch : Dictionary): + for key in patch: + if target.has(key): + var tv = target[key] + if typeof(tv) == TYPE_DICTIONARY: + merge_dir(tv, patch[key]) + else: + target[key] = patch[key] + else: + target[key] = patch[key] + + +static func pascal2snake(string : String) -> String: + string = string.replacen("adformat", "") + var result = PoolStringArray() + for ch in string: + if ch == ch.to_lower(): + result.append(ch) + else: + result.append('_'+ch.to_lower()) + result[0] = result[0][1] + return result.join('') diff --git a/addons/admob/develop/Example.cs b/addons/admob/test/Example.cs similarity index 78% rename from addons/admob/develop/Example.cs rename to addons/admob/test/Example.cs index 6b1a97f..6f4bf32 100644 --- a/addons/admob/develop/Example.cs +++ b/addons/admob/test/Example.cs @@ -60,25 +60,25 @@ public override void _Ready() OS.CenterWindow(); Music.Play(); - foreach(String banner_size in (IEnumerable) MobileAds.Get("BANNER_SIZE")) + foreach(String banner_size in (IEnumerable) ((Godot.Object)MobileAds.Get("AdMobSettings")).Get("BANNER_SIZE")) { BannerSizes.AddItem(banner_size); } if (OS.GetName() == "Android" || OS.GetName() == "iOS"){ BannerPosition.Pressed = Convert.ToBoolean(((IDictionary) config["banner"])["position"]); MobileAds.Call("request_user_consent"); - MobileAds.Connect("consent_info_update_failure", this, nameof(_on_MobileAds_consent_info_update_failure)); - MobileAds.Connect("consent_status_changed", this, nameof(_on_MobileAds_consent_status_changed)); - MobileAds.Connect("banner_loaded", this, nameof(_on_MobileAds_banner_loaded)); - MobileAds.Connect("banner_destroyed", this, nameof(_on_MobileAds_banner_destroyed)); - MobileAds.Connect("interstitial_loaded", this, nameof(_on_MobileAds_interstitial_loaded)); - MobileAds.Connect("interstitial_closed", this, nameof(_on_MobileAds_interstitial_closed)); - MobileAds.Connect("rewarded_ad_loaded", this, nameof(_on_MobileAds_rewarded_ad_loaded)); - MobileAds.Connect("rewarded_ad_closed", this, nameof(_on_MobileAds_rewarded_ad_closed)); - MobileAds.Connect("rewarded_interstitial_ad_loaded", this, nameof(_on_MobileAds_rewarded_interstitial_ad_loaded)); - MobileAds.Connect("rewarded_interstitial_ad_closed", this, nameof(_on_MobileAds_rewarded_interstitial_ad_closed)); - MobileAds.Connect("user_earned_rewarded", this, nameof(_on_MobileAds_user_earned_rewarded)); - MobileAds.Connect("initialization_complete", this, nameof(_on_MobileAds_initialization_complete)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("consent_info_update_failure", this, nameof(_on_MobileAds_consent_info_update_failure)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("consent_status_changed", this, nameof(_on_MobileAds_consent_status_changed)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("banner_loaded", this, nameof(_on_MobileAds_banner_loaded)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("banner_destroyed", this, nameof(_on_MobileAds_banner_destroyed)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("interstitial_loaded", this, nameof(_on_MobileAds_interstitial_loaded)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("interstitial_closed", this, nameof(_on_MobileAds_interstitial_closed)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("rewarded_ad_loaded", this, nameof(_on_MobileAds_rewarded_ad_loaded)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("rewarded_ad_closed", this, nameof(_on_MobileAds_rewarded_ad_closed)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("rewarded_interstitial_ad_loaded", this, nameof(_on_MobileAds_rewarded_interstitial_ad_loaded)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("rewarded_interstitial_ad_closed", this, nameof(_on_MobileAds_rewarded_interstitial_ad_closed)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("user_earned_rewarded", this, nameof(_on_MobileAds_user_earned_rewarded)); + ((Godot.Object)MobileAds.Get("plugin")).Connect("initialization_complete", this, nameof(_on_MobileAds_initialization_complete)); } else { @@ -88,15 +88,16 @@ public override void _Ready() private void _on_MobileAds_initialization_complete(int status, String _adapter_name) { - if (status == (int)((IDictionary) MobileAds.Get("INITIALIZATION_STATUS"))["READY"]) + if (status == (int)((IDictionary) ((Godot.Object)MobileAds.Get("AdMobSettings")).Get("INITIALIZATION_STATUS"))["READY"]) { MobileAds.Call("load_interstitial"); MobileAds.Call("load_rewarded"); MobileAds.Call("load_rewarded_interstitial"); + _add_text_Advice_Node("AdMob initialized on C#! With parameters:"); - _add_text_Advice_Node("is_real: " + config["is_real"].ToString()); - _add_text_Advice_Node("is_for_child_directed_treatment: " + config["is_for_child_directed_treatment"].ToString()); - _add_text_Advice_Node("max_ad_content_rating: " + config["max_ad_content_rating"].ToString()); + _add_text_Advice_Node("is_for_child_directed_treatment: " + ((IDictionary) config["general"])["is_for_child_directed_treatment"].ToString()); + _add_text_Advice_Node("is_test_europe_user_consent: " + ((IDictionary) config["general"])["is_test_europe_user_consent"].ToString()); + _add_text_Advice_Node("max_ad_content_rating: " + ((IDictionary) config["general"])["max_ad_content_rating"].ToString()); _add_text_Advice_Node("instance_id: " + GetInstanceId().ToString()); EnableBanner.Disabled = false; BannerPosition.Disabled = false; diff --git a/addons/admob/develop/Example.gd b/addons/admob/test/Example.gd similarity index 73% rename from addons/admob/develop/Example.gd rename to addons/admob/test/Example.gd index 7233539..f642fba 100644 --- a/addons/admob/develop/Example.gd +++ b/addons/admob/test/Example.gd @@ -24,47 +24,48 @@ func _add_text_Advice_Node(text_value : String): func _ready(): OS.center_window() Music.play() - for banner_size in MobileAds.BANNER_SIZE: + for banner_size in MobileAds.AdMobSettings.BANNER_SIZE: BannerSizes.add_item(banner_size) if OS.get_name() == "Android" or OS.get_name() == "iOS": - BannerPosition.pressed = MobileAds.config.banner.position + BannerPosition.pressed = MobileAds.AdMobSettings.config.banner.position MobileAds.request_user_consent() - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("consent_info_update_failure", self, "_on_MobileAds_consent_info_update_failure") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("consent_status_changed", self, "_on_MobileAds_consent_status_changed") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("banner_loaded", self, "_on_MobileAds_banner_loaded") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("banner_destroyed", self, "_on_MobileAds_banner_destroyed") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("interstitial_loaded", self, "_on_MobileAds_interstitial_loaded") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("interstitial_closed", self, "_on_MobileAds_interstitial_closed") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("rewarded_ad_loaded", self, "_on_MobileAds_rewarded_ad_loaded") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("rewarded_ad_closed", self, "_on_MobileAds_rewarded_ad_closed") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("rewarded_interstitial_ad_loaded", self, "_on_MobileAds_rewarded_interstitial_ad_loaded") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("rewarded_interstitial_ad_closed", self, "_on_MobileAds_rewarded_interstitial_ad_closed") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("user_earned_rewarded", self, "_on_MobileAds_user_earned_rewarded") - # warning-ignore:return_value_discarded - MobileAds.plugin.connect("initialization_complete", self, "_on_MobileAds_initialization_complete") + if MobileAds.plugin != null: + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("consent_info_update_failure", self, "_on_MobileAds_consent_info_update_failure") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("consent_status_changed", self, "_on_MobileAds_consent_status_changed") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("banner_loaded", self, "_on_MobileAds_banner_loaded") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("banner_destroyed", self, "_on_MobileAds_banner_destroyed") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("interstitial_loaded", self, "_on_MobileAds_interstitial_loaded") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("interstitial_closed", self, "_on_MobileAds_interstitial_closed") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("rewarded_ad_loaded", self, "_on_MobileAds_rewarded_ad_loaded") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("rewarded_ad_closed", self, "_on_MobileAds_rewarded_ad_closed") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("rewarded_interstitial_ad_loaded", self, "_on_MobileAds_rewarded_interstitial_ad_loaded") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("rewarded_interstitial_ad_closed", self, "_on_MobileAds_rewarded_interstitial_ad_closed") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("user_earned_rewarded", self, "_on_MobileAds_user_earned_rewarded") + # warning-ignore:return_value_discarded + MobileAds.plugin.connect("initialization_complete", self, "_on_MobileAds_initialization_complete") else: _add_text_Advice_Node("AdMob only works on Android or iOS devices!") func _on_MobileAds_initialization_complete(status, _adapter_name): - if status == MobileAds.INITIALIZATION_STATUS.READY: + if status == MobileAds.AdMobSettings.INITIALIZATION_STATUS.READY: MobileAds.load_interstitial() MobileAds.load_rewarded() MobileAds.load_rewarded_interstitial() _add_text_Advice_Node("AdMob initialized on GDScript! With parameters:") - _add_text_Advice_Node("is_real: " + str(MobileAds.config.is_real)) - _add_text_Advice_Node("is_for_child_directed_treatment: " + str(MobileAds.config.is_for_child_directed_treatment)) - _add_text_Advice_Node("max_ad_content_rating: " + str(MobileAds.config.max_ad_content_rating)) + _add_text_Advice_Node("is_for_child_directed_treatment: " + str(MobileAds.config.general.is_for_child_directed_treatment)) + _add_text_Advice_Node("is_test_europe_user_consent: " + str(MobileAds.config.general.is_test_europe_user_consent)) + _add_text_Advice_Node("max_ad_content_rating: " + str(MobileAds.config.general.max_ad_content_rating)) _add_text_Advice_Node("instance_id: " + str(get_instance_id())) EnableBanner.disabled = false BannerPosition.disabled = false @@ -134,7 +135,7 @@ func _on_MobileAds_rewarded_ad_closed(): func _on_MobileAds_rewarded_interstitial_ad_loaded(): RewardedInterstitial.disabled = false _add_text_Advice_Node("Rewarded Interstitial ad loaded") - + func _on_MobileAds_rewarded_interstitial_ad_closed(): MobileAds.load_rewarded_interstitial() _add_text_Advice_Node("Rewarded Interstitial ad closed") @@ -152,7 +153,7 @@ func _on_MobileAds_consent_status_changed(status_message : String): func _on_BannerSizes_item_selected(index): if MobileAds.get_is_initialized(): var item_text : String = BannerSizes.get_item_text(index) - MobileAds.config.banner.size = index + MobileAds.config.banner.size = item_text _add_text_Advice_Node("Banner Size changed:" + item_text) if MobileAds.get_is_banner_loaded(): MobileAds.load_banner() diff --git a/addons/admob/develop/Example.tscn b/addons/admob/test/Example.tscn similarity index 99% rename from addons/admob/develop/Example.tscn rename to addons/admob/test/Example.tscn index fd78454..c7818cf 100644 --- a/addons/admob/develop/Example.tscn +++ b/addons/admob/test/Example.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=9 format=2] -[ext_resource path="res://addons/admob/develop/Example.gd" type="Script" id=1] +[ext_resource path="res://addons/admob/test/Example.gd" type="Script" id=1] [ext_resource path="res://addons/admob/assets/icon-500.png" type="Texture" id=2] [ext_resource path="res://addons/admob/assets/poing.jpeg" type="Texture" id=3] [ext_resource path="res://addons/admob/assets/music.ogg" type="AudioStream" id=4] diff --git a/test.tres b/test.tres new file mode 100644 index 0000000..ecdf0e2 --- /dev/null +++ b/test.tres @@ -0,0 +1,36 @@ +[gd_resource type="GDScript" format=2] + +[resource] +script/source = "extends Node + +var config : Dictionary = { + \"banner\": { + \"position\": 1, + \"show_instantly\": true, + \"size\": \"MEDIUM_RECTANGLE\" + }, + \"is_enabled\": true, + \"is_for_child_directed_treatment\": false, + \"is_test_europe_user_consent\": false, + \"max_ad_content_rating\": \"PG\", + \"position\": 0, + \"unit_ids\": { + \"banner\": { + \"Android\": \"ca-app-pub-3940256099942544/6300978111\", + \"iOS\": \"ca-app-pub-3940256099942544/2934735716\" + }, + \"interstitial\": { + \"Android\": \"ca-app-pub-3940256099942544/1033173712\", + \"iOS\": \"ca-app-pub-3940256099942544/4411468910\" + }, + \"rewarded\": { + \"Android\": \"ca-app-pub-3940256099942544/5224354917\", + \"iOS\": \"ca-app-pub-3940256099942544/1712485313\" + }, + \"rewarded_interstitial\": { + \"Android\": \"ca-app-pub-3940256099942544/5354046379\", + \"iOS\": \"ca-app-pub-3940256099942544/6978759866\" + } + } +} +"