mirror of
https://github.com/Relintai/godot-resources-as-sheets-plugin.git
synced 2025-02-21 08:34:26 +01:00
Add sorting by resource and color
This commit is contained in:
parent
1ffa77166a
commit
83d23e60c6
@ -134,13 +134,24 @@ func _load_resources_from_folder(folderpath : String, sort_by : String, sort_rev
|
|||||||
|
|
||||||
func _insert_row_sorted(res : Resource, rows : Array, sort_by : String, sort_reverse : bool):
|
func _insert_row_sorted(res : Resource, rows : Array, sort_by : String, sort_reverse : bool):
|
||||||
for i in rows.size():
|
for i in rows.size():
|
||||||
if sort_reverse != (res.get(sort_by) < rows[i].get(sort_by)):
|
if sort_reverse == _compare_values(res.get(sort_by), rows[i].get(sort_by)):
|
||||||
rows.insert(i, res)
|
rows.insert(i, res)
|
||||||
return
|
return
|
||||||
|
|
||||||
rows.append(res)
|
rows.append(res)
|
||||||
|
|
||||||
|
|
||||||
|
func _compare_values(a, b) -> bool:
|
||||||
|
if a == null or b == null: return b == null
|
||||||
|
if a is Color:
|
||||||
|
return a.h > b.h if a.h != b.h else a.v > b.v
|
||||||
|
|
||||||
|
if a is Resource:
|
||||||
|
return a.resource_path > b.resource_path
|
||||||
|
|
||||||
|
return a > b
|
||||||
|
|
||||||
|
|
||||||
func _set_sorting(sort_by):
|
func _set_sorting(sort_by):
|
||||||
var sort_reverse : bool = !(sorting_by != sort_by or sorting_reverse)
|
var sort_reverse : bool = !(sorting_by != sort_by or sorting_reverse)
|
||||||
sorting_reverse = sort_reverse
|
sorting_reverse = sort_reverse
|
||||||
|
@ -80,7 +80,7 @@ func _increment_values(by : float, property : int):
|
|||||||
|
|
||||||
|
|
||||||
func _increment_values_custom(multiplier : float, property : int):
|
func _increment_values_custom(multiplier : float, property : int):
|
||||||
if property == 4 || property == 5:
|
if property == 4 or property == 5:
|
||||||
# Numbered buttons increment by 5 for Sat and Value, so hue is x0.5 effect. Negate it here
|
# Numbered buttons increment by 5 for Sat and Value, so hue is x0.5 effect. Negate it here
|
||||||
multiplier *= 2.0
|
multiplier *= 2.0
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user