Adding log.gd

This commit is contained in:
Dan Baker 2024-05-02 09:36:31 +01:00
parent eb32d6614e
commit 4522259397
547 changed files with 46844 additions and 0 deletions

View file

@ -0,0 +1,41 @@
extends PanelContainer
# Godot calls this method to get data that can be dragged and dropped onto controls that expect drop data.
# Returns null if there is no data to drag.
# Controls that want to receive drop data should implement can_drop_data() and drop_data().
# position is local to this control. Drag may be forced with force_drag().
func _get_drag_data(_position: Vector2) -> Variant:
var x :TextureRect = $TextureRect
var data: = {texture = x.texture}
var drag_texture := x.duplicate()
drag_texture.size = x.size
drag_texture.position = x.global_position * -0.2
# set drag preview
var control := Panel.new()
control.add_child(drag_texture)
# center texture relative to mouse pos
set_drag_preview(control)
return data
# Godot calls this method to test if data from a control's get_drag_data() can be dropped at position. position is local to this control.
func _can_drop_data(_position: Vector2, data :Variant) -> bool:
return typeof(data) == TYPE_DICTIONARY and data.has("texture")
# Godot calls this method to pass you the data from a control's get_drag_data() result.
# Godot first calls can_drop_data() to test if data is allowed to drop at position where position is local to this control.
func _drop_data(_position: Vector2, data :Variant) -> void:
var drag_texture :Texture = data["texture"]
if drag_texture != null:
$TextureRect.texture = drag_texture
# Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See accept_event().
func _gui_input(_event):
#prints("Panel _gui_input", _event.as_text())
#if _event is InputEventMouseButton:
# prints("Panel _gui_input", _event.as_text())
pass

View file

@ -0,0 +1,16 @@
[gd_scene load_steps=2 format=3 uid="uid://ca2rr3dan4vvw"]
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/DragAndDropControl.gd" id="1"]
[node name="Panel" type="PanelContainer"]
offset_left = 245.0
offset_top = 232.0
offset_right = 350.0
offset_bottom = 337.0
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1")
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 2
expand_mode = 1

View file

@ -0,0 +1,18 @@
extends Control
@onready var texture = preload("res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/icon.png")
func _ready():
# set initial drag texture
$left/TextureRect.texture = texture
# Virtual method to be implemented by the user. Use this method to process and accept inputs on UI elements. See accept_event().
func _gui_input(_event):
#prints("Game _gui_input", _event.as_text())
pass
func _on_Button_button_down():
# print("BUTTON DOWN")
pass

View file

@ -0,0 +1,43 @@
[gd_scene load_steps=3 format=3 uid="uid://skueh3d5qn46"]
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/DragAndDropTestScene.gd" id="1"]
[ext_resource type="PackedScene" uid="uid://ca2rr3dan4vvw" path="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/DragAndDropControl.tscn" id="2_u5ccv"]
[node name="DragAndDropScene" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1")
[node name="left" parent="." instance=ExtResource("2_u5ccv")]
layout_mode = 0
offset_left = 250.0
offset_top = 240.0
offset_right = 355.0
offset_bottom = 345.0
auto_translate = false
localize_numeral_system = false
metadata/_edit_use_anchors_ = true
[node name="right" parent="." instance=ExtResource("2_u5ccv")]
layout_mode = 0
offset_left = 370.0
offset_top = 240.0
offset_right = 475.0
offset_bottom = 345.0
[node name="Button" type="Button" parent="."]
layout_mode = 0
offset_left = 243.0
offset_top = 40.0
offset_right = 479.0
offset_bottom = 200.0
text = "BUTTON"
metadata/_edit_use_anchors_ = true
[connection signal="button_down" from="Button" to="." method="_on_Button_button_down"]

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://di6ovw8bnk7wg"
path="res://.godot/imported/icon.png-50a1939c45a5f06328a9e414b58963b1.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/gdUnit4/test/core/resources/scenes/drag_and_drop/icon.png"
dest_files=["res://.godot/imported/icon.png-50a1939c45a5f06328a9e414b58963b1.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -0,0 +1,15 @@
extends Control
var _player_jump_action_released := false
# enable for manual testing
func __init():
var event := InputEventKey.new()
event.keycode = KEY_SPACE
InputMap.add_action("player_jump")
InputMap.action_add_event("player_jump", event)
func _input(event):
_player_jump_action_released = Input.is_action_just_released("player_jump", true)
#prints("_input2:player_jump", Input.is_action_just_released("player_jump"), Input.is_action_just_released("player_jump", true))

View file

@ -0,0 +1,12 @@
[gd_scene load_steps=2 format=3 uid="uid://cvklb72mxqh1h"]
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/input_actions/InputEventTestScene.gd" id="1_wslmn"]
[node name="InputEventTestScene" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_wslmn")

View file

@ -0,0 +1,15 @@
extends Node2D
class Player extends Node:
var position :Vector3 = Vector3.ZERO
func _init():
set_name("Player")
func is_on_floor() -> bool:
return true
func _ready():
add_child(Player.new(), true)

View file

@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://cn8ucy2rheu0f"]
[ext_resource type="Texture2D" uid="uid://t80a6k3vyrrd" path="res://icon.png" id="1"]
[ext_resource type="Script" path="res://addons/gdUnit4/test/core/resources/scenes/simple_scene.gd" id="2"]
[node name="Node2D" type="Node2D"]
script = ExtResource("2")
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(504, 252)
texture = ExtResource("1")