- Global.gd: move @onready var animation below the regular vars
(gdlint class-definitions-order expects onready vars after
public/private vars).
- Database.gd::DB: move the three _*_PROPS constants above the vars
(constants come before vars in a class body).
- Levels.gd:_search_button_to_use: drop the elif after a branch
that returns (no-elif-return).
- Levels.gd:_gyroscope_changed_{down,up}: continuation lines of the
multi-line return mixed two tabs + three spaces; normalised to
pure tabs.
No semantic change: @onready is property-level so source ordering
doesn't affect init; elif after a return is equivalent to if; the
continuation indent is cosmetic.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two related cleanups from the best-practice audit:
Task 3 — typed Resources instead of MBase / MScene / MLevel / MSetting
The old model classes wrapped the godot_db_manager Table API: each row
read went through table.get_data_at_row_idx(int), Cell.get_data(),
and 'as int' / 'as String' casts that don't actually parse anything
in Godot 4. m_value, m_lock, m_label, ... members shadowed the cell
indirection. Setters round-tripped through table.edit_data() +
Global.database.save_db(). That's a lot of plumbing for what is, in
the end, three flat tables of static strings.
Introduce three @export-typed Resources:
db/scene_entry.gd class_name SceneEntry
db/level_entry.gd class_name LevelEntry
db/settings_data.gd class_name SettingsData
Rewrite scripts/Database.gd so Database.DB holds:
settings: SettingsData
levels: Array[LevelEntry]
scenes: Array[SceneEntry]
Build them once at startup from ahog.json, and serialise back to the
same JSON shape on save() so existing progress files keep working.
LevelEntry carries its own object_to_find / object_finding / reset
methods (talking to Global.database for cross-table lookups), and
SceneEntry carries its own mesh_path / audio_sound. Per-scene
dissolve state (value, tick_reference, dissolved) lives on
SceneEntry as non-exported runtime fields.
Delete db/MBase.gd / db/MScene.gd / db/MLevel.gd / db/MSetting.gd.
Update consumers:
- scripts/Setting.gd: read/write Global.database.settings directly,
call Global.database.save() after each setter.
- scenes/levels/Levels.gd: iterate Global.database.scenes_for_level(
current_scene_int) instead of mscene.new(i) for every row; scene
state reads (scene.lock, scene.mesh, scene.counter, ...) replace
scene.lock() / scene.mesh() / scene.counter() method calls; runtime
dissolve state lives on the SceneEntry instance instead of mutable
m_value / m_tick_reference members on MScene; 'dissolved' flag
replaces set_mesh(null) signalling.
- scenes/UI/choose_scenes/ChooseScene.gd: iterate Global.database
.levels; level.name / level.thumb property access in place of
level.name() / level.thumbnail(). configure_reset() loses its
redundant index argument (LevelEntry knows its own index).
- scripts/event.gd: _on_reset_level signature now takes LevelEntry,
reset path drops index forwarding.
Task 2 — type hints across the remaining scripts
scripts/Global.gd, scenes/Main.gd, scenes/UI/ending/Ending.gd,
scenes/UI/loading/Loading.gd, scenes/UI/settings/Settings.gd: add
typed parameters and -> return annotations. current_scene_int is now
'int = -1' (sentinel) so callers don't fall into Variant comparisons;
event.gd:_on_reset_level resets it to -1 instead of null.
Settings.gd no longer wraps button_pressed in int() before passing to
the now-typed bool setters.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two of the five autoloads were stateless helper bundles, not the
persistent application-wide systems that the Godot 4 best-practice
guide reserves autoload slots for. Convert them to plain classes with
all-static methods so they no longer need a Node living under /root.
- scripts/Animation.gd -> scripts/game_animation.gd (renamed:
conflict with the built-in Animation class; the autoload sidestepped
it by being called GlobalAnimation). class_name GameAnimation,
every helper static. The dissolve tween now captures its target
material in a lambda closure, eliminating the current_material
member that the autoload kept as shared mutable state.
- scripts/Event.gd -> scripts/event.gd, class_name Event, every
handler static. Added Event.level_pressed(name) -> Callable for the
one place ChooseScene needed dynamic lookup of a per-level handler
(replaces the old _build_method('_on_' + name + '_pressed') +
Callable(autoload, string) reflection trick with an explicit match).
Updated call sites:
- scripts/Global.gd: animation.connect('animation_started',
Callable(Event, '...')) -> animation.animation_started.connect(
Event._loading_is_started). Same for animation_finished.
- scenes/levels/Levels.gd: GlobalAnimation.* -> GameAnimation.*;
Quit/TextureButton.connect('pressed', Callable(Event, '...')) ->
pressed.connect(Event._on_main_scene_pressed).
- scenes/UI/choose_scenes/ChooseScene.gd: per-level button connects
go through Event.level_pressed(); reset button's bound callable now
reads Event._on_reset_level.bind(...); cleanup no longer relies on
is_connected with an unbound Callable (which would never match a
bound one anyway) -- iterates reset.pressed.get_connections()
instead. Drop the now-dead _build_method helper.
Also: organise scripts/ by promoting the one-shot migration helpers
(migrate_shaders, migrate_misc, resave_scenes, devisualize_shaders,
find_visualshaders) into scripts/migration/. They are not part of
the runtime and should not be browsable next to the autoloads.
Autoload count goes 5 -> 3 (Loading, Global, Setting remain --
Setting will move to a Resource in a later refactor).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
godot_db_manager was incompatible with Godot 4 (used WindowDialog, Tabs,
PopupPanel which were all removed). Replace with a minimal Database.gd
that parses the same ahog.json format and exposes the same surface API
(get_table_by_name, get_data_at_row_idx, edit_data, save_db, etc.) used
by the M* model classes — no changes needed in MBase/MScene/MLevel/MSetting.
Also port the lod plugin: fix class_name syntax (Godot 4 uses @icon
separately from class_name extends) and Particles -> GPUParticles3D.
Rewrite Global.gd async scene loading: the convert-3to4 tool mapped
load_interactive -> load_threaded_request but those have different APIs
(stage count, poll vs. status enum). Reimplement using the new
load_threaded_get_status / load_threaded_get pair.
Clean project.godot: drop the old _global_script_classes table (Godot 4
uses inline class_name declarations), remove gddb_* autoloads, and
remove the godot_db_manager entry from editor_plugins.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>