NAT Godot Playground click-and-drag proof of concept
This commit is contained in:
3
projects/nat-godot-playground/.gitignore
vendored
Normal file
3
projects/nat-godot-playground/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
*.import
|
||||||
|
.import/
|
||||||
|
.mono/
|
28
projects/nat-godot-playground/EntryControl.gd
Normal file
28
projects/nat-godot-playground/EntryControl.gd
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
extends PanelContainer
|
||||||
|
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
var z = 0
|
||||||
|
|
||||||
|
# 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_EntryControl_mouse_entered():
|
||||||
|
var current_focus_z = get_parent().current_focus_z
|
||||||
|
if is_nan(current_focus_z) or current_focus_z <= self.z:
|
||||||
|
get_parent().current_focus = self
|
||||||
|
get_parent().current_focus_z = self.z
|
||||||
|
|
||||||
|
func _on_EntryControl_mouse_exited():
|
||||||
|
if get_parent().current_focus == self:
|
||||||
|
get_parent().current_focus = null
|
||||||
|
get_parent().current_focus_z = NAN
|
41
projects/nat-godot-playground/Main.tscn
Normal file
41
projects/nat-godot-playground/Main.tscn
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
[gd_scene load_steps=3 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://Playground.gd" type="Script" id=1]
|
||||||
|
[ext_resource path="res://EntryControl.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[node name="Control" type="Control"]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
|
||||||
|
[node name="PlaygroundTabContainer" type="TabContainer" parent="."]
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
margin_right = 8.0
|
||||||
|
margin_bottom = 36.0
|
||||||
|
|
||||||
|
[node name="PlaygroundScrollContainer" type="ScrollContainer" parent="PlaygroundTabContainer"]
|
||||||
|
margin_right = -8.0
|
||||||
|
margin_bottom = -36.0
|
||||||
|
rect_min_size = Vector2( 1280, 720 )
|
||||||
|
|
||||||
|
[node name="Playground" type="Control" parent="PlaygroundTabContainer/PlaygroundScrollContainer"]
|
||||||
|
margin_right = 1280.0
|
||||||
|
margin_bottom = 720.0
|
||||||
|
rect_min_size = Vector2( 1280, 720 )
|
||||||
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
|
[node name="EntryContainer" type="PanelContainer" parent="PlaygroundTabContainer/PlaygroundScrollContainer/Playground"]
|
||||||
|
margin_right = 40.0
|
||||||
|
margin_bottom = 40.0
|
||||||
|
mouse_filter = 1
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="EntryLabel" type="Label" parent="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer"]
|
||||||
|
margin_left = 7.0
|
||||||
|
margin_top = 13.0
|
||||||
|
margin_right = 192.0
|
||||||
|
margin_bottom = 27.0
|
||||||
|
text = "Hello NAT Godot Playground!"
|
||||||
|
|
||||||
|
[connection signal="mouse_entered" from="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" to="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" method="_on_EntryControl_mouse_entered"]
|
||||||
|
[connection signal="mouse_exited" from="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" to="PlaygroundTabContainer/PlaygroundScrollContainer/Playground/EntryContainer" method="_on_EntryControl_mouse_exited"]
|
27
projects/nat-godot-playground/Playground.gd
Normal file
27
projects/nat-godot-playground/Playground.gd
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
extends Control
|
||||||
|
|
||||||
|
|
||||||
|
# Declare member variables here. Examples:
|
||||||
|
# var a = 2
|
||||||
|
# var b = "text"
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready():
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
var current_focus = null
|
||||||
|
var current_focus_z = NAN
|
||||||
|
|
||||||
|
func get_drag_data(position):
|
||||||
|
return current_focus
|
||||||
|
|
||||||
|
func can_drop_data(position, data):
|
||||||
|
return data != null
|
||||||
|
|
||||||
|
func drop_data(position, data):
|
||||||
|
data.rect_position = position
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
#func _process(delta):
|
||||||
|
# pass
|
7
projects/nat-godot-playground/default_env.tres
Normal file
7
projects/nat-godot-playground/default_env.tres
Normal 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 )
|
BIN
projects/nat-godot-playground/icon.png
Normal file
BIN
projects/nat-godot-playground/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.2 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
<Project Sdk="Godot.NET.Sdk/3.3.0">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net472</TargetFramework>
|
||||||
|
<RootNamespace>natgodotplayground</RootNamespace>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
19
projects/nat-godot-playground/nat-godot-playground.sln
Normal file
19
projects/nat-godot-playground/nat-godot-playground.sln
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 2012
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "nat-godot-playground", "nat-godot-playground.csproj", "{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
ExportDebug|Any CPU = ExportDebug|Any CPU
|
||||||
|
ExportRelease|Any CPU = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
|
||||||
|
{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
|
||||||
|
{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
|
||||||
|
{8A39B658-D6F9-4C5F-A2C3-1AFC696ED561}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
31
projects/nat-godot-playground/project.godot
Normal file
31
projects/nat-godot-playground/project.godot
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
; 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="nat-godot-playground"
|
||||||
|
run/main_scene="res://Main.tscn"
|
||||||
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
|
[gui]
|
||||||
|
|
||||||
|
common/drop_mouse_on_gui_input_disabled=true
|
||||||
|
|
||||||
|
[mono]
|
||||||
|
|
||||||
|
project/assembly_name="nat-godot-playground"
|
||||||
|
|
||||||
|
[physics]
|
||||||
|
|
||||||
|
common/enable_pause_aware_picking=true
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
environment/default_environment="res://default_env.tres"
|
Reference in New Issue
Block a user