Skip to content

Commit

Permalink
Upgrade to Godot 4.1
Browse files Browse the repository at this point in the history
* Upgraded to Godot 4.1 to enable planed future features
* Fixed crash after using Spanish translation that was removed from original game
  • Loading branch information
Tetragramat committed Aug 23, 2023
1 parent 9688ff9 commit 8223e35
Show file tree
Hide file tree
Showing 16 changed files with 305 additions and 369 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Godot-specific ignores
.import/
.godot
.import
export.cfg
export_presets.cfg

Expand Down
6 changes: 3 additions & 3 deletions Root.gd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var screens = {
}

func _ready():
current_screen = find_node("Screen")
current_screen = find_child("Screen")
_load_screen("configuration")

func _load_screen(name):
Expand All @@ -19,8 +19,8 @@ func _load_screen(name):
if old_screen != null:
current_screen.remove_child(old_screen)

var new_screen = screens[name].instance()
new_screen.connect("next_screen", self, "_load_screen")
var new_screen = screens[name].instantiate()
new_screen.connect("next_screen", Callable(self, "_load_screen"))
current_screen.add_child(new_screen)
else:
printerr("[ERROR] Cannot load screen: ", name)
6 changes: 3 additions & 3 deletions Root.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=2 format=3 uid="uid://c8m86nycsnkak"]

[ext_resource path="res://Root.gd" type="Script" id=1]
[ext_resource type="Script" path="res://Root.gd" id="1"]

[node name="Root" type="Node"]
script = ExtResource( 1 )
script = ExtResource("1")

[node name="Screen" type="Node" parent="."]
4 changes: 2 additions & 2 deletions assets/NotoSansTC.tres
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_resource type="DynamicFont" load_steps=2 format=2]
[gd_resource type="FontFile" load_steps=2 format=2]

[ext_resource path="res://assets/Noto_Sans_TC/NotoSansTC-Regular.otf" type="DynamicFontData" id=1]
[ext_resource path="res://assets/Noto_Sans_TC/NotoSansTC-Regular.otf" type="FontFile" id=1]

[resource]
font_data = ExtResource( 1 )
33 changes: 33 additions & 0 deletions assets/Noto_Sans_TC/NotoSansTC-Regular.otf.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://i2tkskbgn33x"
path="res://.godot/imported/NotoSansTC-Regular.otf-09972b8fa3c491e5dd55e3afb940349d.fontdata"

[deps]

source_file="res://assets/Noto_Sans_TC/NotoSansTC-Regular.otf"
dest_files=["res://.godot/imported/NotoSansTC-Regular.otf-09972b8fa3c491e5dd55e3afb940349d.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
6 changes: 3 additions & 3 deletions default_env.tres
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_resource type="Environment" load_steps=2 format=2]
[gd_resource type="Environment" load_steps=2 format=3 uid="uid://bf0hj284ykxmd"]

[sub_resource type="ProceduralSky" id=1]
[sub_resource type="Sky" id="1"]

[resource]
background_mode = 2
background_sky = SubResource( 1 )
sky = SubResource("1")
32 changes: 16 additions & 16 deletions icon.png.import
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://c2rekpn7e26r"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://icon.png"
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/hdr_compression=1
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
23 changes: 7 additions & 16 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,17 @@
; [section] ; section goes between []
; param=value ; assign values to parameters

config_version=4

_global_script_classes=[ {
"base": "Object",
"class": "TextManager",
"language": "GDScript",
"path": "res://scripts/text_manager.gd"
} ]
_global_script_class_icons={
"TextManager": ""
}
config_version=5

[application]

config/name="LonaRPG MTL"
run/main_scene="res://Root.tscn"
config/features=PackedStringArray("4.1")
run/low_processor_mode=true
boot_splash/bg_color=Color(0, 0, 0, 1)
boot_splash/image="res://splash.png"
boot_splash/fullsize=false
boot_splash/bg_color=Color( 0, 0, 0, 1 )
config/icon="res://icon.png"
config/windows_native_icon="res://icon.ico"

Expand All @@ -36,11 +27,11 @@ Config="*res://scripts/Config.gd"

[gdnative]

singletons=[ ]
singletons=[]

[gui]

common/swap_ok_cancel=false
common/swap_cancel_ok=false
theme/custom_font="res://assets/NotoSansTC.tres"

[logging]
Expand All @@ -49,7 +40,7 @@ file_logging/log_path="user://logs/log.log"

[rendering]

renderer/rendering_method="gl_compatibility"
environment/defaults/default_environment="res://default_env.tres"
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_environment="res://default_env.tres"
58 changes: 30 additions & 28 deletions screens/Configuration.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,44 @@ extends "AbstractScreen.gd"
const TextManager = preload("res://scripts/text_manager.gd")
const GoogleLocales = preload("res://scripts/locales.gd")

