Cam _process() delta fix with move_speed * delta! (-=

Simplify MenuOptions with ScrollVar.gd, set any Shared var!
Options for light_enabled, shadow_enabled & shadow_buffer^.^
This commit is contained in:
Harmony Honey 2023-04-06 00:32:50 -04:00
parent b49edef593
commit 0fd5e5c262
11 changed files with 201 additions and 63 deletions

View file

@ -6,6 +6,7 @@ var target_node setget set_target_node
onready var target_pos := global_position
var is_rotating := true
var is_moving := true
export var move_speed := 4.8
var screen_size := Vector2(1280, 720)
export var turn_offset := Vector2.ZERO
@ -81,7 +82,7 @@ func _process(delta):
# position
if is_moving:
global_position = global_position.linear_interpolate(target_pos + turn_offset.rotated(rotation), 0.08)
global_position = global_position.linear_interpolate(target_pos + turn_offset.rotated(rotation), move_speed * delta)
emit_signal("moved")

View file

@ -22,7 +22,7 @@ var goals := {}
var clock_rank := 0
enum SPEED {OFF, MAP, FILE, BOTH, TRADE}
var clock_show := 0
var clock_alpha := 1.0
var clock_alpha := 1.0 setget set_clock_alpha
var clock_decimals := 2
var clock_best_color := [Color.white, Color("ffff00")]
@ -111,6 +111,9 @@ var win_size := Vector2(1280, 720)
var win_sizes := [Vector2(640, 360), Vector2(960, 540), Vector2(1280, 720), Vector2(1600, 900),
Vector2(1920, 1080), Vector2(2560, 1440), Vector2(3840, 2160)]
var radial_blur = 0 setget set_radial_blur
var light_enabled := 1 setget set_light_enabled
var shadow_enabled := 1 setget set_shadow_enabled
var shadow_buffer := 2 setget set_shadow_buffer
var is_demo := false
@ -123,7 +126,6 @@ onready var arrow_mat : ShaderMaterial = $ArrowLayer/Arrow/Rect.material
var arrow_track = null
onready var chat := $ArrowLayer/Chat
func _ready():
Wipe.connect("complete", self, "wipe_complete")
boundary_node.visible = false
@ -155,6 +157,12 @@ func _ready():
var fe = f.file_exists("res://src/map/worlds/2A/0_hub.tscn")
f.close()
is_demo = !fe
yield(get_tree(), "idle_frame")
set_radial_blur()
set_light_enabled()
set_shadow_enabled()
set_shadow_buffer()
func _input(event):
if event is InputEventKey and event.pressed and !event.is_echo():
@ -390,6 +398,25 @@ func set_radial_blur(arg := radial_blur):
radial_blur = arg
Cam.blur(radial_blur)
func set_light_enabled(arg := light_enabled):
light_enabled = arg
if is_instance_valid(Clouds.star_light):
Clouds.star_light.enabled = bool(light_enabled)
func set_shadow_enabled(arg := shadow_enabled):
shadow_enabled = arg
if is_instance_valid(Clouds.star_light):
Clouds.star_light.shadow_enabled = bool(shadow_enabled)
func set_shadow_buffer(arg := shadow_buffer):
shadow_buffer = arg
if is_instance_valid(Clouds.star_light):
Clouds.star_light.shadow_buffer_size = [1024, 2048, 4096, 8192, 16384][shadow_buffer % 5]
func set_clock_alpha(arg := clock_alpha):
clock_alpha = clamp(arg, 0, 1)
if is_instance_valid(UI.clock):
UI.clock.modulate.a = clock_alpha
### Exit Game
@ -573,8 +600,14 @@ func save_options():
o["sounds"] = int(volume[1] / 10)
o["music"] = int(volume[2] / 10)
o["mouse"] = bool(Input.mouse_mode == Input.MOUSE_MODE_VISIBLE)
o["radial_blur"] = int(radial_blur)
o["light_enabled"] = int(light_enabled)
o["shadow_enabled"] = int(shadow_enabled)
o["shadow_buffer"] = int(shadow_buffer)
o["clock_show"] = int(clock_show)
o["clock_alpha"] = float(clock_alpha)
o["clock_decimals"] = int(clock_decimals)
@ -599,10 +632,19 @@ func load_options():
set_volume(1, int(d["sounds"]) * 10)
if d.has("music"):
set_volume(2, int(d["music"]) * 10)
if d.has("mouse"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE if bool(d["mouse"]) else Input.MOUSE_MODE_HIDDEN
if d.has("radial_blur"):
self.radial_blur = int(d["radial_blur"])
if d.has("light_enabled"):
self.light_enabled = int(d["light_enabled"])
if d.has("shadow_enabled"):
self.shadow_enabled = int(d["shadow_enabled"])
if d.has("shadow_buffer"):
self.shadow_buffer = int(d["shadow_buffer"])
if d.has("clock_show"):
clock_show = int(d["clock_show"])
if d.has("clock_alpha"):

View file

@ -10,6 +10,10 @@ func fill_items():
i._ready()
if i.is_in_group("speed"):
i.visible = Shared.clock_show > 0
if i.is_in_group("light"):
i.visible = Shared.light_enabled > 0
if i.is_in_group("shadow") and i.visible:
i.visible = Shared.shadow_enabled > 0
.fill_items()

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=2]
[gd_scene load_steps=22 format=2]
[ext_resource path="res://media/image/UI/clock.png" type="Texture" id=1]
[ext_resource path="res://media/font/profile/OptionsItem.tres" type="DynamicFont" id=2]
@ -14,14 +14,11 @@
[ext_resource path="res://media/image/UI/Video.png" type="Texture" id=12]
[ext_resource path="res://src/menu/options/scroll/Volume.tscn" type="PackedScene" id=13]
[ext_resource path="res://src/menu/options/scroll/Fullscreen.gd" type="Script" id=14]
[ext_resource path="res://src/menu/options/scroll/SpeedClock.gd" type="Script" id=15]
[ext_resource path="res://src/menu/options/scroll/SpeedAlpha.gd" type="Script" id=16]
[ext_resource path="res://src/menu/options/scroll/Vsync.gd" type="Script" id=17]
[ext_resource path="res://src/menu/options/scroll/Mouse.gd" type="Script" id=18]
[ext_resource path="res://src/menu/options/scroll/Borderless.gd" type="Script" id=19]
[ext_resource path="res://src/menu/options/scroll/SpeedDec.gd" type="Script" id=20]
[ext_resource path="res://src/shader/fade_x.gdshader" type="Shader" id=21]
[ext_resource path="res://src/menu/options/scroll/RadialBlur.gd" type="Script" id=22]
[ext_resource path="res://src/menu/options/scroll/ScrollVar.gd" type="Script" id=24]
[sub_resource type="ShaderMaterial" id=20]
shader = ExtResource( 21 )
@ -358,6 +355,7 @@ script = ExtResource( 14 )
__meta__ = {
"_edit_use_anchors_": false
}
is_refill = true
[node name="Label" type="Label" parent="Control/Menu/List/Fullscreen"]
anchor_right = 0.5
@ -508,11 +506,12 @@ margin_top = 1130.0
margin_right = 640.0
margin_bottom = 1200.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 22 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
}
list = PoolStringArray( "OFF", "0.5", "1.0", "2.0", "3.0", "5.0", "10.0", "TRIP" )
var_name = "radial_blur"
[node name="Label" type="Label" parent="Control/Menu/List/RadialBlur"]
anchor_right = 0.5
@ -536,19 +535,120 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacer4" type="Control" parent="Control/Menu/List" groups=["no_item"]]
[node name="Light" type="Control" parent="Control/Menu/List"]
margin_top = 1200.0
margin_right = 640.0
margin_bottom = 1230.0
margin_bottom = 1270.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
}
is_refill = true
var_name = "light_enabled"
[node name="Label" type="Label" parent="Control/Menu/List/Light"]
anchor_right = 0.5
anchor_bottom = 1.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "Dynamic Light"
valign = 1
[node name="Label2" type="Label" parent="Control/Menu/List/Light"]
anchor_left = 0.5
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "< OFF >"
align = 2
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Shadows" type="Control" parent="Control/Menu/List" groups=["light"]]
margin_top = 1270.0
margin_right = 640.0
margin_bottom = 1340.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
}
is_refill = true
[node name="Label" type="Label" parent="Control/Menu/List/Shadows"]
anchor_right = 0.5
anchor_bottom = 1.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "Shadows"
valign = 1
[node name="Label2" type="Label" parent="Control/Menu/List/Shadows"]
anchor_left = 0.5
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "< OFF >"
align = 2
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="ShadowBuffer" type="Control" parent="Control/Menu/List" groups=["light", "shadow"]]
margin_top = 1340.0
margin_right = 640.0
margin_bottom = 1410.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
}
list = PoolStringArray( "Low", "Medium", "High", "Ultra", "MAX" )
var_name = "shadow_buffer"
[node name="Label" type="Label" parent="Control/Menu/List/ShadowBuffer"]
anchor_right = 0.5
anchor_bottom = 1.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "Shadow Quality"
valign = 1
[node name="Label2" type="Label" parent="Control/Menu/List/ShadowBuffer"]
anchor_left = 0.5
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 25.0
size_flags_vertical = 6
custom_fonts/font = ExtResource( 2 )
text = "< OFF >"
align = 2
valign = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Spacer4" type="Control" parent="Control/Menu/List" groups=["no_item"]]
margin_top = 1410.0
margin_right = 640.0
margin_bottom = 1440.0
rect_min_size = Vector2( 0, 30 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="HeaderSpeed" type="Control" parent="Control/Menu/List" groups=["no_item"]]
margin_top = 1230.0
margin_top = 1440.0
margin_right = 640.0
margin_bottom = 1300.0
margin_bottom = 1510.0
rect_min_size = Vector2( 0, 70 )
[node name="Tex" type="TextureRect" parent="Control/Menu/List/HeaderSpeed"]
@ -569,15 +669,19 @@ text = "Speedrun"
valign = 1
[node name="Speedrun" type="Control" parent="Control/Menu/List"]
margin_top = 1300.0
margin_top = 1510.0
margin_right = 640.0
margin_bottom = 1370.0
margin_bottom = 1580.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 15 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
"_edit_use_anchors_": false,
"_editor_description_": ""
}
list = PoolStringArray( "OFF", "MAP", "FILE", "BOTH", "TRADE" )
is_refill = true
is_ui_scene = true
var_name = "clock_show"
[node name="Label" type="Label" parent="Control/Menu/List/Speedrun"]
anchor_right = 0.5
@ -602,15 +706,19 @@ __meta__ = {
}
[node name="Speedrun2" type="Control" parent="Control/Menu/List" groups=["speed"]]
margin_top = 1370.0
margin_top = 1580.0
margin_right = 640.0
margin_bottom = 1440.0
margin_bottom = 1650.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 16 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
"_edit_use_anchors_": false,
"_editor_description_": ""
}
list = PoolStringArray( "LESS", "HALF", "MORE", "FULL" )
is_ui_scene = true
var_name = "clock_alpha"
is_frac = true
[node name="Label" type="Label" parent="Control/Menu/List/Speedrun2"]
anchor_right = 0.5
@ -632,15 +740,18 @@ align = 2
valign = 1
[node name="Decimals" type="Control" parent="Control/Menu/List" groups=["speed"]]
margin_top = 1440.0
margin_top = 1650.0
margin_right = 640.0
margin_bottom = 1510.0
margin_bottom = 1720.0
rect_min_size = Vector2( 0, 70 )
script = ExtResource( 20 )
script = ExtResource( 24 )
__meta__ = {
"_edit_use_anchors_": false
"_edit_use_anchors_": false,
"_editor_description_": ""
}
count = 3
is_ui_scene = true
var_name = "clock_decimals"
[node name="Label" type="Label" parent="Control/Menu/List/Decimals"]
anchor_right = 0.5

