mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-02-12 16:53:07 +00:00
add a way to see indices
This commit is contained in:
parent
6224d06428
commit
53a86127a0
|
@ -921,6 +921,10 @@ 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)
|
||||
]
|
||||
}
|
||||
show_color_indices={
|
||||
"deadzone": 0.5,
|
||||
"events": []
|
||||
}
|
||||
|
||||
[input_devices]
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ enum ViewMenu {
|
|||
SHOW_RULERS,
|
||||
SHOW_GUIDES,
|
||||
SHOW_MOUSE_GUIDES,
|
||||
SHOW_COLOR_INDICES,
|
||||
DISPLAY_LAYER_EFFECTS,
|
||||
SNAP_TO,
|
||||
}
|
||||
|
@ -555,6 +556,12 @@ var show_rulers := true:
|
|||
var show_guides := true
|
||||
## If [code]true[/code], the mouse guides are visible.
|
||||
var show_mouse_guides := false
|
||||
## If [code]true[/code], the indices of color are shown.
|
||||
var show_color_indices := false:
|
||||
set(value):
|
||||
show_color_indices = value
|
||||
if is_instance_valid(canvas.color_index):
|
||||
canvas.color_index.enabled = value
|
||||
var display_layer_effects := true:
|
||||
set(value):
|
||||
if value == display_layer_effects:
|
||||
|
@ -749,6 +756,7 @@ func _ready() -> void:
|
|||
Global.use_native_file_dialogs = true
|
||||
await get_tree().process_frame
|
||||
project_switched.emit()
|
||||
canvas.color_index.enabled = show_color_indices # Initialize color index preview
|
||||
|
||||
|
||||
func update_grids(grids_data: Dictionary):
|
||||
|
|
|
@ -34,6 +34,7 @@ var color_mode: int = Image.FORMAT_RGBA8:
|
|||
image.resize_indices()
|
||||
image.select_palette("", false)
|
||||
image.convert_rgb_to_indexed()
|
||||
Global.canvas.color_index.queue_redraw()
|
||||
var fill_color := Color(0)
|
||||
var has_changed := false:
|
||||
set(value):
|
||||
|
|
|
@ -604,6 +604,7 @@ func _exit_tree() -> void:
|
|||
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_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(
|
||||
"view_menu", "display_layer_effects", Global.display_layer_effects
|
||||
)
|
||||
|
|
|
@ -15,6 +15,7 @@ var layer_metadata_texture := ImageTexture.new()
|
|||
@onready var currently_visible_frame := $CurrentlyVisibleFrame as SubViewport
|
||||
@onready var current_frame_drawer := $CurrentlyVisibleFrame/CurrentFrameDrawer as Node2D
|
||||
@onready var tile_mode := $TileMode as Node2D
|
||||
@onready var color_index := $ColorIndex as Node2D
|
||||
@onready var pixel_grid := $PixelGrid as Node2D
|
||||
@onready var grid := $Grid as Node2D
|
||||
@onready var selection := $Selection as SelectionNode
|
||||
|
@ -67,6 +68,7 @@ func _draw() -> void:
|
|||
current_frame_drawer.queue_redraw()
|
||||
tile_mode.queue_redraw()
|
||||
draw_set_transform(position, rotation, scale)
|
||||
color_index.queue_redraw()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=22 format=3 uid="uid://ba24iuv55m4l3"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://ba24iuv55m4l3"]
|
||||
|
||||
[ext_resource type="Script" path="res://src/UI/Canvas/Canvas.gd" id="1"]
|
||||
[ext_resource type="Shader" path="res://src/Shaders/BlendLayers.gdshader" id="1_253dh"]
|
||||
|
@ -17,6 +17,7 @@
|
|||
[ext_resource type="Script" path="res://src/UI/Canvas/Measurements.gd" id="16_nxilb"]
|
||||
[ext_resource type="Shader" path="res://src/Shaders/AutoInvertColors.gdshader" id="17_lowhf"]
|
||||
[ext_resource type="Script" path="res://src/UI/Canvas/ReferenceImages.gd" id="17_qfjb4"]
|
||||
[ext_resource type="Script" path="res://src/UI/Canvas/color_index.gd" id="18_o3xx2"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_6b0ox"]
|
||||
shader = ExtResource("1_253dh")
|
||||
|
@ -26,6 +27,11 @@ shader_parameter/origin_y_positive = true
|
|||
[sub_resource type="CanvasItemMaterial" id="1"]
|
||||
blend_mode = 4
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ascg6"]
|
||||
shader = ExtResource("17_lowhf")
|
||||
shader_parameter/width = 0.05
|
||||
shader_parameter/hollow_shapes = false
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="2"]
|
||||
shader = ExtResource("9")
|
||||
shader_parameter/width = 0.05
|
||||
|
@ -59,6 +65,10 @@ show_behind_parent = true
|
|||
material = SubResource("1")
|
||||
script = ExtResource("4")
|
||||
|
||||
[node name="ColorIndex" type="Node2D" parent="."]
|
||||
material = SubResource("ShaderMaterial_ascg6")
|
||||
script = ExtResource("18_o3xx2")
|
||||
|
||||
[node name="PixelGrid" type="Node2D" parent="."]
|
||||
script = ExtResource("6")
|
||||
|
||||
|
|
37
src/UI/Canvas/color_index.gd
Normal file
37
src/UI/Canvas/color_index.gd
Normal file
|
@ -0,0 +1,37 @@
|
|||
extends Node2D
|
||||
|
||||
const FONT_SIZE = 16
|
||||
|
||||
var users := 1
|
||||
var enabled: bool = false:
|
||||
set(value):
|
||||
enabled = value
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func _draw() -> void:
|
||||
if not enabled:
|
||||
return
|
||||
var project = ExtensionsApi.project.current_project
|
||||
var size: Vector2i = project.size
|
||||
var cel: BaseCel = project.frames[project.current_frame].cels[project.current_layer]
|
||||
if not cel is PixelCel:
|
||||
return
|
||||
var index_image: Image = cel.image.indices_image
|
||||
if index_image.get_size() != size:
|
||||
return
|
||||
|
||||
var font: Font = ExtensionsApi.theme.get_theme().default_font
|
||||
draw_set_transform(position, rotation, Vector2(0.05, 0.05))
|
||||
for x in range(size.x):
|
||||
for y in range(size.y):
|
||||
var index := index_image.get_pixel(x, y).r8
|
||||
draw_string(
|
||||
font,
|
||||
Vector2(x, y) * 20 + Vector2.DOWN * 16,
|
||||
str(index),
|
||||
HORIZONTAL_ALIGNMENT_LEFT,
|
||||
-1,
|
||||
FONT_SIZE if (index < 100) else int(FONT_SIZE / 1.5)
|
||||
)
|
||||
draw_set_transform(position, rotation, scale)
|
|
@ -235,6 +235,7 @@ func _setup_view_menu() -> void:
|
|||
"Show Rulers": "show_rulers",
|
||||
"Show Guides": "show_guides",
|
||||
"Show Mouse Guides": "",
|
||||
"Show Color Indices": "show_color_indices",
|
||||
"Display Layer Effects": &"display_layer_effects",
|
||||
"Snap To": "",
|
||||
}
|
||||
|
@ -270,6 +271,9 @@ func _setup_view_menu() -> void:
|
|||
var show_mouse_guides: bool = Global.config_cache.get_value(
|
||||
"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(
|
||||
"view_menu", "display_layer_effects", Global.display_layer_effects
|
||||
)
|
||||
|
@ -295,6 +299,8 @@ func _setup_view_menu() -> void:
|
|||
_toggle_show_guides()
|
||||
if show_mouse_guides != Global.show_mouse_guides:
|
||||
_toggle_show_mouse_guides()
|
||||
if show_color_indices != Global.show_color_indices:
|
||||
_toggle_show_color_indices()
|
||||
if display_layer_effects != Global.display_layer_effects:
|
||||
Global.display_layer_effects = display_layer_effects
|
||||
if snap_to_rectangular_grid_boundary != Global.snap_to_rectangular_grid_boundary:
|
||||
|
@ -666,6 +672,8 @@ func view_menu_id_pressed(id: int) -> void:
|
|||
_toggle_show_guides()
|
||||
Global.ViewMenu.SHOW_MOUSE_GUIDES:
|
||||
_toggle_show_mouse_guides()
|
||||
Global.ViewMenu.SHOW_COLOR_INDICES:
|
||||
_toggle_show_color_indices()
|
||||
Global.ViewMenu.DISPLAY_LAYER_EFFECTS:
|
||||
Global.display_layer_effects = not Global.display_layer_effects
|
||||
_:
|
||||
|
@ -851,6 +859,11 @@ func _toggle_show_mouse_guides() -> void:
|
|||
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:
|
||||
for i in ui_elements.size():
|
||||
if ui_elements[i].name == "Main Canvas":
|
||||
|
|
Loading…
Reference in a new issue