onready var _language_option_button = $MarginContainer/VBoxContainer/CenterContainer/VBoxContainer/LanguageOptionButton
onready var _google_translate_button = $MarginContainer/VBoxContainer/CenterContainer/VBoxContainer/HBoxContainer/GoogleTranslateButton
onready var _manual_translate_button = $MarginContainer/VBoxContainer/CenterContainer/VBoxContainer/HBoxContainer/ManualTranslateButton
onready var _always_on_top_button = $AlwaysOnTopButton
onready var _file_dialog = $FileDialog
onready var _accept_dialog = $AcceptDialog
onready var _config = get_node("/root/Config")
onready var _data = get_node("/root/LocalizationData")
@onready var _language_option_button = $MarginContainer/VBoxContainer/CenterContainer/VBoxContainer/LanguageOptionButton
@onready var _google_translate_button = $MarginContainer/VBoxContainer/CenterContainer/VBoxContainer/HBoxContainer/GoogleTranslateButton
@onready var _manual_translate_button = $MarginContainer/VBoxContainer/CenterContainer/VBoxContainer/HBoxContainer/ManualTranslateButton
@onready var _always_on_top_button = $AlwaysOnTopButton
@onready var _file_dialog = $FileDialog
@onready var _accept_dialog = $AcceptDialog
@onready var _config = get_node("/root/Config")
@onready var _data = get_node("/root/LocalizationData")

func _ready():
_always_on_top_button.set_pressed(_config.get_window_always_on_top())
setup_language_option_button()
get_tree().connect("files_dropped", self, "_on_files_dropped")
get_viewport().files_dropped.connect(_on_files_dropped)
_parse_cmdline()

func _parse_cmdline():
for argument in OS.get_cmdline_args():
_on_FileDialog_file_selected(argument)
if not argument.contains("res://"):
_on_FileDialog_file_selected(argument)
break

func _process(_delta):
_language_option_button.disabled = _data.text_directory.empty()
_google_translate_button.disabled = _data.language_directory.empty()
_manual_translate_button.disabled = _data.language_directory.empty()
_language_option_button.disabled = _data.text_directory.is_empty()
_google_translate_button.disabled = _data.language_directory.is_empty() or _data.language.is_empty()
_manual_translate_button.disabled = _data.language_directory.is_empty() or _data.language.is_empty()

func _on_SelectGameButton_pressed():
_file_dialog.popup_centered()
_file_dialog.set_current_path(_config.get_game_path())

func _on_files_dropped(files: PoolStringArray, screen: int) -> void:
func _on_files_dropped(files: PackedStringArray, screen: int) -> void:
_file_dialog.visible = false
_on_FileDialog_file_selected(files[0])

func _on_FileDialog_file_selected(path: String):
var dir = Directory.new()
var text_dir = path.get_base_dir() + "/Text"

if not dir.dir_exists(text_dir):
if not DirAccess.dir_exists_absolute(text_dir):
_accept_dialog.dialog_text = "Directory " + text_dir + " does not exist!"
_accept_dialog.popup_centered()
return
Expand All @@ -66,6 +66,10 @@ func _on_LanguageOptionButton_item_selected(index):
_:
_data.language_directory = "CHT"

if not DirAccess.dir_exists_absolute(_data.get_source_dir()):
printerr("Source directory %s does not exist reverting back to default CHT directory." % _data.get_source_dir())
_data.language_directory = "CHT"

copy_recursive(_data.get_source_dir(), _data.get_target_dir())

func _on_GoogleTranslateButton_pressed():
Expand All @@ -76,11 +80,11 @@ func _on_ManualTranslateButton_pressed():

func _on_AlwaysOnTopButton_toggled(button_pressed):
_config.set_window_always_on_top(button_pressed)
OS.set_window_always_on_top(button_pressed)
get_window().always_on_top = (button_pressed)

func setup_language_option_button():
_language_option_button.add_item(_language_option_button.text, 0)
_language_option_button.set_item_disabled(0, true)
_language_option_button.add_item("Select language", 0)
_language_option_button.set_item_metadata(0, "")

var index = 1
for item in GoogleLocales.LOCALES:
Expand All @@ -89,18 +93,18 @@ func setup_language_option_button():
index = index + 1

func copy_recursive(from: String, to: String) -> void:
var directory := Directory.new()

if not directory.dir_exists(to):
if directory.make_dir_recursive(to) != OK:
if not DirAccess.dir_exists_absolute(to):
if DirAccess.make_dir_recursive_absolute(to) != OK:
printerr("Failed to create directory %s" % to)
return

if directory.open(from) != OK:
var directory = DirAccess.open(from)

if not directory:
printerr("Unable to open directory %s" % from)
return

if directory.list_dir_begin(true) != OK:
if directory.list_dir_begin() != OK:
printerr("Unable to list directory %s" % from)
return

Expand All @@ -115,9 +119,7 @@ func copy_recursive(from: String, to: String) -> void:
file_name = directory.get_next()

func copy_file(from: String, to: String) -> void:
var directory = Directory.new()

if directory.copy(from, to) != OK:
if DirAccess.copy_absolute(from, to) != OK:
printerr("Failed to copy file from %s to %s" % [from, to])


Expand Down
Loading

0 comments on commit 8223e35

Please sign in to comment.