Compare commits

8 Commits
main ... dev

Author SHA1 Message Date
Nikolai Fesenko
824c2981c5 test coin animation 2025-08-30 22:56:05 +02:00
Nikolai Fesenko
5120ceb4b7 new coin model 2025-08-30 22:51:01 +02:00
Nikolai Fesenko
c6fa8d175a new transition to phase 2 2025-08-30 22:19:21 +02:00
Nikolai Fesenko
dcbc8f3eba enemy revolver animations 2025-08-30 18:57:52 +02:00
Nikolai Fesenko
4e79762709 main scene anim player 2025-08-30 18:40:29 +02:00
Nikolai Fesenko
b4d7680213 added loading through animation player 2025-08-30 18:02:55 +02:00
Nikolai Fesenko
c0cac7919a phase 2 ai shooting 2025-08-29 20:37:25 +02:00
Nikolai Fesenko
fbd75b3397 added phase 1 of gameplay and ui buttons 2025-08-29 14:31:49 +02:00
37 changed files with 1908 additions and 34 deletions

BIN
Blends/Coin/coin.bin Normal file

Binary file not shown.

BIN
Blends/Coin/coin.blend Normal file

Binary file not shown.

View File

@@ -0,0 +1,53 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://lips2cgpmr8b"
path="res://.godot/imported/coin.blend-26f8edf08583f0fed81637dbe6ec82c6.scn"
[deps]
source_file="res://Blends/Coin/coin.blend"
dest_files=["res://.godot/imported/coin.blend-26f8edf08583f0fed81637dbe6ec82c6.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
blender/nodes/visible=0
blender/nodes/active_collection_only=false
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/export_geometry_nodes_instances=false
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true

205
Blends/Coin/coin.gltf Normal file
View File

@@ -0,0 +1,205 @@
{
"asset":{
"generator":"Khronos glTF Blender I/O v4.5.47",
"version":"2.0"
},
"scene":0,
"scenes":[
{
"name":"Scene",
"nodes":[
0
]
}
],
"nodes":[
{
"mesh":0,
"name":"Cylinder",
"scale":[
0.16937243938446045,
0.011989540420472622,
0.16937243938446045
]
}
],
"materials":[
{
"doubleSided":true,
"name":"Material.001",
"pbrMetallicRoughness":{
"baseColorFactor":[
0.8003232479095459,
0.7214018106460571,
0.048716265708208084,
1
],
"roughnessFactor":0.2857142686843872
}
},
{
"doubleSided":true,
"name":"Material.002",
"pbrMetallicRoughness":{
"baseColorFactor":[
1,
0.012268719263374805,
0.0156707726418972,
1
],
"roughnessFactor":0.3095238208770752
}
}
],
"meshes":[
{
"name":"Cylinder",
"primitives":[
{
"attributes":{
"POSITION":0,
"NORMAL":1,
"TEXCOORD_0":2
},
"indices":3,
"material":0
},
{
"attributes":{
"POSITION":4,
"NORMAL":5,
"TEXCOORD_0":6
},
"indices":7,
"material":1
}
]
}
],
"accessors":[
{
"bufferView":0,
"componentType":5126,
"count":580,
"max":[
1,
1,
1
],
"min":[
-1,
-1,
-1
],
"type":"VEC3"
},
{
"bufferView":1,
"componentType":5126,
"count":580,
"type":"VEC3"
},
{
"bufferView":2,
"componentType":5126,
"count":580,
"type":"VEC2"
},
{
"bufferView":3,
"componentType":5123,
"count":1140,
"type":"SCALAR"
},
{
"bufferView":4,
"componentType":5126,
"count":18978,
"max":[
0.8202698230743408,
1.6481459140777588,
0.4704993665218353
],
"min":[
-0.7866606712341309,
-1.5491652488708496,
-0.7433416843414307
],
"type":"VEC3"
},
{
"bufferView":5,
"componentType":5126,
"count":18978,
"type":"VEC3"
},
{
"bufferView":6,
"componentType":5126,
"count":18978,
"type":"VEC2"
},
{
"bufferView":7,
"componentType":5123,
"count":75216,
"type":"SCALAR"
}
],
"bufferViews":[
{
"buffer":0,
"byteLength":6960,
"byteOffset":0,
"target":34962
},
{
"buffer":0,
"byteLength":6960,
"byteOffset":6960,
"target":34962
},
{
"buffer":0,
"byteLength":4640,
"byteOffset":13920,
"target":34962
},
{
"buffer":0,
"byteLength":2280,
"byteOffset":18560,
"target":34963
},
{
"buffer":0,
"byteLength":227736,
"byteOffset":20840,
"target":34962
},
{
"buffer":0,
"byteLength":227736,
"byteOffset":248576,
"target":34962
},
{
"buffer":0,
"byteLength":151824,
"byteOffset":476312,
"target":34962
},
{
"buffer":0,
"byteLength":150432,
"byteOffset":628136,
"target":34963
}
],
"buffers":[
{
"byteLength":778568,
"uri":"coin.bin"
}
]
}

View File

@@ -0,0 +1,37 @@
[remap]
importer="scene"
importer_version=1
type="PackedScene"
uid="uid://bah3dldj3s48g"
path="res://.godot/imported/coin.gltf-714424d1598d1074dffd6ddc1f2a93ca.scn"
[deps]
source_file="res://Blends/Coin/coin.gltf"
dest_files=["res://.godot/imported/coin.gltf-714424d1598d1074dffd6ddc1f2a93ca.scn"]
[params]
nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
nodes/use_node_type_suffixes=true
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
gltf/naming_version=1
gltf/embedded_image_handling=1

73
Scenes/coin.tscn Normal file
View File

@@ -0,0 +1,73 @@
[gd_scene load_steps=5 format=3 uid="uid://7s0s5nac7psb"]
[ext_resource type="PackedScene" uid="uid://bah3dldj3s48g" path="res://Blends/Coin/coin.gltf" id="1_2qo34"]
[sub_resource type="Animation" id="Animation_2qo34"]
resource_name = "coin_jump_1"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Cylinder:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2008, 0.3008, 0.4008, 0.5008, 0.6008, 0.7008, 0.8008, 0.9, 1),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(0, 0.175061, 0), Vector3(0, 0.368962, 0), Vector3(0, 0.610777, 0), Vector3(0, 0.967692, 0), Vector3(0, 1.4979, 0), Vector3(0, 1.89916, 0), Vector3(0, 2.23659, 0), Vector3(0, 2.95364, 0), Vector3(0, 3.47685, 0), Vector3(0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Cylinder:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.1, 0.2008, 0.3008, 0.4008, 0.5008, 0.6008, 0.7008, 0.8008, 0.9, 1),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
"update": 0,
"values": [Vector3(0, 0, 0), Vector3(0.174533, 0, 0), Vector3(0.872665, 0, 0), Vector3(2.54818, 0, 0), Vector3(3.14159, 0, 0), Vector3(-2.39983, 0, 0), Vector3(-1.14319, 0, 0), Vector3(0.113446, 0, 0), Vector3(1.16064, 0, 0), Vector3(3.0456, 0, 0), Vector3(3.14159, 0, 0)]
}
[sub_resource type="Animation" id="Animation_jgi06"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Cylinder:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Cylinder:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_g537i"]
_data = {
&"RESET": SubResource("Animation_jgi06"),
&"coin_jump_1": SubResource("Animation_2qo34")
}
[node name="coin" instance=ExtResource("1_2qo34")]
[node name="Cylinder" parent="." index="0"]
transform = Transform3D(0.169372, 0, 0, 0, 0.0119895, 0, 0, 0, 0.169372, 0, 0, 0)
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="1"]
libraries = {
&"": SubResource("AnimationLibrary_g537i")
}

