mirror of
https://github.com/Yadciel1/2048-Shooter.git
synced 2025-06-16 11:15:23 +02:00
first
This commit is contained in:
27
addons/admob/src/core/AdMob.gd
Normal file
27
addons/admob/src/core/AdMob.gd
Normal file
@ -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")
|
16
addons/admob/src/core/AdMobEditor.gd
Normal file
16
addons/admob/src/core/AdMobEditor.gd
Normal file
@ -0,0 +1,16 @@
|
||||
tool
|
||||
extends Control
|
||||
var AdMobSettings = preload("res://addons/admob/src/utils/AdMobSettings.gd").new()
|
||||
|
||||
|
||||
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")
|
244
addons/admob/src/core/AdMobEditor.tscn
Normal file
244
addons/admob/src/core/AdMobEditor.tscn
Normal file
@ -0,0 +1,244 @@
|
||||
[gd_scene load_steps=23 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]
|
||||
[ext_resource path="res://addons/admob/src/core/components/Debug.tscn" type="PackedScene" id=13]
|
||||
[ext_resource path="res://addons/admob/src/core/SupportVersion.gd" type="Script" id=14]
|
||||
[ext_resource path="res://addons/admob/src/core/CurrentVersion.gd" type="Script" id=15]
|
||||
[ext_resource path="res://addons/admob/src/core/VersionSupportedHTTPRequest.tscn" type="PackedScene" id=16]
|
||||
|
||||
[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="DynamicFont" id=4]
|
||||
size = 20
|
||||
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=6]
|
||||
size = 20
|
||||
outline_size = 1
|
||||
outline_color = Color( 0, 0, 0, 1 )
|
||||
use_filter = true
|
||||
font_data = ExtResource( 3 )
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=5]
|
||||
bg_color = Color( 0.172549, 0.568627, 0.992157, 1 )
|
||||
|
||||
[node name="AdMobEditor" type="Control"]
|
||||
pause_mode = 2
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_clip_content = true
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 4 )
|
||||
|
||||
[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 = 600.0
|
||||
margin_bottom = 949.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
tab_align = 0
|
||||
|
||||
[node name="General" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 8 )]
|
||||
|
||||
[node name="Debug" parent="MiddleScrollContainer/TabContainer" instance=ExtResource( 13 )]
|
||||
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="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_fonts/normal_font = SubResource( 4 )
|
||||
custom_styles/normal = SubResource( 3 )
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[rainbow sat=10]iOS[/rainbow][color=black]:v2.1.0[/color] [rainbow sat=10]Android[/rainbow][color=black]:v2.1.0[/color]"
|
||||
text = "iOS:v2.1.0 Android:v2.1.0"
|
||||
script = ExtResource( 14 )
|
||||
|
||||
[node name="VersionSupportedHTTPRequest" parent="BottomPanel/SupportVersion" instance=ExtResource( 16 )]
|
||||
|
||||
[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_fonts/font = SubResource( 6 )
|
||||
custom_styles/normal = SubResource( 5 )
|
||||
text = "Version: 1.3.0"
|
||||
align = 2
|
||||
script = ExtResource( 15 )
|
||||
|
||||
[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"]
|
7
addons/admob/src/core/CurrentVersion.gd
Normal file
7
addons/admob/src/core/CurrentVersion.gd
Normal file
@ -0,0 +1,7 @@
|
||||
tool
|
||||
extends Label
|
||||
|
||||
var AdMobGlobals = preload("res://addons/admob/src/utils/AdMobGlobals.gd")
|
||||
|
||||
func _ready():
|
||||
text = "Version: " + AdMobGlobals.get_plugin_version()
|
8
addons/admob/src/core/SupportVersion.gd
Normal file
8
addons/admob/src/core/SupportVersion.gd
Normal file
@ -0,0 +1,8 @@
|
||||
tool
|
||||
extends RichTextLabel
|
||||
|
||||
var support_version_text = "[rainbow sat=10]iOS[/rainbow][color=black]:%s[/color] [rainbow sat=10]Android[/rainbow][color=black]:%s[/color]"
|
||||
|
||||
|
||||
func _on_VersionSupportedHTTPRequest_supported_version_changed(value_dictionary):
|
||||
bbcode_text = support_version_text % [value_dictionary.ios, value_dictionary.android]
|
16
addons/admob/src/core/VersionSupportedHTTPRequest.gd
Normal file
16
addons/admob/src/core/VersionSupportedHTTPRequest.gd
Normal file
@ -0,0 +1,16 @@
|
||||
tool
|
||||
extends HTTPRequest
|
||||
|
||||
signal supported_version_changed(value_dictionary)
|
||||
|
||||
var AdMobGlobals = preload("res://addons/admob/src/utils/AdMobGlobals.gd")
|
||||
|
||||
func _ready():
|
||||
request("https://gist.githubusercontent.com/gumaciel/ba15bd85ebcc87866c24a819de37cc9a/raw/admob_editor_versions_supported.json")
|
||||
|
||||
|
||||
func _on_VersionSupportedHTTPRequest_request_completed(result, response_code, headers, body):
|
||||
var json = JSON.parse(body.get_string_from_utf8())
|
||||
|
||||
var version_support : Dictionary = json.result[AdMobGlobals.get_plugin_version()]
|
||||
emit_signal("supported_version_changed", version_support)
|
8
addons/admob/src/core/VersionSupportedHTTPRequest.tscn
Normal file
8
addons/admob/src/core/VersionSupportedHTTPRequest.tscn
Normal file
@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/admob/src/core/VersionSupportedHTTPRequest.gd" type="Script" id=1]
|
||||
|
||||
[node name="VersionSupportedHTTPRequest" type="HTTPRequest"]
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[connection signal="request_completed" from="." to="." method="_on_VersionSupportedHTTPRequest_request_completed"]
|
29
addons/admob/src/core/components/Debug.gd
Normal file
29
addons/admob/src/core/components/Debug.gd
Normal file
@ -0,0 +1,29 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
|
||||
onready var AdMobEditor : Control = find_parent("AdMobEditor")
|
||||
onready var DebugOnRelease : Control = $TabContainer/Release/DebugOnRelease
|
||||
onready var IsReal : Control = $TabContainer/Release/IsReal
|
||||
onready var TestEuropeUserConsent : Control = $TabContainer/General/TestEuropeUserConsent
|
||||
|
||||
func _ready():
|
||||
DebugOnRelease.pressed = AdMobEditor.AdMobSettings.config.debug.is_debug_on_release
|
||||
IsReal.pressed = AdMobEditor.AdMobSettings.config.debug.is_real
|
||||
TestEuropeUserConsent.pressed = AdMobEditor.AdMobSettings.config.debug.is_test_europe_user_consent
|
||||
|
||||
IsReal.disabled = not DebugOnRelease.pressed
|
||||
|
||||
|
||||
func _on_DebugOnRelease_pressed():
|
||||
AdMobEditor.AdMobSettings.config.debug.is_debug_on_release = DebugOnRelease.pressed
|
||||
if DebugOnRelease.pressed:
|
||||
IsReal.disabled = false
|
||||
else:
|
||||
IsReal.disabled = true
|
||||
|
||||
func _on_IsReal_pressed():
|
||||
AdMobEditor.AdMobSettings.config.debug.is_real = IsReal.pressed
|
||||
|
||||
func _on_TestEuropeUserConsent_pressed():
|
||||
AdMobEditor.AdMobSettings.config.debug.is_test_europe_user_consent = TestEuropeUserConsent.pressed
|
||||
|
68
addons/admob/src/core/components/Debug.tscn
Normal file
68
addons/admob/src/core/components/Debug.tscn
Normal file
@ -0,0 +1,68 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/admob/src/core/components/Debug.gd" type="Script" id=1]
|
||||
|
||||
[node name="Debug" type="VBoxContainer"]
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="."]
|
||||
margin_right = 151.0
|
||||
margin_bottom = 582.0
|
||||
tab_align = 0
|
||||
|
||||
[node name="General" 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="TestEuropeUserConsent" type="CheckBox" parent="TabContainer/General"]
|
||||
margin_right = 193.0
|
||||
margin_bottom = 24.0
|
||||
text = "Test Europe User Consent"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Release" 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="DebugOnRelease" type="CheckBox" parent="TabContainer/Release"]
|
||||
margin_right = 143.0
|
||||
margin_bottom = 24.0
|
||||
text = "Debug on Release"
|
||||
|
||||
[node name="IsReal" type="CheckBox" parent="TabContainer/Release"]
|
||||
margin_top = 28.0
|
||||
margin_right = 143.0
|
||||
margin_bottom = 52.0
|
||||
disabled = true
|
||||
pressed = true
|
||||
text = "Is Real"
|
||||
|
||||
[node name="Advice" type="Label" parent="TabContainer/Release"]
|
||||
margin_top = 56.0
|
||||
margin_right = 143.0
|
||||
margin_bottom = 546.0
|
||||
text = "Advice: `Is Real` will ALWAYS be true unless `Debug on Release` is true.
|
||||
|
||||
So if `Debug on Release` is true it will consider the value of `Is Real` on this page when the game is exported as \"Release\".
|
||||
|
||||
In other words, you don't need to change anything on this page as it may cause bugs in your app once it's in the store.
|
||||
|
||||
Note: The `Test Europe User Consent` button even if it is true, when the application goes to production, that value will be false IF `Debug on Release` is false."
|
||||
autowrap = true
|
||||
|
||||
[connection signal="pressed" from="TabContainer/General/TestEuropeUserConsent" to="." method="_on_TestEuropeUserConsent_pressed"]
|
||||
[connection signal="pressed" from="TabContainer/Release/DebugOnRelease" to="." method="_on_DebugOnRelease_pressed"]
|
||||
[connection signal="pressed" from="TabContainer/Release/IsReal" to="." method="_on_IsReal_pressed"]
|
184
addons/admob/src/core/components/Downloads.gd
Normal file
184
addons/admob/src/core/components/Downloads.gd
Normal file
@ -0,0 +1,184 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
|
||||
onready var AdMobEditor : Control = find_parent("AdMobEditor")
|
||||
|
||||
onready var godot_version : String = "v" + String(Engine.get_version_info().major) + "." + String(Engine.get_version_info().minor) + "." + String(Engine.get_version_info().patch)
|
||||
var actual_downloading_file : String = ""
|
||||
var downloaded_plugin_version : String = ""
|
||||
var version_support : Dictionary
|
||||
|
||||
var android_dictionary : Dictionary = {
|
||||
"version" : ["CURRENT"],
|
||||
"download_directory" : "res://addons/admob/downloads/android"
|
||||
} setget set_android_dictionary
|
||||
|
||||
var ios_dictionary : Dictionary = {
|
||||
"version" : ["CURRENT"],
|
||||
"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! \n%s"
|
||||
|
||||
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():
|
||||
$DontHaveConnectionPanelContainer/Label.text %= $VerifyNetworkGithub.server_to_test
|
||||
|
||||
if godot_version[godot_version.length()-1] == "0":
|
||||
godot_version = godot_version.substr(0, godot_version.length()-2)
|
||||
|
||||
set_process(false)
|
||||
set_version_platform_supported("ios")
|
||||
set_version_platform_supported("android")
|
||||
$TabContainer/Android/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % android_dictionary.download_directory
|
||||
$TabContainer/iOS/ChangeDirectoryHBoxContainer/DownloadDirectoryLabel.text = current_dir_download_label % ios_dictionary.download_directory
|
||||
|
||||
func set_version_platform_supported(platform):
|
||||
if platform == "android":
|
||||
$TabContainer/Android/VersionHBoxContainer/AndroidVersion.clear()
|
||||
for i in android_dictionary.version:
|
||||
$TabContainer/Android/VersionHBoxContainer/AndroidVersion.add_item(i)
|
||||
elif platform == "ios":
|
||||
$TabContainer/iOS/VersionHBoxContainer/iOSVersion.clear()
|
||||
for i in ios_dictionary.version:
|
||||
$TabContainer/iOS/VersionHBoxContainer/iOSVersion.add_item(i)
|
||||
|
||||
|
||||
func _process(delta):
|
||||
var bodySize = $TabContainer/HTTPRequest.get_body_size()
|
||||
var downloadedBytes = $TabContainer/HTTPRequest.get_downloaded_bytes()
|
||||
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, downloaded_plugin_version]
|
||||
|
||||
set_process(false)
|
||||
$AdviceAcceptDialog.popup_centered()
|
||||
|
||||
|
||||
func _on_DownloadGoogleMobileAdsSdkiOS_pressed():
|
||||
var file_name = "googlemobileadssdkios.zip"
|
||||
var plugin_version = version_support.ios
|
||||
$TabContainer/HTTPRequest.download_file = ios_dictionary.download_directory + "/" + file_name
|
||||
$TabContainer/HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-ios/releases/download/" + plugin_version + "/" + file_name)
|
||||
actual_downloading_file = file_name
|
||||
downloaded_plugin_version = "iOS Plugin Version: " + plugin_version
|
||||
|
||||
set_process(true)
|
||||
|
||||
func _on_DownloadiOSTemplate_pressed():
|
||||
var ios_version = $TabContainer/iOS/VersionHBoxContainer/iOSVersion.text
|
||||
if ios_version == "CURRENT":
|
||||
ios_version = godot_version
|
||||
|
||||
var file_name = "ios-template-" + ios_version + ".zip"
|
||||
var plugin_version = version_support.ios
|
||||
$TabContainer/HTTPRequest.download_file = ios_dictionary.download_directory + "/" + file_name
|
||||
$TabContainer/HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-ios/releases/download/" + plugin_version + "/" + file_name)
|
||||
actual_downloading_file = file_name
|
||||
downloaded_plugin_version = "iOS Plugin Version: " + plugin_version
|
||||
|
||||
set_process(true)
|
||||
|
||||
func _on_DownloadAndroidTemplate_pressed():
|
||||
var android_version = $TabContainer/Android/VersionHBoxContainer/AndroidVersion.text.to_lower()
|
||||
if android_version == "current":
|
||||
android_version = godot_version
|
||||
|
||||
var android_target = $TabContainer/Android/TargetHBoxContainer/MenuButton.text.to_lower()
|
||||
|
||||
if android_target == "current":
|
||||
android_target = "mono" if Engine.has_singleton("GodotSharp") else "standard"
|
||||
|
||||
|
||||
var file_name = "android-"+ android_target + "-template-" + android_version + ".zip"
|
||||
var plugin_version = version_support.android
|
||||
$TabContainer/HTTPRequest.download_file = android_dictionary.download_directory + "/" + file_name
|
||||
$TabContainer/HTTPRequest.request("https://github.com/Poing-Studios/godot-admob-android/releases/download/" + plugin_version + "/" + file_name)
|
||||
actual_downloading_file = file_name
|
||||
|
||||
downloaded_plugin_version = "Android Plugin Version: " + plugin_version
|
||||
|
||||
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()
|
||||
|
||||
|
||||
func _on_AndroidOpenDirectoryButton_pressed():
|
||||
var path_directory = ProjectSettings.globalize_path(android_dictionary.download_directory)
|
||||
OS.shell_open(str("file://", path_directory))
|
||||
|
||||
|
||||
func _on_iOSOpenDirectoryButton_pressed():
|
||||
var path_directory = ProjectSettings.globalize_path(ios_dictionary.download_directory)
|
||||
OS.shell_open(str("file://", path_directory))
|
||||
|
||||
|
||||
func _on_VerifyNetworkGithub_network_status_changed(value : int):
|
||||
if value == $VerifyNetworkGithub.CONNECTED:
|
||||
$TabContainer.visible = true
|
||||
$DontHaveConnectionPanelContainer.visible = false
|
||||
else:
|
||||
$TabContainer.visible = false
|
||||
$DontHaveConnectionPanelContainer.visible = true
|
||||
|
||||
|
||||
func _on_VersionSupportedHTTPRequest_supported_version_changed(value_dictionary : Dictionary):
|
||||
version_support = value_dictionary
|
||||
$VersionsAndroidSupportedHTTPRequest.request("https://api.github.com/repos/Poing-Studios/godot-admob-android/releases/tags/"+version_support["android"])
|
||||
$VersionsiOSSupportedHTTPRequest.request("https://api.github.com/repos/Poing-Studios/godot-admob-ios/releases/tags/"+version_support["ios"])
|
||||
|
||||
|
||||
func get_versions_platform_supported(body):
|
||||
var json = JSON.parse(body.get_string_from_utf8())
|
||||
|
||||
var regex = RegEx.new()
|
||||
regex.compile("[v](([0-9])+(\\.{0,1}([0-9]))*)+")
|
||||
|
||||
var versions_supported : Array
|
||||
|
||||
for asset in json.result["assets"]:
|
||||
var godot_version = asset["name"]
|
||||
|
||||
var regex_result = regex.search(godot_version)
|
||||
if regex_result:
|
||||
if not versions_supported.has(regex_result.get_string()):
|
||||
versions_supported.append(regex_result.get_string())
|
||||
|
||||
return versions_supported
|
||||
|
||||
|
||||
|
||||
func _on_VersionsiOSSupportedHTTPRequest_request_completed(result, response_code, headers, body):
|
||||
ios_dictionary.version.append_array(get_versions_platform_supported(body))
|
||||
set_version_platform_supported("ios")
|
||||
|
||||
func _on_VersionsAndroidSupportedHTTPRequest_request_completed(result, response_code, headers, body):
|
||||
android_dictionary.version.append_array(get_versions_platform_supported(body))
|
||||
set_version_platform_supported("android")
|
265
addons/admob/src/core/components/Downloads.tscn
Normal file
265
addons/admob/src/core/components/Downloads.tscn
Normal file
@ -0,0 +1,265 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://addons/admob/src/core/components/Downloads.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/admob/src/core/components/VerifyNetworkGithub.gd" type="Script" id=2]
|
||||
[ext_resource path="res://addons/admob/src/core/VersionSupportedHTTPRequest.tscn" type="PackedScene" id=3]
|
||||
|
||||
[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 )
|
||||
|
||||
[node name="Advice" type="Label" parent="."]
|
||||
margin_right = 720.0
|
||||
margin_bottom = 65.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 = 69.0
|
||||
margin_right = 720.0
|
||||
margin_bottom = 83.0
|
||||
custom_colors/font_color = Color( 0, 0, 0, 1 )
|
||||
custom_styles/fg = SubResource( 1 )
|
||||
custom_styles/bg = SubResource( 2 )
|
||||
|
||||
[node name="AdviceAcceptDialog" type="AcceptDialog" parent="."]
|
||||
margin_top = 104.0
|
||||
margin_right = 500.0
|
||||
margin_bottom = 162.0
|
||||
popup_exclusive = true
|
||||
window_title = "Alerta!"
|
||||
dialog_text = "Download of %s completed! \\n%s"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TabContainer" type="TabContainer" parent="."]
|
||||
margin_top = 87.0
|
||||
margin_right = 720.0
|
||||
margin_bottom = 215.0
|
||||
|
||||
[node name="HTTPRequest" type="HTTPRequest" parent="TabContainer"]
|
||||
|
||||
[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 = 712.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="AndroidOpenDirectoryButton" type="Button" parent="TabContainer/Android/ChangeDirectoryHBoxContainer"]
|
||||
margin_left = 589.0
|
||||
margin_right = 712.0
|
||||
margin_bottom = 20.0
|
||||
text = "OPEN 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 = 712.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, "v3.2.2", null, false, 1, null, "v3.2.3", null, false, 2, null, "v3.3.1", null, false, 3, null, "v3.3.2", null, false, 4, null, "v3.3.3", null, false, 5, null, "v3.3.4", null, false, 6, null, "v3.3", null, false, 7, null, "v3.4.1", null, false, 8, null, "v3.4.2", null, false, 9, null, "v3.4.3", null, false, 10, null, "v3.4.4", null, false, 11, null, "v3.4", null, false, 12, null ]
|
||||
selected = 0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TargetHBoxContainer" type="HBoxContainer" parent="TabContainer/Android"]
|
||||
margin_top = 48.0
|
||||
margin_right = 712.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 = 712.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 = 24.0
|
||||
margin_right = 599.0
|
||||
margin_bottom = 354.0
|
||||
|
||||
[node name="ChangeDirectoryHBoxContainer" type="HBoxContainer" parent="TabContainer/iOS"]
|
||||
margin_right = 1690.0
|
||||
margin_bottom = 250.0
|
||||
|
||||
[node name="DownloadDirectoryLabel" type="Label" parent="TabContainer/iOS/ChangeDirectoryHBoxContainer"]
|
||||
margin_top = 118.0
|
||||
margin_right = 411.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 = 415.0
|
||||
margin_right = 556.0
|
||||
margin_bottom = 250.0
|
||||
text = "CHANGE DIRECTORY"
|
||||
|
||||
[node name="iOSOpenDirectoryButton" type="Button" parent="TabContainer/iOS/ChangeDirectoryHBoxContainer"]
|
||||
margin_left = 560.0
|
||||
margin_right = 683.0
|
||||
margin_bottom = 250.0
|
||||
text = "OPEN DIRECTORY"
|
||||
|
||||
[node name="iOSChangeDirectoryFileDialog" type="FileDialog" parent="TabContainer/iOS/ChangeDirectoryHBoxContainer"]
|
||||
visible = true
|
||||
margin_left = 687.0
|
||||
margin_right = 1087.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 = 1690.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 = 143.0
|
||||
margin_bottom = 20.0
|
||||
text = "CURRENT"
|
||||
items = [ "CURRENT", null, false, 0, null, "v3.3.1", null, false, 1, null, "v3.3.2", null, false, 2, null, "v3.3.3", null, false, 3, null, "v3.3.4", null, false, 4, null, "v3.3", null, false, 5, null, "v3.4.1", null, false, 6, null, "v3.4.2", null, false, 7, null, "v3.4.3", null, false, 8, null, "v3.4.4", null, false, 9, null, "v3.4", null, false, 10, null ]
|
||||
selected = 0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="DownloadiOSTemplate" type="Button" parent="TabContainer/iOS"]
|
||||
margin_top = 278.0
|
||||
margin_right = 1690.0
|
||||
margin_bottom = 298.0
|
||||
text = "Download iOS Template"
|
||||
|
||||
[node name="DownloadGoogleMobileAdsSdkiOS" type="Button" parent="TabContainer/iOS"]
|
||||
margin_top = 302.0
|
||||
margin_right = 1690.0
|
||||
margin_bottom = 322.0
|
||||
text = "Download GoogleMobileAdsSdkiOS"
|
||||
|
||||
[node name="DontHaveConnectionPanelContainer" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
margin_top = 219.0
|
||||
margin_right = 720.0
|
||||
margin_bottom = 263.0
|
||||
|
||||
[node name="Label" type="RichTextLabel" parent="DontHaveConnectionPanelContainer"]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 713.0
|
||||
margin_bottom = 37.0
|
||||
bbcode_enabled = true
|
||||
bbcode_text = "[b]You don't have connection to the Server: %s, please verify your connection in order to Download[/b]"
|
||||
text = "You don't have connection to the Server: https://github.com/, please verify your connection in order to Download"
|
||||
fit_content_height = true
|
||||
scroll_active = false
|
||||
|
||||
[node name="VerifyNetworkGithub" type="HTTPRequest" parent="."]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="VerifyAgainTimer" type="Timer" parent="VerifyNetworkGithub"]
|
||||
wait_time = 60.0
|
||||
autostart = true
|
||||
|
||||
[node name="VersionSupportedHTTPRequest" parent="." instance=ExtResource( 3 )]
|
||||
|
||||
[node name="VersionsAndroidSupportedHTTPRequest" type="HTTPRequest" parent="."]
|
||||
|
||||
[node name="VersionsiOSSupportedHTTPRequest" type="HTTPRequest" parent="."]
|
||||
|
||||
[connection signal="request_completed" from="TabContainer/HTTPRequest" to="." method="_on_HTTPRequest_request_completed"]
|
||||
[connection signal="pressed" from="TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidChangeDirectoryButton" to="." method="_on_AndroidChangeDirectoryButton_pressed"]
|
||||
[connection signal="pressed" from="TabContainer/Android/ChangeDirectoryHBoxContainer/AndroidOpenDirectoryButton" to="." method="_on_AndroidOpenDirectoryButton_pressed"]
|
||||
[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="pressed" from="TabContainer/iOS/ChangeDirectoryHBoxContainer/iOSOpenDirectoryButton" to="." method="_on_iOSOpenDirectoryButton_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"]
|
||||
[connection signal="network_status_changed" from="VerifyNetworkGithub" to="." method="_on_VerifyNetworkGithub_network_status_changed"]
|
||||
[connection signal="request_completed" from="VerifyNetworkGithub" to="VerifyNetworkGithub" method="_on_VerifyNetworkGithub_request_completed"]
|
||||
[connection signal="timeout" from="VerifyNetworkGithub/VerifyAgainTimer" to="VerifyNetworkGithub" method="_on_VerifyAgainTimer_timeout"]
|
||||
[connection signal="supported_version_changed" from="VersionSupportedHTTPRequest" to="." method="_on_VersionSupportedHTTPRequest_supported_version_changed"]
|
||||
[connection signal="request_completed" from="VersionsAndroidSupportedHTTPRequest" to="." method="_on_VersionsAndroidSupportedHTTPRequest_request_completed"]
|
||||
[connection signal="request_completed" from="VersionsiOSSupportedHTTPRequest" to="." method="_on_VersionsiOSSupportedHTTPRequest_request_completed"]
|
20
addons/admob/src/core/components/Enabled.gd
Normal file
20
addons/admob/src/core/components/Enabled.gd
Normal file
@ -0,0 +1,20 @@
|
||||
tool
|
||||
extends CheckBox
|
||||
|
||||
onready var AdMobEditor : Control = find_parent("AdMobEditor")
|
||||
|
||||
func _ready() -> void:
|
||||
pressed = AdMobEditor.AdMobSettings.config.general.is_enabled
|
||||
|
||||
|
||||
func _on_Enabled_pressed():
|
||||
if not pressed:
|
||||
pressed = true
|
||||
$ConfirmationDialog.show()
|
||||
else:
|
||||
AdMobEditor.AdMobSettings.config.general.is_enabled = pressed
|
||||
|
||||
|
||||
func _on_ConfirmationDialog_confirmed() -> void:
|
||||
pressed = false
|
||||
AdMobEditor.AdMobSettings.config.general.is_enabled = pressed
|
15
addons/admob/src/core/components/General.gd
Normal file
15
addons/admob/src/core/components/General.gd
Normal file
@ -0,0 +1,15 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
|
||||
onready var AdMobEditor : Control = find_parent("AdMobEditor")
|
||||
|
||||
func _ready():
|
||||
$ChildDirectedTreatment.pressed = AdMobEditor.AdMobSettings.config.general.is_for_child_directed_treatment
|
||||
$MaxAdContentRating/Value.selected = AdMobEditor.AdMobSettings.MAX_AD_RATING.find(AdMobEditor.AdMobSettings.config.general.max_ad_content_rating)
|
||||
|
||||
|
||||
func _on_ChildDirectedTreatment_pressed():
|
||||
AdMobEditor.AdMobSettings.config.general.is_for_child_directed_treatment = $ChildDirectedTreatment.pressed
|
||||
|
||||
func _on_MaxAdContentRating_item_selected(index):
|
||||
AdMobEditor.AdMobSettings.config.general.max_ad_content_rating = AdMobEditor.AdMobSettings.MAX_AD_RATING[index]
|
78
addons/admob/src/core/components/General.tscn
Normal file
78
addons/admob/src/core/components/General.tscn
Normal file
@ -0,0 +1,78 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/admob/src/core/components/General.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/admob/src/core/components/Enabled.gd" type="Script" id=2]
|
||||
|
||||
[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 )
|
||||
|
||||
[node name="Enabled" type="CheckBox" parent="."]
|
||||
margin_right = 592.0
|
||||
margin_bottom = 24.0
|
||||
pressed = true
|
||||
text = "Enabled"
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="Enabled"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -334.0
|
||||
margin_top = -46.0
|
||||
margin_right = 334.0
|
||||
margin_bottom = 46.0
|
||||
dialog_text = "If \"Enabled\" is false then ads will no longer work, are you sure?
|
||||
|
||||
Note: You can disable ads if the user purchases by IAP, that's why this attribute can be useful."
|
||||
|
||||
[node name="ChildDirectedTreatment" type="CheckBox" parent="."]
|
||||
margin_top = 28.0
|
||||
margin_right = 592.0
|
||||
margin_bottom = 52.0
|
||||
text = "Child Directed Treatment"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="MaxAdContentRating" type="HBoxContainer" parent="."]
|
||||
margin_top = 56.0
|
||||
margin_right = 592.0
|
||||
margin_bottom = 76.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="Enabled" method="_on_Enabled_pressed"]
|
||||
[connection signal="confirmed" from="Enabled/ConfirmationDialog" to="Enabled" method="_on_ConfirmationDialog_confirmed"]
|
||||
[connection signal="pressed" from="ChildDirectedTreatment" to="." method="_on_ChildDirectedTreatment_pressed"]
|
||||
[connection signal="item_selected" from="MaxAdContentRating/Value" to="." method="_on_MaxAdContentRating_item_selected"]
|
18
addons/admob/src/core/components/VerifyNetworkGithub.gd
Normal file
18
addons/admob/src/core/components/VerifyNetworkGithub.gd
Normal file
@ -0,0 +1,18 @@
|
||||
tool
|
||||
extends HTTPRequest
|
||||
|
||||
enum {CONNECTED = 200}
|
||||
|
||||
signal network_status_changed(value)
|
||||
|
||||
export var server_to_test = "https://github.com/"
|
||||
|
||||
func _ready():
|
||||
request(server_to_test)
|
||||
|
||||
func _on_VerifyNetworkGithub_request_completed(result, response_code, headers, body):
|
||||
emit_signal("network_status_changed", response_code)
|
||||
|
||||
|
||||
func _on_VerifyAgainTimer_timeout():
|
||||
request(server_to_test)
|
14
addons/admob/src/core/components/ad_format/AdFormat.tscn
Normal file
14
addons/admob/src/core/components/ad_format/AdFormat.tscn
Normal file
@ -0,0 +1,14 @@
|
||||
[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_right = 500.0
|
||||
margin_bottom = 60.0
|
23
addons/admob/src/core/components/ad_format/BannerAdFormat.gd
Normal file
23
addons/admob/src/core/components/ad_format/BannerAdFormat.gd
Normal file
@ -0,0 +1,23 @@
|
||||
tool
|
||||
extends VBoxContainer
|
||||
onready var AdMobEditor : Control = find_parent("AdMobEditor")
|
||||
|
||||
func _ready():
|
||||
$RespectSafeArea.connect("value_changed", self, "_on_RespectSafeArea_value_changed")
|
||||
|
||||
$BannerSizeHBoxContainer/BannerSize.selected = AdMobEditor.AdMobSettings.BANNER_SIZE.find(AdMobEditor.AdMobSettings.config.banner.size)
|
||||
$RespectSafeArea.pressed = AdMobEditor.AdMobSettings.config.banner.respect_safe_area
|
||||
$BannerShowInstantly.pressed = AdMobEditor.AdMobSettings.config.banner.show_instantly
|
||||
$BannerOnTop.pressed = AdMobEditor.AdMobSettings.config.banner.position
|
||||
|
||||
func _on_BannerSize_item_selected(index):
|
||||
AdMobEditor.AdMobSettings.config.banner.size = AdMobEditor.AdMobSettings.BANNER_SIZE[index]
|
||||
|
||||
func _on_BannerShowInstantly_pressed():
|
||||
AdMobEditor.AdMobSettings.config.banner.show_instantly = $BannerShowInstantly.pressed#
|
||||
|
||||
func _on_BannerOnTop_pressed():
|
||||
AdMobEditor.AdMobSettings.config.banner.position = int($BannerOnTop.pressed)
|
||||
|
||||
func _on_RespectSafeArea_value_changed(value : bool):
|
||||
AdMobEditor.AdMobSettings.config.banner.respect_safe_area = value
|
@ -0,0 +1,86 @@
|
||||
[gd_scene load_steps=4 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]
|
||||
[ext_resource path="res://addons/admob/src/core/components/ad_format/RespectSafeArea.gd" type="Script" id=3]
|
||||
|
||||
[node name="BannerAdFormat" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="BannerSizeHBoxContainer" type="HBoxContainer" parent="." index="0"]
|
||||
margin_right = 500.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="RespectSafeArea" type="CheckBox" parent="." index="1"]
|
||||
margin_top = 24.0
|
||||
margin_right = 500.0
|
||||
margin_bottom = 48.0
|
||||
pressed = true
|
||||
text = "Respect Safe Area (RECOMMEND TRUE)"
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="ConfirmationDialog" type="ConfirmationDialog" parent="RespectSafeArea" index="0"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -250.0
|
||||
margin_top = -114.0
|
||||
margin_right = 250.0
|
||||
margin_bottom = 114.0
|
||||
window_title = "!!!WARNING!!!"
|
||||
dialog_text = "IT'S NOT RECOMMENDED LEAVE THIS AS FALSE
|
||||
|
||||
According to Google AdMob documentation for iOS: Banner ads must be placed in the \"Safe Area\" to avoid being obscured by rounded corners, sensor housing, and the Home indicator.
|
||||
|
||||
Read here: https://developers.google.com/admob/ios/x-ad-rendering"
|
||||
dialog_autowrap = true
|
||||
|
||||
[node name="BannerShowInstantly" type="CheckBox" parent="." index="2"]
|
||||
margin_top = 52.0
|
||||
margin_right = 500.0
|
||||
margin_bottom = 76.0
|
||||
pressed = true
|
||||
text = "Show Banner Instantly"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="BannerOnTop" type="CheckBox" parent="." index="3"]
|
||||
margin_top = 80.0
|
||||
margin_right = 500.0
|
||||
margin_bottom = 104.0
|
||||
text = "Banner On Top"
|
||||
|
||||
[node name="UnitIds" parent="." index="4"]
|
||||
margin_top = 108.0
|
||||
margin_bottom = 168.0
|
||||
|
||||
[connection signal="item_selected" from="BannerSizeHBoxContainer/BannerSize" to="." method="_on_BannerSize_item_selected"]
|
||||
[connection signal="pressed" from="RespectSafeArea" to="RespectSafeArea" method="_on_RespectSafeArea_pressed"]
|
||||
[connection signal="confirmed" from="RespectSafeArea/ConfirmationDialog" to="RespectSafeArea" method="_on_ConfirmationDialog_confirmed"]
|
||||
[connection signal="pressed" from="BannerShowInstantly" to="." method="_on_BannerShowInstantly_pressed"]
|
||||
[connection signal="pressed" from="BannerOnTop" to="." method="_on_BannerOnTop_pressed"]
|
@ -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 )]
|
@ -0,0 +1,17 @@
|
||||
tool
|
||||
extends CheckBox
|
||||
|
||||
signal value_changed(value)
|
||||
|
||||
|
||||
func _on_ConfirmationDialog_confirmed():
|
||||
pressed = false
|
||||
emit_signal("value_changed", pressed)
|
||||
|
||||
|
||||
func _on_RespectSafeArea_pressed():
|
||||
if not pressed:
|
||||
pressed = true
|
||||
$ConfirmationDialog.show()
|
||||
else:
|
||||
emit_signal("value_changed", pressed)
|
@ -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 )]
|
@ -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 )]
|
@ -0,0 +1,44 @@
|
||||
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)
|
||||
|
||||
func _ready():
|
||||
for operational_system in $OperationalSystemTabContainer.get_children():
|
||||
for unit_name in (AdMobEditor.AdMobSettings.config[ad_format_name].unit_ids[operational_system.name] as Dictionary):
|
||||
var unit_id = AdMobEditor.AdMobSettings.config[ad_format_name].unit_ids[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):
|
||||
instance_ad_unit(system, true)
|
||||
|
||||
|
||||
func add_ad_unit(operational_system : String, name_value: String, id_value : String):
|
||||
AdMobEditor.AdMobSettings.config[ad_format_name].unit_ids[operational_system][name_value] = id_value
|
||||
|
||||
func remove_ad_unit(operational_system : String, name_value: String):
|
||||
AdMobEditor.AdMobSettings.config[ad_format_name].unit_ids[operational_system].erase(name_value)
|
||||
AdMobEditor.AdMobSettings.save_config()
|
||||
|
||||
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
|
@ -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 = 35.0
|
||||
margin_right = 58.0
|
||||
margin_bottom = 49.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 = 84.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
|
@ -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"
|
@ -0,0 +1,75 @@
|
||||
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 _ready():
|
||||
if get_index() == 0:
|
||||
$GridContainer/RemoveButton.disabled = true
|
||||
|
||||
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():
|
||||
if ad_unit.get_index() != 0: 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:
|
||||
if ad_unit.get_index() != 0: ad_unit.get_node("GridContainer/RemoveButton").disabled = false
|
||||
ad_unit.get_node("GridContainer/EditButton").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
|
@ -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 = "<insert-name>"
|
||||
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 = "<insert-id>"
|
||||
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"]
|
202
addons/admob/src/singletons/AdMobSingleton.gd
Normal file
202
addons/admob/src/singletons/AdMobSingleton.gd
Normal file
@ -0,0 +1,202 @@
|
||||
extends Node
|
||||
|
||||
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_clicked()
|
||||
signal interstitial_closed()
|
||||
signal interstitial_recorded_impression()
|
||||
|
||||
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_clicked()
|
||||
signal rewarded_ad_closed()
|
||||
signal rewarded_ad_recorded_impression()
|
||||
|
||||
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_clicked()
|
||||
signal rewarded_interstitial_ad_closed()
|
||||
signal rewarded_interstitial_ad_recorded_impression()
|
||||
|
||||
signal user_earned_rewarded(currency, amount)
|
||||
|
||||
var AdMobSettings = preload("res://addons/admob/src/utils/AdMobSettings.gd").new()
|
||||
onready var config = AdMobSettings.config
|
||||
var _plugin : Object
|
||||
|
||||
func _ready() -> void:
|
||||
if config.general.is_enabled:
|
||||
if (Engine.has_singleton("AdMob")):
|
||||
_plugin = Engine.get_singleton("AdMob")
|
||||
initialize()
|
||||
_connect_signals()
|
||||
|
||||
func get_is_initialized() -> bool:
|
||||
if _plugin:
|
||||
return _plugin.get_is_initialized()
|
||||
return false
|
||||
|
||||
func initialize() -> void:
|
||||
if _plugin:
|
||||
var is_release : bool = OS.has_feature("release")
|
||||
|
||||
var is_debug_on_release : bool = config.debug.is_debug_on_release
|
||||
|
||||
var is_real : bool = false
|
||||
var is_test_europe_user_consent : bool = config.debug.is_test_europe_user_consent
|
||||
|
||||
if is_release:
|
||||
is_real = true
|
||||
is_test_europe_user_consent = false
|
||||
|
||||
if is_debug_on_release:
|
||||
is_real = config.debug.is_real
|
||||
is_test_europe_user_consent = config.debug.is_test_europe_user_consent
|
||||
|
||||
_plugin.initialize(config.general.is_for_child_directed_treatment, config.general.max_ad_content_rating, is_real, is_test_europe_user_consent)
|
||||
|
||||
|
||||
|
||||
|
||||
func _connect_signals() -> void:
|
||||
_plugin.connect("initialization_complete", self, "_on_AdMob_initialization_complete")
|
||||
|
||||
_plugin.connect("consent_form_dismissed", self, "_on_AdMob_consent_form_dismissed")
|
||||
_plugin.connect("consent_status_changed", self, "_on_AdMob_consent_status_changed")
|
||||
_plugin.connect("consent_form_load_failure", self, "_on_AdMob_consent_form_load_failure")
|
||||
_plugin.connect("consent_info_update_success", self, "_on_AdMob_consent_info_update_success")
|
||||
_plugin.connect("consent_info_update_failure", self, "_on_AdMob_consent_info_update_failure")
|
||||
|
||||
_plugin.connect("banner_loaded", self, "_on_AdMob_banner_loaded")
|
||||
_plugin.connect("banner_failed_to_load", self, "_on_AdMob_banner_failed_to_load")
|
||||
_plugin.connect("banner_opened", self, "_on_AdMob_banner_opened")
|
||||
_plugin.connect("banner_clicked", self, "_on_AdMob_banner_clicked")
|
||||
_plugin.connect("banner_closed", self, "_on_AdMob_banner_closed")
|
||||
_plugin.connect("banner_recorded_impression", self, "_on_AdMob_banner_recorded_impression")
|
||||
_plugin.connect("banner_destroyed", self, "_on_AdMob_banner_destroyed")
|
||||
|
||||
_plugin.connect("interstitial_failed_to_load", self, "_on_AdMob_interstitial_failed_to_load")
|
||||
_plugin.connect("interstitial_loaded", self, "_on_AdMob_interstitial_loaded")
|
||||
_plugin.connect("interstitial_failed_to_show", self, "_on_AdMob_interstitial_failed_to_show")
|
||||
_plugin.connect("interstitial_opened", self, "_on_AdMob_interstitial_opened")
|
||||
_plugin.connect("interstitial_clicked", self, "_on_AdMob_interstitial_clicked")
|
||||
_plugin.connect("interstitial_closed", self, "_on_AdMob_interstitial_closed")
|
||||
_plugin.connect("interstitial_recorded_impression", self, "_on_AdMob_interstitial_recorded_impression")
|
||||
|
||||
_plugin.connect("rewarded_ad_failed_to_load", self, "_on_AdMob_rewarded_ad_failed_to_load")
|
||||
_plugin.connect("rewarded_ad_loaded", self, "_on_AdMob_rewarded_ad_loaded")
|
||||
_plugin.connect("rewarded_ad_failed_to_show", self, "_on_AdMob_rewarded_ad_failed_to_show")
|
||||
_plugin.connect("rewarded_ad_opened", self, "_on_AdMob_rewarded_ad_opened")
|
||||
_plugin.connect("rewarded_ad_clicked", self, "_on_AdMob_rewarded_ad_clicked")
|
||||
_plugin.connect("rewarded_ad_closed", self, "_on_AdMob_rewarded_ad_closed")
|
||||
_plugin.connect("rewarded_ad_recorded_impression", self, "_on_AdMob_rewarded_ad_recorded_impression")
|
||||
|
||||
_plugin.connect("rewarded_interstitial_ad_failed_to_load", self, "_on_AdMob_rewarded_interstitial_ad_failed_to_load")
|
||||
_plugin.connect("rewarded_interstitial_ad_loaded", self, "_on_AdMob_rewarded_interstitial_ad_loaded")
|
||||
_plugin.connect("rewarded_interstitial_ad_failed_to_show", self, "_on_AdMob_rewarded_interstitial_ad_failed_to_show")
|
||||
_plugin.connect("rewarded_interstitial_ad_opened", self, "_on_AdMob_rewarded_interstitial_ad_opened")
|
||||
_plugin.connect("rewarded_interstitial_ad_clicked", self, "_on_AdMob_rewarded_interstitial_ad_clicked")
|
||||
_plugin.connect("rewarded_interstitial_ad_closed", self, "_on_AdMob_rewarded_interstitial_ad_closed")
|
||||
_plugin.connect("rewarded_interstitial_ad_recorded_impression", self, "_on_AdMob_rewarded_interstitial_ad_recorded_impression")
|
||||
|
||||
_plugin.connect("user_earned_rewarded", self, "_on_AdMob_user_earned_rewarded")
|
||||
|
||||
|
||||
func _on_AdMob_initialization_complete(status : int, adapter_name : String) -> void:
|
||||
emit_signal("initialization_complete", status, adapter_name)
|
||||
|
||||
func _on_AdMob_consent_form_dismissed() -> void:
|
||||
emit_signal("consent_form_dismissed")
|
||||
func _on_AdMob_consent_status_changed(consent_status_message : String) -> void:
|
||||
emit_signal("consent_status_changed", consent_status_message)
|
||||
func _on_AdMob_consent_form_load_failure(error_code : int, error_message: String) -> void:
|
||||
emit_signal("consent_form_load_failure", error_code, error_message)
|
||||
func _on_AdMob_consent_info_update_success(consent_status_message : String) -> void:
|
||||
emit_signal("consent_info_update_success", consent_status_message)
|
||||
func _on_AdMob_consent_info_update_failure(error_code : int, error_message : String) -> void:
|
||||
emit_signal("consent_info_update_failure", error_code, error_message)
|
||||
|
||||
func _on_AdMob_banner_loaded() -> void:
|
||||
emit_signal("banner_loaded")
|
||||
func _on_AdMob_banner_failed_to_load(error_code : int) -> void:
|
||||
emit_signal("banner_failed_to_load", error_code)
|
||||
func _on_AdMob_banner_opened() -> void:
|
||||
emit_signal("banner_loaded")
|
||||
func _on_AdMob_banner_clicked() -> void:
|
||||
emit_signal("banner_clicked")
|
||||
func _on_AdMob_banner_closed() -> void:
|
||||
emit_signal("banner_closed")
|
||||
func _on_AdMob_banner_recorded_impression() -> void:
|
||||
emit_signal("banner_recorded_impression")
|
||||
func _on_AdMob_banner_destroyed() -> void:
|
||||
emit_signal("banner_destroyed")
|
||||
|
||||
func _on_AdMob_interstitial_failed_to_load(error_code : int) -> void:
|
||||
emit_signal("interstitial_failed_to_load", error_code)
|
||||
func _on_AdMob_interstitial_loaded() -> void:
|
||||
emit_signal("interstitial_loaded")
|
||||
func _on_AdMob_interstitial_failed_to_show(error_code : int) -> void:
|
||||
emit_signal("interstitial_failed_to_show", error_code)
|
||||
func _on_AdMob_interstitial_opened() -> void:
|
||||
emit_signal("interstitial_opened")
|
||||
func _on_AdMob_interstitial_clicked() -> void:
|
||||
emit_signal("interstitial_clicked")
|
||||
func _on_AdMob_interstitial_closed() -> void:
|
||||
emit_signal("interstitial_closed")
|
||||
func _on_AdMob_interstitial_recorded_impression() -> void:
|
||||
emit_signal("interstitial_recorded_impression")
|
||||
|
||||
func _on_AdMob_rewarded_ad_failed_to_load(error_code : int) -> void:
|
||||
emit_signal("rewarded_ad_failed_to_load", error_code)
|
||||
func _on_AdMob_rewarded_ad_loaded() -> void:
|
||||
emit_signal("rewarded_ad_loaded")
|
||||
func _on_AdMob_rewarded_ad_failed_to_show(error_code : int) -> void:
|
||||
emit_signal("rewarded_ad_failed_to_show", error_code)
|
||||
func _on_AdMob_rewarded_ad_opened() -> void:
|
||||
emit_signal("rewarded_ad_opened")
|
||||
func _on_AdMob_rewarded_ad_clicked() -> void:
|
||||
emit_signal("rewarded_ad_clicked")
|
||||
func _on_AdMob_rewarded_ad_closed() -> void:
|
||||
emit_signal("rewarded_ad_closed")
|
||||
func _on_AdMob_rewarded_ad_recorded_impression() -> void:
|
||||
emit_signal("rewarded_ad_recorded_impression")
|
||||
|
||||
func _on_AdMob_rewarded_interstitial_ad_failed_to_load(error_code : int) -> void:
|
||||
emit_signal("rewarded_interstitial_ad_failed_to_load", error_code)
|
||||
func _on_AdMob_rewarded_interstitial_ad_loaded() -> void:
|
||||
emit_signal("rewarded_interstitial_ad_loaded")
|
||||
func _on_AdMob_rewarded_interstitial_ad_failed_to_show(error_code : int) -> void:
|
||||
emit_signal("rewarded_interstitial_ad_failed_to_show", error_code)
|
||||
func _on_AdMob_rewarded_interstitial_ad_opened() -> void:
|
||||
emit_signal("rewarded_interstitial_ad_opened")
|
||||
func _on_AdMob_rewarded_interstitial_ad_clicked() -> void:
|
||||
emit_signal("rewarded_interstitial_ad_clicked")
|
||||
func _on_AdMob_rewarded_interstitial_ad_closed() -> void:
|
||||
emit_signal("rewarded_interstitial_ad_closed")
|
||||
func _on_AdMob_rewarded_interstitial_ad_recorded_impression() -> void:
|
||||
emit_signal("rewarded_interstitial_ad_recorded_impression")
|
||||
|
||||
func _on_AdMob_user_earned_rewarded(currency : String, amount : int) -> void:
|
||||
emit_signal("user_earned_rewarded", currency, amount)
|
106
addons/admob/src/singletons/MobileAds.gd
Normal file
106
addons/admob/src/singletons/MobileAds.gd
Normal file
@ -0,0 +1,106 @@
|
||||
extends "res://addons/admob/src/singletons/AdMobSingleton.gd"
|
||||
|
||||
func _ready() -> void:
|
||||
# warning-ignore:return_value_discarded
|
||||
get_tree().connect("screen_resized", self, "_on_get_tree_resized")
|
||||
|
||||
|
||||
func load_banner(ad_unit_name : String = "standard") -> void:
|
||||
if _plugin:
|
||||
_plugin.load_banner(config.banner.unit_ids[OS.get_name()][ad_unit_name], config.banner.position, config.banner.size, config.banner.show_instantly, config.banner.respect_safe_area)
|
||||
|
||||
func load_interstitial(ad_unit_name : String = "standard") -> void:
|
||||
if _plugin:
|
||||
_plugin.load_interstitial(config.interstitial.unit_ids[OS.get_name()][ad_unit_name])
|
||||
|
||||
func load_rewarded(ad_unit_name : String = "standard") -> void:
|
||||
if _plugin:
|
||||
_plugin.load_rewarded(config.rewarded.unit_ids[OS.get_name()][ad_unit_name])
|
||||
|
||||
func load_rewarded_interstitial(ad_unit_name : String = "standard") -> void:
|
||||
if _plugin:
|
||||
_plugin.load_rewarded_interstitial(config.rewarded_interstitial.unit_ids[OS.get_name()][ad_unit_name])
|
||||
|
||||
func destroy_banner() -> void:
|
||||
if _plugin:
|
||||
_plugin.destroy_banner()
|
||||
|
||||
func show_banner() -> void:
|
||||
if _plugin:
|
||||
_plugin.show_banner()
|
||||
|
||||
func hide_banner() -> void:
|
||||
if _plugin:
|
||||
_plugin.hide_banner()
|
||||
|
||||
func show_interstitial() -> void:
|
||||
if _plugin:
|
||||
_plugin.show_interstitial()
|
||||
|
||||
func show_rewarded() -> void:
|
||||
if _plugin:
|
||||
_plugin.show_rewarded()
|
||||
|
||||
func show_rewarded_interstitial() -> void:
|
||||
if _plugin:
|
||||
_plugin.show_rewarded_interstitial()
|
||||
|
||||
func request_user_consent() -> void:
|
||||
if _plugin:
|
||||
_plugin.request_user_consent()
|
||||
|
||||
func reset_consent_state(will_request_user_consent := false) -> void:
|
||||
if _plugin:
|
||||
_plugin.reset_consent_state()
|
||||
|
||||
func get_banner_width() -> int:
|
||||
if _plugin:
|
||||
return _plugin.get_banner_width()
|
||||
return 0
|
||||
|
||||
func get_banner_width_in_pixels() -> int:
|
||||
if _plugin:
|
||||
return _plugin.get_banner_width_in_pixels()
|
||||
return 0
|
||||
|
||||
func get_banner_height() -> int:
|
||||
if _plugin:
|
||||
return _plugin.get_banner_height()
|
||||
return 0
|
||||
|
||||
func get_banner_height_in_pixels() -> int:
|
||||
if _plugin:
|
||||
return _plugin.get_banner_height_in_pixels()
|
||||
return 0
|
||||
|
||||
func get_is_banner_loaded() -> bool:
|
||||
if _plugin:
|
||||
return _plugin.get_is_banner_loaded()
|
||||
return false
|
||||
|
||||
func get_is_interstitial_loaded() -> bool:
|
||||
if _plugin:
|
||||
return _plugin.get_is_interstitial_loaded()
|
||||
return false
|
||||
|
||||
func get_is_rewarded_loaded() -> bool:
|
||||
if _plugin:
|
||||
return _plugin.get_is_rewarded_loaded()
|
||||
return false
|
||||
|
||||
func get_is_rewarded_interstitial_loaded() -> bool:
|
||||
if _plugin:
|
||||
return _plugin.get_is_rewarded_interstitial_loaded()
|
||||
return false
|
||||
|
||||
func _on_get_tree_resized() -> void:
|
||||
if _plugin:
|
||||
if get_is_banner_loaded() and config.banner.size == "SMART_BANNER":
|
||||
load_banner()
|
||||
if get_is_interstitial_loaded(): #verify if interstitial and rewarded is loaded because the only reason to load again now is to resize
|
||||
load_interstitial()
|
||||
if get_is_rewarded_loaded():
|
||||
load_rewarded()
|
||||
if get_is_rewarded_interstitial_loaded():
|
||||
load_rewarded_interstitial()
|
||||
|
8
addons/admob/src/utils/AdMobGlobals.gd
Normal file
8
addons/admob/src/utils/AdMobGlobals.gd
Normal file
@ -0,0 +1,8 @@
|
||||
const SAVE_ADMOB_GLOBALS_PATH := "user://admob_globals.tres"
|
||||
|
||||
|
||||
static func get_plugin_version() -> String:
|
||||
var plugin_config_file := ConfigFile.new()
|
||||
plugin_config_file.load("res://addons/admob/plugin.cfg")
|
||||
var version : String = plugin_config_file.get_value("plugin", "version")
|
||||
return version
|
4
addons/admob/src/utils/AdMobLoad.gd
Normal file
4
addons/admob/src/utils/AdMobLoad.gd
Normal file
@ -0,0 +1,4 @@
|
||||
static func load_config(p_path) -> Dictionary:
|
||||
if ProjectSettings.has_setting(p_path):
|
||||
return ProjectSettings.get_setting(p_path)
|
||||
return {}
|
3
addons/admob/src/utils/AdMobSave.gd
Normal file
3
addons/admob/src/utils/AdMobSave.gd
Normal file
@ -0,0 +1,3 @@
|
||||
static func save_config(p_path : String, p_config : Dictionary) -> void:
|
||||
ProjectSettings.set_setting(p_path, p_config)
|
||||
ProjectSettings.save()
|
103
addons/admob/src/utils/AdMobSettings.gd
Normal file
103
addons/admob/src/utils/AdMobSettings.gd
Normal file
@ -0,0 +1,103 @@
|
||||
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 {BOTTOM, TOP}
|
||||
|
||||
|
||||
var config : Dictionary = {
|
||||
"general" : {
|
||||
"is_enabled": true,
|
||||
"is_for_child_directed_treatment": false,
|
||||
"max_ad_content_rating": "PG"
|
||||
},
|
||||
"debug" : {
|
||||
"is_debug_on_release": false,
|
||||
"is_real": true,
|
||||
"is_test_europe_user_consent": false
|
||||
},
|
||||
"banner": {
|
||||
"position": POSITION.TOP,
|
||||
"respect_safe_area" : true,
|
||||
"show_instantly": true,
|
||||
"size": BANNER_SIZE[0],
|
||||
"unit_ids" : {
|
||||
"Android": {
|
||||
"standard" : "ca-app-pub-3940256099942544/6300978111",
|
||||
},
|
||||
"iOS": {
|
||||
"standard" : "ca-app-pub-3940256099942544/2934735716"
|
||||
}
|
||||
}
|
||||
},
|
||||
"interstitial": {
|
||||
"unit_ids" : {
|
||||
"Android": {
|
||||
"standard" : "ca-app-pub-3940256099942544/1033173712"
|
||||
},
|
||||
"iOS": {
|
||||
"standard" : "ca-app-pub-3940256099942544/4411468910"
|
||||
}
|
||||
}
|
||||
},
|
||||
"rewarded": {
|
||||
"unit_ids" : {
|
||||
"Android": {
|
||||
"standard" : "ca-app-pub-3940256099942544/5224354917"
|
||||
},
|
||||
"iOS": {
|
||||
"standard" : "ca-app-pub-3940256099942544/1712485313"
|
||||
}
|
||||
}
|
||||
},
|
||||
"rewarded_interstitial": {
|
||||
"unit_ids" : {
|
||||
"Android": {
|
||||
"standard" : "ca-app-pub-3940256099942544/5354046379"
|
||||
},
|
||||
"iOS": {
|
||||
"standard" : "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)
|
||||
if Engine.editor_hint:
|
||||
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('')
|
Reference in New Issue
Block a user