Added some objects. Changed storage to being on user://storage.db. And cleaned up the project folder.

This commit is contained in:
Jonathan Herrewijnen 2021-04-05 22:59:49 +02:00
parent a86a5ed396
commit 285cb8d096
239 changed files with 22132 additions and 21 deletions

View File

@ -14,6 +14,7 @@ func AddInventoryItem(itemid, amount):
if(player_inventory_items[x].item_id == itemid): if(player_inventory_items[x].item_id == itemid):
print(str(player_inventory_items[x])) print(str(player_inventory_items[x]))
player_inventory_items[x].amount += amount player_inventory_items[x].amount += amount
Database.SaveInventory(player_inventory_items)
return return
#if we reached here then no exisiting item is found and we iterate the array again #if we reached here then no exisiting item is found and we iterate the array again
print("adding item") print("adding item")
@ -24,6 +25,8 @@ func AddInventoryItem(itemid, amount):
player_inventory_items[x].shortdesc = "desc" player_inventory_items[x].shortdesc = "desc"
player_inventory_items[x].item_id = itemid player_inventory_items[x].item_id = itemid
player_inventory_items[x].amount = amount player_inventory_items[x].amount = amount
Database.SaveInventory(player_inventory_items)
return
func GoToScene(scene): func GoToScene(scene):
if current_scene != null: if current_scene != null:

View File

@ -1,14 +1,16 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=7 format=2]
[ext_resource path="res://Menu.gd" type="Script" id=1] [ext_resource path="res://MiscCodes/Menu.gd" type="Script" id=1]
[ext_resource path="res://pictures/animations/Loading/loading_ring.png" type="Texture" id=2] [ext_resource path="res://pictures/animations/Loading/loading_ring.png" type="Texture" id=2]
[ext_resource path="res://MiscCodes/loading_ring.gd" type="Script" id=3] [ext_resource path="res://MiscCodes/loading_ring.gd" type="Script" id=3]
[ext_resource path="res://ring_of_races_font.ttf" type="DynamicFontData" id=4]
[ext_resource path="res://pictures/gui/backgrounds/treesbackground1.png" type="Texture" id=5] [ext_resource path="res://pictures/gui/backgrounds/treesbackground1.png" type="Texture" id=5]
[sub_resource type="DynamicFontData" id=2]
font_path = "res://ring_of_races_font.ttf"
[sub_resource type="DynamicFont" id=1] [sub_resource type="DynamicFont" id=1]
size = 30 size = 30
font_data = ExtResource( 4 ) font_data = SubResource( 2 )
[node name="Main Menu" type="Node2D"] [node name="Main Menu" type="Node2D"]
script = ExtResource( 1 ) script = ExtResource( 1 )

View File

View File

@ -0,0 +1,71 @@
extends KinematicBody2D
const GRAVITY = 0.0
const WALK_SPEED = 200
const interaction_circle_size = 150
onready var background_map = get_node("/root/Map1/background")
onready var player = get_node("/root/Map1/Player")
onready var cell_size = background_map._get_cell_size()
onready var plants_map = get_node("/root/Map1/interaction_map")
onready var interaction = get_node("/root/Map1/player_interaction")
var velocity = Vector2()
var world_position
#Moving buttons
func _physics_process(delta):
if Input.is_key_pressed(KEY_SPACE) or Input.is_mouse_button_pressed(BUTTON_LEFT):
_interaction_process()
velocity.y += delta * GRAVITY
if Input.is_action_pressed("move_left"):
velocity.x = -WALK_SPEED
elif Input.is_action_pressed("move_right"):
velocity.x = WALK_SPEED
elif Input.is_action_pressed("move_up"):
velocity.y = -WALK_SPEED
elif Input.is_action_pressed("move_down"):
velocity.y = WALK_SPEED
else:
velocity.x = 0
velocity.y = 0
move_and_slide(velocity, Vector2(0, -1))
Global.current_camera.Update()
# if(interaction.get_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y)) == -1):
# interaction.clear()
# interaction.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), 0)
func InteractWithCell():
var plant_cell_mouse = plants_map.get_cell(int(world_position[0] / cell_size.x), int(world_position[1] / cell_size.y))
var plant_cell_character = plants_map.get_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y))
var background_cell = background_map.get_cell(int(world_position[0] / cell_size.x), int(world_position[1] / cell_size.y))
var interaction_cell = interaction.get_cell(int(world_position[0] / cell_size.x), int(world_position[1] / cell_size.y))
if plant_cell_mouse > 0 and plant_cell_mouse % 2 == 0:
Global.AddInventoryItem(3, 1)
plants_map.set_cell(int(world_position[0] / cell_size.x), int(world_position[1] / cell_size.y), (plant_cell_mouse-1))
AnimationOnInteraction(1)
elif plant_cell_character > 0 and plant_cell_character % 2 == 0:
Global.AddInventoryItem(3, 1)
plants_map.set_cell(int(self.position.x / cell_size.x), int(self.position.y / cell_size.y), (plant_cell_character-1))
AnimationOnInteraction(1)
func _interaction_process():
if Input.is_key_pressed(KEY_SPACE) or Input.is_mouse_button_pressed(BUTTON_LEFT):
world_position = get_global_mouse_position()
InteractWithCell()
func _input(event):
pass
func AnimationOnInteraction(Item):
print("Item = ", Item, " Animation")
var itemimage = TextureRect.new()
itemimage.texture = load("res://pictures/inventory_iconpictures/food_items/herbs/saffron.png")
itemimage.set_position(Vector2(randf()*20-40, randf()*40-20))
add_child(itemimage)
yield(get_tree().create_timer(1.0), "timeout")
remove_child(itemimage)
func _ready():
Global.player_inventory_items = Database.GetInventoryItems()

9
MiscCodes/Menu.gd Normal file
View File

@ -0,0 +1,9 @@
extends Node2D
func _ready():
pass # Replace with function body.
func _on_Btn_PlayGame_pressed():
Global.LoadSave()
Global.GoToScene("river_intersection_home_2")

16
MiscCodes/Menu_Buttons.gd Normal file
View File

@ -0,0 +1,16 @@
extends Button
# 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

View File

@ -0,0 +1,27 @@
extends Button
# 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_gui_input(event):
print(event)
if event == InputEventScreenTouch.CONNECT_ONESHOT:
get_tree().change_scene("res://river_intersection_home2.tscn")
# get_tree().change_scene("res://river_intersection_home2.tscn")
pass # Replace with function body.

14
MiscCodes/MiscButtons.gd Normal file
View File

@ -0,0 +1,14 @@
extends TouchScreenButton
#func _input(always):
func _physics_process(delta):
if Input.is_action_pressed("move_left") and Input.is_action_pressed("move_right"):
show()
elif Input.is_action_pressed("ui_end"):
hide()
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@ -0,0 +1,77 @@
extends Camera2D
onready var player = get_node("/root/Map1/Player")
onready var background_map = get_node("/root/Map1/background")
onready var screen_size = self.get_viewport_rect().size
func _ready():
calculate_bounds()
Global.current_camera = self
$dev_statistics.visible = Global.dev_stats
var once = true
var lockedPlayerCamera = false
var min_x = 0
var min_y = 0
var max_x = 0
var max_y = 0
var max_x_pixel = 0
var max_y_pixel = 0
#function that calculates the borders/bounds of the map
func calculate_bounds():
var used_cells = background_map.get_used_cells()
for pos in used_cells:
if pos.x < min_x:
min_x = int(pos.x)
elif pos.x > max_x:
max_x = int(pos.x)
if pos.y < min_y:
min_y = int(pos.y)
elif pos.y > max_y:
max_y = int(pos.y)
print(min_x,"-",max_x, " AND " ,min_y , "-" , max_y)
max_x_pixel = (max_x * 32)
max_y_pixel = (max_y * 32)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if(Global.dev_stats):
$dev_statistics/fps_stats.text = "FPS: " + str(Performance.get_monitor(Performance.TIME_FPS))
CameraToPlayer()
if once:
once = false
#AnimateMoveCamera(player.position, Vector2(player.position.x - 100,player.position.y - 10), "position", 2)
pass
func get_global_pos():
return Vector2(position.x, position.y)
#Move camera to position
func MoveCamera(x, y):
if x < int(screen_size.x / 2):
pass
else:
position.x = x
if y < int(screen_size.y / 2):
pass
else:
position.y = y
func _on_Tween_tween_completed(object, key):
print(object, key)
lockedPlayerCamera = false
func AnimateMoveCamera(source, destination, key, time):
var tween = get_node("/root/Map1/Tween")
lockedPlayerCamera = true
tween.interpolate_property(get_node("/root/Map1/Camera2D"), key, source, destination, time, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
func CameraToPlayer():
if lockedPlayerCamera == false:
MoveCamera(player.position.x, player.position.y)
func Update():
CameraToPlayer()

View File

@ -0,0 +1,6 @@
extends TouchScreenButton
onready var ShowInventory = Global.ShowInventory
func _input(always):
ShowInventory = 1;

View File

@ -0,0 +1,20 @@
extends TileMap
onready var player = get_node("/root/Map1/Player")
func _ready():
pass # Replace with function body.
func _get_cell_size():
return cell_size
func _unhandled_input(event):
var pl_pos = player.position
var pl_pos_tile = Vector2(pl_pos.x / cell_size.x, pl_pos.y / cell_size.y)
var pl_tile = get_cellv(pl_pos_tile)
if event == Input.action_press("map_interaction"):
if(pl_tile != -1):
set_cellv(pl_pos_tile, -1)
func _on_Inventory_pressed():
Global.GoToScene("inventory_screen")

19
MiscScenes/Control.tscn Normal file
View File

@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://arrow_down.png" type="Texture" id=1]
[sub_resource type="GradientTexture" id=1]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TouchScreenButton" type="TouchScreenButton" parent="."]
position = Vector2( 890.674, 223.37 )
scale = Vector2( 4.01662, 3.80615 )
normal = ExtResource( 1 )
pressed = SubResource( 1 )
action = "ui_right"

3
Other/Planten.tres Normal file
View File

@ -0,0 +1,3 @@
[gd_resource type="TileSet" format=2]
[resource]

36
Other/Planten.tsx Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.4" tiledversion="1.4.2" name="Planten" tilewidth="32" tileheight="32" tilecount="11" columns="0">
<tile id="0">
<image width="32" height="32" source="omgeving/Planten/raspberry_bush1.png"/>
</tile>
<tile id="1">
<image width="32" height="32" source="omgeving/Planten/raspberry_bush2.png"/>
</tile>
<tile id="2" probability="0.25">
<image width="32" height="32" source="omgeving/Planten/gras_met_rozen1.png"/>
</tile>
<tile id="3" probability="0.25">
<image width="32" height="32" source="omgeving/Planten/gras_met_rozen2.png"/>
</tile>
<tile id="4" probability="0.25">
<image width="32" height="32" source="omgeving/Planten/gras_met_rozen3.png"/>
</tile>
<tile id="5">
<image width="32" height="32" source="omgeving/Planten/gras1.png"/>
</tile>
<tile id="6">
<image width="32" height="32" source="omgeving/Planten/gras2.png"/>
</tile>
<tile id="7">
<image width="32" height="32" source="omgeving/Planten/gras3.png"/>
</tile>
<tile id="8">
<image width="32" height="32" source="omgeving/Planten/gras4.png"/>
</tile>
<tile id="9">
<image width="32" height="32" source="omgeving/Planten/gras5.png"/>
</tile>
<tile id="10">
<image width="32" height="32" source="omgeving/Planten/gras6.png"/>
</tile>
</tileset>

18
Other/Planten.tsx.import Normal file
View File

@ -0,0 +1,18 @@
[remap]
importer="vnen.tiled_tileset_importer"
type="TileSet"
valid=false
[deps]
source_file="res://Other/Planten.tsx"
[params]
custom_properties=true
tile_metadata=false
image_flags=7
embed_internal_images=false
save_tiled_properties=false
apply_offset=false
post_import_script=""

182
Other/Plants.tres Normal file
View File

@ -0,0 +1,182 @@
[gd_resource type="TileSet" load_steps=2 format=2]
[ext_resource path="res://pictures/tileset_images/Plants.png" type="Texture" id=1]
[resource]
0/name = "Plants.png 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 32, 0, 32, 32 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 32, 32 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ Vector3( 1, 0, 2 ) ]
0/autotile/z_index_map = [ Vector3( 0, 0, 1 ), Vector3( 1, 0, 1 ), Vector3( 2, 0, 2 ) ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
1/name = "Plants.png 1"
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( 32, 0, 32, 32 )
1/tile_mode = 0
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
2/name = "Plants.png 2"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 64, 0, 32, 32 )
2/tile_mode = 0
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0
3/name = "Plants.png 3"
3/texture = ExtResource( 1 )
3/tex_offset = Vector2( 0, 0 )
3/modulate = Color( 1, 1, 1, 1 )
3/region = Rect2( 96, 0, 32, 32 )
3/tile_mode = 0
3/occluder_offset = Vector2( 0, 0 )
3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape_one_way = false
3/shape_one_way_margin = 0.0
3/shapes = [ ]
3/z_index = 0
4/name = "Plants.png 4"
4/texture = ExtResource( 1 )
4/tex_offset = Vector2( 0, 0 )
4/modulate = Color( 1, 1, 1, 1 )
4/region = Rect2( 0, 0, 32, 32 )
4/tile_mode = 0
4/occluder_offset = Vector2( 0, 0 )
4/navigation_offset = Vector2( 0, 0 )
4/shape_offset = Vector2( 0, 0 )
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
4/shape_one_way = false
4/shape_one_way_margin = 0.0
4/shapes = [ ]
4/z_index = 0
5/name = "Plants.png 5"
5/texture = ExtResource( 1 )
5/tex_offset = Vector2( 0, 0 )
5/modulate = Color( 1, 1, 1, 1 )
5/region = Rect2( 128, 0, 32, 32 )
5/tile_mode = 0
5/occluder_offset = Vector2( 0, 0 )
5/navigation_offset = Vector2( 0, 0 )
5/shape_offset = Vector2( 0, 0 )
5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
5/shape_one_way = false
5/shape_one_way_margin = 0.0
5/shapes = [ ]
5/z_index = 0
6/name = "Plants.png 6"
6/texture = ExtResource( 1 )
6/tex_offset = Vector2( 0, 0 )
6/modulate = Color( 1, 1, 1, 1 )
6/region = Rect2( 160, 0, 32, 32 )
6/tile_mode = 0
6/occluder_offset = Vector2( 0, 0 )
6/navigation_offset = Vector2( 0, 0 )
6/shape_offset = Vector2( 0, 0 )
6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
6/shape_one_way = false
6/shape_one_way_margin = 0.0
6/shapes = [ ]
6/z_index = 0
7/name = "Plants.png 7"
7/texture = ExtResource( 1 )
7/tex_offset = Vector2( 0, 0 )
7/modulate = Color( 1, 1, 1, 1 )
7/region = Rect2( 192, 0, 32, 32 )
7/tile_mode = 0
7/occluder_offset = Vector2( 0, 0 )
7/navigation_offset = Vector2( 0, 0 )
7/shape_offset = Vector2( 0, 0 )
7/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
7/shape_one_way = false
7/shape_one_way_margin = 0.0
7/shapes = [ ]
7/z_index = 0
8/name = "Plants.png 8"
8/texture = ExtResource( 1 )
8/tex_offset = Vector2( 0, 0 )
8/modulate = Color( 1, 1, 1, 1 )
8/region = Rect2( 224, 0, 32, 32 )
8/tile_mode = 0
8/occluder_offset = Vector2( 0, 0 )
8/navigation_offset = Vector2( 0, 0 )
8/shape_offset = Vector2( 0, 0 )
8/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
8/shape_one_way = false
8/shape_one_way_margin = 0.0
8/shapes = [ ]
8/z_index = 0
9/name = "Plants.png 9"
9/texture = ExtResource( 1 )
9/tex_offset = Vector2( 0, 0 )
9/modulate = Color( 1, 1, 1, 1 )
9/region = Rect2( 256, 0, 32, 32 )
9/tile_mode = 0
9/occluder_offset = Vector2( 0, 0 )
9/navigation_offset = Vector2( 0, 0 )
9/shape_offset = Vector2( 0, 0 )
9/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
9/shape_one_way = false
9/shape_one_way_margin = 0.0
9/shapes = [ ]
9/z_index = 0
10/name = "Plants.png 10"
10/texture = ExtResource( 1 )
10/tex_offset = Vector2( 0, 0 )
10/modulate = Color( 1, 1, 1, 1 )
10/region = Rect2( 288, 0, 32, 32 )
10/tile_mode = 0
10/occluder_offset = Vector2( 0, 0 )
10/navigation_offset = Vector2( 0, 0 )
10/shape_offset = Vector2( 0, 0 )
10/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
10/shape_one_way = false
10/shape_one_way_margin = 0.0
10/shapes = [ ]
10/z_index = 0
11/name = "Plants.png 11"
11/texture = ExtResource( 1 )
11/tex_offset = Vector2( 0, 0 )
11/modulate = Color( 1, 1, 1, 1 )
11/region = Rect2( 320, 0, 32, 32 )
11/tile_mode = 0
11/occluder_offset = Vector2( 0, 0 )
11/navigation_offset = Vector2( 0, 0 )
11/shape_offset = Vector2( 0, 0 )
11/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
11/shape_one_way = false
11/shape_one_way_margin = 0.0
11/shapes = [ ]
11/z_index = 0

202
Other/Vloer.tres Normal file
View File

@ -0,0 +1,202 @@
[gd_resource type="TileSet" load_steps=2 format=2]
[ext_resource path="res://omgeving/vloer32x32/TilesetGodotVloer.png" type="Texture" id=1]
[resource]
0/name = "Vloer 0"
0/texture = ExtResource( 1 )
0/tex_offset = Vector2( 0, 0 )
0/modulate = Color( 1, 1, 1, 1 )
0/region = Rect2( 0, 0, -1, -1 )
0/tile_mode = 2
0/autotile/icon_coordinate = Vector2( 0, 0 )
0/autotile/tile_size = Vector2( 32, 32 )
0/autotile/spacing = 0
0/autotile/occluder_map = [ ]
0/autotile/navpoly_map = [ ]
0/autotile/priority_map = [ ]
0/autotile/z_index_map = [ ]
0/occluder_offset = Vector2( 0, 0 )
0/navigation_offset = Vector2( 0, 0 )
0/shape_offset = Vector2( 0, 0 )
0/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
0/shape_one_way = false
0/shape_one_way_margin = 0.0
0/shapes = [ ]
0/z_index = 0
1/name = "TilesetGodotVloer.png 1"
1/texture = ExtResource( 1 )
1/tex_offset = Vector2( 0, 0 )
1/modulate = Color( 1, 1, 1, 1 )
1/region = Rect2( -32, 0, 32, 32 )
1/tile_mode = 1
1/autotile/bitmask_mode = 0
1/autotile/bitmask_flags = [ ]
1/autotile/icon_coordinate = Vector2( 0, 0 )
1/autotile/tile_size = Vector2( 32, 32 )
1/autotile/spacing = 0
1/autotile/occluder_map = [ ]
1/autotile/navpoly_map = [ ]
1/autotile/priority_map = [ ]
1/autotile/z_index_map = [ ]
1/occluder_offset = Vector2( 0, 0 )
1/navigation_offset = Vector2( 0, 0 )
1/shape_offset = Vector2( 0, 0 )
1/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
1/shape_one_way = false
1/shape_one_way_margin = 0.0
1/shapes = [ ]
1/z_index = 0
2/name = "TilesetGodotVloer.png 2"
2/texture = ExtResource( 1 )
2/tex_offset = Vector2( 0, 0 )
2/modulate = Color( 1, 1, 1, 1 )
2/region = Rect2( 0, 0, 176, 176 )
2/tile_mode = 1
2/autotile/bitmask_mode = 0
2/autotile/bitmask_flags = [ ]
2/autotile/icon_coordinate = Vector2( 0, 0 )
2/autotile/tile_size = Vector2( 32, 32 )
2/autotile/spacing = 0
2/autotile/occluder_map = [ ]
2/autotile/navpoly_map = [ ]
2/autotile/priority_map = [ ]
2/autotile/z_index_map = [ ]
2/occluder_offset = Vector2( 0, 0 )
2/navigation_offset = Vector2( 0, 0 )
2/shape_offset = Vector2( 0, 0 )
2/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
2/shape_one_way = false
2/shape_one_way_margin = 0.0
2/shapes = [ ]
2/z_index = 0
3/name = "TilesetGodotVloer.png 3"
3/texture = ExtResource( 1 )
3/tex_offset = Vector2( 0, 0 )
3/modulate = Color( 1, 1, 1, 1 )
3/region = Rect2( 352, 0, 176, 176 )
3/tile_mode = 1
3/autotile/bitmask_mode = 0
3/autotile/bitmask_flags = [ ]
3/autotile/icon_coordinate = Vector2( 0, 0 )
3/autotile/tile_size = Vector2( 176, 176 )
3/autotile/spacing = 0
3/autotile/occluder_map = [ ]
3/autotile/navpoly_map = [ ]
3/autotile/priority_map = [ ]
3/autotile/z_index_map = [ ]
3/occluder_offset = Vector2( 0, 0 )
3/navigation_offset = Vector2( 0, 0 )
3/shape_offset = Vector2( 0, 0 )
3/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
3/shape_one_way = false
3/shape_one_way_margin = 0.0
3/shapes = [ ]
3/z_index = 0
4/name = "TilesetGodotVloer.png 4"
4/texture = ExtResource( 1 )
4/tex_offset = Vector2( 0, 0 )
4/modulate = Color( 1, 1, 1, 1 )
4/region = Rect2( 0, 0, 176, 176 )
4/tile_mode = 1
4/autotile/bitmask_mode = 0
4/autotile/bitmask_flags = [ ]
4/autotile/icon_coordinate = Vector2( 0, 0 )
4/autotile/tile_size = Vector2( 176, 176 )
4/autotile/spacing = 0
4/autotile/occluder_map = [ ]
4/autotile/navpoly_map = [ ]
4/autotile/priority_map = [ ]
4/autotile/z_index_map = [ ]
4/occluder_offset = Vector2( 0, 0 )
4/navigation_offset = Vector2( 0, 0 )
4/shape_offset = Vector2( 0, 0 )
4/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
4/shape_one_way = false
4/shape_one_way_margin = 0.0
4/shapes = [ ]
4/z_index = 0
5/name = "TilesetGodotVloer.png 5"
5/texture = ExtResource( 1 )
5/tex_offset = Vector2( 0, 0 )
5/modulate = Color( 1, 1, 1, 1 )
5/region = Rect2( 176, 0, 176, 176 )
5/tile_mode = 0
5/occluder_offset = Vector2( 0, 0 )
5/navigation_offset = Vector2( 0, 0 )
5/shape_offset = Vector2( 0, 0 )
5/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
5/shape_one_way = false
5/shape_one_way_margin = 0.0
5/shapes = [ ]
5/z_index = 0
6/name = "TilesetGodotVloer.png 6"
6/texture = ExtResource( 1 )
6/tex_offset = Vector2( 0, 0 )
6/modulate = Color( 1, 1, 1, 1 )
6/region = Rect2( 352, 0, 176, 176 )
6/tile_mode = 0
6/occluder_offset = Vector2( 0, 0 )
6/navigation_offset = Vector2( 0, 0 )
6/shape_offset = Vector2( 0, 0 )
6/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
6/shape_one_way = false
6/shape_one_way_margin = 0.0
6/shapes = [ ]
6/z_index = 0
7/name = "TilesetGodotVloer.png 7"
7/texture = ExtResource( 1 )
7/tex_offset = Vector2( 0, 0 )
7/modulate = Color( 1, 1, 1, 1 )
7/region = Rect2( 528, 0, 176, 176 )
7/tile_mode = 0
7/occluder_offset = Vector2( 0, 0 )
7/navigation_offset = Vector2( 0, 0 )
7/shape_offset = Vector2( 0, 0 )
7/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
7/shape_one_way = false
7/shape_one_way_margin = 0.0
7/shapes = [ ]
7/z_index = 0
8/name = "TilesetGodotVloer.png 8"
8/texture = ExtResource( 1 )
8/tex_offset = Vector2( 0, 0 )
8/modulate = Color( 1, 1, 1, 1 )
8/region = Rect2( 704, 0, 176, 176 )
8/tile_mode = 0
8/occluder_offset = Vector2( 0, 0 )
8/navigation_offset = Vector2( 0, 0 )
8/shape_offset = Vector2( 0, 0 )
8/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
8/shape_one_way = false
8/shape_one_way_margin = 0.0
8/shapes = [ ]
8/z_index = 0
9/name = "TilesetGodotVloer.png 9"
9/texture = ExtResource( 1 )
9/tex_offset = Vector2( 0, 0 )
9/modulate = Color( 1, 1, 1, 1 )
9/region = Rect2( 880, 0, 176, 176 )
9/tile_mode = 0
9/occluder_offset = Vector2( 0, 0 )
9/navigation_offset = Vector2( 0, 0 )
9/shape_offset = Vector2( 0, 0 )
9/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
9/shape_one_way = false
9/shape_one_way_margin = 0.0
9/shapes = [ ]
9/z_index = 0
10/name = "TilesetGodotVloer.png 10"
10/texture = ExtResource( 1 )
10/tex_offset = Vector2( 0, 0 )
10/modulate = Color( 1, 1, 1, 1 )
10/region = Rect2( 1056, 0, 176, 176 )
10/tile_mode = 0
10/occluder_offset = Vector2( 0, 0 )
10/navigation_offset = Vector2( 0, 0 )
10/shape_offset = Vector2( 0, 0 )
10/shape_transform = Transform2D( 1, 0, 0, 1, 0, 0 )
10/shape_one_way = false
10/shape_one_way_margin = 0.0
10/shapes = [ ]
10/z_index = 0

BIN
Other/default_env.tres Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
[gd_resource type="DynamicFontData" format=2]
[resource]
resource_local_to_scene = true
font_path = "res://ring_of_races_font.ttf"

Binary file not shown.

BIN
Ring of Races_v03_GLE2.apk Normal file

Binary file not shown.

View File

@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=2] [gd_scene load_steps=3 format=2]
[ext_resource path="res://Vloer.tres" type="TileSet" id=1] [ext_resource path="res://Other/Vloer.tres" type="TileSet" id=1]
[ext_resource path="res://Planten.tres" type="TileSet" id=2] [ext_resource path="res://Other/Planten.tres" type="TileSet" id=2]
[node name="Node2D" type="Node2D"] [node name="Node2D" type="Node2D"]
position = Vector2( 109, 0 ) position = Vector2( 109, 0 )

