Skip to content

Conversation

@AcTePuKc
Copy link

Please check if the PR fulfills these requirements:

  • The commit message follows our guidelines.

  • For bug fixes and features:

    • You tested the changes.

Related issue (if applicable): N/A


What kind of change does this PR introduce?

  • Project migration / compatibility update
  • Maintenance / cleanup for Godot 4

Does this PR introduce a breaking change?

  • Yes — this PR migrates the project to Godot 4 and is not compatible with Godot 3.
  • No

(The project behavior remains the same; changes are required for Godot 4 compatibility.)


New feature or change

What is the current behavior?

  • The project targets Godot 3.x.
  • Opening the project in Godot 4 results in missing nodes, deprecated APIs, or incompatibilities (e.g. Tween nodes, WindowDialog).

What is the new behavior?

  • The project has been migrated to Godot 4 syntax and APIs.
  • Scripts, scenes, resources, and project.godot were updated for Godot 4 compatibility.
  • Obsolete Godot 3 Tween nodes were removed where identified.

Known issues / follow-ups

  • The project does not yet run fully without errors.
  • There are known remaining issues that require a follow-up pass, likely related to:
    • leftover Godot 3 Tween data in some scene files that were not opened during this migration pass, and/or
    • UI-related nodes (WindowDialog, ScrollContainer) that require layout or design decisions.
  • These issues are expected and were intentionally left unresolved to avoid guessing original intent.

Other information

  • Migrated file types:
    • .gd
    • project.godot
    • selected .tscn and .tres files
  • Some scenes/resources may still require follow-up fixes that depend on application-specific layout or design decisions.
  • Import/cache files (.import, .godot/) were intentionally excluded and are regenerated by the engine.
  • The migration focuses on Godot 4 compatibility and correctness, not UI redesign or layout refactoring.

This should fix the mess I've made previously
Refactor ThemeManager to improve type safety and clarity.
res://addons/gdscript-course-builder/ui/InsertContentBlockDialog.tscn now plays properly, will check the rest
@NathanLovato
Copy link
Contributor

Thanks again for the work you're doing. One small note, if you use LLMs as part of your toolset, please make sure to preserve comments as to how the file is supposed to function and things like that. The comments about why certain things were done were already sparse, and they're important to keep to maintain a good understanding of caveats or workarounds, etc.

@AcTePuKc
Copy link
Author

Thanks for the note — totally fair point.

This isn’t the final form yet. While doing the mechanical Godot 4 port and tracking down runtime issues, some explanatory comments may have been removed or simplified. I’m currently focusing on getting the project to run cleanly first, and I’ll be restoring missing comments (and adding Godot 4–specific notes where behavior changed) as I continue iterating over the files in the next few days.
Most files are now running, but some GUI elements will likely need follow-up adjustments. I haven’t pushed those GUI-related changes yet, as I’m still tracking down the remaining issues.

Copy link
Contributor

@NathanLovato NathanLovato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just leaving you a few comments here as you're working through this to point out things I'd like you to change in the approach as you're working on this so the work you do does not have to be undone later on.

I'll check things out as you progress and leave you a few pointers like these for guidelines. If you have any questions, let me know.

onready var _theme = preload("res://ui/theme/gdscript_app_theme.tres")

var _font_defaults := {}
@onready var _theme: Theme = preload("res://ui/theme/gdscript_app_theme.tres")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@onready var _theme: Theme = preload("res://ui/theme/gdscript_app_theme.tres")
var _theme: Theme = preload("res://ui/theme/gdscript_app_theme.tres")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to delay the variable execution here. the resource will be preloaded at compile/load time.


func _cache_font_defaults() -> void:
_font_defaults.clear()
_cache_theme_defaults()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here I recommend inlining the function's code and not calling a separate function. You can include a comment about why you use this code: to store the default size of things.

Splitting small pieces of code like that to separate functions, on the one hand, labels the functions, but when they're small single use pieces like this, it also creates indirection. In a small script like that, it's fine. It's just at scale, it makes the code harder to trace.

Comment on lines +27 to +33
func _cache_theme_defaults() -> void:
_theme_defaults.clear()
for type: String in THEME_TYPES:
_theme_defaults[type] = {
"size": _theme.get_font_size("font_size", type),
"font": _theme.get_font("font", type)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why clear the theme defaults here? They start empty already and this is called only once. Also, as mentioned above, I'd prefer this code to be inlined in the _ready() function.

Comment on lines +16 to +25
var current_profile = UserProfiles.get_profile()

error = fs.list_dir_begin(true, true)
if error != OK:
printerr("Failed to read theme fonts directory at '%s': Error code %d" % [THEME_FONTS_ROOT, error])
return
# Fix for lines 20-22: Cast the Variant to the target type before passing to functions
var scale_val: float = current_profile.font_size_scale as float
var contrast_val: bool = current_profile.lower_contrast as bool
var dyslexia_val: bool = current_profile.dyslexia_font as bool

var current_file := fs.get_next() as String
while not current_file.empty():
if current_file.get_extension() != "tres":
current_file = fs.get_next()
continue

var font_resource = ResourceLoader.load(THEME_FONTS_ROOT.plus_file(current_file)) as DynamicFont
if not font_resource:
current_file = fs.get_next()
continue

_font_defaults[font_resource] = {"size": font_resource.size, "font": font_resource.font_data.font_path}
current_file = fs.get_next()

scale_all_font_sizes(roundi(scale_val), false)
set_lower_contrast(contrast_val, false)
set_dyslexia_font(dyslexia_val, false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub is buggy and won't let me suggest code here, but for code like this:

  1. The comment is not helpful here and should be removed. Looks like an LLM insertion (the code also does look like that)
  2. The variables look like proxies around the current profile properties and add unnecessary lines of code.
  3. The type information is only missing on line 16 on the current profile. Adding just a colon for type inference would give you type information.

Instead here the code should look more like this:

var current_profile := UserProfiles.get_profile()

# ...

scale_all_font_sizes(current_profile.font_size_scale, false)
# ...

It looks like you use an LLM, so I'd say it's really important that you check after the tool and think about what the code actually needs to do and if anything is unnecessary. No matter what you do, and even with the best LLM, it will likely generate and include unnecessary and poor code that does things that are not needed. It may also break the code in subtle ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants