mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 16:53:07 +00:00
Fixed more stuff
This commit is contained in:
parent
8b12eac231
commit
6a60050bd3
|
@ -53,16 +53,24 @@ class GridPreference:
|
|||
value_type = _value_type
|
||||
if _default_value != null:
|
||||
default_value = _default_value
|
||||
else:
|
||||
default_value = Global.get(prop_name)
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var grids = Global.config_cache.get_value(
|
||||
"preferences", "grids", {0: create_default_properties()}
|
||||
)
|
||||
Global.config_cache.set_value("preferences", "grids", grids)
|
||||
$GridsCount.value = grids.size()
|
||||
for pref in grid_preferences:
|
||||
if not has_node(pref.node_path):
|
||||
continue
|
||||
var node := get_node(pref.node_path)
|
||||
var restore_default_button := RestoreDefaultButton.new()
|
||||
restore_default_button.pressed.connect(
|
||||
_on_Grid_Pref_value_changed.bind(
|
||||
pref.default_value, pref, restore_default_button
|
||||
)
|
||||
)
|
||||
restore_default_button.setting_name = pref.prop_name
|
||||
restore_default_button.value_type = pref.value_type
|
||||
restore_default_button.default_value = pref.default_value
|
||||
|
@ -71,11 +79,6 @@ func _ready() -> void:
|
|||
var node_position := node.get_index()
|
||||
node.get_parent().add_child(restore_default_button)
|
||||
node.get_parent().move_child(restore_default_button, node_position)
|
||||
var grids = Global.config_cache.get_value(
|
||||
"preferences", "grids", {0: create_default_properties()}
|
||||
)
|
||||
Global.config_cache.set_value("preferences", "grids", grids)
|
||||
$GridsCount.value = grids.size()
|
||||
|
||||
match pref.value_type:
|
||||
"button_pressed":
|
||||
|
@ -108,12 +111,12 @@ func _on_Grid_Pref_value_changed(value, pref: GridPreference, button: RestoreDef
|
|||
var prop := pref.prop_name
|
||||
grid_info[prop] = value
|
||||
grids[grid_selected] = grid_info
|
||||
Global.update_grids(grids)
|
||||
var default_value = pref.default_value
|
||||
var disable: bool = Global.get(prop) == default_value
|
||||
var disable: bool = Global.grids[grid_selected].get(prop) == default_value
|
||||
if typeof(value) == TYPE_COLOR:
|
||||
disable = value.is_equal_approx(default_value)
|
||||
disable_restore_default_button(button, disable)
|
||||
Global.update_grids(grids)
|
||||
Global.config_cache.set_value(
|
||||
"preferences", "grids", grids
|
||||
)
|
||||
|
@ -133,6 +136,7 @@ func _on_grids_count_value_changed(value: float) -> void:
|
|||
for key: int in range(grid_idx + 1, grids.size()):
|
||||
grids.erase(key)
|
||||
add_remove_select_button(key, true)
|
||||
Global.update_grids(grids)
|
||||
Global.config_cache.set_value("preferences", "grids", grids)
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
extends Node2D
|
||||
|
||||
var unique_rect_lines := PackedVector2Array()
|
||||
var unique_iso_lines := PackedVector2Array()
|
||||
|
||||
func _ready() -> void:
|
||||
Global.project_switched.connect(queue_redraw)
|
||||
|
@ -10,7 +12,9 @@ func _draw() -> void:
|
|||
return
|
||||
|
||||
var target_rect: Rect2i
|
||||
for grid_idx in Global.grids.size():
|
||||
unique_rect_lines.clear()
|
||||
unique_iso_lines.clear()
|
||||
for grid_idx in range(Global.grids.size() - 1, -1, -1):
|
||||
if Global.grids[grid_idx].grid_draw_over_tile_mode:
|
||||
target_rect = Global.current_project.tiles.get_bounding_rect()
|
||||
else:
|
||||
|
@ -35,6 +39,8 @@ func _draw_cartesian_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
+ fposmod(grid.grid_offset.x - target_rect.position.x, grid.grid_size.x)
|
||||
)
|
||||
while x <= target_rect.end.x:
|
||||
# Check if the exact line has been added before
|
||||
if not Vector2(x, target_rect.position.y) in unique_rect_lines:
|
||||
grid_multiline_points.push_back(Vector2(x, target_rect.position.y))
|
||||
grid_multiline_points.push_back(Vector2(x, target_rect.end.y))
|
||||
x += grid.grid_size.x
|
||||
|
@ -44,10 +50,13 @@ func _draw_cartesian_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
+ fposmod(grid.grid_offset.y - target_rect.position.y, grid.grid_size.y)
|
||||
)
|
||||
while y <= target_rect.end.y:
|
||||
# Check if the exact line has been added before
|
||||
if not Vector2(target_rect.position.x, y) in unique_rect_lines:
|
||||
grid_multiline_points.push_back(Vector2(target_rect.position.x, y))
|
||||
grid_multiline_points.push_back(Vector2(target_rect.end.x, y))
|
||||
y += grid.grid_size.y
|
||||
|
||||
unique_rect_lines.append_array(grid_multiline_points)
|
||||
if not grid_multiline_points.is_empty():
|
||||
draw_multiline(grid_multiline_points, grid.grid_color)
|
||||
|
||||
|
@ -73,6 +82,7 @@ func _draw_isometric_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
var start: Vector2 = Vector2(target_rect.position) + Vector2(0, y)
|
||||
var cells_to_rect_bounds: float = minf(max_cell_count.x, y / cell_size.y)
|
||||
var end := start + cells_to_rect_bounds * per_cell_offset
|
||||
if not start in unique_iso_lines:
|
||||
grid_multiline_points.push_back(start)
|
||||
grid_multiline_points.push_back(end)
|
||||
y += cell_size.y
|
||||
|
@ -83,6 +93,7 @@ func _draw_isometric_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
var start: Vector2 = Vector2(target_rect.position) + Vector2(x, target_rect.size.y)
|
||||
var cells_to_rect_bounds: float = minf(max_cell_count.y, max_cell_count.x - x / cell_size.x)
|
||||
var end: Vector2 = start + cells_to_rect_bounds * per_cell_offset
|
||||
if not start in unique_iso_lines:
|
||||
grid_multiline_points.push_back(start)
|
||||
grid_multiline_points.push_back(end)
|
||||
x += cell_size.x
|
||||
|
@ -96,6 +107,7 @@ func _draw_isometric_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
var start: Vector2 = Vector2(target_rect.position) + Vector2(0, y)
|
||||
var cells_to_rect_bounds: float = minf(max_cell_count.x, max_cell_count.y - y / cell_size.y)
|
||||
var end: Vector2 = start + cells_to_rect_bounds * per_cell_offset
|
||||
if not start in unique_iso_lines:
|
||||
grid_multiline_points.push_back(start)
|
||||
grid_multiline_points.push_back(end)
|
||||
y += cell_size.y
|
||||
|
@ -106,9 +118,11 @@ func _draw_isometric_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
var start: Vector2 = Vector2(target_rect.position) + Vector2(x, 0)
|
||||
var cells_to_rect_bounds: float = minf(max_cell_count.y, max_cell_count.x - x / cell_size.x)
|
||||
var end: Vector2 = start + cells_to_rect_bounds * per_cell_offset
|
||||
if not start in unique_iso_lines:
|
||||
grid_multiline_points.push_back(start)
|
||||
grid_multiline_points.push_back(end)
|
||||
x += cell_size.x
|
||||
grid_multiline_points.append_array(grid_multiline_points)
|
||||
|
||||
if not grid_multiline_points.is_empty():
|
||||
draw_multiline(grid_multiline_points, grid.grid_color)
|
||||
|
|
Loading…
Reference in a new issue