View File

@@ -1,10 +1,180 @@
[gd_scene load_steps=6 format=3 uid="uid://b4ot3p50x08po"]
[gd_scene load_steps=14 format=3 uid="uid://b4ot3p50x08po"]
[ext_resource type="PackedScene" uid="uid://cuqeg7u667dw6" path="res://Blends/Room/room.gltf" id="1_jjgbg"]
[ext_resource type="PackedScene" uid="uid://j06vthscroca" path="res://Scenes/bullet.tscn" id="3_8gbba"]
[ext_resource type="PackedScene" uid="uid://bge7npb7b1y6x" path="res://Scenes/revolver.tscn" id="4_jjvhh"]
[ext_resource type="Script" uid="uid://dcmqt4341kxem" path="res://Scripts/bullet_stack.gd" id="4_kry3j"]
[ext_resource type="PackedScene" uid="uid://bueqdw22nl501" path="res://Scenes/AI.tscn" id="5_kry3j"]
[ext_resource type="PackedScene" uid="uid://cbr3e8xsfwyhf" path="res://Scenes/main_game_ui.tscn" id="6_21xkr"]
[ext_resource type="Script" uid="uid://cwj0jaw6impcj" path="res://Scripts/main_animation_player.gd" id="7_6bp64"]
[sub_resource type="Animation" id="Animation_21xkr"]
resource_name = "player_revolver_up"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("revolver:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(1.02871, 3.34454, 0.425178), Vector3(1.02871, 4.11691, 0.425178)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("revolver:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 1.5708), Vector3(0, 0, 3.14159)]
}
[sub_resource type="Animation" id="Animation_6bp64"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("revolver:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(1.02871, 3.34454, 0.425178)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("revolver:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0, 1.5708)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("enemy_revolver:position")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(1.01994, 3.38413, -0.496572)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("enemy_revolver:rotation")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(8.74064e-08, 3.14159, -1.59017)]
}
[sub_resource type="Animation" id="Animation_344ge"]
resource_name = "player_revolver_down"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("revolver:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(1.02871, 4.11691, 0.425178), Vector3(1.02871, 3.34454, 0.425178)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("revolver:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 0, 3.14159), Vector3(0, 0, 1.5708)]
}
[sub_resource type="Animation" id="Animation_ynf5e"]
resource_name = "enemey_rev_up"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("enemy_revolver:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(1.01994, 3.38413, -0.496572), Vector3(-0.790087, 4.02359, -0.496572)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("enemy_revolver:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(8.74064e-08, 3.14159, -1.59017), Vector3(0, 3.14159, -3.14159)]
}
[sub_resource type="Animation" id="Animation_hptm8"]
resource_name = "enemey_rev_down"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("enemy_revolver:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(-0.790087, 4.02359, -0.496572), Vector3(1.01994, 3.38413, -0.496572)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("enemy_revolver:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.0333334, 1),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [Vector3(0, 3.14159, -3.14159), Vector3(8.74064e-08, 3.14159, -1.59017)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_344ge"]
_data = {
&"RESET": SubResource("Animation_6bp64"),
&"enemey_rev_down": SubResource("Animation_hptm8"),
&"enemey_rev_up": SubResource("Animation_ynf5e"),
&"player_revolver_down": SubResource("Animation_344ge"),
&"player_revolver_up": SubResource("Animation_21xkr")
}
[node name="Node3D" type="Node3D"]
@@ -22,11 +192,11 @@ spot_range = 4.8595
spot_angle = 42.0126
[node name="revolver" parent="." instance=ExtResource("4_jjvhh")]
transform = Transform3D(-0.1, -8.74228e-09, 0, 8.74228e-09, -0.1, 0, 0, 0, 0.1, 0.354285, 4.2476, 0.425178)
transform = Transform3D(-4.37114e-09, -0.1, 0, 0.1, -4.37114e-09, 0, 0, 0, 0.1, 1.02871, 3.34454, 0.425178)
is_player_revolver = true
[node name="BulletStack" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.09463, 3.35364, -0.941887)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.39969, 3.35364, -0.941887)
script = ExtResource("4_kry3j")
[node name="bullet2" parent="BulletStack" instance=ExtResource("3_8gbba")]
@@ -47,10 +217,39 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.126874, -0.00966144, 0.1641
[node name="bullet6" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.300729, -0.0193229, 0.207828)
[node name="bullet7" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0812991, -0.0193229, 0.241967)
[node name="bullet8" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.000887632, -0.00966144, 0.23783)
[node name="bullet9" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.172968, -0.0193229, 0.281501)
[node name="bullet10" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.20906, -0.0193229, 0.401988)
[node name="bullet11" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.126874, -0.00966144, 0.397851)
[node name="bullet12" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.300729, -0.0193229, 0.441522)
[node name="bullet13" parent="BulletStack" instance=ExtResource("3_8gbba")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.162003, -0.0193229, 0.00827265)
[node name="person3" parent="." instance=ExtResource("5_kry3j")]
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 0.0599972, 3.68584, -2.25251)
[node name="enemy_revolver" parent="." instance=ExtResource("4_jjvhh")]
transform = Transform3D(0.1, 0, 0, 0, -0.1, -8.74228e-09, 0, 8.74228e-09, -0.1, 0.354285, 4.2476, -0.496572)
transform = Transform3D(0.00193719, -0.0999812, 1.50996e-08, -0.0999812, -0.00193719, -8.74064e-09, 9.0315e-09, -1.49274e-08, -0.1, 1.01994, 3.38413, -0.496572)
[editable path="revolver"]
[node name="MainGame" parent="." instance=ExtResource("6_21xkr")]
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_344ge")
}
script = ExtResource("7_6bp64")
[connection signal="animation_finished" from="AnimationPlayer" to="AnimationPlayer" method="_on_animation_finished"]

36
Scenes/main_game_ui.tscn Normal file
View File