View File

@ -1,7 +1,7 @@
extends Node extends Node
const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns") const SQLite = preload("res://addons/godot-sqlite/bin/gdsqlite.gdns")
var path = "res://Storage/World1.db" var path = "user://storage.db"
var db_name = "RingOfRaces" var db_name = "RingOfRaces"
var db = null var db = null
var verbose = true var verbose = true
@ -37,7 +37,11 @@ func OpenConnection():
self.db.path = path self.db.path = path
self.db.verbose_mode = verbose self.db.verbose_mode = verbose
var create = false var create = false
print(path)
# This does not seem to work. The file is in the right place, but being recreated everytime. The file is findable in Res:// and C:/ .. But not after the user folder
if !file.file_exists(path): if !file.file_exists(path):
print("File not existing, so creating new db")
create = true create = true
self.db.open_db() self.db.open_db()
if create: if create:
@ -53,8 +57,9 @@ func GetInventoryItems():
ret = db.select_rows("player_inventory", "",["*"]) ret = db.select_rows("player_inventory", "",["*"])
return ret return ret
func SaveInventory(inventory): func SaveInventory(player_inventory_items):
if(inventory == null or len(inventory) != 40): print("Now on inventory save file")
if(player_inventory_items == null or len(player_inventory_items) != 40):
Global.Log("Bad inventory save!", 3) Global.Log("Bad inventory save!", 3)
return return
OpenConnectionIfClosed() OpenConnectionIfClosed()

View File

@ -7,7 +7,7 @@ custom_features=""
export_filter="all_resources" export_filter="all_resources"
include_filter="" include_filter=""
exclude_filter="" exclude_filter=""
export_path="./Ring of Races_v03.apk" export_path="./Ring of Races_v03_GLE2.apk"
patch_list=PoolStringArray( ) patch_list=PoolStringArray( )
script_export_mode=1 script_export_mode=1
script_encryption_key="" script_encryption_key=""

39
modules/godot_remote/.gitignore vendored Normal file
View File

