improve cursor and add cursor themes

This commit is contained in:
Nitwel 2024-05-10 13:16:17 +02:00
parent a52ebc03e7
commit 0bee8c5f9c
12 changed files with 240 additions and 22 deletions

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:58fcb3f5a4f3c2ba1c13952d999ceb53dc21a214f7a484efc4ddea84ddade5ce
size 220

View File

@ -0,0 +1,36 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://churthrr24yhw"
path.s3tc="res://.godot/imported/old.png-a60d47e8bc819babf135eb9ce84b124c.s3tc.ctex"
path.etc2="res://.godot/imported/old.png-a60d47e8bc819babf135eb9ce84b124c.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
}
[deps]
source_file="res://assets/cursors/old.png"
dest_files=["res://.godot/imported/old.png-a60d47e8bc819babf135eb9ce84b124c.s3tc.ctex", "res://.godot/imported/old.png-a60d47e8bc819babf135eb9ce84b124c.etc2.ctex"]
[params]
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=true
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=0

View File

@ -3,8 +3,8 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bl33klueufwja"
path.s3tc="res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.s3tc.ctex"
path.etc2="res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.etc2.ctex"
path.s3tc="res://.godot/imported/pointer.png-d044c796591a4272f0c14ca625e25d78.s3tc.ctex"
path.etc2="res://.godot/imported/pointer.png-d044c796591a4272f0c14ca625e25d78.etc2.ctex"
metadata={
"imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
@ -12,8 +12,8 @@ metadata={
[deps]
source_file="res://assets/materials/pointer.png"
dest_files=["res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.s3tc.ctex", "res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.etc2.ctex"]
source_file="res://assets/cursors/pointer.png"
dest_files=["res://.godot/imported/pointer.png-d044c796591a4272f0c14ca625e25d78.s3tc.ctex", "res://.godot/imported/pointer.png-d044c796591a4272f0c14ca625e25d78.etc2.ctex"]
[params]

View File

@ -38,9 +38,10 @@ label = "videocam_off"
icon = true
[node name="Slider" parent="." instance=ExtResource("4_lfexu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.05, -0.1, 0)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.1, 0)
min = 1.0
max = 30.0
value = 1.0
step = 1.0
label_unit = "FPS"
size = Vector3(0.1, 0.02, 0.01)

View File

@ -4,6 +4,8 @@ const Pointer = preload ("res://lib/utils/pointer/pointer.gd")
const Initiator = preload ("res://lib/utils/pointer/initiator.gd")
@onready var cursor: Node3D = $Cursor
@onready var default_cursor: Sprite3D = $Cursor/DefaultCursor
@onready var retro_cursor: Sprite3D = $Cursor/RetroCursor
@onready var decal: Decal = $Decal
@export var is_right: bool = true
@ -35,6 +37,16 @@ func _ready():
pointer.released(_event_type_map[button])
)
R.effect(func(_arg):
match Store.settings.state.cursor_style:
1:
default_cursor.visible=false
retro_cursor.visible=true
0, _:
default_cursor.visible=true
retro_cursor.visible=false
)
func _physics_process(_delta):
_handle_cursor()
@ -58,4 +70,13 @@ func _handle_cursor():
cursor.visible = true
decal.visible = false
cursor.global_transform.origin = get_collision_point() + get_collision_normal() * 0.001 # offset to avoid z-fighting
cursor.global_transform.basis = Basis.looking_at(get_collision_normal(), Vector3.UP)
if abs(get_collision_normal().dot(Vector3.UP)) > 0.9:
var ray_dir_inv = global_transform.basis.z
cursor.global_transform.basis = Basis.looking_at(get_collision_normal().lerp(ray_dir_inv, 0.01), Vector3.UP, true)
else:
cursor.global_transform.basis = Basis.looking_at(get_collision_normal(), Vector3.UP, true)
var cursor_scale = clamp(distance * 1.5 - 0.75, 1.0, 3.0)
cursor.scale = Vector3(cursor_scale, cursor_scale, cursor_scale)

View File

@ -1,7 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://dscp8x0ari57n"]
[gd_scene load_steps=8 format=3 uid="uid://dscp8x0ari57n"]
[ext_resource type="Texture2D" uid="uid://bl33klueufwja" path="res://assets/materials/pointer.png" id="1_2f2iv"]
[ext_resource type="Texture2D" uid="uid://bl33klueufwja" path="res://assets/cursors/pointer.png" id="1_2f2iv"]
[ext_resource type="Script" path="res://content/system/raycast/raycast.gd" id="1_gp8nv"]
[ext_resource type="Texture2D" uid="uid://churthrr24yhw" path="res://assets/cursors/old.png" id="3_f5ibs"]
[ext_resource type="Shader" path="res://content/system/raycast/raycast.gdshader" id="3_lpfe7"]
[ext_resource type="Texture2D" uid="uid://cy5dna78q6tn6" path="res://assets/models/ray/ray.png" id="4_fe8o8"]
[ext_resource type="ArrayMesh" uid="uid://d3kriab522o2w" path="res://assets/models/ray/ray.obj" id="5_3o4gy"]
@ -28,12 +29,22 @@ lower_fade = 0.000919435
[node name="Cursor" type="Node3D" parent="."]
[node name="CursorSprite" type="Sprite3D" parent="Cursor"]
[node name="DefaultCursor" type="Sprite3D" parent="Cursor"]
transform = Transform3D(0.03, 2.71051e-20, 0, -5.42101e-20, 0.03, -2.03288e-21, -2.46521e-33, 2.5411e-21, 0.03, 0, 0, 0)
visible = false
pixel_size = 0.001
texture_filter = 0
render_priority = 90
texture = ExtResource("1_2f2iv")
[node name="RetroCursor" type="Sprite3D" parent="Cursor"]
transform = Transform3D(0.03, 0, 0, 0, 0.03, 0, 0, 0, 0.03, 0, 0, 0)
offset = Vector2(5.835, -9.175)
pixel_size = 0.03
texture_filter = 0
render_priority = 90
texture = ExtResource("3_f5ibs")
[node name="Ray" type="MeshInstance3D" parent="."]
transform = Transform3D(1, -1.39624e-11, -6.10317e-19, 0, -4.37114e-08, 1, -1.39624e-11, -1, -4.37114e-08, 0, 0, -0.0182334)
material_override = SubResource("ShaderMaterial_ov0gt")

View File

@ -4,7 +4,7 @@ class_name Tabs3D
signal on_select(selected: int)
var selected = R.state(null)
var selected = R.state(0)
@export var initial_selected: Node3D
@ -15,23 +15,20 @@ func _ready():
return
if initial_selected:
selected.value = initial_selected
R.effect(func(_arg):
on_select.emit(selected.value)
)
selected.value = initial_selected.get_index()
for option in get_children():
if option is Button3D == false:
continue
option.on_button_down.connect(func():
selected.value=option
selected.value=option.get_index()
on_select.emit(option.get_index())
)
R.effect(func(_arg):
option.active=option == selected.value
option.disabled=option == selected.value
option.active=option.get_index() == selected.value
option.disabled=option.get_index() == selected.value
)
option.toggleable = true
option.toggleable = true

View File

@ -14,7 +14,7 @@ func _ready():
remove_child(child)
R.effect(func(_arg):
if tabs.selected.value.get_index() == i:
if tabs.selected.value == i:
add_child(child)
elif child.get_parent() == self:
remove_child(child)

View File

@ -1,6 +1,7 @@
extends Node3D
@onready var voice_assist = $VoiceAssist
@onready var cursor_options = $CursorOptions
func _ready():
var settings_store = Store.settings.state
@ -32,7 +33,15 @@ func _ready():
settings_store.voice_assistant=false
Store.settings.save_local()
)
cursor_options.selected.value = settings_store.cursor_style
cursor_options.on_select.connect(func(option):
settings_store.cursor_style=option
settings_store.cursor_style=option
print("cursor_style", option)
Store.settings.save_local()
)
R.bind(voice_assist, "label", button_label)

View File

@ -1,7 +1,56 @@
[gd_scene load_steps=3 format=3 uid="uid://4hai6lp64m2o"]
[gd_scene load_steps=14 format=3 uid="uid://4hai6lp64m2o"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_52ufi"]
[ext_resource type="Script" path="res://content/ui/menu/settings/menus/features_menu.gd" id="1_imqs2"]
[ext_resource type="Script" path="res://content/ui/components/tabs/tabs.gd" id="3_cwu20"]
[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="4_v4u0l"]
[ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="5_3vfb4"]
[ext_resource type="Texture2D" uid="uid://bl33klueufwja" path="res://assets/cursors/pointer.png" id="6_ypel5"]
[ext_resource type="Texture2D" uid="uid://churthrr24yhw" path="res://assets/cursors/old.png" id="7_un12x"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_0hxn1"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("4_v4u0l")
shader_parameter/color = Color(1, 1, 1, 0.3)
shader_parameter/border_color = Color(1, 1, 1, 1)
shader_parameter/edge_color = Color(0, 0, 0, 1)
shader_parameter/size = Vector2(1, 1)
shader_parameter/border_size = 0.01
shader_parameter/border_fade_in = 0.05
shader_parameter/border_fade_out = 0.0
shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_1x032"]
size = Vector2(0.04, 0.04)
[sub_resource type="BoxShape3D" id="BoxShape3D_01skh"]
resource_local_to_scene = true
size = Vector3(0.04, 0.04, 0.01)
[sub_resource type="BoxShape3D" id="BoxShape3D_surd4"]
resource_local_to_scene = true
size = Vector3(0.04, 0.04, 0.03)
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pnxr8"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("4_v4u0l")
shader_parameter/color = Color(1, 1, 1, 0.3)
shader_parameter/border_color = Color(1, 1, 1, 1)
shader_parameter/edge_color = Color(0, 0, 0, 1)
shader_parameter/size = Vector2(1, 1)
shader_parameter/border_size = 0.01
shader_parameter/border_fade_in = 0.05
shader_parameter/border_fade_out = 0.0
shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02
[sub_resource type="QuadMesh" id="QuadMesh_6ehqp"]
size = Vector2(0.04, 0.04)
[node name="FeaturesMenu" type="Node3D"]
script = ExtResource("1_imqs2")
@ -21,3 +70,87 @@ text = "Voice Assistant: "
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="LabelCursor" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.13, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Cursor Style: "
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="CursorOptions" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.17, -0.13, 0)
script = ExtResource("3_cwu20")
gap = 0.01
[node name="CircleCursor" parent="CursorOptions" instance=ExtResource("1_52ufi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, 0, 0)
label = ""
icon = true
toggleable = true
[node name="Panel3D" parent="CursorOptions/CircleCursor/Body" index="0"]
material_override = SubResource("ShaderMaterial_0hxn1")
mesh = SubResource("QuadMesh_1x032")
[node name="CollisionShape3D" parent="CursorOptions/CircleCursor/Body" index="1"]
shape = SubResource("BoxShape3D_01skh")
[node name="Label" parent="CursorOptions/CircleCursor/Body" index="2"]
text = ""
font = ExtResource("5_3vfb4")
font_size = 28
autowrap_mode = 0
width = 1000.0
[node name="Sprite3D" type="Sprite3D" parent="CursorOptions/CircleCursor/Body/Label" index="0"]
transform = Transform3D(0.05, 0, 0, 0, 0.05, 0, 0, 0, 0.05, 0, 0, 0)
pixel_size = 0.001
double_sided = false
render_priority = 20
texture = ExtResource("6_ypel5")
[node name="CollisionShape3D" parent="CursorOptions/CircleCursor/FingerArea" index="0"]
shape = SubResource("BoxShape3D_surd4")
[node name="CollisionShape3D" parent="CursorOptions/CircleCursor/TouchBody" index="0"]
shape = SubResource("BoxShape3D_01skh")
[node name="RetroCursor" parent="CursorOptions" instance=ExtResource("1_52ufi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.07, 0, 0)
label = ""
icon = true
toggleable = true
[node name="Panel3D" parent="CursorOptions/RetroCursor/Body" index="0"]
material_override = SubResource("ShaderMaterial_pnxr8")
mesh = SubResource("QuadMesh_6ehqp")
[node name="CollisionShape3D" parent="CursorOptions/RetroCursor/Body" index="1"]
shape = SubResource("BoxShape3D_01skh")
[node name="Label" parent="CursorOptions/RetroCursor/Body" index="2"]
text = ""
font = ExtResource("5_3vfb4")
font_size = 28
autowrap_mode = 0
width = 1000.0
[node name="Sprite3D" type="Sprite3D" parent="CursorOptions/RetroCursor/Body/Label" index="0"]
pixel_size = 0.001
double_sided = false
texture_filter = 0
render_priority = 20
texture = ExtResource("7_un12x")
[node name="CollisionShape3D" parent="CursorOptions/RetroCursor/FingerArea" index="0"]
shape = SubResource("BoxShape3D_surd4")
[node name="CollisionShape3D" parent="CursorOptions/RetroCursor/TouchBody" index="0"]
shape = SubResource("BoxShape3D_01skh")
[editable path="CursorOptions/CircleCursor"]
[editable path="CursorOptions/RetroCursor"]

View File

@ -3,6 +3,11 @@ extends StoreClass
const StoreClass = preload ("./store.gd")
enum CursorStyle {
DEFAULT,
RETRO
}
func _init():
_save_path = "user://settings.json"
@ -14,7 +19,8 @@ func _init():
## If the voice assistant should be enabled
"voice_assistant": false,
## If the onboarding process has been completed
"onboarding_complete": false
"onboarding_complete": false,
"cursor_style": CursorStyle.DEFAULT
})
func clear():
@ -23,3 +29,4 @@ func clear():
self.state.token = ""
self.state.voice_assistant = false
self.state.onboarding_complete = false
self.state.cursor_style = CursorStyle.DEFAULT