@@ -0,0 +1,36 @@
[gd_scene load_steps=2 format=3 uid="uid://cbr3e8xsfwyhf"]
[ext_resource type="Script" uid="uid://2ktulh0d67v0" path="res://Scripts/player_choice_box.gd" id="1_mx1e2"]
[node name="MainGame" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
mouse_filter = 1
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
anchor_top = 1.0
anchor_right = 0.5
anchor_bottom = 1.0
offset_left = -86.5
offset_top = -125.08
offset_right = 86.5
offset_bottom = -94.08
grow_horizontal = 2
grow_vertical = 0
script = ExtResource("1_mx1e2")
[node name="Button" type="Button" parent="HBoxContainer"]
layout_mode = 2
text = "Shoot him
"
[node name="Button2" type="Button" parent="HBoxContainer"]
layout_mode = 2
text = "Shoot me"

142
Scenes/prototype.tscn Normal file
View File

@@ -0,0 +1,142 @@
[gd_scene load_steps=7 format=3 uid="uid://b1lmku8qo5ln5"]
[ext_resource type="PackedScene" uid="uid://bge7npb7b1y6x" path="res://Scenes/revolver.tscn" id="1_4ousu"]
[ext_resource type="PackedScene" uid="uid://j06vthscroca" path="res://Scenes/bullet.tscn" id="2_6koui"]
[ext_resource type="PackedScene" uid="uid://c7t8himcaqljg" path="res://Blends/Person/person2.gltf" id="3_6koui"]
[sub_resource type="Animation" id="Animation_3mrnv"]
resource_name = "new_animation"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("person2/Cylinder_001:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.3, 0.6, 0.8),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector3(0, 0.349901, -0.530438), Vector3(-0.0617815, 0.349901, -0.536435), Vector3(0.136233, 0.349901, -0.56728), Vector3(0.101021, 0.349901, -0.490088)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("person2/Cylinder_001:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.3, 0.6, 0.8),
"transitions": PackedFloat32Array(1, 1, 1, 1),
"update": 0,
"values": [Vector3(1.5708, 0, 0), Vector3(1.5708, -0.193505, 0), Vector3(1.5708, -0.483596, 0), Vector3(1.5708, -0.876435, 0)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("person2/Cylinder_002:position")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0, 0.3, 0.6, 0.8, 1),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 0,
"values": [Vector3(0, 0.349901, -1.17486), Vector3(0.0617815, 0.349901, -1.167), Vector3(0.435, 0.349901, -1.13615), Vector3(0.594801, 0.349901, -0.901257), Vector3(0.594801, 0.349901, -0.850009)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("person2/Cylinder_002:rotation")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.3, 0.6, 0.8, 1),
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
"update": 0,
"values": [Vector3(1.5708, 0, 0), Vector3(1.5708, -0.193505, 0), Vector3(1.5708, -0.483596, 0), Vector3(1.5708, -0.876435, 0), Vector3(1.5708, -1.71175, 0)]
}
[sub_resource type="Animation" id="Animation_uurmw"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("person2/Cylinder_001:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0.349901, -0.530438)]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("person2/Cylinder_001:rotation")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(1.5708, 0, 0)]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("person2/Cylinder_002:position")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0, 0.349901, -1.17486)]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("person2/Cylinder_002:rotation")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(1.5708, 0, 0)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_3mrnv"]
_data = {
&"RESET": SubResource("Animation_uurmw"),
&"new_animation": SubResource("Animation_3mrnv")
}
[node name="Prototype" type="Node3D"]
[node name="Camera3D" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.448508, 1.2315)
[node name="bullet" parent="." instance=ExtResource("2_6koui")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.114408, 0, -0.120555)
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_3mrnv")
}
autoplay = "new_animation"
[node name="person2" parent="." instance=ExtResource("3_6koui")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.28447, 0, 0.116344)
[node name="Cylinder_001" parent="person2" index="2"]
transform = Transform3D(0.0938729, 0, 0, 0, -4.10331e-09, -0.0938729, 0, 0.0938729, -4.10331e-09, 0, 0.349901, -0.530438)
[node name="Cylinder_002" parent="person2" index="3"]
transform = Transform3D(0.0527661, 0, 0, 0, -2.30648e-09, -0.0527661, 0, 0.0527661, -2.30648e-09, 0, 0.349901, -1.17486)
[node name="revolver" parent="person2/Cylinder_002" index="0" instance=ExtResource("1_4ousu")]
transform = Transform3D(-0.990786, -0.0843367, 0.105973, 0.104904, 0.017018, 0.994336, -0.0856625, 0.996292, -0.00801402, 0.0800285, -14.663, -2.40374)
is_player_revolver = true
[editable path="person2"]

View File

@@ -1,8 +1,45 @@
[gd_scene load_steps=3 format=3 uid="uid://bge7npb7b1y6x"]
[gd_scene load_steps=6 format=3 uid="uid://bge7npb7b1y6x"]
[ext_resource type="PackedScene" uid="uid://k5auld1jqu12" path="res://Blends/Revolver/revolver.gltf" id="1_wa2bx"]
[ext_resource type="Script" uid="uid://d3174fuibuuyo" path="res://Scripts/revolver.gd" id="2_ncs2m"]
[sub_resource type="Animation" id="Animation_ncs2m"]
resource_name = "cylinder_out"
length = 0.5
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Cylinder_002:position")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.5),
"transitions": PackedFloat32Array(1, 1.7411),
"update": 0,
"values": [Vector3(0.0429976, 0.542699, 3.97893), Vector3(2.0611, 0.542699, 3.97893)]
}
[sub_resource type="Animation" id="Animation_ldl0s"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Cylinder_002:position")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector3(0.0429976, 0.542699, 3.97893)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_h5sga"]
_data = {
&"RESET": SubResource("Animation_ldl0s"),
&"cylinder_out": SubResource("Animation_ncs2m")
}
[node name="revolver" node_paths=PackedStringArray("cylinder") instance=ExtResource("1_wa2bx")]
transform = Transform3D(0.1, 0, 0, 0, 0.1, 0, 0, 0, 0.1, 0, 0, 0)
script = ExtResource("2_ncs2m")
@@ -18,4 +55,12 @@ transform = Transform3D(0.388665, 1.69891e-08, 0.673188, 0.673188, -2.9426e-08,
transform = Transform3D(-4.37114e-08, 0, 0.564469, 0, 0.0715409, 0, -1, 0, -2.46737e-08, 0, -0.305258, 3.93692)
[node name="Timer" type="Timer" parent="." index="5"]
wait_time = 0.5
one_shot = true
[node name="AnimationPlayer" type="AnimationPlayer" parent="." index="6"]
libraries = {
&"": SubResource("AnimationLibrary_h5sga")
}
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]

View File

@@ -5,11 +5,28 @@ var revolver: Node3D
func _ready() -> void:
revolver = GameManager.get_enemy_revolver()
GameManager.state_changed.connect(on_state_changed)
func on_state_changed():
if GameManager.current_state == GameManager.GameState.PLAYER2_GUN_LOAD:
make_turn()
elif GameManager.current_state == GameManager.GameState.PLAYER2_UNLOAD:
unload()
func unload():
print("Unload")
var choices = GameManager.PlayerChoice.values()
var choice = choices.pick_random()
GameManager.player_phase2_choice = choice
print(GameManager.player_phase2_choice)
if GameManager.PlayerChoice.SHOOT_SELF == choice:
print("I will shoot myself")
revolver.rotation_degrees = Vector3(180,180,0)
else:
print("I will shoot opponent")
revolver.rotation_degrees = Vector3(180,0,0)
revolver.current_round = 0
for i in range(0, 6, 1):
revolver.shoot()
revolver.current_round = i
func make_turn():
if revolver == null:
revolver = GameManager.get_enemy_revolver()

View File

@@ -34,3 +34,13 @@ func on_target_reached():
func _on_static_body_3d_input_event(camera: Node, event: InputEvent, event_position: Vector3, normal: Vector3, shape_idx: int) -> void:
if event.is_action_released("left_mouse_click"):
GameManager.bullet_selected.emit(self)
func shoot(target):
if is_live:
print("Ammo was live")
else:
print("Ammo not live")
pass
GameManager.bullet_shoot.emit(target)
self.queue_free()

View File

