Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions app_info.json

This file was deleted.

19 changes: 19 additions & 0 deletions app_info.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
project_founder_and_manager = "Anish Mishra"
authors = [
"Anish Mishra (syntaxerror247)"
]

donors = []
anonymous_donors = 0
golden_donors = []
anonymous_golden_donors = 0

diamond_donors = []
anonymous_diamond_donors = 0

past_donors = []
past_anonymous_donors = 0
past_golden_donors = []
past_anonymous_golden_donors = 0
past_diamond_donors = []
past_anonymous_diamond_donors = 0
4 changes: 2 additions & 2 deletions godot_only/scripts/tests.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ func _run() -> void:
for report_line in report:
print_rich(report_line)


func add_to_report(test_category: String, test: String, result: String,
expected: String) -> void:
report.append('%s: [b]"%s"[/b] returned [b]"%s"[/b], expected [b]"%s"[/b]' %\
[test_category, test, result, expected])


# This test is dependent on specifics of the Formatter and AttributePathdata classes.
# But its logic would likely not change enough in the future to make the tests obsolete.
# https://www.w3.org/TR/SVG11/paths.html#PathDataBNF
Expand Down Expand Up @@ -103,6 +103,6 @@ func transform_list_tests() -> void:
}

for test in tests:
var result := AttributeTransformList.new("transform")._format(test, spacious_formatter)
var result := AttributeTransformList.new("transform").format(test, spacious_formatter)
if result != tests[test]:
add_to_report("Transform list parser", test, result, tests[test])
2 changes: 1 addition & 1 deletion godot_only/scripts/update_translations.gd
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func populate_delimiters() -> void:
for method in ["translate"]:
for quote in ["'", '"', '"""']:
delimiters["Translator." + method + "(" + quote] = quote + ")"
for i in range(2, 8):
for i in range(2, 10):
delimiters["Translator." + method + "(\n" + "\t".repeat(i) + quote] = quote + ")"

var messages: Array[Message] = [Message.new("translation-credits", PackedStringArray())]
Expand Down
1 change: 0 additions & 1 deletion project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ HandlerGUI="*res://src/autoload/HandlerGUI.gd"

window/size/viewport_width=480
window/size/viewport_height=854
window/energy_saving/keep_screen_on=false
window/handheld/orientation=6
mouse_cursor/tooltip_position_offset=Vector2(0, 10)

Expand Down
17 changes: 4 additions & 13 deletions src/autoload/Configs.gd
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,10 @@ func post_load() -> void:
sync_canvas_color()
sync_locale()
sync_max_fps()
sync_keep_screen_on()
sync_theme()


func generate_highlighter() -> SVGHighlighter:
var new_highlighter := SVGHighlighter.new()
new_highlighter.symbol_color = Configs.savedata.highlighting_symbol_color
new_highlighter.element_color = Configs.savedata.highlighting_element_color
new_highlighter.attribute_color = Configs.savedata.highlighting_attribute_color
new_highlighter.string_color = Configs.savedata.highlighting_string_color
new_highlighter.comment_color = Configs.savedata.highlighting_comment_color
new_highlighter.text_color = Configs.savedata.highlighting_text_color
new_highlighter.cdata_color = Configs.savedata.highlighting_cdata_color
new_highlighter.error_color = Configs.savedata.highlighting_error_color
return new_highlighter


# Global effects from settings. Some of them should also be used on launch.

func sync_canvas_color() -> void:
Expand All @@ -130,6 +118,9 @@ func sync_vsync() -> void:
func sync_max_fps() -> void:
Engine.max_fps = savedata.max_fps

func sync_keep_screen_on() -> void:
DisplayServer.screen_set_keep_on(savedata.keep_screen_on)

func sync_theme() -> void:
ThemeUtils.generate_and_apply_theme()
theme_changed.emit()
8 changes: 3 additions & 5 deletions src/autoload/State.gd
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,9 @@ func get_selection_context(popup_method: Callable, context: Utils.LayoutPart) ->
btn_arr.append(ContextPopup.create_shortcut_button("duplicate"))

