mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 16:53:07 +00:00
formatting
This commit is contained in:
parent
8990ff2816
commit
d34c7739fb
|
@ -749,6 +749,7 @@ func update_grids(grids_data: Dictionary):
|
|||
for grid_idx in grids_data.size():
|
||||
Grid.new(grids_data[grid_idx]) # gets auto added to grids array
|
||||
|
||||
|
||||
func _initialize_keychain() -> void:
|
||||
Keychain.config_file = config_cache
|
||||
Keychain.actions = {
|
||||
|
|
|
@ -1,20 +1,11 @@
|
|||
extends GridContainer
|
||||
|
||||
var grid_preferences: Array[GridPreference] = [
|
||||
GridPreference.new(
|
||||
"grid_type", "GridType", "selected", Global.GridTypes.CARTESIAN
|
||||
),
|
||||
GridPreference.new("grid_type", "GridType", "selected", Global.GridTypes.CARTESIAN),
|
||||
GridPreference.new("grid_size", "GridSizeValue", "value", Vector2i(2, 2)),
|
||||
GridPreference.new(
|
||||
"isometric_grid_size", "IsometricGridSizeValue", "value", Vector2i(16, 8)
|
||||
),
|
||||
GridPreference.new("isometric_grid_size", "IsometricGridSizeValue", "value", Vector2i(16, 8)),
|
||||
GridPreference.new("grid_offset", "GridOffsetValue", "value", Vector2i.ZERO),
|
||||
GridPreference.new(
|
||||
"grid_draw_over_tile_mode",
|
||||
"GridDrawOverTileMode",
|
||||
"button_pressed",
|
||||
false
|
||||
),
|
||||
GridPreference.new("grid_draw_over_tile_mode", "GridDrawOverTileMode", "button_pressed", false),
|
||||
GridPreference.new("grid_color", "GridColor", "color", Color.BLACK),
|
||||
]
|
||||
|
||||
|
@ -67,9 +58,7 @@ func _ready() -> void:
|
|||
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
|
||||
)
|
||||
_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
|
||||
|
@ -82,9 +71,7 @@ func _ready() -> void:
|
|||
|
||||
match pref.value_type:
|
||||
"button_pressed":
|
||||
node.toggled.connect(
|
||||
_on_Grid_Pref_value_changed.bind(pref, restore_default_button)
|
||||
)
|
||||
node.toggled.connect(_on_Grid_Pref_value_changed.bind(pref, restore_default_button))
|
||||
"value":
|
||||
node.value_changed.connect(
|
||||
_on_Grid_Pref_value_changed.bind(pref, restore_default_button)
|
||||
|
@ -101,7 +88,6 @@ func _ready() -> void:
|
|||
grid_selected = 0
|
||||
|
||||
|
||||
|
||||
func _on_Grid_Pref_value_changed(value, pref: GridPreference, button: RestoreDefaultButton) -> void:
|
||||
var grids: Dictionary = Global.config_cache.get_value(
|
||||
"preferences", "grids", {0: create_default_properties()}
|
||||
|
@ -117,9 +103,7 @@ func _on_Grid_Pref_value_changed(value, pref: GridPreference, button: RestoreDef
|
|||
if typeof(value) == TYPE_COLOR:
|
||||
disable = value.is_equal_approx(default_value)
|
||||
disable_restore_default_button(button, disable)
|
||||
Global.config_cache.set_value(
|
||||
"preferences", "grids", grids
|
||||
)
|
||||
Global.config_cache.set_value("preferences", "grids", grids)
|
||||
|
||||
|
||||
func _on_grids_count_value_changed(value: float) -> void:
|
||||
|
@ -162,7 +146,7 @@ func add_remove_select_button(grid_idx: int, remove := false):
|
|||
var select_button = Button.new()
|
||||
select_button.text = str(grid_idx)
|
||||
grids_select_container.add_child(select_button)
|
||||
select_button.pressed.connect(func() : grid_selected = grid_idx)
|
||||
select_button.pressed.connect(func(): grid_selected = grid_idx)
|
||||
else:
|
||||
if grid_idx < grids_select_container.get_child_count():
|
||||
grids_select_container.get_child(grid_idx).queue_free()
|
||||
|
|
|
@ -149,7 +149,9 @@ func snap_position(pos: Vector2) -> Vector2:
|
|||
pos = grid_point.floor()
|
||||
|
||||
if Global.snap_to_rectangular_grid_center:
|
||||
var grid_center := pos.snapped(Global.grids[0].grid_size) + Vector2(Global.grids[0].grid_size / 2)
|
||||
var grid_center := (
|
||||
pos.snapped(Global.grids[0].grid_size) + Vector2(Global.grids[0].grid_size / 2)
|
||||
)
|
||||
grid_center += Vector2(Global.grids[0].grid_offset)
|
||||
# keeping grid_center as is would have been fine but this adds extra accuracy as to
|
||||
# which snap point (from the list below) is closest to mouse and occupy THAT point
|
||||
|
|
|
@ -113,10 +113,12 @@ func _snap_position(pos: Vector2) -> Vector2:
|
|||
if !Global.current_project.has_selection:
|
||||
var move_offset := Vector2.ZERO
|
||||
move_offset.x = (
|
||||
_start_pos.x - (_start_pos.x / Global.grids[0].grid_size.x) * Global.grids[0].grid_size.x
|
||||
_start_pos.x
|
||||
- (_start_pos.x / Global.grids[0].grid_size.x) * Global.grids[0].grid_size.x
|
||||
)
|
||||
move_offset.y = (
|
||||
_start_pos.y - (_start_pos.y / Global.grids[0].grid_size.y) * Global.grids[0].grid_size.y
|
||||
_start_pos.y
|
||||
- (_start_pos.y / Global.grids[0].grid_size.y) * Global.grids[0].grid_size.y
|
||||
)
|
||||
pos += move_offset
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ extends Node2D
|
|||
var unique_rect_lines := PackedVector2Array()
|
||||
var unique_iso_lines := PackedVector2Array()
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Global.project_switched.connect(queue_redraw)
|
||||
|
||||
|
@ -67,9 +68,7 @@ func _draw_isometric_grid(grid_index: int, target_rect: Rect2i) -> void:
|
|||
|
||||
var cell_size: Vector2 = grid.isometric_grid_size
|
||||
var max_cell_count: Vector2 = Vector2(target_rect.size) / cell_size
|
||||
var origin_offset: Vector2 = Vector2(grid.grid_offset - target_rect.position).posmodv(
|
||||
cell_size
|
||||
)
|
||||
var origin_offset: Vector2 = Vector2(grid.grid_offset - target_rect.position).posmodv(cell_size)
|
||||
|
||||
# lines ↗↗↗ (from bottom-left to top-right)
|
||||
var per_cell_offset: Vector2 = cell_size * Vector2(1, -1)
|
||||
|
|
Loading…
Reference in a new issue