@@ -1,23 +1,33 @@
extends Node
signal bullet_shoot
signal bullet_selected(object)
signal state_changed
enum GameState { PLAYER1_GUN_LOAD, PLAYER2_GUN_LOAD, GUN_ANIMATION, PLAYER1_UNLOAD,PLAYER2_UNLOAD}
enum PlayerChoice {SHOOT_SELF, SHOOT_OPPONENT}
var player_phase2_choice
var current_state = GameState.PLAYER1_GUN_LOAD
var bullets: Array
var player1_revolver: Node3D
var player2_revolver: Node3D
var is_player1_loaded: bool = false
var is_player2_loaded: bool = false
var bullet_stack: Node3D
var animPl: AnimationPlayer
var last_turn: int
func _ready() -> void:
bullet_shoot.connect(on_bullet_shoot)
bullet_selected.connect(on_bullet_selected)
func _input(event: InputEvent) -> void:
if event.is_action_released("load"):
player1_revolver.load_bullet(bullet_stack.bullets[0])
set_player_turn()
elif event.is_action_released("load2"):
player1_revolver.load_bullet(bullet_stack.bullets[1])
@@ -52,19 +62,62 @@ func check_unloaded_bullets():
else:
return false
func check_loaded_bullets(revolver: Node3D):
if revolver.can_be_loaded():
return true
else:
return false
func end_player_turn():
if check_unloaded_bullets():
set_state(GameState.PLAYER2_GUN_LOAD)
else:
set_state(GameState.PLAYER2_UNLOAD)
print("End of Phase 1")
animPl.play("player_revolver_down")
#end_turn()
func end_enemy_turn():
if check_unloaded_bullets():
set_state(GameState.PLAYER1_GUN_LOAD)
animPl.play("enemey_rev_down")
#set_player_turn()
#end_turn()
func end_turn():
if !player1_revolver.can_be_loaded() and !player2_revolver.can_be_loaded() or !check_unloaded_bullets():
var player = get_phase2_player_start()
if player == 0:
set_state(GameState.PLAYER1_UNLOAD)
else:
set_state(GameState.PLAYER2_UNLOAD)
else:
set_state(GameState.PLAYER1_UNLOAD)
print("End of Phase 1")
if last_turn == 0:
set_enemy_turn()
else:
set_player_turn()
func get_enemy_revolver() -> Node3D:
return player2_revolver
func get_phase2_player_start():
var randNumb = randi_range(0,1)
if randNumb == 0:
return 0
else:
return 1
func on_bullet_shoot(target):
pass
func set_player_turn():
animPl.play("player_revolver_up")
func set_enemy_turn():
animPl.play("enemey_rev_up")
func on_animation_finished(anim_name):
if anim_name == "player_revolver_up":
set_state(GameState.PLAYER1_GUN_LOAD)
elif anim_name == "player_revolver_down":
last_turn = 0
end_turn()
elif anim_name == "enemey_rev_up":
set_state(GameState.PLAYER2_GUN_LOAD)
elif anim_name == "enemey_rev_down":
last_turn = 1
end_turn()

View File

@@ -0,0 +1,8 @@
extends AnimationPlayer
func _ready() -> void:
GameManager.animPl = self
func _on_animation_finished(anim_name: StringName) -> void:
GameManager.on_animation_finished(anim_name)

View File

@@ -0,0 +1 @@
uid://cwj0jaw6impcj

View File

@@ -0,0 +1,11 @@
extends HBoxContainer
var start_pos: Vector2
func _ready() -> void:
start_pos = self.position
self.position = Vector2(1000.0,1000.0)
GameManager.state_changed.connect(on_state_changed)
func on_state_changed():
if GameManager.current_state == GameManager.GameState.PLAYER1_UNLOAD:
self.position = start_pos

View File

@@ -0,0 +1 @@
uid://2ktulh0d67v0

View File

