diff --git a/.import/.gdignore b/.import/.gdignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.import/.gdignore @@ -0,0 +1 @@ + diff --git a/.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.md5 b/.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.md5 new file mode 100644 index 0000000..c6c11c2 --- /dev/null +++ b/.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.md5 @@ -0,0 +1,3 @@ +source_md5="8b2693d49a529f0c49e9fc34e83d3aaa" +dest_md5="0af5e2d86183443cbd8f6d3196cda481" + diff --git a/.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.stex b/.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.stex new file mode 100644 index 0000000..60b1a8f Binary files /dev/null and b/.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.stex differ diff --git a/.import/Tank Town V2.png-9a71ef29ce758f006bf4551e5170da54.md5 b/.import/Tank Town V2.png-9a71ef29ce758f006bf4551e5170da54.md5 new file mode 100644 index 0000000..e3c4a7b --- /dev/null +++ b/.import/Tank Town V2.png-9a71ef29ce758f006bf4551e5170da54.md5 @@ -0,0 +1,3 @@ +source_md5="8b2693d49a529f0c49e9fc34e83d3aaa" +dest_md5="bf817dc874b11b0dfcefaf8c34d3c307" + diff --git a/.import/Tank Town V2.png-9a71ef29ce758f006bf4551e5170da54.stex b/.import/Tank Town V2.png-9a71ef29ce758f006bf4551e5170da54.stex new file mode 100644 index 0000000..d3f645a Binary files /dev/null and b/.import/Tank Town V2.png-9a71ef29ce758f006bf4551e5170da54.stex differ diff --git a/.import/android.png-fb2caea48032eea3d74244daf04c3454.md5 b/.import/android.png-fb2caea48032eea3d74244daf04c3454.md5 new file mode 100644 index 0000000..8d3164e --- /dev/null +++ b/.import/android.png-fb2caea48032eea3d74244daf04c3454.md5 @@ -0,0 +1,3 @@ +source_md5="f4b4f85907b184d9e397a6ff63f6ce72" +dest_md5="5be099a36bdf2c27d567c38fe51f4f9f" + diff --git a/.import/android.png-fb2caea48032eea3d74244daf04c3454.stex b/.import/android.png-fb2caea48032eea3d74244daf04c3454.stex new file mode 100644 index 0000000..2159a58 Binary files /dev/null and b/.import/android.png-fb2caea48032eea3d74244daf04c3454.stex differ diff --git a/.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.md5 b/.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.md5 new file mode 100644 index 0000000..23eb0d5 --- /dev/null +++ b/.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.md5 @@ -0,0 +1,3 @@ +source_md5="e34f6838dc85a9800d72ca02e5290d16" +dest_md5="67b96e815e9f9092154bc9009dbb8123" + diff --git a/.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.stex b/.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.stex new file mode 100644 index 0000000..7262e28 Binary files /dev/null and b/.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.stex differ diff --git a/.import/enemy.png-f7d9f81714867a24a08e299bb600e611.md5 b/.import/enemy.png-f7d9f81714867a24a08e299bb600e611.md5 new file mode 100644 index 0000000..79a6a67 --- /dev/null +++ b/.import/enemy.png-f7d9f81714867a24a08e299bb600e611.md5 @@ -0,0 +1,3 @@ +source_md5="d84b20a4723ca8ec5545c2c99699474a" +dest_md5="dd3176c4cc91f48dded2f76c041b4ca5" + diff --git a/.import/enemy.png-f7d9f81714867a24a08e299bb600e611.stex b/.import/enemy.png-f7d9f81714867a24a08e299bb600e611.stex new file mode 100644 index 0000000..2babfdd Binary files /dev/null and b/.import/enemy.png-f7d9f81714867a24a08e299bb600e611.stex differ diff --git a/.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.md5 b/.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.md5 new file mode 100644 index 0000000..c9eabd4 --- /dev/null +++ b/.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.md5 @@ -0,0 +1,3 @@ +source_md5="2159e5e3c0a3f08caaa4653955b12279" +dest_md5="0a61b50f5151e2a0e094e43b57b4c35b" + diff --git a/.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.stex b/.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.stex new file mode 100644 index 0000000..45e50d9 Binary files /dev/null and b/.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.stex differ diff --git a/.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.md5 b/.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.md5 new file mode 100644 index 0000000..90abfdc --- /dev/null +++ b/.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.md5 @@ -0,0 +1,3 @@ +source_md5="c15584810ad94ea7ef679c58fe0e1858" +dest_md5="00ee2785af01b9527f444ddc1879fedd" + diff --git a/.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.stex b/.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.stex new file mode 100644 index 0000000..22cc2c1 Binary files /dev/null and b/.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.stex differ diff --git a/.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.md5 b/.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.md5 new file mode 100644 index 0000000..ca5d2f5 --- /dev/null +++ b/.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.md5 @@ -0,0 +1,3 @@ +source_md5="50e28167ca4d52622270ac728d424d61" +dest_md5="88e8c42bc4e81ab7ea3958e3c9e48da2" + diff --git a/.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.stex b/.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.stex new file mode 100644 index 0000000..30ae137 Binary files /dev/null and b/.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.stex differ diff --git a/.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.md5 b/.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.md5 new file mode 100644 index 0000000..fa6d722 --- /dev/null +++ b/.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.md5 @@ -0,0 +1,3 @@ +source_md5="9d0cd33193aad3daec08e68d2ba0471c" +dest_md5="b8f17e81423910c62384ad8b935cff4f" + diff --git a/.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.stex b/.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.stex new file mode 100644 index 0000000..4597555 Binary files /dev/null and b/.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.stex differ diff --git a/.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.md5 b/.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.md5 new file mode 100644 index 0000000..489e2f4 --- /dev/null +++ b/.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.md5 @@ -0,0 +1,3 @@ +source_md5="161febcc2c64bbfa259a57b89434b8ce" +dest_md5="c76956748bead53fe1f1f1929cf37234" + diff --git a/.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.stex b/.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.stex new file mode 100644 index 0000000..8587eb9 Binary files /dev/null and b/.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.stex differ diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 new file mode 100644 index 0000000..5328bc7 --- /dev/null +++ b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5 @@ -0,0 +1,3 @@ +source_md5="47313fa4c47a9963fddd764e1ec6e4a8" +dest_md5="26ea799ea0a3da9e753b3ebe822e0570" + diff --git a/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex new file mode 100644 index 0000000..71f6913 Binary files /dev/null and b/.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex differ diff --git a/.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.md5 b/.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.md5 new file mode 100644 index 0000000..a58b82a --- /dev/null +++ b/.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.md5 @@ -0,0 +1,3 @@ +source_md5="163696855a2264825c4b3f1c60271d57" +dest_md5="d867d38ba9da7a92b66f4ef8d20883e8" + diff --git a/.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.stex b/.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.stex new file mode 100644 index 0000000..21782b2 Binary files /dev/null and b/.import/ios.png-09946c77d84d877ee235a3ef7222fc0c.stex differ diff --git a/.import/music.ogg-6849ed60109f01916f243ace862e95fb.md5 b/.import/music.ogg-6849ed60109f01916f243ace862e95fb.md5 new file mode 100644 index 0000000..209f3f3 --- /dev/null +++ b/.import/music.ogg-6849ed60109f01916f243ace862e95fb.md5 @@ -0,0 +1,3 @@ +source_md5="932b771ad808fc298f615227d050ec43" +dest_md5="deaae9245814d83fa2b904287e449d43" + diff --git a/.import/music.ogg-6849ed60109f01916f243ace862e95fb.oggstr b/.import/music.ogg-6849ed60109f01916f243ace862e95fb.oggstr new file mode 100644 index 0000000..d464634 Binary files /dev/null and b/.import/music.ogg-6849ed60109f01916f243ace862e95fb.oggstr differ diff --git a/.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.md5 b/.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.md5 new file mode 100644 index 0000000..be583a5 --- /dev/null +++ b/.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.md5 @@ -0,0 +1,3 @@ +source_md5="5ba87031cb02945fb9ed3ccdbd282bbc" +dest_md5="b31c147db95dc18ff0f8960e532e993a" + diff --git a/.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.stex b/.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.stex new file mode 100644 index 0000000..4828479 Binary files /dev/null and b/.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.stex differ diff --git a/.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.md5 b/.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.md5 new file mode 100644 index 0000000..9c22c74 --- /dev/null +++ b/.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.md5 @@ -0,0 +1,3 @@ +source_md5="c2ff3ee413d4d2395dc48b39ec2f3a6e" +dest_md5="b1647a55dc19646db9564c1312414faa" + diff --git a/.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.stex b/.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.stex new file mode 100644 index 0000000..f9e9fc8 Binary files /dev/null and b/.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.stex differ diff --git a/Bullet.tscn b/Bullet.tscn new file mode 100644 index 0000000..9039c29 --- /dev/null +++ b/Bullet.tscn @@ -0,0 +1,55 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://box.png" type="Texture" id=1] + +[sub_resource type="GDScript" id=3] +resource_name = "Bullet" +script/source = "extends KinematicBody2D + + +var velocity = Vector2(0,-1) +var speed = 300 + +# Declare member variables here. Examples: +# var a = 2 +# var b = \"text\" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + +func _physics_process(delta): + + move_and_collide(velocity.normalized() * delta * speed) + pass + + +func _on_Area2D_area_entered(area): + if !area.is_in_group(\"Border\"): + queue_free() + pass # Replace with function body. +" + +[sub_resource type="RectangleShape2D" id=2] +extents = Vector2( 3.33333, 3.33333 ) + +[node name="Node2D" type="KinematicBody2D"] +scale = Vector2( 1.5, 1.5 ) +script = SubResource( 3 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 3.73522e-06, -3.41733e-06 ) +scale = Vector2( 1.1, 1.1 ) +shape = SubResource( 2 ) + +[node name="Area2D" type="Area2D" parent="." groups=["Bullet"]] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +position = Vector2( 5.96046e-08, -5.96046e-08 ) +shape = SubResource( 2 ) + +[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] diff --git a/Entity.tscn b/Entity.tscn new file mode 100644 index 0000000..66ee514 --- /dev/null +++ b/Entity.tscn @@ -0,0 +1,79 @@ +[gd_scene load_steps=6 format=2] + +[ext_resource path="res://enemy.png" type="Texture" id=1] +[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=2] + +[sub_resource type="GDScript" id=1] +script/source = "extends KinematicBody2D + +var velocity = Vector2(0,1) +var speed = 50 +signal on_Death + +# Called when the node enters the scene tree for the first time. +func _ready(): + var text = randi() % 4 + $Label.text = (text+1) as String + var Progressbars = get_tree().get_nodes_in_group(\"XP\") + for Progressbar in Progressbars: + Progressbar.connect(\"full_bar\", self, \"set_speed\") + pass # Replace with function body. + +func _physics_process(delta): + move_and_collide(velocity.normalized() * delta * speed) + pass + +func _on_Area2D_area_entered(area): + if area.is_in_group(\"Bullet\"): + var text = $Label.text as int + if text > 1: + $Label.text = (text-1) as String + else: + var value = 1 + emit_signal(\"on_Death\", value) + queue_free() + if area.is_in_group(\"Border\"): + get_tree().change_scene(\"res://GameOver.tscn\") + pass # Replace with function body. + +func set_speed(value): + speed += value +" + +[sub_resource type="RectangleShape2D" id=2] +extents = Vector2( 4, 4 ) + +[sub_resource type="DynamicFont" id=3] +size = 12 +font_data = ExtResource( 2 ) + +[node name="Node2D" type="KinematicBody2D" groups=["Enemy"]] +position = Vector2( 64, 64 ) +scale = Vector2( 12, 12 ) +script = SubResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +texture = ExtResource( 1 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +scale = Vector2( 0.9, 0.9 ) +shape = SubResource( 2 ) + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +shape = SubResource( 2 ) + +[node name="Label" type="Label" parent="."] +margin_left = -3.33333 +margin_top = -4.0 +margin_right = 8.66667 +margin_bottom = 10.0 +grow_horizontal = 2 +grow_vertical = 2 +rect_min_size = Vector2( 8, 8 ) +rect_scale = Vector2( 0.545, 0.639 ) +custom_fonts/font = SubResource( 3 ) +text = "1" + +[connection signal="area_entered" from="Area2D" to="." method="_on_Area2D_area_entered"] diff --git a/Export/Game.exe b/Export/Game.exe new file mode 100644 index 0000000..9d0305f Binary files /dev/null and b/Export/Game.exe differ diff --git a/Export/Game.pck b/Export/Game.pck new file mode 100644 index 0000000..2ea6d1a Binary files /dev/null and b/Export/Game.pck differ diff --git a/Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf b/Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf new file mode 100644 index 0000000..fc36630 Binary files /dev/null and b/Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf differ diff --git a/Font/super-legend-boy-font/misc/FSLA_NonCommercial_License-4726.html b/Font/super-legend-boy-font/misc/FSLA_NonCommercial_License-4726.html new file mode 100644 index 0000000..42c24e0 --- /dev/null +++ b/Font/super-legend-boy-font/misc/FSLA_NonCommercial_License-4726.html @@ -0,0 +1,63 @@ + + + +Font Software License Agreement - Non-Commercial + + +