var xnode := root_element.get_xnode(selected_xids[0])
if selected_xids.size() == 1 and ((not xnode.is_element() and\
xnode.get_type() != BasicXNode.NodeType.UNKNOWN) or (xnode.is_element() and\
not xnode.possible_conversions.is_empty())):
btn_arr.append(ContextPopup.create_button(
Translator.translate("Convert To"),
if selected_xids.size() == 1 and (not xnode.is_element() or\
(xnode.is_element() and not xnode.possible_conversions.is_empty())):
btn_arr.append(ContextPopup.create_button(Translator.translate("Convert To"),
popup_convert_to_context.bind(popup_method), false,
load("res://assets/icons/Reload.svg")))

Expand Down
14 changes: 7 additions & 7 deletions src/config_classes/Formatter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ static func get_enum_value_text_map(property: String) -> Dictionary:

func get_setting_default(setting: String) -> Variant:
match setting:
"xml_keep_unrecognized": return false
"xml_add_trailing_newline": return false
"xml_indentation_use_spaces": return false
"xml_indentation_spaces": return 2
Expand Down Expand Up @@ -115,12 +114,6 @@ func _init(new_preset := Preset.COMPACT) -> void:
xml_keep_comments = new_value
emit_changed()

@export var xml_keep_unrecognized := false:
set(new_value):
if xml_keep_unrecognized != new_value:
xml_keep_unrecognized = new_value
emit_changed()

@export var xml_add_trailing_newline := false:
set(new_value):
if xml_add_trailing_newline != new_value:
Expand Down Expand Up @@ -245,3 +238,10 @@ const INDENTS_MAX = 16
if transform_list_remove_unnecessary_params != new_value:
transform_list_remove_unnecessary_params = new_value
emit_changed()


func get_indent_string() -> String:
if xml_indentation_use_spaces:
return " ".repeat(xml_indentation_spaces)
else:
return "\t"
20 changes: 15 additions & 5 deletions src/config_classes/SVGHighlighter.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ var attribute_color := Color("bce0ff"):
unrecognized_attribute_color = Color(new_value, new_value.a * 0.7)


func _init() -> void:
symbol_color = Configs.savedata.highlighting_symbol_color
element_color = Configs.savedata.highlighting_element_color
attribute_color = Configs.savedata.highlighting_attribute_color
string_color = Configs.savedata.highlighting_string_color
comment_color = Configs.savedata.highlighting_comment_color
text_color = Configs.savedata.highlighting_text_color
cdata_color = Configs.savedata.highlighting_cdata_color
error_color = Configs.savedata.highlighting_error_color

func _get_line_syntax_highlighting(line: int) -> Dictionary:
var svg_text := get_text_edit().get_line(line)
if svg_text.is_empty():
Expand Down Expand Up @@ -66,13 +76,13 @@ func _get_line_syntax_highlighting(line: int) -> Dictionary:
color_map[offset] = {"color": symbol_color}
break
else:
if not expecting_attribute_name:
color_map[offset] = {"color": error_color}
return color_map
else:
expecting_end = false
if expecting_attribute_name and c != "=":
expecting_attribute_name = false
expecting_end = false
current_attribute_name += c
else:
color_map[offset] = {"color": error_color}
return color_map
elif not current_attribute_name.is_empty():
if c in " \t\n\r":
color_map[offset - current_attribute_name.length()] = {"color":
Expand Down
59 changes: 29 additions & 30 deletions src/config_classes/SaveData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func get_setting_default(setting: String) -> Variant:
"accent_color":
match theme_preset:
ThemePreset.DARK: return Color("3e8cfc")
ThemePreset.LIGHT: return Color("0830a6ff")
ThemePreset.LIGHT: return Color("0031bf")
ThemePreset.BLACK: return Color("7c8dbf")
"highlighter_preset":
match theme_preset:
Expand Down Expand Up @@ -68,7 +68,7 @@ func get_setting_default(setting: String) -> Variant:
ThemePreset.LIGHT: return Color("b22")
"basic_color_warning":
match theme_preset:
ThemePreset.DARK,ThemePreset.BLACK: return Color("ee5")
ThemePreset.DARK,ThemePreset.BLACK: return Color("ee6")
ThemePreset.LIGHT: return Color("991")
"handle_size": return 1.0 if OS.get_name() != "Android" else 2.0
"handle_inner_color": return Color("fff")
Expand All @@ -94,21 +94,24 @@ func get_setting_default(setting: String) -> Variant:
"invert_zoom": return false
"wraparound_panning": return false
"use_ctrl_for_zoom": return true
"use_native_file_dialog": return true
"use_filename_for_window_title": return true
"ui_scale": return ScalingApproach.AUTO
"vsync": return true
"max_fps": return 0
"keep_screen_on": return false
"use_native_file_dialog": return true
"use_filename_for_window_title": return true
return null

func reset_to_default() -> void:
for setting in _get_setting_names():
set(setting, get_setting_default(setting))

func reset_theme_items_to_default() -> void:
var old_highlighter_preset_value := highlighter_preset
for setting in theme_items:
set(setting, get_setting_default(setting))
reset_highlighting_items_to_default()
if old_highlighter_preset_value != highlighter_preset:
reset_highlighting_items_to_default()

func reset_highlighting_items_to_default() -> void:
for setting in highlighting_items:
Expand All @@ -129,17 +132,6 @@ const theme_items: PackedStringArray = [
"basic_color_valid",
"basic_color_error",
"basic_color_warning",
"handle_size",
"handle_inner_color",
"handle_color",
"handle_hovered_color",
"handle_selected_color",
"handle_hovered_selected_color",
"selection_rectangle_speed",
"selection_rectangle_width",
"selection_rectangle_dash_length",
"selection_rectangle_color1",
"selection_rectangle_color2",
"canvas_color",
"grid_color",
]
Expand Down Expand Up @@ -326,7 +318,7 @@ const CURRENT_VERSION = 1
emit_changed()
Configs.basic_colors_changed.emit()

@export var basic_color_warning := Color("ee5"):
@export var basic_color_warning := Color("ee6"):
set(new_value):
if basic_color_warning != new_value:
basic_color_warning = new_value
Expand Down Expand Up @@ -485,19 +477,6 @@ const MAX_SELECTION_RECTANGLE_DASH_LENGTH = 600.0
use_ctrl_for_zoom = new_value
emit_changed()

@export var use_native_file_dialog := true:
set(new_value):
if use_native_file_dialog != new_value:
use_native_file_dialog = new_value
emit_changed()

@export var use_filename_for_window_title := true:
set(new_value):
if use_filename_for_window_title != new_value:
use_filename_for_window_title = new_value
emit_changed()
external_call(HandlerGUI.update_window_title)

enum ScalingApproach {AUTO, CONSTANT_075, CONSTANT_100, CONSTANT_125, CONSTANT_150,
CONSTANT_175, CONSTANT_200, CONSTANT_225, CONSTANT_250, CONSTANT_275, CONSTANT_300, CONSTANT_400, MAX}
@export var ui_scale := ScalingApproach.AUTO:
Expand Down Expand Up @@ -533,6 +512,26 @@ const MAX_FPS_MAX = 600
emit_changed()
external_call(Configs.sync_max_fps)

@export var keep_screen_on := false:
set(new_value):
if keep_screen_on != new_value:
keep_screen_on = new_value
emit_changed()
external_call(Configs.sync_keep_screen_on)

@export var use_native_file_dialog := true:
set(new_value):
if use_native_file_dialog != new_value:
use_native_file_dialog = new_value
emit_changed()

@export var use_filename_for_window_title := true:
set(new_value):
if use_filename_for_window_title != new_value:
use_filename_for_window_title = new_value
emit_changed()
external_call(HandlerGUI.update_window_title)


# Session

Expand Down
2 changes: 1 addition & 1 deletion src/config_classes/TabData.gd
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func set_svg_text(new_text: String) -> void:
if not is_instance_valid(undo_redo):
undo_redo = UndoRedoRef.new()
var old_value := _svg_text
undo_redo.create_action("")
undo_redo.create_action()
undo_redo.add_do_property(self, "_svg_text", new_text)
undo_redo.add_undo_property(self, "_svg_text", old_value)
undo_redo.add_do_property(State, "svg_text", new_text)
Expand Down
14 changes: 6 additions & 8 deletions src/data_classes/Attribute.gd
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Represents an attribute inside an element, i.e. <element attribute="value"/>.
# If the Attribute's data type is known, one of the inheriting classes should be used.
# By default uses the editor formatter.
class_name Attribute

signal value_changed
Expand All @@ -13,7 +14,7 @@ func set_value(new_value: String) -> void:
# Formatting can be expensive, so do this cheap check first.
if new_value == _value:
return
var proposed_new_value := format(new_value)
var proposed_new_value := format(new_value, Configs.savedata.editor_formatter)
if proposed_new_value != _value:
_value = proposed_new_value
_sync()
Expand All @@ -22,16 +23,13 @@ func set_value(new_value: String) -> void:
func get_value() -> String:
return _value

func get_formatted_value(formatter: Formatter) -> String:
return format(_value, formatter)

func _sync() -> void:
pass

func format(text: String) -> String:
return _format(text, Configs.savedata.editor_formatter)

func get_export_value() -> String:
return _format(_value, Configs.savedata.export_formatter)

func _format(text: String, _formatter: Formatter) -> String:
func format(text: String, _formatter: Formatter) -> String:
return text

func _init(new_name: String, init_value := "") -> void:
Expand Down
2 changes: 1 addition & 1 deletion src/data_classes/AttributeColor.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func set_value(new_value: String) -> void:
name in DB.attribute_color_url_allowed, name in DB.attribute_color_none_allowed,
name in DB.attribute_color_current_color_allowed) else "")

func _format(text: String, formatter: Formatter) -> String:
func format(text: String, formatter: Formatter) -> String:
text = text.strip_edges()

if text.is_empty() or text in ["none", "currentColor"]:
Expand Down
2 changes: 1 addition & 1 deletion src/data_classes/AttributeList.gd
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var _list: PackedFloat64Array
func _sync() -> void:
_list = text_to_list(get_value())

func _format(text: String, formatter: Formatter) -> String:
func format(text: String, formatter: Formatter) -> String:
return list_to_text(text_to_list(text), formatter)


Expand Down
2 changes: 1 addition & 1 deletion src/data_classes/AttributeNumeric.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func is_percentage() -> bool:
return _percentage


func _format(text: String, formatter: Formatter) -> String:
func format(text: String, formatter: Formatter) -> String:
var num := text_to_num(text)
if text_check_percentage(text):
return num_to_text(num * 100.0, formatter) + "%"
Expand Down
2 changes: 1 addition & 1 deletion src/data_classes/AttributePathdata.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ func _sync() -> void:
_commands = parse_pathdata(get_value())
parse_properties()

func _format(text: String, formatter: Formatter) -> String:
func format(text: String, formatter: Formatter) -> String:
return path_commands_to_text(parse_pathdata(text), formatter)


Expand Down
Loading