@@ -1,18 +1,28 @@
extends Node3D
enum revolver_state {UP, DOWN, LOADING}
var state: int = revolver_state.DOWN
var game_state: int
var bullet_target_pos = Vector3(1.95,0.03,4.612) #2.231
var loaded_bullets = Array()
var max_bullets: int = 6
var current_round: int = 1
var current_round: int = 0
var timer: Timer
var target_angle: Vector3 = Vector3(0,0,90)
@export var is_player_revolver: bool = false
@export var cylinder: Node3D
var animationPlayer: AnimationPlayer
var is_cylinder_out: bool = false
var curr_load_bullet: Node3D
func _ready() -> void:
loaded_bullets.resize(max_bullets + 1)
animationPlayer = $AnimationPlayer
game_state = GameManager.current_state
GameManager.state_changed.connect(on_state_changed)
loaded_bullets.resize(max_bullets)
timer = $Timer
if is_player_revolver:
GameManager.set_player_revolver(self)
@@ -21,33 +31,87 @@ func _ready() -> void:
func _process(delta: float) -> void:
if is_cylinder_out:
cylinder.position = lerp(cylinder.position, Vector3(1.947,0.543,3.979), delta/ 0.1)
pass
#cylinder.position = lerp(cylinder.position, Vector3(1.947,0.543,3.979), delta/ 0.1)
else:
cylinder.position = lerp(cylinder.position, Vector3(0,0.543,3.979), delta/ 0.1)
pass
#cylinder.position = lerp(cylinder.position, Vector3(0,0.543,3.979), delta/ 0.1)
cylinder.rotation_degrees = lerp(cylinder.rotation_degrees,Vector3(30 + current_round*60,90,90), delta / 0.1 )
#rotation_degrees = lerp(rotation_degrees, target_angle, delta / 0.1)
if state == revolver_state.UP:
#global_position = lerp(global_position, up_pos, delta/ 0.1)
#target_angle = target_angle_up
pass
elif state == revolver_state.DOWN:
pass
#global_position = lerp(global_position, down_pos, delta / 0.1)
#target_angle = target_angle_down
#cylinder.rotation_degrees = Vector3(30 + current_round*60,90,90)
func load_bullet(bullet_object: Node3D):
loaded_bullets[current_round] = bullet_object
bullet_object.is_loaded = true
bullet_object.destination_reached.connect(on_bullet_reached)
bullet_object.moveTo(to_global(bullet_target_pos))
bullet_object.rotate_x(deg_to_rad(-90))
curr_load_bullet = bullet_object
is_cylinder_out = true
bullet_object.reparent(cylinder)
animationPlayer.play("cylinder_out")
timer.timeout.connect(on_load_anim_end)
#cylinder.rotation.x = 90.0
func on_load_anim_end():
is_cylinder_out = false
if is_player_revolver:
GameManager.end_player_turn()
else:
GameManager.end_enemy_turn()
animationPlayer.play_backwards("cylinder_out")
timer.timeout.disconnect(on_load_anim_end)
func on_bullet_reached():
current_round += 1
timer.start()
func shoot():
loaded_bullets[current_round].shoot(null)
pass
func can_be_loaded():
var free: int = 0
for bullet in loaded_bullets:
if bullet == null:
free += 1
if free > 0:
return true
else:
return false
func on_state_changed():
if is_player_revolver:
if GameManager.current_state == GameManager.GameState.PLAYER1_GUN_LOAD:
state = revolver_state.UP
if GameManager.current_state == GameManager.GameState.PLAYER2_GUN_LOAD:
state = revolver_state.DOWN
else:
if GameManager.current_state == GameManager.GameState.PLAYER2_GUN_LOAD:
state = revolver_state.UP
if GameManager.current_state == GameManager.GameState.PLAYER1_GUN_LOAD:
state = revolver_state.DOWN
func _on_animation_player_animation_finished(anim_name: StringName) -> void:
if anim_name == "cylinder_out" and is_cylinder_out:
loaded_bullets[current_round] = curr_load_bullet
curr_load_bullet.is_loaded = true
curr_load_bullet.destination_reached.connect(on_bullet_reached)
curr_load_bullet.moveTo(to_global(bullet_target_pos))
curr_load_bullet.rotate_x(deg_to_rad(-90))
curr_load_bullet.reparent(cylinder)
elif anim_name == "cylinder_out" and is_cylinder_out == false:
if !can_be_loaded():
if is_player_revolver:
GameManager.is_player1_loaded = true
else:
GameManager.is_player2_loaded = true
if is_player_revolver:
GameManager.end_player_turn()
else:
GameManager.end_enemy_turn()

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ds1brgul327l0"
path="res://.godot/imported/ANIME-PICTURES.NET_-_435314-1920x1080-senran+kagura-homura+(senran+kagura)-yomi+(senran+kagura)-hikage+(senran+kagura)-mirai+(senran+kagura)-haruka+(senran+kagura).jpeg-8631b2d80db4404b92f69470fd0c2315.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/ANIME-PICTURES.NET_-_435314-1920x1080-senran+kagura-homura+(senran+kagura)-yomi+(senran+kagura)-hikage+(senran+kagura)-mirai+(senran+kagura)-haruka+(senran+kagura).jpeg"
dest_files=["res://.godot/imported/ANIME-PICTURES.NET_-_435314-1920x1080-senran+kagura-homura+(senran+kagura)-yomi+(senran+kagura)-hikage+(senran+kagura)-mirai+(senran+kagura)-haruka+(senran+kagura).jpeg-8631b2d80db4404b92f69470fd0c2315.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

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bqxwnlrkv6mft"
path="res://.godot/imported/bb4b32cd79fb85dfe85f00a17d634a44_bp.png-d1280714b7c0662815de28909bd20fbb.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://addons/bb4b32cd79fb85dfe85f00a17d634a44_bp.png"
dest_files=["res://.godot/imported/bb4b32cd79fb85dfe85f00a17d634a44_bp.png-d1280714b7c0662815de28909bd20fbb.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

2
addons/cba/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
# Personal configuration file
config.json

21
addons/cba/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 peachey2k2
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

26
addons/cba/README.md Normal file
View File

@@ -0,0 +1,26 @@
[![Discord](https://img.shields.io/discord/1146846558508302366.svg?colorB=7289DA&style=for-the-badge&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHYAAABWAgMAAABnZYq0AAAACVBMVEUAAB38%2FPz%2F%2F%2F%2Bm8P%2F9AAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfhBxwQJhxy2iqrAAABoElEQVRIx7WWzdGEIAyGgcMeKMESrMJ6rILZCiiBg4eYKr%2Fd1ZAfgXFm98sJfAyGNwno3G9sLucgYGpQ4OGVRxQTREMDZjF7ILSWjoiHo1n%2BE03Aw8p7CNY5IhkYd%2F%2F6MtO3f8BNhR1QWnarCH4tr6myl0cWgUVNcfMcXACP1hKrGMt8wcAyxide7Ymcgqale7hN6846uJCkQxw6GG7h2MH4Czz3cLqD1zHu0VOXMfZjHLoYvsdd0Q7ZvsOkafJ1P4QXxrWFd14wMc60h8JKCbyQvImzlFjyGoZTKzohwWR2UzSONHhYXBQOaKKsySsahwGGDnb%2FiYPJw22sCqzirSULYy1qtHhXGbtgrM0oagBV4XiTJok3GoLoDNH8ooTmBm7ZMsbpFzi2bgPGoXWXME6XT%2BRJ4GLddxJ4PpQy7tmfoU2HPN6cKg%2BledKHBKlF8oNSt5w5g5o8eXhu1IOlpl5kGerDxIVT%2BztzKepulD8utXqpChamkzzuo7xYGk%2FkpSYuviLXun5bzdRf0Krejzqyz7Z3p0I1v2d6HmA07dofmS48njAiuMgAAAAASUVORK5CYII%3D)](https://discord.gg/ZuUWPaSrHa)
# Chey's Background Addon
A simple plugin to put a background image behind your Godot editor.
![image](https://github.com/peachey2k2/cheys-background-addon/assets/100072467/fe1286ab-337e-456c-9a2d-4d7a482f399c)
# Installation
You can download it from the [asset library](https://godotengine.org/asset-library/asset/2933), which you can also use within the editor.
Then enable the plugin from `Project > Project Settings > Plugins`. It will probably freeze for a couple seconds. That's intended.
# Configuration
Simply go to `Project > Tools > Backgrounds`. That should open up the configuration window.
All the configuration is stored in `addons/cba/config.json`.
> [!NOTE]
> Changing the UI color might freeze your editor for a second or two. Don't worry, that's normal. Godot just takes time to refresh all the theming.
![image](https://github.com/peachey2k2/cheys-background-addon/assets/100072467/c6d28ac6-733e-4112-8511-ceb0f2cc5c5a)
# Support
If you have a problem with the plugin, just come to my Discord server and I'll try to help.
[![Discord](https://discordapp.com/api/guilds/1146846558508302366/widget.png?style=banner3)](https://discord.gg/ZuUWPaSrHa)

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

BIN
addons/cba/images/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

7
addons/cba/plugin.cfg Normal file
View File

@@ -0,0 +1,7 @@
[plugin]
name="Chey's Background Addon"
description="An addon that lets you add a background for your editor."
author="peachey2k2"
version="1.1.6"
script="plugin.gd"

220
addons/cba/plugin.gd Normal file
View File

@@ -0,0 +1,220 @@
@tool
extends EditorPlugin
var base:Control
var editor_settings:EditorSettings
const TOOL = preload("res://addons/cba/tool.tscn")
var settings:Dictionary = {}
var bg:TextureRect
var tool:Window
var theme:Theme
var accent_color:Color
func _disable_plugin():
bg.queue_free()
editor_settings.set("interface/theme/custom_theme", "")
editor_settings.set("interface/theme/preset", "Default")
remove_tool_menu_item("Backgrounds")
func _enter_tree():
#Benchmark.start("init")
if not Engine.is_editor_hint(): return
base = EditorInterface.get_base_control()
editor_settings = EditorInterface.get_editor_settings()
editor_settings.settings_changed.connect(func():
for setting in editor_settings.get_changed_settings():
_setting_changed(setting)
)
bg = TextureRect.new()
bg.name = "Editor Background"
bg.mouse_filter = Control.MOUSE_FILTER_IGNORE
bg.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
bg.set_anchors_and_offsets_preset(Control.PRESET_FULL_RECT)
base.add_child.call_deferred(bg)
# move it to the top of the tree so it's behind all the UI
base.move_child.call_deferred(bg, 0)
await bg.ready
theme = preload("res://addons/cba/theme.tres")
if editor_settings.get("interface/theme/custom_theme") != "res://addons/cba/theme.tres":
editor_settings.set("interface/theme/custom_theme", "res://addons/cba/theme.tres")
if editor_settings.get("interface/theme/preset") != "Custom":
editor_settings.set("interface/theme/preset", "Custom")
await base.get_tree().physics_frame
load_settings()
add_tool_menu_item("Backgrounds", func():
if is_instance_valid(tool): printerr("There is already a background picker window open."); return
tool = TOOL.instantiate()
tool.main = self
base.add_child(tool)
tool.start()
tool.popup_centered()
)
#Benchmark.end("init")
func change_setting(value:Variant, setting:String, update_ui:bool = false, update_setting:bool = true):
var is_prev_ready := is_instance_valid(tool)
match setting:
"image":
var img := load_image(value)
if is_prev_ready: tool.preview.texture = img
if update_setting: bg.texture = img
"stretch":
if update_setting: bg.stretch_mode = value
if is_prev_ready:
tool.preview.stretch_mode = value
if update_ui:
tool.get_node("VBoxContainer/HBoxContainer/VBoxContainer/stretch mode").select(value)
"filter":
if update_setting: bg.texture_filter = value
if is_prev_ready:
tool.preview.texture_filter = value
if update_ui:
tool.get_node("VBoxContainer/HBoxContainer/VBoxContainer/filter mode").select(value)
"ui_color":
if is_prev_ready:
if update_ui:
value = Color(settings["ui_color"])
tool.get_node("VBoxContainer/HBoxContainer/VBoxContainer2/ui_color").color = value
else:
value = tool.get_node("VBoxContainer/HBoxContainer/VBoxContainer2/ui_color").color
if not update_ui && update_setting:
if value == Color(settings["ui_color"]): return
change_theme_color(value)
settings["ui_color"] = value.to_html()
value = null
"bg_modulate":
if value is String: value = Color(value)
if update_setting: bg.modulate = value
if is_prev_ready:
tool.preview.modulate = value
if update_ui:
tool.get_node("VBoxContainer/HBoxContainer/VBoxContainer2/bg_modulate").color = value
value = value.to_html()
"edit_transparency":
if is_prev_ready:
if update_ui:
value = settings["edit_transparency"]
tool.get_node("VBoxContainer/edit_transparency").button_pressed = value
else:
value = tool.get_node("VBoxContainer/edit_transparency").button_pressed
if not update_ui && update_setting:
if value == settings["edit_transparency"]: return
settings["edit_transparency"] = value
change_theme_color(Color(settings["ui_color"]))
value = null
if value != null: settings[setting] = value
func load_image(path:String) -> Texture2D:
var file := FileAccess.open(path, FileAccess.READ)
if file == null: printerr("file not found: ", path); return
var image = Image.load_from_file(path)
var out = ImageTexture.create_from_image(image)
return out
func load_settings():
if FileAccess.file_exists("res://addons/cba/config.json"):
var file := FileAccess.open("res://addons/cba/config.json", FileAccess.READ)
if file == null:
file = FileAccess.open("res://addons/cba/config.json", FileAccess.WRITE_READ)
assert(file != null, "Error opening file.")
return
else:
settings = JSON.parse_string(file.get_as_text())
file.close()
else:
var file := FileAccess.open("res://addons/cba/config.json", FileAccess.WRITE)
var defaults := {
"filter": 0.0,
"image": ProjectSettings.globalize_path("res://addons/cba/images/default.png"),
"stretch": 1,
"ui_color": "00000088",
"bg_modulate": "ffffffb0",
"edit_transparency": false,
}
file.store_string(JSON.stringify(defaults, "\t"))
settings = defaults
file.close()
for s in settings.keys():
change_setting(settings[s], s, true)
func save_settings():
var file := FileAccess.open("res://addons/cba/config.json", FileAccess.WRITE)
file.store_string(JSON.stringify(settings, "\t"))
func _setting_changed(setting:String):
match setting:
"interface/theme/accent_color":
change_theme_color(Color(settings["ui_color"]))
func change_theme_color(col:Color):
#Benchmark.start("change theme color")
accent_color = editor_settings.get_setting("interface/theme/accent_color")
var controls_list = get_all_controls([base])
var col2 := Color(col, col.a/2.0)
var col3 := Color(col, min(col.a/col.v, col.a/4.0))
change_color("EditorStyles", "Background", col)
change_color("EditorStyles", "BottomPanel", col)
change_color("EditorStyles", "BottomPanelDebuggerOverride", col)
change_color("EditorStyles", "Content", col)
change_color("EditorStyles", "LaunchPadNormal", col)
change_color("TabContainer", "panel", col)
change_color("TabContainer", "tab_selected", col, accent_color)
change_color("TabContainer", "tab_unselected", col2)
change_color("TabContainer", "tab_hovered", col2)
change_color("TabBar", "tab_selected", col, accent_color)
change_color("TabBar", "tab_unselected", col2)
change_color("TabBar", "tab_hovered", col2)
change_color("TabContainerOdd", "tab_selected", col, accent_color)
change_color("TabContainerOdd", "panel", col2)
# bordered
change_color("Button", "normal", col3)
change_color("MenuButton", "normal", col3)
change_color("OptionButton", "normal", col3)
change_color("RichTextLabel", "normal", col3)
change_color("LineEdit", "normal", col3)
change_color("TextEdit", "normal", col3)
change_color("LineEdit", "read_only", col3)
change_color("TextEdit", "read_only", col3)
change_color("EditorProperty", "child_bg", col3)
change_color("EditorInspectorCategory", "bg", col2)
# fix to old values showing up in transparent preview
if settings["edit_transparency"]:
change_color("LineEdit", "focus", col3)
else:
change_color("LineEdit", "focus", Color.BLACK)
# trigger an update
theme.get_stylebox("Background", "EditorStyles").emit_changed()
#Benchmark.end("change theme color")
func get_all_controls(nodes:Array[Node]) -> Array[Node]:
var out:Array[Node] = []
for node in nodes:
if node is Control: out.append(node)
var children := node.get_children() as Array[Node]
out += get_all_controls(children)
return out
func change_color(type:String, name:String, col:Color, border = null):
var box:StyleBoxFlat = theme.get_stylebox(name, type)
box.set_block_signals(true)
box.bg_color = col
if border != null:
box.border_color = border
box.set_block_signals(false)

1
addons/cba/plugin.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://dpgybwvyhvqkx

359
addons/cba/theme.tres Normal file
View File

@@ -0,0 +1,359 @@
[gd_resource type="Theme" load_steps=39 format=3 uid="uid://cbdjaabpm8jfk"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_6rrxc"]
content_margin_left = 6.0
content_margin_top = 5.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color(0.47788, 0.47788, 0.47788, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_4bdji"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_x4bf7"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.290196)
border_color = Color(0.25098, 0.266667, 0.298039, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_qm4uc"]
bg_color = Color(0, 0, 0, 0.145098)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kmfvt"]
bg_color = Color(0, 0, 0, 0.580392)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1tn6y"]
content_margin_left = 4.0
content_margin_top = 6.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.580392)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_mfvec"]
content_margin_left = 4.0
content_margin_top = 0.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.580392)
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yxe5q"]
bg_color = Color(0.617575, 0.626378, 0.219465, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_wrepn"]
bg_color = Color(0, 0, 0, 0.580392)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_4qoyy"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_bae5w"]
bg_color = Color(0, 0, 0, 0)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hqa07"]
bg_color = Color(0.71993, 0.58247, 0.18956, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jbgu4"]
bg_color = Color(0.87666, 0.482054, 0.185217, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7xbe2"]
content_margin_left = 2.0
content_margin_top = 0.0
content_margin_right = 2.0
content_margin_bottom = 0.0
bg_color = Color(0, 0, 0, 0.580392)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_eag6m"]
bg_color = Color(0.266667, 0.647059, 0.819608, 0)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_nn8ly"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_yi1o1"]
bg_color = Color(0.6, 0.6, 0.6, 0)
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_ebp5u"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_7l2sj"]
bg_color = Color(0, 0, 0, 1)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cbyhm"]
content_margin_left = 6.0
content_margin_top = 4.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_width_bottom = 2
border_color = Color(0.113725, 0.133333, 0.160784, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_cjlww"]
content_margin_left = 6.0
content_margin_top = 4.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_width_bottom = 2
border_color = Color(0.113725, 0.133333, 0.160784, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_xi4cy"]
content_margin_left = 6.0
content_margin_top = 5.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_color = Color(0.501961, 0.501961, 0.501961, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_thgut"]
content_margin_left = 6.0
content_margin_top = 5.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_color = Color(0.501961, 0.501961, 0.501961, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4rkfj"]
content_margin_left = 4.0
content_margin_top = 4.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.145098)
border_width_left = 1
border_width_top = 1
border_width_right = 1
border_width_bottom = 1
border_color = Color(0.301961, 0.301961, 0.301961, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_jlb1y"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.290196)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_lvnv7"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.580392)
border_width_top = 2
border_color = Color(0.44, 0.73, 0.98, 1)
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ve3ye"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.290196)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_kcmrn"]
content_margin_left = 4.0
content_margin_top = 6.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.580392)
border_color = Color(0.900808, 0.647855, 0.245012, 1)
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e473q"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.290196)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gir5j"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.580392)
border_width_top = 2
border_color = Color(0.44, 0.73, 0.98, 1)
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_th0sh"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.290196)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_og5m1"]
content_margin_left = 0.0
content_margin_top = 0.0
content_margin_right = 0.0
content_margin_bottom = 0.0
bg_color = Color(0, 0, 0, 0)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_prlgo"]
content_margin_left = 4.0
content_margin_top = 6.0
content_margin_right = 4.0
content_margin_bottom = 4.0
bg_color = Color(0, 0, 0, 0.290196)
corner_radius_bottom_right = 3
corner_radius_bottom_left = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4n6md"]
content_margin_left = 11.0
content_margin_top = 5.0
content_margin_right = 11.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.580392)
border_width_top = 2
border_color = Color(0.44, 0.73, 0.98, 1)
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_4bdji"]
bg_color = Color(0, 0, 0, 0.12451)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_1gbrb"]
content_margin_left = 6.0
content_margin_top = 4.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_width_bottom = 2
border_color = Color(0.113725, 0.133333, 0.160784, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_gfc5e"]
content_margin_left = 6.0
content_margin_top = 4.0
content_margin_right = 6.0
content_margin_bottom = 5.0
bg_color = Color(0, 0, 0, 0.145098)
border_width_bottom = 2
border_color = Color(0.113725, 0.133333, 0.160784, 1)
corner_radius_top_left = 3
corner_radius_top_right = 3
corner_detail = 3
anti_aliasing = false
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_c0v5a"]
[resource]
Button/styles/normal = SubResource("StyleBoxFlat_6rrxc")
CodeEdit/styles/normal = SubResource("StyleBoxEmpty_4bdji")
EditorInspectorCategory/styles/bg = SubResource("StyleBoxFlat_x4bf7")
EditorProperty/styles/child_bg = SubResource("StyleBoxFlat_qm4uc")
EditorStyles/styles/Background = SubResource("StyleBoxFlat_kmfvt")
EditorStyles/styles/BottomPanel = SubResource("StyleBoxFlat_1tn6y")
EditorStyles/styles/BottomPanelDebuggerOverride = SubResource("StyleBoxFlat_mfvec")
EditorStyles/styles/CanvasItemInfoOverlay = SubResource("StyleBoxFlat_yxe5q")
EditorStyles/styles/Content = SubResource("StyleBoxFlat_wrepn")
EditorStyles/styles/ContextualToolbar = SubResource("StyleBoxEmpty_4qoyy")
EditorStyles/styles/DebuggerPanel = SubResource("StyleBoxFlat_bae5w")
EditorStyles/styles/DictionaryAddItem = SubResource("StyleBoxFlat_hqa07")
EditorStyles/styles/Focus = SubResource("StyleBoxFlat_jbgu4")
EditorStyles/styles/LaunchPadNormal = SubResource("StyleBoxFlat_7xbe2")
EditorStyles/styles/MenuPanel = SubResource("StyleBoxFlat_eag6m")
EditorStyles/styles/PanelForeground = null
EditorStyles/styles/ScriptEditor = SubResource("StyleBoxEmpty_nn8ly")
EditorStyles/styles/ScriptEditorPanel = SubResource("StyleBoxFlat_yi1o1")
ItemList/styles/panel = SubResource("StyleBoxEmpty_ebp5u")
LineEdit/styles/focus = SubResource("StyleBoxFlat_7l2sj")
LineEdit/styles/normal = SubResource("StyleBoxFlat_cbyhm")
LineEdit/styles/read_only = SubResource("StyleBoxFlat_cjlww")
MenuButton/styles/normal = SubResource("StyleBoxFlat_xi4cy")
OptionButton/styles/normal = SubResource("StyleBoxFlat_thgut")
RichTextLabel/styles/normal = SubResource("StyleBoxFlat_4rkfj")
TabBar/styles/tab_hovered = SubResource("StyleBoxFlat_jlb1y")
TabBar/styles/tab_selected = SubResource("StyleBoxFlat_lvnv7")
TabBar/styles/tab_unselected = SubResource("StyleBoxFlat_ve3ye")
TabContainer/styles/panel = SubResource("StyleBoxFlat_kcmrn")
TabContainer/styles/tab_hovered = SubResource("StyleBoxFlat_e473q")
TabContainer/styles/tab_selected = SubResource("StyleBoxFlat_gir5j")
TabContainer/styles/tab_unselected = SubResource("StyleBoxFlat_th0sh")
TabContainer/styles/tabbar_background = SubResource("StyleBoxFlat_og5m1")
TabContainerOdd/styles/panel = SubResource("StyleBoxFlat_prlgo")
TabContainerOdd/styles/tab_selected = SubResource("StyleBoxFlat_4n6md")
TextEdit/styles/focus = SubResource("StyleBoxFlat_4bdji")
TextEdit/styles/normal = SubResource("StyleBoxFlat_1gbrb")
TextEdit/styles/read_only = SubResource("StyleBoxFlat_gfc5e")
Tree/styles/panel = SubResource("StyleBoxEmpty_c0v5a")

38
addons/cba/tool.gd Normal file
View File

@@ -0,0 +1,38 @@
@tool
extends Window
var preview:TextureRect
var main:EditorPlugin
func start():
if not Engine.is_editor_hint(): queue_free(); return
$"VBoxContainer/HBoxContainer/VBoxContainer/image picker".pressed.connect(_image_picker)
$"VBoxContainer/HBoxContainer/VBoxContainer/stretch mode".item_selected.connect(main.change_setting.bind("stretch"))
$"VBoxContainer/HBoxContainer/VBoxContainer/filter mode".item_selected.connect(main.change_setting.bind("filter"))
#$HBoxContainer/VBoxContainer2/ui_alpha.value_changed.connect(main.change_setting.bind("ui_alpha")) # too laggy
$VBoxContainer/HBoxContainer/VBoxContainer2/ui_color.popup_closed.connect(main.change_setting.bind(null, "ui_color"))
$VBoxContainer/HBoxContainer/VBoxContainer2/bg_modulate.color_changed.connect(main.change_setting.bind("bg_modulate"))
$VBoxContainer/edit_transparency.toggled.connect(main.change_setting.bind("edit_transparency"))
close_requested.connect(close)
preview = $VBoxContainer/PanelContainer/TextureRect # thank you onready
main.load_settings()
func _input(event):
if event.is_action_pressed("ui_cancel"):
close()
func close():
main.save_settings()
queue_free()
func _image_picker():
var picker := EditorFileDialog.new()
picker.close_requested.connect(queue_free)
picker.file_selected.connect(main.change_setting.bind("image"))
picker.size = Vector2(700, 500)
picker.access = EditorFileDialog.ACCESS_FILESYSTEM
picker.file_mode = EditorFileDialog.FILE_MODE_OPEN_FILE
picker.filters = ["*.bmp, *.dds, *.exr, *.hdr, *.jpg, *.jpeg, *.png, *.tga, *.svg, *.svgz, *.webp; Supported Images"]
add_child(picker)
picker.popup_centered()

1
addons/cba/tool.gd.uid Normal file
View File

@@ -0,0 +1 @@
uid://ca766t2y66e16

172
addons/cba/tool.tscn Normal file
View File

@@ -0,0 +1,172 @@
[gd_scene load_steps=6 format=3 uid="uid://cqkxegtagb5ts"]
[ext_resource type="Script" uid="uid://d08kr32g2gva0" path="res://addons/cba/tool.gd" id="1_yg3st"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_l27jc"]
content_margin_left = 6.0
content_margin_right = 6.0
bg_color = Color(0.423529, 0.266667, 0.215686, 1)
border_width_left = 2
border_width_top = 2
border_width_right = 2
border_width_bottom = 2
border_color = Color(0.691357, 0.691357, 0.691357, 1)
shadow_color = Color(0, 0, 0, 0.729412)
shadow_size = 2
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_5s6hr"]
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_p8vlj"]
bg_color = Color(0.177332, 0.180983, 0.215343, 1)
[sub_resource type="Theme" id="Theme_csmr1"]
Button/font_sizes/font_size = 14
Button/styles/normal = SubResource("StyleBoxFlat_l27jc")
ColorPickerButton/styles/normal = SubResource("StyleBoxEmpty_5s6hr")
Label/font_sizes/font_size = 14
Panel/styles/panel = SubResource("StyleBoxFlat_p8vlj")
[node name="Tool" type="Window"]
title = "Chey's Background Addon"
initial_position = 5
size = Vector2i(400, 400)
min_size = Vector2i(400, 400)
max_size = Vector2i(400, 400)
script = ExtResource("1_yg3st")
[node name="Panel" type="Panel" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme = SubResource("Theme_csmr1")
[node name="VBoxContainer" type="VBoxContainer" parent="."]
clip_contents = true
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_bottom = 32.0
grow_horizontal = 2
grow_vertical = 2
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
clip_contents = true
custom_minimum_size = Vector2(0, 230)
layout_mode = 2
theme = SubResource("Theme_csmr1")
[node name="TextureRect" type="TextureRect" parent="VBoxContainer/PanelContainer"]
layout_mode = 2
expand_mode = 1
[node name="HBoxContainer" type="HBoxContainer" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
theme = SubResource("Theme_csmr1")
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
size_flags_vertical = 0
[node name="image picker" type="Button" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
custom_minimum_size = Vector2(0, 37)
layout_mode = 2
size_flags_stretch_ratio = 0.0
text = "Pick an image"
[node name="stretch mode" type="OptionButton" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
clip_contents = true
custom_minimum_size = Vector2(0, 37)
layout_mode = 2
size_flags_stretch_ratio = 0.0
clip_text = true
item_count = 7
popup/item_0/text = "Scale"
popup/item_0/id = 0
popup/item_1/text = "Tile"
popup/item_1/id = 1
popup/item_2/text = "Keep"
popup/item_2/id = 2
popup/item_3/text = "Keep Centered"
popup/item_3/id = 3
popup/item_4/text = "Keep Aspect"
popup/item_4/id = 4
popup/item_5/text = "Keep Aspect Centered"
popup/item_5/id = 5
popup/item_6/text = "Keep Aspect Covered"
popup/item_6/id = 6
[node name="filter mode" type="OptionButton" parent="VBoxContainer/HBoxContainer/VBoxContainer"]
clip_contents = true
custom_minimum_size = Vector2(0, 37)
layout_mode = 2
size_flags_stretch_ratio = 0.0
clip_text = true
item_count = 6
popup/item_0/text = "Nearest"
popup/item_0/id = 0
popup/item_1/text = "Linear"
popup/item_1/id = 1
popup/item_2/text = "Nearest Mipmap"
popup/item_2/id = 2
popup/item_3/text = "Linear Mipmap"
popup/item_3/id = 3
popup/item_4/text = "Nearest Mipmap Anisotropic"
popup/item_4/id = 4
popup/item_5/text = "Linear Mipmap Anisotropic"
popup/item_5/id = 5
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/HBoxContainer"]
clip_contents = true
layout_mode = 2
size_flags_horizontal = 3
theme = SubResource("Theme_csmr1")
[node name="Label" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer2"]
layout_mode = 2
size_flags_vertical = 0
theme_override_constants/line_spacing = -6
text = "UI Color
(close picker to change)"
horizontal_alignment = 1
[node name="ui_color" type="ColorPickerButton" parent="VBoxContainer/HBoxContainer/VBoxContainer2"]
custom_minimum_size = Vector2(0, 20)
layout_mode = 2
size_flags_vertical = 0
size_flags_stretch_ratio = 0.0
[node name="Label2" type="Label" parent="VBoxContainer/HBoxContainer/VBoxContainer2"]
layout_mode = 2
size_flags_vertical = 0
text = "Background Modulate"
horizontal_alignment = 1
[node name="bg_modulate" type="ColorPickerButton" parent="VBoxContainer/HBoxContainer/VBoxContainer2"]
custom_minimum_size = Vector2(0, 20)
layout_mode = 2
size_flags_vertical = 0
size_flags_stretch_ratio = 0.0
[node name="edit_transparency" type="CheckBox" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 2
size_flags_stretch_ratio = 0.38
tooltip_text = "For some reason, when editing an inspector field, Godot
still displays the previous state of it behind the current one.
Also, for some reason, when renaming a node in the scene
tab, the rename box opens in a separate window, which
ruins the transparency and makes it more gray. So as a hack,
this plugin turns text boxes black when editing. If you think
the prior is a better alternative, you can switch to that here."
text = "Enable textbox transparency on edit (?)"
[node name="Control" type="Control" parent="VBoxContainer"]
clip_contents = true
custom_minimum_size = Vector2(0, 40)
layout_mode = 2
size_flags_vertical = 0
size_flags_stretch_ratio = 1.21

View File

@@ -19,6 +19,10 @@ config/icon="res://icon.svg"
GameManager="*res://Scripts/game_manager.gd"
[editor_plugins]
enabled=PackedStringArray("res://addons/cba/plugin.cfg")
[input]
load={