Chequered Ink Ltd.

+

Font Software License Agreement - Non-Commercial


+

1. Definition of terms

+ + +

2. Eligibility and the agreement

+ + +

3. Scope and use

+ + +

4. Intellectual property

+ + +

5. Liability

+ + +

6. Termination

+ + +

7. Additional Terms Of Use

+ + + \ No newline at end of file diff --git a/Font/super-legend-boy-font/misc/Get Commercial License-cca5.url b/Font/super-legend-boy-font/misc/Get Commercial License-cca5.url new file mode 100644 index 0000000..c2f54e3 --- /dev/null +++ b/Font/super-legend-boy-font/misc/Get Commercial License-cca5.url @@ -0,0 +1,6 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +[InternetShortcut] +IDList= +URL=https://chequered.ink/font-license/ +HotKey=0 diff --git a/Game.gd b/Game.gd new file mode 100644 index 0000000..5175828 --- /dev/null +++ b/Game.gd @@ -0,0 +1,53 @@ +extends Node2D + + +const SlotClass = preload("res://Slot.gd") +var Panzer_Temp = preload("res://Panzer.tscn") +onready var game_slots = $VBoxContainer/PanzerSlots +var holding_item = null + +signal speed_shoot + +func _ready(): + for gam_slot in game_slots.get_children(): + gam_slot.connect("gui_input", self, "slot_gui_input", [gam_slot]) + + +func slot_gui_input(event: InputEvent, slot: SlotClass): + if event is InputEventMouseButton: + if event.button_index == BUTTON_LEFT && event.pressed: + if holding_item != null: + if!slot.Panzer: + slot.putIntoSlot(holding_item) + holding_item = null + else: + var temp_item = slot.Panzer + slot.pickFromSlot() + temp_item.global_position = event.global_position + slot.putIntoSlot(holding_item) + holding_item = temp_item + elif slot.Panzer: + holding_item = slot.Panzer + slot.pickFromSlot() + holding_item.global_position = get_global_mouse_position() + +func _input(event): + if holding_item: + holding_item.global_position = get_global_mouse_position() + pass + + +func _on_Panzer_pressed(): + if holding_item == null: + var Panzer = null + Panzer = Panzer_Temp.instance() + add_child(Panzer) + holding_item = Panzer + holding_item.global_position = get_global_mouse_position() + pass # Replace with function body. + + +func _on_Speed_pressed(): + var value = 0.5 + emit_signal("speed_shoot", value) + pass # Replace with function body. diff --git a/Game.tscn b/Game.tscn new file mode 100644 index 0000000..6998937 --- /dev/null +++ b/Game.tscn @@ -0,0 +1,204 @@ +[gd_scene load_steps=13 format=2] + +[ext_resource path="res://box.png" type="Texture" id=1] +[ext_resource path="res://Slot.gd" type="Script" id=2] +[ext_resource path="res://Game.gd" type="Script" id=3] +[ext_resource path="res://Spawner.gd" type="Script" id=4] +[ext_resource path="res://retrowave.png" type="Texture" id=5] +[ext_resource path="res://Font/super-legend-boy-font/SuperLegendBoy-4w8Y.ttf" type="DynamicFontData" id=6] +[ext_resource path="res://Overlay.tscn" type="PackedScene" id=7] + +[sub_resource type="TileSet" id=1] + +[sub_resource type="RectangleShape2D" id=4] +extents = Vector2( 288, 20 ) + +[sub_resource type="StyleBoxTexture" id=3] +texture = ExtResource( 1 ) +region_rect = Rect2( 0, 0, 8, 8 ) + +[sub_resource type="StyleBoxTexture" id=2] +texture = ExtResource( 1 ) +region_rect = Rect2( 0, 0, 8, 8 ) + +[sub_resource type="DynamicFont" id=5] +font_data = ExtResource( 6 ) + +[node name="Game" type="Node2D"] +script = ExtResource( 3 ) + +[node name="Sprite" type="Sprite" parent="."] +position = Vector2( 288, 592 ) +scale = Vector2( 0.463768, 0.5 ) +texture = ExtResource( 5 ) + +[node name="TileMap" type="TileMap" parent="."] +tile_set = SubResource( 1 ) +format = 1 + +[node name="Panel" type="Panel" parent="."] +margin_top = 760.0 +margin_right = 576.0 +margin_bottom = 800.0 +rect_min_size = Vector2( 575, 32 ) + +[node name="Area2D" type="Area2D" parent="Panel" groups=["Border"]] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Panel/Area2D"] +position = Vector2( 288, 20 ) +shape = SubResource( 4 ) + +[node name="Spawner" type="GridContainer" parent="."] +anchor_top = 1.0 +anchor_bottom = 1.0 +margin_top = -128.0 +margin_right = 575.0 +custom_constants/hseparation = 21 +columns = 4 + +[node name="Spawner 1" type="Panel" parent="Spawner"] +margin_right = 128.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +custom_styles/panel = SubResource( 3 ) +script = ExtResource( 4 ) + +[node name="Spawner 2" type="Panel" parent="Spawner"] +margin_left = 149.0 +margin_right = 277.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +custom_styles/panel = SubResource( 3 ) +script = ExtResource( 4 ) + +[node name="Spawner 3" type="Panel" parent="Spawner"] +margin_left = 298.0 +margin_right = 426.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +custom_styles/panel = SubResource( 3 ) +script = ExtResource( 4 ) + +[node name="Spawner 4" type="Panel" parent="Spawner"] +margin_left = 447.0 +margin_right = 575.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +custom_styles/panel = SubResource( 3 ) +script = ExtResource( 4 ) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +margin_top = 800.0 +margin_right = 575.0 +margin_bottom = 1200.0 + +[node name="PanzerSlots" type="GridContainer" parent="VBoxContainer"] +margin_right = 575.0 +margin_bottom = 266.0 +custom_constants/vseparation = 10 +custom_constants/hseparation = 21 +columns = 4 + +[node name="Slot 1" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_right = 128.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 2" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_left = 149.0 +margin_right = 277.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 3" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_left = 298.0 +margin_right = 426.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 4" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_left = 447.0 +margin_right = 575.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 5" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_top = 138.0 +margin_right = 128.0 +margin_bottom = 266.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 6" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_left = 149.0 +margin_top = 138.0 +margin_right = 277.0 +margin_bottom = 266.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 7" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_left = 298.0 +margin_top = 138.0 +margin_right = 426.0 +margin_bottom = 266.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="Slot 8" type="Panel" parent="VBoxContainer/PanzerSlots"] +margin_left = 447.0 +margin_top = 138.0 +margin_right = 575.0 +margin_bottom = 266.0 +rect_min_size = Vector2( 128, 128 ) +rect_pivot_offset = Vector2( 64, 64 ) +custom_styles/panel = SubResource( 2 ) +script = ExtResource( 2 ) + +[node name="ButtonGrid" type="GridContainer" parent="VBoxContainer"] +margin_top = 270.0 +margin_right = 575.0 +margin_bottom = 398.0 +columns = 4 + +[node name="Speed" type="Button" parent="VBoxContainer/ButtonGrid"] +margin_right = 128.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +custom_fonts/font = SubResource( 5 ) +text = "Speed" + +[node name="Panzer" type="Button" parent="VBoxContainer/ButtonGrid"] +margin_left = 132.0 +margin_right = 260.0 +margin_bottom = 128.0 +rect_min_size = Vector2( 128, 128 ) +custom_fonts/font = SubResource( 5 ) +text = "Panzer" + +[node name="Control" parent="." instance=ExtResource( 7 )] +anchor_right = 0.0 +anchor_bottom = 0.0 +margin_right = 575.0 +margin_bottom = 0.0 + +[connection signal="pressed" from="VBoxContainer/ButtonGrid/Speed" to="." method="_on_Speed_pressed"] +[connection signal="pressed" from="VBoxContainer/ButtonGrid/Panzer" to="." method="_on_Panzer_pressed"] diff --git a/GameOver.tscn b/GameOver.tscn new file mode 100644 index 0000000..5d16c95 --- /dev/null +++ b/GameOver.tscn @@ -0,0 +1,48 @@ +[gd_scene load_steps=2 format=2] + +[sub_resource type="GDScript" id=1] +script/source = "extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = \"text\" + + +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +#func _process(delta): +# pass + + +func _on_Button_pressed(): + get_tree().change_scene(\"res://Game.tscn\") + pass # Replace with function body. +" + +[node name="Control" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = SubResource( 1 ) + +[node name="VBoxContainer" type="VBoxContainer" parent="."] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -20.0 +margin_top = -20.0 +margin_right = 20.0 +margin_bottom = 20.0 + +[node name="Button" type="Button" parent="VBoxContainer"] +margin_right = 57.0 +margin_bottom = 20.0 +text = "Restart" +icon_align = 1 + +[connection signal="pressed" from="VBoxContainer/Button" to="." method="_on_Button_pressed"] diff --git a/Overlay.tscn b/Overlay.tscn new file mode 100644 index 0000000..33c8460 --- /dev/null +++ b/Overlay.tscn @@ -0,0 +1,59 @@ +[gd_scene load_steps=2 format=2] + +[sub_resource type="GDScript" id=1] +script/source = "extends Control + + +# Declare member variables here. Examples: +# var a = 2 +# var b = \"text\" + +onready var pBar = $CanvasLayer/ProgressBar + +signal full_bar + + +# Called when the node enters the scene tree for the first time. +func _ready(): + var Enemies = get_tree().get_nodes_in_group(\"Enemy\") + for Enemy in Enemies: + Enemy.connect(\"on_Death\", self, \"on_Death_listed\") + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta): + if pBar.value == pBar.max_value: + var value = 50 + emit_signal(\"full_bar\", value) + pBar.value = 0 + pBar.max_value += 10 + pass + +func on_Death_listed(value): + pBar.value += value +" + +[node name="Control" type="Control" groups=["XP"]] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_bottom = -1040.0 +grow_horizontal = 2 +grow_vertical = 2 +script = SubResource( 1 ) + +[node name="CanvasLayer" type="CanvasLayer" parent="."] + +[node name="ProgressBar" type="ProgressBar" parent="CanvasLayer"] +anchor_left = 0.5 +anchor_right = 0.5 +margin_left = -144.0 +margin_top = 48.0 +margin_right = 48.0 +margin_bottom = 62.0 +rect_scale = Vector2( 1.5, 1.5 ) +max_value = 10.0 + +[node name="Label" type="Label" parent="."] +margin_right = 184.0 +margin_bottom = 160.0 diff --git a/Panzer.tscn b/Panzer.tscn new file mode 100644 index 0000000..3556e79 --- /dev/null +++ b/Panzer.tscn @@ -0,0 +1,51 @@ +[gd_scene load_steps=3 format=2] + +[ext_resource path="res://assets/Tank Town V2.png" type="Texture" id=1] + +[sub_resource type="GDScript" id=1] +script/source = "extends Node2D + +var Time = 0 +const bulletPath = preload(\"res://Bullet.tscn\") +var speed = 2.5 +onready var GameNode + +func _ready(): + GameNode = find_parent(\"Game\") + GameNode.connect(\"speed_shoot\", self, \"set_shoot_speed\") + pass + +func _process(delta): + Time += delta + if Time > speed and get_parent() != GameNode: #wenn er nicht gehoben wird dann: + shoot() + Time = 0 + pass + +func shoot(): + var bullet = bulletPath.instance() + find_parent(\"Game\").add_child(bullet) + bullet.position = $Position2D.global_position + +func set_shoot_speed(value): + if speed != 0.5: + speed -= value + print(speed) + pass +" + +[node name="ShooterObject" type="Node2D"] +position = Vector2( 64, 64 ) +scale = Vector2( 2, 2 ) +z_index = 1 +script = SubResource( 1 ) + +[node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 3, 3 ) +z_index = 1 +texture = ExtResource( 1 ) +region_enabled = true +region_rect = Rect2( 0, 48, 16, 16 ) + +[node name="Position2D" type="Position2D" parent="."] +position = Vector2( 0.5, -28 ) diff --git a/Slot.gd b/Slot.gd new file mode 100644 index 0000000..6044837 --- /dev/null +++ b/Slot.gd @@ -0,0 +1,24 @@ +extends Panel + +var PanzerType = preload("res://Panzer.tscn") +var Panzer = null + +func _ready(): + if randi() % 2 == 0: + Panzer = PanzerType.instance() + add_child(Panzer) + + +func pickFromSlot(): + remove_child(Panzer) + var GameNode = find_parent("Game") + GameNode.add_child(Panzer) + Panzer = null + +func putIntoSlot(new_panzer): + Panzer = new_panzer + Panzer.position = Vector2(64, 64) + var GameNode = find_parent("Game") + GameNode.remove_child(Panzer) + add_child(Panzer) + diff --git a/Spawner.gd b/Spawner.gd new file mode 100644 index 0000000..4ed84f0 --- /dev/null +++ b/Spawner.gd @@ -0,0 +1,20 @@ +extends Panel + +var enemy_pre = preload("res://Entity.tscn") +var enemy = null +var Time = 0 + +# Called when the node enters the scene tree for the first time. +func _ready(): + if randi() % 2 == 0: + enemy = enemy_pre.instance() + add_child(enemy) + pass + +func _process(delta): + Time += delta + if Time > 5: + if randi() % 2 == 0: + enemy = enemy_pre.instance() + add_child(enemy) + Time = 0 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/LICENSE b/addons/admob/LICENSE new file mode 100644 index 0000000..db60394 --- /dev/null +++ b/addons/admob/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Poing Studios + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. 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..9dd1294 --- /dev/null +++ b/addons/admob/assets/android.png.import @@ -0,0 +1,35 @@ +[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 +process/normal_map_invert_y=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/fonts/orange_juice_2_0.ttf b/addons/admob/assets/fonts/orange_juice_2_0.ttf new file mode 100644 index 0000000..bfccdf3 Binary files /dev/null and b/addons/admob/assets/fonts/orange_juice_2_0.ttf differ diff --git a/addons/admob/assets/icon-1024.png b/addons/admob/assets/icon-1024.png new file mode 100644 index 0000000..f0ad071 Binary files /dev/null and b/addons/admob/assets/icon-1024.png differ diff --git a/addons/admob/assets/icon-1024.png.import b/addons/admob/assets/icon-1024.png.import new file mode 100644 index 0000000..8d77c94 --- /dev/null +++ b/addons/admob/assets/icon-1024.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/icon-1024.png" +dest_files=[ "res://.import/icon-1024.png-2958e8f3e03f08146a840475cdd3cd61.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/assets/icon-120.png b/addons/admob/assets/icon-120.png new file mode 100644 index 0000000..eb9b215 Binary files /dev/null and b/addons/admob/assets/icon-120.png differ diff --git a/addons/admob/assets/icon-120.png.import b/addons/admob/assets/icon-120.png.import new file mode 100644 index 0000000..98311ca --- /dev/null +++ b/addons/admob/assets/icon-120.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/icon-120.png" +dest_files=[ "res://.import/icon-120.png-f1130a47a81f19626ca0e688a5d38d3a.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/assets/icon-15.png b/addons/admob/assets/icon-15.png new file mode 100644 index 0000000..72ca0ad Binary files /dev/null and b/addons/admob/assets/icon-15.png differ diff --git a/addons/admob/assets/icon-15.png.import b/addons/admob/assets/icon-15.png.import new file mode 100644 index 0000000..b8bb61e --- /dev/null +++ b/addons/admob/assets/icon-15.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/icon-15.png" +dest_files=[ "res://.import/icon-15.png-befc05bf38293c8cfe2bd393c6e153c6.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/assets/icon-500.png b/addons/admob/assets/icon-500.png new file mode 100644 index 0000000..1d52ac4 Binary files /dev/null and b/addons/admob/assets/icon-500.png differ diff --git a/addons/admob/assets/icon-500.png.import b/addons/admob/assets/icon-500.png.import new file mode 100644 index 0000000..572ab9e --- /dev/null +++ b/addons/admob/assets/icon-500.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/icon-500.png" +dest_files=[ "res://.import/icon-500.png-551469a97496c83ff13bc47c2b1cdefa.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/assets/icon-76.png b/addons/admob/assets/icon-76.png new file mode 100644 index 0000000..eaab975 Binary files /dev/null and b/addons/admob/assets/icon-76.png differ diff --git a/addons/admob/assets/icon-76.png.import b/addons/admob/assets/icon-76.png.import new file mode 100644 index 0000000..36acb04 --- /dev/null +++ b/addons/admob/assets/icon-76.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/icon-76.png" +dest_files=[ "res://.import/icon-76.png-81101785e7e41d0daa72dddaf6f4956f.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 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..e65be74 --- /dev/null +++ b/addons/admob/assets/ios.png.import @@ -0,0 +1,35 @@ +[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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/addons/admob/assets/music.ogg b/addons/admob/assets/music.ogg new file mode 100644 index 0000000..24f3758 Binary files /dev/null and b/addons/admob/assets/music.ogg differ diff --git a/addons/admob/assets/music.ogg.import b/addons/admob/assets/music.ogg.import new file mode 100644 index 0000000..b349761 --- /dev/null +++ b/addons/admob/assets/music.ogg.import @@ -0,0 +1,15 @@ +[remap] + +importer="ogg_vorbis" +type="AudioStreamOGGVorbis" +path="res://.import/music.ogg-6849ed60109f01916f243ace862e95fb.oggstr" + +[deps] + +source_file="res://addons/admob/assets/music.ogg" +dest_files=[ "res://.import/music.ogg-6849ed60109f01916f243ace862e95fb.oggstr" ] + +[params] + +loop=true +loop_offset=0 diff --git a/addons/admob/assets/poing.jpeg b/addons/admob/assets/poing.jpeg new file mode 100644 index 0000000..1b8bb80 Binary files /dev/null and b/addons/admob/assets/poing.jpeg differ diff --git a/addons/admob/assets/poing.jpeg.import b/addons/admob/assets/poing.jpeg.import new file mode 100644 index 0000000..f8f7778 --- /dev/null +++ b/addons/admob/assets/poing.jpeg.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://addons/admob/assets/poing.jpeg" +dest_files=[ "res://.import/poing.jpeg-b1ae7a0b5e3bb646b5b1cf5ae07e3b86.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 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 new file mode 100644 index 0000000..0012a86 --- /dev/null +++ b/addons/admob/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="AdMob" +description="The AdMob of Plugin for Android and iOS." +author="Poing Studios" +version="1.3.2" +script="src/core/AdMob.gd" 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..03752cf --- /dev/null +++ b/addons/admob/src/core/AdMobEditor.gd @@ -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") diff --git a/addons/admob/src/core/AdMobEditor.tscn b/addons/admob/src/core/AdMobEditor.tscn new file mode 100644 index 0000000..121c1b8 --- /dev/null +++ b/addons/admob/src/core/AdMobEditor.tscn @@ -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"] diff --git a/addons/admob/src/core/CurrentVersion.gd b/addons/admob/src/core/CurrentVersion.gd new file mode 100644 index 0000000..fcc9fa6 --- /dev/null +++ b/addons/admob/src/core/CurrentVersion.gd @@ -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() diff --git a/addons/admob/src/core/SupportVersion.gd b/addons/admob/src/core/SupportVersion.gd new file mode 100644 index 0000000..1c7a1fb --- /dev/null +++ b/addons/admob/src/core/SupportVersion.gd @@ -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] diff --git a/addons/admob/src/core/VersionSupportedHTTPRequest.gd b/addons/admob/src/core/VersionSupportedHTTPRequest.gd new file mode 100644 index 0000000..5220194 --- /dev/null +++ b/addons/admob/src/core/VersionSupportedHTTPRequest.gd @@ -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) diff --git a/addons/admob/src/core/VersionSupportedHTTPRequest.tscn b/addons/admob/src/core/VersionSupportedHTTPRequest.tscn new file mode 100644 index 0000000..c3e2382 --- /dev/null +++ b/addons/admob/src/core/VersionSupportedHTTPRequest.tscn @@ -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"] diff --git a/addons/admob/src/core/components/Debug.gd b/addons/admob/src/core/components/Debug.gd new file mode 100644 index 0000000..69c9dde --- /dev/null +++ b/addons/admob/src/core/components/Debug.gd @@ -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 + diff --git a/addons/admob/src/core/components/Debug.tscn b/addons/admob/src/core/components/Debug.tscn new file mode 100644 index 0000000..0b5e7e1 --- /dev/null +++ b/addons/admob/src/core/components/Debug.tscn @@ -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"] diff --git a/addons/admob/src/core/components/Downloads.gd b/addons/admob/src/core/components/Downloads.gd new file mode 100644 index 0000000..1a8a450 --- /dev/null +++ b/addons/admob/src/core/components/Downloads.gd @@ -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") diff --git a/addons/admob/src/core/components/Downloads.tscn b/addons/admob/src/core/components/Downloads.tscn new file mode 100644 index 0000000..2e5b806 --- /dev/null +++ b/addons/admob/src/core/components/Downloads.tscn @@ -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"] diff --git a/addons/admob/src/core/components/Enabled.gd b/addons/admob/src/core/components/Enabled.gd new file mode 100644 index 0000000..77f5d22 --- /dev/null +++ b/addons/admob/src/core/components/Enabled.gd @@ -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 diff --git a/addons/admob/src/core/components/General.gd b/addons/admob/src/core/components/General.gd new file mode 100644 index 0000000..12debad --- /dev/null +++ b/addons/admob/src/core/components/General.gd @@ -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] diff --git a/addons/admob/src/core/components/General.tscn b/addons/admob/src/core/components/General.tscn new file mode 100644 index 0000000..0683136 --- /dev/null +++ b/addons/admob/src/core/components/General.tscn @@ -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"] diff --git a/addons/admob/src/core/components/VerifyNetworkGithub.gd b/addons/admob/src/core/components/VerifyNetworkGithub.gd new file mode 100644 index 0000000..2fa2fee --- /dev/null +++ b/addons/admob/src/core/components/VerifyNetworkGithub.gd @@ -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) 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..3faff63 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/AdFormat.tscn @@ -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 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..c575d9b --- /dev/null +++ b/addons/admob/src/core/components/ad_format/BannerAdFormat.gd @@ -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 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..47717a7 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/BannerAdFormat.tscn @@ -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"] 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/RespectSafeArea.gd b/addons/admob/src/core/components/ad_format/RespectSafeArea.gd new file mode 100644 index 0000000..0ca0858 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/RespectSafeArea.gd @@ -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) 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..bb00102 --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/UnitIds.gd @@ -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 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..a0c1b51 --- /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 = 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 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..0c52d6a --- /dev/null +++ b/addons/admob/src/core/components/ad_format/unit_ids/ad_unit_operational_system/ad_unit/AdUnit.gd @@ -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 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/src/singletons/AdMobSingleton.gd b/addons/admob/src/singletons/AdMobSingleton.gd new file mode 100644 index 0000000..31a769a --- /dev/null +++ b/addons/admob/src/singletons/AdMobSingleton.gd @@ -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) diff --git a/addons/admob/src/singletons/MobileAds.gd b/addons/admob/src/singletons/MobileAds.gd new file mode 100644 index 0000000..0189bba --- /dev/null +++ b/addons/admob/src/singletons/MobileAds.gd @@ -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() + diff --git a/addons/admob/src/utils/AdMobGlobals.gd b/addons/admob/src/utils/AdMobGlobals.gd new file mode 100644 index 0000000..56f5456 --- /dev/null +++ b/addons/admob/src/utils/AdMobGlobals.gd @@ -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 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..a0f8baf --- /dev/null +++ b/addons/admob/src/utils/AdMobSave.gd @@ -0,0 +1,3 @@ +static func save_config(p_path : String, p_config : Dictionary) -> void: + ProjectSettings.set_setting(p_path, p_config) + ProjectSettings.save() diff --git a/addons/admob/src/utils/AdMobSettings.gd b/addons/admob/src/utils/AdMobSettings.gd new file mode 100644 index 0000000..4dd06b5 --- /dev/null +++ b/addons/admob/src/utils/AdMobSettings.gd @@ -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('') diff --git a/addons/admob/test/Example.cs b/addons/admob/test/Example.cs new file mode 100644 index 0000000..b6c50d5 --- /dev/null +++ b/addons/admob/test/Example.cs @@ -0,0 +1,299 @@ +using Godot; +using System; +using System.Collections; + +public class Example : Control +{ + private Node MobileAds; + IDictionary config; + + private Button EnableBanner; + private Button DisableBanner; + private Button ShowBanner; + private Button HideBanner; + + private Button Interstitial; + private Button Rewarded; + private Button RewardedInterstitial; + + private Button RequestUserConsent; + private Button ResetConsentState; + + private RichTextLabel Advice; + private AudioStreamPlayer Music; + + private CheckBox BannerPosition; + private ItemList BannerSizes; + + private void GetAllNodes() + { + MobileAds = (Node) GetNode("/root/MobileAds"); + config = (IDictionary) MobileAds.Get("config"); + + EnableBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner/EnableBanner"); + DisableBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner/DisableBanner"); + ShowBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner2/ShowBanner"); + HideBanner = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Banner2/HideBanner"); + + Interstitial = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Interstitial"); + Rewarded = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/Rewarded"); + RewardedInterstitial = (Button) GetNode("Background/TabContainer/AdFormats/VBoxContainer/RewardedInterstitial"); + + RequestUserConsent = (Button) GetNode("Background/TabContainer/UMP/VBoxContainer/RequestUserConsent"); + ResetConsentState = (Button) GetNode("Background/TabContainer/UMP/VBoxContainer/ResetConsentState"); + + Advice = (RichTextLabel) GetNode("Background/Advice"); + Music = (AudioStreamPlayer) GetNode("Music"); + + BannerPosition = (CheckBox) GetNode("Background/TabContainer/Banner/VBoxContainer/Position"); + BannerSizes = (ItemList) GetNode("Background/TabContainer/Banner/VBoxContainer/BannerSizes"); + } + + private void _add_text_Advice_Node(String text_value) + { + Advice.BbcodeText += text_value + "\n"; + } + + public override void _Ready() + { + GetAllNodes(); + OS.CenterWindow(); + Music.Play(); + + 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)); + } + else + { + _add_text_Advice_Node("AdMob only works on Android or iOS devices!"); + } + } + + private void _on_MobileAds_initialization_complete(int status, String _adapter_name) + { + 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_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; + RequestUserConsent.Disabled = false; + ResetConsentState.Disabled = false; + } + else + { + _add_text_Advice_Node("AdMob not initialized, check your configuration"); + } + _add_text_Advice_Node("---------------------------------------------------"); + } + private void _on_MobileAds_interstitial_loaded() + { + _add_text_Advice_Node("Interstitial loaded"); + Interstitial.Disabled = false; + } + + private void _on_MobileAds_interstitial_closed() + { + MobileAds.Call("load_interstitial"); + _add_text_Advice_Node("Interstitial closed"); + } + + private void _on_Interstitial_pressed() + { + MobileAds.Call("show_interstitial"); + Interstitial.Disabled = true; + } + + private void reset_banner_buttons() + { + DisableBanner.Disabled = true; + EnableBanner.Disabled = false; + ShowBanner.Disabled = true; + HideBanner.Disabled = true; + } + + private void _on_MobileAds_banner_destroyed() + { + reset_banner_buttons(); + _add_text_Advice_Node("Banner destroyed"); + } + + private void _on_MobileAds_banner_loaded() + { + DisableBanner.Disabled = false; + EnableBanner.Disabled = true; + ShowBanner.Disabled = false; + HideBanner.Disabled = false; + _add_text_Advice_Node("Banner loaded"); + _add_text_Advice_Node("Banner width: " + MobileAds.Call("get_banner_width")); + _add_text_Advice_Node("Banner height: " + MobileAds.Call("get_banner_height")); + _add_text_Advice_Node("Banner width in pixels: " + MobileAds.Call("get_banner_width_in_pixels")); + _add_text_Advice_Node("Banner height in pixels: " + MobileAds.Call("get_banner_height_in_pixels")); + } + + private void _on_EnableBanner_pressed() + { + EnableBanner.Disabled = true; + MobileAds.Call("load_banner"); + } + + private void _on_DisableBanner_pressed() + { + DisableBanner.Disabled = true; + EnableBanner.Disabled = false; + MobileAds.Call("destroy_banner"); + } + + private void _on_Rewarded_pressed() + { + MobileAds.Call("show_rewarded"); + Rewarded.Disabled = true; + } + + private void _on_RewardedInterstitial_pressed() + { + MobileAds.Call("show_rewarded_interstitial"); + RewardedInterstitial.Disabled = true; + } + + private void _on_MobileAds_rewarded_ad_loaded() + { + _add_text_Advice_Node("Rewarded ad loaded"); + Rewarded.Disabled = false; + } + + private void _on_MobileAds_rewarded_ad_closed() + { + MobileAds.Call("load_rewarded"); + _add_text_Advice_Node("Rewarded ad closed"); + } + + private void _on_MobileAds_rewarded_interstitial_ad_loaded() + { + _add_text_Advice_Node("Rewarded Interstitial ad loaded"); + RewardedInterstitial.Disabled = false; + } + + private void _on_MobileAds_rewarded_interstitial_ad_closed() + { + MobileAds.Call("load_rewarded_interstitial"); + _add_text_Advice_Node("Rewarded Interstitial ad closed"); + } + + private void _on_MobileAds_user_earned_rewarded(String currency, int amount) + { + Advice.BbcodeText += "EARNED " + currency + " with amount: " + amount.ToString() + "\n"; + } + + private void _on_MobileAds_consent_info_update_failure(int _error_code, String error_message) + { + _add_text_Advice_Node("Request Consent from European Users failure: " + error_message); + _add_text_Advice_Node("---------------------------------------------------"); + + } + + private void _on_MobileAds_consent_status_changed(String status_message) + { + _add_text_Advice_Node(status_message); + } + + + private void _on_BannerSizes_item_selected(int index) + { + if ((bool) MobileAds.Call("get_is_initialized")) + { + String item_text = (String) BannerSizes.GetItemText(index); + + ((IDictionary)config["banner"])["size"] = index; + _add_text_Advice_Node("Banner Size changed:" + item_text); + if ((bool) MobileAds.Call("get_is_banner_loaded")) + { + MobileAds.Call("load_banner"); + } + } + } + + private void _on_ResetConsentState_pressed() + { + MobileAds.Call("reset_consent_state", true); + } + + private void _on_RequestUserConsent_pressed() + { + MobileAds.Call("request_user_consent"); + } + + + private void _on_Position_pressed() + { + ((IDictionary)config["banner"])["position"] = BannerPosition.Pressed; + if ((bool)MobileAds.Call("get_is_banner_loaded")) + { + MobileAds.Call("load_banner"); + } + } + + + private void _on_IsInitialized_pressed() + { + _add_text_Advice_Node("Is initialized: " + MobileAds.Call("get_is_initialized")); + } + + + private void _on_IsBannerLoaded_pressed() + { + _add_text_Advice_Node("Is Banner loaded: " + MobileAds.Call("get_is_banner_loaded")); + } + + + private void _on_IsInterstitialLoaded_pressed() + { + _add_text_Advice_Node("Is Interstitial loaded: " + MobileAds.Call("get_is_interstitial_loaded")); + } + + + private void _on_IsRewardedLoaded_pressed(){ + _add_text_Advice_Node("Is Rewarded loaded: " + MobileAds.Call("get_is_rewarded_loaded")); + } + + + private void _on_IsRewardedInterstitialLoaded_pressed(){ + _add_text_Advice_Node("Is RewardedInterstitial loaded: " + MobileAds.Call("get_is_rewarded_interstitial_loaded")); + } + + + private void _on_ShowBanner_pressed() + { + MobileAds.Call("show_banner"); + } + + + private void _on_HideBanner_pressed() + { + MobileAds.Call("hide_banner"); + } +} diff --git a/addons/admob/test/Example.gd b/addons/admob/test/Example.gd new file mode 100644 index 0000000..64b7695 --- /dev/null +++ b/addons/admob/test/Example.gd @@ -0,0 +1,299 @@ +extends Control + +onready var EnableBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner/EnableBanner +onready var DisableBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner/DisableBanner +onready var ShowBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner2/ShowBanner +onready var HideBanner : Button = $Background/TabContainer/AdFormats/VBoxContainer/Banner2/HideBanner + +onready var Interstitial : Button = $Background/TabContainer/AdFormats/VBoxContainer/Interstitial +onready var Rewarded : Button = $Background/TabContainer/AdFormats/VBoxContainer/Rewarded +onready var RewardedInterstitial : Button = $Background/TabContainer/AdFormats/VBoxContainer/RewardedInterstitial + +onready var RequestUserConsent : Button = $Background/TabContainer/UMP/VBoxContainer/RequestUserConsent +onready var ResetConsentState : Button = $Background/TabContainer/UMP/VBoxContainer/ResetConsentState + +onready var Advice : RichTextLabel = $Background/Advice + +onready var BannerPosition : CheckBox = $Background/TabContainer/Banner/VBoxContainer/Position +onready var RespectSafeArea : CheckBox = $Background/TabContainer/Banner/VBoxContainer/RespectSafeArea +onready var BannerSizes : ItemList = $Background/TabContainer/Banner/VBoxContainer/BannerSizes + +func _add_text_Advice_Node(text_value : String) -> void: + Advice.bbcode_text += text_value + "\n" + +func _ready() -> void: + BannerPosition.pressed = MobileAds.AdMobSettings.config.banner.position + RespectSafeArea.pressed = MobileAds.AdMobSettings.config.banner.respect_safe_area + + OS.center_window() + for banner_size in MobileAds.AdMobSettings.BANNER_SIZE: + BannerSizes.add_item(banner_size) + if OS.get_name() == "Android" or OS.get_name() == "iOS": + # warning-ignore:return_value_discarded + MobileAds.connect("consent_form_dismissed", self, "_on_MobileAds_consent_form_dismissed") + # warning-ignore:return_value_discarded + MobileAds.connect("consent_form_load_failure", self, "_on_MobileAds_consent_form_load_failure") + # warning-ignore:return_value_discarded + MobileAds.connect("consent_info_update_failure", self, "_on_MobileAds_consent_info_update_failure") + # warning-ignore:return_value_discarded + MobileAds.connect("consent_info_update_success", self, "_on_MobileAds_consent_info_update_success") + # warning-ignore:return_value_discarded + MobileAds.connect("consent_status_changed", self, "_on_MobileAds_consent_status_changed") + # warning-ignore:return_value_discarded + MobileAds.connect("banner_loaded", self, "_on_MobileAds_banner_loaded") + # warning-ignore:return_value_discarded + MobileAds.connect("banner_destroyed", self, "_on_MobileAds_banner_destroyed") + # warning-ignore:return_value_discarded + MobileAds.connect("banner_clicked", self, "_on_MobileAds_banner_clicked") + # warning-ignore:return_value_discarded + MobileAds.connect("banner_closed", self, "_on_MobileAds_banner_closed") + # warning-ignore:return_value_discarded + MobileAds.connect("banner_failed_to_load", self, "_on_MobileAds_banner_failed_to_load") + # warning-ignore:return_value_discarded + MobileAds.connect("banner_recorded_impression", self, "_on_MobileAds_banner_recorded_impression") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_loaded", self, "_on_MobileAds_interstitial_loaded") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_closed", self, "_on_MobileAds_interstitial_closed") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_clicked", self, "_on_MobileAds_interstitial_clicked") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_failed_to_load", self, "_on_MobileAds_interstitial_failed_to_load") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_failed_to_show", self, "_on_MobileAds_interstitial_failed_to_show") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_opened", self, "_on_MobileAds_interstitial_opened") + # warning-ignore:return_value_discarded + MobileAds.connect("interstitial_recorded_impression", self, "_on_MobileAds_interstitial_recorded_impression") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_loaded", self, "_on_MobileAds_rewarded_ad_loaded") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_closed", self, "_on_MobileAds_rewarded_ad_closed") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_clicked", self, "_on_MobileAds_rewarded_ad_clicked") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_failed_to_load", self, "_on_MobileAds_rewarded_ad_failed_to_load") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_failed_to_show", self, "_on_MobileAds_rewarded_ad_failed_to_show") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_opened", self, "_on_MobileAds_rewarded_ad_opened") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_ad_recorded_impression", self, "_on_MobileAds_rewarded_ad_recorded_impression") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_loaded", self, "_on_MobileAds_rewarded_interstitial_ad_loaded") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_closed", self, "_on_MobileAds_rewarded_interstitial_ad_closed") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_clicked", self, "_on_MobileAds_rewarded_interstitial_ad_clicked") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_failed_to_load", self, "_on_MobileAds_rewarded_interstitial_ad_failed_to_load") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_failed_to_show", self, "_on_MobileAds_rewarded_interstitial_ad_failed_to_show") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_opened", self, "_on_MobileAds_rewarded_interstitial_ad_opened") + # warning-ignore:return_value_discarded + MobileAds.connect("rewarded_interstitial_ad_recorded_impression", self, "_on_MobileAds_rewarded_interstitial_ad_recorded_impression") + # warning-ignore:return_value_discarded + MobileAds.connect("user_earned_rewarded", self, "_on_MobileAds_user_earned_rewarded") + # warning-ignore:return_value_discarded + MobileAds.connect("initialization_complete", self, "_on_MobileAds_initialization_complete") + else: + _add_text_Advice_Node("AdMob only works on Android or iOS devices!") + +func _on_MobileAds_rewarded_interstitial_ad_clicked(): + _add_text_Advice_Node("Rewarded Interstitial clicked") +func _on_MobileAds_rewarded_interstitial_ad_failed_to_load(error_code): + _add_text_Advice_Node("Rewarded Interstitial failed to load, error_code = " + str(error_code)) +func _on_MobileAds_rewarded_interstitial_ad_failed_to_show(error_code): + _add_text_Advice_Node("Rewarded Interstitial failed to show, error_code = " + str(error_code)) +func _on_MobileAds_rewarded_interstitial_ad_opened(): + _add_text_Advice_Node("Rewarded Interstitial opened") +func _on_MobileAds_rewarded_interstitial_ad_recorded_impression(): + _add_text_Advice_Node("Rewarded Interstitial recorded impression") + +func _on_MobileAds_rewarded_ad_clicked(): + _add_text_Advice_Node("Rewarded clicked") +func _on_MobileAds_rewarded_ad_failed_to_load(error_code): + _add_text_Advice_Node("Rewarded failed to load, error_code = " + str(error_code)) +func _on_MobileAds_rewarded_ad_failed_to_show(error_code): + _add_text_Advice_Node("Rewarded failed to show, error_code = " + str(error_code)) +func _on_MobileAds_rewarded_ad_opened(): + _add_text_Advice_Node("Rewarded opened") +func _on_MobileAds_rewarded_ad_recorded_impression(): + _add_text_Advice_Node("Rewarded recorded impression") + + +func _on_MobileAds_interstitial_clicked(): + _add_text_Advice_Node("Interstitial clicked") +func _on_MobileAds_interstitial_failed_to_load(error_code): + _add_text_Advice_Node("Interstitial failed to load, error_code = " + str(error_code)) +func _on_MobileAds_interstitial_failed_to_show(error_code): + _add_text_Advice_Node("Interstitial failed to show, error_code = " + str(error_code)) +func _on_MobileAds_interstitial_opened(): + _add_text_Advice_Node("Interstitial opened") +func _on_MobileAds_interstitial_recorded_impression(): + _add_text_Advice_Node("Interstitial recorded impression") + +func _on_MobileAds_banner_clicked(): + _add_text_Advice_Node("Banner clicked") +func _on_MobileAds_banner_closed(): + _add_text_Advice_Node("Banner closed") +func _on_MobileAds_banner_failed_to_load(error_code): + _add_text_Advice_Node("Banner failed to load, error_code = " + str(error_code)) +func _on_MobileAds_banner_recorded_impression(): + _add_text_Advice_Node("Banner recorded impression") + +func _on_MobileAds_initialization_complete(status : int, adapter_name : String) -> void: + 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(JSON.print(MobileAds.config, "\t")) + _add_text_Advice_Node("instance_id: " + str(get_instance_id())) + EnableBanner.disabled = false + BannerPosition.disabled = false + RequestUserConsent.disabled = false + ResetConsentState.disabled = false + else: + _add_text_Advice_Node("AdMob not initialized, check your configuration") + _add_text_Advice_Node("---------------------------------------------------") + +func _on_MobileAds_interstitial_loaded() -> void: + Interstitial.disabled = false + _add_text_Advice_Node("Interstitial loaded") + +func _on_MobileAds_interstitial_closed() -> void: + MobileAds.load_interstitial() + _add_text_Advice_Node("Interstitial closed") + +func _on_Interstitial_pressed() -> void: + MobileAds.show_interstitial() + Interstitial.disabled = true + +func reset_banner_buttons() -> void: + DisableBanner.disabled = true + EnableBanner.disabled = false + ShowBanner.disabled = true + HideBanner.disabled = true + +func _on_MobileAds_banner_destroyed() -> void: + reset_banner_buttons() + _add_text_Advice_Node("Banner destroyed") + +func _on_MobileAds_banner_loaded() -> void: + DisableBanner.disabled = false + EnableBanner.disabled = true + ShowBanner.disabled = false + HideBanner.disabled = false + _add_text_Advice_Node("Banner loaded") + _add_text_Advice_Node("Banner width: " + str(MobileAds.get_banner_width())) + _add_text_Advice_Node("Banner height: " + str(MobileAds.get_banner_height())) + _add_text_Advice_Node("Banner width in pixels: " + str(MobileAds.get_banner_width_in_pixels())) + _add_text_Advice_Node("Banner height in pixels: " + str(MobileAds.get_banner_height_in_pixels())) + +func _on_EnableBanner_pressed() -> void: + EnableBanner.disabled = true + MobileAds.load_banner() + +func _on_DisableBanner_pressed() -> void: + DisableBanner.disabled = true + EnableBanner.disabled = false + MobileAds.destroy_banner() + +func _on_Rewarded_pressed() -> void: + MobileAds.show_rewarded() + Rewarded.disabled = true + +func _on_RewardedInterstitial_pressed() -> void: + MobileAds.show_rewarded_interstitial() + RewardedInterstitial.disabled = true + +func _on_MobileAds_rewarded_ad_loaded() -> void: + Rewarded.disabled = false + _add_text_Advice_Node("Rewarded ad loaded") + +func _on_MobileAds_rewarded_ad_closed() -> void: + MobileAds.load_rewarded() + _add_text_Advice_Node("Rewarded ad closed") + +func _on_MobileAds_rewarded_interstitial_ad_loaded() -> void: + RewardedInterstitial.disabled = false + _add_text_Advice_Node("Rewarded Interstitial ad loaded") + +func _on_MobileAds_rewarded_interstitial_ad_closed() -> void: + MobileAds.load_rewarded_interstitial() + _add_text_Advice_Node("Rewarded Interstitial ad closed") + +func _on_MobileAds_user_earned_rewarded(currency : String, amount : int) -> void: + Advice.bbcode_text += "EARNED " + currency + " with amount: " + str(amount) + "\n" + +func _on_MobileAds_consent_form_dismissed() -> void: + _add_text_Advice_Node("Request Consent from European Users Form dismissed") + +func _on_MobileAds_consent_form_load_failure(error_code, error_message) -> void: + _add_text_Advice_Node("Request Consent from European Users load_failure: " + error_message) + _add_text_Advice_Node("---------------------------------------------------") + +func _on_MobileAds_consent_info_update_failure(_error_code : int, error_message : String) -> void: + _add_text_Advice_Node("Request Consent from European Users update failure: " + error_message) + _add_text_Advice_Node("---------------------------------------------------") + +func _on_MobileAds_consent_info_update_success(status_message : String) -> void: + _add_text_Advice_Node("Consent info update success: " + status_message) + +func _on_MobileAds_consent_status_changed(status_message : String) -> void: + _add_text_Advice_Node("Consent status changed: " + status_message) + +func _on_BannerSizes_item_selected(index : int) -> void: + if MobileAds.get_is_initialized(): + var item_text : String = BannerSizes.get_item_text(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() + +func _on_ResetConsentState_pressed() -> void: + MobileAds.reset_consent_state(true) + +func _on_RequestUserConsent_pressed() -> void: + MobileAds.request_user_consent() + + +func _on_Position_pressed() -> void: + MobileAds.config.banner.position = BannerPosition.pressed + if MobileAds.get_is_banner_loaded(): + MobileAds.load_banner() + +func _on_RespectSafeArea_pressed(): + MobileAds.config.banner.respect_safe_area = RespectSafeArea.pressed + if MobileAds.get_is_banner_loaded(): + MobileAds.load_banner() + +func _on_IsInitialized_pressed() -> void: + _add_text_Advice_Node("Is initialized: " + str(MobileAds.get_is_initialized())) + + +func _on_IsBannerLoaded_pressed() -> void: + _add_text_Advice_Node("Is Banner loaded: " + str(MobileAds.get_is_banner_loaded())) + + +func _on_IsInterstitialLoaded_pressed() -> void: + _add_text_Advice_Node("Is Interstitial loaded: " + str(MobileAds.get_is_interstitial_loaded())) + + +func _on_IsRewardedLoaded_pressed() -> void: + _add_text_Advice_Node("Is Rewarded loaded: " + str(MobileAds.get_is_rewarded_loaded())) + + +func _on_IsRewardedInterstitialLoaded_pressed() -> void: + _add_text_Advice_Node("Is RewardedInterstitial loaded: " + str(MobileAds.get_is_rewarded_interstitial_loaded())) + + +func _on_ShowBanner_pressed() -> void: + MobileAds.show_banner() + +func _on_HideBanner_pressed() -> void: + MobileAds.hide_banner() + + diff --git a/addons/admob/test/Example.tscn b/addons/admob/test/Example.tscn new file mode 100644 index 0000000..b5e5133 --- /dev/null +++ b/addons/admob/test/Example.tscn @@ -0,0 +1,347 @@ +[gd_scene load_steps=11 format=2] + +[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] +[ext_resource path="res://addons/admob/test/MusicCheckButton.gd" type="Script" id=5] + +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0.36377, 0.23226, 0.0795746, 1 ) + +[sub_resource type="StyleBoxEmpty" id=2] + +[sub_resource type="Theme" id=3] +TabContainer/styles/panel = SubResource( 2 ) + +[sub_resource type="StyleBoxFlat" id=4] +bg_color = Color( 0, 0, 0, 1 ) + +[sub_resource type="StyleBoxFlat" id=5] +bg_color = Color( 0, 0, 0, 1 ) + +[node name="Example" type="Control"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 1 ) +__meta__ = { +"_edit_lock_": true, +"_edit_use_anchors_": false +} + +[node name="Background" type="ColorRect" parent="."] +anchor_right = 1.0 +anchor_bottom = 1.0 +color = Color( 1, 0.541176, 0, 1 ) +__meta__ = { +"_edit_lock_": true, +"_edit_use_anchors_": false +} + +[node name="Poing" type="TextureRect" parent="Background"] +anchor_left = 1.0 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -100.0 +margin_top = -100.0 +texture = ExtResource( 3 ) +expand = true +stretch_mode = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="AdMob" type="TextureRect" parent="Background"] +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +margin_left = -256.0 +margin_top = -256.0 +margin_right = 256.0 +margin_bottom = 256.0 +texture = ExtResource( 2 ) +stretch_mode = 6 +__meta__ = { +"_edit_lock_": true +} + +[node name="Advice" type="RichTextLabel" parent="Background"] +anchor_top = 0.0933333 +anchor_right = 1.0 +anchor_bottom = 0.402222 +custom_styles/normal = SubResource( 1 ) +bbcode_enabled = true +bbcode_text = "[wave]" +scroll_following = true +__meta__ = { +"_edit_use_anchors_": true +} + +[node name="TabContainer" type="TabContainer" parent="Background"] +anchor_left = 0.145 +anchor_top = 0.546667 +anchor_right = 0.855 +anchor_bottom = 0.773333 +theme = SubResource( 3 ) +__meta__ = { +"_edit_use_anchors_": true +} + +[node name="AdFormats" type="Tabs" parent="Background/TabContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 24.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/AdFormats"] +anchor_right = 1.0 +anchor_bottom = 1.0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Banner" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"] +margin_top = 46.0 +margin_right = 426.0 +margin_bottom = 66.0 +size_flags_vertical = 0 +alignment = 1 + +[node name="EnableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"] +margin_right = 211.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +disabled = true +text = "ENABLE BANNER" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="DisableBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner"] +margin_left = 215.0 +margin_right = 426.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +disabled = true +text = "DISABLE BANNER" + +[node name="Banner2" type="HBoxContainer" parent="Background/TabContainer/AdFormats/VBoxContainer"] +margin_top = 70.0 +margin_right = 426.0 +margin_bottom = 90.0 +size_flags_vertical = 0 +alignment = 1 + +[node name="ShowBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"] +margin_right = 211.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +disabled = true +text = "SHOW BANNER" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="HideBanner" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer/Banner2"] +margin_left = 215.0 +margin_right = 426.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +disabled = true +text = "HIDE BANNER" + +[node name="Interstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"] +margin_top = 94.0 +margin_right = 426.0 +margin_bottom = 114.0 +disabled = true +text = "INTERSTITIAL" + +[node name="Rewarded" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"] +margin_top = 118.0 +margin_right = 426.0 +margin_bottom = 138.0 +disabled = true +text = "REWARDED" + +[node name="RewardedInterstitial" type="Button" parent="Background/TabContainer/AdFormats/VBoxContainer"] +margin_top = 142.0 +margin_right = 426.0 +margin_bottom = 162.0 +disabled = true +text = "REWARDED INTERSTITIAL" + +[node name="Banner" type="Tabs" parent="Background/TabContainer"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 24.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/Banner"] +anchor_right = 1.0 +anchor_bottom = 1.0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="Control" type="Control" parent="Background/TabContainer/Banner/VBoxContainer"] +margin_top = 58.0 +margin_right = 355.0 +margin_bottom = 68.0 +rect_min_size = Vector2( 0, 10 ) + +[node name="Position" type="CheckBox" parent="Background/TabContainer/Banner/VBoxContainer"] +margin_top = 72.0 +margin_right = 355.0 +margin_bottom = 88.0 +custom_styles/hover = SubResource( 4 ) +custom_styles/pressed = SubResource( 4 ) +custom_styles/normal = SubResource( 4 ) +pressed = true +text = "Position on TOP" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RespectSafeArea" type="CheckBox" parent="Background/TabContainer/Banner/VBoxContainer"] +margin_top = 92.0 +margin_right = 355.0 +margin_bottom = 108.0 +custom_styles/hover = SubResource( 4 ) +custom_styles/pressed = SubResource( 4 ) +custom_styles/normal = SubResource( 4 ) +text = "Respect Safe Area (RECOMMENDED TRUE)" + +[node name="BannerSizes" type="ItemList" parent="Background/TabContainer/Banner/VBoxContainer"] +margin_top = 112.0 +margin_right = 355.0 +margin_bottom = 121.0 +auto_height = true +same_column_width = true +__meta__ = { +"_edit_use_anchors_": true +} + +[node name="UMP" type="Tabs" parent="Background/TabContainer"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 24.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/UMP"] +anchor_right = 1.0 +anchor_bottom = 1.0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="RequestUserConsent" type="Button" parent="Background/TabContainer/UMP/VBoxContainer"] +margin_top = 67.0 +margin_right = 355.0 +margin_bottom = 87.0 +disabled = true +text = "REQUEST USER CONSENT" + +[node name="ResetConsentState" type="Button" parent="Background/TabContainer/UMP/VBoxContainer"] +margin_top = 91.0 +margin_right = 355.0 +margin_bottom = 111.0 +disabled = true +text = "RESET CONSENT STATE" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="General" type="Tabs" parent="Background/TabContainer"] +visible = false +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_top = 24.0 + +[node name="VBoxContainer" type="VBoxContainer" parent="Background/TabContainer/General"] +anchor_right = 1.0 +anchor_bottom = 1.0 +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="IsInitialized" type="Button" parent="Background/TabContainer/General/VBoxContainer"] +margin_top = 31.0 +margin_right = 355.0 +margin_bottom = 51.0 +text = "is_initialized()" + +[node name="IsBannerLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"] +margin_top = 55.0 +margin_right = 355.0 +margin_bottom = 75.0 +text = "is_banner_loaded()" + +[node name="IsInterstitialLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"] +margin_top = 79.0 +margin_right = 355.0 +margin_bottom = 99.0 +text = "is_interstitial_loaded()" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="IsRewardedLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"] +margin_top = 103.0 +margin_right = 355.0 +margin_bottom = 123.0 +text = "is_rewarded_loaded()" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="IsRewardedInterstitialLoaded" type="Button" parent="Background/TabContainer/General/VBoxContainer"] +margin_top = 127.0 +margin_right = 355.0 +margin_bottom = 147.0 +text = "is_rewarded_interstitial_loaded()" +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="MusicCheckButton" type="CheckButton" parent="Background"] +anchor_left = 1.0 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +margin_left = -110.0 +margin_top = -84.0 +margin_bottom = -44.0 +custom_styles/hover = SubResource( 5 ) +custom_styles/pressed = SubResource( 5 ) +custom_styles/normal = SubResource( 5 ) +pressed = true +text = "MUSIC" +script = ExtResource( 5 ) + +[node name="Music" type="AudioStreamPlayer" parent="Background/MusicCheckButton"] +stream = ExtResource( 4 ) + +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner/EnableBanner" to="." method="_on_EnableBanner_pressed"] +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner/DisableBanner" to="." method="_on_DisableBanner_pressed"] +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner2/ShowBanner" to="." method="_on_ShowBanner_pressed"] +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Banner2/HideBanner" to="." method="_on_HideBanner_pressed"] +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Interstitial" to="." method="_on_Interstitial_pressed"] +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/Rewarded" to="." method="_on_Rewarded_pressed"] +[connection signal="pressed" from="Background/TabContainer/AdFormats/VBoxContainer/RewardedInterstitial" to="." method="_on_RewardedInterstitial_pressed"] +[connection signal="pressed" from="Background/TabContainer/Banner/VBoxContainer/Position" to="." method="_on_Position_pressed"] +[connection signal="pressed" from="Background/TabContainer/Banner/VBoxContainer/RespectSafeArea" to="." method="_on_RespectSafeArea_pressed"] +[connection signal="item_selected" from="Background/TabContainer/Banner/VBoxContainer/BannerSizes" to="." method="_on_BannerSizes_item_selected"] +[connection signal="pressed" from="Background/TabContainer/UMP/VBoxContainer/RequestUserConsent" to="." method="_on_RequestUserConsent_pressed"] +[connection signal="pressed" from="Background/TabContainer/UMP/VBoxContainer/ResetConsentState" to="." method="_on_ResetConsentState_pressed"] +[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsInitialized" to="." method="_on_IsInitialized_pressed"] +[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsBannerLoaded" to="." method="_on_IsBannerLoaded_pressed"] +[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsInterstitialLoaded" to="." method="_on_IsInterstitialLoaded_pressed"] +[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsRewardedLoaded" to="." method="_on_IsRewardedLoaded_pressed"] +[connection signal="pressed" from="Background/TabContainer/General/VBoxContainer/IsRewardedInterstitialLoaded" to="." method="_on_IsRewardedInterstitialLoaded_pressed"] +[connection signal="pressed" from="Background/MusicCheckButton" to="Background/MusicCheckButton" method="_on_MusicCheckButton_pressed"] diff --git a/addons/admob/test/MusicCheckButton.gd b/addons/admob/test/MusicCheckButton.gd new file mode 100644 index 0000000..8c85cce --- /dev/null +++ b/addons/admob/test/MusicCheckButton.gd @@ -0,0 +1,7 @@ +extends CheckButton + +func _ready(): + $Music.playing = pressed + +func _on_MusicCheckButton_pressed(): + $Music.playing = pressed diff --git a/assets/Tank Town V2.png b/assets/Tank Town V2.png new file mode 100644 index 0000000..c761a3c Binary files /dev/null and b/assets/Tank Town V2.png differ diff --git a/assets/Tank Town V2.png.import b/assets/Tank Town V2.png.import new file mode 100644 index 0000000..1d8e07a --- /dev/null +++ b/assets/Tank Town V2.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Tank Town V2.png" +dest_files=[ "res://.import/Tank Town V2.png-08c956fc5009403ed62839d990ebaf50.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=false +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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/box.png b/box.png new file mode 100644 index 0000000..4e0b409 Binary files /dev/null and b/box.png differ diff --git a/box.png.import b/box.png.import new file mode 100644 index 0000000..406f655 --- /dev/null +++ b/box.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://box.png" +dest_files=[ "res://.import/box.png-196cb2b6d7422a4ab3b9c60b5a994fe3.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=false +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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/enemy.png b/enemy.png new file mode 100644 index 0000000..5e93bae Binary files /dev/null and b/enemy.png differ diff --git a/enemy.png.import b/enemy.png.import new file mode 100644 index 0000000..1da7970 --- /dev/null +++ b/enemy.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/enemy.png-f7d9f81714867a24a08e299bb600e611.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://enemy.png" +dest_files=[ "res://.import/enemy.png-f7d9f81714867a24a08e299bb600e611.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=false +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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/export_presets.cfg b/export_presets.cfg new file mode 100644 index 0000000..ba455ff --- /dev/null +++ b/export_presets.cfg @@ -0,0 +1,42 @@ +[preset.0] + +name="Windows Desktop" +platform="Windows Desktop" +runnable=true +custom_features="" +export_filter="all_resources" +include_filter="" +exclude_filter="" +export_path="Export/Game.exe" +script_export_mode=1 +script_encryption_key="" + +[preset.0.options] + +custom_template/debug="" +custom_template/release="" +binary_format/64_bits=true +binary_format/embed_pck=true +texture_format/bptc=false +texture_format/s3tc=true +texture_format/etc=false +texture_format/etc2=false +texture_format/no_bptc_fallbacks=true +codesign/enable=false +codesign/identity_type=0 +codesign/identity="" +codesign/password="" +codesign/timestamp=true +codesign/timestamp_server_url="" +codesign/digest_algorithm=1 +codesign/description="" +codesign/custom_options=PoolStringArray( ) +application/modify_resources=true +application/icon="" +application/file_version="" +application/product_version="" +application/company_name="" +application/product_name="" +application/file_description="" +application/copyright="" +application/trademarks="" diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..c98fbb6 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..d34ff27 --- /dev/null +++ b/project.godot @@ -0,0 +1,125 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +[admob] + +config={ +"banner": { +"position": 1, +"respect_safe_area": true, +"show_instantly": true, +"size": "BANNER", +"unit_ids": { +"Android": { +"standard": "ca-app-pub-3940256099942544/6300978111" +}, +"iOS": { +"standard": "ca-app-pub-3940256099942544/2934735716" +} +} +}, +"debug": { +"is_debug_on_release": false, +"is_real": true, +"is_test_europe_user_consent": false +}, +"general": { +"is_enabled": true, +"is_for_child_directed_treatment": false, +"max_ad_content_rating": "PG" +}, +"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" +} +} +} +} + +[application] + +config/name="2048 shooter" +run/main_scene="res://Game.tscn" +config/icon="res://icon.png" + +[autoload] + +MobileAds="*res://addons/admob/src/singletons/MobileAds.gd" + +[display] + +window/size/width=576 +window/size/height=1200 +window/handheld/orientation="portrait" +window/stretch/mode="2d" + +[editor_plugins] + +enabled=PoolStringArray( "res://addons/admob/plugin.cfg" ) + +[gui] + +common/drop_mouse_on_gui_input_disabled=true + +[importer_defaults] + +texture={ +"compress/bptc_ldr": 0, +"compress/hdr_mode": 0, +"compress/lossy_quality": 0.7, +"compress/mode": 0, +"compress/normal_map": 0, +"detect_3d": false, +"flags/anisotropic": false, +"flags/filter": false, +"flags/mipmaps": false, +"flags/repeat": 0, +"flags/srgb": 2, +"process/HDR_as_SRGB": false, +"process/fix_alpha_border": true, +"process/invert_color": false, +"process/normal_map_invert_y": false, +"process/premult_alpha": false, +"size_limit": 0, +"stream": false, +"svg/scale": 1.0 +} + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +environment/default_environment="res://default_env.tres" diff --git a/retrowave.png b/retrowave.png new file mode 100644 index 0000000..bc9b5ae Binary files /dev/null and b/retrowave.png differ diff --git a/retrowave.png.import b/retrowave.png.import new file mode 100644 index 0000000..8db6bf9 --- /dev/null +++ b/retrowave.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://retrowave.png" +dest_files=[ "res://.import/retrowave.png-b70d674409984a3af1a2bdf9451dd5af.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=false +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 +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0