View file

@ -7,4 +7,3 @@ func _ready():
func set_value():
if cursor != int(OS.window_fullscreen):
Shared.toggle_fullscreen()
MenuOptions.fill_items()

View file

@ -1,8 +0,0 @@
extends Scroll
func _ready():
cursor = Shared.radial_blur
set_label()
func set_value():
Shared.radial_blur = cursor

View file

@ -9,6 +9,8 @@ export var is_loop := false
export var count := 0
export var list : PoolStringArray = ["OFF", "ON"]
var is_select := false
export var is_refill := false
export var is_ui_scene := false
func _ready():
set_label()
@ -27,6 +29,10 @@ func set_cursor(arg := cursor):
cursor = posmod(arg, max(count + 1, list.size())) if is_loop else clamp(arg, 0, max(count, list.size() - 1))
set_label()
set_value()
if is_refill:
MenuOptions.fill_items()
if is_ui_scene:
UI.scene_changed(true)
func select(arg := is_select):
is_select = arg

View file

@ -0,0 +1,12 @@
extends Scroll
export var var_name := "shadow_enabled"
export var is_frac := false
func _ready():
cursor = Shared.get(var_name)
if is_frac: cursor = (cursor * list.size()) - 1
set_label()
func set_value():
Shared.set(var_name, (float(cursor + 1) / list.size()) if is_frac else cursor)

View file

@ -1,10 +0,0 @@
extends Scroll
func _ready():
cursor = (Shared.clock_alpha * list.size()) - 1
set_label()
func set_value():
Shared.clock_alpha = float(cursor + 1) / list.size()
UI.clock.modulate.a = Shared.clock_alpha
UI.scene_changed(true)

View file

@ -1,10 +0,0 @@
extends Scroll
func _ready():
cursor = Shared.clock_show
set_label()
func set_value():
Shared.clock_show = cursor
UI.scene_changed(true)
MenuOptions.fill_items()

View file

@ -1,9 +0,0 @@
extends Scroll
func _ready():
cursor = Shared.clock_decimals
set_label()
func set_value():
Shared.clock_decimals = cursor
UI.scene_changed(true)