@ -0,0 +1,39 @@
# SConstruct
*.dblite
__pycache__
*.pyc
# Visual Studio Cache
.vs/
# VSCode Cache
.vscode/
# Binaries
*.obj
*.iobj
*.so
*.dll
*.o
*.dylib
*.pdb
*.ipdb
*.ilk
*.exe
*.exp
*.lib
*.vcxproj.filters
*.vcxproj.user
*.os
*.out
api.json
.import/
.mono/
obj/
libs/
bin/
# exist only for testing
test.gd
godot_remote_client/AssetsInSuperSecureAndUn1queF0lder/Textures/SVG/*.png

3
modules/godot_remote/.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/GodotNativeTools/godot-cpp

View File

@ -0,0 +1,47 @@
# Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := godot-cpp
ifeq ($(TARGET_ARCH_ABI),x86)
LOCAL_SRC_FILES := godot-cpp/bin/libgodot-cpp.android.release.x86.a
endif
ifeq ($(TARGET_ARCH_ABI),x86_64)
LOCAL_SRC_FILES := godot-cpp/bin/libgodot-cpp.android.release.x86_64.a
endif
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_SRC_FILES := godot-cpp/bin/libgodot-cpp.android.release.armv7.a
endif
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
LOCAL_SRC_FILES := godot-cpp/bin/libgodot-cpp.android.release.arm64v8.a
endif
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := godot_remote.android.release.$(TARGET_ARCH_ABI)
LOCAL_CPPFLAGS := -std=c++14
LOCAL_CPP_FEATURES := rtti exceptions
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := \
godot_remote/GodotRemote.cpp \
godot_remote/GRClient.cpp \
godot_remote/GRDevice.cpp \
godot_remote/GRInputData.cpp \
godot_remote/GRNotifications.cpp \
godot_remote/GRPacket.cpp \
godot_remote/GRResources.cpp \
godot_remote/GRServer.cpp \
godot_remote/GRUtils.cpp \
godot_remote/jpge.cpp \
godot_remote/register_types.cpp
LOCAL_C_INCLUDES := \
godot-cpp/godot-headers \
godot-cpp/include/ \
godot-cpp/include/core \
godot-cpp/include/gen \
LOCAL_STATIC_LIBRARIES := godot-cpp
include $(BUILD_SHARED_LIBRARY)

View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GodotRemoteGDNative", "GodotRemoteGDNative_only_for_developing.vcxproj", "{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug|x64 = debug|x64
debug|x86 = debug|x86
release|x64 = release|x64
release|x86 = release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.debug|x64.ActiveCfg = debug|x64
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.debug|x64.Build.0 = debug|x64
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.debug|x86.ActiveCfg = debug|Win32
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.debug|x86.Build.0 = debug|Win32
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.release|x64.ActiveCfg = release|x64
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.release|x64.Build.0 = release|x64
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.release|x86.ActiveCfg = release|Win32
{4D452F2C-8FBB-476B-A990-1E9E5DB93D32}.release|x86.Build.0 = release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2D6E9625-5E11-4AF3-A331-3B18E40A974D}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,215 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="debug|Win32">
<Configuration>debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release|Win32">
<Configuration>release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="debug|x64">
<Configuration>debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="release|x64">
<Configuration>release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{4d452f2c-8fbb-476b-a990-1e9e5db93d32}</ProjectGuid>
<RootNamespace>GodotRemoteGDNative</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>GodotRemoteGDNative</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<TargetName>godot_remote.windows.$(Configuration).$(PlatformArchitecture)</TargetName>
<OutDir>$(SolutionDir)\bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
<LibraryPath>$(ProjectDir)godot-cpp\bin;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir)godot-cpp\include;$(ProjectDir)godot-cpp\godot_headers;$(ProjectDir)godot-cpp\include\gen;$(ProjectDir)godot-cpp\include\core;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
<LinkIncremental>false</LinkIncremental>
<TargetName>godot_remote.windows.$(Configuration).$(PlatformArchitecture)</TargetName>
<OutDir>$(SolutionDir)\bin\</OutDir>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
<LibraryPath>$(ProjectDir)godot-cpp\bin;$(LibraryPath)</LibraryPath>
<IncludePath>$(ProjectDir)godot-cpp\include;$(ProjectDir)godot-cpp\godot_headers;$(ProjectDir)godot-cpp\include\gen;$(ProjectDir)godot-cpp\include\core;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
<IncludePath>$(ProjectDir)godot-cpp\include;$(ProjectDir)godot-cpp\godot-headers;$(ProjectDir)godot-cpp\include\gen;$(ProjectDir)godot-cpp\include\core;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)godot-cpp\bin;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)\bin\</OutDir>
<TargetName>godot_remote.windows.$(Configuration).$(PlatformArchitecture)</TargetName>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)godot-cpp\include;$(ProjectDir)godot-cpp\godot-headers;$(ProjectDir)godot-cpp\include\gen;$(ProjectDir)godot-cpp\include\core;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)godot-cpp\bin;$(LibraryPath)</LibraryPath>
<OutDir>$(SolutionDir)\bin\</OutDir>
<TargetName>godot_remote.windows.$(Configuration).$(PlatformArchitecture)</TargetName>
<IntDir>$(SolutionDir)obj\$(PlatformTarget)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;GDNATIVE_LIBRARY;TOOLS_ENABLED;DEBUG_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WholeProgramOptimization>true</WholeProgramOptimization>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgodot-cpp.windows.$(Configuration).$(PlatformArchitecture).lib;</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;GDNATIVE_LIBRARY;TOOLS_ENABLED;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>libgodot-cpp.windows.$(Configuration).$(PlatformArchitecture).lib;</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<PreprocessorDefinitions>WIN64;_DEBUG;GDNATIVE_LIBRARY;TOOLS_ENABLED;DEBUG_ENABLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>Sync</ExceptionHandling>
<WholeProgramOptimization>true</WholeProgramOptimization>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<LanguageStandard>stdcpp14</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libgodot-cpp.windows.$(Configuration).$(PlatformArchitecture).lib;</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>
</FunctionLevelLinking>
<IntrinsicFunctions>false</IntrinsicFunctions>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN64;GDNATIVE_LIBRARY;TOOLS_ENABLED;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ExceptionHandling>Sync</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>NotSet</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>false</GenerateDebugInformation>
<AdditionalDependencies>libgodot-cpp.windows.$(Configuration).$(PlatformArchitecture).lib;</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="godot_remote\GodotRemote.cpp" />
<ClCompile Include="godot_remote\GRClient.cpp" />
<ClCompile Include="godot_remote\GRDevice.cpp" />
<ClCompile Include="godot_remote\GRInputData.cpp" />
<ClCompile Include="godot_remote\GRNotifications.cpp" />
<ClCompile Include="godot_remote\GRPacket.cpp" />
<ClCompile Include="godot_remote\GRResources.cpp" />
<ClCompile Include="godot_remote\GRServer.cpp" />
<ClCompile Include="godot_remote\GRUtils.cpp" />
<ClCompile Include="godot_remote\jpge.cpp" />
<ClCompile Include="godot_remote\register_types.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="godot_remote\GodotRemote.h" />
<ClInclude Include="godot_remote\GRClient.h" />
<ClInclude Include="godot_remote\GRDevice.h" />
<ClInclude Include="godot_remote\GRInputData.h" />
<ClInclude Include="godot_remote\GRNotifications.h" />
<ClInclude Include="godot_remote\GRPacket.h" />
<ClInclude Include="godot_remote\GRResources.h" />
<ClInclude Include="godot_remote\GRServer.h" />
<ClInclude Include="godot_remote\GRUtils.h" />
<ClInclude Include="godot_remote\GRVersion.h" />
<ClInclude Include="godot_remote\jpge.h" />
<ClInclude Include="godot_remote\register_types.h" />
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
<None Include="SConstruct" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Close_icon.png-55bdce32d084d5e5f806a4a5d837ea4b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Close_icon.png"
dest_files=[ "res://.import/Close_icon.png-55bdce32d084d5e5f806a4a5d837ea4b.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m3.7578 2.3438-1.4141 1.4141 4.2422 4.2422-4.2422 4.2422 1.4141 1.4141 4.2422-4.2422 4.2422 4.2422 1.4141-1.4141-4.2422-4.2422 4.2422-4.2422-1.4141-1.4141-4.2422 4.2422z" fill="#e0e0e0"/></svg>

After

Width:  |  Height:  |  Size: 285 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Close_icon.svg-eb6caf74ca6969dc2a8ada8a0b98f1d5.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Close_icon.svg"
dest_files=[ "res://.import/Close_icon.svg-eb6caf74ca6969dc2a8ada8a0b98f1d5.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Connected_icon.png-e646ca1b6ff2d860a81b4e89f1619f50.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Connected_icon.png"
dest_files=[ "res://.import/Connected_icon.png-e646ca1b6ff2d860a81b4e89f1619f50.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zm3.293 3.877 1.4141 1.4141-5.707 5.709-3.707-3.709 1.4141-1.4141 2.293 2.293z" fill="#45ff8b"/></svg>

After

Width:  |  Height:  |  Size: 255 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Connected_icon.svg-91c77637b50d393da88a03a3c4a31090.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Connected_icon.svg"
dest_files=[ "res://.import/Connected_icon.svg-91c77637b50d393da88a03a3c4a31090.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 472 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Disconnected_icon.png-ec94adf71229facb1d8116765a16fdcd.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Disconnected_icon.png"
dest_files=[ "res://.import/Disconnected_icon.png-ec94adf71229facb1d8116765a16fdcd.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 1c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zm-2.8281 2.7578 2.8281 2.8281 2.8281-2.8281 1.4141 1.4141-2.8281 2.8281 2.8281 2.8281-1.4141 1.4141-2.8281-2.8281-2.8281 2.8281-1.4141-1.4141 2.8281-2.8281-2.8281-2.8281 1.4141-1.4141z" fill="#ff5d5d"/></svg>

After

Width:  |  Height:  |  Size: 362 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Disconnected_icon.svg-8ac048c62e1e64861e3552cc93c93d53.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Disconnected_icon.svg"
dest_files=[ "res://.import/Disconnected_icon.svg-8ac048c62e1e64861e3552cc93c93d53.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Error_icon.png-3f424e587d3cb0431a257db9d2ea385d.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Error_icon.png"
dest_files=[ "res://.import/Error_icon.png-3f424e587d3cb0431a257db9d2ea385d.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1 @@
<svg height="8" viewBox="0 0 8 8" width="8" xmlns="http://www.w3.org/2000/svg"><rect fill="#ff5d5d" height="8" ry="4" width="8"/></svg>

After

Width:  |  Height:  |  Size: 135 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Error_icon.svg-b652e469ed1378493bd3d78653637703.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Error_icon.svg"
dest_files=[ "res://.import/Error_icon.svg-b652e469ed1378493bd3d78653637703.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Warning_icon.png-3b98f3fb52d2ad40673fed73dff42ea6.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Warning_icon.png"
dest_files=[ "res://.import/Warning_icon.png-3b98f3fb52d2ad40673fed73dff42ea6.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1 @@
<svg height="8" viewBox="0 0 8 8" width="8" xmlns="http://www.w3.org/2000/svg"><rect fill="#ffdd65" height="8" ry="4" width="8"/></svg>

After

Width:  |  Height:  |  Size: 135 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Warning_icon.svg-d7cff469ecb7ebc653295abfc7c04800.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Icons/Warning_icon.svg"
dest_files=[ "res://.import/Warning_icon.svg-d7cff469ecb7ebc653295abfc7c04800.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/NoSignal.png-27de0974ec5cc467f5b572d6723aefde.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/NoSignal/NoSignal.png"
dest_files=[ "res://.import/NoSignal.png-27de0974ec5cc467f5b572d6723aefde.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/NoSignalVertical.png-9f616e3a19712373e669287fcd3cf0a9.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/NoSignal/NoSignalVertical.png"
dest_files=[ "res://.import/NoSignalVertical.png-9f616e3a19712373e669287fcd3cf0a9.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/mobile_settings.png-796e6d8df2995de699cde1a8e2870e85.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Screenshots/mobile_settings.png"
dest_files=[ "res://.import/mobile_settings.png-796e6d8df2995de699cde1a8e2870e85.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/settings.png-f8eef4d7d1f2459d5277f22ea0ef6cb3.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://modules/godot_remote/Images/Screenshots/settings.png"
dest_files=[ "res://.import/settings.png-f8eef4d7d1f2459d5277f22ea0ef6cb3.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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020-2021 DmitriySalnikov
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, andor 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.

View File

@ -0,0 +1,723 @@
# Godot Remote
This is cross platform native module for [Godot Engine](https://github.com/godotengine/godot) v3 for control apps and games over WiFi or ADB.
If you are developing on a non-touch device, this module is the best way to quickly test touch input or test mobile sensors data.
[Video Demonstration](https://youtu.be/LbFcQnS3z3E)
[Custom Packets Demo](https://youtu.be/RmhppDWZZk8)
## Support
[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/I2I53VZ2D)
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://paypal.me/dmitriysalnikov)
## Compiling the Module
### As a module
1. [configure environment](https://docs.godotengine.org/en/3.2/development/compiling/index.html) to build editor for your platform (you need to clone [3.2 branch](https://github.com/godotengine/godot/tree/3.2) not master)
2. copy ```godot_remote``` folder to the ```modules/``` directory or make [symlink](https://en.wikipedia.org/wiki/Symbolic_link)
3. compile engine with instructions from documentation above (e.g. ```scons p=windows tools=yes -j[place here count of your CPU threads]```)
4. run ```bin/godot[based on config]```.
If everything compiles successfully, you'll find the new category in project settings ```Debug/Godot Remote``` where you can configure server.
![Settings](Images/Screenshots/settings.png)
### As a GDNative library
1. [Configure environment](https://docs.godotengine.org/en/3.2/development/compiling/index.html) to build editor for your platform
2. Generate api.json for GDNative api. ```bin/godot --gdnative-generate-json-api api.json```
3. Copy api.json to the root directory of this repository
4. Compile godot-cpp (e.g. in godot-cpp directory run ```scons generate_bindings=true platform=windows target=release bits=64 -j8 ../api.json```)
5. Compile module for your platform (Available platforms: windows, osx, linux, ios, android. Tested platforms: windows, linux, android)
1. For android: Run in root directory ```[path to your android ndk root dir]/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_PLATFORM=android-21```
2. For all other platforms: ```scons platform=windows target=release -j8```
6. Use produced library in ```bin/```
GDNative has limitations so here ```GodotRemote``` is not a singleton and you need to create autoload scene with attached NativeScript for ```GodotRemote``` class. Also there is no any settings in ```Debug/Godot Remote```.
Enum constants in this version changed too (see [API Reference] )
**Currently, the GDNative version does not support the assignment of sensor data, so the editor will not support accelerometer, gyroscope, etc.
Also, this version may crash at a random moment.**
If GDNative becomes more stable, I will add the necessary code to easily integrate this module into any project, but now it just works.. sometimes.
### Additional parameters
Also module has additional compilation parameters for scons script
1. ```godot_remote_no_default_resources``` (yes/no) default no - compile with or without default resources
2. ```godot_remote_disable_server``` (yes/no) default no - do not include server code
3. ```godot_remote_disable_client``` (yes/no) default no - do not include client code
## Download
Precompiled binaries can be found on [GitHub Releases](https://github.com/DmitriySalnikov/GodotRemote/releases) page
### Mobile app
On releases page you can found precompiled mobile app but also it can be downloaded from [Google Play](https://play.google.com/store/apps/details?id=com.dmitriysalnikov.godotremote)
## Configure Mobile App
To open settings menu you need to touch the screen with 5 fingers at once.
Then you'll see this settings menu:
![Settings](Images/Screenshots/mobile_settings.png)
**Important:** after entering server address you should apply it by pressing `Set Type and Address` or `Set Type and Port`
## Custom client
If need to support other platforms or you need a specific version of module integrated to the client app, you can build client from source code placed [here](godot_remote_client).
If you don't want to use my client app you can check the [example client project](examples/simple_client) and build your own client.
Or you can donate me some money with request to buy iPhone and adapt a client for it 🙂
## API Reference
Methods will be declared follows this template:
```python
return_type function_name([arg_name1 : type [= defalut value]][, arg_name2 : type [= defalut value]])
```
**Important:** All enums in GDNative version is exposed in GodotRemote class because of limitations.
For example, if you want to use StreamState.STREAM_ACTIVE from GRClient you need to get property GRClient_STREAM_ACTIVE of GodotRemote __object__
```python
# Godot module:
GRClient.STREAM_ACTIVE:
# GDNative
# *GodotRemote is autoload scene with attached NativeScript
GodotRemote.GRClient_STREAM_ACTIVE
```
### GodotRemote
Main class of module.
```python
# --- Properties
# Canvas layer that shows notifications
# type int, default 128
notifications_layer
# Notifications position on screen
# type GRNotifications.NotificationsPosition, default TC
notifications_position
# Is notifications enabled
# type bool, default true
notifications_enabled
# Base duration for showing notifications
# type float, default 3.0
notifications_duration
# Notifcations style
# type GRNotificationStyle
notifications_style
# --- Methods
# Notifications
# Adds or fully update existing notification
# @title: Notification title
# @text: Text of notification
# @notification_icon: Notification icon from enum NotificationIcon
# @update_existing: Updates existing notification
# @duration_multiplier: Multiply base notifications duration
void add_notification(title: String, text: String, notification_icon: GRNotifications.NotificationIcon = 0, update_existing: bool = true, duration_multiplier: float = 1.0)
# Adds new notification or append text to existing notification
# @title: Notification title
# @text: Text of notification
# @icon: Notification icon from enum NotificationIcon
# @add_to_new_line: Adds text to new line or adds to current line
void add_notification_or_append_string(title: String, text: String, icon: GRNotifications.NotificationIcon, add_to_new_line: bool = true, duration_multiplier: float = 1.0)
# Adds notification or update one line of notification text
# @title: Notification title
# @id: Line ID
# @text: Text of notification
# @icon: Notification icon from enum NotificationIcon
# @duration_multiplier: Multiply base notifications duration
void add_notification_or_update_line(title: String, id: String, text: String, icon: GRNotifications.NotificationIcon, duration_multiplier: float = 1.0)
# Clear all notifications
void clear_notifications()
# Get notifications list
# @return list of all visible notifications
Array get_all_notifications()
# Get notification with specified title or null
# @title: Notification title
# @return matched notification
GRNotificationPanel get_notification(title: String)
# Get all notifications with specified title
# @title: Notification title
# @return list of visible notifications
Array get_notifications_with_title(title: String)
# Remove notifications with specified title
# @title: Notifications title
# @is_all_entries: Delete all notifications with @title if true
void remove_notification(title: String, is_all_entries: bool = true)
# Remove exact notification by reference
# @notification: Notification reference
void remove_notification_exact(notification: Node)
# Client/Server
# Create device: client or server
# @device_type: Type of device
# @return true if device created successful
bool create_remote_device(device_type: GodotRemote.DeviceType = 0)
# Start device
# @return true if device valid
bool start_remote_device()
# Create and start device
# @device_type: Type of device
void create_and_start_device(device_type: GodotRemote.DeviceType = 0)
# Remove and delete currently working device
# @return true if succeed
bool remove_remote_device()
# Get device
# @return client, server or null
GRDevice get_device()
# Utility functions
# Not exposed to GDScript fuctions from Input class
# And currently not available in GDNative
void set_accelerometer(value: Vector3)
void set_gravity(value: Vector3)
void set_gyroscope(value: Vector3)
void set_magnetometer(value: Vector3)
# Set GodotRemote log level
# @level: Level of logging
void set_log_level(level: LogLevel)
# Get GodotRemote module version
# @return module version in format "MAJOR.MINOR.BUILD"
String get_version()
# --- Signals
# Device added
device_added()
# Device removed
device_removed()
# --- Enumerations
DeviceType:
DEVICE_AUTO = 0
DEVICE_SERVER = 1
DEVICE_CLIENT = 2
LogLevel:
LL_NONE = 4
LL_DEBUG = 0
LL_NORMAL = 1
LL_WARNING = 2
LL_ERROR = 3
```
### GRNotifications
Container for all notifications
```python
# --- Signals
# Called when a single notification is added
notification_added(title: String, text: String)
# Called when a single notification is removed
notification_removed(title: String, is_cleared: bool)
# Called when all notifications are cleared
notifications_cleared()
# Called when notifications are enabled or disabled
notifications_toggled(is_enabled: bool)
# --- Enumerations
NotificationIcon:
ICON_NONE = 0
ICON_ERROR = 1
ICON_WARNING = 2
ICON_SUCCESS = 3
ICON_FAIL = 4
NotificationsPosition:
TOP_LEFT = 0
TOP_CENTER = 1
TOP_RIGHT = 2
BOTTOM_LEFT = 3
BOTTOM_CENTER = 4
BOTTOM_RIGHT = 5
```
### GRNotificationStyle
Helper class to store parameters of notifications style
```python
# --- Properties
# Style of background notifications panel
# type StyleBox
panel_style
# Theme for notification close button
# type Theme
close_button_theme
# Close button icon texture
# type Texture
close_button_icon
# Notification title font
# type Font
title_font
# Notification text font
# type Font
text_font
# --- Methods
# Get notification icon from this style
# @notification_icon: Notfication icon id
# @return icon texture of null
Texture get_notification_icon(notification_icon: GRNotifications.NotificationIcon)
# Set notification icon in this style
# @notification_icon: Notfication icon id
# @icon_texture: Icon texture
void set_notification_icon(notification_icon: GRNotifications.NotificationIcon, icon_texture: Texture)
```
### GRInputData
Container for all InputEvents
```python
# --- Enumerations
InputType:
_NoneIT = 0
_InputDeviceSensors = 1
_InputEvent = 64
_InputEventAction = 65
_InputEventGesture = 66
_InputEventJoypadButton = 67
_InputEventJoypadMotion = 68
_InputEventKey = 69
_InputEventMagnifyGesture = 70
_InputEventMIDI = 71
_InputEventMouse = 72
_InputEventMouseButton = 73
_InputEventMouseMotion = 74
_InputEventPanGesture = 75
_InputEventScreenDrag = 76
_InputEventScreenTouch = 77
_InputEventWithModifiers = 78
_InputEventMAX = 79
```
### GRPacket
The basic data type used to exchange information between the client and the server
```python
# --- Enumerations
PacketType:
NonePacket = 0
SyncTime = 1
ImageData = 2
InputData = 3
ServerSettings = 4
MouseModeSync = 5
CustomInputScene = 6
ClientStreamOrientation = 7
ClientStreamAspect = 8
CustomUserData = 9
Ping = 128
Pong = 192
```
### GRDevice
Base class for client and server
```python
# --- Properties
# Connection port
# type int, default 52341
port
# --- Methods
# Send user data to remote device
# @packet_id: any data to identify your packet
# @user_data: any data to send to remote device
# @full_objects: flag for full serialization of objects, possibly with their executable code. For more info check Godot's PacketPeer.put_var() and PacketPeer.get_var()
void send_user_data(packet_id: Variant, user_data: Variant, full_objects: bool = false)
# Get average FPS
# @return average FPS
float get_avg_fps()
# Get minimum FPS
# @return minimum FPS
float get_min_fps()
# Get maximum FPS
# @return maximum FPS
float get_max_fps()
# Get average ping
# @return average ping
float get_avg_ping()
# Get minimum ping
# @return minimum ping
float get_min_ping()
# Get maximum ping
# @return maximum ping
float get_max_ping()
# Get device status
WorkingStatus get_status()
# Start device
void start()
# Stop device
void stop()
# --- Signals
# Device status changed
status_changed(status: GRDevice.WorkingStatus)
# User data received from a remote device
user_data_received(packet_id: Variant, user_data: Variant)
# --- Enumerations
ImageCompressionType:
COMPRESSION_UNCOMPRESSED = 0
COMPRESSION_JPG = 1
COMPRESSION_PNG = 2
Subsampling:
SUBSAMPLING_Y_ONLY = 0
SUBSAMPLING_H1V1 = 1
SUBSAMPLING_H2V1 = 2
SUBSAMPLING_H2V2 = 3
TypesOfServerSettings:
SERVER_SETTINGS_USE_INTERNAL = 0
SERVER_SETTINGS_VIDEO_STREAM_ENABLED = 1
SERVER_SETTINGS_COMPRESSION_TYPE = 2
SERVER_SETTINGS_JPG_QUALITY = 3
SERVER_SETTINGS_SKIP_FRAMES = 4
SERVER_SETTINGS_RENDER_SCALE = 5
WorkingStatus:
STATUS_STARTING = 3
STATUS_STOPPING = 2
STATUS_WORKING = 1
STATUS_STOPPED = 0
```
### GRServer
```python
# --- Properties
# Server password
# type String, default ""
password
# Path to the custom input scene.
# type String, default ""
custom_input_scene
# Is custom input scene compressed
## Doesn't work in GDNative
# type bool, default true
custom_input_scene_compressed
# Compression type of custom input scene
## Doesn't work in GDNative
# type File.CompressionMode, default FastLZ
custom_input_scene_compression_type
# --- Methods
# Set whether the stream is enabled
bool set_video_stream_enabled(value : bool)
# Get whether the stream is enabled
bool is_video_stream_enabled()
# Set how many frames to skip
bool set_skip_frames(frames : int)
# Get the number of skipping frames
int get_skip_frames()
# Set JPG quality
bool set_jpg_quality(quality : int)
# Get JPG quality
int get_jpg_quality()
# Set the scale of the stream
bool set_render_scale(scale : float)
# Get stream scale
float get_render_scale()
# Force update custom input scene on client
void force_update_custom_input_scene()
# Get resize viewport node
# @return resize viewport or null
GRSViewport get_gr_viewport()
# --- Signals
# On client connected
client_connected(device_id: String)
# On client disconnected
client_disconnected(device_id: String)
# On orientation of client's screen or viewport changed
client_viewport_orientation_changed(is_vertical: bool)
# On client's screen or viewport aspect ratio changed
client_viewport_aspect_ratio_changed(stream_aspect: float)
```
### GRClient
```python
# --- Properties
# Capture input only when containing control has focus
# type bool, default false
capture_on_focus
# Capture input only when stream image hovered
# type bool, default true
capture_when_hover
# Capture mouse pointer and touch events
# type bool, default true
capture_pointer
# Capture input
# type bool, default true
capture_input
# Type of connection
# type GRClient.ConnectionType, default CONNECTION_WiFi
connection_type
# Frequency of sending data to the server
# type int, default 60
target_send_fps
# Stretch mode of stream image
# type GRClient.StretchMode, default STRETCH_KEEP_ASPECT
stretch_mode
# Use texture filtering of stream image
# type bool, default true
texture_filtering
# Password
# type String, default ""
password
# ID of device
# type String, default 6 random digits and characters
device_id
# Sync viewport orientation with server
# type bool, default true
viewport_orientation_syncing
# Sync viewport aspect ratio with server
# type bool, default true
viewport_aspect_ratio_syncing
# Receive updated server settings
# type bool, default false
server_settings_syncing
# --- Methods
# Restore settings on server
void disable_overriding_server_settings()
# Get the current visible custom input scene
# @return: Custom input scene
Node get_custom_input_scene()
# Get server address
# @return server address
String get_address()
# Is connected to server
# @return true if connected to server
bool is_connected_to_host()
# Is stream active
# @return true if stream active
bool is_stream_active()
# Set server address to connect
# @ip: IP of server
# @return true if address is valid
bool set_address(ip: String)
# Set both server address and port
# @ip: IP of server
# @port: Port of server
# @return true if address is valid
bool set_address_port(ip: String, port: int)
# Set the control to show stream in
# @control_node: Control where stream will be shown
# @position_in_node: Position of stream in parent
void set_control_to_show_in(control_node: Control, position_in_node: int = 0)
# Set custom material for no signal screen
# @material: Custom material
void set_custom_no_signal_material(material: Material)
# Set custom horizontal texture for no signal screen
# @texture: Custom texture
void set_custom_no_signal_texture(texture: Texture)
# Set custom vertical texture for no signal screen
# @texture: Custom texture
void set_custom_no_signal_vertical_texture(texture: Texture)
# Override setting on server
# @setting: Which setting need to change
# @value: Value of setting
void set_server_setting(setting: GRdevice.TypesOfServerSettings, value: Variant)
# --- Signals
# On custom input scene added and becomes visible
custom_input_scene_added()
# On custom input scene removed
custom_input_scene_removed()
# On connection state changed
connection_state_changed(is_connected: bool)
# On stream state changed
stream_state_changed(state: GRClient.StreamState)
# On mouse mode changed on server
mouse_mode_changed(mouse_mode: Input.MouseMode)
# On received server settings from server
server_settings_received(settings: Dictionary)
# --- Enumerations
ConnectionType:
CONNECTION_ADB = 1
CONNECTION_WiFi = 0
StreamState:
STREAM_NO_SIGNAL = 0
STREAM_ACTIVE = 1
STREAM_NO_IMAGE = 2
StretchMode:
STRETCH_KEEP_ASPECT = 0
STRETCH_FILL = 1
```
There is no need to describe other classes here
## Custom Input Scenes
In custom input scenes you can use everything you want but to send InputEvent's from client to server you must emulate input. Or use the send_user_data() method and user_data_received signal for send and receive custom packets.
Example:
```python
# -- With InputEvent's
func _on_pressed():
# Create event for pressed state
var iea_p = InputEventAction.new()
iea_p.pressed = true
iea_p.action = "jump"
# Create event for released state
var iea_r = InputEventAction.new()
iea_r.pressed = false
iea_p.action = "jump"
# Parse event to send it to the server
Input.parse_input_event(iea_p)
Input.parse_input_event(iea_r)
# -- With custom packets
# on first device
func _ready():
GodotRemote.get_device().connect("user_data_received", self, "_on_user_data_received")
func _on_user_data_received(id, data):
print("Received packet: %s, data: %s" % [id, data])
# on second device
func _on_button_pressed():
GodotRemote.get_device().send_user_data("bg_color", color, false)
```
## License
MIT license

View File

@ -0,0 +1,470 @@
#!/usr/bin/env python
import os
import sys
import subprocess
if sys.version_info < (3,):
def decode_utf8(x):
return x
else:
import codecs
def decode_utf8(x):
return codecs.utf_8_decode(x)[0]
# Workaround for MinGW. See:
# http://www.scons.org/wiki/LongCmdLinesOnWin32
if (os.name=="nt"):
import subprocess
def mySubProcess(cmdline,env):
#print "SPAWNED : " + cmdline
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
proc = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, startupinfo=startupinfo, shell = False, env = env)
data, err = proc.communicate()
rv = proc.wait()
if rv:
print("=====")
print(err.decode("utf-8"))
print("=====")
return rv
def mySpawn(sh, escape, cmd, args, env):
newargs = ' '.join(args[1:])
cmdline = cmd + " " + newargs
rv=0
if len(cmdline) > 32000 and cmd.endswith("ar") :
cmdline = cmd + " " + args[1] + " " + args[2] + " "
for i in range(3,len(args)) :
rv = mySubProcess( cmdline + args[i], env )
if rv :
break
else:
rv = mySubProcess( cmdline, env )
return rv
def add_sources(sources, dir, extension):
for f in os.listdir(dir):
if f.endswith('.' + extension):
sources.append(dir + '/' + f)
# Try to detect the host platform automatically.
# This is used if no `platform` argument is passed
if sys.platform.startswith('linux'):
host_platform = 'linux'
elif sys.platform.startswith('freebsd'):
host_platform = 'freebsd'
elif sys.platform == 'darwin':
host_platform = 'osx'
elif sys.platform == 'win32' or sys.platform == 'msys':
host_platform = 'windows'
else:
raise ValueError(
'Could not detect platform automatically, please specify with '
'platform=<platform>'
)
env = Environment(ENV = os.environ)
is64 = sys.maxsize > 2**32
if (
env['TARGET_ARCH'] == 'amd64' or
env['TARGET_ARCH'] == 'emt64' or
env['TARGET_ARCH'] == 'x86_64' or
env['TARGET_ARCH'] == 'arm64-v8a'
):
is64 = True
opts = Variables([], ARGUMENTS)
opts.Add(EnumVariable(
'platform',
'Target platform',
host_platform,
allowed_values=('linux', 'freebsd', 'osx', 'windows', 'android', 'ios'),
ignorecase=2
))
opts.Add(EnumVariable(
'bits',
'Target platform bits',
'64' if is64 else '32',
('32', '64')
))
opts.Add(BoolVariable(
'use_llvm',
'Use the LLVM compiler - only effective when targeting Linux or FreeBSD',
False
))
opts.Add(BoolVariable(
'use_mingw',
'Use the MinGW compiler instead of MSVC - only effective on Windows',
False
))
# Must be the same setting as used for cpp_bindings
opts.Add(EnumVariable(
'target',
'Compilation target',
'debug',
allowed_values=('debug', 'release'),
ignorecase=2
))
opts.Add(PathVariable(
'headers_dir',
'Path to the directory containing Godot headers',
'godot-cpp/godot-headers',
PathVariable.PathIsDir
))
opts.Add(PathVariable(
'custom_api_file',
'Path to a custom JSON API file',
None,
PathVariable.PathIsFile
))
opts.Add(EnumVariable(
'generate_bindings',
'Generate GDNative API bindings',
'auto',
allowed_values = ['yes', 'no', 'auto', 'true'],
ignorecase = 2
))
opts.Add(EnumVariable(
'android_arch',
'Target Android architecture',
'armv7',
['armv7','arm64v8','x86','x86_64']
))
opts.Add(
'macos_deployment_target',
'macOS deployment target',
'default'
)
opts.Add(EnumVariable(
'ios_arch',
'Target iOS architecture',
'arm64',
['armv7', 'arm64', 'x86_64']
))
opts.Add(BoolVariable(
'ios_simulator',
'Target iOS Simulator',
False
))
opts.Add(
'IPHONEPATH',
'Path to iPhone toolchain',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain',
)
opts.Add(
'android_api_level',
'Target Android API level',
'18' if ARGUMENTS.get("android_arch", 'armv7') in ['armv7', 'x86'] else '21'
)
opts.Add(
'ANDROID_NDK_ROOT',
'Path to your Android NDK installation. By default, uses ANDROID_NDK_ROOT from your defined environment variables.',
os.environ.get("ANDROID_NDK_ROOT", None)
)
opts.Add(BoolVariable(
'generate_template_get_node',
"Generate a template version of the Node class's get_node.",
True
))
# GODOT REMOTE CUSTOM OPTIONS
opts.Add(BoolVariable(
'godot_remote_no_default_resources',
'Compile without embeded resources.',
False
))
opts.Add(BoolVariable(
'godot_remote_disable_server',
'Compile without server side.',
False
))
opts.Add(BoolVariable(
'godot_remote_disable_client',
'Compile without client side.',
False
))
# END
opts.Update(env)
Help(opts.GenerateHelpText(env))
# This makes sure to keep the session environment variables on Windows.
# This way, you can run SCons in a Visual Studio 2017 prompt and it will find
# all the required tools
if host_platform == 'windows' and env['platform'] != 'android':
if env['bits'] == '64':
env = Environment(TARGET_ARCH='amd64')
elif env['bits'] == '32':
env = Environment(TARGET_ARCH='x86')
opts.Update(env)
if env['platform'] == 'linux' or env['platform'] == 'freebsd':
env['SHLIBSUFFIX'] = '.so'
if env['use_llvm']:
env['CXX'] = 'clang++'
env.Append(CCFLAGS=['-fPIC', '-std=c++14', '-Wwrite-strings'])
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
if env['bits'] == '64':
env.Append(CCFLAGS=['-m64'])
env.Append(LINKFLAGS=['-m64'])
elif env['bits'] == '32':
env.Append(CCFLAGS=['-m32'])
env.Append(LINKFLAGS=['-m32'])
elif env['platform'] == 'osx':
# Use Clang on macOS by default
env['CXX'] = 'clang++'
env['SHLIBSUFFIX'] = '.dylib'
if env['bits'] == '32':
raise ValueError(
'Only 64-bit builds are supported for the macOS target.'
)
env.Append(CCFLAGS=['-std=c++14', '-arch', 'x86_64'])
if env['macos_deployment_target'] != 'default':
env.Append(CCFLAGS=['-mmacosx-version-min=' + env['macos_deployment_target']])
env.Append(LINKFLAGS=[
'-arch',
'x86_64',
'-framework',
'Cocoa',
'-Wl,-undefined,dynamic_lookup',
])
if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
elif env['platform'] == 'ios':
env['SHLIBSUFFIX'] = '.dylib'
if env['ios_simulator']:
sdk_name = 'iphonesimulator'
env.Append(CCFLAGS=['-mios-simulator-version-min=10.0'])
env['LIBSUFFIX'] = ".simulator" + env['LIBSUFFIX']
else:
sdk_name = 'iphoneos'
env.Append(CCFLAGS=['-miphoneos-version-min=10.0'])
try:
sdk_path = decode_utf8(subprocess.check_output(['xcrun', '--sdk', sdk_name, '--show-sdk-path']).strip())
except (subprocess.CalledProcessError, OSError):
raise ValueError("Failed to find SDK path while running xcrun --sdk {} --show-sdk-path.".format(sdk_name))
compiler_path = env['IPHONEPATH'] + '/usr/bin/'
env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH']
env['CC'] = compiler_path + 'clang'
env['CXX'] = compiler_path + 'clang++'
env['AR'] = compiler_path + 'ar'
env['RANLIB'] = compiler_path + 'ranlib'
env.Append(CCFLAGS=['-std=c++14', '-arch', env['ios_arch'], '-isysroot', sdk_path])
env.Append(LINKFLAGS=[
'-arch',
env['ios_arch'],
'-framework',
'Cocoa',
'-Wl,-undefined,dynamic_lookup',
'-isysroot', sdk_path,
'-F' + sdk_path
])
if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og', '-g'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
elif env['platform'] == 'windows':
env['SHLIBSUFFIX'] = '.dll'
if host_platform == 'windows' and not env['use_mingw']:
# MSVC
env.Append(LINKFLAGS=['/WX'])
if env['target'] == 'debug':
env.Append(CCFLAGS=['/Z7', '/Od', '/EHsc', '/D_DEBUG', '/MDd'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['/O2', '/EHsc', '/DNDEBUG', '/MD'])
elif host_platform == 'linux' or host_platform == 'freebsd' or host_platform == 'osx':
# Cross-compilation using MinGW
if env['bits'] == '64':
env['CXX'] = 'x86_64-w64-mingw32-g++'
env['AR'] = "x86_64-w64-mingw32-ar"
env['RANLIB'] = "x86_64-w64-mingw32-ranlib"
env['LINK'] = "x86_64-w64-mingw32-g++"
elif env['bits'] == '32':
env['CXX'] = 'i686-w64-mingw32-g++'
env['AR'] = "i686-w64-mingw32-ar"
env['RANLIB'] = "i686-w64-mingw32-ranlib"
env['LINK'] = "i686-w64-mingw32-g++"
elif host_platform == 'windows' and env['use_mingw']:
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
env = Environment(ENV = os.environ, tools=["mingw"])
opts.Update(env)
#env = env.Clone(tools=['mingw'])
env["SPAWN"] = mySpawn
# Native or cross-compilation using MinGW
if host_platform == 'linux' or host_platform == 'freebsd' or host_platform == 'osx' or env['use_mingw']:
# These options are for a release build even using target=debug
env.Append(CCFLAGS=['-O3', '-std=c++14', '-Wwrite-strings'])
env.Append(LINKFLAGS=[
'--static',
'-Wl,--no-undefined',
'-static-libgcc',
'-static-libstdc++',
])
elif env['platform'] == 'android':
env['SHLIBSUFFIX'] = '.so'
if env['target'] == 'debug':
env.Append(CCFLAGS=['-Og'])
elif env['target'] == 'release':
env.Append(CCFLAGS=['-O3'])
if host_platform == 'windows':
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
env = Environment(ENV = os.environ, tools=["mingw"])
opts.Update(env)
#env = env.Clone(tools=['mingw'])
env["SPAWN"] = mySpawn
# Verify NDK root
if not 'ANDROID_NDK_ROOT' in env:
raise ValueError("To build for Android, ANDROID_NDK_ROOT must be defined. Please set ANDROID_NDK_ROOT to the root folder of your Android NDK installation.")
# Validate API level
api_level = int(env['android_api_level'])
if env['android_arch'] in ['x86_64', 'arm64v8'] and api_level < 21:
print("WARN: 64-bit Android architectures require an API level of at least 21; setting android_api_level=21")
env['android_api_level'] = '21'
api_level = 21
# Setup toolchain
toolchain = env['ANDROID_NDK_ROOT'] + "/toolchains/llvm/prebuilt/"
if host_platform == "windows":
toolchain += "windows"
import platform as pltfm
if pltfm.machine().endswith("64"):
toolchain += "-x86_64"
elif host_platform == "linux":
toolchain += "linux-x86_64"
elif host_platform == "osx":
toolchain += "darwin-x86_64"
env.PrependENVPath('PATH', toolchain + "/bin") # This does nothing half of the time, but we'll put it here anyways
# Get architecture info
arch_info_table = {
"armv7" : {
"march":"armv7-a", "target":"armv7a-linux-androideabi", "tool_path":"arm-linux-androideabi", "compiler_path":"armv7a-linux-androideabi",
"ccflags" : ['-mfpu=neon']
},
"arm64v8" : {
"march":"armv8-a", "target":"aarch64-linux-android", "tool_path":"aarch64-linux-android", "compiler_path":"aarch64-linux-android",
"ccflags" : []
},
"x86" : {
"march":"i686", "target":"i686-linux-android", "tool_path":"i686-linux-android", "compiler_path":"i686-linux-android",
"ccflags" : ['-mstackrealign']
},
"x86_64" : {"march":"x86-64", "target":"x86_64-linux-android", "tool_path":"x86_64-linux-android", "compiler_path":"x86_64-linux-android",
"ccflags" : []
}
}
arch_info = arch_info_table[env['android_arch']]
# Setup tools
env['CC'] = toolchain + "/bin/clang"
env['CXX'] = toolchain + "/bin/clang++"
env['AR'] = toolchain + "/bin/" + arch_info['tool_path'] + "-ar"
env.Append(CCFLAGS=['--target=' + arch_info['target'] + env['android_api_level'], '-march=' + arch_info['march'], '-fPIC'])#, '-fPIE', '-fno-addrsig', '-Oz'])
env.Append(CCFLAGS=arch_info['ccflags'])
arch_suffix = env['bits']
if env['platform'] == 'android':
arch_suffix = env['android_arch']
if env['platform'] == 'ios':
arch_suffix = env['ios_arch']
env.Append(CPPPATH=[
'.',
env['headers_dir'],
'godot_remote',
'godot-cpp/include',
'godot-cpp/include/gen',
'godot-cpp/include/core',
])
env.Append(LIBPATH=['godot-cpp/bin/'])
env.Append(LIBS=[
'libgodot-cpp.{}.{}.{}{}'.format( # godot-cpp lib
env['platform'],
env['target'],
arch_suffix,
env['LIBSUFFIX']),
])
# Generate bindings?
json_api_file = ''
if 'custom_api_file' in env:
json_api_file = env['custom_api_file']
else:
json_api_file = os.path.join(os.getcwd(), env['headers_dir'], 'api.json')
if env['generate_bindings'] == 'auto':
# Check if generated files exist
should_generate_bindings = not os.path.isfile(os.path.join(os.getcwd(), 'src', 'gen', 'Object.cpp'))
else:
should_generate_bindings = env['generate_bindings'] in ['yes', 'true']
env.Append(CPPDEFINES=['GDNATIVE_LIBRARY'])
if env['godot_remote_no_default_resources'] == True:
env.Append(CPPDEFINES=['NO_GODOTREMOTE_DEFAULT_RESOURCES'])
if env['godot_remote_disable_server'] == True:
env.Append(CPPDEFINES=['NO_GODOTREMOTE_SERVER'])
if env['godot_remote_disable_client'] == True:
env.Append(CPPDEFINES=['NO_GODOTREMOTE_CLIENT'])
# Sources to compile
sources = []
add_sources(sources, 'godot_remote', 'cpp')
library = env.SharedLibrary(
target='bin/' + 'godot_remote.{}.{}.{}{}'.format(
env['platform'],
env['target'],
arch_suffix,
env['SHLIBSUFFIX']
#env['LIBSUFFIX']
), source=sources
)
Default(library)

View File

@ -0,0 +1 @@
%ANDROID_NDK_ROOT%/ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk APP_PLATFORM=android-21 -j8

View File

@ -0,0 +1,14 @@
cd godot-cpp
set cpu=%NUMBER_OF_PROCESSORS%
set api=custom_api_file="../api.json"
scons generate_bindings=true platform=windows target=release bits=64 -j%cpu% %api%
scons platform=windows target=release bits=64 -j%cpu% %api%
scons platform=windows target=debug bits=64 -j%cpu% %api%
scons platform=android target=debug android_arch=arm64v8 -j%cpu% %api%
scons platform=android target=release android_arch=arm64v8 -j%cpu% %api%
scons platform=android target=release android_arch=armv7 -j%cpu% %api%
scons platform=android target=release android_arch=x86 -j%cpu% %api%
scons platform=android target=release android_arch=x86_64 -j%cpu% %api%

View File

@ -0,0 +1 @@
scons platform=windows bits=64 target=release -j8

View File

@ -0,0 +1,10 @@
extends Control
# If you want to disable capturing touch events or mouse pointer
# you can use this method
func _enter_tree():
GodotRemote.get_device().set_capture_pointer(false)
# And after removing this scene you need to restore value
func _exit_tree():
GodotRemote.get_device().set_capture_pointer(true)

View File

@ -0,0 +1,40 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://CustomInput.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[node name="CustomInput" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Control" type="Control" parent="."]
anchor_top = 0.5
anchor_bottom = 0.5
margin_top = -20.0
margin_right = 40.0
margin_bottom = 20.0
[node name="TouchScreenButton" type="TouchScreenButton" parent="Control"]
position = Vector2( 33, -180 )
scale = Vector2( 5.45313, 6.5 )
normal = ExtResource( 2 )
action = "ui_left"
[node name="Control2" type="Control" parent="."]
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
margin_left = -40.0
margin_top = -20.0
margin_bottom = 20.0
[node name="TouchScreenButton2" type="TouchScreenButton" parent="Control2"]
position = Vector2( -342.74, -180 )
scale = Vector2( 5.45313, 6.5 )
normal = ExtResource( 2 )
action = "ui_right"

View File

@ -0,0 +1,37 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Player.gd" type="Script" id=2]
[ext_resource path="res://icon.png" type="Texture" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 32.04, 30.9 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 32, 32 )
[node name="Main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Ground" type="StaticBody2D" parent="."]
position = Vector2( 522, 493.5 )
scale = Vector2( 17.1563, 0.265625 )
[node name="Sprite" type="Sprite" parent="Ground"]
texture = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Ground"]
shape = SubResource( 1 )
[node name="Player" type="KinematicBody2D" parent="."]
position = Vector2( 527.072, 375.837 )
script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="Player"]
texture = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Player"]
shape = SubResource( 2 )

View File

@ -0,0 +1,15 @@
extends KinematicBody2D
var speed = 500.0
# Basic player logic
func _physics_process(delta):
var direction = Vector2()
if Input.is_action_pressed("ui_left"):
direction.x -= 1
if Input.is_action_pressed("ui_right"):
direction.x += 1
var velocity = (direction * speed + Vector2.DOWN * 98)
move_and_slide(velocity, Vector2.UP)

View File

@ -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 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -0,0 +1,34 @@
[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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,49 @@
; 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
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="Custom Input Scene"
run/main_scene="res://Main.tscn"
config/icon="res://icon.png"
[debug]
godot_remote/server_custom_input_scene/custom_input_scene="res://CustomInput.tscn"
godot_remote/server/video_stream_enabled=false
[input]
ui_left={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":65,"unicode":0,"echo":false,"script":null)
]
}
ui_right={
"deadzone": 0.5,
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"unicode":0,"echo":false,"script":null)
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":68,"unicode":0,"echo":false,"script":null)
]
}
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"

View File

@ -0,0 +1,16 @@
extends Control
func _ready() -> void:
GodotRemote.connect("device_added", self, "device_added")
func device_added():
print(GodotRemote.get_device().get_custom_input_scene())
GodotRemote.get_device().connect("user_data_received", self, "user_data_received")
func user_data_received(packet_id, user_data):
print("Received packet: %s, data: %s" % [packet_id, user_data])
match packet_id:
"bg_color": VisualServer.set_default_clear_color(user_data)
func _on_HSlider_value_changed(value: float) -> void:
GodotRemote.get_device().send_user_data("slider_value", value, false)

View File

@ -0,0 +1,74 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Control.gd" type="Script" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[sub_resource type="Animation" id=1]
resource_name = "New Anim"
length = 3.0
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Control:rect_position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.9, 2.2 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 730, 32 ), Vector2( 815.526, 473.886 ), Vector2( 203.097, 448.007 ) ]
}
tracks/1/type = "value"
tracks/1/path = NodePath("Control:rect_rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/keys = {
"times": PoolRealArray( 0, 0.9, 2.2 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ 0.0, 422.2, -251.5 ]
}
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HSlider" type="HSlider" parent="."]
margin_left = 9.0
margin_top = 129.0
margin_right = 409.0
margin_bottom = 162.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="."]
margin_left = 15.0
margin_top = 103.0
margin_right = 334.0
margin_bottom = 125.0
text = "Remote progress bar value"
[node name="Control" type="TextureRect" parent="."]
margin_left = 454.735
margin_top = 458.64
margin_right = 518.738
margin_bottom = 522.641
rect_rotation = 25.3133
texture = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "New Anim"
"anims/New Anim" = SubResource( 1 )
[connection signal="value_changed" from="HSlider" to="." method="_on_HSlider_value_changed"]

View File

@ -0,0 +1,12 @@
extends Control
func _ready() -> void:
GodotRemote.get_device().connect("user_data_received", self, "user_data_received")
func _on_ColorPickerButton_color_changed(color: Color) -> void:
GodotRemote.get_device().send_user_data("bg_color", color, false)
func user_data_received(packet_id, user_data):
print("Received packet: %s, data: %s" % [packet_id, user_data])
match packet_id:
"slider_value": $ProgressBar.value = user_data

View File

@ -0,0 +1,61 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://ControlColorRemote.gd" type="Script" id=1]
[node name="Control" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_lock_": true,
"_edit_use_anchors_": false
}
[node name="ProgressBar" type="ProgressBar" parent="."]
anchor_left = 0.0556641
anchor_top = 0.0383333
anchor_right = 0.959961
anchor_bottom = 0.0883333
__meta__ = {
"_edit_use_anchors_": true
}
[node name="Control" type="Control" parent="."]
anchor_left = 0.319902
anchor_top = 0.262483
anchor_right = 0.702714
anchor_bottom = 0.945817
margin_bottom = -3.8147e-06
__meta__ = {
"_edit_use_anchors_": true
}
[node name="VBoxContainer" type="VBoxContainer" parent="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Label" type="Label" parent="Control/VBoxContainer"]
margin_top = 45.0
margin_right = 391.0
margin_bottom = 59.0
size_flags_vertical = 6
size_flags_stretch_ratio = 0.35
text = "SELECT BACKGROUND COLOR"
align = 1
__meta__ = {
"_edit_use_anchors_": true
}
[node name="ColorPickerButton" type="ColorPickerButton" parent="Control/VBoxContainer"]
margin_top = 109.0
margin_right = 391.0
margin_bottom = 410.0
size_flags_vertical = 3
__meta__ = {
"_edit_use_anchors_": true
}
[connection signal="color_changed" from="Control/VBoxContainer/ColorPickerButton" to="." method="_on_ColorPickerButton_color_changed"]

View File

@ -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 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

View File

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="StreamTexture"
path.s3tc="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.stex"
path.etc="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.etc.stex"
metadata={
"imported_formats": [ "s3tc", "etc" ],
"vram_texture": true
}
[deps]
source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.s3tc.stex", "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.etc.stex" ]
[params]
compress/mode=2
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=true
flags/filter=true
flags/mipmaps=true
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

View File

@ -0,0 +1,26 @@
; 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
[application]
config/name="Custom User Packets"
run/main_scene="res://Control.tscn"
config/icon="res://icon.png"
[debug]
godot_remote/server_custom_input_scene/custom_input_scene="res://ControlColorRemote.tscn"
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"

View File

@ -0,0 +1,32 @@
extends Control
# firstly you need to disable autostart GodotRemote in Project Settings/Debug/Godot Remote/General
# and change the Network/Limits/Connect Timeout Seconds to 1 otherwise app will be closing very long time
func _ready():
# create client
GodotRemote.create_remote_device(GodotRemote.DEVICE_CLIENT)
# get device and convert it to client class
var d : GRClient = GodotRemote.get_device()
# set control where you want to see stream. it can be whole screen control or custom 'viewport'
d.set_control_to_show_in(self)
# set address of server. optional if you want to connect to other projects on one pc or if you use connection over adb
d.set_address("127.0.0.1")
# set password to get acces to the server if it need one
d.password = "1234"
# and change other settings if you need it
# start client
GodotRemote.start_remote_device()
# If you need to support custom input scenes best way to avoid any errors by overriding resources
# from server is just put all assets of this project to folder with unique and long name
#
# Example:
# *res://
# -UniqueL0ngNameThatINeverOverrideFromServer
# -icon.png
# -default_env.tres
# -Scene.tscn
# -Scene.gd

View File

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=2]
[ext_resource path="res://UniqueL0ngNameThatINeverOverrideFromServer/ControlToShowStream.gd" type="Script" id=1]
[node name="ControlToShowStreamIn" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/icon.png-9b69519d77c698a6f97b5d1c3f5e548f.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://UniqueL0ngNameThatINeverOverrideFromServer/icon.png"
dest_files=[ "res://.import/icon.png-9b69519d77c698a6f97b5d1c3f5e548f.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,34 @@
; 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
[application]
config/name="Example Client"
run/main_scene="res://UniqueL0ngNameThatINeverOverrideFromServer/ControlToShowStream.tscn"
config/icon="res://UniqueL0ngNameThatINeverOverrideFromServer/icon.png"
[debug]
settings/stdout/verbose_stdout=true
godot_remote/general/autostart=false
[editor_plugins]
enabled=PoolStringArray( )
[network]
limits/tcp/connect_timeout_seconds=1
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false

View File

@ -0,0 +1,23 @@
extends Control
var is_vertical = false
var screen_aspect = OS.window_size.x / OS.window_size.y
func _ready():
# Waiting for one frame until the device is created
yield(get_tree(), "idle_frame")
# Connect to server signals
GodotRemote.get_device().connect("client_viewport_orientation_changed", self, "_screen_rotated")
GodotRemote.get_device().connect("client_viewport_aspect_ratio_changed", self, "_screen_aspect_changed")
# Simple functions to resize window
func _screen_rotated(_is_vertical):
is_vertical = _is_vertical
if _is_vertical:
OS.window_size = Vector2(600, 600 / screen_aspect)
else:
OS.window_size = Vector2(600 * screen_aspect, 600)
func _screen_aspect_changed(_aspect):
screen_aspect = _aspect
_screen_rotated(is_vertical)

View File

@ -0,0 +1,15 @@
[gd_scene load_steps=3 format=2]
[ext_resource path="res://icon.png" type="Texture" id=1]
[ext_resource path="res://Main.gd" type="Script" id=2]
[node name="Main" type="Control"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
[node name="TextureRect" type="TextureRect" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
texture = ExtResource( 1 )
stretch_mode = 1

View File

@ -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 )

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

@ -0,0 +1,34 @@
[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
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View File

@ -0,0 +1,26 @@
; 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
[application]
config/name="Viewport Size Syncing"
run/main_scene="res://Main.tscn"
config/icon="res://icon.png"
[display]
window/size/width=600
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,338 @@
/* GRClient.h */
#pragma once
#ifndef NO_GODOTREMOTE_CLIENT
#include "GRDevice.h"
#ifndef GDNATIVE_LIBRARY
#include "core/io/ip_address.h"
#include "core/io/stream_peer_tcp.h"
#include "scene/gui/texture_rect.h"
#include "scene/main/node.h"
#else
#include <Node.hpp>
#include <PacketPeerStream.hpp>
#include <Shader.hpp>
#include <ShaderMaterial.hpp>
#include <StreamPeerTCP.hpp>
#include <TextureRect.hpp>
#include <Thread.hpp>
using namespace godot;
#endif
class GRClient : public GRDevice {
GD_S_CLASS(GRClient, GRDevice);
friend class GRTextureRect;
enum class ScreenOrientation : int {
NONE = 0,
VERTICAL = 1,
HORIZONTAL = 2,
};
public:
enum ConnectionType : int {
CONNECTION_WiFi = 0,
CONNECTION_ADB = 1,
};
enum StretchMode : int {
STRETCH_KEEP_ASPECT = 0,
STRETCH_FILL = 1,
};
enum StreamState : int {
STREAM_NO_SIGNAL = 0,
STREAM_ACTIVE = 1,
STREAM_NO_IMAGE = 2,
};
#ifndef GDNATIVE_LIBRARY
private:
#else
public:
#endif
class ImgProcessingStorageClient : public Object {
GD_CLASS(ImgProcessingStorageClient, Object);
public:
GRClient *dev = nullptr;
PoolByteArray tex_data;
uint64_t framerate = 0;
int format = 0;
ImageCompressionType compression_type = ImageCompressionType::COMPRESSION_UNCOMPRESSED;
Size2 size;
bool _is_processing_img = false;
bool _thread_closing = false;
static void _register_methods(){};
void _init() {
LEAVE_IF_EDITOR();
tex_data = PoolByteArray();
};
~ImgProcessingStorageClient() {
LEAVE_IF_EDITOR();
tex_data.resize(0);
}
};
class ConnectionThreadParamsClient : public Object {
GD_CLASS(ConnectionThreadParamsClient, Object);
public:
GRClient *dev = nullptr;
Ref<StreamPeerTCP> peer;
Ref<PacketPeerStream> ppeer;
Thread_define(thread_ref);
bool break_connection = false;
bool stop_thread = false;
bool finished = false;
void close_thread() {
break_connection = true;
stop_thread = true;
Thread_close(thread_ref);
}
static void _register_methods(){};
void _init(){};
~ConnectionThreadParamsClient() {
LEAVE_IF_EDITOR();
close_thread();
if (peer.is_valid()) {
peer.unref();
}
if (ppeer.is_valid()) {
ppeer.unref();
}
};
};
private:
bool is_deleting = false;
bool is_connection_working = false;
Node *settings_menu_node = nullptr;
class Control *control_to_show_in = nullptr;
class GRTextureRect *tex_shows_stream = nullptr;
class GRInputCollector *input_collector = nullptr;
ConnectionThreadParamsClient *thread_connection = nullptr;
ScreenOrientation is_vertical = ScreenOrientation::NONE;
String device_id = "UNKNOWN";
String server_address = String("127.0.0.1");
String password;
bool is_filtering_enabled = true;
bool _viewport_orientation_syncing = true;
bool _viewport_aspect_ratio_syncing = true;
bool _server_settings_syncing = false;
StretchMode stretch_mode = StretchMode::STRETCH_KEEP_ASPECT;
Mutex_define(connection_mutex);
ConnectionType con_type = ConnectionType::CONNECTION_WiFi;
int input_buffer_size_in_mb = 4;
int send_data_fps = 60;
uint64_t sync_time_client = 0;
uint64_t sync_time_server = 0;
// NO SIGNAL screen
uint64_t prev_valid_connection_time = 0;
StreamState signal_connection_state = StreamState::STREAM_NO_SIGNAL;
bool no_signal_is_vertical = false;
Ref<class Texture> custom_no_signal_texture;
Ref<class Texture> custom_no_signal_vertical_texture;
Ref<class Material> custom_no_signal_material;
#ifndef NO_GODOTREMOTE_DEFAULT_RESOURCES
Ref<class Image> no_signal_image;
Ref<class Image> no_signal_vertical_image;
Ref<class ShaderMaterial> no_signal_mat;
#endif
Node *custom_input_scene = nullptr;
String custom_input_scene_tmp_pck_file = "user://custom_input_scene.pck";
void _force_update_stream_viewport_signals();
void _load_custom_input_scene(Ref<class GRPacketCustomInputScene> _data);
void _remove_custom_input_scene();
void _viewport_size_changed();
void _on_node_deleting(int var_name);
void _update_texture_from_image(Ref<Image> img);
void _update_stream_texture_state(ENUM_ARG(StreamState) _stream_state);
virtual void _reset_counters() override;
THREAD_FUNC void _thread_connection(THREAD_DATA p_userdata);
THREAD_FUNC void _thread_image_decoder(THREAD_DATA p_userdata);
static void _connection_loop(ConnectionThreadParamsClient *con_thread);
static GRDevice::AuthResult _auth_on_server(GRClient *dev, Ref<PacketPeerStream> &con);
protected:
virtual void _internal_call_only_deffered_start() override;
virtual void _internal_call_only_deffered_stop() override;
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_notification);
public:
void set_control_to_show_in(class Control *ctrl, int position_in_node DEF_ARG(= 0));
void set_custom_no_signal_texture(Ref<Texture> custom_tex);
void set_custom_no_signal_vertical_texture(Ref<Texture> custom_tex);
void set_custom_no_signal_material(Ref<Material> custom_mat);
bool is_capture_on_focus();
void set_capture_on_focus(bool value);
bool is_capture_when_hover();
void set_capture_when_hover(bool value);
bool is_capture_pointer();
void set_capture_pointer(bool value);
bool is_capture_input();
void set_capture_input(bool value);
void set_connection_type(ENUM_ARG(ConnectionType) type);
ENUM_ARG(ConnectionType)
get_connection_type();
void set_target_send_fps(int fps);
int get_target_send_fps();
void set_stretch_mode(ENUM_ARG(StretchMode) stretch);
ENUM_ARG(StretchMode)
get_stretch_mode();
void set_texture_filtering(bool is_filtering);
bool get_texture_filtering();
void set_viewport_orientation_syncing(bool is_syncing);
bool is_viewport_orientation_syncing();
void set_viewport_aspect_ratio_syncing(bool is_syncing);
bool is_viewport_aspect_ratio_syncing();
void set_server_settings_syncing(bool is_syncing);
bool is_server_settings_syncing();
void set_password(String _pass);
String get_password();
void set_device_id(String _id);
String get_device_id();
ENUM_ARG(StreamState)
get_stream_state();
bool is_stream_active();
bool is_connected_to_host();
Node *get_custom_input_scene();
String get_address();
bool set_address(String ip);
bool set_address_port(String ip, uint16_t _port);
void set_input_buffer(int mb);
void set_server_setting(ENUM_ARG(TypesOfServerSettings) param, Variant value);
void disable_overriding_server_settings();
void _init();
void _deinit();
};
class GRInputCollector : public Node {
GD_CLASS(GRInputCollector, Node);
friend GRClient;
_TS_CLASS_;
private:
GRClient *dev = nullptr;
GRInputCollector **this_in_client = nullptr; //somebody help
class TextureRect *texture_rect = nullptr;
//Array collected_input_data; // Ref<GRInputData>
std::vector<Ref<GRInputData> > collected_input_data;
class Control *parent;
bool capture_only_when_control_in_focus = false;
bool capture_pointer_only_when_hover_control = true;
bool dont_capture_pointer = false;
Rect2 stream_rect;
PoolVector3Array sensors;
Dictionary mouse_buttons;
Dictionary screen_touches;
protected:
void _collect_input(Ref<InputEvent> ie);
void _update_stream_rect();
void _release_pointers();
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _input(Ref<InputEvent> ie);
void _notification(int p_notification);
public:
bool is_capture_on_focus();
void set_capture_on_focus(bool value);
bool is_capture_when_hover();
void set_capture_when_hover(bool value);
bool is_capture_pointer();
void set_capture_pointer(bool value);
bool is_capture_input();
void set_capture_input(bool value);
void set_tex_rect(class TextureRect *tr);
Ref<class GRPacketInputData> get_collected_input_data();
void _init();
void _deinit();
};
class GRTextureRect : public TextureRect {
GD_CLASS(GRTextureRect, TextureRect);
friend GRClient;
GRClient *dev = nullptr;
GRTextureRect **this_in_client = nullptr;
void _tex_size_changed();
protected:
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_notification);
public:
void _init();
void _deinit();
};
#ifndef GDNATIVE_LIBRARY
VARIANT_ENUM_CAST(GRClient::ConnectionType)
VARIANT_ENUM_CAST(GRClient::StretchMode)
VARIANT_ENUM_CAST(GRClient::StreamState)
#endif
#endif // !NO_GODOTREMOTE_CLIENT

