mirror of
https://github.com/tonytins/CozyPixelStudio.git
synced 2025-06-25 21:14:42 -04:00
Ability to import an image file as a pattern
Also moved some pattern importing code from Import.gd to Global.create_pattern_button()
This commit is contained in:
parent
a8de56ed68
commit
8e2fe8dac3
4 changed files with 30 additions and 10 deletions
|
@ -611,6 +611,17 @@ func create_brush_button(brush_img : Image, brush_type := Brush_Types.CUSTOM, hi
|
|||
brush_container.add_child(brush_button)
|
||||
|
||||
|
||||
func create_pattern_button(image : Image, hint_tooltip := "") -> void:
|
||||
var pattern_button : BaseButton = load("res://src/UI/PatternButton.tscn").instance()
|
||||
pattern_button.image = image
|
||||
var pattern_tex := ImageTexture.new()
|
||||
pattern_tex.create_from_image(image, 0)
|
||||
pattern_button.get_child(0).texture = pattern_tex
|
||||
pattern_button.hint_tooltip = hint_tooltip
|
||||
pattern_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
patterns_popup.get_node("ScrollContainer/PatternContainer").add_child(pattern_button)
|
||||
|
||||
|
||||
func remove_brush_buttons() -> void:
|
||||
current_brush_types[0] = Brush_Types.PIXEL
|
||||
current_brush_types[1] = Brush_Types.PIXEL
|
||||
|
|
|
@ -236,15 +236,7 @@ func import_patterns(priority_ordered_search_path: Array) -> void:
|
|||
if err == OK:
|
||||
image.convert(Image.FORMAT_RGBA8)
|
||||
Global.patterns.append(image)
|
||||
|
||||
var pattern_button : BaseButton = load("res://src/UI/PatternButton.tscn").instance()
|
||||
pattern_button.image = image
|
||||
var pattern_tex := ImageTexture.new()
|
||||
pattern_tex.create_from_image(image, 0)
|
||||
pattern_button.get_child(0).texture = pattern_tex
|
||||
pattern_button.hint_tooltip = pattern
|
||||
pattern_button.mouse_default_cursor_shape = Control.CURSOR_POINTING_HAND
|
||||
Global.patterns_popup.get_node("ScrollContainer/PatternContainer").add_child(pattern_button)
|
||||
Global.create_pattern_button(image, pattern)
|
||||
|
||||
if Global.patterns.size() > 0:
|
||||
var image_size = Global.patterns[0].get_size()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue