mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-18 17:19:50 +00:00
Update the ExtensionsAPI to handle fonts
This commit is contained in:
parent
91f0b26245
commit
fd714d04df
|
@ -24,7 +24,7 @@ boot_splash/use_filter=false
|
||||||
config/icon="res://assets/graphics/icons/icon.png"
|
config/icon="res://assets/graphics/icons/icon.png"
|
||||||
config/macos_native_icon="res://assets/graphics/icons/icon.icns"
|
config/macos_native_icon="res://assets/graphics/icons/icon.icns"
|
||||||
config/windows_native_icon="res://assets/graphics/icons/icon.ico"
|
config/windows_native_icon="res://assets/graphics/icons/icon.ico"
|
||||||
config/ExtensionsAPI_Version=4
|
config/ExtensionsAPI_Version=5
|
||||||
config/Pxo_Version=3
|
config/Pxo_Version=3
|
||||||
|
|
||||||
[audio]
|
[audio]
|
||||||
|
|
|
@ -409,6 +409,29 @@ class ThemeAPI:
|
||||||
Themes.remove_theme(theme)
|
Themes.remove_theme(theme)
|
||||||
ExtensionsApi.remove_action("ThemeAPI", "add_theme")
|
ExtensionsApi.remove_action("ThemeAPI", "add_theme")
|
||||||
|
|
||||||
|
## Adds a new font.
|
||||||
|
func add_font(font: Font) -> void:
|
||||||
|
Global.loaded_fonts.append(font)
|
||||||
|
Global.font_loaded.emit()
|
||||||
|
|
||||||
|
## Removes a loaded font.
|
||||||
|
## If that font is the current one of the interface, set it back to Roboto.
|
||||||
|
func remove_font(font: Font) -> void:
|
||||||
|
var font_index := Global.loaded_fonts.find(font)
|
||||||
|
if font_index == -1:
|
||||||
|
return
|
||||||
|
if Global.theme_font_index == font_index:
|
||||||
|
Global.theme_font_index = 1
|
||||||
|
Global.loaded_fonts.remove_at(font_index)
|
||||||
|
Global.font_loaded.emit()
|
||||||
|
|
||||||
|
## Sets a font as the current one for the interface. The font must have been
|
||||||
|
## added beforehand by [method add_font].
|
||||||
|
func set_font(font: Font) -> void:
|
||||||
|
var font_index := Global.loaded_fonts.find(font)
|
||||||
|
if font_index > -1:
|
||||||
|
Global.theme_font_index = font_index
|
||||||
|
|
||||||
|
|
||||||
## Gives ability to add/remove tools.
|
## Gives ability to add/remove tools.
|
||||||
class ToolAPI:
|
class ToolAPI:
|
||||||
|
|
|
@ -12,6 +12,7 @@ signal project_about_to_switch ## Emitted before a project is about to be switc
|
||||||
signal project_switched ## Emitted whenever you switch to some other project tab.
|
signal project_switched ## Emitted whenever you switch to some other project tab.
|
||||||
signal cel_switched ## Emitted whenever you select a different cel.
|
signal cel_switched ## Emitted whenever you select a different cel.
|
||||||
signal project_data_changed(project: Project) ## Emitted when project data is modified.
|
signal project_data_changed(project: Project) ## Emitted when project data is modified.
|
||||||
|
signal font_loaded ## Emitted when a new font has been loaded, or an old one gets unloaded.
|
||||||
|
|
||||||
enum LayerTypes { PIXEL, GROUP, THREE_D }
|
enum LayerTypes { PIXEL, GROUP, THREE_D }
|
||||||
enum GridTypes { CARTESIAN, ISOMETRIC, ALL }
|
enum GridTypes { CARTESIAN, ISOMETRIC, ALL }
|
||||||
|
|
|
@ -241,6 +241,7 @@ class Preference:
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
|
Global.font_loaded.connect(_add_fonts)
|
||||||
# Replace OK since preference changes are being applied immediately, not after OK confirmation
|
# Replace OK since preference changes are being applied immediately, not after OK confirmation
|
||||||
get_ok_button().text = "Close"
|
get_ok_button().text = "Close"
|
||||||
get_ok_button().size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
get_ok_button().size_flags_horizontal = Control.SIZE_EXPAND_FILL
|
||||||
|
@ -293,9 +294,7 @@ func _ready() -> void:
|
||||||
language.add_child(button)
|
language.add_child(button)
|
||||||
button.pressed.connect(_on_language_pressed.bind(button.get_index()))
|
button.pressed.connect(_on_language_pressed.bind(button.get_index()))
|
||||||
|
|
||||||
# Add fonts to the font option button
|
_add_fonts()
|
||||||
for font_name in Global.get_available_font_names():
|
|
||||||
%FontOptionButton.add_item(font_name)
|
|
||||||
|
|
||||||
for pref in preferences:
|
for pref in preferences:
|
||||||
if not right_side.has_node(pref.node_path):
|
if not right_side.has_node(pref.node_path):
|
||||||
|
@ -363,6 +362,14 @@ func _on_Preference_value_changed(value, pref: Preference, button: RestoreDefaul
|
||||||
disable_restore_default_button(button, disable)
|
disable_restore_default_button(button, disable)
|
||||||
|
|
||||||
|
|
||||||
|
## Add fonts to the font option button.
|
||||||
|
func _add_fonts() -> void:
|
||||||
|
%FontOptionButton.clear()
|
||||||
|
for font_name in Global.get_available_font_names():
|
||||||
|
%FontOptionButton.add_item(font_name)
|
||||||
|
%FontOptionButton.select(Global.theme_font_index)
|
||||||
|
|
||||||
|
|
||||||
func preference_update(require_restart := false) -> void:
|
func preference_update(require_restart := false) -> void:
|
||||||
if require_restart:
|
if require_restart:
|
||||||
must_restart.visible = true
|
must_restart.visible = true
|
||||||
|
|
Loading…
Reference in a new issue