From 3f361bc8ce07b9e4e3bba0369c280c3e7024a5e8 Mon Sep 17 00:00:00 2001 From: Marcus Brummer Date: Tue, 24 Sep 2024 08:27:14 +0200 Subject: [PATCH] Added tablet driver settings and made wintab default on Windows (#307) * Switched to wintab tablet driver for windows * Added tablet driver settings --- lorien/Assets/I18n/ar.txt | 1 + lorien/Assets/I18n/de.txt | 1 + lorien/Assets/I18n/en.txt | 1 + lorien/Assets/I18n/es.txt | 1 + lorien/Assets/I18n/fr.txt | 1 + lorien/Assets/I18n/it.txt | 1 + lorien/Assets/I18n/ko.txt | 1 + lorien/Assets/I18n/pt-BR.txt | 1 + lorien/Assets/I18n/ru.txt | 1 + lorien/Assets/I18n/tr.txt | 1 + lorien/Assets/I18n/uk.txt | 1 + lorien/Assets/I18n/zh-CN.txt | 1 + lorien/Assets/I18n/zh-TW.txt | 1 + lorien/Main.gd | 4 ++++ lorien/Misc/Settings.gd | 1 + lorien/UI/Dialogs/SettingsDialog.gd | 19 +++++++++++++++++++ lorien/UI/Dialogs/SettingsDialog.tscn | 15 +++++++++++++++ lorien/project.godot | 4 ++++ 18 files changed, 56 insertions(+) diff --git a/lorien/Assets/I18n/ar.txt b/lorien/Assets/I18n/ar.txt index aa072a27..7f496858 100644 --- a/lorien/Assets/I18n/ar.txt +++ b/lorien/Assets/I18n/ar.txt @@ -64,6 +64,7 @@ SETTINGS_BRUSH_SIZE مقاس الفرشاة الافتراضي SETTINGS_CANVAS_COLOR لون اللوحة الافتراضي SETTINGS_PROJECT_FOLDER ملف المشروع الافتراضي SETTINGS_LANGUAGE اللغة +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME الشكل SETTINGS_UI_SCALE حجم واجهة المستخدم SETTINGS_UI_SCALE_AUTO تلقائي diff --git a/lorien/Assets/I18n/de.txt b/lorien/Assets/I18n/de.txt index a232c4ef..a0e3665c 100644 --- a/lorien/Assets/I18n/de.txt +++ b/lorien/Assets/I18n/de.txt @@ -63,6 +63,7 @@ SETTINGS_PRESSURE_SENSITIVITY Druckempfindlichkeit SETTINGS_BRUSH_SIZE Default Pinsel Größe SETTINGS_PROJECT_FOLDER Default Project Ordner SETTINGS_LANGUAGE Sprache +SETTINGS_TABLET_DRIVER Tablet Treiber SETTINGS_THEME Theme SETTINGS_GRID_SIZE Grid Größe SETTINGS_GRID_PATTERN Grid Pattern diff --git a/lorien/Assets/I18n/en.txt b/lorien/Assets/I18n/en.txt index e974dca1..55895ce6 100644 --- a/lorien/Assets/I18n/en.txt +++ b/lorien/Assets/I18n/en.txt @@ -68,6 +68,7 @@ SETTINGS_BRUSH_SIZE Default Brush Size SETTINGS_PROJECT_FOLDER Default save/load folder SETTINGS_GRID_SIZE Grid Size SETTINGS_LANGUAGE Language +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Theme SETTINGS_UI_SCALE UI Scale SETTINGS_UI_SCALE_AUTO Auto diff --git a/lorien/Assets/I18n/es.txt b/lorien/Assets/I18n/es.txt index 0fe3088a..ebca6c29 100644 --- a/lorien/Assets/I18n/es.txt +++ b/lorien/Assets/I18n/es.txt @@ -63,6 +63,7 @@ SETTINGS_BRUSH_SIZE Tamaño de Pincel Predeterminado SETTINGS_CANVAS_COLOR Color de Canvas SETTINGS_PROJECT_FOLDER Carpeta de Proyectos Predeterminada SETTINGS_LANGUAGE Idioma +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Tema SETTINGS_FPS_FOREGROUND Color de texto de FPS SETTINGS_FPS_BACKGROUND Color de fondo de FPS diff --git a/lorien/Assets/I18n/fr.txt b/lorien/Assets/I18n/fr.txt index 7f31aa3a..eb562d4f 100644 --- a/lorien/Assets/I18n/fr.txt +++ b/lorien/Assets/I18n/fr.txt @@ -62,6 +62,7 @@ SETTINGS_PRESSURE_SENSITIVITY Sensibilité de la pression SETTINGS_BRUSH_SIZE Épaisseur par défaut de la brosse SETTINGS_PROJECT_FOLDER Dossier par défaut du projet SETTINGS_LANGUAGE Langue +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Thème SETTINGS_FPS_FOREGROUND Fps lorsque actif SETTINGS_FPS_BACKGROUND Fps lorsque inactif diff --git a/lorien/Assets/I18n/it.txt b/lorien/Assets/I18n/it.txt index 4dbaefb1..9cc9262f 100644 --- a/lorien/Assets/I18n/it.txt +++ b/lorien/Assets/I18n/it.txt @@ -62,6 +62,7 @@ SETTINGS_PRESSURE_SENSITIVITY Sensibilità alla pressione SETTINGS_BRUSH_SIZE Dimensione Pennello Predefinita SETTINGS_PROJECT_FOLDER Cartella di Progetto Predefinita SETTINGS_LANGUAGE Lingua +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Tema SETTINGS_FPS_FOREGROUND Fps in primo piano SETTINGS_FPS_BACKGROUND Fps sullo sfondo diff --git a/lorien/Assets/I18n/ko.txt b/lorien/Assets/I18n/ko.txt index 70ddc7be..2127e31a 100644 --- a/lorien/Assets/I18n/ko.txt +++ b/lorien/Assets/I18n/ko.txt @@ -63,6 +63,7 @@ SETTINGS_PRESSURE_SENSITIVITY 필압 민감도 SETTINGS_BRUSH_SIZE 기본 브러쉬 크기 SETTINGS_PROJECT_FOLDER 기본 프로젝트 풀더 SETTINGS_LANGUAGE 언어 +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME 테마 SETTINGS_UI_SCALE UI 표시 배율 SETTINGS_UI_SCALE_AUTO 자동 diff --git a/lorien/Assets/I18n/pt-BR.txt b/lorien/Assets/I18n/pt-BR.txt index c612e730..2eac9738 100644 --- a/lorien/Assets/I18n/pt-BR.txt +++ b/lorien/Assets/I18n/pt-BR.txt @@ -66,6 +66,7 @@ SETTINGS_BRUSH_SIZE Tamanho Padrão do Pincel SETTINGS_CANVAS_COLOR Cor da Área de Desenho SETTINGS_PROJECT_FOLDER Pasta Padrão do Projeto SETTINGS_LANGUAGE Idioma +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Tema SETTINGS_UI_SCALE Escala da Interface SETTINGS_UI_SCALE_AUTO Automática diff --git a/lorien/Assets/I18n/ru.txt b/lorien/Assets/I18n/ru.txt index 9eef4922..76f1a535 100644 --- a/lorien/Assets/I18n/ru.txt +++ b/lorien/Assets/I18n/ru.txt @@ -62,6 +62,7 @@ SETTINGS_BRUSH_SIZE Размер кисти по умолчанию SETTINGS_CANVAS_COLOR Цвет кисти SETTINGS_PROJECT_FOLDER Папка проекта по умолчанию SETTINGS_LANGUAGE Язык +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Тема SETTINGS_FPS_FOREGROUND Foreground Fps # TODO SETTINGS_FPS_BACKGROUND Background Fps # TODO diff --git a/lorien/Assets/I18n/tr.txt b/lorien/Assets/I18n/tr.txt index 126f2684..3cb1bd9d 100644 --- a/lorien/Assets/I18n/tr.txt +++ b/lorien/Assets/I18n/tr.txt @@ -66,6 +66,7 @@ SETTINGS_CANVAS_COLOR Tuval Rengi SETTINGS_PROJECT_FOLDER Varsayılan Proje Klasörü SETTINGS_GRID_SIZE Izgara Boyutu SETTINGS_LANGUAGE Dil +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Tema SETTINGS_UI_SCALE UI Boyutu SETTINGS_UI_SCALE_AUTO Otomatik diff --git a/lorien/Assets/I18n/uk.txt b/lorien/Assets/I18n/uk.txt index e0703b99..974c31d2 100644 --- a/lorien/Assets/I18n/uk.txt +++ b/lorien/Assets/I18n/uk.txt @@ -66,6 +66,7 @@ SETTINGS_BRUSH_SIZE Розмір Пензлика за замовч SETTINGS_PROJECT_FOLDER Папка Проекту за замовчуванням SETTINGS_GRID_SIZE Розмір сітки SETTINGS_LANGUAGE Мова +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME Тема SETTINGS_UI_SCALE Розмір UI SETTINGS_UI_SCALE_AUTO Авто diff --git a/lorien/Assets/I18n/zh-CN.txt b/lorien/Assets/I18n/zh-CN.txt index f13e4b19..4ede8275 100644 --- a/lorien/Assets/I18n/zh-CN.txt +++ b/lorien/Assets/I18n/zh-CN.txt @@ -64,6 +64,7 @@ SETTINGS_BRUSH_SIZE 默认画笔大小 SETTINGS_CANVAS_COLOR 画布颜色 SETTINGS_PROJECT_FOLDER 默认项目路径 SETTINGS_LANGUAGE 语言 +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME 主题 SETTINGS_UI_SCALE UI 缩放 SETTINGS_UI_SCALE_AUTO 自动 diff --git a/lorien/Assets/I18n/zh-TW.txt b/lorien/Assets/I18n/zh-TW.txt index 88a1aa33..0b70215d 100644 --- a/lorien/Assets/I18n/zh-TW.txt +++ b/lorien/Assets/I18n/zh-TW.txt @@ -64,6 +64,7 @@ SETTINGS_BRUSH_SIZE 預設畫筆大小 SETTINGS_CANVAS_COLOR 畫布底色 SETTINGS_PROJECT_FOLDER 預設專案目錄 SETTINGS_LANGUAGE 語言 +SETTINGS_TABLET_DRIVER Tablet Driver SETTINGS_THEME 佈景主題 SETTINGS_UI_SCALE UI 縮放 SETTINGS_UI_SCALE_AUTO 自動 diff --git a/lorien/Main.gd b/lorien/Main.gd index 20f44815..f3b5c966 100644 --- a/lorien/Main.gd +++ b/lorien/Main.gd @@ -40,6 +40,10 @@ func _ready() -> void: _file_dialog.current_dir = Settings.get_value(Settings.GENERAL_DEFAULT_PROJECT_DIR, docs_folder) _export_dialog.current_dir = Settings.get_value(Settings.GENERAL_DEFAULT_PROJECT_DIR, docs_folder) + # Set tablet driver + var driver: String = Settings.get_value(Settings.GENERAL_TABLET_DRIVER, DisplayServer.tablet_get_current_driver()) + DisplayServer.tablet_set_current_driver(driver) + # Signals get_window().files_dropped.connect(_on_files_dropped) diff --git a/lorien/Misc/Settings.gd b/lorien/Misc/Settings.gd index 9298b4d0..93a26793 100644 --- a/lorien/Misc/Settings.gd +++ b/lorien/Misc/Settings.gd @@ -12,6 +12,7 @@ const GENERAL_DEFAULT_BRUSH_SIZE := "general_default_brush_size" const GENERAL_DEFAULT_PROJECT_DIR := "general_default_project_dir" const GENERAL_LANGUAGE := "general_language" const GENERAL_TOOL_PRESSURE := "general_tool_pressure" +const GENERAL_TABLET_DRIVER := "general_tablet_driver" const COLOR_PALETTE_UUID_LAST_USED := "general_color_palette_uuid_last_used" # TODO: move this to state.cfg # ------------------------------------------------------------------------------------------------- diff --git a/lorien/UI/Dialogs/SettingsDialog.gd b/lorien/UI/Dialogs/SettingsDialog.gd index 33cc8594..51b60f58 100644 --- a/lorien/UI/Dialogs/SettingsDialog.gd +++ b/lorien/UI/Dialogs/SettingsDialog.gd @@ -42,6 +42,7 @@ signal constant_pressure_changed(state: bool) @onready var _stabilizer_strength: SpinBox = %StabilizerStrength @onready var _project_dir: LineEdit = %DefaultProjectDir @onready var _language: OptionButton = %Language +@onready var _tablet_driver: OptionButton = %TabletDriver @onready var _theme: OptionButton = %Theme @onready var _canvas_color: ColorPickerButton= %CanvasColor @onready var _ui_scale_mode: OptionButton = %UIScaleOptions @@ -67,6 +68,7 @@ func _ready() -> void: _tool_pressure.value_changed.connect(_on_default_tool_pressure_changed) _project_dir.text_changed.connect(_on_default_project_dir_changed) _language.item_selected.connect(_on_language_selected) + _tablet_driver.item_selected.connect(_on_tablet_driver_selected) _theme.item_selected.connect(_on_theme_selected) _ui_scale_mode.item_selected.connect(_on_ui_scale_mode_selected) _ui_scale.value_changed.connect(_on_ui_scale_changed) @@ -87,6 +89,7 @@ func _set_values() -> void: var brush_size: int = Settings.get_value(Settings.GENERAL_DEFAULT_BRUSH_SIZE, Config.DEFAULT_BRUSH_SIZE) var project_dir: String = Settings.get_value(Settings.GENERAL_DEFAULT_PROJECT_DIR, "") var locale: String = Settings.get_value(Settings.GENERAL_LANGUAGE, "en") + var driver: String = Settings.get_value(Settings.GENERAL_TABLET_DRIVER, DisplayServer.tablet_get_current_driver()) var tool_pressure: float = Settings.get_value(Settings.GENERAL_TOOL_PRESSURE, Config.DEFAULT_TOOL_PRESSURE) var pressure_sensitivity: float = Settings.get_value(Settings.GENERAL_PRESSURE_SENSITIVITY, Config.DEFAULT_PRESSURE_SENSITIVITY) var constant_pressure: bool = Settings.get_value(Settings.GENERAL_CONSTANT_PRESSURE, Config.DEFAULT_CONSTANT_PRESSURE) @@ -114,6 +117,7 @@ func _set_values() -> void: _ui_scale.set_editable(true) _set_languages(locale) + _set_tablet_drivers(driver) _set_rounding() _set_keybindings() _set_ui_scale_range() @@ -176,6 +180,15 @@ func _set_languages(current_locale: String) -> void: var id := Array(Settings.locales).find(current_locale) _language.selected = _language.get_item_index(id) +#-------------------------------------------------------------------------------------------------- +func _set_tablet_drivers(current_driver: String) -> void: + for i: int in DisplayServer.tablet_get_driver_count(): + var driver := DisplayServer.tablet_get_driver_name(i) + if driver != "dummy": + _tablet_driver.add_item(driver) + if current_driver == driver: + _tablet_driver.selected = i + #-------------------------------------------------------------------------------------------------- func _set_keybindings() -> void: for action: KeybindingsManager.Action in KeybindingsManager.get_actions(): @@ -278,6 +291,12 @@ func _on_language_selected(idx: int) -> void: GlobalSignals.language_changed.emit() _restart_label.show() +# ------------------------------------------------------------------------------------------------- +func _on_tablet_driver_selected(idx: int) -> void: + var driver := _tablet_driver.get_item_text(idx) + Settings.set_value(Settings.GENERAL_TABLET_DRIVER, driver) + DisplayServer.tablet_set_current_driver(driver) + # ------------------------------------------------------------------------------------------------- func _on_ui_scale_mode_selected(index: int) -> void: match index: diff --git a/lorien/UI/Dialogs/SettingsDialog.tscn b/lorien/UI/Dialogs/SettingsDialog.tscn index 8a6dbeb2..4b7b9034 100644 --- a/lorien/UI/Dialogs/SettingsDialog.tscn +++ b/lorien/UI/Dialogs/SettingsDialog.tscn @@ -180,6 +180,21 @@ placeholder_text = "e.g. C:/Users/me/Lorien" layout_mode = 2 theme_override_constants/separation = 24 +[node name="TabletDriver" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 3 + +[node name="Label" type="Label" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer/TabletDriver"] +layout_mode = 2 +size_flags_horizontal = 3 +size_flags_vertical = 6 +text = "SETTINGS_TABLET_DRIVER" + +[node name="TabletDriver" type="OptionButton" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer/TabletDriver"] +unique_name_in_owner = true +layout_mode = 2 +size_flags_horizontal = 3 + [node name="Language" type="HBoxContainer" parent="VBoxContainer/MarginContainer/VBoxContainer/GeneralContainer/VBoxContainer"] layout_mode = 2 size_flags_horizontal = 3 diff --git a/lorien/project.godot b/lorien/project.godot index 1e534bf3..bbaa5e55 100644 --- a/lorien/project.godot +++ b/lorien/project.godot @@ -257,6 +257,10 @@ canvas_pan_key={ ] } +[input_devices] + +pen_tablet/driver.windows="wintab" + [locale] translation_remaps={