1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-15 02:03:06 +00:00

fix some things

This commit is contained in:
Variable 2024-11-26 12:52:43 +05:00
parent 53a86127a0
commit adbeec12f8
5 changed files with 30 additions and 20 deletions

View file

@ -921,7 +921,7 @@ right_text_tool={
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null) "events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":true,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
] ]
} }
show_color_indices={ show_pixel_indices={
"deadzone": 0.5, "deadzone": 0.5,
"events": [] "events": []
} }

View file

@ -35,10 +35,10 @@ enum ViewMenu {
MIRROR_VIEW, MIRROR_VIEW,
SHOW_GRID, SHOW_GRID,
SHOW_PIXEL_GRID, SHOW_PIXEL_GRID,
SHOW_PIXEL_INDICES,
SHOW_RULERS, SHOW_RULERS,
SHOW_GUIDES, SHOW_GUIDES,
SHOW_MOUSE_GUIDES, SHOW_MOUSE_GUIDES,
SHOW_COLOR_INDICES,
DISPLAY_LAYER_EFFECTS, DISPLAY_LAYER_EFFECTS,
SNAP_TO, SNAP_TO,
} }
@ -557,9 +557,9 @@ var show_guides := true
## If [code]true[/code], the mouse guides are visible. ## If [code]true[/code], the mouse guides are visible.
var show_mouse_guides := false var show_mouse_guides := false
## If [code]true[/code], the indices of color are shown. ## If [code]true[/code], the indices of color are shown.
var show_color_indices := false: var show_pixel_indices := false:
set(value): set(value):
show_color_indices = value show_pixel_indices = value
if is_instance_valid(canvas.color_index): if is_instance_valid(canvas.color_index):
canvas.color_index.enabled = value canvas.color_index.enabled = value
var display_layer_effects := true: var display_layer_effects := true:
@ -756,7 +756,7 @@ func _ready() -> void:
Global.use_native_file_dialogs = true Global.use_native_file_dialogs = true
await get_tree().process_frame await get_tree().process_frame
project_switched.emit() project_switched.emit()
canvas.color_index.enabled = show_color_indices # Initialize color index preview canvas.color_index.enabled = show_pixel_indices # Initialize color index preview
func update_grids(grids_data: Dictionary): func update_grids(grids_data: Dictionary):

View file

@ -601,10 +601,10 @@ func _exit_tree() -> void:
Global.config_cache.set_value("window", "size", get_window().size) Global.config_cache.set_value("window", "size", get_window().size)
Global.config_cache.set_value("view_menu", "draw_grid", Global.draw_grid) Global.config_cache.set_value("view_menu", "draw_grid", Global.draw_grid)
Global.config_cache.set_value("view_menu", "draw_pixel_grid", Global.draw_pixel_grid) Global.config_cache.set_value("view_menu", "draw_pixel_grid", Global.draw_pixel_grid)
Global.config_cache.set_value("view_menu", "show_pixel_indices", Global.show_pixel_indices)
Global.config_cache.set_value("view_menu", "show_rulers", Global.show_rulers) Global.config_cache.set_value("view_menu", "show_rulers", Global.show_rulers)
Global.config_cache.set_value("view_menu", "show_guides", Global.show_guides) Global.config_cache.set_value("view_menu", "show_guides", Global.show_guides)
Global.config_cache.set_value("view_menu", "show_mouse_guides", Global.show_mouse_guides) Global.config_cache.set_value("view_menu", "show_mouse_guides", Global.show_mouse_guides)
Global.config_cache.set_value("view_menu", "show_color_indices", Global.show_color_indices)
Global.config_cache.set_value( Global.config_cache.set_value(
"view_menu", "display_layer_effects", Global.display_layer_effects "view_menu", "display_layer_effects", Global.display_layer_effects
) )

View file

@ -9,16 +9,26 @@ var enabled: bool = false:
queue_redraw() queue_redraw()
func _ready() -> void:
Global.camera.zoom_changed.connect(queue_redraw)
func _draw() -> void: func _draw() -> void:
if not enabled: if not enabled:
return return
# when we zoom out there is a visual issue that inverts the text
# (kind of how you look through a magnifying glass)
# so we should restrict the rendering distance of this preview.
var zoom_percentage := 100.0 * Global.camera.zoom.x
if zoom_percentage < Global.pixel_grid_show_at_zoom:
return
var project = ExtensionsApi.project.current_project var project = ExtensionsApi.project.current_project
var size: Vector2i = project.size var size: Vector2i = project.size
var cel: BaseCel = project.frames[project.current_frame].cels[project.current_layer] var cel: BaseCel = project.frames[project.current_frame].cels[project.current_layer]
if not cel is PixelCel: if not cel is PixelCel:
return return
var index_image: Image = cel.image.indices_image var index_image: Image = cel.image.indices_image
if index_image.get_size() != size: if index_image.get_size() != size or not cel.image.is_indexed:
return return
var font: Font = ExtensionsApi.theme.get_theme().default_font var font: Font = ExtensionsApi.theme.get_theme().default_font

View file

