Indent every script with tabs, like the Godot editor does
This commit is contained in:
1 parent
8c1987807c
commit
bad4b3ad8b
35 files changed
+1653
-1653
No files matched your search
+36
-36
@@ -14,54 +14,54 @@ var _rows: VBoxContainer = $VBoxContainer
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
scroll_direction = 1
|
||||
scroll_direction = 1
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
var speed_pixels_per_second: float = float(Settings.inspiration_list_speed) * 60.0
|
||||
var scroll_amount: float = speed_pixels_per_second * delta * float(scroll_direction)
|
||||
var speed_pixels_per_second: float = float(Settings.inspiration_list_speed) * 60.0
|
||||
var scroll_amount: float = speed_pixels_per_second * delta * float(scroll_direction)
|
||||
|
||||
var scroll_bar = get_v_scroll_bar()
|
||||
var scroll_bar = get_v_scroll_bar()
|
||||
|
||||
# Don't scroll if list is empty or too short
|
||||
if scroll_bar.max_value <= 0:
|
||||
return
|
||||
# Don't scroll if list is empty or too short
|
||||
if scroll_bar.max_value <= 0:
|
||||
return
|
||||
|
||||
var current_pos = scroll_bar.value
|
||||
var current_pos = scroll_bar.value
|
||||
|
||||
if scroll_direction == 1:
|
||||
# Scrolling down
|
||||
if current_pos + scroll_bar.page < scroll_bar.max_value:
|
||||
scroll_bar.value = min(current_pos + scroll_amount, scroll_bar.max_value - scroll_bar.page)
|
||||
else:
|
||||
# Reached bottom, reverse direction
|
||||
scroll_direction = -1
|
||||
scroll_bar.value = scroll_bar.max_value - scroll_bar.page
|
||||
else:
|
||||
# Scrolling up
|
||||
if current_pos > 0:
|
||||
scroll_bar.value = max(current_pos + scroll_amount, 0)
|
||||
else:
|
||||
# Reached top, reverse direction
|
||||
scroll_direction = 1
|
||||
scroll_bar.value = 0
|
||||
if scroll_direction == 1:
|
||||
# Scrolling down
|
||||
if current_pos + scroll_bar.page < scroll_bar.max_value:
|
||||
scroll_bar.value = min(current_pos + scroll_amount, scroll_bar.max_value - scroll_bar.page)
|
||||
else:
|
||||
# Reached bottom, reverse direction
|
||||
scroll_direction = -1
|
||||
scroll_bar.value = scroll_bar.max_value - scroll_bar.page
|
||||
else:
|
||||
# Scrolling up
|
||||
if current_pos > 0:
|
||||
scroll_bar.value = max(current_pos + scroll_amount, 0)
|
||||
else:
|
||||
# Reached top, reverse direction
|
||||
scroll_direction = 1
|
||||
scroll_bar.value = 0
|
||||
|
||||
|
||||
## Fetches every soundtrack from the server and shows them.
|
||||
func load_from_server() -> void:
|
||||
print("load_from_server")
|
||||
var populate_list: Callable = func populate_list(array) -> void:
|
||||
if typeof(array) == TYPE_ARRAY:
|
||||
show_soundtracks(array)
|
||||
else:
|
||||
print("Unexpected data")
|
||||
MusicServerClient.fetch_all_soundtracks(populate_list)
|
||||
print("load_from_server")
|
||||
var populate_list: Callable = func populate_list(array) -> void:
|
||||
if typeof(array) == TYPE_ARRAY:
|
||||
show_soundtracks(array)
|
||||
else:
|
||||
print("Unexpected data")
|
||||
MusicServerClient.fetch_all_soundtracks(populate_list)
|
||||
|
||||
|
||||
## Shows [param list] instead of the soundtracks shown now.
|
||||
func show_soundtracks(list: Array) -> void:
|
||||
soundtracks = []
|
||||
soundtracks.append_array(list)
|
||||
Settings.delete_children(_rows)
|
||||
for i: int in soundtracks.size():
|
||||
_rows.add_child(ListRow.create(soundtracks[i], i, 20))
|
||||
soundtracks = []
|
||||
soundtracks.append_array(list)
|
||||
Settings.delete_children(_rows)
|
||||
for i: int in soundtracks.size():
|
||||
_rows.add_child(ListRow.create(soundtracks[i], i, 20))
|
||||
Reference in new issue
Block a user