1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-02-12 16:53:07 +00:00

Compare commits

...

5 commits

Author SHA1 Message Date
Variable cf32c8812a hide 0 index 2024-11-29 20:31:30 +05:00
Variable ceeab25c87
Merge branch 'Orama-Interactive:master' into indicex-display 2024-11-29 16:54:13 +05:00
Variable 7f4c7a6bf1
Grid patch (#1142)
* fix second grid not *shown* removed when first grid has default values.

* Make next added grid twice the previous size, and with a different color

* Formatting
2024-11-28 22:02:13 +02:00
HuanWuCode 41ea287df4
Update Import.gd (#1121) 2024-11-27 17:01:00 +02:00
Emmanouil Papadeas a3e372c5d8 [skip ci] Update CHANGELOG.md 2024-11-26 14:01:45 +02:00
5 changed files with 88 additions and 18 deletions

View file

@ -4,6 +4,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). All the dates are in YYYY-MM-DD format. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). All the dates are in YYYY-MM-DD format.
<br><br> <br><br>
## [v1.1] - Unreleased
This update has been brought to you by the contributions of:
Fayez Akhtar ([@Variable-ind](https://github.com/Variable-ind))
Built using Godot 4.3
### Added
- Indexed mode has finally been implemented! [#1136](https://github.com/Orama-Interactive/Pixelorama/pull/1136)
- Added a new text tool. Destructive only for now, meaning that once the text is confirmed, it cannot be changed later. [#1134](https://github.com/Orama-Interactive/Pixelorama/pull/1134)
- Implemented support for multiple grids. [#1122](https://github.com/Orama-Interactive/Pixelorama/pull/1122)
### Changed
- System font names are now sorted by alphabetical order.
### Fixed
- Fixed crash when Pixelorama starts without a palette.
- Undo/redo now works again when the cursor is hovering over the timeline.
- Palette swatches now get deleted when the user removes all palettes
- Fixed the Palettize effect and palette exporting to images storing slightly wrong color values. [77f6bcf](https://github.com/Orama-Interactive/Pixelorama/commit/77f6bcf07bd80bc042e478bb883d05900cebe436)
- Fixed some issues with the Palettize effect where the output would be different if the palette size changed and empty swatches were added, even if the colors themselves stayed the same. Initially fixed by [bd7d3b1](https://github.com/Orama-Interactive/Pixelorama/commit/bd7d3b19cc98804e9b99754153c4d553d2048ee3), but [1dcb696](https://github.com/Orama-Interactive/Pixelorama/commit/1dcb696c35121f8208bde699f87bb75deff99d13) is the proper fix.
- Fixed recorder label not updating when project is changed. [#1139](https://github.com/Orama-Interactive/Pixelorama/pull/1139)
## [v1.0.5] - 2024-11-18 ## [v1.0.5] - 2024-11-18
This update has been brought to you by the contributions of: This update has been brought to you by the contributions of:
Fayez Akhtar ([@Variable-ind](https://github.com/Variable-ind)) Fayez Akhtar ([@Variable-ind](https://github.com/Variable-ind))

View file

@ -760,7 +760,11 @@ func _ready() -> void:
func update_grids(grids_data: Dictionary): func update_grids(grids_data: Dictionary):
# Remove old grids
grids.clear() grids.clear()
if is_instance_valid(Global.canvas.grid):
Global.canvas.grid.queue_redraw()
# ADD new ones
for grid_idx in grids_data.size(): for grid_idx in grids_data.size():
Grid.new(grids_data[grid_idx]) # gets auto added to grids array Grid.new(grids_data[grid_idx]) # gets auto added to grids array

View file

@ -90,9 +90,9 @@ func get_brush_files_from_directory(directory: String): # -> Array
func add_randomised_brush(fpaths: Array, tooltip_name: String) -> void: func add_randomised_brush(fpaths: Array, tooltip_name: String) -> void:
# Attempt to load the images from the file paths. # Attempt to load the images from the file paths.
var loaded_images: Array = [] var loaded_images: Array = []
for filen in fpaths: for file in fpaths:
var image := Image.new() var image := Image.new()
var err := image.load(filen) var err := image.load(file)
if err == OK: if err == OK:
image.convert(Image.FORMAT_RGBA8) image.convert(Image.FORMAT_RGBA8)
loaded_images.append(image) loaded_images.append(image)

View file

@ -1,5 +1,19 @@
extends GridContainer extends GridContainer
# We should use pre defined initial grid colors instead of random colors
const INITIAL_GRID_COLORS := [
Color.BLACK,
Color.WHITE,
Color.YELLOW,
Color.GREEN,
Color.BLUE,
Color.GRAY,
Color.ORANGE,
Color.PINK,
Color.SIENNA,
Color.CORAL,
]
var grid_preferences: Array[GridPreference] = [ 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("grid_size", "GridSizeValue", "value", Vector2i(2, 2)),
@ -109,21 +123,42 @@ func _on_grid_pref_value_changed(value, pref: GridPreference, button: RestoreDef
func _on_grids_count_value_changed(value: float) -> void: func _on_grids_count_value_changed(value: float) -> void:
var grid_idx = int(value - 1) var new_grids: Dictionary = Global.config_cache.get_value(
var grids: Dictionary = Global.config_cache.get_value(
"preferences", "grids", {0: create_default_properties()} "preferences", "grids", {0: create_default_properties()}
) )
if grid_idx >= grids_select_container.get_child_count(): var last_grid_idx = int(value - 1)
for key in range(grids_select_container.get_child_count(), grid_idx + 1): if last_grid_idx >= grids_select_container.get_child_count():
if not grids.has(key): # Add missing grids
grids[key] = create_default_properties() for key in range(grids_select_container.get_child_count(), value):
if not new_grids.has(key):
var new_grid := create_default_properties()
if new_grids.has(key - 1): # Failsafe
var last_grid = new_grids[key - 1]
# This small bit of code is there to make ui look a little neater
# Reasons:
# - Usually user intends to make the next grid twice the size.
# - Having all grids being same size initially may cause confusion for some
# users when they try to change color of a middle grid not seeing it's changing
# (due to being covered by grids above it).
if (
new_grid.has("grid_size")
and new_grid.has("isometric_grid_size")
and new_grid.has("grid_color")
):
new_grid["grid_size"] = last_grid["grid_size"] * 2
new_grid["isometric_grid_size"] = last_grid["isometric_grid_size"] * 2
if key < INITIAL_GRID_COLORS.size():
new_grid["grid_color"] = INITIAL_GRID_COLORS[key]
new_grids[key] = new_grid
add_remove_select_button(key) add_remove_select_button(key)
else: else:
for key: int in range(grid_idx + 1, grids.size()): # Remove extra grids
grids.erase(key) for key: int in range(value, new_grids.size()):
new_grids.erase(key)
add_remove_select_button(key, true) add_remove_select_button(key, true)
Global.update_grids(grids) grid_selected = min(grid_selected, last_grid_idx)
Global.config_cache.set_value("preferences", "grids", grids) Global.update_grids(new_grids)
Global.config_cache.set_value("preferences", "grids", new_grids)
func create_default_properties() -> Dictionary: func create_default_properties() -> Dictionary:
@ -152,7 +187,6 @@ func add_remove_select_button(grid_idx: int, remove := false):
else: else:
if grid_idx < grids_select_container.get_child_count(): if grid_idx < grids_select_container.get_child_count():
grids_select_container.get_child(grid_idx).queue_free() grids_select_container.get_child(grid_idx).queue_free()
grid_selected = min(grid_selected, grid_idx - 1)
func update_pref_ui(grid_data: Dictionary): func update_pref_ui(grid_data: Dictionary):
@ -161,3 +195,6 @@ func update_pref_ui(grid_data: Dictionary):
if grid_data.has(key): if grid_data.has(key):
var node := get_node(pref.node_path) var node := get_node(pref.node_path)
node.set(pref.value_type, grid_data[key]) node.set(pref.value_type, grid_data[key])
if pref.value_type == "color":
# the signal doesn't seem to be emitted automatically
node.color_changed.emit(grid_data[key])

View file

@ -23,19 +23,26 @@ func _draw() -> void:
if zoom_percentage < Global.pixel_grid_show_at_zoom: if zoom_percentage < Global.pixel_grid_show_at_zoom:
return return
var project = ExtensionsApi.project.current_project var project = ExtensionsApi.project.current_project
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 or not cel.image.is_indexed: if index_image.get_size() != project.size or not cel.image.is_indexed:
return return
var used_rect: Rect2i = cel.image.get_used_rect()
if used_rect.size != Vector2i.ZERO:
# use smaller image for optimization
index_image = index_image.get_region(used_rect)
var font: Font = ExtensionsApi.theme.get_theme().default_font var font: Font = ExtensionsApi.theme.get_theme().default_font
draw_set_transform(position, rotation, Vector2(0.05, 0.05)) var offset = position + Vector2(used_rect.position)
for x in range(size.x): draw_set_transform(offset, rotation, Vector2(0.05, 0.05))
for y in range(size.y): for x in range(index_image.get_size().x):
for y in range(index_image.get_size().y):
var index := index_image.get_pixel(x, y).r8 var index := index_image.get_pixel(x, y).r8
if index == 0:
continue
draw_string( draw_string(
font, font,
Vector2(x, y) * 20 + Vector2.DOWN * 16, Vector2(x, y) * 20 + Vector2.DOWN * 16,