Commit Graph

5 Commits

Author SHA1 Message Date
Vaillant Jeremy 6146d84b87 Fix Levels.gd type inference + Database integer-division warning + brighten scenes
- scenes/levels/Levels.gd: replace 'var level := Global.database
  .level_by_index(...)' with explicit 'var level: LevelEntry = ...'.
  Global.database is typed RefCounted so the parser can't see DB's
  return types through the walrus operator. Two callsites.
- scripts/Database.gd: annotate the two 'range(data.size() / W)'
  loops with @warning_ignore('integer_division'). The division is
  intentional (row count = bytes / row width); Godot 4 warns by
  default in case the slash was a typo.
- env: ambient_light_energy 0.4 -> 1.0 in WarCraft.tscn, Home.tscn
  and env_warcraft.tres. 0.4 left the floor pitch-black; 1.0 is a
  compromise between the original 1.55 (oversaturated) and this.
  Re-baking the lightmap in the editor is still the right fix —
  this commit just keeps the scene playable in the meantime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-16 22:02:59 +02:00
Vaillant Jeremy c17769246f Replace M* table-wrapper classes with typed Resources; add type hints
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>
2026-05-16 21:58:11 +02:00
Vaillant Jeremy ec906117bb Replace godot_db_manager plugin with native DB, port lod plugin
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>
2026-05-16 19:21:09 +02:00
darknight fcff613a93 bugfix/android-database (#78)
Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com>
Reviewed-on: Athena/game-source#78
Co-authored-by: darknight <vaillant.jeremy@dev-crea.com>
Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
2021-06-06 18:54:25 +02:00
darknight 0debe0d2d3 feature/update-main-ui (#66)
Co-authored-by: stilobique-i7 <aurelienvlt@free.fr>
Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com>
Reviewed-on: Athena/game-source#66
Co-authored-by: darknight <vaillant.jeremy@dev-crea.com>
Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
2021-06-03 22:18:50 +02:00