]> Untitled Git - wolf-seeking-sheep.git/blob - assets/phone/dating_app_profile.gd
Squashed commit of the following:
[wolf-seeking-sheep.git] / assets / phone / dating_app_profile.gd
1 @tool
2 class_name DatingProfileControl
3 extends Control
4
5
6 static var _details_format_str: String = "[b]%s[/b]    [font_size=45]%s[/font_size]"
7 static var _bullet_format_str: String = "• %s"
8 static var _distance_format_str: String = "%s miles away"
9
10
11 @export var profile: DatingProfile:
12         set(p):
13                 if profile != null:
14                         profile.changed.disconnect(_on_profile_changed)
15                 profile = p
16                 profile.changed.connect(_on_profile_changed)
17                 _on_profile_changed()
18
19
20 func _on_profile_changed():
21         # TODO: why aren't these unique names instantiated at the start?
22         if get_node_or_null("%details") == null:
23                 return
24                 
25         if profile == null:
26                 %pic.texture = null
27                 %details.text = ""
28                 %blurb.text = ""
29                 return
30                 
31         %pic.texture = profile.pic
32         var details: Array[String] = []
33         details.append(_details_format_str % [profile.name, profile.age])
34         for detail: String in [profile.job, profile.education]:
35                 if not detail.is_empty():
36                         details.append(_bullet_format_str % detail)
37         details.append(_bullet_format_str % (_distance_format_str % profile.distance_away))
38         %details.text = "\n".join(details)
39         %blurb.text = profile.bio