View File

@ -0,0 +1,255 @@
/* GRDevice.cpp */
#include "GRDevice.h"
#include "GodotRemote.h"
#ifndef GDNATIVE_LIBRARY
#else
#include <ClassDB.hpp>
using namespace godot;
#endif
using namespace GRUtils;
#ifndef GDNATIVE_LIBRARY
void GRDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("_internal_call_only_deffered_start"), &GRDevice::_internal_call_only_deffered_start);
ClassDB::bind_method(D_METHOD("_internal_call_only_deffered_stop"), &GRDevice::_internal_call_only_deffered_stop);
ClassDB::bind_method(D_METHOD("_internal_call_only_deffered_restart"), &GRDevice::_internal_call_only_deffered_restart);
ClassDB::bind_method(D_METHOD("get_avg_ping"), &GRDevice::get_avg_ping);
ClassDB::bind_method(D_METHOD("get_min_ping"), &GRDevice::get_min_ping);
ClassDB::bind_method(D_METHOD("get_max_ping"), &GRDevice::get_max_ping);
ClassDB::bind_method(D_METHOD("get_avg_fps"), &GRDevice::get_avg_fps);
ClassDB::bind_method(D_METHOD("get_min_fps"), &GRDevice::get_min_fps);
ClassDB::bind_method(D_METHOD("get_max_fps"), &GRDevice::get_max_fps);
ClassDB::bind_method(D_METHOD("get_port"), &GRDevice::get_port);
ClassDB::bind_method(D_METHOD("set_port", "port"), &GRDevice::set_port, DEFVAL(52341));
//ClassDB::bind_method(D_METHOD("send_packet", "packet"), &GRDevice::send_packet);
ClassDB::bind_method(D_METHOD("send_user_data", "packet_id", "user_data", "full_objects"), &GRDevice::send_user_data, DEFVAL(false));
ClassDB::bind_method(D_METHOD("start"), &GRDevice::start);
ClassDB::bind_method(D_METHOD("stop"), &GRDevice::stop);
ClassDB::bind_method(D_METHOD("get_status"), &GRDevice::get_status);
ADD_SIGNAL(MethodInfo("status_changed", PropertyInfo(Variant::INT, "status")));
ADD_SIGNAL(MethodInfo("user_data_received", PropertyInfo(Variant::NIL, "packet_id"), PropertyInfo(Variant::NIL, "user_data")));
ADD_PROPERTY(PropertyInfo(Variant::INT, "port"), "set_port", "get_port");
BIND_ENUM_CONSTANT(STATUS_STARTING);
BIND_ENUM_CONSTANT(STATUS_STOPPING);
BIND_ENUM_CONSTANT(STATUS_WORKING);
BIND_ENUM_CONSTANT(STATUS_STOPPED);
BIND_ENUM_CONSTANT(SERVER_SETTINGS_USE_INTERNAL);
BIND_ENUM_CONSTANT(SERVER_SETTINGS_VIDEO_STREAM_ENABLED);
BIND_ENUM_CONSTANT(SERVER_SETTINGS_COMPRESSION_TYPE);
BIND_ENUM_CONSTANT(SERVER_SETTINGS_JPG_QUALITY);
BIND_ENUM_CONSTANT(SERVER_SETTINGS_SKIP_FRAMES);
BIND_ENUM_CONSTANT(SERVER_SETTINGS_RENDER_SCALE);
BIND_ENUM_CONSTANT(SUBSAMPLING_Y_ONLY);
BIND_ENUM_CONSTANT(SUBSAMPLING_H1V1);
BIND_ENUM_CONSTANT(SUBSAMPLING_H2V1);
BIND_ENUM_CONSTANT(SUBSAMPLING_H2V2);
BIND_ENUM_CONSTANT(COMPRESSION_UNCOMPRESSED);
BIND_ENUM_CONSTANT(COMPRESSION_JPG);
BIND_ENUM_CONSTANT(COMPRESSION_PNG);
}
#else
void GRDevice::_register_methods() {
METHOD_REG(GRDevice, _notification);
METHOD_REG(GRDevice, _internal_call_only_deffered_start);
METHOD_REG(GRDevice, _internal_call_only_deffered_stop);
METHOD_REG(GRDevice, _internal_call_only_deffered_restart);
METHOD_REG(GRDevice, get_avg_ping);
METHOD_REG(GRDevice, get_min_ping);
METHOD_REG(GRDevice, get_max_ping);
METHOD_REG(GRDevice, get_avg_fps);
METHOD_REG(GRDevice, get_min_fps);
METHOD_REG(GRDevice, get_max_fps);
METHOD_REG(GRDevice, get_port);
METHOD_REG(GRDevice, set_port);
//METHOD_REG(GRDevice, send_packet);
METHOD_REG(GRDevice, send_user_data);
METHOD_REG(GRDevice, start);
METHOD_REG(GRDevice, stop);
METHOD_REG(GRDevice, get_status);
register_signal<GRDevice>("status_changed", "status", GODOT_VARIANT_TYPE_INT);
register_signal<GRDevice>("user_data_received", "packet_id", GODOT_VARIANT_TYPE_NIL, "user_data", GODOT_VARIANT_TYPE_NIL);
register_property<GRDevice, uint16_t>("port", &GRDevice::set_port, &GRDevice::get_port, 52341);
}
#endif
void GRDevice::_notification(int p_notification) {
switch (p_notification) {
case NOTIFICATION_POSTINITIALIZE:
#ifndef GDNATIVE_LIBRARY
_init();
#endif
break;
case NOTIFICATION_PREDELETE:
_deinit();
break;
}
}
void GRDevice::_reset_counters() {
avg_fps = min_fps = max_fps = 0;
avg_ping = min_ping = max_ping = 0;
fps_queue = ping_queue = iterable_queue<uint64_t>();
}
void GRDevice::_update_avg_ping(uint64_t ping) {
ping_queue.add_value_limited(ping, avg_ping_max_count);
calculate_avg_min_max_values(ping_queue, &avg_ping, &min_ping, &max_ping, &GRDevice::_ping_calc_modifier);
}
void GRDevice::_update_avg_fps(uint64_t frametime) {
fps_queue.add_value_limited(frametime, (int)round(Engine::get_singleton()->get_frames_per_second()));
calculate_avg_min_max_values(fps_queue, &avg_fps, &min_fps, &max_fps, &GRDevice::_fps_calc_modifier);
}
float GRDevice::_ping_calc_modifier(double i) {
return float(i * 0.001);
}
float GRDevice::_fps_calc_modifier(double i) {
if (i > 0)
return float(1000000.0 / i);
else
return 0;
}
void GRDevice::send_user_data(Variant packet_id, Variant user_data, bool full_objects) {
Mutex_lock(send_queue_mutex);
Ref<GRPacketCustomUserData> packet = newref(GRPacketCustomUserData);
send_packet(packet);
packet->set_packet_id(packet_id);
packet->set_send_full_objects(full_objects);
packet->set_user_data(user_data);
Mutex_unlock(send_queue_mutex);
}
void GRDevice::_send_queue_resize(int new_size) {
Mutex_lock(send_queue_mutex);
send_queue.resize(new_size);
Mutex_unlock(send_queue_mutex);
}
Ref<GRPacket> GRDevice::_send_queue_pop_front() {
Mutex_lock(send_queue_mutex);
Ref<GRPacket> packet;
if (send_queue.size() > 0) {
packet = send_queue.front();
send_queue.erase(send_queue.begin());
}
Mutex_unlock(send_queue_mutex);
return packet;
}
void GRDevice::set_status(WorkingStatus status) {
working_status = status;
emit_signal("status_changed", working_status);
}
float GRDevice::get_avg_ping() {
return avg_ping;
}
float GRDevice::get_min_ping() {
return min_ping;
}
float GRDevice::get_max_ping() {
return max_ping;
}
float GRDevice::get_avg_fps() {
return avg_fps;
}
float GRDevice::get_min_fps() {
return min_fps;
}
float GRDevice::get_max_fps() {
return max_fps;
}
uint16_t GRDevice::get_port() {
return port;
}
void GRDevice::set_port(uint16_t _port) {
port = _port;
restart();
}
void GRDevice::send_packet(Ref<GRPacket> packet) {
ERR_FAIL_COND(packet.is_null());
Mutex_lock(send_queue_mutex);
if (send_queue.size() > 10000)
send_queue.resize(0);
send_queue.push_back(packet);
Mutex_unlock(send_queue_mutex);
}
void GRDevice::start() {
call_deferred("_internal_call_only_deffered_start");
}
void GRDevice::stop() {
call_deferred("_internal_call_only_deffered_stop");
}
void GRDevice::restart() {
call_deferred("_internal_call_only_deffered_restart");
}
void GRDevice::_internal_call_only_deffered_restart() {
if (get_status() == (int)WorkingStatus::STATUS_WORKING) {
_internal_call_only_deffered_stop();
_internal_call_only_deffered_start();
}
}
GRDevice::WorkingStatus GRDevice::get_status() {
return working_status;
}
void GRDevice::_init() {
LEAVE_IF_EDITOR();
port = GET_PS(GodotRemote::ps_general_port_name);
Mutex_delete(send_queue_mutex);
Mutex_create(send_queue_mutex);
}
void GRDevice::_deinit() {
LEAVE_IF_EDITOR();
Mutex_delete(send_queue_mutex);
if (GodotRemote::get_singleton()) {
GodotRemote::get_singleton()->device = nullptr;
}
}