@ -232,10 +232,10 @@ func _setup_view_menu() -> void:
"Mirror View": "mirror_view", "Mirror View": "mirror_view",
"Show Grid": "show_grid", "Show Grid": "show_grid",
"Show Pixel Grid": "show_pixel_grid", "Show Pixel Grid": "show_pixel_grid",
"Show Pixel Indices": "show_pixel_indices",
"Show Rulers": "show_rulers", "Show Rulers": "show_rulers",
"Show Guides": "show_guides", "Show Guides": "show_guides",
"Show Mouse Guides": "", "Show Mouse Guides": "",
"Show Color Indices": "show_color_indices",
"Display Layer Effects": &"display_layer_effects", "Display Layer Effects": &"display_layer_effects",
"Snap To": "", "Snap To": "",
} }
@ -262,6 +262,9 @@ func _setup_view_menu() -> void:
var draw_pixel_grid: bool = Global.config_cache.get_value( var draw_pixel_grid: bool = Global.config_cache.get_value(
"view_menu", "draw_pixel_grid", Global.draw_pixel_grid "view_menu", "draw_pixel_grid", Global.draw_pixel_grid
) )
var show_pixel_indices: bool = Global.config_cache.get_value(
"view_menu", "show_pixel_indices", Global.show_pixel_indices
)
var show_rulers: bool = Global.config_cache.get_value( var show_rulers: bool = Global.config_cache.get_value(
"view_menu", "show_rulers", Global.show_rulers "view_menu", "show_rulers", Global.show_rulers
) )
@ -271,9 +274,6 @@ func _setup_view_menu() -> void:
var show_mouse_guides: bool = Global.config_cache.get_value( var show_mouse_guides: bool = Global.config_cache.get_value(
"view_menu", "show_mouse_guides", Global.show_mouse_guides "view_menu", "show_mouse_guides", Global.show_mouse_guides
) )
var show_color_indices: bool = Global.config_cache.get_value(
"view_menu", "show_color_indices", Global.show_color_indices
)
var display_layer_effects: bool = Global.config_cache.get_value( var display_layer_effects: bool = Global.config_cache.get_value(
"view_menu", "display_layer_effects", Global.display_layer_effects "view_menu", "display_layer_effects", Global.display_layer_effects
) )
@ -299,8 +299,8 @@ func _setup_view_menu() -> void:
_toggle_show_guides() _toggle_show_guides()
if show_mouse_guides != Global.show_mouse_guides: if show_mouse_guides != Global.show_mouse_guides:
_toggle_show_mouse_guides() _toggle_show_mouse_guides()
if show_color_indices != Global.show_color_indices: if show_pixel_indices != Global.show_pixel_indices:
_toggle_show_color_indices() _toggle_show_pixel_indices()
if display_layer_effects != Global.display_layer_effects: if display_layer_effects != Global.display_layer_effects:
Global.display_layer_effects = display_layer_effects Global.display_layer_effects = display_layer_effects
if snap_to_rectangular_grid_boundary != Global.snap_to_rectangular_grid_boundary: if snap_to_rectangular_grid_boundary != Global.snap_to_rectangular_grid_boundary:
@ -672,8 +672,8 @@ func view_menu_id_pressed(id: int) -> void:
_toggle_show_guides() _toggle_show_guides()
Global.ViewMenu.SHOW_MOUSE_GUIDES: Global.ViewMenu.SHOW_MOUSE_GUIDES:
_toggle_show_mouse_guides() _toggle_show_mouse_guides()
Global.ViewMenu.SHOW_COLOR_INDICES: Global.ViewMenu.SHOW_PIXEL_INDICES:
_toggle_show_color_indices() _toggle_show_pixel_indices()
Global.ViewMenu.DISPLAY_LAYER_EFFECTS: Global.ViewMenu.DISPLAY_LAYER_EFFECTS:
Global.display_layer_effects = not Global.display_layer_effects Global.display_layer_effects = not Global.display_layer_effects
_: _:
@ -828,6 +828,11 @@ func _toggle_show_pixel_grid() -> void:
view_menu.set_item_checked(Global.ViewMenu.SHOW_PIXEL_GRID, Global.draw_pixel_grid) view_menu.set_item_checked(Global.ViewMenu.SHOW_PIXEL_GRID, Global.draw_pixel_grid)
func _toggle_show_pixel_indices() -> void:
Global.show_pixel_indices = !Global.show_pixel_indices
view_menu.set_item_checked(Global.ViewMenu.SHOW_PIXEL_INDICES, Global.show_pixel_indices)
func _toggle_show_rulers() -> void: func _toggle_show_rulers() -> void:
Global.show_rulers = !Global.show_rulers Global.show_rulers = !Global.show_rulers
view_menu.set_item_checked(Global.ViewMenu.SHOW_RULERS, Global.show_rulers) view_menu.set_item_checked(Global.ViewMenu.SHOW_RULERS, Global.show_rulers)
@ -859,11 +864,6 @@ func _toggle_show_mouse_guides() -> void:
Global.canvas.mouse_guide_container.get_child(1).queue_redraw() Global.canvas.mouse_guide_container.get_child(1).queue_redraw()
func _toggle_show_color_indices() -> void:
Global.show_color_indices = !Global.show_color_indices
view_menu.set_item_checked(Global.ViewMenu.SHOW_COLOR_INDICES, Global.show_color_indices)
func _toggle_zen_mode() -> void: func _toggle_zen_mode() -> void:
for i in ui_elements.size(): for i in ui_elements.size():
if ui_elements[i].name == "Main Canvas": if ui_elements[i].name == "Main Canvas":