4d5db7bb61
Catch-all commit for everything the --convert-3to4 tool missed during a
manual playtest of the game. All errors raised by clicking through Main
-> Puzzles -> level were fixed.
GDScript:
- PackedScene.instance() -> instantiate() (ChooseScene.gd)
- String(x) constructor doesn't exist -> str(x) (MBase, MScene,
MLevel, Animation, Levels)
- 'x as int/String/bool' doesn't parse strings -> explicit
int()/str()/bool(int()) (MScene, MLevel, MSetting)
- BaseButton.pressed (property) -> button_pressed; set_pressed() ->
direct assignment (Settings.gd)
- AnimationPlayer.add_animation() removed -> go through
AnimationLibrary (Levels.gd)
- PhysicsDirectSpaceState3D.intersect_ray(from, to, ...) ->
PhysicsRayQueryParameters3D.create() (Levels.gd)
- @export with type-hint-in-comment ('# (String, ...)') -> explicit
@export_enum (candle.gd)
- Get effective material with get_active_material() instead of
get_surface_override_material(), with null guard (Levels.gd)
- get_node() -> get_node_or_null() so missing items from ahog.json
(e.g. sm_super_dager in Home) don't crash (Levels.gd)
Scenes/resources:
- Remove 14 Tween nodes from WarCraft.tscn — Tween is no longer a
Node in Godot 4. Rewrite Animation.start_dissolve to use
create_tween().tween_method().
- Rename property material/N -> surface_material_override/N in every
.tscn (10 files) — Godot 3 -> 4 rename that --convert-3to4 missed.
Without this, MeshInstance3D.get_active_material(0) returned the
glTF-imported StandardMaterial3D instead of the project's custom
dissolve ShaderMaterial.
Shaders:
- One-shot scripts/migrate_shaders.gd walks every .material under
assets/ and fixes Godot 3 -> 4 shader code in-place. Fixed 17
materials: depth_draw_alpha_prepass -> depth_prepass_alpha,
hint_color -> source_color, NORMALMAP -> NORMAL_MAP.
Result: Main, Settings, ChooseScene, and the WarCraft level all run
without script or shader errors. Remaining noise is non-blocking
(visual_shader graph in text_outline.material, baked lightmap binary
format from Godot 3, and empty animation tracks).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
71 lines
2.4 KiB
GDScript
71 lines
2.4 KiB
GDScript
extends Control
|
|
|
|
@export var template: PackedScene = load("res://scenes/UI/choose_scenes/parts/Template.tscn")
|
|
|
|
func _ready():
|
|
_load_button_access_scenes()
|
|
|
|
## PRIVATE
|
|
func _load_button_access_scenes():
|
|
for row_index in range(0, Global.database.get_table_by_name("levels").m_rows_count):
|
|
_apply_scene(load("res://db/MLevel.gd").new(row_index), row_index)
|
|
|
|
func _apply_scene(level, index):
|
|
$MarginContainer.add_child(_load_scene(level.name()))
|
|
var node = _build_path(level.name())
|
|
|
|
_configure_select(level, node)
|
|
configure_reset(level, node, index, false)
|
|
configure_counter(level, node)
|
|
|
|
func _load_scene(name):
|
|
var template_instance = template.instantiate()
|
|
template_instance.set_name(name)
|
|
|
|
return template_instance
|
|
|
|
func _build_path(name):
|
|
return "MarginContainer/"+name
|
|
|
|
func _build_method(name):
|
|
return "_on_"+name.to_lower()+"_pressed"
|
|
|
|
func _load_texture(thumbnail):
|
|
return load(thumbnail)
|
|
|
|
func _configure_select(level, node):
|
|
var selector = get_node(node+"/MarginContainer/CenterAlign/MainButton")
|
|
var thumbnail = get_node(node+"/MarginContainer/CenterAlign/MainButton/MarginStich/ThumbnailLevel")
|
|
|
|
thumbnail.set_texture(_load_texture(level.thumbnail()))
|
|
selector.connect("pressed", Callable(Event, _build_method(level.name())))
|
|
|
|
func configure_reset(level, node, index, animate):
|
|
var reset = get_node(node+"/MarginContainer/CenterAlign/MainButton/TabAlign/ButtonReset")
|
|
var animation = get_node(node+"/AnimationPlayer")
|
|
if int(level.object_finding()) == 0:
|
|
_configure_reset_disable(animation, reset, animate)
|
|
else:
|
|
_configure_reset_enable(animation, reset, level, node, index)
|
|
|
|
func _configure_reset_disable(animation, reset, animate = false):
|
|
animation.play("SlideReset")
|
|
if !animate:
|
|
animation.seek(1, false)
|
|
|
|
reset.set_disabled(true)
|
|
reset.set_default_cursor_shape(CURSOR_ARROW)
|
|
if reset.is_connected("pressed", Callable(Event, "_on_reset_level")):
|
|
reset.disconnect("pressed", Callable(Event, "_on_reset_level"))
|
|
|
|
func _configure_reset_enable(animation, reset, level, node, index):
|
|
animation.play_backwards("SlideReset")
|
|
reset.set_disabled(false)
|
|
reset.set_default_cursor_shape(CURSOR_POINTING_HAND)
|
|
reset.connect("pressed", Callable(Event, "_on_reset_level").bind(level, node, index, self))
|
|
|
|
func configure_counter(level, node):
|
|
var count = get_node(node+"/MarginContainer/CenterAlign/MainButton/TabAlign/ButtonCount/MarginBottom/Label")
|
|
|
|
count.set_text(level.object_finding()+" / "+level.object_to_find())
|