View File

@ -0,0 +1,143 @@
/* GRDevice.h */
#pragma once
#include "GRInputData.h"
#include "GRPacket.h"
#include "GRUtils.h"
#ifndef GDNATIVE_LIBRARY
#include "scene/main/node.h"
#else
#include <Array.hpp>
#include <Godot.hpp>
#include <Node.hpp>
#include <PoolArrays.hpp>
#include <Ref.hpp>
#include <Reference.hpp>
#include <String.hpp>
using namespace godot;
#endif
class GRDevice : public Node {
GD_CLASS(GRDevice, Node);
public:
enum class AuthResult : int {
OK = 0,
Error = 1,
Timeout = 2,
TryToConnect = 3,
RefuseConnection = 4,
VersionMismatch = 5,
IncorrectPassword = 6,
PasswordRequired = 7,
};
enum WorkingStatus : int {
STATUS_STOPPED = 0,
STATUS_WORKING = 1,
STATUS_STOPPING = 2,
STATUS_STARTING = 3,
};
enum TypesOfServerSettings : int {
SERVER_SETTINGS_USE_INTERNAL = 0,
SERVER_SETTINGS_VIDEO_STREAM_ENABLED = 1,
SERVER_SETTINGS_COMPRESSION_TYPE = 2,
SERVER_SETTINGS_JPG_QUALITY = 3,
SERVER_SETTINGS_SKIP_FRAMES = 4,
SERVER_SETTINGS_RENDER_SCALE = 5,
};
enum Subsampling : int {
SUBSAMPLING_Y_ONLY = 0,
SUBSAMPLING_H1V1 = 1,
SUBSAMPLING_H2V1 = 2,
SUBSAMPLING_H2V2 = 3
};
enum ImageCompressionType : int {
COMPRESSION_UNCOMPRESSED = 0,
COMPRESSION_JPG = 1,
COMPRESSION_PNG = 2,
};
private:
WorkingStatus working_status = WorkingStatus::STATUS_STOPPED;
protected:
template <class T>
T _find_queued_packet_by_type() {
for (int i = 0; i < send_queue.size(); i++) {
T o = send_queue[i];
if (o.is_valid()) {
return o;
}
}
return T();
}
GRUtils::iterable_queue<uint64_t> fps_queue;
GRUtils::iterable_queue<uint64_t> ping_queue;
float avg_ping = 0, min_ping = 0, max_ping = 0;
float avg_fps = 0, min_fps = 0, max_fps = 0;
uint32_t avg_ping_max_count = 100;
Mutex_define(send_queue_mutex);
std::vector<Ref<GRPacket> > send_queue;
void set_status(WorkingStatus status);
void _update_avg_ping(uint64_t ping);
void _update_avg_fps(uint64_t frametime);
static float _ping_calc_modifier(double i);
static float _fps_calc_modifier(double i);
void _send_queue_resize(int new_size);
Ref<GRPacket> _send_queue_pop_front();
virtual void _reset_counters();
virtual void _internal_call_only_deffered_start(){};
virtual void _internal_call_only_deffered_stop(){};
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_notification);
public:
uint16_t port = 52341;
float get_avg_ping();
float get_min_ping();
float get_max_ping();
float get_avg_fps();
float get_min_fps();
float get_max_fps();
uint16_t get_port();
void set_port(uint16_t _port);
void send_packet(Ref<GRPacket> packet);
void send_user_data(Variant packet_id, Variant user_data, bool full_objects = false);
void start();
void stop();
void restart();
void _internal_call_only_deffered_restart();
virtual WorkingStatus get_status();
void _init();
void _deinit();
};
#ifndef GDNATIVE_LIBRARY
VARIANT_ENUM_CAST(GRDevice::WorkingStatus)
VARIANT_ENUM_CAST(GRDevice::Subsampling)
VARIANT_ENUM_CAST(GRDevice::ImageCompressionType)
VARIANT_ENUM_CAST(GRDevice::TypesOfServerSettings)
#endif

