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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Godot-specific ignores
.godot/
.nomedia
android/

# Others
.~lock.*
Expand Down
18 changes: 18 additions & 0 deletions assets/icons/Checkerboard.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[remap]

importer="svg"
type="SVGTexture"
uid="uid://c68og6bsqt0lb"
path="res://.godot/imported/Checkerboard.svg-6a6a77a30bc3d01a7e939a20ab5e8a17.svgtex"

[deps]

source_file="res://assets/icons/Checkerboard.svg"
dest_files=["res://.godot/imported/Checkerboard.svg-6a6a77a30bc3d01a7e939a20ab5e8a17.svgtex"]

[params]

base_scale=1.0
saturation=1.0
color_map={}
compress=true
18 changes: 18 additions & 0 deletions assets/icons/CheckerboardColorButton.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[remap]

importer="svg"
type="SVGTexture"
uid="uid://y0l74x73w0co"
path="res://.godot/imported/CheckerboardColorButton.svg-a3714a8fc4a1322639155850c5bd0c5e.svgtex"

[deps]

source_file="res://assets/icons/CheckerboardColorButton.svg"
dest_files=["res://.godot/imported/CheckerboardColorButton.svg-a3714a8fc4a1322639155850c5bd0c5e.svgtex"]

[params]

base_scale=1.0
saturation=1.0
color_map={}
compress=true
18 changes: 18 additions & 0 deletions assets/icons/CheckerboardMini.svg.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[remap]

importer="svg"
type="SVGTexture"
uid="uid://stpallv5q0rb"
path="res://.godot/imported/CheckerboardMini.svg-0ea7540124897b15442aca32bc10cdbd.svgtex"

[deps]

source_file="res://assets/icons/CheckerboardMini.svg"
dest_files=["res://.godot/imported/CheckerboardMini.svg-0ea7540124897b15442aca32bc10cdbd.svgtex"]

[params]

base_scale=1.0
saturation=1.0
color_map={}
compress=true
18 changes: 0 additions & 18 deletions assets/icons/backgrounds/Checkerboard.svg.import

This file was deleted.

18 changes: 0 additions & 18 deletions assets/icons/backgrounds/CheckerboardMini.svg.import

This file was deleted.

18 changes: 0 additions & 18 deletions assets/icons/backgrounds/ColorButtonBG.svg.import

This file was deleted.

6 changes: 3 additions & 3 deletions export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=false
architectures/x86_64=false
version/code=4
version/code=5
version/name="1.0-alpha4-dev"
package/unique_name="com.vectortouch.app"
package/name="VectorTouch"
Expand Down Expand Up @@ -261,8 +261,8 @@ architectures/armeabi-v7a=true
architectures/arm64-v8a=true
architectures/x86=true
architectures/x86_64=true
version/code=4
version/name="1.0-alpha3-dev"
version/code=5
version/name="1.0-alpha4-dev"
package/unique_name="com.vectortouch.app"
package/name="VectorTouch"
package/signed=true
Expand Down
65 changes: 32 additions & 33 deletions src/autoload/Configs.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This singleton handles session data and settings.
## An autoload that manages the savefile. Stores signals relating to changes to settings.
extends Node

@warning_ignore_start("unused_signal")
Expand All @@ -14,7 +14,6 @@ signal selection_rectangle_visuals_changed
signal grid_color_changed
signal shortcut_panel_changed
signal active_tab_status_changed
signal active_tab_reference_changed
signal active_tab_changed
signal tabs_changed
signal tab_removed
Expand Down Expand Up @@ -46,52 +45,49 @@ func check_orientation():
orientation_changed.emit()
HandlerGUI.toogle_status_bar(new_orientation == orientation.PORTRAIT)

const savedata_path = "user://savedata.tres"
const _SAVEDATA_PATH = "user://savedata.tres"

## Main point of access to the savefile data. This includes user settings and session data.
var savedata: SaveData:
set(new_value):
if savedata != new_value and is_instance_valid(new_value):
savedata = new_value
savedata.validate()
savedata.changed_deferred.connect(save)


## Helper for updating the savefile.
func save() -> void:
ResourceSaver.save(savedata, savedata_path)
ResourceSaver.save(savedata, _SAVEDATA_PATH)


## Default shortcuts to be able to reset a single action to its defaults.
var default_shortcuts: Dictionary[String, Array] = {}

func _enter_tree() -> void:
# Fill up the default shortcuts dictionary before the shortcuts are loaded.
for action in ShortcutUtils.get_all_actions():
if InputMap.has_action(action):
default_shortcuts[action] = InputMap.action_get_events(action)
load_config()


func load_config() -> void:
if not FileAccess.file_exists(savedata_path):
reset_settings()
return

savedata = ResourceLoader.load(savedata_path)
if not is_instance_valid(savedata):
reset_settings()
return
var savedata_reset_needed := true
# Load savedata.
if FileAccess.file_exists(_SAVEDATA_PATH):
savedata = ResourceLoader.load(_SAVEDATA_PATH)
if is_instance_valid(savedata):
savedata_reset_needed = false

post_load()


func reset_settings() -> void:
savedata = SaveData.new()
savedata.reset_to_default()
savedata.language = "en"
savedata.set_shortcut_panel_slots({ 0: "ui_undo", 1: "ui_redo", 2: "duplicate", 3: "delete", 4: "import", 5: "export"})
savedata.set_palettes([Palette.new("Pure", Palette.Preset.PURE)])
save()
post_load()

func post_load() -> void:
# Build everything from scratch if the savedata didn't exist or was invalid.
# Reset settings to their defaults.
if savedata_reset_needed:
savedata = SaveData.new()
savedata.reset_to_default()
savedata.language = "en"
savedata.set_shortcut_panel_slots({ 0: "ui_undo", 1: "ui_redo", 2: "duplicate", 3: "delete", 4: "import", 5: "export"})
savedata.set_palettes([Palette.new("Pure", Palette.Preset.PURE)])
save()

# Syncs various settings with their savedata value.
# TODO I'm not sure why I made it so syncing within the SaveData only starts when it's fully initialized.
savedata.get_active_tab().activate()
sync_canvas_color()
sync_locale()
Expand All @@ -100,27 +96,30 @@ func post_load() -> void:
sync_theme()


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

## Syncs the canvas color to the value in the savedata.
func sync_canvas_color() -> void:
RenderingServer.set_default_clear_color(savedata.canvas_color)

## Syncs the locale to the value in the savedata.
func sync_locale() -> void:
if not savedata.language in TranslationServer.get_loaded_locales():
savedata.language = "en"
else:
TranslationServer.set_locale(savedata.language)

## Syncs the VSync to the value in the savedata.
func sync_vsync() -> void:
DisplayServer.window_set_vsync_mode(
DisplayServer.VSYNC_ENABLED if savedata.vsync else DisplayServer.VSYNC_DISABLED)
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED if savedata.vsync else DisplayServer.VSYNC_DISABLED)

## Syncs the engine max FPS to the value in the savedata.
func sync_max_fps() -> void:
Engine.max_fps = savedata.max_fps

## Syncs the display server's "Keep screen on" behavior to the value in the savedata.
func sync_keep_screen_on() -> void:
DisplayServer.screen_set_keep_on(savedata.keep_screen_on)

## Syncs the app theme based on the configurations in the savedata.
func sync_theme() -> void:
ThemeUtils.generate_and_apply_theme()
theme_changed.emit()
Loading