1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-13 17:23:08 +00:00

Compare commits

..

2 commits

Author SHA1 Message Date
Emmanouil Papadeas abedba6f64 Add string to Translations.pot 2024-10-16 01:20:22 +03:00
Emmanouil Papadeas b754fa1105 Move the option to the preferences 2024-10-15 23:47:47 +03:00
14 changed files with 97 additions and 171 deletions

View file

@ -894,6 +894,10 @@ msgstr ""
msgid "Background color:" msgid "Background color:"
msgstr "" msgstr ""
#. Found in the preferences, under the Tools category.
msgid "Share options between the left and the right tools"
msgstr ""
msgid "Left tool color:" msgid "Left tool color:"
msgstr "" msgstr ""

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 B

View file

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ce4xwgq2ewig8"
path="res://.godot/imported/share_config_off.png-c0be93b81740c9bf1e8080491cc2ab97.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/misc/share_config_off.png"
dest_files=["res://.godot/imported/share_config_off.png-c0be93b81740c9bf1e8080491cc2ab97.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

View file

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ctqpf1rtxr8p2"
path="res://.godot/imported/share_config_on.png-4896bc6065b2e26d04ed13bcdb11770c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/graphics/misc/share_config_on.png"
dest_files=["res://.godot/imported/share_config_on.png-4896bc6065b2e26d04ed13bcdb11770c.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View file

@ -273,6 +273,10 @@ var tool_button_size := ButtonSize.SMALL:
return return
tool_button_size = value tool_button_size = value
Tools.set_button_size(tool_button_size) Tools.set_button_size(tool_button_size)
var share_options_between_tools := false:
set(value):
share_options_between_tools = value
Tools.attempt_config_share(MOUSE_BUTTON_LEFT)
## Found in Preferences. The left tool color. ## Found in Preferences. The left tool color.
var left_tool_color := Color("0086cf"): var left_tool_color := Color("0086cf"):
set(value): set(value):

View file

@ -2,7 +2,6 @@
extends Node extends Node
signal color_changed(color: Color, button: int) signal color_changed(color: Color, button: int)
@warning_ignore("unused_signal")
signal config_changed(slot_idx: int, config: Dictionary) signal config_changed(slot_idx: int, config: Dictionary)
@warning_ignore("unused_signal") @warning_ignore("unused_signal")
signal flip_rotated(flip_x, flip_y, rotate_90, rotate_180, rotate_270) signal flip_rotated(flip_x, flip_y, rotate_90, rotate_180, rotate_270)
@ -15,10 +14,6 @@ var horizontal_mirror := false
var vertical_mirror := false var vertical_mirror := false
var pixel_perfect := false var pixel_perfect := false
var alpha_locked := false var alpha_locked := false
var share_config := false:
set(value):
share_config = value
attempt_config_share(MOUSE_BUTTON_LEFT)
# Dynamics # Dynamics
var stabilizer_enabled := false var stabilizer_enabled := false
@ -383,27 +378,27 @@ func _ready() -> void:
## Syncs the other tool using the config of tool located at [param from_idx].[br] ## Syncs the other tool using the config of tool located at [param from_idx].[br]
## NOTE: For optimization, if there is already a ready made config available, then we will use that ## NOTE: For optimization, if there is already a ready made config available, then we will use that
## instead of re-calculating the config, else we have no choice but to re-generate it ## instead of re-calculating the config, else we have no choice but to re-generate it
func attempt_config_share(from_idx: int, config: Dictionary = {}): func attempt_config_share(from_idx: int, config: Dictionary = {}) -> void:
if share_config: if not Global.share_options_between_tools:
if config.is_empty() and _slots[from_idx]: return
var from_slot: Slot = _slots.get(from_idx, null) if _slots.is_empty():
if from_slot: return
var from_tool = from_slot.tool_node if config.is_empty() and _slots[from_idx]:
if from_tool.has_method("get_config"): var from_slot: Slot = _slots.get(from_idx, null)
config = from_tool.get_config() if from_slot:
var target_slot: Slot = _slots.get(MOUSE_BUTTON_LEFT, null) var from_tool = from_slot.tool_node
if from_idx == MOUSE_BUTTON_LEFT: if from_tool.has_method("get_config"):
target_slot = _slots.get(MOUSE_BUTTON_RIGHT, null) config = from_tool.get_config()
if target_slot: # FailSafe Check var target_slot: Slot = _slots.get(MOUSE_BUTTON_LEFT, null)
# Using call() to avoid errors in case a tool doesn't contain the method if from_idx == MOUSE_BUTTON_LEFT:
if ( target_slot = _slots.get(MOUSE_BUTTON_RIGHT, null)
target_slot.tool_node.has_method("set_config") if is_instance_valid(target_slot):
and target_slot.tool_node.has_method("update_config") if (
): target_slot.tool_node.has_method("set_config")
target_slot.tool_node.set("is_syncing", true) and target_slot.tool_node.has_method("update_config")
target_slot.tool_node.set_config(config) ):
target_slot.tool_node.update_config() target_slot.tool_node.set_config(config)
target_slot.tool_node.set("is_syncing", false) target_slot.tool_node.update_config()
func reset_options() -> void: func reset_options() -> void:
@ -434,9 +429,9 @@ func remove_tool(t: Tool) -> void:
func set_tool(tool_name: String, button: int) -> void: func set_tool(tool_name: String, button: int) -> void:
## To prevent any unintentional syncing, we will temporarily disconnect the signal # To prevent any unintentional syncing, we will temporarily disconnect the signal
if Tools.config_changed.is_connected(attempt_config_share): if config_changed.is_connected(attempt_config_share):
Tools.config_changed.disconnect(attempt_config_share) config_changed.disconnect(attempt_config_share)
var slot: Slot = _slots[button] var slot: Slot = _slots[button]
var panel: Node = _panels[button] var panel: Node = _panels[button]
var node: Node = tools[tool_name].instantiate_scene() var node: Node = tools[tool_name].instantiate_scene()
@ -461,8 +456,8 @@ func set_tool(tool_name: String, button: int) -> void:
# Wait for config to get loaded, then re-connect and sync # Wait for config to get loaded, then re-connect and sync
await get_tree().process_frame await get_tree().process_frame
if not Tools.config_changed.is_connected(attempt_config_share): if not config_changed.is_connected(attempt_config_share):
Tools.config_changed.connect(attempt_config_share) config_changed.connect(attempt_config_share)
attempt_config_share(config_slot) # Sync it with the other tool attempt_config_share(config_slot) # Sync it with the other tool

View file

@ -36,10 +36,16 @@ var preferences: Array[Preference] = [
"custom_icon_color", "Interface/ButtonOptions/IconColorButton", "color", Color.GRAY "custom_icon_color", "Interface/ButtonOptions/IconColorButton", "color", Color.GRAY
), ),
Preference.new( Preference.new(
"left_tool_color", "Interface/ButtonOptions/LeftToolColorButton", "color", Color("0086cf") "share_options_between_tools",
"Tools/ToolOptions/ShareOptionsCheckBox",
"button_pressed",
false
), ),
Preference.new( Preference.new(
"right_tool_color", "Interface/ButtonOptions/RightToolColorButton", "color", Color("fd6d14") "left_tool_color", "Tools/ToolOptions/LeftToolColorButton", "color", Color("0086cf")
),
Preference.new(
"right_tool_color", "Tools/ToolOptions/RightToolColorButton", "color", Color("fd6d14")
), ),
Preference.new( Preference.new(
"tool_button_size", "tool_button_size",

View file

@ -324,26 +324,6 @@ layout_mode = 2
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
color = Color(0.75, 0.75, 0.75, 1) color = Color(0.75, 0.75, 0.75, 1)
[node name="Label4" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/ButtonOptions"]
layout_mode = 2
text = "Left tool color:"
[node name="LeftToolColorButton" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/ButtonOptions"]
custom_minimum_size = Vector2(64, 20)
layout_mode = 2
mouse_default_cursor_shape = 2
color = Color(0, 0.52549, 0.811765, 1)
[node name="Label5" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/ButtonOptions"]
layout_mode = 2
text = "Right tool color:"
[node name="RightToolColorButton" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Interface/ButtonOptions"]
custom_minimum_size = Vector2(64, 20)
layout_mode = 2
mouse_default_cursor_shape = 2
color = Color(0.992157, 0.427451, 0.0784314, 1)
[node name="Canvas" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"] [node name="Canvas" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"]
visible = false visible = false
layout_mode = 2 layout_mode = 2
@ -875,6 +855,49 @@ layout_mode = 2
mouse_default_cursor_shape = 2 mouse_default_cursor_shape = 2
color = Color(0, 0, 1, 1) color = Color(0, 0, 1, 1)
[node name="Tools" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"]
visible = false
layout_mode = 2
[node name="ToolOptions" type="GridContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools"]
layout_mode = 2
columns = 3
[node name="ShareOptionsLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools/ToolOptions"]
layout_mode = 2
size_flags_horizontal = 3
text = "Share options between the left and the right tools"
[node name="ShareOptionsCheckBox" type="CheckBox" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools/ToolOptions"]
layout_mode = 2
size_flags_horizontal = 3
mouse_default_cursor_shape = 2
text = "On"
[node name="LeftToolColorLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools/ToolOptions"]
layout_mode = 2
size_flags_horizontal = 3
text = "Left tool color:"
[node name="LeftToolColorButton" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools/ToolOptions"]
custom_minimum_size = Vector2(64, 20)
layout_mode = 2
size_flags_horizontal = 3
mouse_default_cursor_shape = 2
color = Color(0, 0.52549, 0.811765, 1)
[node name="RightToolColorLabel" type="Label" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools/ToolOptions"]
layout_mode = 2
size_flags_horizontal = 3
text = "Right tool color:"
[node name="RightToolColorButton" type="ColorPickerButton" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide/Tools/ToolOptions"]
custom_minimum_size = Vector2(64, 20)
layout_mode = 2
size_flags_horizontal = 3
mouse_default_cursor_shape = 2
color = Color(0.992157, 0.427451, 0.0784314, 1)
[node name="Selection" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"] [node name="Selection" type="VBoxContainer" parent="HSplitContainer/VBoxContainer/ScrollContainer/RightSide"]
visible = false visible = false
layout_mode = 2 layout_mode = 2

View file

@ -71,14 +71,13 @@ func _on_Brush_selected(brush: Brushes.Brush) -> void:
func _on_BrushSize_value_changed(value: float) -> void: func _on_BrushSize_value_changed(value: float) -> void:
if _brush_size != int(value): _brush_size = int(value)
_brush_size = int(value) _brush_size_dynamics = _brush_size
_brush_size_dynamics = _brush_size if Tools.dynamics_size != Tools.Dynamics.NONE:
if Tools.dynamics_size != Tools.Dynamics.NONE: _brush_size_dynamics = Tools.brush_size_min
_brush_size_dynamics = Tools.brush_size_min _cache_limit = (_brush_size * _brush_size) * 3 # This equation seems the best match
_cache_limit = (_brush_size * _brush_size) * 3 # This equation seems the best match update_config()
update_config() save_config()
save_config()
func _reset_dynamics() -> void: func _reset_dynamics() -> void:

View file

@ -1,10 +1,7 @@
class_name BaseTool class_name BaseTool
extends VBoxContainer extends VBoxContainer
signal config_changed(config: Dictionary)
var is_moving := false var is_moving := false
var is_syncing := false
var kname: String var kname: String
var tool_slot: Tools.Slot = null var tool_slot: Tools.Slot = null
var cursor_text := "" var cursor_text := ""
@ -37,8 +34,7 @@ func _ready() -> void:
func save_config() -> void: func save_config() -> void:
var config := get_config() var config := get_config()
Global.config_cache.set_value(tool_slot.kname, kname, config) Global.config_cache.set_value(tool_slot.kname, kname, config)
if not is_syncing: # If the tool isn't buzy syncing with another tool Tools.config_changed.emit(tool_slot.button, config)
Tools.config_changed.emit(tool_slot.button, config)
func load_config() -> void: func load_config() -> void:

View file

@ -59,10 +59,10 @@ func _input(event: InputEvent) -> void:
if event.is_action_pressed("change_tool_mode"): if event.is_action_pressed("change_tool_mode"):
_prev_mode = overwrite_button.button_pressed _prev_mode = overwrite_button.button_pressed
if event.is_action("change_tool_mode"): if event.is_action("change_tool_mode"):
overwrite_button.button_pressed = !_prev_mode overwrite_button.set_pressed_no_signal(!_prev_mode)
_overwrite = overwrite_button.button_pressed _overwrite = overwrite_button.button_pressed
if event.is_action_released("change_tool_mode"): if event.is_action_released("change_tool_mode"):
overwrite_button.button_pressed = _prev_mode overwrite_button.set_pressed_no_signal(_prev_mode)
_overwrite = overwrite_button.button_pressed _overwrite = overwrite_button.button_pressed

View file

@ -6,7 +6,6 @@ extends PanelContainer
@onready var pixel_perfect: BaseButton = grid_container.get_node("PixelPerfect") @onready var pixel_perfect: BaseButton = grid_container.get_node("PixelPerfect")
@onready var alpha_lock: BaseButton = grid_container.get_node("AlphaLock") @onready var alpha_lock: BaseButton = grid_container.get_node("AlphaLock")
@onready var dynamics: Button = $"%Dynamics" @onready var dynamics: Button = $"%Dynamics"
@onready var share_config: BaseButton = grid_container.get_node("ShareConfig")
@onready var dynamics_panel: PopupPanel = $DynamicsPanel @onready var dynamics_panel: PopupPanel = $DynamicsPanel
@ -114,13 +113,3 @@ func _on_vertical_mirror_options_id_pressed(id: int) -> void:
project.y_symmetry_point = Global.camera.camera_screen_center.y * 2 project.y_symmetry_point = Global.camera.camera_screen_center.y * 2
project.x_symmetry_axis.points[0].y = project.y_symmetry_point / 2 + 0.5 project.x_symmetry_axis.points[0].y = project.y_symmetry_point / 2 + 0.5
project.x_symmetry_axis.points[1].y = project.y_symmetry_point / 2 + 0.5 project.x_symmetry_axis.points[1].y = project.y_symmetry_point / 2 + 0.5
func _on_share_config_toggled(toggled_on: bool) -> void:
Tools.share_config = toggled_on
Global.config_cache.set_value("tools", "share_config", toggled_on)
var texture_button: TextureRect = share_config.get_node("TextureRect")
var file_name := "share_config_on.png"
if not toggled_on:
file_name = "share_config_off.png"
Global.change_button_texturerect(texture_button, file_name)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=26 format=3 uid="uid://wo0hqxkst808"] [gd_scene load_steps=25 format=3 uid="uid://wo0hqxkst808"]
[ext_resource type="Texture2D" uid="uid://cjrokejjsp5dm" path="res://assets/graphics/misc/horizontal_mirror_off.png" id="1"] [ext_resource type="Texture2D" uid="uid://cjrokejjsp5dm" path="res://assets/graphics/misc/horizontal_mirror_off.png" id="1"]
[ext_resource type="Texture2D" uid="uid://hiduvaa73fr6" path="res://assets/graphics/misc/vertical_mirror_off.png" id="2"] [ext_resource type="Texture2D" uid="uid://hiduvaa73fr6" path="res://assets/graphics/misc/vertical_mirror_off.png" id="2"]
@ -11,7 +11,6 @@
[ext_resource type="Texture2D" uid="uid://di8au2u87jgv5" path="res://assets/graphics/misc/uncheck.png" id="7"] [ext_resource type="Texture2D" uid="uid://di8au2u87jgv5" path="res://assets/graphics/misc/uncheck.png" id="7"]
[ext_resource type="Script" path="res://src/UI/GlobalToolOptions/DynamicsPanel.gd" id="7_iqcw1"] [ext_resource type="Script" path="res://src/UI/GlobalToolOptions/DynamicsPanel.gd" id="7_iqcw1"]
[ext_resource type="PackedScene" uid="uid://bmsc0s03pwji4" path="res://src/UI/Nodes/MaxMinEdit.tscn" id="8"] [ext_resource type="PackedScene" uid="uid://bmsc0s03pwji4" path="res://src/UI/Nodes/MaxMinEdit.tscn" id="8"]
[ext_resource type="Texture2D" uid="uid://ce4xwgq2ewig8" path="res://assets/graphics/misc/share_config_off.png" id="8_7jpan"]
[sub_resource type="InputEventAction" id="InputEventAction_4k08w"] [sub_resource type="InputEventAction" id="InputEventAction_4k08w"]
action = &"horizontal_mirror" action = &"horizontal_mirror"
@ -72,7 +71,7 @@ size_flags_vertical = 3
[node name="GridContainer" type="GridContainer" parent="ScrollContainer/CenterContainer"] [node name="GridContainer" type="GridContainer" parent="ScrollContainer/CenterContainer"]
layout_mode = 2 layout_mode = 2
size_flags_vertical = 0 size_flags_vertical = 0
columns = 6 columns = 5
[node name="Horizontal" type="Button" parent="ScrollContainer/CenterContainer/GridContainer" groups=["UIButtons"]] [node name="Horizontal" type="Button" parent="ScrollContainer/CenterContainer/GridContainer" groups=["UIButtons"]]
custom_minimum_size = Vector2(44, 32) custom_minimum_size = Vector2(44, 32)
@ -238,26 +237,6 @@ offset_right = 11.0
offset_bottom = 10.0 offset_bottom = 10.0
texture = ExtResource("6") texture = ExtResource("6")
[node name="ShareConfig" type="Button" parent="ScrollContainer/CenterContainer/GridContainer"]
custom_minimum_size = Vector2(32, 32)
layout_mode = 2
tooltip_text = "Share config between tools."
mouse_default_cursor_shape = 2
toggle_mode = true
shortcut = SubResource("Shortcut_vcyug")
[node name="TextureRect" type="TextureRect" parent="ScrollContainer/CenterContainer/GridContainer/ShareConfig"]
layout_mode = 0
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -11.0
offset_top = -10.0
offset_right = 11.0
offset_bottom = 10.0
texture = ExtResource("8_7jpan")
[node name="DynamicsPanel" type="PopupPanel" parent="."] [node name="DynamicsPanel" type="PopupPanel" parent="."]
canvas_item_default_texture_filter = 0 canvas_item_default_texture_filter = 0
size = Vector2i(300, 334) size = Vector2i(300, 334)
@ -568,7 +547,6 @@ offset_bottom = 23.0
[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/PixelPerfect" to="." method="_on_PixelPerfect_toggled"] [connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/PixelPerfect" to="." method="_on_PixelPerfect_toggled"]
[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/AlphaLock" to="." method="_on_alpha_lock_toggled"] [connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/AlphaLock" to="." method="_on_alpha_lock_toggled"]
[connection signal="pressed" from="ScrollContainer/CenterContainer/GridContainer/Dynamics" to="." method="_on_Dynamics_pressed"] [connection signal="pressed" from="ScrollContainer/CenterContainer/GridContainer/Dynamics" to="." method="_on_Dynamics_pressed"]
[connection signal="toggled" from="ScrollContainer/CenterContainer/GridContainer/ShareConfig" to="." method="_on_share_config_toggled"]
[connection signal="toggled" from="DynamicsPanel/VBoxContainer/StabilizerContainer/EnableStabilizer" to="DynamicsPanel" method="_on_enable_stabilizer_toggled"] [connection signal="toggled" from="DynamicsPanel/VBoxContainer/StabilizerContainer/EnableStabilizer" to="DynamicsPanel" method="_on_enable_stabilizer_toggled"]
[connection signal="value_changed" from="DynamicsPanel/VBoxContainer/StabilizerContainer/StabilizerValue" to="DynamicsPanel" method="_on_stabilizer_value_value_changed"] [connection signal="value_changed" from="DynamicsPanel/VBoxContainer/StabilizerContainer/StabilizerValue" to="DynamicsPanel" method="_on_stabilizer_value_value_changed"]
[connection signal="value_changed" from="DynamicsPanel/VBoxContainer/LimitContainer/AlphaMin" to="DynamicsPanel" method="_on_alpha_min_value_changed"] [connection signal="value_changed" from="DynamicsPanel/VBoxContainer/LimitContainer/AlphaMin" to="DynamicsPanel" method="_on_alpha_min_value_changed"]