View File

@ -0,0 +1,461 @@
/* GRInputData.cpp */
#include "GRInputData.h"
#include "GRPacket.h"
#ifndef GDNATIVE_LIBRARY
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
#include "scene/main/viewport.h"
#else
#include <OS.hpp>
#include <SceneTree.hpp>
#include <Viewport.hpp>
using namespace godot;
#endif
using namespace GRUtils;
void GRInputDeviceSensorsData::set_sensors(PoolVector3Array _sensors) {
data->resize(0);
data->put_8((uint8_t)get_type());
data->put_var(_sensors);
}
PoolVector3Array GRInputDeviceSensorsData::get_sensors() {
data->seek(0);
data->get_8();
return data->get_var();
}
Ref<GRInputData> GRInputData::create(const PoolByteArray &buf) {
#define CREATE(_d) \
{ \
Ref<_d> id(memnew(_d)); \
id->data->set_data_array(buf); \
return id; \
}
InputType type = (InputType)((PoolByteArray)buf)[0];
switch (type) {
case InputType::_NoneIT:
ERR_PRINT("Can't create GRInputData with type 'None'!");
break;
// ADDITIONAL CLASSES
case InputType::_InputDeviceSensors:
CREATE(GRInputDeviceSensorsData);
// INPUT EVENTS
case InputType::_InputEvent:
case InputType::_InputEventWithModifiers:
case InputType::_InputEventMouse:
case InputType::_InputEventGesture:
ERR_PRINT("Can't create GRInputData for abstract InputEvent! Type index: " + str((int)type));
break;
case InputType::_InputEventAction:
CREATE(GRIEDataAction);
case InputType::_InputEventJoypadButton:
CREATE(GRIEDataJoypadButton);
case InputType::_InputEventJoypadMotion:
CREATE(GRIEDataJoypadMotion);
case InputType::_InputEventKey:
CREATE(GRIEDataKey);
case InputType::_InputEventMagnifyGesture:
CREATE(GRIEDataMagnifyGesture);
case InputType::_InputEventMIDI:
CREATE(GRIEDataMIDI);
case InputType::_InputEventMouseButton:
CREATE(GRIEDataMouseButton);
case InputType::_InputEventMouseMotion:
CREATE(GRIEDataMouseMotion);
case InputType::_InputEventPanGesture:
CREATE(GRIEDataPanGesture);
case InputType::_InputEventScreenDrag:
CREATE(GRIEDataScreenDrag);
case InputType::_InputEventScreenTouch:
CREATE(GRIEDataScreenTouch);
}
#undef CREATE
ERR_PRINT("Can't create unsupported GRInputData! Type index: " + str((int)type));
return Ref<GRInputData>();
}
Ref<GRInputDataEvent> GRInputDataEvent::parse_event(const Ref<InputEvent> &ev, const Rect2 &rect) {
if (ev.is_null())
ERR_FAIL_COND_V(ev.is_null(), Ref<GRInputDataEvent>());
#define PARSE(_i, _d) \
{ \
Ref<_i> ie = ev; \
if (ie.is_valid()) { \
Ref<_d> data(memnew(_d)); \
data->_parse_event(ie, rect); \
return data; \
} \
}
PARSE(InputEventKey, GRIEDataKey);
PARSE(InputEventMouseButton, GRIEDataMouseButton);
PARSE(InputEventMouseMotion, GRIEDataMouseMotion);
PARSE(InputEventScreenTouch, GRIEDataScreenTouch);
PARSE(InputEventScreenDrag, GRIEDataScreenDrag);
PARSE(InputEventMagnifyGesture, GRIEDataMagnifyGesture);
PARSE(InputEventPanGesture, GRIEDataPanGesture);
PARSE(InputEventJoypadButton, GRIEDataJoypadButton);
PARSE(InputEventJoypadMotion, GRIEDataJoypadMotion);
PARSE(InputEventAction, GRIEDataAction);
PARSE(InputEventMIDI, GRIEDataMIDI);
#undef PARSE
ERR_PRINT("Not supported InputEvent type: " + str(ev));
return Ref<GRInputDataEvent>();
}
Ref<InputEvent> GRInputDataEvent::construct_event(const Rect2 &rect) {
ERR_FAIL_COND_V(!data->get_size(), Ref<InputEvent>());
#define CONSTRUCT(_i) \
{ \
Ref<_i> ev(memnew(_i)); \
return _construct_event(ev, vp_size); \
}
InputType type = _get_type();
ERR_FAIL_COND_V_MSG(type < InputType::_InputEvent || type >= InputType::_InputEventMAX, Ref<GRInputDataEvent>(), "Not InputEvent");
Rect2 vp_size = rect;
if (vp_size.size.x == 0 && vp_size.size.y == 0 &&
vp_size.position.x == 0 && vp_size.position.y == 0) {
if (ST() && ST()->get_root()) {
//vp_size = SceneTree::get_singleton()->get_root()->get_visible_rect();
vp_size = Rect2(OS::get_singleton()->get_window_size(), ST()->get_root()->get_size());
}
}
switch (type) {
case InputType::_NoneIT:
ERR_PRINT("Can't create GRInputDataEvent with type 'None'!");
break;
case InputType::_InputEvent:
case InputType::_InputEventWithModifiers:
case InputType::_InputEventMouse:
case InputType::_InputEventGesture:
ERR_PRINT("Can't create GRInputDataEvent for abstract InputEvent! Type index: " + str((int)type));
break;
case InputType::_InputEventAction:
CONSTRUCT(InputEventAction);
case InputType::_InputEventJoypadButton:
CONSTRUCT(InputEventJoypadButton);
case InputType::_InputEventJoypadMotion:
CONSTRUCT(InputEventJoypadMotion);
case InputType::_InputEventKey:
CONSTRUCT(InputEventKey);
case InputType::_InputEventMagnifyGesture:
CONSTRUCT(InputEventMagnifyGesture);
case InputType::_InputEventMIDI:
CONSTRUCT(InputEventMIDI);
case InputType::_InputEventMouseButton:
CONSTRUCT(InputEventMouseButton);
case InputType::_InputEventMouseMotion:
CONSTRUCT(InputEventMouseMotion);
case InputType::_InputEventPanGesture:
CONSTRUCT(InputEventPanGesture);
case InputType::_InputEventScreenDrag:
CONSTRUCT(InputEventScreenDrag);
case InputType::_InputEventScreenTouch:
CONSTRUCT(InputEventScreenTouch);
}
#undef CONSTRUCT
return Ref<InputEvent>();
}
#define fix(_e) ((Vector2(_e) - rect.position) / rect.size)
#define fix_rel(_e) (Vector2(_e) / rect.size)
#define restore(_e) ((Vector2(_e) * rect.size) + ((rect.position - rect.size) / 2.f))
#define restore_rel(_e) (Vector2(_e) * rect.size)
#define CONSTRUCT(_type) Ref<InputEvent> _type::_construct_event(Ref<InputEvent> ev, const Rect2 &rect)
#define PARSE(_type) void _type::_parse_event(const Ref<InputEvent> &ev, const Rect2 &rect)
//////////////////////////////////////////////////////////////////////////
// InputEventWithModifiers
CONSTRUCT(GRIEDataWithModifiers) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventWithModifiers> iewm = ev;
uint8_t flags = (uint8_t)data->get_8();
iewm->set_alt(flags & (1 << 0));
iewm->set_shift(flags & (1 << 1));
iewm->set_control(flags & (1 << 2));
iewm->set_metakey(flags & (1 << 3));
iewm->set_command(flags & (1 << 4));
return iewm;
}
PARSE(GRIEDataWithModifiers) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventWithModifiers> iewm = ev;
data->put_8((uint8_t)iewm->get_alt() | (uint8_t)iewm->get_shift() << 1 | (uint8_t)iewm->get_control() << 2 |
(uint8_t)iewm->get_metakey() << 3 | (uint8_t)iewm->get_command() << 4);
}
//////////////////////////////////////////////////////////////////////////
// InputEventMouse
CONSTRUCT(GRIEDataMouse) {
GRIEDataWithModifiers::_construct_event(ev, rect);
Ref<InputEventMouse> iem = ev;
iem->set_button_mask(data->get_32());
iem->set_position(restore(data->get_var()));
iem->set_global_position(restore(data->get_var()));
return iem;
}
PARSE(GRIEDataMouse) {
GRIEDataWithModifiers::_parse_event(ev, rect);
Ref<InputEventMouse> iem = ev;
data->put_32(iem->get_button_mask());
data->put_var(fix(iem->get_position()));
data->put_var(fix(iem->get_global_position()));
}
//////////////////////////////////////////////////////////////////////////
// InputEventGesture
CONSTRUCT(GRIEDataGesture) {
GRIEDataWithModifiers::_construct_event(ev, rect);
Ref<InputEventGesture> ieg = ev;
ieg->set_position(restore(data->get_var()));
return ieg;
}
PARSE(GRIEDataGesture) {
GRIEDataWithModifiers::_parse_event(ev, rect);
Ref<InputEventGesture> ieg = ev;
data->put_var(fix(ieg->get_position()));
}
//////////////////////////////////////////////////////////////////////////
// InputEventKey
CONSTRUCT(GRIEDataKey) {
GRIEDataWithModifiers::_construct_event(ev, rect);
Ref<InputEventKey> iek = ev;
uint8_t flags = (uint8_t)data->get_8();
iek->set_pressed(flags & 1);
iek->set_echo((flags >> 1) & 1);
iek->set_scancode(data->get_32());
iek->set_unicode(data->get_32());
return iek;
}
PARSE(GRIEDataKey) {
GRIEDataWithModifiers::_parse_event(ev, rect);
Ref<InputEventKey> iek = ev;
data->put_8((uint8_t)iek->is_pressed() | (uint8_t)iek->is_echo() << 1);
data->put_32(iek->get_scancode());
data->put_32(iek->get_unicode());
}
//////////////////////////////////////////////////////////////////////////
// InputEventMouseButton
CONSTRUCT(GRIEDataMouseButton) {
GRIEDataMouse::_construct_event(ev, rect);
Ref<InputEventMouseButton> iemb = ev;
iemb->set_factor(data->get_float());
iemb->set_button_index(data->get_16());
uint8_t flags = (uint8_t)data->get_8();
iemb->set_pressed(flags & 1);
iemb->set_doubleclick((flags >> 1) & 1);
return iemb;
}
PARSE(GRIEDataMouseButton) {
GRIEDataMouse::_parse_event(ev, rect);
Ref<InputEventMouseButton> iemb = ev;
data->put_float(iemb->get_factor());
data->put_16(iemb->get_button_index());
data->put_8((uint8_t)iemb->is_pressed() | (uint8_t)iemb->is_doubleclick() << 1);
}
//////////////////////////////////////////////////////////////////////////
// InputEventMouseMotion
CONSTRUCT(GRIEDataMouseMotion) {
GRIEDataMouse::_construct_event(ev, rect);
Ref<InputEventMouseMotion> iemm = ev;
iemm->set_pressure(data->get_float());
iemm->set_tilt(data->get_var());
iemm->set_relative(restore_rel(data->get_var()));
iemm->set_speed(restore_rel(data->get_var()));
return iemm;
}
PARSE(GRIEDataMouseMotion) {
GRIEDataMouse::_parse_event(ev, rect);
Ref<InputEventMouseMotion> iemm = ev;
data->put_float(iemm->get_pressure());
data->put_var(iemm->get_tilt());
data->put_var(fix_rel(iemm->get_relative()));
data->put_var(fix_rel(iemm->get_speed()));
}
//////////////////////////////////////////////////////////////////////////
// InputEventScreenTouch
CONSTRUCT(GRIEDataScreenTouch) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventScreenTouch> iest = ev;
iest->set_index(data->get_8());
iest->set_pressed(data->get_8());
iest->set_position(restore(data->get_var()));
return iest;
}
PARSE(GRIEDataScreenTouch) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventScreenTouch> iest = ev;
data->put_8(iest->get_index());
data->put_8(iest->is_pressed());
data->put_var(fix(iest->get_position()));
}
//////////////////////////////////////////////////////////////////////////
// InputEventScreenDrag
CONSTRUCT(GRIEDataScreenDrag) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventScreenDrag> iesd = ev;
iesd->set_index(data->get_8());
iesd->set_position(restore(data->get_var()));
iesd->set_relative(restore_rel(data->get_var()));
iesd->set_speed(restore_rel(data->get_var()));
return iesd;
}
PARSE(GRIEDataScreenDrag) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventScreenDrag> iesd = ev;
data->put_8(iesd->get_index());
data->put_var(fix(iesd->get_position()));
data->put_var(fix_rel(iesd->get_relative()));
data->put_var(fix_rel(iesd->get_speed()));
}
//////////////////////////////////////////////////////////////////////////
// InputEventMagnifyGesture
CONSTRUCT(GRIEDataMagnifyGesture) {
GRIEDataGesture::_construct_event(ev, rect);
Ref<InputEventMagnifyGesture> iemg = ev;
iemg->set_factor(data->get_float());
return iemg;
}
PARSE(GRIEDataMagnifyGesture) {
GRIEDataGesture::_parse_event(ev, rect);
Ref<InputEventMagnifyGesture> iemg = ev;
data->put_float(iemg->get_factor());
}
//////////////////////////////////////////////////////////////////////////
// InputEventPanGesture
CONSTRUCT(GRIEDataPanGesture) {
GRIEDataGesture::_construct_event(ev, rect);
Ref<InputEventPanGesture> iepg = ev;
iepg->set_delta(restore_rel(data->get_var()));
return iepg;
}
PARSE(GRIEDataPanGesture) {
GRIEDataGesture::_parse_event(ev, rect);
Ref<InputEventPanGesture> iepg = ev;
data->put_var(fix_rel(iepg->get_delta()));
}
//////////////////////////////////////////////////////////////////////////
// InputEventPanGesture
CONSTRUCT(GRIEDataJoypadButton) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventJoypadButton> iejb = ev;
iejb->set_button_index(data->get_32());
iejb->set_pressure(data->get_float());
iejb->set_pressed(data->get_8());
return iejb;
}
PARSE(GRIEDataJoypadButton) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventJoypadButton> iejb = ev;
data->put_32(iejb->get_button_index());
data->put_float(iejb->get_pressure());
data->put_8(iejb->is_pressed());
}
//////////////////////////////////////////////////////////////////////////
// InputEventJoypadMotion
CONSTRUCT(GRIEDataJoypadMotion) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventJoypadMotion> iejm = ev;
iejm->set_axis(data->get_32());
iejm->set_axis_value(data->get_float());
return iejm;
}
PARSE(GRIEDataJoypadMotion) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventJoypadMotion> iejm = ev;
data->put_32(iejm->get_axis());
data->put_float(iejm->get_axis_value());
}
//////////////////////////////////////////////////////////////////////////
// InputEventAction
CONSTRUCT(GRIEDataAction) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventAction> iea = ev;
iea->set_action(data->get_var());
iea->set_strength(data->get_float());
iea->set_pressed(data->get_8());
return iea;
}
PARSE(GRIEDataAction) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventAction> iea = ev;
data->put_var(iea->get_action());
data->put_float(iea->get_strength());
data->put_8(iea->is_pressed());
}
//////////////////////////////////////////////////////////////////////////
// InputEventAction
CONSTRUCT(GRIEDataMIDI) {
GRInputDataEvent::_construct_event(ev, rect);
Ref<InputEventMIDI> iemidi = ev;
iemidi->set_channel(data->get_32());
iemidi->set_message(data->get_32());
iemidi->set_pitch(data->get_32());
iemidi->set_velocity(data->get_32());
iemidi->set_instrument(data->get_32());
iemidi->set_pressure(data->get_32());
iemidi->set_controller_number(data->get_32());
iemidi->set_controller_value(data->get_32());
return iemidi;
}
PARSE(GRIEDataMIDI) {
GRInputDataEvent::_parse_event(ev, rect);
Ref<InputEventMIDI> iemidi = ev;
data->put_32(iemidi->get_channel());
data->put_32(iemidi->get_message());
data->put_32(iemidi->get_pitch());
data->put_32(iemidi->get_velocity());
data->put_32(iemidi->get_instrument());
data->put_32(iemidi->get_pressure());
data->put_32(iemidi->get_controller_number());
data->put_32(iemidi->get_controller_value());
}
#undef fix
#undef fix_rel
#undef restore
#undef CONSTRUCT
#undef PARSE

