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
10 changes: 7 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ repos:
types_or: [text]

- repo: https://github.com/atelico/gdstyle
rev: v0.2.1
rev: v0.2.4
hooks:
- id: gdstyle-fmt
files: \.gd$
exclude: |
(?x)^(
game/addons/.*
game/addons/(?!
openvic
).*
)
types_or: [text]

Expand All @@ -66,7 +68,9 @@ repos:
exclude: |
(?x)^(
game/assets/localisation/locales/.*|
game/addons/.*
game/addons/(?!
openvic
).*
)


Expand Down
14 changes: 14 additions & 0 deletions game/addons/OpenVic/OpenVic.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@tool
Comment thread
Spartan322 marked this conversation as resolved.
extends EditorPlugin

const TranslatorPlugin := preload("uid://d0rgx3infg54m")

var _translation_plugin := TranslatorPlugin.new()


func _enter_tree() -> void:
add_translation_parser_plugin(_translation_plugin)


func _exit_tree() -> void:
remove_translation_parser_plugin(_translation_plugin)
1 change: 1 addition & 0 deletions game/addons/OpenVic/OpenVic.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://bitrr5fd75qlp
59 changes: 59 additions & 0 deletions game/addons/OpenVic/TranslatorPlugin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
@tool
extends EditorTranslationParserPlugin

const AppSettings := preload("res://addons/kenyoni/app_settings/app_settings.gd")


func _customize_strings(strings: Array[PackedStringArray]) -> Array[PackedStringArray]:
strings.append_array(generate_localization(GameSettings))
strings.append_array(generate_localization(ModSettings))
strings.append_array(generate_localization(Vic2Settings))

var keychain_path: String = ControlsGlobal.get_script().resource_path
for action_id: StringName in ControlsGlobal.actions:
strings.append([ControlsGlobal.actions[action_id].display_name, "", "", "", keychain_path])

for group_name: StringName in ControlsGlobal.groups:
strings.append([group_name, "", "", "", keychain_path])

return strings


func generate_localization(app_setting: AppSettings) -> Array[PackedStringArray]:
var resource_path: String = app_setting.get_script().resource_path

var result: Array[PackedStringArray] = []
for key: String in app_setting.get_sub_sections():
result.append([key.capitalize(), "", "", "", resource_path])

var groups_handled: Array[GameSettings.RevertGroup] = []

for setting: AppSettings.Setting in app_setting.get_section(""):
if setting.has_meta(&"display_name"):
result.append([setting.get_meta(&"display_name"), "", "", "", resource_path])
else:
var key := setting.key()
result.append([key.get_slice("/", key.get_slice_count("/") - 1).capitalize(), "", "", "", resource_path])

if setting.has_meta(&"description"):
result.append([setting.get_meta(&"description"), "", "", "", resource_path])

if setting.has_meta(&"display_template"):
result.append([setting.get_meta(&"display_template"), "", "", "", resource_path])
else:
var display_values: PackedStringArray = setting.get_meta(
&"display_values",
PackedStringArray(),
)
for value: String in display_values:
if value.is_empty(): continue
result.append([value, "", "", "", resource_path])

if setting.has_meta(&"revert_group"):
var revert_group: GameSettings.RevertGroup = setting.get_meta(&"revert_group")
if not groups_handled.has(revert_group):
groups_handled.append(revert_group)
result.append([revert_group.title, "", "", "", resource_path])
result.append([revert_group.text, "", "", "", resource_path])

return result
1 change: 1 addition & 0 deletions game/addons/OpenVic/TranslatorPlugin.gd.uid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
uid://d0rgx3infg54m
7 changes: 7 additions & 0 deletions game/addons/OpenVic/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="OpenVic Plugin"
description=""
author="OpenVic Contributors"
version="1.0.0"
script="OpenVic.gd"
Loading
Loading