This commit is contained in:
2026-03-04 22:52:02 -08:00
parent a675902d72
commit a2eb4de815
6 changed files with 59 additions and 24 deletions

View File

@@ -28,7 +28,7 @@ scale = Vector2(0.783, 0.78)
texture = ExtResource("2_u8g8b")
```
The texture path references an ext_resource pointing to the background image.
The texture path references an ext_resource pointing to the background image. **Use this path for mask extraction, NOT pic_XXX_visual.png.** The .tscn references the AI-generated caption image which is what should be used.
### 2. Verify Entity Visibility
@@ -50,12 +50,14 @@ Use `tools/extract_mask.py` to generate the mask:
```bash
python tools/extract_mask.py "the [entity]" \
scenes/kq4_XXX_room/background.png \
scenes/kq4_XXX_room/caption_XXX_generated.png \
/tmp/[entity]_mask.png
```
**Subject phrasing:** Use descriptive phrasing like "the door of the ogre's cottage" for better results.
**CRITICAL:** Always use the background image path from the .tscn file (e.g., `caption_3_840023845_generated.png`), NOT `pic_XXX_visual.png`. The .tscn shows which image is actually used in-game.
### 4. Generate Polygon Resource
Use `tools/mask_to_polygon.py` to create the .tres file:

View File

@@ -31,7 +31,7 @@ signal looked
signal touched
signal talked
signal entered(lab)
signal exited
signal exited(lab)
@export var label: String
@export var points_resource: PolygonPointsResource:
@@ -52,7 +52,7 @@ func _process(delta):
emit_signal("entered", label)
else:
if is_in == true:
emit_signal("exited")
emit_signal("exited", label)
is_in = false

View File

@@ -1,20 +1,20 @@
extends Node2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var hovered_setpieces: Array[String] = []
@onready var label : Label = $"label"
func _ready():
_connect_setpieces(get_parent())
func _on_transitioned(s):
hovered_setpieces.clear()
$label.hide()
_connect_setpieces(get_parent())
func _connect_setpieces(scene: Node) -> void:
for n in scene.find_children("*", "SetPiece"):
for n in scene.find_children("*", "SetPiece", true, false):
print("LOOKING AT", n)
n.connect("entered", Callable(self, "_on_setpiece_entered"))
n.connect("exited", Callable(self, "_on_setpiece_exited"))
@@ -64,20 +64,33 @@ func _process(delta):
var s = label.size
mouse_pos.x = clamp(mouse_pos.x, cam_top_left.x + margin, cam_bottom_right.x - label.size.x - margin)
mouse_pos.y = clamp(mouse_pos.y, cam_top_left.y, cam_bottom_right.y)
if $label.visible:
print("LABEL VISIBLE", $label.text)
# Update label position
global_position = mouse_pos
func _on_setpiece_entered(lab):
print("LABEL ENTERED ", lab)
$label.show()
$label.text = lab
func _on_setpiece_entered(lab: String) -> void:
if lab not in hovered_setpieces:
hovered_setpieces.append(lab)
_update_label()
func _on_setpiece_exited(lab: String) -> void:
hovered_setpieces.erase(lab)
_update_label()
func _update_label() -> void:
if hovered_setpieces.is_empty():
$label.hide()
return
var size = label.label_settings.font.get_string_size(lab,HORIZONTAL_ALIGNMENT_LEFT,200,32)
var top_label = hovered_setpieces[0]
$label.show()
$label.text = top_label
var size = label.label_settings.font.get_string_size(top_label, HORIZONTAL_ALIGNMENT_LEFT, 200, 32)
label.size = size
func _on_setpiece_exited():
$label.hide()
pass # Replace with function body.

View File

@@ -4,13 +4,13 @@
[ext_resource type="Texture2D" uid="uid://nb7ybebcy6ok" path="res://scenes/kq4_003_fountain_pool/caption_1_2884713022_generated.png" id="2_ev2w4"]
[ext_resource type="Script" uid="uid://xmphq3i0wbg3" path="res://ScalePoint_.gd" id="3_1g2ot"]
[ext_resource type="PackedScene" uid="uid://c4vc1wx7k6cw" path="res://TransitionPiece.tscn" id="4_6r684"]
[ext_resource type="Resource" path="res://scenes/kq4_003_fountain_pool/pool_shap2.tres" id="4_nuxlg"]
[ext_resource type="Resource" uid="uid://biiu4g5skgjun" path="res://scenes/kq4_003_fountain_pool/pool_shap2.tres" id="4_nuxlg"]
[ext_resource type="Texture2D" uid="uid://bmvcn5pl2qble" path="res://scenes/kq4_003_fountain_pool/fg.png" id="5_cu368"]
[ext_resource type="Resource" path="res://scenes/kq4_003_fountain_pool/columns_0.tres" id="6_7gmu8"]
[ext_resource type="Resource" uid="uid://bu8vcjwarqsym" path="res://scenes/kq4_003_fountain_pool/columns_0.tres" id="6_7gmu8"]
[ext_resource type="Script" uid="uid://bounwnqg34t5k" path="res://SetPiece_.gd" id="6_n67q9"]
[ext_resource type="Resource" path="res://scenes/kq4_003_fountain_pool/columns_1.tres" id="7_hj5s8"]
[ext_resource type="Resource" path="res://scenes/kq4_003_fountain_pool/columns_2.tres" id="8_1m5ii"]
[ext_resource type="Resource" path="res://scenes/kq4_003_fountain_pool/columns_3.tres" id="9_s7130"]
[ext_resource type="Resource" uid="uid://byjfu6q8wx5vn" path="res://scenes/kq4_003_fountain_pool/columns_1.tres" id="7_hj5s8"]
[ext_resource type="Resource" uid="uid://dv2fngjcedsrt" path="res://scenes/kq4_003_fountain_pool/columns_2.tres" id="8_1m5ii"]
[ext_resource type="Resource" uid="uid://ufmqd22by6sj" path="res://scenes/kq4_003_fountain_pool/columns_3.tres" id="9_s7130"]
[sub_resource type="NavigationPolygon" id="NavigationPolygon_heq0u"]
vertices = PackedVector2Array(2047.41, 716.57, 2016.32, 718.031, 2012.05, 588.461, 2016.21, 588.297, -24.7109, 554.789, -30.1563, 678.656, -32.4922, 678.719, -26.5, 554.672, 1549.08, 973.094, 1600.39, 892.133, 1664.59, 879.789, 1849.6, 912.438, 2010.65, 1152.71, 1938.66, 866.219, 1997.01, 738.961, 1913.5, 767.961, 1652.01, 755.148, 1694.65, 795.859, 1548.2, 566.008, 1990.35, 536.656, 1991.42, 569.242, 1521.82, 587.352, -3.86719, 536.156, -3.4375, 526.25, 1322.68, 566.07, 572.727, 554.938, -28.5625, 1097.27, -11.0078, 698.188, 363.648, 688.758, 233.078, 917.219, 522.023, 998.82, 544.961, 937, 1256.86, 937, 1356.66, 1006.56, 1515.53, 657.82, 368.352, 561.688, 319.969, 1004.11)
@@ -19,10 +19,10 @@ outlines = Array[PackedVector2Array]([PackedVector2Array(-13, 516, 1548, 556, 20
[node name="background" type="Node2D" unique_id=47039231]
y_sort_enabled = true
scale = Vector2(0.77, 0.77)
script = ExtResource("1_heq0u")
[node name="bg" type="Sprite2D" parent="." unique_id=56586945]
scale = Vector2(0.78, 0.78)
texture = ExtResource("2_ev2w4")
centered = false
@@ -49,6 +49,7 @@ position = Vector2(-150, 100)
polygon = PackedVector2Array(-108, 454, -87, 649, 376, 658, 348, 381)
appear_at_node = "kq4_003_fountain_pool"
target = "uid://1489d4oh9twtu"
label = "Meadow"
[node name="entrance" parent="kq4_002_meadow" index="0"]
position = Vector2(350, 500)
@@ -62,6 +63,7 @@ color = Color(1, 1, 1, 1)
polygon = PackedVector2Array(-235, -142, -147, 252, 155, 148, 102, -85)
appear_at_node = "kq4_003_fountain_pool"
target = "uid://1nxmm3b1kcdm1"
label = "Ogre's Cottage"
[node name="entrance" parent="kq4_004_ogres_cottage" index="0"]
position = Vector2(-79, 65)
@@ -74,6 +76,7 @@ position = Vector2(910, 542)
polygon = PackedVector2Array(-108, 454, -87, 649, 376, 658, 348, 381)
appear_at_node = "kq4_003_fountain_pool"
target = "uid://1hkplw2a78b1y"
label = "Shady Wooded Forest"
[node name="entrance" parent="kq4_009_shady_wooded_area" index="0"]
position = Vector2(118, 514)

View File

@@ -15,3 +15,9 @@ func _on_beach_2_interacted() -> void:
func _on_open_ocean_interacted() -> void:
$west_exit.default_script(self)
func _on_fishermans_house_looked() -> void:
start_main_script(ScriptBuilder.init(
ScriptBuilder.say(ego, "The fisherman's shack looks badly in need of repair, as the sun, wind, and salt spray have taken their toll. From the house, an old pier leads out into the ocean.")
).build(self, "_on_script_complete"))

View File

@@ -4,6 +4,8 @@
[ext_resource type="Texture2D" uid="uid://djbrg233lxgyy" path="res://scenes/kq4_007_fishermans_shack/caption_3_840023845_generated.png" id="2_86g5m"]
[ext_resource type="Script" uid="uid://xmphq3i0wbg3" path="res://ScalePoint_.gd" id="3_abc"]
[ext_resource type="PackedScene" uid="uid://c4vc1wx7k6cw" path="res://TransitionPiece.tscn" id="4_abc"]
[ext_resource type="Resource" uid="uid://bbepaofrwlurc" path="res://scenes/kq4_007_fishermans_shack/fishermans_house_polygon.tres" id="5_house"]
[ext_resource type="Script" uid="uid://bounwnqg34t5k" path="res://SetPiece_.gd" id="6_setpiece"]
[sub_resource type="NavigationPolygon" id="NavigationPolygon_ppo6b"]
vertices = PackedVector2Array(366.85156, 1243.1484, -140.97656, 1182.2422, -76.0625, 588.09375, -30.171875, 216.07031, 1221.4063, 226.97656, 1994.1406, 468.39844, 2011.7969, 1321.9766, 1052.7422, 1419.8672, -76.0625, 588.0781)
@@ -86,9 +88,18 @@ position = Vector2(506, 555)
[node name="exit" parent="west_exit" index="1"]
position = Vector2(-64, 534)
[node name="fishermans_house" type="Polygon2D" parent="." unique_id=1687430893 groups=["set-piece"]]
scale = Vector2(0.78, 0.78)
color = Color(0.5, 0.5, 0.5, 0.25)
polygon = PackedVector2Array(2269, 245, 2339, 677, 2243, 911, 1467.9487, 988.46155, 1102.5641, 748.71796, 1344.8718, 153.84616, 2052, 78)
script = ExtResource("6_setpiece")
label = "Fisherman's House"
points_resource = ExtResource("5_house")
[connection signal="interacted" from="kq4_001_beach" to="." method="_on_beach_interacted"]
[connection signal="interacted" from="kq4_008_back_of_fishermans_shack" to="." method="_on_back_of_fishermans_shack_interacted"]
[connection signal="interacted" from="kq4_013_beach" to="." method="_on_beach_2_interacted"]
[connection signal="looked" from="fishermans_house" to="." method="_on_fishermans_house_looked"]
[editable path="kq4_001_beach"]
[editable path="kq4_008_back_of_fishermans_shack"]