View File

@ -0,0 +1,213 @@
/* GRInputData.h */
#pragma once
#include "GRUtils.h"
#ifndef GDNATIVE_LIBRARY
#include "core/io/stream_peer.h"
#include "core/os/input_event.h"
#include "core/reference.h"
#else
#include <Array.hpp>
#include <Godot.hpp>
#include <InputEvent.hpp>
#include <InputEventAction.hpp>
#include <InputEventGesture.hpp>
#include <InputEventJoypadButton.hpp>
#include <InputEventJoypadMotion.hpp>
#include <InputEventKey.hpp>
#include <InputEventMIDI.hpp>
#include <InputEventMagnifyGesture.hpp>
#include <InputEventMouse.hpp>
#include <InputEventMouseButton.hpp>
#include <InputEventMouseMotion.hpp>
#include <InputEventPanGesture.hpp>
#include <InputEventScreenDrag.hpp>
#include <InputEventScreenTouch.hpp>
#include <InputEventWithModifiers.hpp>
#include <PoolArrays.hpp>
#include <Ref.hpp>
#include <Reference.hpp>
#include <StreamPeer.hpp>
#include <StreamPeerBuffer.hpp>
#include <String.hpp>
using namespace godot;
#endif
//////////////////////////////////////////////////////////////////////////
// BASE CLASS
// GodotRemoteInputData
class GRInputData : public Reference {
GD_CLASS(GRInputData, Reference);
friend class GRInputDeviceSensorsData;
public:
enum InputType : int {
_NoneIT = 0,
// Custom Input Data
_InputDeviceSensors = 1,
// Input Events
_InputEvent = 64,
_InputEventAction = 65,
_InputEventGesture = 66,
_InputEventJoypadButton = 67,
_InputEventJoypadMotion = 68,
_InputEventKey = 69,
_InputEventMagnifyGesture = 70,
_InputEventMIDI = 71,
_InputEventMouse = 72,
_InputEventMouseButton = 73,
_InputEventMouseMotion = 74,
_InputEventPanGesture = 75,
_InputEventScreenDrag = 76,
_InputEventScreenTouch = 77,
_InputEventWithModifiers = 78,
_InputEventMAX,
};
protected:
#ifndef GDNATIVE_LIBRARY
static void _bind_methods() {
BIND_ENUM_CONSTANT(_NoneIT);
BIND_ENUM_CONSTANT(_InputDeviceSensors);
BIND_ENUM_CONSTANT(_InputEvent);
BIND_ENUM_CONSTANT(_InputEventAction);
BIND_ENUM_CONSTANT(_InputEventGesture);
BIND_ENUM_CONSTANT(_InputEventJoypadButton);
BIND_ENUM_CONSTANT(_InputEventJoypadMotion);
BIND_ENUM_CONSTANT(_InputEventKey);
BIND_ENUM_CONSTANT(_InputEventMagnifyGesture);
BIND_ENUM_CONSTANT(_InputEventMIDI);
BIND_ENUM_CONSTANT(_InputEventMouse);
BIND_ENUM_CONSTANT(_InputEventMouseButton);
BIND_ENUM_CONSTANT(_InputEventMouseMotion);
BIND_ENUM_CONSTANT(_InputEventPanGesture);
BIND_ENUM_CONSTANT(_InputEventScreenDrag);
BIND_ENUM_CONSTANT(_InputEventScreenTouch);
BIND_ENUM_CONSTANT(_InputEventWithModifiers);
BIND_ENUM_CONSTANT(_InputEventMAX);
}
#else
public:
void _init(){};
static void _register_methods(){};
protected:
#endif
Ref<StreamPeerBuffer> data;
virtual InputType _get_type() { return InputType::_NoneIT; };
public:
GRInputData() {
data = Ref<StreamPeerBuffer>(memnew(StreamPeerBuffer));
}
~GRInputData() {
data->resize(0);
}
PoolByteArray get_data() {
return data->get_data_array();
}
void set_data(PoolByteArray &_data) {
data->set_data_array(_data);
}
virtual InputType get_type() {
if (data->get_size()) {
data->seek(0);
return (InputType)data->get_8();
} else {
return _get_type();
}
};
static Ref<GRInputData> create(const PoolByteArray &buf);
};
//////////////////////////////////////////////////////////////////////////
// TODO for now all custom classes must add first 8 bits for type
// data->put_8((uint8_t)get_type())
//////////////////////////////////////////////////////////////////////////
// ADDITIONAL CLASSES
// Device Sensors
class GRInputDeviceSensorsData : public GRInputData {
GD_S_CLASS(GRInputDeviceSensorsData, GRInputData);
protected:
GDNATIVE_BASIC_REGISTER;
virtual InputType _get_type() override { return InputType::_InputDeviceSensors; };
public:
virtual void set_sensors(PoolVector3Array _sensors);
virtual PoolVector3Array get_sensors();
};
//////////////////////////////////////////////////////////////////////////
// INPUT EVENTS
// GodotRemoteInputEventData
class GRInputDataEvent : public GRInputData {
GD_S_CLASS(GRInputDataEvent, GRInputData);
protected:
GDNATIVE_BASIC_REGISTER;
virtual Ref<InputEvent> _construct_event(Ref<InputEvent> ev, const Rect2 &rect) {
data->seek(0);
data->get_8();
ev->set_device(data->get_32());
return data;
};
virtual void _parse_event(const Ref<InputEvent> &ev, const Rect2 &rect) {
data->resize(0);
data->put_8((uint8_t)get_type());
data->put_32(ev->get_device());
};
virtual InputType _get_type() override { return InputType::_NoneIT; };
public:
Ref<InputEvent> construct_event(const Rect2 &rect = Rect2());
static Ref<GRInputDataEvent> parse_event(const Ref<InputEvent> &ev, const Rect2 &rect);
};
#define INPUT_EVENT_DATA(__class, _parent, _type) \
class __class : public _parent { \
GD_S_CLASS(__class, _parent); \
friend GRInputDataEvent; \
friend GRInputData; \
\
protected: \
GDNATIVE_BASIC_REGISTER; \
\
virtual Ref<InputEvent> _construct_event(Ref<InputEvent> ev, const Rect2 &rect) override; \
virtual void _parse_event(const Ref<InputEvent> &ev, const Rect2 &rect) override; \
virtual InputType _get_type() override { return _type; }; \
\
public: \
}
INPUT_EVENT_DATA(GRIEDataWithModifiers, GRInputDataEvent, InputType::_InputEventWithModifiers);
INPUT_EVENT_DATA(GRIEDataMouse, GRIEDataWithModifiers, InputType::_InputEventMouse);
INPUT_EVENT_DATA(GRIEDataGesture, GRIEDataWithModifiers, InputType::_InputEventGesture);
INPUT_EVENT_DATA(GRIEDataKey, GRIEDataWithModifiers, InputType::_InputEventKey);
INPUT_EVENT_DATA(GRIEDataMouseButton, GRIEDataMouse, InputType::_InputEventMouseButton);
INPUT_EVENT_DATA(GRIEDataMouseMotion, GRIEDataMouse, InputType::_InputEventMouseMotion);
INPUT_EVENT_DATA(GRIEDataScreenTouch, GRInputDataEvent, InputType::_InputEventScreenTouch);
INPUT_EVENT_DATA(GRIEDataScreenDrag, GRInputDataEvent, InputType::_InputEventScreenDrag);
INPUT_EVENT_DATA(GRIEDataMagnifyGesture, GRIEDataGesture, InputType::_InputEventMagnifyGesture);
INPUT_EVENT_DATA(GRIEDataPanGesture, GRIEDataGesture, InputType::_InputEventPanGesture);
INPUT_EVENT_DATA(GRIEDataJoypadButton, GRInputDataEvent, InputType::_InputEventJoypadButton);
INPUT_EVENT_DATA(GRIEDataJoypadMotion, GRInputDataEvent, InputType::_InputEventJoypadMotion);
INPUT_EVENT_DATA(GRIEDataAction, GRInputDataEvent, InputType::_InputEventAction);
INPUT_EVENT_DATA(GRIEDataMIDI, GRInputDataEvent, InputType::_InputEventMIDI);
#undef INPUT_EVENT_DATA
#ifndef GDNATIVE_LIBRARY
VARIANT_ENUM_CAST(GRInputData::InputType)
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,287 @@
/* GRNotifications.h */
#pragma once
#include "GRUtils.h"
#ifndef GDNATIVE_LIBRARY
#include "core/reference.h"
#include "scene/gui/panel_container.h"
#include "scene/main/canvas_layer.h"
#else
#include <Array.hpp>
#include <Button.hpp>
#include <CanvasLayer.hpp>
#include <Font.hpp>
#include <Godot.hpp>
#include <HBoxContainer.hpp>
#include <ImageTexture.hpp>
#include <Label.hpp>
#include <PanelContainer.hpp>
#include <PoolArrays.hpp>
#include <Ref.hpp>
#include <Reference.hpp>
#include <String.hpp>
#include <StyleBoxEmpty.hpp>
#include <StyleBoxFlat.hpp>
#include <TextureRect.hpp>
#include <Theme.hpp>
#include <Tween.hpp>
#include <VBoxContainer.hpp>
using namespace godot;
#endif
class GRNotificationPanel;
class GRNotificationStyle;
class GRNotificationPanelSTATIC_DATA;
class GRNotifications : public CanvasLayer {
GD_CLASS(GRNotifications, CanvasLayer);
friend class GRNotificationPanel;
public:
enum NotificationIcon : int {
ICON_NONE,
ICON_ERROR,
ICON_WARNING,
ICON_SUCCESS,
ICON_FAIL,
ICON_MAX,
};
enum NotificationsPosition : int {
TOP_LEFT = 0,
TOP_CENTER = 1,
TOP_RIGHT = 2,
BOTTOM_LEFT = 3,
BOTTOM_CENTER = 4,
BOTTOM_RIGHT = 5,
};
private:
static GRNotifications *singleton;
bool clearing_notifications = false;
float notifications_duration = 2.0;
bool notifications_enabled = true;
NotificationsPosition notifications_position = NotificationsPosition::TOP_LEFT;
class VBoxContainer *notif_list_node = nullptr;
std::vector<GRNotificationPanel *> notifications; // GRNotificationPanel *
Ref<GRNotificationStyle> style;
std::vector<GRNotificationPanel *> _get_notifications_with_title(String title); // GRNotificationPanel *
GRNotificationPanel *_get_notification(String title);
void _set_all_notifications_positions(NotificationsPosition pos);
void _set_notifications_position(ENUM_ARG(NotificationsPosition) positon);
void _add_notification_or_append_string(String title, String text, ENUM_ARG(NotificationIcon) icon, bool new_string, float duration_multiplier);
void _add_notification_or_update_line(String title, String id, String text, ENUM_ARG(NotificationIcon) icon, float duration_multiplier);
void _add_notification(String title, String text, ENUM_ARG(NotificationIcon) icon, bool update_existing, float duration_multiplier);
void _remove_notification(String title, bool all_entries);
void _remove_exact_notification(Node *_notif);
void _clear_notifications();
void _remove_list();
protected:
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_what);
public:
/// All functions below need to be called after init notification manager
/// For example call this after yield(get_tree(), "idle_frame")
static GRNotificationPanel *get_notification(String title);
static Array get_all_notifications();
static Array get_notifications_with_title(String title);
static NotificationsPosition get_notifications_position();
static void set_notifications_position(NotificationsPosition positon);
static bool get_notifications_enabled();
static void set_notifications_enabled(bool _enabled);
static float get_notifications_duration();
static void set_notifications_duration(float _duration);
static Ref<class GRNotificationStyle> get_notifications_style();
static void set_notifications_style(Ref<class GRNotificationStyle> _style);
// append text to existing notification or add new notification
static void add_notification_or_append_string(String title, String text, NotificationIcon icon = NotificationIcon::ICON_NONE, bool new_string = true, float duration_multiplier = 1.f);
// update text in existing notification or add new notification
static void add_notification_or_update_line(String title, String id, String text, NotificationIcon icon = NotificationIcon::ICON_NONE, float duration_multiplier = 1.);
static void add_notification(String title, String text, NotificationIcon icon DEF_ARG(= NotificationIcon::ICON_NONE), bool update_existing = true, float duration_multiplier = 1.f);
static void remove_notification(String title, bool all_entries = true);
static void remove_notification_exact(Node *_notif);
static void clear_notifications();
static GRNotifications *get_singleton();
void _init();
void _deinit();
};
// Stupid class to bypass GDNative limitations
// but also it can be changed back by changing default-style generating
class GRNotificationPanelSTATIC_DATA {
public:
Ref<GRNotificationStyle> _default_style;
#ifndef NO_GODOTREMOTE_DEFAULT_RESOURCES
Dictionary _default_textures;
Ref<ImageTexture> _default_close_texture;
#endif
};
class GRNotificationPanel : public PanelContainer {
GD_CLASS(GRNotificationPanel, PanelContainer);
friend GRNotifications;
protected:
GRNotifications *owner = nullptr;
GRNotifications::NotificationIcon notification_icon = GRNotifications::NotificationIcon::ICON_NONE;
float duration_mul = 1.f;
bool is_hovered = false;
Ref<GRNotificationStyle> style;
static GRNotificationPanelSTATIC_DATA *_default_data;
class VBoxContainer *vbox_node = nullptr;
class HBoxContainer *hbox_node = nullptr;
class TextureRect *icon_tex_node = nullptr;
class Label *title_node = nullptr;
class Label *text_node = nullptr;
class Button *close_node = nullptr;
class Tween *tween_node = nullptr;
void _panel_hovered();
void _panel_lose_hover();
void _remove_this_notification();
void _setup_tween(Tween *_tween);
void _update_style();
static Ref<class GRNotificationStyle> generate_default_style();
#ifndef NO_GODOTREMOTE_DEFAULT_RESOURCES
static void _load_default_textures();
#endif
protected:
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_notification);
public:
static void clear_styles();
void set_notification_position(GRNotifications::NotificationsPosition position);
virtual void set_data(GRNotifications *_owner, String title, String text, GRNotifications::NotificationIcon icon, float duration_multiplier DEF_ARG(= 1.f), Ref<GRNotificationStyle> _style DEF_ARG(= Ref<GRNotificationStyle>()));
String get_title();
String get_text();
void update_text(String text);
void _init();
void _deinit();
};
class GRNotificationPanelUpdatable : public GRNotificationPanel {
GD_S_CLASS(GRNotificationPanelUpdatable, GRNotificationPanel);
friend GRNotifications;
protected:
std::map<String, String> lines;
String _get_text_from_lines();
bool configured = false;
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_notification);
public:
void set_updatable_line(GRNotifications *_owner, String title, String id, String text, GRNotifications::NotificationIcon icon, float duration_multiplier DEF_ARG(= 1.f), Ref<GRNotificationStyle> _style DEF_ARG(= Ref<GRNotificationStyle>()));
void remove_updatable_line(String id);
void clear_lines();
void _init();
void _deinit();
};
// STYLE REF
class GRNotificationStyle : public Reference {
GD_CLASS(GRNotificationStyle, Reference);
private:
Ref<StyleBox> panel_style;
Ref<Theme> close_button_theme;
Ref<Texture> close_button_icon;
Ref<Font> title_font;
Ref<Font> text_font;
Ref<Texture> n_icons[GRNotifications::NotificationIcon::ICON_MAX];
protected:
#ifndef GDNATIVE_LIBRARY
static void _bind_methods();
#else
public:
static void _register_methods();
protected:
#endif
void _notification(int p_notification);
public:
void set_panel_style(Ref<StyleBox> style);
Ref<StyleBox> get_panel_style();
void set_close_button_theme(Ref<Theme> theme);
Ref<Theme> get_close_button_theme();
void set_close_button_icon(Ref<Texture> icon);
Ref<Texture> get_close_button_icon();
void set_title_font(Ref<Font> font);
Ref<Font> get_title_font();
void set_text_font(Ref<Font> font);
Ref<Font> get_text_font();
void set_notification_icon(ENUM_ARG(GRNotifications::NotificationIcon) notification_icon, Ref<Texture> icon_texture);
Ref<Texture> get_notification_icon(ENUM_ARG(GRNotifications::NotificationIcon) notification_icon);
void _init();
void _deinit();
};
#ifndef GDNATIVE_LIBRARY
VARIANT_ENUM_CAST(GRNotifications::NotificationsPosition)
VARIANT_ENUM_CAST(GRNotifications::NotificationIcon)
#endif

Some files were not shown because too many files have changed in this diff Show More